Alerting: Refactor API handlers to use web.Bind (#42600)

* Alerting: Refactor API handlers to use web.Bind

* lint
This commit is contained in:
Sofia Papagiannaki
2021-12-13 09:22:57 +01:00
committed by GitHub
parent fd48aee61e
commit c6483cd8ed
13 changed files with 367 additions and 113 deletions
@@ -0,0 +1,27 @@
package api
import (
"github.com/grafana/grafana/pkg/api/response"
"github.com/grafana/grafana/pkg/models"
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
)
// ForkedTestingApi always forwards requests to grafana backend
type ForkedTestingApi struct {
grafana TestingApiService
}
// NewForkedTestingApi creates a new ForkedTestingApi instance
func NewForkedTestingApi(grafana TestingApiService) *ForkedTestingApi {
return &ForkedTestingApi{
grafana: grafana,
}
}
func (f *ForkedTestingApi) forkRouteTestRuleConfig(c *models.ReqContext, body apimodels.TestRulePayload) response.Response {
return f.grafana.RouteTestRuleConfig(c, body)
}
func (f *ForkedTestingApi) forkRouteEvalQueries(c *models.ReqContext, body apimodels.EvalQueriesPayload) response.Response {
return f.grafana.RouteEvalQueries(c, body)
}