From fbed1854754e8df12285d1d1476c5ea1ec9912a0 Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Mon, 23 Jan 2023 11:15:05 +0000 Subject: [PATCH] feature(backups): add backup structures and queries --- .../graphql/common_types/backup_snapshot.py | 9 +++++++++ selfprivacy_api/graphql/common_types/service.py | 6 ++++++ selfprivacy_api/graphql/queries/backup.py | 14 ++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 selfprivacy_api/graphql/common_types/backup_snapshot.py create mode 100644 selfprivacy_api/graphql/queries/backup.py diff --git a/selfprivacy_api/graphql/common_types/backup_snapshot.py b/selfprivacy_api/graphql/common_types/backup_snapshot.py new file mode 100644 index 0000000..3256e0c --- /dev/null +++ b/selfprivacy_api/graphql/common_types/backup_snapshot.py @@ -0,0 +1,9 @@ +import datetime +import strawberry + + +@strawberry.type +class SnapshotInfo: + id: str + service_name: str + created_at: datetime.datetime diff --git a/selfprivacy_api/graphql/common_types/service.py b/selfprivacy_api/graphql/common_types/service.py index c1246ca..61ed5af 100644 --- a/selfprivacy_api/graphql/common_types/service.py +++ b/selfprivacy_api/graphql/common_types/service.py @@ -1,7 +1,9 @@ from enum import Enum import typing import strawberry +import datetime from selfprivacy_api.graphql.common_types.dns import DnsRecord +from selfprivacy_api.graphql.common_types.backup_snapshot import SnapshotInfo from selfprivacy_api.services import get_service_by_id, get_services_by_location from selfprivacy_api.services import Service as ServiceInterface @@ -101,6 +103,10 @@ class Service: """Get storage usage for a service""" return get_storage_usage(self) + @strawberry.field + def backup_snapshots(self) -> typing.Optional[typing.List[SnapshotInfo]]: + return None + def service_to_graphql_service(service: ServiceInterface) -> Service: """Convert service to graphql service""" diff --git a/selfprivacy_api/graphql/queries/backup.py b/selfprivacy_api/graphql/queries/backup.py new file mode 100644 index 0000000..ef61b10 --- /dev/null +++ b/selfprivacy_api/graphql/queries/backup.py @@ -0,0 +1,14 @@ +"""Backup""" +# pylint: disable=too-few-public-methods +import typing +import strawberry +from selfprivacy_api.graphql.common_types.backup_snapshot import SnapshotInfo + + +@strawberry.type +class Backup: + backend: str + + @strawberry.field + def get_backups(self) -> typing.List[SnapshotInfo]: + return []