Skip to content

Commit

Permalink
fix: require From when snoozing an incident
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Oct 4, 2024
1 parent 8ceedfd commit 9bce536
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions incident.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,17 +544,20 @@ func (c *Client) CreateIncidentNote(id string, note IncidentNote) error {
// period of time.
//
// Deprecated: Use SnoozeIncidentWithContext instead.
func (c *Client) SnoozeIncidentWithResponse(id string, duration uint) (*Incident, error) {
return c.SnoozeIncidentWithContext(context.Background(), id, duration)
func (c *Client) SnoozeIncidentWithResponse(id, from string, duration uint) (*Incident, error) {
return c.SnoozeIncidentWithContext(context.Background(), id, from, duration)
}

// SnoozeIncidentWithContext sets an incident to not alert for a specified period of time.
func (c *Client) SnoozeIncidentWithContext(ctx context.Context, id string, duration uint) (*Incident, error) {
d := map[string]uint{
func (c *Client) SnoozeIncidentWithContext(ctx context.Context, id, from string, duration uint) (*Incident, error) {
headers := map[string]string{
"from": from,
}
body := map[string]uint{
"duration": duration,
}

resp, err := c.post(ctx, "/incidents/"+id+"/snooze", d, nil)
resp, err := c.post(ctx, "/incidents/"+id+"/snooze", body, headers)
if err != nil {
return nil, err
}
Expand All @@ -570,10 +573,13 @@ func (c *Client) SnoozeIncidentWithContext(ctx context.Context, id string, durat
// SnoozeIncident sets an incident to not alert for a specified period of time.
//
// Deprecated: Use SnoozeIncidentWithContext instead.
func (c *Client) SnoozeIncident(id string, duration uint) error {
func (c *Client) SnoozeIncident(id, from string, duration uint) error {
headers := make(map[string]string)
headers["from"] = from
data := make(map[string]uint)
data["duration"] = duration
_, err := c.post(context.Background(), "/incidents/"+id+"/snooze", data, nil)

_, err := c.post(context.Background(), "/incidents/"+id+"/snooze", data, headers)
return err
}

Expand Down

0 comments on commit 9bce536

Please sign in to comment.