diff --git a/alerts.go b/alerts.go index 228b27e..2b44d51 100644 --- a/alerts.go +++ b/alerts.go @@ -42,6 +42,7 @@ type Alert struct { Reason string `json:"reason,omitempty"` OpenedAt int64 `json:"openedAt,omitempty"` ClosedAt int64 `json:"closedAt,omitempty"` + Memo string `json:"memo,omitempty"` } // AlertsResp includes alert and next id @@ -50,6 +51,12 @@ type AlertsResp struct { NextID string `json:"nextId,omitempty"` } +type UpdateAlertParan struct { + Memo string `json:"memo,omitempty"` +} + +type UpdateAlertResponse = UpdateAlertParan + func (c *Client) findAlertsWithParam(v url.Values) (*AlertsResp, error) { var d AlertsResp u := c.urlFor("/api/v0/alerts") @@ -138,3 +145,20 @@ func (c *Client) CloseAlert(alertID string, reason string) (*Alert, error) { return data, nil } + +// UpdateAlert updates a Alert +func (c *Client) UpdateAlert(alertID string, param UpdateAlertParan) (*UpdateAlertResponse, error) { + resp, err := c.PutJSON(fmt.Sprintf("/api/v0/alerts/%s", alertID), param) + defer closeResponse(resp) + if err != nil { + return nil, err + } + + var data = UpdateAlertResponse{} + err = json.NewDecoder(resp.Body).Decode(&data) + if err != nil { + return nil, err + } + + return &data, nil +}