Add public repository interfaces and subclassable adapter CRUD API.
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]>
This commit is contained in:
co-authored by
Cursor
parent
f4280f15c1
commit
e98fd3b90d
@@ -8,8 +8,9 @@ import structlog
|
||||
from python_utils import check_env
|
||||
|
||||
from python_repositories.interfaces import (
|
||||
ContextAwareInterface,
|
||||
ConnectionAwareInterface,
|
||||
ContextAwareInterface,
|
||||
ObjectRepositoryInterface,
|
||||
)
|
||||
|
||||
# Handle optional dependencies
|
||||
@@ -18,6 +19,7 @@ if find_spec("minio") is not None:
|
||||
|
||||
|
||||
class MinioAdapter(
|
||||
ObjectRepositoryInterface,
|
||||
ContextAwareInterface,
|
||||
ConnectionAwareInterface,
|
||||
):
|
||||
@@ -113,7 +115,7 @@ class MinioAdapter(
|
||||
self.logger.debug(res)
|
||||
return res
|
||||
|
||||
def _put(
|
||||
def put(
|
||||
self,
|
||||
object_name: str,
|
||||
data: BytesIO,
|
||||
@@ -147,7 +149,7 @@ class MinioAdapter(
|
||||
f"Put object '{object_name}' into bucket '{self._bucket_name}'"
|
||||
)
|
||||
|
||||
def _get(self, object_name: str) -> BytesIO | None:
|
||||
def get(self, object_name: str) -> BytesIO | None:
|
||||
"""Get an object from the Minio bucket."""
|
||||
# Check input
|
||||
if not isinstance(object_name, str) or len(object_name) == 0:
|
||||
@@ -182,7 +184,7 @@ class MinioAdapter(
|
||||
self.logger.error(repr(exc))
|
||||
return None
|
||||
|
||||
def _delete(self, object_name: str) -> None:
|
||||
def delete(self, object_name: str) -> None:
|
||||
"""Delete an object from the Minio bucket."""
|
||||
# Check input
|
||||
if not isinstance(object_name, str) or len(object_name) == 0:
|
||||
@@ -200,7 +202,7 @@ class MinioAdapter(
|
||||
f"Deleted object '{object_name}' from bucket '{self._bucket_name}'"
|
||||
)
|
||||
|
||||
def _list_objects(self, prefix: str = "") -> list[str]:
|
||||
def list_objects(self, prefix: str = "") -> list[str]:
|
||||
"""List objects in the Minio bucket with an optional prefix."""
|
||||
# Check input
|
||||
if not isinstance(prefix, str):
|
||||
|
||||
Reference in New Issue
Block a user