Basic alert system setup

This commit is contained in:
Einar Forselv 2019-12-04 03:58:27 +01:00
parent 7ca7f56258
commit 85e9efb769
5 changed files with 70 additions and 0 deletions

View File

@ -0,0 +1,8 @@
ALERT_INFO = 'INFO',
ALERT_ERROR = 'ERROR'
ALERT_TYPES = [ALERT_INFO, ALERT_ERROR]
def send(subject: str = None, attachment: str = None, alert_type: str = ALERT_ERROR):
"""Send an alert"""
pass

View File

@ -0,0 +1,14 @@
from restic_compose_backup.alerts import ALERT_INFO, ALERT_ERROR, ALERT_TYPES
class BaseAlert:
name = None
def __init__(self):
pass
def create_from_config(self, config):
pass
def send(self, self, subject=None, attachment=None, alert_type=ALERT_ERROR):
pass

View File

@ -0,0 +1,20 @@
"""Check config and expose properly configured alert backends"""
from restic_compose_backup.alerts.smtp import SMTPAlert
from restic_compose_backup.alerts.discord import DiscordWebhookAlert
from restic_compose_backup.config import Config
BACKENDS = [SMTPAlert, DiscordWebhookAlert]
def configured_alert_classes():
"""Returns a list of configured alert class instances"""
config = Config()
entires = []
for cls in BACKENDS:
instance = cls.create_from_config(config)
if instance:
entires.append(instance)
return entires

View File

@ -0,0 +1,14 @@
from restic_compose_backup.alerts.base import BaseAlert
class DiscordWebhookAlert(BaseAlert):
name = 'discord_webhook'
def __init__(self):
pass
def create_from_config(self, config):
pass
def send(self, self, subject=None, attachment=None, alert_type=ALERT_ERROR):
pass

View File

@ -0,0 +1,14 @@
from restic_compose_backup.alerts.base import BaseAlert
class SMTPAlert(BaseAlert):
name = 'smtp'
def __init__(self):
pass
def create_from_config(self, config):
pass
def send(self, self, subject=None, attachment=None, alert_type=ALERT_ERROR):
pass