2015-07-30 02:13:06 +02:00
|
|
|
"""
|
2016-12-14 18:29:04 +01:00
|
|
|
.. module: lemur.plugins.bases.notification
|
2015-07-30 02:13:06 +02:00
|
|
|
:platform: Unix
|
2018-05-29 19:18:16 +02:00
|
|
|
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
|
2015-07-30 02:13:06 +02:00
|
|
|
:license: Apache, see LICENSE for more details.
|
|
|
|
|
|
|
|
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
|
|
|
|
"""
|
|
|
|
from lemur.plugins.base import Plugin
|
|
|
|
|
|
|
|
|
|
|
|
class NotificationPlugin(Plugin):
|
|
|
|
"""
|
|
|
|
This is the base class from which all of the supported
|
|
|
|
issuers will inherit from.
|
|
|
|
"""
|
2019-05-16 16:57:02 +02:00
|
|
|
|
|
|
|
type = "notification"
|
2015-07-30 02:13:06 +02:00
|
|
|
|
2016-12-08 20:33:40 +01:00
|
|
|
def send(self, notification_type, message, targets, options, **kwargs):
|
2015-07-30 02:13:06 +02:00
|
|
|
raise NotImplementedError
|
|
|
|
|
2020-11-12 00:21:40 +01:00
|
|
|
def get_recipients(self, options, additional_recipients):
|
2020-10-16 19:40:11 +02:00
|
|
|
"""
|
2020-11-12 00:21:40 +01:00
|
|
|
Given a set of options (which should include configured recipient info), returns the parsed list of recipients
|
|
|
|
from those options plus the additional recipients specified. The returned value has no duplicates.
|
2020-10-16 19:40:11 +02:00
|
|
|
|
2020-11-12 00:21:40 +01:00
|
|
|
For any notification types where recipients can't be dynamically modified, this returns only the additional recipients.
|
2020-10-16 19:40:11 +02:00
|
|
|
"""
|
2020-11-12 00:21:40 +01:00
|
|
|
return additional_recipients
|
2020-10-16 19:40:11 +02:00
|
|
|
|
2015-07-30 02:13:06 +02:00
|
|
|
|
|
|
|
class ExpirationNotificationPlugin(NotificationPlugin):
|
|
|
|
"""
|
|
|
|
This is the base class for all expiration notification plugins.
|
|
|
|
It contains some default options that are needed for all expiration
|
|
|
|
notification plugins.
|
|
|
|
"""
|
2019-05-16 16:57:02 +02:00
|
|
|
|
2015-07-30 02:13:06 +02:00
|
|
|
default_options = [
|
|
|
|
{
|
2019-05-16 16:57:02 +02:00
|
|
|
"name": "interval",
|
|
|
|
"type": "int",
|
|
|
|
"required": True,
|
2020-11-03 03:16:15 +01:00
|
|
|
"validation": r"^\d+$",
|
2019-05-16 16:57:02 +02:00
|
|
|
"helpMessage": "Number of days to be alert before expiration.",
|
2015-07-30 02:13:06 +02:00
|
|
|
},
|
|
|
|
{
|
2019-05-16 16:57:02 +02:00
|
|
|
"name": "unit",
|
|
|
|
"type": "select",
|
|
|
|
"required": True,
|
|
|
|
"validation": "",
|
|
|
|
"available": ["days", "weeks", "months"],
|
|
|
|
"helpMessage": "Interval unit",
|
|
|
|
},
|
2015-07-30 02:13:06 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
@property
|
2016-07-06 19:27:13 +02:00
|
|
|
def options(self):
|
2021-02-19 02:23:02 +01:00
|
|
|
"""
|
|
|
|
Gets/sets options for the plugin.
|
|
|
|
|
|
|
|
:return:
|
|
|
|
"""
|
2017-10-06 02:27:45 +02:00
|
|
|
return self.default_options + self.additional_options
|
2015-07-30 02:13:06 +02:00
|
|
|
|
2020-10-16 19:40:11 +02:00
|
|
|
def send(self, notification_type, message, excluded_targets, options, **kwargs):
|
2015-07-30 02:13:06 +02:00
|
|
|
raise NotImplementedError
|