google_cloud_storage/http/objects/
delete.rs

1use reqwest_middleware::{ClientWithMiddleware as Client, RequestBuilder};
2
3use crate::http::Escape;
4
5/// Request message for GetObject.
6#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
7#[serde(rename_all = "camelCase")]
8pub struct DeleteObjectRequest {
9    /// Required. Name of the bucket in which the object resides.
10    #[serde(skip_serializing)]
11    pub bucket: String,
12    /// Required. Name of the object.
13    #[serde(skip_serializing)]
14    pub object: String,
15    /// If present, selects a specific revision of this object (as opposed to the
16    /// latest version, the default).
17    pub generation: Option<i64>,
18    /// Makes the operation conditional on whether the object's current generation
19    /// matches the given value. Setting to 0 makes the operation succeed only if
20    /// there are no live versions of the object.
21    pub if_generation_match: Option<i64>,
22    /// Makes the operation conditional on whether the object's current generation
23    /// does not match the given value. If no live object exists, the precondition
24    /// fails. Setting to 0 makes the operation succeed only if there is a live
25    /// version of the object.
26    pub if_generation_not_match: Option<i64>,
27    /// Makes the operation conditional on whether the object's current
28    /// metageneration matches the given value.
29    pub if_metageneration_match: Option<i64>,
30    /// Makes the operation conditional on whether the object's current
31    /// metageneration does not match the given value.
32    pub if_metageneration_not_match: Option<i64>,
33}
34
35pub(crate) fn build(base_url: &str, client: &Client, req: &DeleteObjectRequest) -> RequestBuilder {
36    let url = format!("{}/b/{}/o/{}", base_url, req.bucket.escape(), req.object.escape());
37    client.delete(url).query(&req)
38}