56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
|
|
"""Store backend base types.
|
||
|
|
|
||
|
|
Concrete store implementations live in the `Store/` package.
|
||
|
|
"""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from abc import ABC, abstractmethod
|
||
|
|
from pathlib import Path
|
||
|
|
from typing import Any, Dict, List, Optional, Tuple
|
||
|
|
|
||
|
|
|
||
|
|
class StoreBackend(ABC):
|
||
|
|
@abstractmethod
|
||
|
|
def add_file(self, file_path: Path, **kwargs: Any) -> str:
|
||
|
|
raise NotImplementedError
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
def name(self) -> str:
|
||
|
|
raise NotImplementedError
|
||
|
|
|
||
|
|
def search_store(self, query: str, **kwargs: Any) -> list[Dict[str, Any]]:
|
||
|
|
raise NotImplementedError(f"{self.name()} backend does not support searching")
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
def get_file(self, file_hash: str, **kwargs: Any) -> Path | str | None:
|
||
|
|
raise NotImplementedError
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
def get_metadata(self, file_hash: str, **kwargs: Any) -> Optional[Dict[str, Any]]:
|
||
|
|
raise NotImplementedError
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
def get_tag(self, file_identifier: str, **kwargs: Any) -> Tuple[List[str], str]:
|
||
|
|
raise NotImplementedError
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
def add_tag(self, file_identifier: str, tags: List[str], **kwargs: Any) -> bool:
|
||
|
|
raise NotImplementedError
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
def delete_tag(self, file_identifier: str, tags: List[str], **kwargs: Any) -> bool:
|
||
|
|
raise NotImplementedError
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
def get_url(self, file_identifier: str, **kwargs: Any) -> List[str]:
|
||
|
|
raise NotImplementedError
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
def add_url(self, file_identifier: str, url: List[str], **kwargs: Any) -> bool:
|
||
|
|
raise NotImplementedError
|
||
|
|
|
||
|
|
@abstractmethod
|
||
|
|
def delete_url(self, file_identifier: str, url: List[str], **kwargs: Any) -> bool:
|
||
|
|
raise NotImplementedError
|