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 SearchMonitors to monitors.go #325

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions datadog-accessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -14150,37 +14150,6 @@ func (m *Monitor) SetOverallState(v string) {
m.OverallState = &v
}

// GetOverallStateModified returns the OverallStateModified field if non-nil, zero value otherwise.
func (m *Monitor) GetOverallStateModified() string {
if m == nil || m.OverallStateModified == nil {
return ""
}
return *m.OverallStateModified
}

// GetOverallStateModifiedOk returns a tuple with the OverallStateModified field if it's non-nil, zero value otherwise
// and a boolean to check if the value has been set.
func (m *Monitor) GetOverallStateModifiedOk() (string, bool) {
if m == nil || m.OverallStateModified == nil {
return "", false
}
return *m.OverallStateModified, true
}

// HasOverallStateModified returns a boolean if a field has been set.
func (m *Monitor) HasOverallStateModified() bool {
if m != nil && m.OverallStateModified != nil {
return true
}

return false
}

// SetOverallStateModified allocates a new m.OverallStateModified and returns the pointer to it.
func (m *Monitor) SetOverallStateModified(v string) {
m.OverallStateModified = &v
}

// GetQuery returns the Query field if non-nil, zero value otherwise.
func (m *Monitor) GetQuery() string {
if m == nil || m.Query == nil {
Expand Down
34 changes: 23 additions & 11 deletions monitors.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,17 @@ type State struct {
// Monitor allows watching a metric or check that you care about,
// notifying your team when some defined threshold is exceeded
type Monitor struct {
Creator *Creator `json:"creator,omitempty"`
Id *int `json:"id,omitempty"`
Type *string `json:"type,omitempty"`
Query *string `json:"query,omitempty"`
Name *string `json:"name,omitempty"`
Message *string `json:"message,omitempty"`
OverallState *string `json:"overall_state,omitempty"`
OverallStateModified *string `json:"overall_state_modified,omitempty"`
Tags []string `json:"tags"`
Options *Options `json:"options,omitempty"`
State State `json:"state,omitempty"`
Creator *Creator `json:"creator,omitempty"`
Id *int `json:"id,omitempty"`
Type *string `json:"type,omitempty"`
Query *string `json:"query,omitempty"`
Name *string `json:"name,omitempty"`
Message *string `json:"message,omitempty"`
OverallState *string `json:"overall_state,omitempty"`
OverallStateModified interface{} `json:"overall_state_modified,omitempty"`
Tags []string `json:"tags"`
Options *Options `json:"options,omitempty"`
State State `json:"state,omitempty"`
}

// Creator contains the creator of the monitor
Expand Down Expand Up @@ -262,6 +262,18 @@ func (client *Client) GetMonitorsWithOptions(opts MonitorQueryOpts) ([]Monitor,
return out.Monitors, nil
}

// SearchMonitors retrieves monitors by a slice of notifications
func (client *Client) SearchMonitors(query string) ([]Monitor, error) {
var out reqMonitors

err := client.doJsonRequest("GET", fmt.Sprintf("/v1/monitor/search?query=%v", query), nil, &out)
if err != nil {
return nil, err
}

return out.Monitors, nil
}

// MuteMonitors turns off monitoring notifications
func (client *Client) MuteMonitors() error {
return client.doJsonRequest("POST", "/v1/monitor/mute_all", nil, nil)
Expand Down