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