2022-07-18 02:08:08 -05:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/grafana/grafana/pkg/api/response"
|
2023-01-27 01:50:36 -06:00
|
|
|
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
2022-07-18 02:08:08 -05:00
|
|
|
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
|
|
|
|
)
|
|
|
|
|
|
|
|
// TestingApiHandler always forwards requests to grafana backend
|
|
|
|
type TestingApiHandler struct {
|
|
|
|
svc *TestingApiSrv
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewTestingApi(svc *TestingApiSrv) *TestingApiHandler {
|
|
|
|
return &TestingApiHandler{
|
|
|
|
svc: svc,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-27 01:50:36 -06:00
|
|
|
func (f *TestingApiHandler) handleRouteTestRuleConfig(c *contextmodel.ReqContext, body apimodels.TestRulePayload, dsUID string) response.Response {
|
2022-07-18 02:08:08 -05:00
|
|
|
return f.svc.RouteTestRuleConfig(c, body, dsUID)
|
|
|
|
}
|
|
|
|
|
2023-06-08 17:59:54 -05:00
|
|
|
func (f *TestingApiHandler) handleRouteTestRuleGrafanaConfig(c *contextmodel.ReqContext, body apimodels.PostableExtendedRuleNodeExtended) response.Response {
|
2022-07-18 02:08:08 -05:00
|
|
|
return f.svc.RouteTestGrafanaRuleConfig(c, body)
|
|
|
|
}
|
|
|
|
|
2023-01-27 01:50:36 -06:00
|
|
|
func (f *TestingApiHandler) handleRouteEvalQueries(c *contextmodel.ReqContext, body apimodels.EvalQueriesPayload) response.Response {
|
2022-07-18 02:08:08 -05:00
|
|
|
return f.svc.RouteEvalQueries(c, body)
|
|
|
|
}
|
2022-12-14 08:44:14 -06:00
|
|
|
|
2023-01-27 01:50:36 -06:00
|
|
|
func (f *TestingApiHandler) handleBacktestConfig(ctx *contextmodel.ReqContext, conf apimodels.BacktestConfig) response.Response {
|
2022-12-14 08:44:14 -06:00
|
|
|
return f.svc.BacktestAlertRule(ctx, conf)
|
|
|
|
}
|