2019-12-04 18:36:14 +00:00
|
|
|
from restic_compose_backup.alerts.smtp import SMTPAlert
|
|
|
|
from restic_compose_backup.alerts.discord import DiscordWebhookAlert
|
|
|
|
from restic_compose_backup.config import Config
|
|
|
|
|
2019-12-04 02:58:27 +00:00
|
|
|
ALERT_INFO = 'INFO',
|
|
|
|
ALERT_ERROR = 'ERROR'
|
|
|
|
ALERT_TYPES = [ALERT_INFO, ALERT_ERROR]
|
2019-12-04 18:36:14 +00:00
|
|
|
BACKENDS = [SMTPAlert, DiscordWebhookAlert]
|
2019-12-04 02:58:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
def send(subject: str = None, attachment: str = None, alert_type: str = ALERT_ERROR):
|
|
|
|
"""Send an alert"""
|
|
|
|
pass
|
2019-12-04 18:36:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
def configured_alert_classes():
|
|
|
|
"""Returns a list of configured alert class instances"""
|
|
|
|
entires = []
|
|
|
|
|
|
|
|
for cls in BACKENDS:
|
|
|
|
instance = cls.create_from_env()
|
|
|
|
if instance:
|
|
|
|
entires.append(instance)
|
|
|
|
|
|
|
|
return entires
|