diff --git a/argusclient/client.py b/argusclient/client.py index ef13848..e44717f 100644 --- a/argusclient/client.py +++ b/argusclient/client.py @@ -416,7 +416,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] diff --git a/argusclient/model.py b/argusclient/model.py index 8397f7b..1015993 100644 --- a/argusclient/model.py +++ b/argusclient/model.py @@ -327,6 +327,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)) + for item in value: + if not isinstance(item, Notification): raise ValueError("array member should be of Notification type, but is: %s" % type(item)) # This is a special case allowed only while adding new alerts, so ensure that argus_id of self and the objects is None. # TODO Check for item type also self._notifications = value