google_cloud_storage/http/buckets/patch.rs
1use std::collections::HashMap;
2
3use reqwest_middleware::{ClientWithMiddleware as Client, RequestBuilder};
4
5use crate::http::bucket_access_controls::{BucketAccessControl, PredefinedBucketAcl};
6use crate::http::buckets::insert::RetentionPolicyCreationConfig;
7use crate::http::buckets::{Billing, Cors, Encryption, IamConfiguration, Lifecycle, Logging, Versioning, Website};
8use crate::http::object_access_controls::insert::ObjectAccessControlCreationConfig;
9use crate::http::object_access_controls::{PredefinedObjectAcl, Projection};
10use crate::http::Escape;
11
12#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Default, Debug)]
13#[serde(rename_all = "camelCase")]
14pub struct BucketPatchConfig {
15 /// Access controls on the bucket, containing one or more bucketAccessControls Resources.
16 /// If iamConfiguration.uniformBucketLevelAccess.enabled is set to true,
17 /// this field is omitted in responses, and requests that specify
18 /// this field fail with a 400 Bad Request response.
19 pub acl: Option<Vec<BucketAccessControl>>,
20 /// Default access controls to apply to new objects when no ACL is provided.
21 /// This list defines an entity and role for one or more defaultObjectAccessControls Resources.
22 /// If iamConfiguration.uniformBucketLevelAccess.enabled is set to true,
23 /// this field is omitted in responses, and requests that specify this field
24 /// fail with a 400 Bad Request response.
25 pub default_object_acl: Option<Vec<ObjectAccessControlCreationConfig>>,
26 /// The bucket's lifecycle configuration. See lifecycle management for more information.
27 pub lifecycle: Option<Lifecycle>,
28 /// The bucket's Cross-Origin Resource Sharing (CORS) configuration.
29 pub cors: Option<Vec<Cors>>,
30 /// The bucket's default storage class, used whenever no storageClass is specified
31 /// for a newly-created object. If storageClass is not specified when the bucket is created,
32 /// it defaults to "STANDARD". For available storage classes, see Storage classes.
33 pub storage_class: Option<String>,
34 /// Default access controls to apply to new objects when no ACL is provided.
35 /// This list defines an entity and role for one or more defaultObjectAccessControls Resources.
36 /// If iamConfiguration.uniformBucketLevelAccess.enabled is set to true,
37 /// this field is omitted in responses, and requests that specify this field fail with a 400 Bad Request
38 /// response.
39 pub default_event_based_hold: bool,
40 /// User-provided bucket labels, in key/value pairs.
41 pub labels: Option<HashMap<String, String>>,
42 /// The bucket's website configuration, controlling how the service behaves
43 /// when accessing bucket contents as a web site. See the Static Website Examples for more information.
44 pub website: Option<Website>,
45 /// The bucket's versioning configuration.
46 pub versioning: Option<Versioning>,
47 /// The bucket's logging configuration, which defines the destination bucket
48 /// and optional name prefix for the current bucket's logs.
49 pub logging: Option<Logging>,
50 /// Encryption configuration for a bucket.
51 pub encryption: Option<Encryption>,
52 /// The bucket's billing configuration.
53 pub billing: Option<Billing>,
54 /// The bucket's retention policy, which defines the minimum age
55 /// an object in the bucket must have to be deleted or replaced.
56 pub retention_policy: Option<RetentionPolicyCreationConfig>,
57 /// The bucket's IAM configuration.
58 pub iam_configuration: Option<IamConfiguration>,
59 /// The recovery point objective for cross-region replication of the bucket.
60 /// Applicable only for dual- and multi-region buckets.
61 /// "DEFAULT" uses default replication. "ASYNC_TURBO" enables turbo replication,
62 /// valid for dual-region buckets only. If rpo is not specified when the bucket is created,
63 /// it defaults to "DEFAULT". For more information, see Turbo replication.
64 pub rpo: Option<String>,
65}
66
67/// Request for PatchBucket method.
68#[derive(Clone, PartialEq, Eq, Default, serde::Deserialize, serde::Serialize, Debug)]
69#[serde(rename_all = "camelCase")]
70pub struct PatchBucketRequest {
71 /// Required. Name of a bucket.
72 #[serde(skip_serializing)]
73 pub bucket: String,
74 /// If set, only deletes the bucket if its metageneration matches this value.
75 pub if_metageneration_match: Option<i64>,
76 /// If set, only deletes the bucket if its metageneration does not match this
77 /// value.
78 pub if_metageneration_not_match: Option<i64>,
79 /// Apply a predefined set of access controls to this bucket.
80 pub predefined_acl: Option<PredefinedBucketAcl>,
81 /// Apply a predefined set of default object access controls to this bucket.
82 pub predefined_default_object_acl: Option<PredefinedObjectAcl>,
83 /// Set of properties to return. Defaults to `FULL`.
84 pub projection: Option<Projection>,
85 /// The Bucket metadata for updating.
86 #[serde(skip_serializing)]
87 pub metadata: Option<BucketPatchConfig>,
88}
89
90pub(crate) fn build(base_url: &str, client: &Client, req: &PatchBucketRequest) -> RequestBuilder {
91 let url = format!("{}/b/{}", base_url, req.bucket.escape());
92 let builder = client.patch(url).query(&req);
93 if let Some(body) = &req.metadata {
94 builder.json(body)
95 } else {
96 builder
97 }
98}