Alerting: add route owner middleware (#73869)

alerting: add route owner middleware

Signed-off-by: bergquist <carl.bergquist@gmail.com>
This commit is contained in:
Carl Bergquist
2023-08-29 12:43:33 +02:00
committed by GitHub
parent fe1563882a
commit 10a82e30ba
8 changed files with 89 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ import (
"github.com/grafana/grafana/pkg/api/response"
"github.com/grafana/grafana/pkg/api/routing"
"github.com/grafana/grafana/pkg/middleware"
"github.com/grafana/grafana/pkg/middleware/requestmeta"
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
"github.com/grafana/grafana/pkg/services/ngalert/metrics"
@@ -64,6 +65,7 @@ func (api *API) RegisterTestingApiEndpoints(srv TestingApi, m *metrics.API) {
api.RouteRegister.Group("", func(group routing.RouteRegister) {
group.Post(
toMacaronPath("/api/v1/rule/backtest"),
requestmeta.SetOwner(requestmeta.TeamAlerting),
api.authorize(http.MethodPost, "/api/v1/rule/backtest"),
metrics.Instrument(
http.MethodPost,
@@ -74,6 +76,7 @@ func (api *API) RegisterTestingApiEndpoints(srv TestingApi, m *metrics.API) {
)
group.Post(
toMacaronPath("/api/v1/eval"),
requestmeta.SetOwner(requestmeta.TeamAlerting),
api.authorize(http.MethodPost, "/api/v1/eval"),
metrics.Instrument(
http.MethodPost,
@@ -84,6 +87,7 @@ func (api *API) RegisterTestingApiEndpoints(srv TestingApi, m *metrics.API) {
)
group.Post(
toMacaronPath("/api/v1/rule/test/{DatasourceUID}"),
requestmeta.SetOwner(requestmeta.TeamAlerting),
api.authorize(http.MethodPost, "/api/v1/rule/test/{DatasourceUID}"),
metrics.Instrument(
http.MethodPost,
@@ -94,6 +98,7 @@ func (api *API) RegisterTestingApiEndpoints(srv TestingApi, m *metrics.API) {
)
group.Post(
toMacaronPath("/api/v1/rule/test/grafana"),
requestmeta.SetOwner(requestmeta.TeamAlerting),
api.authorize(http.MethodPost, "/api/v1/rule/test/grafana"),
metrics.Instrument(
http.MethodPost,