2023-02-08 16:57:34 +02:00
|
|
|
from abc import ABC, abstractmethod
|
2023-02-13 13:16:35 +02:00
|
|
|
from typing import List
|
|
|
|
|
|
|
|
from selfprivacy_api.models.backup.snapshot import Snapshot
|
2023-02-08 16:57:34 +02:00
|
|
|
|
|
|
|
|
2023-06-23 15:04:33 +03:00
|
|
|
class AbstractBackupper(ABC):
|
2023-02-08 16:57:34 +02:00
|
|
|
def __init__(self):
|
|
|
|
pass
|
|
|
|
|
2023-03-14 02:39:15 +02:00
|
|
|
@abstractmethod
|
2023-06-19 14:09:10 +03:00
|
|
|
def is_initted(self) -> bool:
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def set_creds(self, account: str, key: str, repo: str):
|
2023-03-14 02:39:15 +02:00
|
|
|
raise NotImplementedError
|
|
|
|
|
2023-02-08 16:57:34 +02:00
|
|
|
@abstractmethod
|
2023-04-14 14:20:03 +03:00
|
|
|
def start_backup(self, folders: List[str], repo_name: str):
|
2023-02-08 16:57:34 +02:00
|
|
|
raise NotImplementedError
|
2023-02-13 13:16:35 +02:00
|
|
|
|
|
|
|
@abstractmethod
|
2023-06-19 17:12:40 +03:00
|
|
|
def get_snapshots(self) -> List[Snapshot]:
|
2023-02-13 13:16:35 +02:00
|
|
|
"""Get all snapshots from the repo"""
|
|
|
|
raise NotImplementedError
|
2023-02-17 18:11:17 +02:00
|
|
|
|
|
|
|
@abstractmethod
|
2023-06-23 12:40:10 +03:00
|
|
|
def init(self):
|
2023-02-17 18:11:17 +02:00
|
|
|
raise NotImplementedError
|
2023-02-22 16:45:11 +02:00
|
|
|
|
|
|
|
@abstractmethod
|
2023-06-23 12:40:10 +03:00
|
|
|
def restore_from_backup(self, snapshot_id: str, folders: List[str]):
|
2023-02-22 16:45:11 +02:00
|
|
|
"""Restore a target folder using a snapshot"""
|
|
|
|
raise NotImplementedError
|
2023-02-22 20:48:08 +02:00
|
|
|
|
|
|
|
@abstractmethod
|
2023-06-23 12:40:10 +03:00
|
|
|
def restored_size(self, snapshot_id: str) -> int:
|
2023-02-22 20:48:08 +02:00
|
|
|
raise NotImplementedError
|
2023-07-05 16:13:30 +03:00
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def forget_snapshot(self, snapshot_id):
|
|
|
|
raise NotImplementedError
|