Skip to content

CLOUDP-57846: List global alerts in mongocli #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 25, 2020
Merged

Conversation

andreaangiolillo
Copy link
Collaborator

Jira ticket: CLOUDP-57846

Checklist

  • I have signed the MongoDB CLA
  • I have added tests that prove my fix is effective or that my feature works
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • I have tested my solution with my local OM

Further comments

./bin/mongocli om alerts global list --profile OPS

{
	"links": [
		{
			"rel": "self",
			"href": "http://localhost:9080/api/public/v1.0/globalAlerts?pageNum=1\u0026itemsPerPage=100"
		}
	],
	"results": [
		{
			"id": "5e7b354f2e676a3d207a845c",
			"groupId": "5e7b34822e676a3d207a8399",
			"alertConfigId": "5e7b35292e676a3d207a8431",
			"eventTypeName": "USERS_WITHOUT_MULTI_FACTOR_AUTH",
			"created": "2020-03-25T10:41:19Z",
			"updated": "2020-03-25T10:53:28Z",
			"status": "OPEN",
			"lastNotified": "2020-03-25T10:41:28Z",
			"acknowledgedUntil": "2020-11-01T03:59:28Z",
			"acknowledgementComment": "TEST",
			"acknowledgingUsername": "ydxjuumo",
			"links": [
				{
					"rel": "self",
					"href": "http://localhost:9080/api/public/v1.0/globalAlerts/5e7b354f2e676a3d207a845c"
				}
			]
		}
	],
	"totalCount": 1
}

@andreaangiolillo andreaangiolillo added the WIP Work in progress label Mar 25, 2020
@andreaangiolillo andreaangiolillo requested a review from gssbzn March 25, 2020 14:06
@andreaangiolillo andreaangiolillo removed the WIP Work in progress label Mar 25, 2020
Copy link
Collaborator

@gssbzn gssbzn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small question and one small change but looks great

}

func (opts *opsManagerAlertsGlobalListOpts) Run() error {
alertOpts := om.AlertsListOptions{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] what about pagination?
[nit] you could also do &om.AlertsListOptions{ here and not do the & on line 42

// GlobalAlerts encapsulate the logic to manage different cloud providers
func (s *Store) GlobalAlerts(opts *om.AlertsListOptions) (*om.GlobalAlerts, error) {
switch s.service {
case config.OpsManagerService, config.CloudManagerService:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is config.OpsManagerService only so you may need to remove config.CloudManagerService

@andreaangiolillo andreaangiolillo requested a review from gssbzn March 25, 2020 14:41
Copy link
Collaborator

@gssbzn gssbzn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

func (opts *opsManagerAlertsGlobalListOpts) Run() error {
alertOpts := &om.AlertsListOptions{
Status: opts.status,
ListOptions: mongodbatlas.ListOptions{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just as FYI (no need for any change here) you can also do

alertOpts := &om.AlertsListOptions{}
alertOpts.PageNum = opts.pageNum

go has automatic delegation for embedded structs, this is just style and there's no advantage of one over the other, so just letting you know

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also for future work, we should do with pagination what we did with delete that we embed a struct with the common things that all paginated resources do

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will create the activity on Jira

@andreaangiolillo andreaangiolillo merged commit 40016ce into master Mar 25, 2020
@andreaangiolillo andreaangiolillo deleted the CLOUDP-57846 branch March 25, 2020 16:11
corryroot pushed a commit to corryroot/mongodb-atlas-cli that referenced this pull request Jun 15, 2023
DOCSP-24941 Add support for Chocholatey to the installation options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants