2021-03-11 13:28:00 -06:00
|
|
|
/*Package api contains base API implementation of unified alerting
|
|
|
|
*
|
2021-04-09 04:55:41 -05:00
|
|
|
*Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
2021-03-11 13:28:00 -06:00
|
|
|
*
|
2021-04-09 04:55:41 -05:00
|
|
|
*Do not manually edit these files, please find ngalert/api/swagger-codegen/ for commands on how to generate them.
|
2021-03-11 13:28:00 -06:00
|
|
|
*/
|
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
2021-04-28 15:59:15 -05:00
|
|
|
"net/http"
|
|
|
|
|
2021-03-11 13:28:00 -06:00
|
|
|
"github.com/go-macaron/binding"
|
2021-04-09 04:55:41 -05:00
|
|
|
|
2021-03-11 13:28:00 -06:00
|
|
|
"github.com/grafana/grafana/pkg/api/response"
|
|
|
|
"github.com/grafana/grafana/pkg/api/routing"
|
2021-04-06 09:22:05 -05:00
|
|
|
"github.com/grafana/grafana/pkg/middleware"
|
2021-03-11 13:28:00 -06:00
|
|
|
"github.com/grafana/grafana/pkg/models"
|
2021-04-19 13:26:04 -05:00
|
|
|
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
|
2021-04-30 11:28:06 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/ngalert/metrics"
|
2021-03-11 13:28:00 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
type TestingApiService interface {
|
2021-04-21 14:44:50 -05:00
|
|
|
RouteEvalQueries(*models.ReqContext, apimodels.EvalQueriesPayload) response.Response
|
2021-03-11 13:28:00 -06:00
|
|
|
RouteTestRuleConfig(*models.ReqContext, apimodels.TestRulePayload) response.Response
|
|
|
|
}
|
|
|
|
|
2021-09-14 06:55:01 -05:00
|
|
|
func (api *API) RegisterTestingApiEndpoints(srv TestingApiService, m *metrics.API) {
|
2021-03-11 13:28:00 -06:00
|
|
|
api.RouteRegister.Group("", func(group routing.RouteRegister) {
|
2021-04-28 15:59:15 -05:00
|
|
|
group.Post(
|
|
|
|
toMacaronPath("/api/v1/eval"),
|
|
|
|
binding.Bind(apimodels.EvalQueriesPayload{}),
|
2021-04-30 11:28:06 -05:00
|
|
|
metrics.Instrument(
|
2021-04-28 15:59:15 -05:00
|
|
|
http.MethodPost,
|
|
|
|
"/api/v1/eval",
|
|
|
|
srv.RouteEvalQueries,
|
2021-04-30 11:28:06 -05:00
|
|
|
m,
|
2021-04-28 15:59:15 -05:00
|
|
|
),
|
|
|
|
)
|
|
|
|
group.Post(
|
|
|
|
toMacaronPath("/api/v1/rule/test/{Recipient}"),
|
|
|
|
binding.Bind(apimodels.TestRulePayload{}),
|
2021-04-30 11:28:06 -05:00
|
|
|
metrics.Instrument(
|
2021-04-28 15:59:15 -05:00
|
|
|
http.MethodPost,
|
|
|
|
"/api/v1/rule/test/{Recipient}",
|
|
|
|
srv.RouteTestRuleConfig,
|
2021-04-30 11:28:06 -05:00
|
|
|
m,
|
2021-04-28 15:59:15 -05:00
|
|
|
),
|
|
|
|
)
|
2021-04-06 09:22:05 -05:00
|
|
|
}, middleware.ReqSignedIn)
|
2021-03-11 13:28:00 -06:00
|
|
|
}
|