Files
grafana/pkg/api/alerting.go
alerting-team[bot] a1389bc173 Alerting: Update alerting module to 77a1e2f35be87bebc41a0bf634f336282f0b9b53 (#115498)
* [create-pull-request] automated change

* Remove IsProtectedField and temp structure

* Fix alerting historian

* make update-workspace

---------

Co-authored-by: yuri-tceretian <25988953+yuri-tceretian@users.noreply.github.com>
Co-authored-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
Co-authored-by: Alexander Akhmetov <me@alx.cx>
2025-12-23 14:46:44 -05:00

53 lines
1.4 KiB
Go

package api
import (
"net/http"
"slices"
"strings"
"github.com/grafana/alerting/notify"
"github.com/grafana/alerting/receivers/schema"
"github.com/grafana/grafana/pkg/api/response"
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
)
func (hs *HTTPServer) GetAlertNotifiers() func(*contextmodel.ReqContext) response.Response {
return func(r *contextmodel.ReqContext) response.Response {
v2 := notify.GetSchemaForAllIntegrations()
slices.SortFunc(v2, func(a, b schema.IntegrationTypeSchema) int {
return strings.Compare(string(a.Type), string(b.Type))
})
if r.Query("version") == "2" {
return response.JSON(http.StatusOK, v2)
}
type NotifierPlugin struct {
Type string `json:"type"`
TypeAlias string `json:"typeAlias,omitempty"`
Name string `json:"name"`
Heading string `json:"heading"`
Description string `json:"description"`
Info string `json:"info"`
Options []schema.Field `json:"options"`
}
result := make([]*NotifierPlugin, 0, len(v2))
for _, s := range v2 {
v1, ok := s.GetVersion(schema.V1)
if !ok {
continue
}
result = append(result, &NotifierPlugin{
Type: string(s.Type),
Name: s.Name,
Description: s.Description,
Heading: s.Heading,
Info: s.Info,
Options: v1.Options,
})
}
return response.JSON(http.StatusOK, result)
}
}