diff --git a/restic_compose_backup/alerts/__init__.py b/restic_compose_backup/alerts/__init__.py new file mode 100644 index 0000000..5c0453a --- /dev/null +++ b/restic_compose_backup/alerts/__init__.py @@ -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 diff --git a/restic_compose_backup/alerts/base.py b/restic_compose_backup/alerts/base.py new file mode 100644 index 0000000..4df5ad2 --- /dev/null +++ b/restic_compose_backup/alerts/base.py @@ -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 diff --git a/restic_compose_backup/alerts/config.py b/restic_compose_backup/alerts/config.py new file mode 100644 index 0000000..2333c2a --- /dev/null +++ b/restic_compose_backup/alerts/config.py @@ -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 diff --git a/restic_compose_backup/alerts/discord.py b/restic_compose_backup/alerts/discord.py new file mode 100644 index 0000000..98c3a54 --- /dev/null +++ b/restic_compose_backup/alerts/discord.py @@ -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 diff --git a/restic_compose_backup/alerts/smtp.py b/restic_compose_backup/alerts/smtp.py new file mode 100644 index 0000000..91b721e --- /dev/null +++ b/restic_compose_backup/alerts/smtp.py @@ -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