Files
Medios-Macina/Store/_base.py

74 lines
2.3 KiB
Python
Raw Normal View History

2025-12-11 19:04:02 -08:00
"""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
2025-12-11 23:21:45 -08:00
class Store(ABC):
2025-12-11 19:04:02 -08:00
@abstractmethod
def add_file(self, file_path: Path, **kwargs: Any) -> str:
raise NotImplementedError
@abstractmethod
def name(self) -> str:
raise NotImplementedError
2025-12-11 23:21:45 -08:00
def search(self, query: str, **kwargs: Any) -> list[Dict[str, Any]]:
2025-12-11 19:04:02 -08:00
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
2025-12-12 21:55:38 -08:00
@abstractmethod
def get_note(self, file_identifier: str, **kwargs: Any) -> Dict[str, str]:
"""Get notes for a file.
Returns a mapping of note name/key -> note text.
"""
raise NotImplementedError
@abstractmethod
def set_note(self, file_identifier: str, name: str, text: str, **kwargs: Any) -> bool:
"""Add or replace a named note for a file."""
raise NotImplementedError
@abstractmethod
def delete_note(self, file_identifier: str, name: str, **kwargs: Any) -> bool:
"""Delete a named note for a file."""
raise NotImplementedError