Define split JSON and object repository ABCs, promote adapter methods to public CRUD, add example domain repositories, modernize interface stubs, and make the package installable for tests. Co-authored-by: Cursor <[email protected]>
34 lines
840 B
Python
34 lines
840 B
Python
"""Definition of ObjectRepositoryInterface abstract base class."""
|
|
|
|
from abc import ABC, abstractmethod
|
|
from io import BytesIO
|
|
|
|
|
|
class ObjectRepositoryInterface(ABC):
|
|
"""Interface that defines binary object CRUD methods."""
|
|
|
|
@abstractmethod
|
|
def get(self, object_name: str) -> BytesIO | None:
|
|
"""Get an object by name."""
|
|
...
|
|
|
|
@abstractmethod
|
|
def put(
|
|
self,
|
|
object_name: str,
|
|
data: BytesIO,
|
|
content_type: str = "application/octet-stream",
|
|
) -> None:
|
|
"""Put an object by name."""
|
|
...
|
|
|
|
@abstractmethod
|
|
def delete(self, object_name: str) -> None:
|
|
"""Delete an object by name."""
|
|
...
|
|
|
|
@abstractmethod
|
|
def list_objects(self, prefix: str = "") -> list[str]:
|
|
"""List object names with an optional prefix."""
|
|
...
|