2023-01-23 11:15:05 +00:00
|
|
|
"""Backup"""
|
|
|
|
# pylint: disable=too-few-public-methods
|
|
|
|
import typing
|
|
|
|
import strawberry
|
2023-05-29 16:12:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
from selfprivacy_api.backup import Backups
|
|
|
|
from selfprivacy_api.backup.local_secret import LocalBackupSecret
|
|
|
|
from selfprivacy_api.graphql.queries.providers import BackupProvider
|
|
|
|
from selfprivacy_api.graphql.common_types.service import SnapshotInfo
|
|
|
|
|
|
|
|
|
|
|
|
@strawberry.type
|
|
|
|
class BackupConfiguration:
|
|
|
|
provider: BackupProvider
|
|
|
|
# When server is lost, the app should have the key to decrypt backups on a new server
|
|
|
|
encryption_key: str
|
|
|
|
# If none, autobackups are disabled
|
|
|
|
autobackup_period: typing.Optional[int] = None
|
|
|
|
# Bucket name for Backblaze, path for some other providers
|
|
|
|
location_name: typing.Optional[str] = None
|
|
|
|
location_id: typing.Optional[str] = None
|
|
|
|
# False when repo is not initialized and not ready to be used
|
|
|
|
is_initialized: bool
|
2023-01-23 11:15:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
@strawberry.type
|
|
|
|
class Backup:
|
2023-05-29 16:12:22 +00:00
|
|
|
@strawberry.field
|
|
|
|
def configuration() -> BackupConfiguration:
|
|
|
|
config = BackupConfiguration()
|
|
|
|
config.encryption_key = LocalBackupSecret.get()
|
|
|
|
config.is_initialized = Backups.is_initted()
|
|
|
|
config.autobackup_period = Backups.autobackup_period_minutes()
|
|
|
|
config.location_name = Backups.provider().location
|
|
|
|
config.location_id = Backups.provider().repo_id
|
2023-01-23 11:15:05 +00:00
|
|
|
|
|
|
|
@strawberry.field
|
2023-05-29 16:12:22 +00:00
|
|
|
def all_snapshots(self) -> typing.List[SnapshotInfo]:
|
2023-01-23 11:15:05 +00:00
|
|
|
return []
|