2022-09-27 08:56:30 -05:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2023-11-14 08:47:34 -06:00
|
|
|
"github.com/grafana/grafana/pkg/services/auth/identity"
|
2022-11-11 07:28:24 -06:00
|
|
|
"github.com/grafana/grafana/pkg/services/folder"
|
2022-09-27 08:56:30 -05:00
|
|
|
ngmodels "github.com/grafana/grafana/pkg/services/ngalert/models"
|
|
|
|
)
|
|
|
|
|
|
|
|
// RuleStore is the interface for persisting alert rules and instances
|
|
|
|
type RuleStore interface {
|
2024-01-17 03:07:39 -06:00
|
|
|
// TODO after deprecating namespace_id field in GettableGrafanaRule we can simplify this interface
|
|
|
|
// by returning map[string]struct{} instead of map[string]*folder.Folder
|
2023-11-14 08:47:34 -06:00
|
|
|
GetUserVisibleNamespaces(context.Context, int64, identity.Requester) (map[string]*folder.Folder, error)
|
|
|
|
GetNamespaceByUID(ctx context.Context, uid string, orgID int64, user identity.Requester) (*folder.Folder, error)
|
2023-03-28 03:34:35 -05:00
|
|
|
GetAlertRulesGroupByRuleUID(ctx context.Context, query *ngmodels.GetAlertRulesGroupByRuleUIDQuery) ([]*ngmodels.AlertRule, error)
|
|
|
|
ListAlertRules(ctx context.Context, query *ngmodels.ListAlertRulesQuery) (ngmodels.RulesGroup, error)
|
2022-09-27 08:56:30 -05:00
|
|
|
|
|
|
|
// InsertAlertRules will insert all alert rules passed into the function
|
|
|
|
// and return the map of uuid to id.
|
2023-10-06 17:11:24 -05:00
|
|
|
InsertAlertRules(ctx context.Context, rule []ngmodels.AlertRule) ([]ngmodels.AlertRuleKeyWithId, error)
|
2022-09-29 15:47:56 -05:00
|
|
|
UpdateAlertRules(ctx context.Context, rule []ngmodels.UpdateRule) error
|
2022-09-27 08:56:30 -05:00
|
|
|
DeleteAlertRulesByUID(ctx context.Context, orgID int64, ruleUID ...string) error
|
|
|
|
|
|
|
|
// IncreaseVersionForAllRulesInNamespace Increases version for all rules that have specified namespace. Returns all rules that belong to the namespace
|
2023-01-26 11:29:10 -06:00
|
|
|
IncreaseVersionForAllRulesInNamespace(ctx context.Context, orgID int64, namespaceUID string) ([]ngmodels.AlertRuleKeyWithVersionAndPauseStatus, error)
|
2022-09-27 08:56:30 -05:00
|
|
|
}
|