Alerting: Support template UID in template service (#92164)
* add uid to template and populate it * update delete method to support both uid and name * update UpdateTemplate to support search by UID and fallback to name + support renaming of the template * update upsert to exit if template not found and uid is specified * update Get method to address by name or uid --------- Co-authored-by: Matthew Jacobson <matthew.jacobson@grafana.com>
This commit is contained in:
co-authored by
Matthew Jacobson
parent
354aee951d
commit
4755eb5176
@@ -45,9 +45,9 @@ type ContactPointService interface {
|
||||
|
||||
type TemplateService interface {
|
||||
GetTemplates(ctx context.Context, orgID int64) ([]definitions.NotificationTemplate, error)
|
||||
GetTemplate(ctx context.Context, orgID int64, name string) (definitions.NotificationTemplate, error)
|
||||
GetTemplate(ctx context.Context, orgID int64, nameOrUid string) (definitions.NotificationTemplate, error)
|
||||
UpsertTemplate(ctx context.Context, orgID int64, tmpl definitions.NotificationTemplate) (definitions.NotificationTemplate, error)
|
||||
DeleteTemplate(ctx context.Context, orgID int64, name string, provenance definitions.Provenance, version string) error
|
||||
DeleteTemplate(ctx context.Context, orgID int64, nameOrUid string, provenance definitions.Provenance, version string) error
|
||||
}
|
||||
|
||||
type NotificationPolicyService interface {
|
||||
@@ -229,9 +229,9 @@ func (srv *ProvisioningSrv) RoutePutTemplate(c *contextmodel.ReqContext, body de
|
||||
return response.JSON(http.StatusAccepted, modified)
|
||||
}
|
||||
|
||||
func (srv *ProvisioningSrv) RouteDeleteTemplate(c *contextmodel.ReqContext, name string) response.Response {
|
||||
func (srv *ProvisioningSrv) RouteDeleteTemplate(c *contextmodel.ReqContext, nameOrUid string) response.Response {
|
||||
version := c.Query("version")
|
||||
err := srv.templates.DeleteTemplate(c.Req.Context(), c.SignedInUser.GetOrgID(), name, determineProvenance(c), version)
|
||||
err := srv.templates.DeleteTemplate(c.Req.Context(), c.SignedInUser.GetOrgID(), nameOrUid, determineProvenance(c), version)
|
||||
if err != nil {
|
||||
return response.ErrOrFallback(http.StatusInternalServerError, "", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user