2021-03-11 13:28:00 -06:00
|
|
|
{{>partial_header}}
|
|
|
|
package {{packageName}}
|
|
|
|
|
|
|
|
{{#operations}}
|
|
|
|
import (
|
|
|
|
"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/routing"
|
|
|
|
"github.com/grafana/grafana/pkg/api/response"
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
2021-04-20 12:12:32 -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-04-06 09:22:05 -05:00
|
|
|
"github.com/grafana/grafana/pkg/middleware"
|
2021-03-11 13:28:00 -06:00
|
|
|
)
|
|
|
|
|
2021-12-13 02:22:57 -06:00
|
|
|
type {{classname}}ForkingService interface { {{#operation}}
|
|
|
|
{{nickname}}(*models.ReqContext) response.Response{{/operation}}
|
|
|
|
}
|
|
|
|
|
|
|
|
{{#operations}}{{#operation}}
|
|
|
|
func (f *Forked{{classname}}) {{nickname}}(ctx *models.ReqContext) response.Response {
|
|
|
|
{{#bodyParams}}
|
|
|
|
conf := apimodels.{{dataType}}{}
|
|
|
|
if err := web.Bind(ctx.Req, &conf); err != nil {
|
|
|
|
return response.Error(http.StatusBadRequest, "bad request data", err)
|
|
|
|
}
|
2022-04-05 16:48:51 -05:00
|
|
|
return f.fork{{nickname}}(ctx, conf)
|
2021-12-13 02:22:57 -06:00
|
|
|
{{/bodyParams}}
|
|
|
|
{{^bodyParams}}
|
2022-04-05 16:48:51 -05:00
|
|
|
return f.fork{{nickname}}(ctx)
|
2021-12-13 02:22:57 -06:00
|
|
|
{{/bodyParams}}
|
|
|
|
}
|
|
|
|
{{/operation}}{{/operations}}
|
|
|
|
|
|
|
|
func (api *API) Register{{classname}}Endpoints(srv {{classname}}ForkingService, m *metrics.API) {
|
2021-03-11 13:28:00 -06:00
|
|
|
api.RouteRegister.Group("", func(group routing.RouteRegister){ {{#operations}}{{#operation}}
|
2021-04-28 15:59:15 -05:00
|
|
|
group.{{httpMethod}}(
|
2021-12-13 02:22:57 -06:00
|
|
|
toMacaronPath("{{{path}}}"),
|
2022-02-04 11:42:04 -06:00
|
|
|
api.authorize(http.Method{{httpMethod}}, "{{{path}}}"),
|
2021-04-30 11:28:06 -05:00
|
|
|
metrics.Instrument(
|
2021-04-28 15:59:15 -05:00
|
|
|
http.Method{{httpMethod}},
|
|
|
|
"{{{path}}}",
|
|
|
|
srv.{{nickname}},
|
2021-04-30 11:28:06 -05:00
|
|
|
m,
|
2021-04-28 15:59:15 -05:00
|
|
|
),
|
|
|
|
){{/operation}}{{/operations}}
|
2022-03-24 16:13:47 -05:00
|
|
|
}, middleware.ReqSignedIn)
|
2021-03-11 13:28:00 -06:00
|
|
|
}{{#operation}}
|
2021-12-13 02:22:57 -06:00
|
|
|
{{/operation}}{{/operations}}
|