Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

Commit

Permalink
Retrieve all recipients available for notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
tbroden84 committed Feb 15, 2020
1 parent 1515dd4 commit 8ef2704
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions api/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ func (api *API) ReadNotification(instance_id int, id string) (map[string]interfa
return data, err
}

func (api *API) ReadNotifications(instance_id int) ([]map[string]interface{}, error) {
var data []map[string]interface{}
failed := make(map[string]interface{})
log.Printf("[DEBUG] go-api::ReadNotifications::read instance id: %v", instance_id)
path := fmt.Sprintf("/api/instances/%d/alarms/recipients", instance_id)
response, err := api.sling.New().Path(path).Receive(&data, &failed)
log.Printf("[DEBUG] go-api::ReadNotifications::read data: %v", data)

if err != nil {
return nil, err
}
if response.StatusCode != 200 {
return nil, errors.New(fmt.Sprintf("ReadNotifications failed, status: %v, message: %s", response.StatusCode, failed))
}

return data, err
}

func (api *API) UpdateNotification(instance_id int, params map[string]interface{}) error {
failed := make(map[string]interface{})
log.Printf("[DEBUG] go-api::notification::update instance id: %v, params: %v", instance_id, params)
Expand Down

0 comments on commit 8ef2704

Please sign in to comment.