mirror of
https://github.com/grafana/grafana.git
synced 2024-12-01 21:19:28 -06:00
dde0b93cf1
* Base-line API for provisioning notification policies * Wire API up, some simple tests * Return provenance status through API * Fix missing call * Transactions * Clarity in package dependencies * Unify receivers in definitions * Fix issue introduced by receiver change * Drop unused internal test implementation * FGAC hooks for provisioning routes * Polish, swap names * Asserting on number of exposed routes * Don't bubble up updated object * Integrate with new concurrency token feature in store * Back out duplicated changes * Remove redundant tests * Regenerate and create unit tests for API layer * Integration tests for auth * Address linter errors * Put route behind toggle * Use alternative store API and fix feature toggle in tests * Fixes, polish * Fix whitespace * Re-kick drone * Rename services to provisioning
49 lines
1.5 KiB
Plaintext
49 lines
1.5 KiB
Plaintext
{{>partial_header}}
|
|
package {{packageName}}
|
|
|
|
{{#operations}}
|
|
import (
|
|
"github.com/go-macaron/binding"
|
|
|
|
"github.com/grafana/grafana/pkg/api/routing"
|
|
"github.com/grafana/grafana/pkg/api/response"
|
|
"github.com/grafana/grafana/pkg/models"
|
|
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
|
|
"github.com/grafana/grafana/pkg/services/ngalert/metrics"
|
|
"github.com/grafana/grafana/pkg/middleware"
|
|
)
|
|
|
|
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)
|
|
}
|
|
return f.fork{{nickname}}(ctx, conf)
|
|
{{/bodyParams}}
|
|
{{^bodyParams}}
|
|
return f.fork{{nickname}}(ctx)
|
|
{{/bodyParams}}
|
|
}
|
|
{{/operation}}{{/operations}}
|
|
|
|
func (api *API) Register{{classname}}Endpoints(srv {{classname}}ForkingService, m *metrics.API) {
|
|
api.RouteRegister.Group("", func(group routing.RouteRegister){ {{#operations}}{{#operation}}
|
|
group.{{httpMethod}}(
|
|
toMacaronPath("{{{path}}}"),
|
|
api.authorize(http.Method{{httpMethod}}, "{{{path}}}"),
|
|
metrics.Instrument(
|
|
http.Method{{httpMethod}},
|
|
"{{{path}}}",
|
|
srv.{{nickname}},
|
|
m,
|
|
),
|
|
){{/operation}}{{/operations}}
|
|
}, middleware.ReqSignedIn)
|
|
}{{#operation}}
|
|
{{/operation}}{{/operations}} |