2023-02-01 11:58:55 +00:00
|
|
|
from selfprivacy_api.graphql.queries.providers import BackupProvider
|
|
|
|
from selfprivacy_api.backup.providers.provider import AbstractBackupProvider
|
|
|
|
|
|
|
|
from selfprivacy_api.backup.providers.backblaze import Backblaze
|
2023-02-03 18:29:45 +00:00
|
|
|
from selfprivacy_api.backup.providers.memory import InMemoryBackup
|
2023-02-20 11:44:59 +00:00
|
|
|
from selfprivacy_api.backup.providers.local_file import LocalFileBackup
|
2023-02-01 11:58:55 +00:00
|
|
|
|
|
|
|
PROVIDER_MAPPING = {
|
2023-02-03 18:29:45 +00:00
|
|
|
BackupProvider.BACKBLAZE: Backblaze,
|
|
|
|
BackupProvider.MEMORY: InMemoryBackup,
|
2023-02-20 11:44:59 +00:00
|
|
|
BackupProvider.FILE: LocalFileBackup,
|
2023-06-16 16:03:09 +00:00
|
|
|
BackupProvider.NONE: AbstractBackupProvider,
|
2023-02-01 11:58:55 +00:00
|
|
|
}
|
|
|
|
|
2023-02-03 18:29:45 +00:00
|
|
|
|
|
|
|
def get_provider(provider_type: BackupProvider) -> AbstractBackupProvider:
|
2023-02-01 11:58:55 +00:00
|
|
|
return PROVIDER_MAPPING[provider_type]
|
2023-03-13 19:03:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
def get_kind(provider: AbstractBackupProvider) -> str:
|
|
|
|
for key, value in PROVIDER_MAPPING.items():
|
|
|
|
if isinstance(provider, value):
|
|
|
|
return key.value
|