feat(notifications): make it possible to send test alert notifications

closes #5847
This commit is contained in:
bergquist
2016-09-05 14:45:15 +02:00
parent 4c5461d4ba
commit d11bc57c37
7 changed files with 163 additions and 3 deletions
+16
View File
@@ -214,6 +214,22 @@ func DeleteAlertNotification(c *middleware.Context) Response {
return ApiSuccess("Notification deleted")
}
//POST /api/alert-notifications/test
func NotificationTest(c *middleware.Context, dto dtos.NotificationTestCommand) Response {
cmd := &alerting.NotificationTestCommand{
Name: dto.Name,
Type: dto.Type,
Severity: dto.Severity,
Settings: dto.Settings,
}
if err := bus.Dispatch(cmd); err != nil {
return ApiError(500, "Failed to send alert notifications", err)
}
return ApiSuccess("Test notification sent")
}
func GetAlertHistory(c *middleware.Context) Response {
alertId, err := getAlertIdForRequest(c)
if err != nil {
+1
View File
@@ -259,6 +259,7 @@ func Register(r *macaron.Macaron) {
r.Get("/alert-notifications", wrap(GetAlertNotifications))
r.Group("/alert-notifications", func() {
r.Post("/test", bind(dtos.NotificationTestCommand{}), wrap(NotificationTest))
r.Post("/", bind(m.CreateAlertNotificationCommand{}), wrap(CreateAlertNotification))
r.Put("/:notificationId", bind(m.UpdateAlertNotificationCommand{}), wrap(UpdateAlertNotification))
r.Get("/:notificationId", wrap(GetAlertNotificationById))
+7
View File
@@ -63,3 +63,10 @@ type AlertHistory struct {
Data *simplejson.Json `json:"data"`
}
type NotificationTestCommand struct {
Name string `json:"name"`
Type string `json:"type"`
Settings *simplejson.Json `json:"settings"`
Severity string `json:"severity"`
}