diff --git a/selfprivacy_api/graphql/mutations/backup_mutations.py b/selfprivacy_api/graphql/mutations/backup_mutations.py index b92af4a..f6dc282 100644 --- a/selfprivacy_api/graphql/mutations/backup_mutations.py +++ b/selfprivacy_api/graphql/mutations/backup_mutations.py @@ -157,6 +157,35 @@ class BackupMutations: job=job_to_api_job(job), ) + @strawberry.mutation(permission_classes=[IsAuthenticated]) + def forget_snapshot(self, snapshot_id: str) -> GenericMutationReturn: + """Forget a snapshot. + Makes it inaccessible from the server. + After some time, the data (encrypted) will not be recoverable + from the backup server too, but not immediately""" + + snap = Backups.get_snapshot_by_id(snapshot_id) + if snap is None: + return GenericMutationReturn( + success=False, + code=404, + message=f"snapshot {snapshot_id} not found", + ) + + try: + Backups.forget_snapshot(snap) + return GenericMutationReturn( + success=True, + code=200, + message="", + ) + except Exception as error: + return GenericMutationReturn( + success=False, + code=400, + message=str(error), + ) + @strawberry.mutation(permission_classes=[IsAuthenticated]) def force_snapshots_reload(self) -> GenericMutationReturn: """Force snapshots reload"""