Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions argusclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,8 @@ def __init__(self, argus, get_all_req_opts=None):
super(AlertsServiceClient, self).__init__(Alert, argus, id_path="alerts/%s", get_all_req_opts=get_all_req_opts)

def _fill(self, alert):
alert._triggers = AlertTriggersServiceClient(self.argus, alert)
alert._notifications = AlertNotificationsServiceClient(self.argus, alert)
alert._triggers_client = AlertTriggersServiceClient(self.argus, alert)
alert._notifications_client = AlertNotificationsServiceClient(self.argus, alert)
return alert

def add(self, alert):
Expand All @@ -566,9 +566,9 @@ def add(self, alert):
alertobj = self._fill(self.argus._request("post", "alerts", dataObj=alert))
self._coll[alertobj.id] = alertobj
if alert.trigger:
alertobj.trigger = alertobj.triggers.add(alert.trigger)
alertobj.trigger = alertobj.triggers_client.add(alert.trigger)
if alert.notification:
alertobj.notification = alertobj.notifications.add(alert.notification)
alertobj.notification = alertobj.notifications_client.add(alert.notification)
if 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]
Expand Down
10 changes: 10 additions & 0 deletions argusclient/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ class Alert(BaseEncodable):
def __init__(self, name, expression, cronEntry, **kwargs):
self._triggers = None
self._notifications = None
self._triggers_client = None
self._notifications_client = None
super(Alert, self).__init__(name=name, expression=expression, cronEntry=cronEntry, **kwargs)

@property
Expand Down Expand Up @@ -357,6 +359,10 @@ def triggers(self, value):
# TODO Check for item type also
self._triggers = value

@property
def triggers_client(self):
return self._triggers_client

@property
def notification(self):
""" A convenience property to be used when :attr:`notifications` contains a single :class:`argusclient.model.Notification`. """
Expand All @@ -383,6 +389,10 @@ def notifications(self, value):
# TODO Check for item type also
self._notifications = value

@property
def notifications_client(self):
return self._notifications_client


class Trigger(BaseEncodable):
"""
Expand Down