mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-23 04:21:29 +00:00
30 lines
1,013 B
Python
30 lines
1,013 B
Python
from typing import Type
|
|
|
|
from selfprivacy_api.graphql.queries.providers import (
|
|
BackupProvider as BackupProviderEnum,
|
|
)
|
|
from selfprivacy_api.backup.providers.provider import AbstractBackupProvider
|
|
|
|
from selfprivacy_api.backup.providers.backblaze import Backblaze
|
|
from selfprivacy_api.backup.providers.memory import InMemoryBackup
|
|
from selfprivacy_api.backup.providers.local_file import LocalFileBackup
|
|
from selfprivacy_api.backup.providers.none import NoBackups
|
|
|
|
PROVIDER_MAPPING: dict[BackupProviderEnum, Type[AbstractBackupProvider]] = {
|
|
BackupProviderEnum.BACKBLAZE: Backblaze,
|
|
BackupProviderEnum.MEMORY: InMemoryBackup,
|
|
BackupProviderEnum.FILE: LocalFileBackup,
|
|
BackupProviderEnum.NONE: NoBackups,
|
|
}
|
|
|
|
|
|
def get_provider(
|
|
provider_type: BackupProviderEnum,
|
|
) -> Type[AbstractBackupProvider]:
|
|
return PROVIDER_MAPPING[provider_type]
|
|
|
|
|
|
def get_kind(provider: AbstractBackupProvider) -> str:
|
|
"""Get the kind of the provider in the form of a string"""
|
|
return provider.name.value
|