NGAlert: Send list of available ngalert notification channels via API (#33489)

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
This commit is contained in:
Ganesh Vernekar
2021-05-04 13:58:39 +02:00
committed by GitHub
parent ab872612ce
commit 918552d34b
11 changed files with 1048 additions and 61 deletions
+10 -2
View File
@@ -11,6 +11,7 @@ import (
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/alerting"
"github.com/grafana/grafana/pkg/services/guardian"
"github.com/grafana/grafana/pkg/services/ngalert/notifier"
"github.com/grafana/grafana/pkg/services/search"
"github.com/grafana/grafana/pkg/util"
)
@@ -179,8 +180,15 @@ func GetAlert(c *models.ReqContext) response.Response {
return response.JSON(200, &query.Result)
}
func GetAlertNotifiers(c *models.ReqContext) response.Response {
return response.JSON(200, alerting.GetNotifiers())
func GetAlertNotifiers(ngalertEnabled bool) func(*models.ReqContext) response.Response {
return func(_ *models.ReqContext) response.Response {
if ngalertEnabled {
return response.JSON(200, notifier.GetAvailableNotifiers())
}
// TODO(codesome): This wont be required in 8.0 since ngalert
// will be enabled by default with no disabling. This is to be removed later.
return response.JSON(200, alerting.GetNotifiers())
}
}
func GetAlertNotificationLookup(c *models.ReqContext) response.Response {