| 1222 | } |
| 1223 | |
| 1224 | func (c *Client) DeleteSilence(ctx context.Context, id string) error { |
| 1225 | u := c.alertmanagerClient.URL(fmt.Sprintf("api/prom/api/v2/silence/%s", url.PathEscape(id)), nil) |
| 1226 | |
| 1227 | req, err := http.NewRequest(http.MethodDelete, u.String(), nil) |
| 1228 | if err != nil { |
| 1229 | return fmt.Errorf("error creating request: %v", err) |
| 1230 | } |
| 1231 | |
| 1232 | resp, body, err := c.alertmanagerClient.Do(ctx, req) |
| 1233 | if err != nil { |
| 1234 | return err |
| 1235 | } |
| 1236 | |
| 1237 | if resp.StatusCode == http.StatusNotFound { |
| 1238 | return ErrNotFound |
| 1239 | } |
| 1240 | |
| 1241 | if resp.StatusCode != http.StatusOK { |
| 1242 | return fmt.Errorf("deleting silence failed with status %d and error %v", resp.StatusCode, string(body)) |
| 1243 | } |
| 1244 | |
| 1245 | return nil |
| 1246 | } |
| 1247 | |
| 1248 | func (c *Client) GetReceivers(ctx context.Context) ([]string, error) { |
| 1249 | u := c.alertmanagerClient.URL("api/prom/api/v2/receivers", nil) |