-
Notifications
You must be signed in to change notification settings - Fork 33
/
alert_group_settings.go
49 lines (42 loc) · 1.93 KB
/
alert_group_settings.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package mackerel
import "fmt"
// AlertGroupSetting represents a Mackerel alert group setting.
// ref. https://mackerel.io/api-docs/entry/alert-group-settings
type AlertGroupSetting struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
Memo string `json:"memo,omitempty"`
ServiceScopes []string `json:"serviceScopes,omitempty"`
RoleScopes []string `json:"roleScopes,omitempty"`
MonitorScopes []string `json:"monitorScopes,omitempty"`
NotificationInterval uint64 `json:"notificationInterval,omitempty"`
}
// FindAlertGroupSettings finds alert group settings.
func (c *Client) FindAlertGroupSettings() ([]*AlertGroupSetting, error) {
data, err := requestGet[struct {
AlertGroupSettings []*AlertGroupSetting `json:"alertGroupSettings"`
}](c, "/api/v0/alert-group-settings")
if err != nil {
return nil, err
}
return data.AlertGroupSettings, nil
}
// CreateAlertGroupSetting creates an alert group setting.
func (c *Client) CreateAlertGroupSetting(param *AlertGroupSetting) (*AlertGroupSetting, error) {
return requestPost[AlertGroupSetting](c, "/api/v0/alert-group-settings", param)
}
// GetAlertGroupSetting gets an alert group setting.
func (c *Client) GetAlertGroupSetting(id string) (*AlertGroupSetting, error) {
path := fmt.Sprintf("/api/v0/alert-group-settings/%s", id)
return requestGet[AlertGroupSetting](c, path)
}
// UpdateAlertGroupSetting updates an alert group setting.
func (c *Client) UpdateAlertGroupSetting(id string, param *AlertGroupSetting) (*AlertGroupSetting, error) {
path := fmt.Sprintf("/api/v0/alert-group-settings/%s", id)
return requestPut[AlertGroupSetting](c, path, param)
}
// DeleteAlertGroupSetting deletes an alert group setting.
func (c *Client) DeleteAlertGroupSetting(id string) (*AlertGroupSetting, error) {
path := fmt.Sprintf("/api/v0/alert-group-settings/%s", id)
return requestDelete[AlertGroupSetting](c, path)
}