Skip to content
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

Add full param options for monitors #180

Closed
wants to merge 2 commits into from

Conversation

Seanstoppable
Copy link
Contributor

Add a more generic function that will let people mix and match
Have existing functions wrap this better function
Resolves the rest of state support in #164

@ojongerius
Copy link
Collaborator

Thanks @Seanstoppable ! If you pull 0a5d6ca your build should go green. I'll review when I've got some spare time.

Add a more generic function that will let people mix and match
Have existing functions wrap this better function
Resolves the rest of state support in zorkian#164
@Seanstoppable
Copy link
Contributor Author

Great, thanks @ojongerius

monitors.go Outdated
// https://docs.datadoghq.com/api/?lang=bash#get-all-monitor-details
type MonitorQueryOpts struct {
GroupStates []string
Name string
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be a pointer, ie: *string

monitors.go Outdated
query = append(query, value)
}

if opts.WithDowntimes != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Up to you but you could use the generated GetWithDownTimesOk like so:

if v, ok := opts.GetWithDowntimesOk; ok {
    query = append(query, fmt.Sprintf("name=%t", strings.Join(v, ",")))
}

monitors.go Outdated
query = append(query, value)
}

if opts.Name != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Works at the moment but needs to be changed either manually test if not nil if you refactor Name to be a pointer. Alternatively you can use the autogenereated getters and setters like so:

if v, ok := opts.GetNameOk; ok {
    query = append(query, fmt.Sprintf("name=%v", strings.Join(v, ",")))
}

@Seanstoppable
Copy link
Contributor Author

@ojongerius apologies for the delay. Updated with feedback, thanks!

@ojongerius
Copy link
Collaborator

@Seanstoppable sorry I've been swamped with work, could you please resolve conflicts so I can merge this?

@Seanstoppable
Copy link
Contributor Author

Closing in favor of #199

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants