mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-02-02 14:16:38 +00:00
feature(backups): a graphql query to get provider info
This commit is contained in:
parent
d0b27da641
commit
e7683352cd
|
@ -108,6 +108,13 @@ class Service:
|
|||
return None
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class SnapshotInfo:
|
||||
id: str
|
||||
service: "Service"
|
||||
created_at: datetime.datetime
|
||||
|
||||
|
||||
def service_to_graphql_service(service: ServiceInterface) -> Service:
|
||||
"""Convert service to graphql service"""
|
||||
return Service(
|
||||
|
|
|
@ -2,13 +2,39 @@
|
|||
# pylint: disable=too-few-public-methods
|
||||
import typing
|
||||
import strawberry
|
||||
from selfprivacy_api.graphql.common_types.backup_snapshot import SnapshotInfo
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class Backup:
|
||||
backend: str
|
||||
@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
|
||||
|
||||
@strawberry.field
|
||||
def get_backups(self) -> typing.List[SnapshotInfo]:
|
||||
def all_snapshots(self) -> typing.List[SnapshotInfo]:
|
||||
return []
|
||||
|
|
Loading…
Reference in a new issue