diff --git a/object-store/python/object_store/__init__.py b/object-store/python/object_store/__init__.py index 9ac8283..e62ae5f 100644 --- a/object-store/python/object_store/__init__.py +++ b/object-store/python/object_store/__init__.py @@ -5,6 +5,8 @@ # of static code checkers. Thus we avoid listing them with __all__ = ... from ._internal import ClientOptions as ClientOptions from ._internal import ListResult as ListResult +from ._internal import PutResult as PutResult +from ._internal import MultipartUpload as MultipartUpload from ._internal import ObjectMeta as ObjectMeta from ._internal import ObjectStore as _ObjectStore from ._internal import Path as Path @@ -80,7 +82,7 @@ def get_range(self, location: PathLike, start: int, length: int) -> bytes: """ return super().get_range(_as_path(location), start, length) - def put(self, location: PathLike, bytes: BytesLike) -> None: + def put(self, location: PathLike, bytes: BytesLike) -> PutResult: """Save the provided bytes to the specified location. Args: @@ -89,6 +91,23 @@ def put(self, location: PathLike, bytes: BytesLike) -> None: """ return super().put(_as_path(location), _as_bytes(bytes)) + def put_opts(self, location: PathLike, bytes: BytesLike) -> PutResult: + """Save the provided bytes to the specified location with the given options + + Args: + location (PathLike): path / key to storage location + bytes (BytesLike): data to be written to location + """ + return super().put_opts(_as_path(location), _as_bytes(bytes)) + + def put_multipart(self, location: PathLike) -> MultipartUpload: + """Perform a multipart upload + + Args: + location (PathLike): path / key to storage location + """ + return super().put_multipart(_as_path(location)) + def delete(self, location: PathLike) -> None: """Delete the object at the specified location. diff --git a/object-store/python/object_store/_internal.pyi b/object-store/python/object_store/_internal.pyi index c3d6bd3..1252832 100644 --- a/object-store/python/object_store/_internal.pyi +++ b/object-store/python/object_store/_internal.pyi @@ -32,6 +32,28 @@ class ListResult: def objects(self) -> list[ObjectMeta]: """Object metadata for the listing""" +class PutResult: + """TODO...""" + + # @property + # def common_prefixes(self) -> list[Path]: + # """Prefixes that are common (like directories)""" + # @property + # def objects(self) -> list[ObjectMeta]: + # """Object metadata for the listing""" + pass + +class MultipartUpload: + """TODO...""" + + # @property + # def common_prefixes(self) -> list[Path]: + # """Prefixes that are common (like directories)""" + # @property + # def objects(self) -> list[ObjectMeta]: + # """Object metadata for the listing""" + pass + class ClientOptions: """HTTP client configuration for remote object stores""" @@ -133,8 +155,12 @@ class ObjectStore: """Return the bytes that are stored at the specified location.""" def get_range(self, location: Path, start: int, length: int) -> bytes: """Return the bytes that are stored at the specified location in the given byte range.""" - def put(self, location: Path, bytes: bytes) -> None: + def put(self, location: Path, bytes: bytes) -> PutResult: """Save the provided bytes to the specified location.""" + def put_opts(self, location: Path, bytes: bytes) -> PutResult: + """Save the provided bytes to the specified location with the given options""" + def put_multipart(self, location: Path) -> MultipartUpload: + """Perform a multipart upload""" def list(self, prefix: Path | None) -> list[ObjectMeta]: """List all the objects with the given prefix.