Alerting: Rule version history API (#99041)
* implement store method to read rule versions * implement request handler * declare a new endpoint * fix fake to return correct response * add tests * add integration tests * rename history to versions * apply diff from swagger CI step Signed-off-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com> --------- Signed-off-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
This commit is contained in:
@@ -204,3 +204,34 @@ func alertRuleToAlertRuleVersion(rule alertRule) alertRuleVersion {
|
||||
Metadata: rule.Metadata,
|
||||
}
|
||||
}
|
||||
|
||||
func alertRuleVersionToAlertRule(version alertRuleVersion) alertRule {
|
||||
return alertRule{
|
||||
ID: version.ID,
|
||||
OrgID: version.RuleOrgID,
|
||||
Title: version.Title,
|
||||
Condition: version.Condition,
|
||||
Data: version.Data,
|
||||
Updated: version.Created,
|
||||
UpdatedBy: version.CreatedBy,
|
||||
IntervalSeconds: version.IntervalSeconds,
|
||||
Version: version.Version,
|
||||
UID: version.RuleUID,
|
||||
NamespaceUID: version.RuleNamespaceUID,
|
||||
// Versions do not store Dashboard\Panel as separate column.
|
||||
// However, these fields are part of annotations and information in these fields is redundant
|
||||
DashboardUID: nil,
|
||||
PanelID: nil,
|
||||
RuleGroup: version.RuleGroup,
|
||||
RuleGroupIndex: version.RuleGroupIndex,
|
||||
Record: version.Record,
|
||||
NoDataState: version.NoDataState,
|
||||
ExecErrState: version.ExecErrState,
|
||||
For: version.For,
|
||||
Annotations: version.Annotations,
|
||||
Labels: version.Labels,
|
||||
IsPaused: version.IsPaused,
|
||||
NotificationSettings: version.NotificationSettings,
|
||||
Metadata: version.Metadata,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user