Alerting: Support deleting rule groups in the provisioning API (#83514)
* Alerting: feat: support deleting rule groups in the provisioning API Adds support for DELETE to the provisioning API's alert rule groups route, which allows deleting the rule group with a single API call. Previously, groups were deleted by deleting rules one-by-one. Fixes #81860 This change doesn't add any new paths to the API, only new methods. --------- Co-authored-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
This commit is contained in:
co-authored by
Yuri Tseretyan
parent
467302480f
commit
b905777ba9
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
type ProvisioningApi interface {
|
||||
RouteDeleteAlertRule(*contextmodel.ReqContext) response.Response
|
||||
RouteDeleteAlertRuleGroup(*contextmodel.ReqContext) response.Response
|
||||
RouteDeleteContactpoints(*contextmodel.ReqContext) response.Response
|
||||
RouteDeleteMuteTiming(*contextmodel.ReqContext) response.Response
|
||||
RouteDeleteTemplate(*contextmodel.ReqContext) response.Response
|
||||
@@ -57,6 +58,12 @@ func (f *ProvisioningApiHandler) RouteDeleteAlertRule(ctx *contextmodel.ReqConte
|
||||
uIDParam := web.Params(ctx.Req)[":UID"]
|
||||
return f.handleRouteDeleteAlertRule(ctx, uIDParam)
|
||||
}
|
||||
func (f *ProvisioningApiHandler) RouteDeleteAlertRuleGroup(ctx *contextmodel.ReqContext) response.Response {
|
||||
// Parse Path Parameters
|
||||
folderUIDParam := web.Params(ctx.Req)[":FolderUID"]
|
||||
groupParam := web.Params(ctx.Req)[":Group"]
|
||||
return f.handleRouteDeleteAlertRuleGroup(ctx, folderUIDParam, groupParam)
|
||||
}
|
||||
func (f *ProvisioningApiHandler) RouteDeleteContactpoints(ctx *contextmodel.ReqContext) response.Response {
|
||||
// Parse Path Parameters
|
||||
uIDParam := web.Params(ctx.Req)[":UID"]
|
||||
@@ -237,6 +244,18 @@ func (api *API) RegisterProvisioningApiEndpoints(srv ProvisioningApi, m *metrics
|
||||
m,
|
||||
),
|
||||
)
|
||||
group.Delete(
|
||||
toMacaronPath("/api/v1/provisioning/folder/{FolderUID}/rule-groups/{Group}"),
|
||||
requestmeta.SetOwner(requestmeta.TeamAlerting),
|
||||
requestmeta.SetSLOGroup(requestmeta.SLOGroupHighSlow),
|
||||
api.authorize(http.MethodDelete, "/api/v1/provisioning/folder/{FolderUID}/rule-groups/{Group}"),
|
||||
metrics.Instrument(
|
||||
http.MethodDelete,
|
||||
"/api/v1/provisioning/folder/{FolderUID}/rule-groups/{Group}",
|
||||
api.Hooks.Wrap(srv.RouteDeleteAlertRuleGroup),
|
||||
m,
|
||||
),
|
||||
)
|
||||
group.Delete(
|
||||
toMacaronPath("/api/v1/provisioning/contact-points/{UID}"),
|
||||
requestmeta.SetOwner(requestmeta.TeamAlerting),
|
||||
|
||||
Reference in New Issue
Block a user