mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(alerting): add paused api endpoint
This commit is contained in:
@@ -252,6 +252,27 @@ func NotificationTest(c *middleware.Context, dto dtos.NotificationTestCommand) R
|
||||
return ApiSuccess("Test notification sent")
|
||||
}
|
||||
|
||||
//POST /api/alerts/:alertId/pause
|
||||
func PauseAlert(c *middleware.Context, cmd models.PauseAlertCommand) Response {
|
||||
cmd.OrgId = c.OrgId
|
||||
cmd.AlertId = c.ParamsInt64(":alertId")
|
||||
|
||||
if cmd.AlertId == 0 {
|
||||
return ApiError(400, "Missing alert id", nil)
|
||||
}
|
||||
|
||||
if err := bus.Dispatch(&cmd); err != nil {
|
||||
return ApiError(500, "", err)
|
||||
}
|
||||
|
||||
response := "un paused"
|
||||
if cmd.Paused {
|
||||
response = "paused"
|
||||
}
|
||||
|
||||
return ApiSuccess("Alert " + response)
|
||||
}
|
||||
|
||||
func getAlertIdForRequest(c *middleware.Context) (int64, error) {
|
||||
alertId := c.QueryInt64("alertId")
|
||||
panelId := c.QueryInt64("panelId")
|
||||
|
||||
@@ -252,6 +252,7 @@ func Register(r *macaron.Macaron) {
|
||||
|
||||
r.Group("/alerts", func() {
|
||||
r.Post("/test", bind(dtos.AlertTestCommand{}), wrap(AlertTest))
|
||||
r.Post("/:alertId/pause", ValidateOrgAlert, bind(m.PauseAlertCommand{}), wrap(PauseAlert))
|
||||
r.Get("/:alertId", ValidateOrgAlert, wrap(GetAlert))
|
||||
r.Get("/", wrap(GetAlerts))
|
||||
r.Get("/states-for-dashboard", wrap(GetAlertStatesForDashboard))
|
||||
|
||||
@@ -58,3 +58,9 @@ type NotificationTestCommand struct {
|
||||
Type string `json:"type"`
|
||||
Settings *simplejson.Json `json:"settings"`
|
||||
}
|
||||
|
||||
type PauseAlertCommand struct {
|
||||
AlertId int64 `json:"alertId"`
|
||||
DashboardId int64 `json:"dashboardId"`
|
||||
PanelId int64 `json:"panelId"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user