Alerting: Time interval Delete API to check for usages in alert rules (#90500)
* Check if a time interval is used in alert rules before deleting it * Add time interval to parameters of ListAlertRulesQuery and ListNotificationSettings of DbStore == Refacorings == * refactor isMuteTimeInUse to accept a single route * update getMuteTiming to not return err * update delete to get the mute timing from config first
This commit is contained in:
@@ -217,3 +217,40 @@ func (s *fakeRuleAccessControlService) CanWriteAllRules(ctx context.Context, use
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
type fakeAlertRuleNotificationStore struct {
|
||||
Calls []call
|
||||
|
||||
RenameReceiverInNotificationSettingsFn func(ctx context.Context, orgID int64, oldReceiver, newReceiver string) (int, error)
|
||||
ListNotificationSettingsFn func(ctx context.Context, q models.ListNotificationSettingsQuery) (map[models.AlertRuleKey][]models.NotificationSettings, error)
|
||||
}
|
||||
|
||||
func (f *fakeAlertRuleNotificationStore) RenameReceiverInNotificationSettings(ctx context.Context, orgID int64, oldReceiver, newReceiver string) (int, error) {
|
||||
call := call{
|
||||
Method: "RenameReceiverInNotificationSettings",
|
||||
Args: []interface{}{ctx, orgID, oldReceiver, newReceiver},
|
||||
}
|
||||
f.Calls = append(f.Calls, call)
|
||||
|
||||
if f.RenameReceiverInNotificationSettingsFn != nil {
|
||||
return f.RenameReceiverInNotificationSettingsFn(ctx, orgID, oldReceiver, newReceiver)
|
||||
}
|
||||
|
||||
// Default values when no function hook is provided
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func (f *fakeAlertRuleNotificationStore) ListNotificationSettings(ctx context.Context, q models.ListNotificationSettingsQuery) (map[models.AlertRuleKey][]models.NotificationSettings, error) {
|
||||
call := call{
|
||||
Method: "ListNotificationSettings",
|
||||
Args: []interface{}{ctx, q},
|
||||
}
|
||||
f.Calls = append(f.Calls, call)
|
||||
|
||||
if f.ListNotificationSettingsFn != nil {
|
||||
return f.ListNotificationSettingsFn(ctx, q)
|
||||
}
|
||||
|
||||
// Default values when no function hook is provided
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user