This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git
The following commit(s) were added to refs/heads/main by this push:
new 4ffe62a96 feat(bindings/python): add python presign_delete (#5661)
4ffe62a96 is described below
commit 4ffe62a96a5a4695938f19dc6f7489a4c6045dac
Author: Asuka Minato <[email protected]>
AuthorDate: Tue Feb 25 20:16:35 2025 +0900
feat(bindings/python): add python presign_delete (#5661)
python-presign-delete
---
bindings/python/python/opendal/__init__.pyi | 4 ++++
bindings/python/src/capability.rs | 3 +++
bindings/python/src/operator.rs | 20 ++++++++++++++++++++
3 files changed, 27 insertions(+)
diff --git a/bindings/python/python/opendal/__init__.pyi
b/bindings/python/python/opendal/__init__.pyi
index 442a094fa..cf7442876 100644
--- a/bindings/python/python/opendal/__init__.pyi
+++ b/bindings/python/python/opendal/__init__.pyi
@@ -85,6 +85,9 @@ class AsyncOperator(_Base):
async def presign_write(
self, path: PathBuf, expire_second: int
) -> PresignedRequest: ...
+ async def presign_delete(
+ self, path: PathBuf, expire_second: int
+ ) -> PresignedRequest: ...
def capability(self) -> Capability: ...
async def copy(self, source: PathBuf, target: PathBuf) -> None: ...
async def rename(self, source: PathBuf, target: PathBuf) -> None: ...
@@ -207,6 +210,7 @@ class Capability:
presign_read: bool
presign_stat: bool
presign_write: bool
+ presign_delete: bool
shared: bool
blocking: bool
diff --git a/bindings/python/src/capability.rs
b/bindings/python/src/capability.rs
index c1a5423c3..d2890cda8 100644
--- a/bindings/python/src/capability.rs
+++ b/bindings/python/src/capability.rs
@@ -97,6 +97,8 @@ pub struct Capability {
pub presign_stat: bool,
/// If operator supports presign write.
pub presign_write: bool,
+ /// If operator supports presign delete.
+ pub presign_delete: bool,
/// If operator supports shared.
pub shared: bool,
@@ -140,6 +142,7 @@ impl Capability {
presign_read: capability.presign_read,
presign_stat: capability.presign_stat,
presign_write: capability.presign_write,
+ presign_delete: capability.presign_delete,
shared: capability.shared,
blocking: capability.blocking,
}
diff --git a/bindings/python/src/operator.rs b/bindings/python/src/operator.rs
index e9a3598e3..05e1c9abe 100644
--- a/bindings/python/src/operator.rs
+++ b/bindings/python/src/operator.rs
@@ -579,6 +579,26 @@ impl AsyncOperator {
})
}
+ /// Presign an operation for delete which expires after `expire_second`
seconds.
+ pub fn presign_delete<'p>(
+ &'p self,
+ py: Python<'p>,
+ path: PathBuf,
+ expire_second: u64,
+ ) -> PyResult<Bound<'p, PyAny>> {
+ let this = self.core.clone();
+ let path = path.to_string_lossy().to_string();
+ future_into_py(py, async move {
+ let res = this
+ .presign_delete(&path, Duration::from_secs(expire_second))
+ .await
+ .map_err(format_pyerr)
+ .map(PresignedRequest)?;
+
+ Ok(res)
+ })
+ }
+
pub fn capability(&self) -> PyResult<capability::Capability> {
Ok(capability::Capability::new(
self.core.info().full_capability(),