Files
grafana/pkg/services/ngalert/api/tooling/definitions/provisioning_templates.go
T
Yuri Tseretyan db3503fb32 Alerting: Support for imported Templates (#114196)
* refactor template service to contstruct notification template in one place, get provenance before creating and calculate resource version after.
* refactor get by UID and name

* introduce template kind in NotificationTemplate
* introduce includeImported flag and use in the k8s api
* support imported templates
* add kind to template uid
* tests for imported templates
* update API model
* set kind to default templates
2025-12-17 20:26:22 +00:00

95 lines
2.5 KiB
Go

package definitions
import "github.com/grafana/alerting/definition"
// swagger:route GET /v1/provisioning/templates provisioning stable RouteGetTemplates
//
// Get all notification template groups.
//
// Responses:
// 200: NotificationTemplates
// swagger:route GET /v1/provisioning/templates/{name} provisioning stable RouteGetTemplate
//
// Get a notification template group.
//
// Responses:
// 200: NotificationTemplate
// 404: PublicError
// swagger:route PUT /v1/provisioning/templates/{name} provisioning stable RoutePutTemplate
//
// Updates an existing notification template group.
//
// Consumes:
// - application/json
//
// Responses:
// 202: NotificationTemplate
// 400: PublicError
// 409: PublicError
// swagger:route DELETE /v1/provisioning/templates/{name} provisioning stable RouteDeleteTemplate
//
// Delete a notification template group.
//
// Responses:
// 204: description: The template was deleted successfully.
// 409: PublicError
// swagger:parameters RouteGetTemplate RoutePutTemplate RouteDeleteTemplate
type RouteGetTemplateParam struct {
// Template group name
// in:path
Name string `json:"name"`
}
// swagger:parameters stable RouteDeleteTemplate
type RouteDeleteTemplateParam struct {
// Template group name
// in:path
Name string `json:"name"`
// Version of template to use for optimistic concurrency. Leave empty to disable validation
// in:query
Version string `json:"version"`
}
// swagger:model
type NotificationTemplate struct {
UID string `json:"-" yaml:"-"`
Name string `json:"name"`
Template string `json:"template"`
Provenance Provenance `json:"provenance,omitempty"`
ResourceVersion string `json:"version,omitempty"`
Kind definition.TemplateKind `json:"-" yaml:"-"`
}
// swagger:model
type NotificationTemplates []NotificationTemplate
type NotificationTemplateContent struct {
Template string `json:"template"`
ResourceVersion string `json:"version,omitempty"`
}
// swagger:parameters RoutePutTemplate
type NotificationTemplatePayload struct {
// in:body
Body NotificationTemplateContent
}
// swagger:parameters RoutePutTemplate
type NotificationTemplateHeaders struct {
// in:header
XDisableProvenance string `json:"X-Disable-Provenance"`
}
func (t *NotificationTemplate) ResourceType() string {
return "template"
}
func (t *NotificationTemplate) ResourceID() string {
return t.Name
}