2014-03-07 17:08:39 -07:00
|
|
|
import json
|
2014-02-27 16:55:07 -07:00
|
|
|
|
2014-03-10 16:51:08 -06:00
|
|
|
|
2014-02-27 16:55:07 -07:00
|
|
|
class Notification(object):
|
|
|
|
""" An abstract base class used to define the notification interface and common functions
|
|
|
|
"""
|
2014-03-11 09:50:24 -06:00
|
|
|
def __init__(self, src_partition, src_offset, tenant_id, name, address, timeout=60):
|
2014-03-07 17:08:39 -07:00
|
|
|
""" Setup the notification object
|
|
|
|
The src_partition and src_offset allow the notification to be linked to the alarm that it came from
|
2014-03-11 09:50:24 -06:00
|
|
|
The timeout is how long to wait for the notification to send. Waiting too long will cause other finished
|
|
|
|
notifications that come after this one to remain uncommitted.
|
2014-03-07 17:08:39 -07:00
|
|
|
"""
|
2014-03-11 09:50:24 -06:00
|
|
|
self.address = address
|
|
|
|
self.name = name
|
2014-03-07 17:08:39 -07:00
|
|
|
self.src_partition = src_partition
|
|
|
|
self.src_offset = src_offset
|
2014-03-11 09:50:24 -06:00
|
|
|
self.tenant_id = tenant_id
|
|
|
|
self.timeout = timeout
|
2014-03-07 17:08:39 -07:00
|
|
|
|
|
|
|
def to_json(self):
|
|
|
|
""" Return json representation
|
|
|
|
"""
|
|
|
|
return json.dumps(self.__dict__)
|
|
|
|
|
|
|
|
def send(self):
|
|
|
|
""" Send the notification
|
|
|
|
"""
|
|
|
|
raise NotImplementedError
|