fix(health-agent): fix notification param name and type — notificationIDList expects a list of IDs not a dict
This commit is contained in:
parent
a5fc058978
commit
2827b227d5
@ -35,11 +35,7 @@ def find_parent_group(monitor_name, groups, group_map):
|
||||
def find_group_notifications(monitor_name, groups, notification_map):
|
||||
for g in groups:
|
||||
if monitor_name in g.get("children", []):
|
||||
ids = {}
|
||||
for n in g.get("notifications", []):
|
||||
nid = notification_map.get(n)
|
||||
if nid is not None:
|
||||
ids[str(nid)] = True
|
||||
ids = [notification_map[n] for n in g.get("notifications", []) if notification_map.get(n) is not None]
|
||||
return ids or None
|
||||
return None
|
||||
|
||||
@ -119,11 +115,7 @@ def setup_uptime_kuma(dry_run=False, only=None):
|
||||
raw_name = g["name"]
|
||||
formatted_name = f"{project} [{env_name}] {raw_name}"
|
||||
|
||||
notif_ids = {}
|
||||
for n in g.get("notifications", []):
|
||||
nid = notification_map.get(n)
|
||||
if nid is not None:
|
||||
notif_ids[str(nid)] = True
|
||||
notif_ids = [notification_map[n] for n in g.get("notifications", []) if notification_map.get(n) is not None]
|
||||
|
||||
logger.info(f"Processing group: {formatted_name}")
|
||||
if not dry_run:
|
||||
@ -131,7 +123,7 @@ def setup_uptime_kuma(dry_run=False, only=None):
|
||||
logger.info(f"Creating group monitor: {formatted_name}")
|
||||
kwargs = {"type": MonitorType.GROUP, "name": formatted_name}
|
||||
if notif_ids:
|
||||
kwargs["notification_id_list"] = notif_ids
|
||||
kwargs["notificationIDList"] = notif_ids
|
||||
res = api.add_monitor(**kwargs)
|
||||
group_map[raw_name] = res['monitorID']
|
||||
else:
|
||||
@ -168,7 +160,7 @@ def setup_uptime_kuma(dry_run=False, only=None):
|
||||
"parent": parent_group_id
|
||||
}
|
||||
if notif_ids:
|
||||
kwargs["notification_id_list"] = notif_ids
|
||||
kwargs["notificationIDList"] = notif_ids
|
||||
result = api.add_monitor(**kwargs)
|
||||
new_monitor_ids[m_name] = result['monitorID']
|
||||
else:
|
||||
@ -215,7 +207,7 @@ def setup_uptime_kuma(dry_run=False, only=None):
|
||||
if parent_group_id is not None:
|
||||
kwargs["parent"] = parent_group_id
|
||||
if notif_ids:
|
||||
kwargs["notification_id_list"] = notif_ids
|
||||
kwargs["notificationIDList"] = notif_ids
|
||||
api.add_monitor(**kwargs)
|
||||
logger.info(f"Created HTTP monitor: {m_name}")
|
||||
except Exception as e:
|
||||
@ -248,7 +240,7 @@ def setup_uptime_kuma(dry_run=False, only=None):
|
||||
if parent_group_id is not None:
|
||||
kwargs["parent"] = parent_group_id
|
||||
if notif_ids:
|
||||
kwargs["notification_id_list"] = notif_ids
|
||||
kwargs["notificationIDList"] = notif_ids
|
||||
api.add_monitor(**kwargs)
|
||||
logger.info(f"Created DNS monitor: {m_name}")
|
||||
except Exception as e:
|
||||
@ -284,7 +276,7 @@ def setup_uptime_kuma(dry_run=False, only=None):
|
||||
if parent_group_id is not None:
|
||||
kwargs["parent"] = parent_group_id
|
||||
if notif_ids:
|
||||
kwargs["notification_id_list"] = notif_ids
|
||||
kwargs["notificationIDList"] = notif_ids
|
||||
api.add_monitor(**kwargs)
|
||||
logger.info(f"Created Ping monitor: {m_name}")
|
||||
except Exception as e:
|
||||
@ -314,7 +306,7 @@ def setup_uptime_kuma(dry_run=False, only=None):
|
||||
if parent_group_id is not None:
|
||||
kwargs["parent"] = parent_group_id
|
||||
if notif_ids:
|
||||
kwargs["notification_id_list"] = notif_ids
|
||||
kwargs["notificationIDList"] = notif_ids
|
||||
api.add_monitor(**kwargs)
|
||||
logger.info(f"Created Ping monitor: {m_name}")
|
||||
except Exception as e:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user