Alerting: Allow administrators delete rules permanently via UI (#101974)

* add query parameter to existing APIs to control the permanent deletion of rules
* add GUID to gettable rule
* add new endpoint /ruler/grafana/api/v1/trash/rule/guid/{RuleGUID} to delete rules from trash permanently

---------

Signed-off-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
This commit is contained in:
Yuri Tseretyan
2025-03-14 22:14:06 +02:00
committed by GitHub
parent e30034a42a
commit 309a2eb4e9
25 changed files with 585 additions and 115 deletions
@@ -20,6 +20,18 @@ import (
// 403: ForbiddenError
// 404: description: Not found.
// swagger:route Delete /ruler/grafana/api/v1/trash/rule/guid/{RuleGUID} ruler RouteDeleteRuleFromTrashByGUID
//
// Permanently delete a rule from trash by GUID
//
// Produces:
// - application/json
//
// Responses:
// 202: Ack
// 403: ForbiddenError
// 404: description: Not found.
// swagger:route Get /ruler/grafana/api/v1/rule/{RuleUID}/versions ruler RouteGetRuleVersionsByUID
//
// Get rule versions by UID
@@ -237,6 +249,12 @@ type PathGetRuleByUIDParams struct {
RuleUID string
}
// swagger:parameters RouteDeleteRuleFromTrashByGUID
type PathDeleteRuleFromTrashByGUIDParams struct {
// in: path
RuleGUID string
}
// swagger:model
type RuleGroupConfigResponse struct {
GettableRuleGroupConfig
@@ -572,6 +590,7 @@ type GettableGrafanaRule struct {
NotificationSettings *AlertRuleNotificationSettings `json:"notification_settings,omitempty" yaml:"notification_settings,omitempty"`
Record *Record `json:"record,omitempty" yaml:"record,omitempty"`
Metadata *AlertRuleMetadata `json:"metadata,omitempty" yaml:"metadata,omitempty"`
GUID string `json:"guid" yaml:"guid"`
}
// UserInfo represents user-related information, including a unique identifier and a name.