google_cloud_storage/http/objects/
compose.rs1use reqwest_middleware::{ClientWithMiddleware as Client, RequestBuilder};
2
3use crate::http::object_access_controls::PredefinedObjectAcl;
4use crate::http::objects::{Encryption, Object, SourceObjects};
5use crate::http::Escape;
6
7#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
9#[serde(rename_all = "camelCase")]
10pub struct ComposeObjectRequest {
11 #[serde(skip_serializing)]
14 pub bucket: String,
15 #[serde(skip_serializing)]
17 pub destination_object: String,
18 pub destination_predefined_acl: Option<PredefinedObjectAcl>,
20 #[serde(skip_serializing)]
21 pub composing_targets: ComposingTargets,
22 pub if_generation_match: Option<i64>,
26 pub if_metageneration_match: Option<i64>,
29 pub kms_key_name: Option<String>,
34 #[serde(skip_serializing)]
36 pub encryption: Option<Encryption>,
37}
38
39#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
40#[serde(rename_all = "camelCase")]
41pub struct ComposingTargets {
42 pub destination: Option<Object>,
44 pub source_objects: Vec<SourceObjects>,
46}
47
48pub(crate) fn build(base_url: &str, client: &Client, req: &ComposeObjectRequest) -> RequestBuilder {
49 let url = format!(
50 "{}/b/{}/o/{}/compose",
51 base_url,
52 req.bucket.escape(),
53 req.destination_object.escape()
54 );
55 let builder = client.post(url).query(&req).json(&req.composing_targets);
56 if let Some(e) = &req.encryption {
57 e.with_headers(builder)
58 } else {
59 builder
60 }
61}