Commit 79b86466 by Marcus Efraimsson Committed by Torkel Ödegaard

Fix: Alerting Notification channel http api fixes (#16288)

Fix so that uid can be changed when updating notification
channels through the http api.
Update documentation
parent bfba47c6
...@@ -152,6 +152,7 @@ Content-Type: application/json ...@@ -152,6 +152,7 @@ Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{ {
"uid": "new-alert-notification", // optional
"name": "new alert notification", //Required "name": "new alert notification", //Required
"type": "email", //Required "type": "email", //Required
"isDefault": false, "isDefault": false,
...@@ -170,7 +171,7 @@ Content-Type: application/json ...@@ -170,7 +171,7 @@ Content-Type: application/json
{ {
"id": 1, "id": 1,
"uid": "cIBgcSjkk", "uid": "new-alert-notification",
"name": "new alert notification", "name": "new alert notification",
"type": "email", "type": "email",
"isDefault": false, "isDefault": false,
...@@ -198,6 +199,7 @@ Content-Type: application/json ...@@ -198,6 +199,7 @@ Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{ {
"uid": "new-alert-notification", // optional
"name": "new alert notification", //Required "name": "new alert notification", //Required
"type": "email", //Required "type": "email", //Required
"isDefault": false, "isDefault": false,
...@@ -217,7 +219,7 @@ Content-Type: application/json ...@@ -217,7 +219,7 @@ Content-Type: application/json
{ {
"id": 1, "id": 1,
"uid": "cIBgcSjkk", "uid": "new-alert-notification",
"name": "new alert notification", "name": "new alert notification",
"type": "email", "type": "email",
"isDefault": false, "isDefault": false,
...@@ -247,7 +249,7 @@ Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk ...@@ -247,7 +249,7 @@ Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{ {
"id": 1, "id": 1,
"uid": "cIBgcSjkk", "uid": "new-alert-notification", // optional
"name": "new alert notification", //Required "name": "new alert notification", //Required
"type": "email", //Required "type": "email", //Required
"isDefault": false, "isDefault": false,
...@@ -267,7 +269,7 @@ Content-Type: application/json ...@@ -267,7 +269,7 @@ Content-Type: application/json
{ {
"id": 1, "id": 1,
"uid": "cIBgcSjkk", "uid": "new-alert-notification",
"name": "new alert notification", "name": "new alert notification",
"type": "email", "type": "email",
"isDefault": false, "isDefault": false,
......
...@@ -54,6 +54,7 @@ type CreateAlertNotificationCommand struct { ...@@ -54,6 +54,7 @@ type CreateAlertNotificationCommand struct {
type UpdateAlertNotificationCommand struct { type UpdateAlertNotificationCommand struct {
Id int64 `json:"id" binding:"Required"` Id int64 `json:"id" binding:"Required"`
Uid string `json:"uid"`
Name string `json:"name" binding:"Required"` Name string `json:"name" binding:"Required"`
Type string `json:"type" binding:"Required"` Type string `json:"type" binding:"Required"`
SendReminder bool `json:"sendReminder"` SendReminder bool `json:"sendReminder"`
...@@ -68,6 +69,7 @@ type UpdateAlertNotificationCommand struct { ...@@ -68,6 +69,7 @@ type UpdateAlertNotificationCommand struct {
type UpdateAlertNotificationWithUidCommand struct { type UpdateAlertNotificationWithUidCommand struct {
Uid string `json:"-"` Uid string `json:"-"`
NewUid string `json:"uid"`
Name string `json:"name" binding:"Required"` Name string `json:"name" binding:"Required"`
Type string `json:"type" binding:"Required"` Type string `json:"type" binding:"Required"`
SendReminder bool `json:"sendReminder"` SendReminder bool `json:"sendReminder"`
......
...@@ -317,6 +317,10 @@ func UpdateAlertNotification(cmd *m.UpdateAlertNotificationCommand) error { ...@@ -317,6 +317,10 @@ func UpdateAlertNotification(cmd *m.UpdateAlertNotificationCommand) error {
current.SendReminder = cmd.SendReminder current.SendReminder = cmd.SendReminder
current.DisableResolveMessage = cmd.DisableResolveMessage current.DisableResolveMessage = cmd.DisableResolveMessage
if cmd.Uid != "" {
current.Uid = cmd.Uid
}
if current.SendReminder { if current.SendReminder {
if cmd.Frequency == "" { if cmd.Frequency == "" {
return m.ErrNotificationFrequencyNotFound return m.ErrNotificationFrequencyNotFound
...@@ -356,8 +360,13 @@ func UpdateAlertNotificationWithUid(cmd *m.UpdateAlertNotificationWithUidCommand ...@@ -356,8 +360,13 @@ func UpdateAlertNotificationWithUid(cmd *m.UpdateAlertNotificationWithUidCommand
return fmt.Errorf("Cannot update, alert notification uid %s doesn't exist", cmd.Uid) return fmt.Errorf("Cannot update, alert notification uid %s doesn't exist", cmd.Uid)
} }
if cmd.NewUid == "" {
cmd.NewUid = cmd.Uid
}
updateNotification := &m.UpdateAlertNotificationCommand{ updateNotification := &m.UpdateAlertNotificationCommand{
Id: current.Id, Id: current.Id,
Uid: cmd.NewUid,
Name: cmd.Name, Name: cmd.Name,
Type: cmd.Type, Type: cmd.Type,
SendReminder: cmd.SendReminder, SendReminder: cmd.SendReminder,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment