mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-22 20:11:30 +00:00
fix(backups): try to actually get backup configuration
This commit is contained in:
parent
f950dd1e93
commit
0ef6569d97
|
@ -4,3 +4,5 @@ from selfprivacy_api.backup.restic_backuper import ResticBackuper
|
|||
|
||||
class Backblaze(AbstractBackupProvider):
|
||||
backuper = ResticBackuper("--b2-account", "--b2-key", ":b2:")
|
||||
|
||||
name = "BACKBLAZE"
|
||||
|
|
|
@ -5,6 +5,8 @@ from selfprivacy_api.backup.restic_backuper import ResticBackuper
|
|||
class LocalFileBackup(AbstractBackupProvider):
|
||||
backuper = ResticBackuper("", "", "memory")
|
||||
|
||||
name = "FILE"
|
||||
|
||||
# login and key args are for compatibility with generic provider methods. They are ignored.
|
||||
def __init__(self, filename: str, login: str = "", key: str = ""):
|
||||
super().__init__()
|
||||
|
|
|
@ -4,3 +4,5 @@ from selfprivacy_api.backup.restic_backuper import ResticBackuper
|
|||
|
||||
class InMemoryBackup(AbstractBackupProvider):
|
||||
backuper = ResticBackuper("", "", ":memory:")
|
||||
|
||||
name = "MEMORY"
|
||||
|
|
|
@ -18,22 +18,25 @@ class BackupConfiguration:
|
|||
# False when repo is not initialized and not ready to be used
|
||||
is_initialized: bool
|
||||
# If none, autobackups are disabled
|
||||
autobackup_period: typing.Optional[int] = None
|
||||
autobackup_period: typing.Optional[int]
|
||||
# Bucket name for Backblaze, path for some other providers
|
||||
location_name: typing.Optional[str] = None
|
||||
location_id: typing.Optional[str] = None
|
||||
location_name: typing.Optional[str]
|
||||
location_id: typing.Optional[str]
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class Backup:
|
||||
@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
|
||||
def configuration(self) -> BackupConfiguration:
|
||||
encryption_key = LocalBackupSecret.get()
|
||||
return BackupConfiguration(
|
||||
provider=BackupProvider[Backups.provider().name],
|
||||
encryption_key=encryption_key.decode() if encryption_key else "",
|
||||
is_initialized=Backups.is_initted(),
|
||||
autobackup_period=Backups.autobackup_period_minutes(),
|
||||
location_name=Backups.provider().location,
|
||||
location_id=Backups.provider().repo_id,
|
||||
)
|
||||
|
||||
@strawberry.field
|
||||
def all_snapshots(self) -> typing.List[SnapshotInfo]:
|
||||
|
|
|
@ -19,6 +19,7 @@ class ServerProvider(Enum):
|
|||
@strawberry.enum
|
||||
class BackupProvider(Enum):
|
||||
BACKBLAZE = "BACKBLAZE"
|
||||
NONE = "NONE"
|
||||
# for testing purposes, make sure not selectable in prod.
|
||||
MEMORY = "MEMORY"
|
||||
FILE = "FILE"
|
||||
|
|
Loading…
Reference in a new issue