fix deleting the last notification rule for pagerduty migrator (#484)

This commit is contained in:
Vadim Stepanov 2022-09-07 10:58:31 +01:00 committed by GitHub
parent 981fdf54a1
commit b68dd9bc92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,12 +31,16 @@ def migrate_notification_rules(user: dict) -> None:
notification_rules, user["oncall_user"]["id"]
)
for rule in user["oncall_user"]["notification_rules"]:
oncall_api_client.delete("personal_notification_rules/{}".format(rule["id"]))
for rule in oncall_rules:
oncall_api_client.create("personal_notification_rules", rule)
if oncall_rules:
# delete old notification rules if any new rules were created
for rule in user["oncall_user"]["notification_rules"]:
oncall_api_client.delete(
"personal_notification_rules/{}".format(rule["id"])
)
def transform_notification_rules(
notification_rules: list[dict], user_id: str