From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox 2/3] s3-client: parse and return headers for delete object response
Date: Tue, 27 Jan 2026 13:27:10 +0100 [thread overview]
Message-ID: <20260127122712.505774-3-c.ebner@proxmox.com> (raw)
In-Reply-To: <20260127122712.505774-1-c.ebner@proxmox.com>
Mimic the response elements from the list objects parsing in the
delete object response.
In preparation for being able to perform delete objects via
individual delete object api calls, if the respective provider quirk
is set in the client options.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
proxmox-s3-client/src/client.rs | 9 +++++----
proxmox-s3-client/src/response_reader.rs | 21 +++++++++++++++++++--
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/proxmox-s3-client/src/client.rs b/proxmox-s3-client/src/client.rs
index 83176b39..3d0af5d6 100644
--- a/proxmox-s3-client/src/client.rs
+++ b/proxmox-s3-client/src/client.rs
@@ -29,8 +29,9 @@ use crate::aws_sign_v4::AWS_SIGN_V4_DATETIME_FORMAT;
use crate::aws_sign_v4::{aws_sign_v4_signature, aws_sign_v4_uri_encode};
use crate::object_key::S3ObjectKey;
use crate::response_reader::{
- CopyObjectResponse, DeleteObjectsResponse, GetObjectResponse, HeadObjectResponse,
- ListBucketsResponse, ListObjectsV2Response, PutObjectResponse, ResponseReader,
+ CopyObjectResponse, DeleteObjectsResponse, DeletedObject, GetObjectResponse,
+ HeadObjectResponse, ListBucketsResponse, ListObjectsV2Response, PutObjectResponse,
+ ResponseReader,
};
/// Default timeout for s3 api requests.
@@ -544,7 +545,7 @@ impl S3Client {
/// Removes an object from a bucket.
/// See reference docs: https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html
- pub async fn delete_object(&self, object_key: S3ObjectKey) -> Result<(), Error> {
+ pub async fn delete_object(&self, object_key: S3ObjectKey) -> Result<DeletedObject, Error> {
let object_key = object_key.to_full_key(&self.options.common_prefix);
let request = Request::builder()
.method(Method::DELETE)
@@ -553,7 +554,7 @@ impl S3Client {
let response = self.send(request, None).await?;
let response_reader = ResponseReader::new(response);
- response_reader.delete_object_response().await
+ response_reader.delete_object_response(object_key).await
}
/// Delete multiple objects from a bucket using a single HTTP request.
diff --git a/proxmox-s3-client/src/response_reader.rs b/proxmox-s3-client/src/response_reader.rs
index 7066c33b..be7c0950 100644
--- a/proxmox-s3-client/src/response_reader.rs
+++ b/proxmox-s3-client/src/response_reader.rs
@@ -361,7 +361,10 @@ impl ResponseReader {
/// Read and parse the delete object response.
///
/// Returns with error if an unexpected status code is encountered.
- pub(crate) async fn delete_object_response(self) -> Result<(), Error> {
+ pub(crate) async fn delete_object_response(
+ self,
+ key: S3ObjectKey,
+ ) -> Result<DeletedObject, Error> {
let (parts, _body) = self.response.into_parts();
match parts.status {
@@ -369,7 +372,21 @@ impl ResponseReader {
status_code => bail!("unexpected status code {status_code}"),
};
- Ok(())
+ let delete_marker = Self::parse_optional_header(
+ HeaderName::from_static("x-amz-delete-marker"),
+ &parts.headers,
+ )?;
+ let delete_marker_version_id = Self::parse_optional_header(
+ HeaderName::from_static("x-amz-version-id"),
+ &parts.headers,
+ )?;
+
+ Ok(DeletedObject {
+ delete_marker,
+ delete_marker_version_id,
+ key: Some(key),
+ version_id: None,
+ })
}
/// Read and parse the delete objects response.
--
2.47.3
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next prev parent reply other threads:[~2026-01-27 12:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-27 12:27 [pbs-devel] [PATCH proxmox{, -backup} 0/4] fix #7078: Add quirk for providers not supporting deleteObjects Christian Ebner
2026-01-27 12:27 ` [pbs-devel] [PATCH proxmox 1/3] s3-client: factor out optional response header parsing Christian Ebner
2026-01-27 12:27 ` Christian Ebner [this message]
2026-01-27 12:27 ` [pbs-devel] [PATCH proxmox 3/3] s3-client: extend provider quirks by delete objects via delete object Christian Ebner
2026-01-27 12:27 ` [pbs-devel] [PATCH proxmox-backup 1/1] fix #7078: ui: exponse DeleteObjects via DeleteObject provider quirk Christian Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260127122712.505774-3-c.ebner@proxmox.com \
--to=c.ebner@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.