diff --git a/selfprivacy_api/graphql/common_types/service.py b/selfprivacy_api/graphql/common_types/service.py index fd671d4..836a3df 100644 --- a/selfprivacy_api/graphql/common_types/service.py +++ b/selfprivacy_api/graphql/common_types/service.py @@ -94,6 +94,7 @@ class Service: is_required: bool is_enabled: bool can_be_backed_up: bool + backup_description: str status: ServiceStatusEnum url: typing.Optional[str] dns_records: typing.Optional[typing.List[DnsRecord]] @@ -126,6 +127,7 @@ def service_to_graphql_service(service: ServiceInterface) -> Service: is_required=service.is_required(), is_enabled=service.is_enabled(), can_be_backed_up=service.can_be_backed_up(), + backup_description=service.get_backup_description(), status=ServiceStatusEnum(service.get_status().value), url=service.get_url(), dns_records=[ diff --git a/selfprivacy_api/services/bitwarden/__init__.py b/selfprivacy_api/services/bitwarden/__init__.py index 6842af6..98455d8 100644 --- a/selfprivacy_api/services/bitwarden/__init__.py +++ b/selfprivacy_api/services/bitwarden/__init__.py @@ -55,6 +55,10 @@ class Bitwarden(Service): def is_required() -> bool: return False + @staticmethod + def get_backup_description() -> str: + return "Password database, encryption certificate and attachments." + @staticmethod def is_enabled() -> bool: with ReadUserData() as user_data: diff --git a/selfprivacy_api/services/gitea/__init__.py b/selfprivacy_api/services/gitea/__init__.py index f9ff3d2..ce73dc6 100644 --- a/selfprivacy_api/services/gitea/__init__.py +++ b/selfprivacy_api/services/gitea/__init__.py @@ -51,6 +51,10 @@ class Gitea(Service): def is_required() -> bool: return False + @staticmethod + def get_backup_description() -> str: + return "Git repositories, database and user data." + @staticmethod def is_enabled() -> bool: with ReadUserData() as user_data: diff --git a/selfprivacy_api/services/jitsi/__init__.py b/selfprivacy_api/services/jitsi/__init__.py index a969eb2..2b54ae1 100644 --- a/selfprivacy_api/services/jitsi/__init__.py +++ b/selfprivacy_api/services/jitsi/__init__.py @@ -54,6 +54,10 @@ class Jitsi(Service): def is_required() -> bool: return False + @staticmethod + def get_backup_description() -> str: + return "Secrets that are used to encrypt the communication." + @staticmethod def is_enabled() -> bool: with ReadUserData() as user_data: diff --git a/selfprivacy_api/services/mailserver/__init__.py b/selfprivacy_api/services/mailserver/__init__.py index b0a6e30..d3600e5 100644 --- a/selfprivacy_api/services/mailserver/__init__.py +++ b/selfprivacy_api/services/mailserver/__init__.py @@ -54,6 +54,10 @@ class MailServer(Service): def is_required() -> bool: return True + @staticmethod + def get_backup_description() -> str: + return "Mail boxes and filters." + @staticmethod def is_enabled() -> bool: return True diff --git a/selfprivacy_api/services/nextcloud/__init__.py b/selfprivacy_api/services/nextcloud/__init__.py index ae81403..632c5d3 100644 --- a/selfprivacy_api/services/nextcloud/__init__.py +++ b/selfprivacy_api/services/nextcloud/__init__.py @@ -49,6 +49,10 @@ class Nextcloud(Service): def is_required() -> bool: return False + @staticmethod + def get_backup_description() -> str: + return "All the files and other data stored in Nextcloud." + @staticmethod def is_enabled() -> bool: with ReadUserData() as user_data: diff --git a/selfprivacy_api/services/ocserv/__init__.py b/selfprivacy_api/services/ocserv/__init__.py index 4f46692..3860b19 100644 --- a/selfprivacy_api/services/ocserv/__init__.py +++ b/selfprivacy_api/services/ocserv/__init__.py @@ -48,6 +48,10 @@ class Ocserv(Service): def can_be_backed_up() -> bool: return False + @staticmethod + def get_backup_description() -> str: + return "Nothing to backup." + @staticmethod def is_enabled() -> bool: with ReadUserData() as user_data: diff --git a/selfprivacy_api/services/pleroma/__init__.py b/selfprivacy_api/services/pleroma/__init__.py index 0d5b338..bac1cda 100644 --- a/selfprivacy_api/services/pleroma/__init__.py +++ b/selfprivacy_api/services/pleroma/__init__.py @@ -46,6 +46,10 @@ class Pleroma(Service): def is_required() -> bool: return False + @staticmethod + def get_backup_description() -> str: + return "Your Pleroma accounts, posts and media." + @staticmethod def is_enabled() -> bool: with ReadUserData() as user_data: diff --git a/selfprivacy_api/services/service.py b/selfprivacy_api/services/service.py index 65337b4..286fab7 100644 --- a/selfprivacy_api/services/service.py +++ b/selfprivacy_api/services/service.py @@ -41,83 +41,125 @@ class Service(ABC): @staticmethod @abstractmethod def get_id() -> str: + """ + The unique id of the service. + """ pass @staticmethod @abstractmethod def get_display_name() -> str: + """ + The name of the service that is shown to the user. + """ pass @staticmethod @abstractmethod def get_description() -> str: + """ + The description of the service that is shown to the user. + """ pass @staticmethod @abstractmethod def get_svg_icon() -> str: + """ + The monochrome svg icon of the service. + """ pass @staticmethod @abstractmethod def get_url() -> typing.Optional[str]: + """ + The url of the service if it is accessible from the internet browser. + """ pass @classmethod def get_user(cls) -> typing.Optional[str]: + """ + The user that owns the service's files. + Defaults to the service's id. + """ return cls.get_id() @classmethod def get_group(cls) -> typing.Optional[str]: + """ + The group that owns the service's files. + Defaults to the service's user. + """ return cls.get_user() @staticmethod @abstractmethod def is_movable() -> bool: + """`True` if the service can be moved to the non-system volume.""" pass @staticmethod @abstractmethod def is_required() -> bool: + """`True` if the service is required for the server to function.""" pass @staticmethod def can_be_backed_up() -> bool: + """`True` if the service can be backed up.""" return True + @staticmethod + @abstractmethod + def get_backup_description() -> str: + """ + The text shown to the user that exlplains what data will be + backed up. + """ + pass + @staticmethod @abstractmethod def is_enabled() -> bool: + """`True` if the service is enabled.""" pass @staticmethod @abstractmethod def get_status() -> ServiceStatus: + """The status of the service, reported by systemd.""" pass @staticmethod @abstractmethod def enable(): + """Enable the service. Usually this means enabling systemd unit.""" pass @staticmethod @abstractmethod def disable(): + """Disable the service. Usually this means disabling systemd unit.""" pass @staticmethod @abstractmethod def stop(): + """Stop the service. Usually this means stopping systemd unit.""" pass @staticmethod @abstractmethod def start(): + """Start the service. Usually this means starting systemd unit.""" pass @staticmethod @abstractmethod def restart(): + """Restart the service. Usually this means restarting systemd unit.""" pass @staticmethod diff --git a/selfprivacy_api/services/test_service/__init__.py b/selfprivacy_api/services/test_service/__init__.py index b1c2924..af527a0 100644 --- a/selfprivacy_api/services/test_service/__init__.py +++ b/selfprivacy_api/services/test_service/__init__.py @@ -53,6 +53,10 @@ class DummyService(Service): def is_required() -> bool: return False + @staticmethod + def get_backup_description() -> str: + return "How did we get here?" + @staticmethod def is_enabled() -> bool: return True