diff --git a/selfprivacy_api/backup/__init__.py b/selfprivacy_api/backup/__init__.py index 265ee0f..72d1567 100644 --- a/selfprivacy_api/backup/__init__.py +++ b/selfprivacy_api/backup/__init__.py @@ -335,27 +335,27 @@ class Backups: buckets: list[RotationBucket] = [ RotationBucket( - quotas.last, + quotas.last, # type: ignore -1, lambda _, index: index, ), RotationBucket( - quotas.daily, + quotas.daily, # type: ignore -1, lambda date, _: date.year * 10000 + date.month * 100 + date.day, ), RotationBucket( - quotas.weekly, + quotas.weekly, # type: ignore -1, lambda date, _: date.year * 100 + date.isocalendar()[1], ), RotationBucket( - quotas.monthly, + quotas.monthly, # type: ignore -1, lambda date, _: date.year * 100 + date.month, ), RotationBucket( - quotas.yearly, + quotas.yearly, # type: ignore -1, lambda date, _: date.year, ), @@ -409,11 +409,11 @@ class Backups: Storage.set_autobackup_quotas( AutobackupQuotas( - last=Backups._standardize_quotas(quotas.last), - daily=Backups._standardize_quotas(quotas.daily), - weekly=Backups._standardize_quotas(quotas.weekly), - monthly=Backups._standardize_quotas(quotas.monthly), - yearly=Backups._standardize_quotas(quotas.yearly), + last=Backups._standardize_quotas(quotas.last), # type: ignore + daily=Backups._standardize_quotas(quotas.daily), # type: ignore + weekly=Backups._standardize_quotas(quotas.weekly), # type: ignore + monthly=Backups._standardize_quotas(quotas.monthly), # type: ignore + yearly=Backups._standardize_quotas(quotas.yearly), # type: ignore ) ) @@ -438,7 +438,7 @@ class Backups: job: Job, ) -> None: Jobs.update( - job, status=JobStatus.CREATED, status_text=f"Waiting for pre-restore backup" + job, status=JobStatus.CREATED, status_text="Waiting for pre-restore backup" ) failsafe_snapshot = Backups.back_up(service, BackupReason.PRE_RESTORE) diff --git a/selfprivacy_api/dependencies.py b/selfprivacy_api/dependencies.py index 9e144fd..35cf9e1 100644 --- a/selfprivacy_api/dependencies.py +++ b/selfprivacy_api/dependencies.py @@ -27,4 +27,4 @@ async def get_token_header( def get_api_version() -> str: """Get API version""" - return "2.4.0" + return "2.4.1" diff --git a/selfprivacy_api/graphql/common_types/service.py b/selfprivacy_api/graphql/common_types/service.py index 836a3df..319ce3e 100644 --- a/selfprivacy_api/graphql/common_types/service.py +++ b/selfprivacy_api/graphql/common_types/service.py @@ -2,6 +2,7 @@ from enum import Enum import typing import strawberry import datetime +from selfprivacy_api.graphql.common_types.backup import BackupReason from selfprivacy_api.graphql.common_types.dns import DnsRecord from selfprivacy_api.services import get_service_by_id, get_services_by_location @@ -114,6 +115,7 @@ class SnapshotInfo: id: str service: Service created_at: datetime.datetime + reason: BackupReason def service_to_graphql_service(service: ServiceInterface) -> Service: diff --git a/selfprivacy_api/graphql/queries/backup.py b/selfprivacy_api/graphql/queries/backup.py index 6d47a8c..fc5f78a 100644 --- a/selfprivacy_api/graphql/queries/backup.py +++ b/selfprivacy_api/graphql/queries/backup.py @@ -77,6 +77,7 @@ class Backup: id=snap.id, service=service, created_at=snap.created_at, + reason=snap.reason, ) result.append(graphql_snap) return result diff --git a/selfprivacy_api/models/backup/snapshot.py b/selfprivacy_api/models/backup/snapshot.py index 28ad661..b2831e7 100644 --- a/selfprivacy_api/models/backup/snapshot.py +++ b/selfprivacy_api/models/backup/snapshot.py @@ -8,4 +8,4 @@ class Snapshot(BaseModel): id: str service_name: str created_at: datetime.datetime - reason: BackupReason + reason: BackupReason = BackupReason.EXPLICIT diff --git a/setup.py b/setup.py index 5ce3947..44d2336 100755 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="selfprivacy_api", - version="2.4.0", + version="2.4.1", packages=find_packages(), scripts=[ "selfprivacy_api/app.py", diff --git a/tests/test_graphql/test_api_backup.py b/tests/test_graphql/test_api_backup.py index 14410e3..225abf7 100644 --- a/tests/test_graphql/test_api_backup.py +++ b/tests/test_graphql/test_api_backup.py @@ -145,6 +145,7 @@ allSnapshots { id } createdAt + reason } """