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]>
24 lines
705 B
Python
24 lines
705 B
Python
"""Example domain repository backed by MinIO objects."""
|
|
|
|
from io import BytesIO
|
|
|
|
from python_repositories.adapters.minio_adapter import MinioAdapter
|
|
|
|
|
|
class ArtifactObjectRepository(MinioAdapter):
|
|
"""Example: domain repository backed by MinIO objects."""
|
|
|
|
def _object_name(self, artifact_id: str) -> str:
|
|
return f"artifacts/{artifact_id}"
|
|
|
|
def get_artifact(self, artifact_id: str) -> BytesIO | None:
|
|
return self.get(self._object_name(artifact_id))
|
|
|
|
def store_artifact(
|
|
self,
|
|
artifact_id: str,
|
|
data: BytesIO,
|
|
content_type: str = "application/octet-stream",
|
|
) -> None:
|
|
self.put(self._object_name(artifact_id), data, content_type)
|