From 49bb57e8659115eaf73f3039effb29b41e981ffd Mon Sep 17 00:00:00 2001 From: Adam McKenna Date: Mon, 23 Jan 2017 17:29:39 -0800 Subject: [PATCH 1/2] Check for item type --- argusclient/model.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/argusclient/model.py b/argusclient/model.py index 130c2bd..fe167f1 100644 --- a/argusclient/model.py +++ b/argusclient/model.py @@ -324,7 +324,8 @@ def notifications(self): @notifications.setter def notifications(self, value): if not isinstance(value, list): raise ValueError("value should be of list type, but is: %s" % type(value)) - # TODO Check for item type also + for item in value: + if not isinstance(item, Notification): raise ValueError("array member should be of Notification type, but is: %s" % type(item)) self._notifications = value From 2e7592de16e7f2d942e92b452138195a33498318 Mon Sep 17 00:00:00 2001 From: Adam McKenna Date: Mon, 23 Jan 2017 17:29:46 -0800 Subject: [PATCH 2/2] Support for adding multiple notifications with new alert --- argusclient/client.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/argusclient/client.py b/argusclient/client.py index f9f276b..30f9c19 100644 --- a/argusclient/client.py +++ b/argusclient/client.py @@ -391,7 +391,18 @@ def add(self, alert): alertobj.trigger = alertobj.triggers.add(alert.trigger) if alert.notification: alertobj.notification = alertobj.notifications.add(alert.notification) - if alert.trigger and alert.notification: + elif alert.notifications and isinstance(alert.notifications, list): + notifications = [] + for notification in alert.notifications: + notifications.append(alertobj.notifications.add(notification)) + alertobj.notifications = notifications + if alert.trigger and alert.notifications: + alertobj.trigger.notificationsIds = [] + for notification in alertobj.notifications: + self.argus.alerts.add_notification_trigger(alertobj.id, notification.id, alertobj.trigger.id) + notification.triggersIds = [alertobj.trigger.id] + alertobj.trigger.notificationsIds.append(notification.id) + elif alert.trigger and alert.notification: self.argus.alerts.add_notification_trigger(alertobj.id, alertobj.notification.id, alertobj.trigger.id) alertobj.notification.triggersIds = [alertobj.trigger.id] alertobj.trigger.notificationsIds = [alertobj.notification.id]