@@ -9,16 +9,45 @@ import (
99)
1010
1111type AlertNotification struct {
12- Id int64 `json:"id,omitempty"`
13- Name string `json:"name"`
14- Type string `json:"type"`
15- IsDefault bool `json:"isDefault"`
16- Settings interface {} `json:"settings"`
12+ Id int64 `json:"id,omitempty"`
13+ Uid string `json:"uid"`
14+ Name string `json:"name"`
15+ Type string `json:"type"`
16+ IsDefault bool `json:"isDefault"`
17+ DisableResolveMessage bool `json:"disableResolveMessage"`
18+ SendReminder bool `json:"sendReminder"`
19+ Frequency string `json:"frequency"`
20+ Settings interface {} `json:"settings"`
21+ }
22+
23+ func (c * Client ) AlertNotifications () ([]AlertNotification , error ) {
24+ alertnotifications := make ([]AlertNotification , 0 )
25+
26+ req , err := c .newRequest ("GET" , "/api/alert-notifications/" , nil , nil )
27+ if err != nil {
28+ return nil , err
29+ }
30+
31+ resp , err := c .Do (req )
32+ if err != nil {
33+ return nil , err
34+ }
35+ if resp .StatusCode != 200 {
36+ return nil , errors .New (resp .Status )
37+ }
38+
39+ data , err := ioutil .ReadAll (resp .Body )
40+ if err != nil {
41+ return nil , err
42+ }
43+
44+ err = json .Unmarshal (data , & alertnotifications )
45+ return alertnotifications , err
1746}
1847
1948func (c * Client ) AlertNotification (id int64 ) (* AlertNotification , error ) {
2049 path := fmt .Sprintf ("/api/alert-notifications/%d" , id )
21- req , err := c .newRequest ("GET" , path , nil )
50+ req , err := c .newRequest ("GET" , path , nil , nil )
2251 if err != nil {
2352 return nil , err
2453 }
@@ -46,7 +75,7 @@ func (c *Client) NewAlertNotification(a *AlertNotification) (int64, error) {
4675 if err != nil {
4776 return 0 , err
4877 }
49- req , err := c .newRequest ("POST" , "/api/alert-notifications" , bytes .NewBuffer (data ))
78+ req , err := c .newRequest ("POST" , "/api/alert-notifications" , nil , bytes .NewBuffer (data ))
5079 if err != nil {
5180 return 0 , err
5281 }
@@ -77,7 +106,7 @@ func (c *Client) UpdateAlertNotification(a *AlertNotification) error {
77106 if err != nil {
78107 return err
79108 }
80- req , err := c .newRequest ("PUT" , path , bytes .NewBuffer (data ))
109+ req , err := c .newRequest ("PUT" , path , nil , bytes .NewBuffer (data ))
81110 if err != nil {
82111 return err
83112 }
@@ -95,7 +124,7 @@ func (c *Client) UpdateAlertNotification(a *AlertNotification) error {
95124
96125func (c * Client ) DeleteAlertNotification (id int64 ) error {
97126 path := fmt .Sprintf ("/api/alert-notifications/%d" , id )
98- req , err := c .newRequest ("DELETE" , path , nil )
127+ req , err := c .newRequest ("DELETE" , path , nil , nil )
99128 if err != nil {
100129 return err
101130 }
0 commit comments