google_storage1/
api.rs

1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16    /// View and manage your data across Google Cloud Platform services
17    CloudPlatform,
18
19    /// View your data across Google Cloud Platform services
20    CloudPlatformReadOnly,
21
22    /// Manage your data and permissions in Google Cloud Storage
23    DevstorageFullControl,
24
25    /// View your data in Google Cloud Storage
26    DevstorageReadOnly,
27
28    /// Manage your data in Google Cloud Storage
29    DevstorageReadWrite,
30}
31
32impl AsRef<str> for Scope {
33    fn as_ref(&self) -> &str {
34        match *self {
35            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
36            Scope::CloudPlatformReadOnly => {
37                "https://www.googleapis.com/auth/cloud-platform.read-only"
38            }
39            Scope::DevstorageFullControl => {
40                "https://www.googleapis.com/auth/devstorage.full_control"
41            }
42            Scope::DevstorageReadOnly => "https://www.googleapis.com/auth/devstorage.read_only",
43            Scope::DevstorageReadWrite => "https://www.googleapis.com/auth/devstorage.read_write",
44        }
45    }
46}
47
48#[allow(clippy::derivable_impls)]
49impl Default for Scope {
50    fn default() -> Scope {
51        Scope::CloudPlatform
52    }
53}
54
55// ########
56// HUB ###
57// ######
58
59/// Central instance to access all Storage related resource activities
60///
61/// # Examples
62///
63/// Instantiate a new hub
64///
65/// ```test_harness,no_run
66/// extern crate hyper;
67/// extern crate hyper_rustls;
68/// extern crate google_storage1 as storage1;
69/// use storage1::api::Object;
70/// use storage1::{Result, Error};
71/// # async fn dox() {
72/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
73///
74/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
75/// // `client_secret`, among other things.
76/// let secret: yup_oauth2::ApplicationSecret = Default::default();
77/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
78/// // unless you replace  `None` with the desired Flow.
79/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
80/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
81/// // retrieve them from storage.
82/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
83///     secret,
84///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
85/// ).build().await.unwrap();
86///
87/// let client = hyper_util::client::legacy::Client::builder(
88///     hyper_util::rt::TokioExecutor::new()
89/// )
90/// .build(
91///     hyper_rustls::HttpsConnectorBuilder::new()
92///         .with_native_roots()
93///         .unwrap()
94///         .https_or_http()
95///         .enable_http1()
96///         .build()
97/// );
98/// let mut hub = Storage::new(client, auth);
99/// // As the method needs a request, you would usually fill it with the desired information
100/// // into the respective structure. Some of the parts shown here might not be applicable !
101/// // Values shown here are possibly random and not representative !
102/// let mut req = Object::default();
103///
104/// // You can configure optional parameters by calling the respective setters at will, and
105/// // execute the final call using `doit()`.
106/// // Values shown here are possibly random and not representative !
107/// let result = hub.objects().rewrite(req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject")
108///              .user_project("Stet")
109///              .source_generation(-13)
110///              .rewrite_token("et")
111///              .projection("sed")
112///              .max_bytes_rewritten_per_call(-24)
113///              .if_source_metageneration_not_match(-68)
114///              .if_source_metageneration_match(-76)
115///              .if_source_generation_not_match(-31)
116///              .if_source_generation_match(-93)
117///              .if_metageneration_not_match(-20)
118///              .if_metageneration_match(-34)
119///              .if_generation_not_match(-22)
120///              .if_generation_match(-28)
121///              .destination_predefined_acl("amet.")
122///              .destination_kms_key_name("consetetur")
123///              .doit().await;
124///
125/// match result {
126///     Err(e) => match e {
127///         // The Error enum provides details about what exactly happened.
128///         // You can also just use its `Debug`, `Display` or `Error` traits
129///          Error::HttpError(_)
130///         |Error::Io(_)
131///         |Error::MissingAPIKey
132///         |Error::MissingToken(_)
133///         |Error::Cancelled
134///         |Error::UploadSizeLimitExceeded(_, _)
135///         |Error::Failure(_)
136///         |Error::BadRequest(_)
137///         |Error::FieldClash(_)
138///         |Error::JsonDecodeError(_, _) => println!("{}", e),
139///     },
140///     Ok(res) => println!("Success: {:?}", res),
141/// }
142/// # }
143/// ```
144#[derive(Clone)]
145pub struct Storage<C> {
146    pub client: common::Client<C>,
147    pub auth: Box<dyn common::GetToken>,
148    _user_agent: String,
149    _base_url: String,
150    _root_url: String,
151}
152
153impl<C> common::Hub for Storage<C> {}
154
155impl<'a, C> Storage<C> {
156    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Storage<C> {
157        Storage {
158            client,
159            auth: Box::new(auth),
160            _user_agent: "google-api-rust-client/6.0.0".to_string(),
161            _base_url: "https://storage.googleapis.com/storage/v1/".to_string(),
162            _root_url: "https://storage.googleapis.com/".to_string(),
163        }
164    }
165
166    pub fn anywhere_caches(&'a self) -> AnywhereCachMethods<'a, C> {
167        AnywhereCachMethods { hub: self }
168    }
169    pub fn bucket_access_controls(&'a self) -> BucketAccessControlMethods<'a, C> {
170        BucketAccessControlMethods { hub: self }
171    }
172    pub fn buckets(&'a self) -> BucketMethods<'a, C> {
173        BucketMethods { hub: self }
174    }
175    pub fn channels(&'a self) -> ChannelMethods<'a, C> {
176        ChannelMethods { hub: self }
177    }
178    pub fn default_object_access_controls(&'a self) -> DefaultObjectAccessControlMethods<'a, C> {
179        DefaultObjectAccessControlMethods { hub: self }
180    }
181    pub fn folders(&'a self) -> FolderMethods<'a, C> {
182        FolderMethods { hub: self }
183    }
184    pub fn managed_folders(&'a self) -> ManagedFolderMethods<'a, C> {
185        ManagedFolderMethods { hub: self }
186    }
187    pub fn notifications(&'a self) -> NotificationMethods<'a, C> {
188        NotificationMethods { hub: self }
189    }
190    pub fn object_access_controls(&'a self) -> ObjectAccessControlMethods<'a, C> {
191        ObjectAccessControlMethods { hub: self }
192    }
193    pub fn objects(&'a self) -> ObjectMethods<'a, C> {
194        ObjectMethods { hub: self }
195    }
196    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
197        ProjectMethods { hub: self }
198    }
199
200    /// Set the user-agent header field to use in all requests to the server.
201    /// It defaults to `google-api-rust-client/6.0.0`.
202    ///
203    /// Returns the previously set user-agent.
204    pub fn user_agent(&mut self, agent_name: String) -> String {
205        std::mem::replace(&mut self._user_agent, agent_name)
206    }
207
208    /// Set the base url to use in all requests to the server.
209    /// It defaults to `https://storage.googleapis.com/storage/v1/`.
210    ///
211    /// Returns the previously set base url.
212    pub fn base_url(&mut self, new_base_url: String) -> String {
213        std::mem::replace(&mut self._base_url, new_base_url)
214    }
215
216    /// Set the root url to use in all requests to the server.
217    /// It defaults to `https://storage.googleapis.com/`.
218    ///
219    /// Returns the previously set root url.
220    pub fn root_url(&mut self, new_root_url: String) -> String {
221        std::mem::replace(&mut self._root_url, new_root_url)
222    }
223}
224
225// ############
226// SCHEMAS ###
227// ##########
228/// An Anywhere Cache instance.
229///
230/// # Activities
231///
232/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
233/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
234///
235/// * [disable anywhere caches](AnywhereCachDisableCall) (response)
236/// * [get anywhere caches](AnywhereCachGetCall) (response)
237/// * [insert anywhere caches](AnywhereCachInsertCall) (request)
238/// * [list anywhere caches](AnywhereCachListCall) (none)
239/// * [pause anywhere caches](AnywhereCachPauseCall) (response)
240/// * [resume anywhere caches](AnywhereCachResumeCall) (response)
241/// * [update anywhere caches](AnywhereCachUpdateCall) (request)
242#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
243#[serde_with::serde_as]
244#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
245pub struct AnywhereCache {
246    /// The cache-level entry admission policy.
247    #[serde(rename = "admissionPolicy")]
248    pub admission_policy: Option<String>,
249    /// The ID of the Anywhere cache instance.
250    #[serde(rename = "anywhereCacheId")]
251    pub anywhere_cache_id: Option<String>,
252    /// The name of the bucket containing this cache instance.
253    pub bucket: Option<String>,
254    /// The creation time of the cache instance in RFC 3339 format.
255    #[serde(rename = "createTime")]
256    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
257    /// The ID of the resource, including the project number, bucket name and anywhere cache ID.
258    pub id: Option<String>,
259    /// The kind of item this is. For Anywhere Cache, this is always storage#anywhereCache.
260    pub kind: Option<String>,
261    /// True if the cache instance has an active Update long-running operation.
262    #[serde(rename = "pendingUpdate")]
263    pub pending_update: Option<bool>,
264    /// The link to this cache instance.
265    #[serde(rename = "selfLink")]
266    pub self_link: Option<String>,
267    /// The current state of the cache instance.
268    pub state: Option<String>,
269    /// The TTL of all cache entries in whole seconds. e.g., "7200s".
270    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
271    pub ttl: Option<chrono::Duration>,
272    /// The modification time of the cache instance metadata in RFC 3339 format.
273    #[serde(rename = "updateTime")]
274    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
275    /// The zone in which the cache instance is running. For example, us-central1-a.
276    pub zone: Option<String>,
277}
278
279impl common::RequestValue for AnywhereCache {}
280impl common::Resource for AnywhereCache {}
281impl common::ResponseResult for AnywhereCache {}
282
283/// A list of Anywhere Caches.
284///
285/// # Activities
286///
287/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
288/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
289///
290/// * [list anywhere caches](AnywhereCachListCall) (response)
291#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
292#[serde_with::serde_as]
293#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
294pub struct AnywhereCaches {
295    /// The list of items.
296    pub items: Option<Vec<AnywhereCache>>,
297    /// The kind of item this is. For lists of Anywhere Caches, this is always storage#anywhereCaches.
298    pub kind: Option<String>,
299    /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results.
300    #[serde(rename = "nextPageToken")]
301    pub next_page_token: Option<String>,
302}
303
304impl common::ResponseResult for AnywhereCaches {}
305
306/// A bucket.
307///
308/// # Activities
309///
310/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
311/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
312///
313/// * [delete buckets](BucketDeleteCall) (none)
314/// * [get buckets](BucketGetCall) (response)
315/// * [get iam policy buckets](BucketGetIamPolicyCall) (none)
316/// * [get storage layout buckets](BucketGetStorageLayoutCall) (none)
317/// * [insert buckets](BucketInsertCall) (request|response)
318/// * [list buckets](BucketListCall) (none)
319/// * [lock retention policy buckets](BucketLockRetentionPolicyCall) (response)
320/// * [patch buckets](BucketPatchCall) (request|response)
321/// * [set iam policy buckets](BucketSetIamPolicyCall) (none)
322/// * [test iam permissions buckets](BucketTestIamPermissionCall) (none)
323/// * [update buckets](BucketUpdateCall) (request|response)
324/// * [operations cancel buckets](BucketOperationCancelCall) (none)
325/// * [operations get buckets](BucketOperationGetCall) (none)
326/// * [operations list buckets](BucketOperationListCall) (none)
327#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
328#[serde_with::serde_as]
329#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
330pub struct Bucket {
331    /// Access controls on the bucket.
332    pub acl: Option<Vec<BucketAccessControl>>,
333    /// The bucket's Autoclass configuration.
334    pub autoclass: Option<BucketAutoclass>,
335    /// The bucket's billing configuration.
336    pub billing: Option<BucketBilling>,
337    /// The bucket's Cross-Origin Resource Sharing (CORS) configuration.
338    pub cors: Option<Vec<BucketCors>>,
339    /// The bucket's custom placement configuration for Custom Dual Regions.
340    #[serde(rename = "customPlacementConfig")]
341    pub custom_placement_config: Option<BucketCustomPlacementConfig>,
342    /// The default value for event-based hold on newly created objects in this bucket. Event-based hold is a way to retain objects indefinitely until an event occurs, signified by the hold's release. After being released, such objects will be subject to bucket-level retention (if any). One sample use case of this flag is for banks to hold loan documents for at least 3 years after loan is paid in full. Here, bucket-level retention is 3 years and the event is loan being paid in full. In this example, these objects will be held intact for any number of years until the event has occurred (event-based hold on the object is released) and then 3 more years after that. That means retention duration of the objects begins from the moment event-based hold transitioned from true to false. Objects under event-based hold cannot be deleted, overwritten or archived until the hold is removed.
343    #[serde(rename = "defaultEventBasedHold")]
344    pub default_event_based_hold: Option<bool>,
345    /// Default access controls to apply to new objects when no ACL is provided.
346    #[serde(rename = "defaultObjectAcl")]
347    pub default_object_acl: Option<Vec<ObjectAccessControl>>,
348    /// Encryption configuration for a bucket.
349    pub encryption: Option<BucketEncryption>,
350    /// HTTP 1.1 Entity tag for the bucket.
351    pub etag: Option<String>,
352    /// The bucket's hierarchical namespace configuration.
353    #[serde(rename = "hierarchicalNamespace")]
354    pub hierarchical_namespace: Option<BucketHierarchicalNamespace>,
355    /// The bucket's IAM configuration.
356    #[serde(rename = "iamConfiguration")]
357    pub iam_configuration: Option<BucketIamConfiguration>,
358    /// The ID of the bucket. For buckets, the id and name properties are the same.
359    pub id: Option<String>,
360    /// The kind of item this is. For buckets, this is always storage#bucket.
361    pub kind: Option<String>,
362    /// User-provided labels, in key/value pairs.
363    pub labels: Option<HashMap<String, String>>,
364    /// The bucket's lifecycle configuration. See lifecycle management for more information.
365    pub lifecycle: Option<BucketLifecycle>,
366    /// The location of the bucket. Object data for objects in the bucket resides in physical storage within this region. Defaults to US. See the developer's guide for the authoritative list.
367    pub location: Option<String>,
368    /// The type of the bucket location.
369    #[serde(rename = "locationType")]
370    pub location_type: Option<String>,
371    /// The bucket's logging configuration, which defines the destination bucket and optional name prefix for the current bucket's logs.
372    pub logging: Option<BucketLogging>,
373    /// The metadata generation of this bucket.
374    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
375    pub metageneration: Option<i64>,
376    /// The name of the bucket.
377    pub name: Option<String>,
378    /// The bucket's object retention config.
379    #[serde(rename = "objectRetention")]
380    pub object_retention: Option<BucketObjectRetention>,
381    /// The owner of the bucket. This is always the project team's owner group.
382    pub owner: Option<BucketOwner>,
383    /// The project number of the project the bucket belongs to.
384    #[serde(rename = "projectNumber")]
385    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
386    pub project_number: Option<u64>,
387    /// The bucket's retention policy. The retention policy enforces a minimum retention time for all objects contained in the bucket, based on their creation time. Any attempt to overwrite or delete objects younger than the retention period will result in a PERMISSION_DENIED error. An unlocked retention policy can be modified or removed from the bucket via a storage.buckets.update operation. A locked retention policy cannot be removed or shortened in duration for the lifetime of the bucket. Attempting to remove or decrease period of a locked retention policy will result in a PERMISSION_DENIED error.
388    #[serde(rename = "retentionPolicy")]
389    pub retention_policy: Option<BucketRetentionPolicy>,
390    /// The Recovery Point Objective (RPO) of this bucket. Set to ASYNC_TURBO to turn on Turbo Replication on a bucket.
391    pub rpo: Option<String>,
392    /// Reserved for future use.
393    #[serde(rename = "satisfiesPZS")]
394    pub satisfies_pzs: Option<bool>,
395    /// The URI of this bucket.
396    #[serde(rename = "selfLink")]
397    pub self_link: Option<String>,
398    /// The bucket's soft delete policy, which defines the period of time that soft-deleted objects will be retained, and cannot be permanently deleted.
399    #[serde(rename = "softDeletePolicy")]
400    pub soft_delete_policy: Option<BucketSoftDeletePolicy>,
401    /// The bucket's default storage class, used whenever no storageClass is specified for a newly-created object. This defines how objects in the bucket are stored and determines the SLA and the cost of storage. Values include MULTI_REGIONAL, REGIONAL, STANDARD, NEARLINE, COLDLINE, ARCHIVE, and DURABLE_REDUCED_AVAILABILITY. If this value is not specified when the bucket is created, it will default to STANDARD. For more information, see storage classes.
402    #[serde(rename = "storageClass")]
403    pub storage_class: Option<String>,
404    /// The creation time of the bucket in RFC 3339 format.
405    #[serde(rename = "timeCreated")]
406    pub time_created: Option<chrono::DateTime<chrono::offset::Utc>>,
407    /// The modification time of the bucket in RFC 3339 format.
408    pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
409    /// The bucket's versioning configuration.
410    pub versioning: Option<BucketVersioning>,
411    /// 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.
412    pub website: Option<BucketWebsite>,
413}
414
415impl common::RequestValue for Bucket {}
416impl common::Resource for Bucket {}
417impl common::ResponseResult for Bucket {}
418
419/// An access-control entry.
420///
421/// # Activities
422///
423/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
424/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
425///
426/// * [delete bucket access controls](BucketAccessControlDeleteCall) (none)
427/// * [get bucket access controls](BucketAccessControlGetCall) (response)
428/// * [insert bucket access controls](BucketAccessControlInsertCall) (request|response)
429/// * [list bucket access controls](BucketAccessControlListCall) (none)
430/// * [patch bucket access controls](BucketAccessControlPatchCall) (request|response)
431/// * [update bucket access controls](BucketAccessControlUpdateCall) (request|response)
432#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
433#[serde_with::serde_as]
434#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
435pub struct BucketAccessControl {
436    /// The name of the bucket.
437    pub bucket: Option<String>,
438    /// The domain associated with the entity, if any.
439    pub domain: Option<String>,
440    /// The email address associated with the entity, if any.
441    pub email: Option<String>,
442    /// The entity holding the permission, in one of the following forms:
443    /// - user-userId
444    /// - user-email
445    /// - group-groupId
446    /// - group-email
447    /// - domain-domain
448    /// - project-team-projectId
449    /// - allUsers
450    /// - allAuthenticatedUsers Examples:
451    /// - The user liz@example.com would be user-liz@example.com.
452    /// - The group example@googlegroups.com would be group-example@googlegroups.com.
453    /// - To refer to all members of the Google Apps for Business domain example.com, the entity would be domain-example.com.
454    pub entity: Option<String>,
455    /// The ID for the entity, if any.
456    #[serde(rename = "entityId")]
457    pub entity_id: Option<String>,
458    /// HTTP 1.1 Entity tag for the access-control entry.
459    pub etag: Option<String>,
460    /// The ID of the access-control entry.
461    pub id: Option<String>,
462    /// The kind of item this is. For bucket access control entries, this is always storage#bucketAccessControl.
463    pub kind: Option<String>,
464    /// The project team associated with the entity, if any.
465    #[serde(rename = "projectTeam")]
466    pub project_team: Option<BucketAccessControlProjectTeam>,
467    /// The access permission for the entity.
468    pub role: Option<String>,
469    /// The link to this access-control entry.
470    #[serde(rename = "selfLink")]
471    pub self_link: Option<String>,
472}
473
474impl common::RequestValue for BucketAccessControl {}
475impl common::Resource for BucketAccessControl {}
476impl common::ResponseResult for BucketAccessControl {}
477
478/// An access-control list.
479///
480/// # Activities
481///
482/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
483/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
484///
485/// * [list bucket access controls](BucketAccessControlListCall) (response)
486#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
487#[serde_with::serde_as]
488#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
489pub struct BucketAccessControls {
490    /// The list of items.
491    pub items: Option<Vec<BucketAccessControl>>,
492    /// The kind of item this is. For lists of bucket access control entries, this is always storage#bucketAccessControls.
493    pub kind: Option<String>,
494}
495
496impl common::ResponseResult for BucketAccessControls {}
497
498/// The storage layout configuration of a bucket.
499///
500/// # Activities
501///
502/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
503/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
504///
505/// * [get storage layout buckets](BucketGetStorageLayoutCall) (response)
506#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
507#[serde_with::serde_as]
508#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
509pub struct BucketStorageLayout {
510    /// The name of the bucket.
511    pub bucket: Option<String>,
512    /// The bucket's custom placement configuration for Custom Dual Regions.
513    #[serde(rename = "customPlacementConfig")]
514    pub custom_placement_config: Option<BucketStorageLayoutCustomPlacementConfig>,
515    /// The bucket's hierarchical namespace configuration.
516    #[serde(rename = "hierarchicalNamespace")]
517    pub hierarchical_namespace: Option<BucketStorageLayoutHierarchicalNamespace>,
518    /// The kind of item this is. For storage layout, this is always storage#storageLayout.
519    pub kind: Option<String>,
520    /// The location of the bucket.
521    pub location: Option<String>,
522    /// The type of the bucket location.
523    #[serde(rename = "locationType")]
524    pub location_type: Option<String>,
525}
526
527impl common::ResponseResult for BucketStorageLayout {}
528
529/// A list of buckets.
530///
531/// # Activities
532///
533/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
534/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
535///
536/// * [list buckets](BucketListCall) (response)
537#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
538#[serde_with::serde_as]
539#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
540pub struct Buckets {
541    /// The list of items.
542    pub items: Option<Vec<Bucket>>,
543    /// The kind of item this is. For lists of buckets, this is always storage#buckets.
544    pub kind: Option<String>,
545    /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results.
546    #[serde(rename = "nextPageToken")]
547    pub next_page_token: Option<String>,
548}
549
550impl common::ResponseResult for Buckets {}
551
552/// A bulk restore objects request.
553///
554/// # Activities
555///
556/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
557/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
558///
559/// * [bulk restore objects](ObjectBulkRestoreCall) (request)
560#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
561#[serde_with::serde_as]
562#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
563pub struct BulkRestoreObjectsRequest {
564    /// If false (default), the restore will not overwrite live objects with the same name at the destination. This means some deleted objects may be skipped. If true, live objects will be overwritten resulting in a noncurrent object (if versioning is enabled). If versioning is not enabled, overwriting the object will result in a soft-deleted object. In either case, if a noncurrent object already exists with the same name, a live version can be written without issue.
565    #[serde(rename = "allowOverwrite")]
566    pub allow_overwrite: Option<bool>,
567    /// If true, copies the source object's ACL; otherwise, uses the bucket's default object ACL. The default is false.
568    #[serde(rename = "copySourceAcl")]
569    pub copy_source_acl: Option<bool>,
570    /// Restores only the objects matching any of the specified glob(s). If this parameter is not specified, all objects will be restored within the specified time range.
571    #[serde(rename = "matchGlobs")]
572    pub match_globs: Option<Vec<String>>,
573    /// Restores only the objects that were soft-deleted after this time.
574    #[serde(rename = "softDeletedAfterTime")]
575    pub soft_deleted_after_time: Option<chrono::DateTime<chrono::offset::Utc>>,
576    /// Restores only the objects that were soft-deleted before this time.
577    #[serde(rename = "softDeletedBeforeTime")]
578    pub soft_deleted_before_time: Option<chrono::DateTime<chrono::offset::Utc>>,
579}
580
581impl common::RequestValue for BulkRestoreObjectsRequest {}
582
583/// An notification channel used to watch for resource changes.
584///
585/// # Activities
586///
587/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
588/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
589///
590/// * [stop channels](ChannelStopCall) (request)
591/// * [watch all objects](ObjectWatchAllCall) (request|response)
592#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
593#[serde_with::serde_as]
594#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
595pub struct Channel {
596    /// The address where notifications are delivered for this channel.
597    pub address: Option<String>,
598    /// Date and time of notification channel expiration, expressed as a Unix timestamp, in milliseconds. Optional.
599    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
600    pub expiration: Option<i64>,
601    /// A UUID or similar unique string that identifies this channel.
602    pub id: Option<String>,
603    /// Identifies this as a notification channel used to watch for changes to a resource, which is "api#channel".
604    pub kind: Option<String>,
605    /// Additional parameters controlling delivery channel behavior. Optional.
606    pub params: Option<HashMap<String, String>>,
607    /// A Boolean value to indicate whether payload is wanted. Optional.
608    pub payload: Option<bool>,
609    /// An opaque ID that identifies the resource being watched on this channel. Stable across different API versions.
610    #[serde(rename = "resourceId")]
611    pub resource_id: Option<String>,
612    /// A version-specific identifier for the watched resource.
613    #[serde(rename = "resourceUri")]
614    pub resource_uri: Option<String>,
615    /// An arbitrary string delivered to the target address with each notification delivered over this channel. Optional.
616    pub token: Option<String>,
617    /// The type of delivery mechanism used for this channel.
618    #[serde(rename = "type")]
619    pub type_: Option<String>,
620}
621
622impl common::RequestValue for Channel {}
623impl common::Resource for Channel {}
624impl common::ResponseResult for Channel {}
625
626/// A Compose request.
627///
628/// # Activities
629///
630/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
631/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
632///
633/// * [compose objects](ObjectComposeCall) (request)
634#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
635#[serde_with::serde_as]
636#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
637pub struct ComposeRequest {
638    /// Properties of the resulting object.
639    pub destination: Option<Object>,
640    /// The kind of item this is.
641    pub kind: Option<String>,
642    /// The list of source objects that will be concatenated into a single object.
643    #[serde(rename = "sourceObjects")]
644    pub source_objects: Option<Vec<ComposeRequestSourceObjects>>,
645}
646
647impl common::RequestValue for ComposeRequest {}
648
649/// Represents an expression text. Example: title: "User account presence" description: "Determines whether the request has a user account" expression: "size(request.user) > 0"
650///
651/// This type is not used in any activity, and only used as *part* of another schema.
652///
653#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
654#[serde_with::serde_as]
655#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
656pub struct Expr {
657    /// An optional description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
658    pub description: Option<String>,
659    /// Textual representation of an expression in Common Expression Language syntax. The application context of the containing message determines which well-known feature set of CEL is supported.
660    pub expression: Option<String>,
661    /// An optional string indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
662    pub location: Option<String>,
663    /// An optional title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.
664    pub title: Option<String>,
665}
666
667impl common::Part for Expr {}
668
669/// A folder. Only available in buckets with hierarchical namespace enabled.
670///
671/// # Activities
672///
673/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
674/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
675///
676/// * [delete folders](FolderDeleteCall) (none)
677/// * [get folders](FolderGetCall) (response)
678/// * [insert folders](FolderInsertCall) (request|response)
679/// * [list folders](FolderListCall) (none)
680/// * [rename folders](FolderRenameCall) (none)
681#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
682#[serde_with::serde_as]
683#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
684pub struct Folder {
685    /// The name of the bucket containing this folder.
686    pub bucket: Option<String>,
687    /// The creation time of the folder in RFC 3339 format.
688    #[serde(rename = "createTime")]
689    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
690    /// The ID of the folder, including the bucket name, folder name.
691    pub id: Option<String>,
692    /// The kind of item this is. For folders, this is always storage#folder.
693    pub kind: Option<String>,
694    /// The version of the metadata for this folder. Used for preconditions and for detecting changes in metadata.
695    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
696    pub metageneration: Option<i64>,
697    /// The name of the folder. Required if not specified by URL parameter.
698    pub name: Option<String>,
699    /// Only present if the folder is part of an ongoing rename folder operation. Contains information which can be used to query the operation status.
700    #[serde(rename = "pendingRenameInfo")]
701    pub pending_rename_info: Option<FolderPendingRenameInfo>,
702    /// The link to this folder.
703    #[serde(rename = "selfLink")]
704    pub self_link: Option<String>,
705    /// The modification time of the folder metadata in RFC 3339 format.
706    #[serde(rename = "updateTime")]
707    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
708}
709
710impl common::RequestValue for Folder {}
711impl common::Resource for Folder {}
712impl common::ResponseResult for Folder {}
713
714/// A list of folders.
715///
716/// # Activities
717///
718/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
719/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
720///
721/// * [list folders](FolderListCall) (response)
722#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
723#[serde_with::serde_as]
724#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
725pub struct Folders {
726    /// The list of items.
727    pub items: Option<Vec<Folder>>,
728    /// The kind of item this is. For lists of folders, this is always storage#folders.
729    pub kind: Option<String>,
730    /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results.
731    #[serde(rename = "nextPageToken")]
732    pub next_page_token: Option<String>,
733}
734
735impl common::ResponseResult for Folders {}
736
737/// The response message for storage.buckets.operations.list.
738///
739/// # Activities
740///
741/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
742/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
743///
744/// * [operations list buckets](BucketOperationListCall) (response)
745#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
746#[serde_with::serde_as]
747#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
748pub struct GoogleLongrunningListOperationsResponse {
749    /// The kind of item this is. For lists of operations, this is always storage#operations.
750    pub kind: Option<String>,
751    /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results.
752    #[serde(rename = "nextPageToken")]
753    pub next_page_token: Option<String>,
754    /// A list of operations that matches the specified filter in the request.
755    pub operations: Option<Vec<GoogleLongrunningOperation>>,
756}
757
758impl common::ResponseResult for GoogleLongrunningListOperationsResponse {}
759
760/// This resource represents a long-running operation that is the result of a network API call.
761///
762/// # Activities
763///
764/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
765/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
766///
767/// * [insert anywhere caches](AnywhereCachInsertCall) (response)
768/// * [update anywhere caches](AnywhereCachUpdateCall) (response)
769/// * [rename folders](FolderRenameCall) (response)
770/// * [bulk restore objects](ObjectBulkRestoreCall) (response)
771/// * [operations get buckets](BucketOperationGetCall) (response)
772#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
773#[serde_with::serde_as]
774#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
775pub struct GoogleLongrunningOperation {
776    /// If the value is "false", it means the operation is still in progress. If "true", the operation is completed, and either "error" or "response" is available.
777    pub done: Option<bool>,
778    /// The error result of the operation in case of failure or cancellation.
779    pub error: Option<GoogleRpcStatus>,
780    /// The kind of item this is. For operations, this is always storage#operation.
781    pub kind: Option<String>,
782    /// Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
783    pub metadata: Option<HashMap<String, serde_json::Value>>,
784    /// The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the "name" should be a resource name ending with "operations/{operationId}".
785    pub name: Option<String>,
786    /// The normal response of the operation in case of success. If the original method returns no data on success, such as "Delete", the response is google.protobuf.Empty. If the original method is standard Get/Create/Update, the response should be the resource. For other methods, the response should have the type "XxxResponse", where "Xxx" is the original method name. For example, if the original method name is "TakeSnapshot()", the inferred response type is "TakeSnapshotResponse".
787    pub response: Option<HashMap<String, serde_json::Value>>,
788    /// The link to this long running operation.
789    #[serde(rename = "selfLink")]
790    pub self_link: Option<String>,
791}
792
793impl common::ResponseResult for GoogleLongrunningOperation {}
794
795/// The "Status" type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each "Status" message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
796///
797/// This type is not used in any activity, and only used as *part* of another schema.
798///
799#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
800#[serde_with::serde_as]
801#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
802pub struct GoogleRpcStatus {
803    /// The status code, which should be an enum value of google.rpc.Code.
804    pub code: Option<i32>,
805    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
806    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
807    /// A developer-facing error message, which should be in English.
808    pub message: Option<String>,
809}
810
811impl common::Part for GoogleRpcStatus {}
812
813/// JSON template to produce a JSON-style HMAC Key resource for Create responses.
814///
815/// # Activities
816///
817/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
818/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
819///
820/// * [hmac keys create projects](ProjectHmacKeyCreateCall) (response)
821#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
822#[serde_with::serde_as]
823#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
824pub struct HmacKey {
825    /// The kind of item this is. For HMAC keys, this is always storage#hmacKey.
826    pub kind: Option<String>,
827    /// Key metadata.
828    pub metadata: Option<HmacKeyMetadata>,
829    /// HMAC secret key material.
830    pub secret: Option<String>,
831}
832
833impl common::ResponseResult for HmacKey {}
834
835/// JSON template to produce a JSON-style HMAC Key metadata resource.
836///
837/// # Activities
838///
839/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
840/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
841///
842/// * [hmac keys get projects](ProjectHmacKeyGetCall) (response)
843/// * [hmac keys update projects](ProjectHmacKeyUpdateCall) (request|response)
844#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
845#[serde_with::serde_as]
846#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
847pub struct HmacKeyMetadata {
848    /// The ID of the HMAC Key.
849    #[serde(rename = "accessId")]
850    pub access_id: Option<String>,
851    /// HTTP 1.1 Entity tag for the HMAC key.
852    pub etag: Option<String>,
853    /// The ID of the HMAC key, including the Project ID and the Access ID.
854    pub id: Option<String>,
855    /// The kind of item this is. For HMAC Key metadata, this is always storage#hmacKeyMetadata.
856    pub kind: Option<String>,
857    /// Project ID owning the service account to which the key authenticates.
858    #[serde(rename = "projectId")]
859    pub project_id: Option<String>,
860    /// The link to this resource.
861    #[serde(rename = "selfLink")]
862    pub self_link: Option<String>,
863    /// The email address of the key's associated service account.
864    #[serde(rename = "serviceAccountEmail")]
865    pub service_account_email: Option<String>,
866    /// The state of the key. Can be one of ACTIVE, INACTIVE, or DELETED.
867    pub state: Option<String>,
868    /// The creation time of the HMAC key in RFC 3339 format.
869    #[serde(rename = "timeCreated")]
870    pub time_created: Option<chrono::DateTime<chrono::offset::Utc>>,
871    /// The last modification time of the HMAC key metadata in RFC 3339 format.
872    pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
873}
874
875impl common::RequestValue for HmacKeyMetadata {}
876impl common::ResponseResult for HmacKeyMetadata {}
877
878/// A list of hmacKeys.
879///
880/// # Activities
881///
882/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
883/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
884///
885/// * [hmac keys list projects](ProjectHmacKeyListCall) (response)
886#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
887#[serde_with::serde_as]
888#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
889pub struct HmacKeysMetadata {
890    /// The list of items.
891    pub items: Option<Vec<HmacKeyMetadata>>,
892    /// The kind of item this is. For lists of hmacKeys, this is always storage#hmacKeysMetadata.
893    pub kind: Option<String>,
894    /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results.
895    #[serde(rename = "nextPageToken")]
896    pub next_page_token: Option<String>,
897}
898
899impl common::ResponseResult for HmacKeysMetadata {}
900
901/// A managed folder.
902///
903/// # Activities
904///
905/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
906/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
907///
908/// * [delete managed folders](ManagedFolderDeleteCall) (none)
909/// * [get managed folders](ManagedFolderGetCall) (response)
910/// * [get iam policy managed folders](ManagedFolderGetIamPolicyCall) (none)
911/// * [insert managed folders](ManagedFolderInsertCall) (request|response)
912/// * [list managed folders](ManagedFolderListCall) (none)
913/// * [set iam policy managed folders](ManagedFolderSetIamPolicyCall) (none)
914/// * [test iam permissions managed folders](ManagedFolderTestIamPermissionCall) (none)
915#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
916#[serde_with::serde_as]
917#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
918pub struct ManagedFolder {
919    /// The name of the bucket containing this managed folder.
920    pub bucket: Option<String>,
921    /// The creation time of the managed folder in RFC 3339 format.
922    #[serde(rename = "createTime")]
923    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
924    /// The ID of the managed folder, including the bucket name and managed folder name.
925    pub id: Option<String>,
926    /// The kind of item this is. For managed folders, this is always storage#managedFolder.
927    pub kind: Option<String>,
928    /// The version of the metadata for this managed folder. Used for preconditions and for detecting changes in metadata.
929    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
930    pub metageneration: Option<i64>,
931    /// The name of the managed folder. Required if not specified by URL parameter.
932    pub name: Option<String>,
933    /// The link to this managed folder.
934    #[serde(rename = "selfLink")]
935    pub self_link: Option<String>,
936    /// The last update time of the managed folder metadata in RFC 3339 format.
937    #[serde(rename = "updateTime")]
938    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
939}
940
941impl common::RequestValue for ManagedFolder {}
942impl common::Resource for ManagedFolder {}
943impl common::ResponseResult for ManagedFolder {}
944
945/// A list of managed folders.
946///
947/// # Activities
948///
949/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
950/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
951///
952/// * [list managed folders](ManagedFolderListCall) (response)
953#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
954#[serde_with::serde_as]
955#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
956pub struct ManagedFolders {
957    /// The list of items.
958    pub items: Option<Vec<ManagedFolder>>,
959    /// The kind of item this is. For lists of managed folders, this is always storage#managedFolders.
960    pub kind: Option<String>,
961    /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results.
962    #[serde(rename = "nextPageToken")]
963    pub next_page_token: Option<String>,
964}
965
966impl common::ResponseResult for ManagedFolders {}
967
968/// A subscription to receive Google PubSub notifications.
969///
970/// # Activities
971///
972/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
973/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
974///
975/// * [delete notifications](NotificationDeleteCall) (none)
976/// * [get notifications](NotificationGetCall) (response)
977/// * [insert notifications](NotificationInsertCall) (request|response)
978/// * [list notifications](NotificationListCall) (none)
979#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
980#[serde_with::serde_as]
981#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
982pub struct Notification {
983    /// An optional list of additional attributes to attach to each Cloud PubSub message published for this notification subscription.
984    pub custom_attributes: Option<HashMap<String, String>>,
985    /// HTTP 1.1 Entity tag for this subscription notification.
986    pub etag: Option<String>,
987    /// If present, only send notifications about listed event types. If empty, sent notifications for all event types.
988    pub event_types: Option<Vec<String>>,
989    /// The ID of the notification.
990    pub id: Option<String>,
991    /// The kind of item this is. For notifications, this is always storage#notification.
992    pub kind: Option<String>,
993    /// If present, only apply this notification configuration to object names that begin with this prefix.
994    pub object_name_prefix: Option<String>,
995    /// The desired content of the Payload.
996    pub payload_format: Option<String>,
997    /// The canonical URL of this notification.
998    #[serde(rename = "selfLink")]
999    pub self_link: Option<String>,
1000    /// The Cloud PubSub topic to which this subscription publishes. Formatted as: '//pubsub.googleapis.com/projects/{project-identifier}/topics/{my-topic}'
1001    pub topic: Option<String>,
1002}
1003
1004impl common::RequestValue for Notification {}
1005impl common::Resource for Notification {}
1006impl common::ResponseResult for Notification {}
1007
1008/// A list of notification subscriptions.
1009///
1010/// # Activities
1011///
1012/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1013/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1014///
1015/// * [list notifications](NotificationListCall) (response)
1016#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1017#[serde_with::serde_as]
1018#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1019pub struct Notifications {
1020    /// The list of items.
1021    pub items: Option<Vec<Notification>>,
1022    /// The kind of item this is. For lists of notifications, this is always storage#notifications.
1023    pub kind: Option<String>,
1024}
1025
1026impl common::ResponseResult for Notifications {}
1027
1028/// An object.
1029///
1030/// # Activities
1031///
1032/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1033/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1034///
1035/// * [bulk restore objects](ObjectBulkRestoreCall) (none)
1036/// * [compose objects](ObjectComposeCall) (response)
1037/// * [copy objects](ObjectCopyCall) (request|response)
1038/// * [delete objects](ObjectDeleteCall) (none)
1039/// * [get objects](ObjectGetCall) (response)
1040/// * [get iam policy objects](ObjectGetIamPolicyCall) (none)
1041/// * [insert objects](ObjectInsertCall) (request|response)
1042/// * [list objects](ObjectListCall) (none)
1043/// * [patch objects](ObjectPatchCall) (request|response)
1044/// * [restore objects](ObjectRestoreCall) (response)
1045/// * [rewrite objects](ObjectRewriteCall) (request)
1046/// * [set iam policy objects](ObjectSetIamPolicyCall) (none)
1047/// * [test iam permissions objects](ObjectTestIamPermissionCall) (none)
1048/// * [update objects](ObjectUpdateCall) (request|response)
1049/// * [watch all objects](ObjectWatchAllCall) (none)
1050#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1051#[serde_with::serde_as]
1052#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1053pub struct Object {
1054    /// Access controls on the object.
1055    pub acl: Option<Vec<ObjectAccessControl>>,
1056    /// The name of the bucket containing this object.
1057    pub bucket: Option<String>,
1058    /// Cache-Control directive for the object data. If omitted, and the object is accessible to all anonymous users, the default will be public, max-age=3600.
1059    #[serde(rename = "cacheControl")]
1060    pub cache_control: Option<String>,
1061    /// Number of underlying components that make up this object. Components are accumulated by compose operations.
1062    #[serde(rename = "componentCount")]
1063    pub component_count: Option<i32>,
1064    /// Content-Disposition of the object data.
1065    #[serde(rename = "contentDisposition")]
1066    pub content_disposition: Option<String>,
1067    /// Content-Encoding of the object data.
1068    #[serde(rename = "contentEncoding")]
1069    pub content_encoding: Option<String>,
1070    /// Content-Language of the object data.
1071    #[serde(rename = "contentLanguage")]
1072    pub content_language: Option<String>,
1073    /// Content-Type of the object data. If an object is stored without a Content-Type, it is served as application/octet-stream.
1074    #[serde(rename = "contentType")]
1075    pub content_type: Option<String>,
1076    /// CRC32c checksum, as described in RFC 4960, Appendix B; encoded using base64 in big-endian byte order. For more information about using the CRC32c checksum, see Hashes and ETags: Best Practices.
1077    pub crc32c: Option<String>,
1078    /// A timestamp in RFC 3339 format specified by the user for an object.
1079    #[serde(rename = "customTime")]
1080    pub custom_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1081    /// Metadata of customer-supplied encryption key, if the object is encrypted by such a key.
1082    #[serde(rename = "customerEncryption")]
1083    pub customer_encryption: Option<ObjectCustomerEncryption>,
1084    /// HTTP 1.1 Entity tag for the object.
1085    pub etag: Option<String>,
1086    /// Whether an object is under event-based hold. Event-based hold is a way to retain objects until an event occurs, which is signified by the hold's release (i.e. this value is set to false). After being released (set to false), such objects will be subject to bucket-level retention (if any). One sample use case of this flag is for banks to hold loan documents for at least 3 years after loan is paid in full. Here, bucket-level retention is 3 years and the event is the loan being paid in full. In this example, these objects will be held intact for any number of years until the event has occurred (event-based hold on the object is released) and then 3 more years after that. That means retention duration of the objects begins from the moment event-based hold transitioned from true to false.
1087    #[serde(rename = "eventBasedHold")]
1088    pub event_based_hold: Option<bool>,
1089    /// The content generation of this object. Used for object versioning.
1090    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1091    pub generation: Option<i64>,
1092    /// This is the time (in the future) when the soft-deleted object will no longer be restorable. It is equal to the soft delete time plus the current soft delete retention duration of the bucket.
1093    #[serde(rename = "hardDeleteTime")]
1094    pub hard_delete_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1095    /// The ID of the object, including the bucket name, object name, and generation number.
1096    pub id: Option<String>,
1097    /// The kind of item this is. For objects, this is always storage#object.
1098    pub kind: Option<String>,
1099    /// Not currently supported. Specifying the parameter causes the request to fail with status code 400 - Bad Request.
1100    #[serde(rename = "kmsKeyName")]
1101    pub kms_key_name: Option<String>,
1102    /// MD5 hash of the data; encoded using base64. For more information about using the MD5 hash, see Hashes and ETags: Best Practices.
1103    #[serde(rename = "md5Hash")]
1104    pub md5_hash: Option<String>,
1105    /// Media download link.
1106    #[serde(rename = "mediaLink")]
1107    pub media_link: Option<String>,
1108    /// User-provided metadata, in key/value pairs.
1109    pub metadata: Option<HashMap<String, String>>,
1110    /// The version of the metadata for this object at this generation. Used for preconditions and for detecting changes in metadata. A metageneration number is only meaningful in the context of a particular generation of a particular object.
1111    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1112    pub metageneration: Option<i64>,
1113    /// The name of the object. Required if not specified by URL parameter.
1114    pub name: Option<String>,
1115    /// The owner of the object. This will always be the uploader of the object.
1116    pub owner: Option<ObjectOwner>,
1117    /// A collection of object level retention parameters.
1118    pub retention: Option<ObjectRetention>,
1119    /// A server-determined value that specifies the earliest time that the object's retention period expires. This value is in RFC 3339 format. Note 1: This field is not provided for objects with an active event-based hold, since retention expiration is unknown until the hold is removed. Note 2: This value can be provided even when temporary hold is set (so that the user can reason about policy without having to first unset the temporary hold).
1120    #[serde(rename = "retentionExpirationTime")]
1121    pub retention_expiration_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1122    /// The link to this object.
1123    #[serde(rename = "selfLink")]
1124    pub self_link: Option<String>,
1125    /// Content-Length of the data in bytes.
1126    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1127    pub size: Option<u64>,
1128    /// The time at which the object became soft-deleted in RFC 3339 format.
1129    #[serde(rename = "softDeleteTime")]
1130    pub soft_delete_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1131    /// Storage class of the object.
1132    #[serde(rename = "storageClass")]
1133    pub storage_class: Option<String>,
1134    /// Whether an object is under temporary hold. While this flag is set to true, the object is protected against deletion and overwrites. A common use case of this flag is regulatory investigations where objects need to be retained while the investigation is ongoing. Note that unlike event-based hold, temporary hold does not impact retention expiration time of an object.
1135    #[serde(rename = "temporaryHold")]
1136    pub temporary_hold: Option<bool>,
1137    /// The creation time of the object in RFC 3339 format.
1138    #[serde(rename = "timeCreated")]
1139    pub time_created: Option<chrono::DateTime<chrono::offset::Utc>>,
1140    /// The time at which the object became noncurrent in RFC 3339 format. Will be returned if and only if this version of the object has been deleted.
1141    #[serde(rename = "timeDeleted")]
1142    pub time_deleted: Option<chrono::DateTime<chrono::offset::Utc>>,
1143    /// The time at which the object's storage class was last changed. When the object is initially created, it will be set to timeCreated.
1144    #[serde(rename = "timeStorageClassUpdated")]
1145    pub time_storage_class_updated: Option<chrono::DateTime<chrono::offset::Utc>>,
1146    /// The modification time of the object metadata in RFC 3339 format. Set initially to object creation time and then updated whenever any metadata of the object changes. This includes changes made by a requester, such as modifying custom metadata, as well as changes made by Cloud Storage on behalf of a requester, such as changing the storage class based on an Object Lifecycle Configuration.
1147    pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
1148}
1149
1150impl common::RequestValue for Object {}
1151impl common::Resource for Object {}
1152impl common::ResponseResult for Object {}
1153
1154/// An access-control entry.
1155///
1156/// # Activities
1157///
1158/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1159/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1160///
1161/// * [get default object access controls](DefaultObjectAccessControlGetCall) (response)
1162/// * [insert default object access controls](DefaultObjectAccessControlInsertCall) (request|response)
1163/// * [patch default object access controls](DefaultObjectAccessControlPatchCall) (request|response)
1164/// * [update default object access controls](DefaultObjectAccessControlUpdateCall) (request|response)
1165/// * [delete object access controls](ObjectAccessControlDeleteCall) (none)
1166/// * [get object access controls](ObjectAccessControlGetCall) (response)
1167/// * [insert object access controls](ObjectAccessControlInsertCall) (request|response)
1168/// * [list object access controls](ObjectAccessControlListCall) (none)
1169/// * [patch object access controls](ObjectAccessControlPatchCall) (request|response)
1170/// * [update object access controls](ObjectAccessControlUpdateCall) (request|response)
1171#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1172#[serde_with::serde_as]
1173#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1174pub struct ObjectAccessControl {
1175    /// The name of the bucket.
1176    pub bucket: Option<String>,
1177    /// The domain associated with the entity, if any.
1178    pub domain: Option<String>,
1179    /// The email address associated with the entity, if any.
1180    pub email: Option<String>,
1181    /// The entity holding the permission, in one of the following forms:
1182    /// - user-userId
1183    /// - user-email
1184    /// - group-groupId
1185    /// - group-email
1186    /// - domain-domain
1187    /// - project-team-projectId
1188    /// - allUsers
1189    /// - allAuthenticatedUsers Examples:
1190    /// - The user liz@example.com would be user-liz@example.com.
1191    /// - The group example@googlegroups.com would be group-example@googlegroups.com.
1192    /// - To refer to all members of the Google Apps for Business domain example.com, the entity would be domain-example.com.
1193    pub entity: Option<String>,
1194    /// The ID for the entity, if any.
1195    #[serde(rename = "entityId")]
1196    pub entity_id: Option<String>,
1197    /// HTTP 1.1 Entity tag for the access-control entry.
1198    pub etag: Option<String>,
1199    /// The content generation of the object, if applied to an object.
1200    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1201    pub generation: Option<i64>,
1202    /// The ID of the access-control entry.
1203    pub id: Option<String>,
1204    /// The kind of item this is. For object access control entries, this is always storage#objectAccessControl.
1205    pub kind: Option<String>,
1206    /// The name of the object, if applied to an object.
1207    pub object: Option<String>,
1208    /// The project team associated with the entity, if any.
1209    #[serde(rename = "projectTeam")]
1210    pub project_team: Option<ObjectAccessControlProjectTeam>,
1211    /// The access permission for the entity.
1212    pub role: Option<String>,
1213    /// The link to this access-control entry.
1214    #[serde(rename = "selfLink")]
1215    pub self_link: Option<String>,
1216}
1217
1218impl common::RequestValue for ObjectAccessControl {}
1219impl common::Resource for ObjectAccessControl {}
1220impl common::ResponseResult for ObjectAccessControl {}
1221
1222/// An access-control list.
1223///
1224/// # Activities
1225///
1226/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1227/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1228///
1229/// * [list default object access controls](DefaultObjectAccessControlListCall) (response)
1230/// * [list object access controls](ObjectAccessControlListCall) (response)
1231#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1232#[serde_with::serde_as]
1233#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1234pub struct ObjectAccessControls {
1235    /// The list of items.
1236    pub items: Option<Vec<ObjectAccessControl>>,
1237    /// The kind of item this is. For lists of object access control entries, this is always storage#objectAccessControls.
1238    pub kind: Option<String>,
1239}
1240
1241impl common::ResponseResult for ObjectAccessControls {}
1242
1243/// A list of objects.
1244///
1245/// # Activities
1246///
1247/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1248/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1249///
1250/// * [list objects](ObjectListCall) (response)
1251#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1252#[serde_with::serde_as]
1253#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1254pub struct Objects {
1255    /// The list of items.
1256    pub items: Option<Vec<Object>>,
1257    /// The kind of item this is. For lists of objects, this is always storage#objects.
1258    pub kind: Option<String>,
1259    /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results.
1260    #[serde(rename = "nextPageToken")]
1261    pub next_page_token: Option<String>,
1262    /// The list of prefixes of objects matching-but-not-listed up to and including the requested delimiter.
1263    pub prefixes: Option<Vec<String>>,
1264}
1265
1266impl common::ResponseResult for Objects {}
1267
1268/// A bucket/object/managedFolder IAM policy.
1269///
1270/// # Activities
1271///
1272/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1273/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1274///
1275/// * [get iam policy buckets](BucketGetIamPolicyCall) (response)
1276/// * [set iam policy buckets](BucketSetIamPolicyCall) (request|response)
1277/// * [get iam policy managed folders](ManagedFolderGetIamPolicyCall) (response)
1278/// * [set iam policy managed folders](ManagedFolderSetIamPolicyCall) (request|response)
1279/// * [get iam policy objects](ObjectGetIamPolicyCall) (response)
1280/// * [set iam policy objects](ObjectSetIamPolicyCall) (request|response)
1281#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1282#[serde_with::serde_as]
1283#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1284pub struct Policy {
1285    /// An association between a role, which comes with a set of permissions, and members who may assume that role.
1286    pub bindings: Option<Vec<PolicyBindings>>,
1287    /// HTTP 1.1  Entity tag for the policy.
1288    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1289    pub etag: Option<Vec<u8>>,
1290    /// The kind of item this is. For policies, this is always storage#policy. This field is ignored on input.
1291    pub kind: Option<String>,
1292    /// The ID of the resource to which this policy belongs. Will be of the form projects/_/buckets/bucket for buckets, projects/_/buckets/bucket/objects/object for objects, and projects/_/buckets/bucket/managedFolders/managedFolder. A specific generation may be specified by appending #generationNumber to the end of the object name, e.g. projects/_/buckets/my-bucket/objects/data.txt#17. The current generation can be denoted with #0. This field is ignored on input.
1293    #[serde(rename = "resourceId")]
1294    pub resource_id: Option<String>,
1295    /// The IAM policy format version.
1296    pub version: Option<i32>,
1297}
1298
1299impl common::RequestValue for Policy {}
1300impl common::ResponseResult for Policy {}
1301
1302/// A rewrite response.
1303///
1304/// # Activities
1305///
1306/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1307/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1308///
1309/// * [rewrite objects](ObjectRewriteCall) (response)
1310#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1311#[serde_with::serde_as]
1312#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1313pub struct RewriteResponse {
1314    /// true if the copy is finished; otherwise, false if the copy is in progress. This property is always present in the response.
1315    pub done: Option<bool>,
1316    /// The kind of item this is.
1317    pub kind: Option<String>,
1318    /// The total size of the object being copied in bytes. This property is always present in the response.
1319    #[serde(rename = "objectSize")]
1320    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1321    pub object_size: Option<i64>,
1322    /// A resource containing the metadata for the copied-to object. This property is present in the response only when copying completes.
1323    pub resource: Option<Object>,
1324    /// A token to use in subsequent requests to continue copying data. This token is present in the response only when there is more data to copy.
1325    #[serde(rename = "rewriteToken")]
1326    pub rewrite_token: Option<String>,
1327    /// The total bytes written so far, which can be used to provide a waiting user with a progress indicator. This property is always present in the response.
1328    #[serde(rename = "totalBytesRewritten")]
1329    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1330    pub total_bytes_rewritten: Option<i64>,
1331}
1332
1333impl common::ResponseResult for RewriteResponse {}
1334
1335/// A subscription to receive Google PubSub notifications.
1336///
1337/// # Activities
1338///
1339/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1340/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1341///
1342/// * [service account get projects](ProjectServiceAccountGetCall) (response)
1343#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1344#[serde_with::serde_as]
1345#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1346pub struct ServiceAccount {
1347    /// The ID of the notification.
1348    pub email_address: Option<String>,
1349    /// The kind of item this is. For notifications, this is always storage#notification.
1350    pub kind: Option<String>,
1351}
1352
1353impl common::ResponseResult for ServiceAccount {}
1354
1355/// A storage.(buckets|objects|managedFolders).testIamPermissions response.
1356///
1357/// # Activities
1358///
1359/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1360/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1361///
1362/// * [test iam permissions buckets](BucketTestIamPermissionCall) (response)
1363/// * [test iam permissions managed folders](ManagedFolderTestIamPermissionCall) (response)
1364/// * [test iam permissions objects](ObjectTestIamPermissionCall) (response)
1365#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1366#[serde_with::serde_as]
1367#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1368pub struct TestIamPermissionsResponse {
1369    /// The kind of item this is.
1370    pub kind: Option<String>,
1371    /// The permissions held by the caller. Permissions are always of the format storage.resource.capability, where resource is one of buckets, objects, or managedFolders. The supported permissions are as follows:  
1372    /// - storage.buckets.delete — Delete bucket.  
1373    /// - storage.buckets.get — Read bucket metadata.  
1374    /// - storage.buckets.getIamPolicy — Read bucket IAM policy.  
1375    /// - storage.buckets.create — Create bucket.  
1376    /// - storage.buckets.list — List buckets.  
1377    /// - storage.buckets.setIamPolicy — Update bucket IAM policy.  
1378    /// - storage.buckets.update — Update bucket metadata.  
1379    /// - storage.objects.delete — Delete object.  
1380    /// - storage.objects.get — Read object data and metadata.  
1381    /// - storage.objects.getIamPolicy — Read object IAM policy.  
1382    /// - storage.objects.create — Create object.  
1383    /// - storage.objects.list — List objects.  
1384    /// - storage.objects.setIamPolicy — Update object IAM policy.  
1385    /// - storage.objects.update — Update object metadata.
1386    /// - storage.managedFolders.delete — Delete managed folder.  
1387    /// - storage.managedFolders.get — Read managed folder metadata.  
1388    /// - storage.managedFolders.getIamPolicy — Read managed folder IAM policy.  
1389    /// - storage.managedFolders.create — Create managed folder.  
1390    /// - storage.managedFolders.list — List managed folders.  
1391    /// - storage.managedFolders.setIamPolicy — Update managed folder IAM policy.
1392    pub permissions: Option<Vec<String>>,
1393}
1394
1395impl common::ResponseResult for TestIamPermissionsResponse {}
1396
1397/// The bucket's Autoclass configuration.
1398///
1399/// This type is not used in any activity, and only used as *part* of another schema.
1400///
1401#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1402#[serde_with::serde_as]
1403#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1404pub struct BucketAutoclass {
1405    /// Whether or not Autoclass is enabled on this bucket
1406    pub enabled: Option<bool>,
1407    /// The storage class that objects in the bucket eventually transition to if they are not read for a certain length of time. Valid values are NEARLINE and ARCHIVE.
1408    #[serde(rename = "terminalStorageClass")]
1409    pub terminal_storage_class: Option<String>,
1410    /// A date and time in RFC 3339 format representing the time of the most recent update to "terminalStorageClass".
1411    #[serde(rename = "terminalStorageClassUpdateTime")]
1412    pub terminal_storage_class_update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1413    /// A date and time in RFC 3339 format representing the instant at which "enabled" was last toggled.
1414    #[serde(rename = "toggleTime")]
1415    pub toggle_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1416}
1417
1418impl common::NestedType for BucketAutoclass {}
1419impl common::Part for BucketAutoclass {}
1420
1421/// The bucket's billing configuration.
1422///
1423/// This type is not used in any activity, and only used as *part* of another schema.
1424///
1425#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1426#[serde_with::serde_as]
1427#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1428pub struct BucketBilling {
1429    /// When set to true, Requester Pays is enabled for this bucket.
1430    #[serde(rename = "requesterPays")]
1431    pub requester_pays: Option<bool>,
1432}
1433
1434impl common::NestedType for BucketBilling {}
1435impl common::Part for BucketBilling {}
1436
1437/// The bucket's Cross-Origin Resource Sharing (CORS) configuration.
1438///
1439/// This type is not used in any activity, and only used as *part* of another schema.
1440///
1441#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1442#[serde_with::serde_as]
1443#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1444pub struct BucketCors {
1445    /// The value, in seconds, to return in the  Access-Control-Max-Age header used in preflight responses.
1446    #[serde(rename = "maxAgeSeconds")]
1447    pub max_age_seconds: Option<i32>,
1448    /// The list of HTTP methods on which to include CORS response headers, (GET, OPTIONS, POST, etc) Note: "*" is permitted in the list of methods, and means "any method".
1449    pub method: Option<Vec<String>>,
1450    /// The list of Origins eligible to receive CORS response headers. Note: "*" is permitted in the list of origins, and means "any Origin".
1451    pub origin: Option<Vec<String>>,
1452    /// The list of HTTP headers other than the simple response headers to give permission for the user-agent to share across domains.
1453    #[serde(rename = "responseHeader")]
1454    pub response_header: Option<Vec<String>>,
1455}
1456
1457impl common::NestedType for BucketCors {}
1458impl common::Part for BucketCors {}
1459
1460/// The bucket's custom placement configuration for Custom Dual Regions.
1461///
1462/// This type is not used in any activity, and only used as *part* of another schema.
1463///
1464#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1465#[serde_with::serde_as]
1466#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1467pub struct BucketCustomPlacementConfig {
1468    /// The list of regional locations in which data is placed.
1469    #[serde(rename = "dataLocations")]
1470    pub data_locations: Option<Vec<String>>,
1471}
1472
1473impl common::NestedType for BucketCustomPlacementConfig {}
1474impl common::Part for BucketCustomPlacementConfig {}
1475
1476/// Encryption configuration for a bucket.
1477///
1478/// This type is not used in any activity, and only used as *part* of another schema.
1479///
1480#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1481#[serde_with::serde_as]
1482#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1483pub struct BucketEncryption {
1484    /// A Cloud KMS key that will be used to encrypt objects inserted into this bucket, if no encryption method is specified.
1485    #[serde(rename = "defaultKmsKeyName")]
1486    pub default_kms_key_name: Option<String>,
1487}
1488
1489impl common::NestedType for BucketEncryption {}
1490impl common::Part for BucketEncryption {}
1491
1492/// The bucket's hierarchical namespace configuration.
1493///
1494/// This type is not used in any activity, and only used as *part* of another schema.
1495///
1496#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1497#[serde_with::serde_as]
1498#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1499pub struct BucketHierarchicalNamespace {
1500    /// When set to true, hierarchical namespace is enabled for this bucket.
1501    pub enabled: Option<bool>,
1502}
1503
1504impl common::NestedType for BucketHierarchicalNamespace {}
1505impl common::Part for BucketHierarchicalNamespace {}
1506
1507/// The bucket's IAM configuration.
1508///
1509/// This type is not used in any activity, and only used as *part* of another schema.
1510///
1511#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1512#[serde_with::serde_as]
1513#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1514pub struct BucketIamConfiguration {
1515    /// The bucket's uniform bucket-level access configuration. The feature was formerly known as Bucket Policy Only. For backward compatibility, this field will be populated with identical information as the uniformBucketLevelAccess field. We recommend using the uniformBucketLevelAccess field to enable and disable the feature.
1516    #[serde(rename = "bucketPolicyOnly")]
1517    pub bucket_policy_only: Option<BucketIamConfigurationBucketPolicyOnly>,
1518    /// The bucket's Public Access Prevention configuration. Currently, 'inherited' and 'enforced' are supported.
1519    #[serde(rename = "publicAccessPrevention")]
1520    pub public_access_prevention: Option<String>,
1521    /// The bucket's uniform bucket-level access configuration.
1522    #[serde(rename = "uniformBucketLevelAccess")]
1523    pub uniform_bucket_level_access: Option<BucketIamConfigurationUniformBucketLevelAccess>,
1524}
1525
1526impl common::NestedType for BucketIamConfiguration {}
1527impl common::Part for BucketIamConfiguration {}
1528
1529/// The bucket's uniform bucket-level access configuration. The feature was formerly known as Bucket Policy Only. For backward compatibility, this field will be populated with identical information as the uniformBucketLevelAccess field. We recommend using the uniformBucketLevelAccess field to enable and disable the feature.
1530///
1531/// This type is not used in any activity, and only used as *part* of another schema.
1532///
1533#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1534#[serde_with::serde_as]
1535#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1536pub struct BucketIamConfigurationBucketPolicyOnly {
1537    /// If set, access is controlled only by bucket-level or above IAM policies.
1538    pub enabled: Option<bool>,
1539    /// The deadline for changing iamConfiguration.bucketPolicyOnly.enabled from true to false in RFC 3339 format. iamConfiguration.bucketPolicyOnly.enabled may be changed from true to false until the locked time, after which the field is immutable.
1540    #[serde(rename = "lockedTime")]
1541    pub locked_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1542}
1543
1544impl common::NestedType for BucketIamConfigurationBucketPolicyOnly {}
1545impl common::Part for BucketIamConfigurationBucketPolicyOnly {}
1546
1547/// The bucket's uniform bucket-level access configuration.
1548///
1549/// This type is not used in any activity, and only used as *part* of another schema.
1550///
1551#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1552#[serde_with::serde_as]
1553#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1554pub struct BucketIamConfigurationUniformBucketLevelAccess {
1555    /// If set, access is controlled only by bucket-level or above IAM policies.
1556    pub enabled: Option<bool>,
1557    /// The deadline for changing iamConfiguration.uniformBucketLevelAccess.enabled from true to false in RFC 3339  format. iamConfiguration.uniformBucketLevelAccess.enabled may be changed from true to false until the locked time, after which the field is immutable.
1558    #[serde(rename = "lockedTime")]
1559    pub locked_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1560}
1561
1562impl common::NestedType for BucketIamConfigurationUniformBucketLevelAccess {}
1563impl common::Part for BucketIamConfigurationUniformBucketLevelAccess {}
1564
1565/// The bucket's lifecycle configuration. See lifecycle management for more information.
1566///
1567/// This type is not used in any activity, and only used as *part* of another schema.
1568///
1569#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1570#[serde_with::serde_as]
1571#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1572pub struct BucketLifecycle {
1573    /// A lifecycle management rule, which is made of an action to take and the condition(s) under which the action will be taken.
1574    pub rule: Option<Vec<BucketLifecycleRule>>,
1575}
1576
1577impl common::NestedType for BucketLifecycle {}
1578impl common::Part for BucketLifecycle {}
1579
1580/// A lifecycle management rule, which is made of an action to take and the condition(s) under which the action will be taken.
1581///
1582/// This type is not used in any activity, and only used as *part* of another schema.
1583///
1584#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1585#[serde_with::serde_as]
1586#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1587pub struct BucketLifecycleRule {
1588    /// The action to take.
1589    pub action: Option<BucketLifecycleRuleAction>,
1590    /// The condition(s) under which the action will be taken.
1591    pub condition: Option<BucketLifecycleRuleCondition>,
1592}
1593
1594impl common::NestedType for BucketLifecycleRule {}
1595impl common::Part for BucketLifecycleRule {}
1596
1597/// The action to take.
1598///
1599/// This type is not used in any activity, and only used as *part* of another schema.
1600///
1601#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1602#[serde_with::serde_as]
1603#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1604pub struct BucketLifecycleRuleAction {
1605    /// Target storage class. Required iff the type of the action is SetStorageClass.
1606    #[serde(rename = "storageClass")]
1607    pub storage_class: Option<String>,
1608    /// Type of the action. Currently, only Delete, SetStorageClass, and AbortIncompleteMultipartUpload are supported.
1609    #[serde(rename = "type")]
1610    pub type_: Option<String>,
1611}
1612
1613impl common::NestedType for BucketLifecycleRuleAction {}
1614impl common::Part for BucketLifecycleRuleAction {}
1615
1616/// The condition(s) under which the action will be taken.
1617///
1618/// This type is not used in any activity, and only used as *part* of another schema.
1619///
1620#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1621#[serde_with::serde_as]
1622#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1623pub struct BucketLifecycleRuleCondition {
1624    /// Age of an object (in days). This condition is satisfied when an object reaches the specified age.
1625    pub age: Option<i32>,
1626    /// A date in RFC 3339 format with only the date part (for instance, "2013-01-15"). This condition is satisfied when an object is created before midnight of the specified date in UTC.
1627    #[serde(rename = "createdBefore")]
1628    pub created_before: Option<chrono::NaiveDate>,
1629    /// A date in RFC 3339 format with only the date part (for instance, "2013-01-15"). This condition is satisfied when the custom time on an object is before this date in UTC.
1630    #[serde(rename = "customTimeBefore")]
1631    pub custom_time_before: Option<chrono::NaiveDate>,
1632    /// Number of days elapsed since the user-specified timestamp set on an object. The condition is satisfied if the days elapsed is at least this number. If no custom timestamp is specified on an object, the condition does not apply.
1633    #[serde(rename = "daysSinceCustomTime")]
1634    pub days_since_custom_time: Option<i32>,
1635    /// Number of days elapsed since the noncurrent timestamp of an object. The condition is satisfied if the days elapsed is at least this number. This condition is relevant only for versioned objects. The value of the field must be a nonnegative integer. If it's zero, the object version will become eligible for Lifecycle action as soon as it becomes noncurrent.
1636    #[serde(rename = "daysSinceNoncurrentTime")]
1637    pub days_since_noncurrent_time: Option<i32>,
1638    /// Relevant only for versioned objects. If the value is true, this condition matches live objects; if the value is false, it matches archived objects.
1639    #[serde(rename = "isLive")]
1640    pub is_live: Option<bool>,
1641    /// A regular expression that satisfies the RE2 syntax. This condition is satisfied when the name of the object matches the RE2 pattern. Note: This feature is currently in the "Early Access" launch stage and is only available to a whitelisted set of users; that means that this feature may be changed in backward-incompatible ways and that it is not guaranteed to be released.
1642    #[serde(rename = "matchesPattern")]
1643    pub matches_pattern: Option<String>,
1644    /// List of object name prefixes. This condition will be satisfied when at least one of the prefixes exactly matches the beginning of the object name.
1645    #[serde(rename = "matchesPrefix")]
1646    pub matches_prefix: Option<Vec<String>>,
1647    /// Objects having any of the storage classes specified by this condition will be matched. Values include MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, ARCHIVE, STANDARD, and DURABLE_REDUCED_AVAILABILITY.
1648    #[serde(rename = "matchesStorageClass")]
1649    pub matches_storage_class: Option<Vec<String>>,
1650    /// List of object name suffixes. This condition will be satisfied when at least one of the suffixes exactly matches the end of the object name.
1651    #[serde(rename = "matchesSuffix")]
1652    pub matches_suffix: Option<Vec<String>>,
1653    /// A date in RFC 3339 format with only the date part (for instance, "2013-01-15"). This condition is satisfied when the noncurrent time on an object is before this date in UTC. This condition is relevant only for versioned objects.
1654    #[serde(rename = "noncurrentTimeBefore")]
1655    pub noncurrent_time_before: Option<chrono::NaiveDate>,
1656    /// Relevant only for versioned objects. If the value is N, this condition is satisfied when there are at least N versions (including the live version) newer than this version of the object.
1657    #[serde(rename = "numNewerVersions")]
1658    pub num_newer_versions: Option<i32>,
1659}
1660
1661impl common::NestedType for BucketLifecycleRuleCondition {}
1662impl common::Part for BucketLifecycleRuleCondition {}
1663
1664/// The bucket's logging configuration, which defines the destination bucket and optional name prefix for the current bucket's logs.
1665///
1666/// This type is not used in any activity, and only used as *part* of another schema.
1667///
1668#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1669#[serde_with::serde_as]
1670#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1671pub struct BucketLogging {
1672    /// The destination bucket where the current bucket's logs should be placed.
1673    #[serde(rename = "logBucket")]
1674    pub log_bucket: Option<String>,
1675    /// A prefix for log object names.
1676    #[serde(rename = "logObjectPrefix")]
1677    pub log_object_prefix: Option<String>,
1678}
1679
1680impl common::NestedType for BucketLogging {}
1681impl common::Part for BucketLogging {}
1682
1683/// The bucket's object retention config.
1684///
1685/// This type is not used in any activity, and only used as *part* of another schema.
1686///
1687#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1688#[serde_with::serde_as]
1689#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1690pub struct BucketObjectRetention {
1691    /// The bucket's object retention mode. Can be Enabled.
1692    pub mode: Option<String>,
1693}
1694
1695impl common::NestedType for BucketObjectRetention {}
1696impl common::Part for BucketObjectRetention {}
1697
1698/// The owner of the bucket. This is always the project team's owner group.
1699///
1700/// This type is not used in any activity, and only used as *part* of another schema.
1701///
1702#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1703#[serde_with::serde_as]
1704#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1705pub struct BucketOwner {
1706    /// The entity, in the form project-owner-projectId.
1707    pub entity: Option<String>,
1708    /// The ID for the entity.
1709    #[serde(rename = "entityId")]
1710    pub entity_id: Option<String>,
1711}
1712
1713impl common::NestedType for BucketOwner {}
1714impl common::Part for BucketOwner {}
1715
1716/// The bucket's retention policy. The retention policy enforces a minimum retention time for all objects contained in the bucket, based on their creation time. Any attempt to overwrite or delete objects younger than the retention period will result in a PERMISSION_DENIED error. An unlocked retention policy can be modified or removed from the bucket via a storage.buckets.update operation. A locked retention policy cannot be removed or shortened in duration for the lifetime of the bucket. Attempting to remove or decrease period of a locked retention policy will result in a PERMISSION_DENIED error.
1717///
1718/// This type is not used in any activity, and only used as *part* of another schema.
1719///
1720#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1721#[serde_with::serde_as]
1722#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1723pub struct BucketRetentionPolicy {
1724    /// Server-determined value that indicates the time from which policy was enforced and effective. This value is in RFC 3339 format.
1725    #[serde(rename = "effectiveTime")]
1726    pub effective_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1727    /// Once locked, an object retention policy cannot be modified.
1728    #[serde(rename = "isLocked")]
1729    pub is_locked: Option<bool>,
1730    /// The duration in seconds that objects need to be retained. Retention duration must be greater than zero and less than 100 years. Note that enforcement of retention periods less than a day is not guaranteed. Such periods should only be used for testing purposes.
1731    #[serde(rename = "retentionPeriod")]
1732    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1733    pub retention_period: Option<i64>,
1734}
1735
1736impl common::NestedType for BucketRetentionPolicy {}
1737impl common::Part for BucketRetentionPolicy {}
1738
1739/// The bucket's soft delete policy, which defines the period of time that soft-deleted objects will be retained, and cannot be permanently deleted.
1740///
1741/// This type is not used in any activity, and only used as *part* of another schema.
1742///
1743#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1744#[serde_with::serde_as]
1745#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1746pub struct BucketSoftDeletePolicy {
1747    /// Server-determined value that indicates the time from which the policy, or one with a greater retention, was effective. This value is in RFC 3339 format.
1748    #[serde(rename = "effectiveTime")]
1749    pub effective_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1750    /// The duration in seconds that soft-deleted objects in the bucket will be retained and cannot be permanently deleted.
1751    #[serde(rename = "retentionDurationSeconds")]
1752    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1753    pub retention_duration_seconds: Option<i64>,
1754}
1755
1756impl common::NestedType for BucketSoftDeletePolicy {}
1757impl common::Part for BucketSoftDeletePolicy {}
1758
1759/// The bucket's versioning configuration.
1760///
1761/// This type is not used in any activity, and only used as *part* of another schema.
1762///
1763#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1764#[serde_with::serde_as]
1765#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1766pub struct BucketVersioning {
1767    /// While set to true, versioning is fully enabled for this bucket.
1768    pub enabled: Option<bool>,
1769}
1770
1771impl common::NestedType for BucketVersioning {}
1772impl common::Part for BucketVersioning {}
1773
1774/// 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.
1775///
1776/// This type is not used in any activity, and only used as *part* of another schema.
1777///
1778#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1779#[serde_with::serde_as]
1780#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1781pub struct BucketWebsite {
1782    /// If the requested object path is missing, the service will ensure the path has a trailing '/', append this suffix, and attempt to retrieve the resulting object. This allows the creation of index.html objects to represent directory pages.
1783    #[serde(rename = "mainPageSuffix")]
1784    pub main_page_suffix: Option<String>,
1785    /// If the requested object path is missing, and any mainPageSuffix object is missing, if applicable, the service will return the named object from this bucket as the content for a 404 Not Found result.
1786    #[serde(rename = "notFoundPage")]
1787    pub not_found_page: Option<String>,
1788}
1789
1790impl common::NestedType for BucketWebsite {}
1791impl common::Part for BucketWebsite {}
1792
1793/// The project team associated with the entity, if any.
1794///
1795/// This type is not used in any activity, and only used as *part* of another schema.
1796///
1797#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1798#[serde_with::serde_as]
1799#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1800pub struct BucketAccessControlProjectTeam {
1801    /// The project number.
1802    #[serde(rename = "projectNumber")]
1803    pub project_number: Option<String>,
1804    /// The team.
1805    pub team: Option<String>,
1806}
1807
1808impl common::NestedType for BucketAccessControlProjectTeam {}
1809impl common::Part for BucketAccessControlProjectTeam {}
1810
1811/// The bucket's custom placement configuration for Custom Dual Regions.
1812///
1813/// This type is not used in any activity, and only used as *part* of another schema.
1814///
1815#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1816#[serde_with::serde_as]
1817#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1818pub struct BucketStorageLayoutCustomPlacementConfig {
1819    /// The list of regional locations in which data is placed.
1820    #[serde(rename = "dataLocations")]
1821    pub data_locations: Option<Vec<String>>,
1822}
1823
1824impl common::NestedType for BucketStorageLayoutCustomPlacementConfig {}
1825impl common::Part for BucketStorageLayoutCustomPlacementConfig {}
1826
1827/// The bucket's hierarchical namespace configuration.
1828///
1829/// This type is not used in any activity, and only used as *part* of another schema.
1830///
1831#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1832#[serde_with::serde_as]
1833#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1834pub struct BucketStorageLayoutHierarchicalNamespace {
1835    /// When set to true, hierarchical namespace is enabled for this bucket.
1836    pub enabled: Option<bool>,
1837}
1838
1839impl common::NestedType for BucketStorageLayoutHierarchicalNamespace {}
1840impl common::Part for BucketStorageLayoutHierarchicalNamespace {}
1841
1842/// The list of source objects that will be concatenated into a single object.
1843///
1844/// This type is not used in any activity, and only used as *part* of another schema.
1845///
1846#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1847#[serde_with::serde_as]
1848#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1849pub struct ComposeRequestSourceObjects {
1850    /// The generation of this object to use as the source.
1851    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1852    pub generation: Option<i64>,
1853    /// The source object's name. All source objects must reside in the same bucket.
1854    pub name: Option<String>,
1855    /// Conditions that must be met for this operation to execute.
1856    #[serde(rename = "objectPreconditions")]
1857    pub object_preconditions: Option<ComposeRequestSourceObjectsObjectPreconditions>,
1858}
1859
1860impl common::NestedType for ComposeRequestSourceObjects {}
1861impl common::Part for ComposeRequestSourceObjects {}
1862
1863/// Conditions that must be met for this operation to execute.
1864///
1865/// This type is not used in any activity, and only used as *part* of another schema.
1866///
1867#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1868#[serde_with::serde_as]
1869#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1870pub struct ComposeRequestSourceObjectsObjectPreconditions {
1871    /// Only perform the composition if the generation of the source object that would be used matches this value. If this value and a generation are both specified, they must be the same value or the call will fail.
1872    #[serde(rename = "ifGenerationMatch")]
1873    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1874    pub if_generation_match: Option<i64>,
1875}
1876
1877impl common::NestedType for ComposeRequestSourceObjectsObjectPreconditions {}
1878impl common::Part for ComposeRequestSourceObjectsObjectPreconditions {}
1879
1880/// Only present if the folder is part of an ongoing rename folder operation. Contains information which can be used to query the operation status.
1881///
1882/// This type is not used in any activity, and only used as *part* of another schema.
1883///
1884#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1885#[serde_with::serde_as]
1886#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1887pub struct FolderPendingRenameInfo {
1888    /// The ID of the rename folder operation.
1889    #[serde(rename = "operationId")]
1890    pub operation_id: Option<String>,
1891}
1892
1893impl common::NestedType for FolderPendingRenameInfo {}
1894impl common::Part for FolderPendingRenameInfo {}
1895
1896/// Metadata of customer-supplied encryption key, if the object is encrypted by such a key.
1897///
1898/// This type is not used in any activity, and only used as *part* of another schema.
1899///
1900#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1901#[serde_with::serde_as]
1902#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1903pub struct ObjectCustomerEncryption {
1904    /// The encryption algorithm.
1905    #[serde(rename = "encryptionAlgorithm")]
1906    pub encryption_algorithm: Option<String>,
1907    /// SHA256 hash value of the encryption key.
1908    #[serde(rename = "keySha256")]
1909    pub key_sha256: Option<String>,
1910}
1911
1912impl common::NestedType for ObjectCustomerEncryption {}
1913impl common::Part for ObjectCustomerEncryption {}
1914
1915/// The owner of the object. This will always be the uploader of the object.
1916///
1917/// This type is not used in any activity, and only used as *part* of another schema.
1918///
1919#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1920#[serde_with::serde_as]
1921#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1922pub struct ObjectOwner {
1923    /// The entity, in the form user-userId.
1924    pub entity: Option<String>,
1925    /// The ID for the entity.
1926    #[serde(rename = "entityId")]
1927    pub entity_id: Option<String>,
1928}
1929
1930impl common::NestedType for ObjectOwner {}
1931impl common::Part for ObjectOwner {}
1932
1933/// A collection of object level retention parameters.
1934///
1935/// This type is not used in any activity, and only used as *part* of another schema.
1936///
1937#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1938#[serde_with::serde_as]
1939#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1940pub struct ObjectRetention {
1941    /// The bucket's object retention mode, can only be Unlocked or Locked.
1942    pub mode: Option<String>,
1943    /// A time in RFC 3339 format until which object retention protects this object.
1944    #[serde(rename = "retainUntilTime")]
1945    pub retain_until_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1946}
1947
1948impl common::NestedType for ObjectRetention {}
1949impl common::Part for ObjectRetention {}
1950
1951/// The project team associated with the entity, if any.
1952///
1953/// This type is not used in any activity, and only used as *part* of another schema.
1954///
1955#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1956#[serde_with::serde_as]
1957#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1958pub struct ObjectAccessControlProjectTeam {
1959    /// The project number.
1960    #[serde(rename = "projectNumber")]
1961    pub project_number: Option<String>,
1962    /// The team.
1963    pub team: Option<String>,
1964}
1965
1966impl common::NestedType for ObjectAccessControlProjectTeam {}
1967impl common::Part for ObjectAccessControlProjectTeam {}
1968
1969/// An association between a role, which comes with a set of permissions, and members who may assume that role.
1970///
1971/// This type is not used in any activity, and only used as *part* of another schema.
1972///
1973#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1974#[serde_with::serde_as]
1975#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1976pub struct PolicyBindings {
1977    /// The condition that is associated with this binding. NOTE: an unsatisfied condition will not allow user access via current binding. Different bindings, including their conditions, are examined independently.
1978    pub condition: Option<Expr>,
1979    /// A collection of identifiers for members who may assume the provided role. Recognized identifiers are as follows:  
1980    /// - allUsers — A special identifier that represents anyone on the internet; with or without a Google account.  
1981    /// - allAuthenticatedUsers — A special identifier that represents anyone who is authenticated with a Google account or a service account.  
1982    /// - user:emailid — An email address that represents a specific account. For example, user:alice@gmail.com or user:joe@example.com.  
1983    /// - serviceAccount:emailid — An email address that represents a service account. For example,  serviceAccount:my-other-app@appspot.gserviceaccount.com .  
1984    /// - group:emailid — An email address that represents a Google group. For example, group:admins@example.com.  
1985    /// - domain:domain — A Google Apps domain name that represents all the users of that domain. For example, domain:google.com or domain:example.com.  
1986    /// - projectOwner:projectid — Owners of the given project. For example, projectOwner:my-example-project  
1987    /// - projectEditor:projectid — Editors of the given project. For example, projectEditor:my-example-project  
1988    /// - projectViewer:projectid — Viewers of the given project. For example, projectViewer:my-example-project
1989    pub members: Option<Vec<String>>,
1990    /// The role to which members belong. Two types of roles are supported: new IAM roles, which grant permissions that do not map directly to those provided by ACLs, and legacy IAM roles, which do map directly to ACL permissions. All roles are of the format roles/storage.specificRole.
1991    /// The new IAM roles are:  
1992    /// - roles/storage.admin — Full control of Google Cloud Storage resources.  
1993    /// - roles/storage.objectViewer — Read-Only access to Google Cloud Storage objects.  
1994    /// - roles/storage.objectCreator — Access to create objects in Google Cloud Storage.  
1995    /// - roles/storage.objectAdmin — Full control of Google Cloud Storage objects.   The legacy IAM roles are:  
1996    /// - roles/storage.legacyObjectReader — Read-only access to objects without listing. Equivalent to an ACL entry on an object with the READER role.  
1997    /// - roles/storage.legacyObjectOwner — Read/write access to existing objects without listing. Equivalent to an ACL entry on an object with the OWNER role.  
1998    /// - roles/storage.legacyBucketReader — Read access to buckets with object listing. Equivalent to an ACL entry on a bucket with the READER role.  
1999    /// - roles/storage.legacyBucketWriter — Read access to buckets with object listing/creation/deletion. Equivalent to an ACL entry on a bucket with the WRITER role.  
2000    /// - roles/storage.legacyBucketOwner — Read and write access to existing buckets with object listing/creation/deletion. Equivalent to an ACL entry on a bucket with the OWNER role.
2001    pub role: Option<String>,
2002}
2003
2004impl common::NestedType for PolicyBindings {}
2005impl common::Part for PolicyBindings {}
2006
2007// ###################
2008// MethodBuilders ###
2009// #################
2010
2011/// A builder providing access to all methods supported on *anywhereCach* resources.
2012/// It is not used directly, but through the [`Storage`] hub.
2013///
2014/// # Example
2015///
2016/// Instantiate a resource builder
2017///
2018/// ```test_harness,no_run
2019/// extern crate hyper;
2020/// extern crate hyper_rustls;
2021/// extern crate google_storage1 as storage1;
2022///
2023/// # async fn dox() {
2024/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2025///
2026/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2027/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2028///     secret,
2029///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2030/// ).build().await.unwrap();
2031///
2032/// let client = hyper_util::client::legacy::Client::builder(
2033///     hyper_util::rt::TokioExecutor::new()
2034/// )
2035/// .build(
2036///     hyper_rustls::HttpsConnectorBuilder::new()
2037///         .with_native_roots()
2038///         .unwrap()
2039///         .https_or_http()
2040///         .enable_http1()
2041///         .build()
2042/// );
2043/// let mut hub = Storage::new(client, auth);
2044/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2045/// // like `disable(...)`, `get(...)`, `insert(...)`, `list(...)`, `pause(...)`, `resume(...)` and `update(...)`
2046/// // to build up your call.
2047/// let rb = hub.anywhere_caches();
2048/// # }
2049/// ```
2050pub struct AnywhereCachMethods<'a, C>
2051where
2052    C: 'a,
2053{
2054    hub: &'a Storage<C>,
2055}
2056
2057impl<'a, C> common::MethodsBuilder for AnywhereCachMethods<'a, C> {}
2058
2059impl<'a, C> AnywhereCachMethods<'a, C> {
2060    /// Create a builder to help you perform the following task:
2061    ///
2062    /// Disables an Anywhere Cache instance.
2063    ///
2064    /// # Arguments
2065    ///
2066    /// * `bucket` - Name of the parent bucket.
2067    /// * `anywhereCacheId` - The ID of requested Anywhere Cache instance.
2068    pub fn disable(&self, bucket: &str, anywhere_cache_id: &str) -> AnywhereCachDisableCall<'a, C> {
2069        AnywhereCachDisableCall {
2070            hub: self.hub,
2071            _bucket: bucket.to_string(),
2072            _anywhere_cache_id: anywhere_cache_id.to_string(),
2073            _delegate: Default::default(),
2074            _additional_params: Default::default(),
2075            _scopes: Default::default(),
2076        }
2077    }
2078
2079    /// Create a builder to help you perform the following task:
2080    ///
2081    /// Returns the metadata of an Anywhere Cache instance.
2082    ///
2083    /// # Arguments
2084    ///
2085    /// * `bucket` - Name of the parent bucket.
2086    /// * `anywhereCacheId` - The ID of requested Anywhere Cache instance.
2087    pub fn get(&self, bucket: &str, anywhere_cache_id: &str) -> AnywhereCachGetCall<'a, C> {
2088        AnywhereCachGetCall {
2089            hub: self.hub,
2090            _bucket: bucket.to_string(),
2091            _anywhere_cache_id: anywhere_cache_id.to_string(),
2092            _delegate: Default::default(),
2093            _additional_params: Default::default(),
2094            _scopes: Default::default(),
2095        }
2096    }
2097
2098    /// Create a builder to help you perform the following task:
2099    ///
2100    /// Creates an Anywhere Cache instance.
2101    ///
2102    /// # Arguments
2103    ///
2104    /// * `request` - No description provided.
2105    /// * `bucket` - Name of the parent bucket.
2106    pub fn insert(&self, request: AnywhereCache, bucket: &str) -> AnywhereCachInsertCall<'a, C> {
2107        AnywhereCachInsertCall {
2108            hub: self.hub,
2109            _request: request,
2110            _bucket: bucket.to_string(),
2111            _delegate: Default::default(),
2112            _additional_params: Default::default(),
2113            _scopes: Default::default(),
2114        }
2115    }
2116
2117    /// Create a builder to help you perform the following task:
2118    ///
2119    /// Returns a list of Anywhere Cache instances of the bucket matching the criteria.
2120    ///
2121    /// # Arguments
2122    ///
2123    /// * `bucket` - Name of the parent bucket.
2124    pub fn list(&self, bucket: &str) -> AnywhereCachListCall<'a, C> {
2125        AnywhereCachListCall {
2126            hub: self.hub,
2127            _bucket: bucket.to_string(),
2128            _page_token: Default::default(),
2129            _page_size: Default::default(),
2130            _delegate: Default::default(),
2131            _additional_params: Default::default(),
2132            _scopes: Default::default(),
2133        }
2134    }
2135
2136    /// Create a builder to help you perform the following task:
2137    ///
2138    /// Pauses an Anywhere Cache instance.
2139    ///
2140    /// # Arguments
2141    ///
2142    /// * `bucket` - Name of the parent bucket.
2143    /// * `anywhereCacheId` - The ID of requested Anywhere Cache instance.
2144    pub fn pause(&self, bucket: &str, anywhere_cache_id: &str) -> AnywhereCachPauseCall<'a, C> {
2145        AnywhereCachPauseCall {
2146            hub: self.hub,
2147            _bucket: bucket.to_string(),
2148            _anywhere_cache_id: anywhere_cache_id.to_string(),
2149            _delegate: Default::default(),
2150            _additional_params: Default::default(),
2151            _scopes: Default::default(),
2152        }
2153    }
2154
2155    /// Create a builder to help you perform the following task:
2156    ///
2157    /// Resumes a paused or disabled Anywhere Cache instance.
2158    ///
2159    /// # Arguments
2160    ///
2161    /// * `bucket` - Name of the parent bucket.
2162    /// * `anywhereCacheId` - The ID of requested Anywhere Cache instance.
2163    pub fn resume(&self, bucket: &str, anywhere_cache_id: &str) -> AnywhereCachResumeCall<'a, C> {
2164        AnywhereCachResumeCall {
2165            hub: self.hub,
2166            _bucket: bucket.to_string(),
2167            _anywhere_cache_id: anywhere_cache_id.to_string(),
2168            _delegate: Default::default(),
2169            _additional_params: Default::default(),
2170            _scopes: Default::default(),
2171        }
2172    }
2173
2174    /// Create a builder to help you perform the following task:
2175    ///
2176    /// Updates the config(ttl and admissionPolicy) of an Anywhere Cache instance.
2177    ///
2178    /// # Arguments
2179    ///
2180    /// * `request` - No description provided.
2181    /// * `bucket` - Name of the parent bucket.
2182    /// * `anywhereCacheId` - The ID of requested Anywhere Cache instance.
2183    pub fn update(
2184        &self,
2185        request: AnywhereCache,
2186        bucket: &str,
2187        anywhere_cache_id: &str,
2188    ) -> AnywhereCachUpdateCall<'a, C> {
2189        AnywhereCachUpdateCall {
2190            hub: self.hub,
2191            _request: request,
2192            _bucket: bucket.to_string(),
2193            _anywhere_cache_id: anywhere_cache_id.to_string(),
2194            _delegate: Default::default(),
2195            _additional_params: Default::default(),
2196            _scopes: Default::default(),
2197        }
2198    }
2199}
2200
2201/// A builder providing access to all methods supported on *bucketAccessControl* resources.
2202/// It is not used directly, but through the [`Storage`] hub.
2203///
2204/// # Example
2205///
2206/// Instantiate a resource builder
2207///
2208/// ```test_harness,no_run
2209/// extern crate hyper;
2210/// extern crate hyper_rustls;
2211/// extern crate google_storage1 as storage1;
2212///
2213/// # async fn dox() {
2214/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2215///
2216/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2217/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2218///     secret,
2219///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2220/// ).build().await.unwrap();
2221///
2222/// let client = hyper_util::client::legacy::Client::builder(
2223///     hyper_util::rt::TokioExecutor::new()
2224/// )
2225/// .build(
2226///     hyper_rustls::HttpsConnectorBuilder::new()
2227///         .with_native_roots()
2228///         .unwrap()
2229///         .https_or_http()
2230///         .enable_http1()
2231///         .build()
2232/// );
2233/// let mut hub = Storage::new(client, auth);
2234/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2235/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
2236/// // to build up your call.
2237/// let rb = hub.bucket_access_controls();
2238/// # }
2239/// ```
2240pub struct BucketAccessControlMethods<'a, C>
2241where
2242    C: 'a,
2243{
2244    hub: &'a Storage<C>,
2245}
2246
2247impl<'a, C> common::MethodsBuilder for BucketAccessControlMethods<'a, C> {}
2248
2249impl<'a, C> BucketAccessControlMethods<'a, C> {
2250    /// Create a builder to help you perform the following task:
2251    ///
2252    /// Permanently deletes the ACL entry for the specified entity on the specified bucket.
2253    ///
2254    /// # Arguments
2255    ///
2256    /// * `bucket` - Name of a bucket.
2257    /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
2258    pub fn delete(&self, bucket: &str, entity: &str) -> BucketAccessControlDeleteCall<'a, C> {
2259        BucketAccessControlDeleteCall {
2260            hub: self.hub,
2261            _bucket: bucket.to_string(),
2262            _entity: entity.to_string(),
2263            _user_project: Default::default(),
2264            _delegate: Default::default(),
2265            _additional_params: Default::default(),
2266            _scopes: Default::default(),
2267        }
2268    }
2269
2270    /// Create a builder to help you perform the following task:
2271    ///
2272    /// Returns the ACL entry for the specified entity on the specified bucket.
2273    ///
2274    /// # Arguments
2275    ///
2276    /// * `bucket` - Name of a bucket.
2277    /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
2278    pub fn get(&self, bucket: &str, entity: &str) -> BucketAccessControlGetCall<'a, C> {
2279        BucketAccessControlGetCall {
2280            hub: self.hub,
2281            _bucket: bucket.to_string(),
2282            _entity: entity.to_string(),
2283            _user_project: Default::default(),
2284            _delegate: Default::default(),
2285            _additional_params: Default::default(),
2286            _scopes: Default::default(),
2287        }
2288    }
2289
2290    /// Create a builder to help you perform the following task:
2291    ///
2292    /// Creates a new ACL entry on the specified bucket.
2293    ///
2294    /// # Arguments
2295    ///
2296    /// * `request` - No description provided.
2297    /// * `bucket` - Name of a bucket.
2298    pub fn insert(
2299        &self,
2300        request: BucketAccessControl,
2301        bucket: &str,
2302    ) -> BucketAccessControlInsertCall<'a, C> {
2303        BucketAccessControlInsertCall {
2304            hub: self.hub,
2305            _request: request,
2306            _bucket: bucket.to_string(),
2307            _user_project: Default::default(),
2308            _delegate: Default::default(),
2309            _additional_params: Default::default(),
2310            _scopes: Default::default(),
2311        }
2312    }
2313
2314    /// Create a builder to help you perform the following task:
2315    ///
2316    /// Retrieves ACL entries on the specified bucket.
2317    ///
2318    /// # Arguments
2319    ///
2320    /// * `bucket` - Name of a bucket.
2321    pub fn list(&self, bucket: &str) -> BucketAccessControlListCall<'a, C> {
2322        BucketAccessControlListCall {
2323            hub: self.hub,
2324            _bucket: bucket.to_string(),
2325            _user_project: Default::default(),
2326            _delegate: Default::default(),
2327            _additional_params: Default::default(),
2328            _scopes: Default::default(),
2329        }
2330    }
2331
2332    /// Create a builder to help you perform the following task:
2333    ///
2334    /// Patches an ACL entry on the specified bucket.
2335    ///
2336    /// # Arguments
2337    ///
2338    /// * `request` - No description provided.
2339    /// * `bucket` - Name of a bucket.
2340    /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
2341    pub fn patch(
2342        &self,
2343        request: BucketAccessControl,
2344        bucket: &str,
2345        entity: &str,
2346    ) -> BucketAccessControlPatchCall<'a, C> {
2347        BucketAccessControlPatchCall {
2348            hub: self.hub,
2349            _request: request,
2350            _bucket: bucket.to_string(),
2351            _entity: entity.to_string(),
2352            _user_project: Default::default(),
2353            _delegate: Default::default(),
2354            _additional_params: Default::default(),
2355            _scopes: Default::default(),
2356        }
2357    }
2358
2359    /// Create a builder to help you perform the following task:
2360    ///
2361    /// Updates an ACL entry on the specified bucket.
2362    ///
2363    /// # Arguments
2364    ///
2365    /// * `request` - No description provided.
2366    /// * `bucket` - Name of a bucket.
2367    /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
2368    pub fn update(
2369        &self,
2370        request: BucketAccessControl,
2371        bucket: &str,
2372        entity: &str,
2373    ) -> BucketAccessControlUpdateCall<'a, C> {
2374        BucketAccessControlUpdateCall {
2375            hub: self.hub,
2376            _request: request,
2377            _bucket: bucket.to_string(),
2378            _entity: entity.to_string(),
2379            _user_project: Default::default(),
2380            _delegate: Default::default(),
2381            _additional_params: Default::default(),
2382            _scopes: Default::default(),
2383        }
2384    }
2385}
2386
2387/// A builder providing access to all methods supported on *bucket* resources.
2388/// It is not used directly, but through the [`Storage`] hub.
2389///
2390/// # Example
2391///
2392/// Instantiate a resource builder
2393///
2394/// ```test_harness,no_run
2395/// extern crate hyper;
2396/// extern crate hyper_rustls;
2397/// extern crate google_storage1 as storage1;
2398///
2399/// # async fn dox() {
2400/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2401///
2402/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2403/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2404///     secret,
2405///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2406/// ).build().await.unwrap();
2407///
2408/// let client = hyper_util::client::legacy::Client::builder(
2409///     hyper_util::rt::TokioExecutor::new()
2410/// )
2411/// .build(
2412///     hyper_rustls::HttpsConnectorBuilder::new()
2413///         .with_native_roots()
2414///         .unwrap()
2415///         .https_or_http()
2416///         .enable_http1()
2417///         .build()
2418/// );
2419/// let mut hub = Storage::new(client, auth);
2420/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2421/// // like `delete(...)`, `get(...)`, `get_iam_policy(...)`, `get_storage_layout(...)`, `insert(...)`, `list(...)`, `lock_retention_policy(...)`, `operations_cancel(...)`, `operations_get(...)`, `operations_list(...)`, `patch(...)`, `set_iam_policy(...)`, `test_iam_permissions(...)` and `update(...)`
2422/// // to build up your call.
2423/// let rb = hub.buckets();
2424/// # }
2425/// ```
2426pub struct BucketMethods<'a, C>
2427where
2428    C: 'a,
2429{
2430    hub: &'a Storage<C>,
2431}
2432
2433impl<'a, C> common::MethodsBuilder for BucketMethods<'a, C> {}
2434
2435impl<'a, C> BucketMethods<'a, C> {
2436    /// Create a builder to help you perform the following task:
2437    ///
2438    /// Permanently deletes an empty bucket.
2439    ///
2440    /// # Arguments
2441    ///
2442    /// * `bucket` - Name of a bucket.
2443    pub fn delete(&self, bucket: &str) -> BucketDeleteCall<'a, C> {
2444        BucketDeleteCall {
2445            hub: self.hub,
2446            _bucket: bucket.to_string(),
2447            _user_project: Default::default(),
2448            _if_metageneration_not_match: Default::default(),
2449            _if_metageneration_match: Default::default(),
2450            _delegate: Default::default(),
2451            _additional_params: Default::default(),
2452            _scopes: Default::default(),
2453        }
2454    }
2455
2456    /// Create a builder to help you perform the following task:
2457    ///
2458    /// Returns metadata for the specified bucket.
2459    ///
2460    /// # Arguments
2461    ///
2462    /// * `bucket` - Name of a bucket.
2463    pub fn get(&self, bucket: &str) -> BucketGetCall<'a, C> {
2464        BucketGetCall {
2465            hub: self.hub,
2466            _bucket: bucket.to_string(),
2467            _user_project: Default::default(),
2468            _projection: Default::default(),
2469            _if_metageneration_not_match: Default::default(),
2470            _if_metageneration_match: Default::default(),
2471            _delegate: Default::default(),
2472            _additional_params: Default::default(),
2473            _scopes: Default::default(),
2474        }
2475    }
2476
2477    /// Create a builder to help you perform the following task:
2478    ///
2479    /// Returns an IAM policy for the specified bucket.
2480    ///
2481    /// # Arguments
2482    ///
2483    /// * `bucket` - Name of a bucket.
2484    pub fn get_iam_policy(&self, bucket: &str) -> BucketGetIamPolicyCall<'a, C> {
2485        BucketGetIamPolicyCall {
2486            hub: self.hub,
2487            _bucket: bucket.to_string(),
2488            _user_project: Default::default(),
2489            _options_requested_policy_version: Default::default(),
2490            _delegate: Default::default(),
2491            _additional_params: Default::default(),
2492            _scopes: Default::default(),
2493        }
2494    }
2495
2496    /// Create a builder to help you perform the following task:
2497    ///
2498    /// Returns the storage layout configuration for the specified bucket. Note that this operation requires storage.objects.list permission.
2499    ///
2500    /// # Arguments
2501    ///
2502    /// * `bucket` - Name of a bucket.
2503    pub fn get_storage_layout(&self, bucket: &str) -> BucketGetStorageLayoutCall<'a, C> {
2504        BucketGetStorageLayoutCall {
2505            hub: self.hub,
2506            _bucket: bucket.to_string(),
2507            _prefix: Default::default(),
2508            _delegate: Default::default(),
2509            _additional_params: Default::default(),
2510            _scopes: Default::default(),
2511        }
2512    }
2513
2514    /// Create a builder to help you perform the following task:
2515    ///
2516    /// Creates a new bucket.
2517    ///
2518    /// # Arguments
2519    ///
2520    /// * `request` - No description provided.
2521    /// * `project` - A valid API project identifier.
2522    pub fn insert(&self, request: Bucket, project: &str) -> BucketInsertCall<'a, C> {
2523        BucketInsertCall {
2524            hub: self.hub,
2525            _request: request,
2526            _project: project.to_string(),
2527            _user_project: Default::default(),
2528            _projection: Default::default(),
2529            _predefined_default_object_acl: Default::default(),
2530            _predefined_acl: Default::default(),
2531            _enable_object_retention: Default::default(),
2532            _delegate: Default::default(),
2533            _additional_params: Default::default(),
2534            _scopes: Default::default(),
2535        }
2536    }
2537
2538    /// Create a builder to help you perform the following task:
2539    ///
2540    /// Retrieves a list of buckets for a given project.
2541    ///
2542    /// # Arguments
2543    ///
2544    /// * `project` - A valid API project identifier.
2545    pub fn list(&self, project: &str) -> BucketListCall<'a, C> {
2546        BucketListCall {
2547            hub: self.hub,
2548            _project: project.to_string(),
2549            _user_project: Default::default(),
2550            _projection: Default::default(),
2551            _prefix: Default::default(),
2552            _page_token: Default::default(),
2553            _max_results: Default::default(),
2554            _delegate: Default::default(),
2555            _additional_params: Default::default(),
2556            _scopes: Default::default(),
2557        }
2558    }
2559
2560    /// Create a builder to help you perform the following task:
2561    ///
2562    /// Locks retention policy on a bucket.
2563    ///
2564    /// # Arguments
2565    ///
2566    /// * `bucket` - Name of a bucket.
2567    /// * `ifMetagenerationMatch` - Makes the operation conditional on whether bucket's current metageneration matches the given value.
2568    pub fn lock_retention_policy(
2569        &self,
2570        bucket: &str,
2571        if_metageneration_match: i64,
2572    ) -> BucketLockRetentionPolicyCall<'a, C> {
2573        BucketLockRetentionPolicyCall {
2574            hub: self.hub,
2575            _bucket: bucket.to_string(),
2576            _if_metageneration_match: if_metageneration_match,
2577            _user_project: Default::default(),
2578            _delegate: Default::default(),
2579            _additional_params: Default::default(),
2580            _scopes: Default::default(),
2581        }
2582    }
2583
2584    /// Create a builder to help you perform the following task:
2585    ///
2586    /// Patches a bucket. Changes to the bucket will be readable immediately after writing, but configuration changes may take time to propagate.
2587    ///
2588    /// # Arguments
2589    ///
2590    /// * `request` - No description provided.
2591    /// * `bucket` - Name of a bucket.
2592    pub fn patch(&self, request: Bucket, bucket: &str) -> BucketPatchCall<'a, C> {
2593        BucketPatchCall {
2594            hub: self.hub,
2595            _request: request,
2596            _bucket: bucket.to_string(),
2597            _user_project: Default::default(),
2598            _projection: Default::default(),
2599            _predefined_default_object_acl: Default::default(),
2600            _predefined_acl: Default::default(),
2601            _if_metageneration_not_match: Default::default(),
2602            _if_metageneration_match: Default::default(),
2603            _delegate: Default::default(),
2604            _additional_params: Default::default(),
2605            _scopes: Default::default(),
2606        }
2607    }
2608
2609    /// Create a builder to help you perform the following task:
2610    ///
2611    /// Updates an IAM policy for the specified bucket.
2612    ///
2613    /// # Arguments
2614    ///
2615    /// * `request` - No description provided.
2616    /// * `bucket` - Name of a bucket.
2617    pub fn set_iam_policy(&self, request: Policy, bucket: &str) -> BucketSetIamPolicyCall<'a, C> {
2618        BucketSetIamPolicyCall {
2619            hub: self.hub,
2620            _request: request,
2621            _bucket: bucket.to_string(),
2622            _user_project: Default::default(),
2623            _delegate: Default::default(),
2624            _additional_params: Default::default(),
2625            _scopes: Default::default(),
2626        }
2627    }
2628
2629    /// Create a builder to help you perform the following task:
2630    ///
2631    /// Tests a set of permissions on the given bucket to see which, if any, are held by the caller.
2632    ///
2633    /// # Arguments
2634    ///
2635    /// * `bucket` - Name of a bucket.
2636    /// * `permissions` - Permissions to test.
2637    pub fn test_iam_permissions(
2638        &self,
2639        bucket: &str,
2640        permissions: &Vec<String>,
2641    ) -> BucketTestIamPermissionCall<'a, C> {
2642        BucketTestIamPermissionCall {
2643            hub: self.hub,
2644            _bucket: bucket.to_string(),
2645            _permissions: permissions.clone(),
2646            _user_project: Default::default(),
2647            _delegate: Default::default(),
2648            _additional_params: Default::default(),
2649            _scopes: Default::default(),
2650        }
2651    }
2652
2653    /// Create a builder to help you perform the following task:
2654    ///
2655    /// Updates a bucket. Changes to the bucket will be readable immediately after writing, but configuration changes may take time to propagate.
2656    ///
2657    /// # Arguments
2658    ///
2659    /// * `request` - No description provided.
2660    /// * `bucket` - Name of a bucket.
2661    pub fn update(&self, request: Bucket, bucket: &str) -> BucketUpdateCall<'a, C> {
2662        BucketUpdateCall {
2663            hub: self.hub,
2664            _request: request,
2665            _bucket: bucket.to_string(),
2666            _user_project: Default::default(),
2667            _projection: Default::default(),
2668            _predefined_default_object_acl: Default::default(),
2669            _predefined_acl: Default::default(),
2670            _if_metageneration_not_match: Default::default(),
2671            _if_metageneration_match: Default::default(),
2672            _delegate: Default::default(),
2673            _additional_params: Default::default(),
2674            _scopes: Default::default(),
2675        }
2676    }
2677
2678    /// Create a builder to help you perform the following task:
2679    ///
2680    /// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed.
2681    ///
2682    /// # Arguments
2683    ///
2684    /// * `bucket` - The parent bucket of the operation resource.
2685    /// * `operationId` - The ID of the operation resource.
2686    pub fn operations_cancel(
2687        &self,
2688        bucket: &str,
2689        operation_id: &str,
2690    ) -> BucketOperationCancelCall<'a, C> {
2691        BucketOperationCancelCall {
2692            hub: self.hub,
2693            _bucket: bucket.to_string(),
2694            _operation_id: operation_id.to_string(),
2695            _delegate: Default::default(),
2696            _additional_params: Default::default(),
2697            _scopes: Default::default(),
2698        }
2699    }
2700
2701    /// Create a builder to help you perform the following task:
2702    ///
2703    /// Gets the latest state of a long-running operation.
2704    ///
2705    /// # Arguments
2706    ///
2707    /// * `bucket` - The parent bucket of the operation resource.
2708    /// * `operationId` - The ID of the operation resource.
2709    pub fn operations_get(
2710        &self,
2711        bucket: &str,
2712        operation_id: &str,
2713    ) -> BucketOperationGetCall<'a, C> {
2714        BucketOperationGetCall {
2715            hub: self.hub,
2716            _bucket: bucket.to_string(),
2717            _operation_id: operation_id.to_string(),
2718            _delegate: Default::default(),
2719            _additional_params: Default::default(),
2720            _scopes: Default::default(),
2721        }
2722    }
2723
2724    /// Create a builder to help you perform the following task:
2725    ///
2726    /// Lists operations that match the specified filter in the request.
2727    ///
2728    /// # Arguments
2729    ///
2730    /// * `bucket` - Name of the bucket in which to look for operations.
2731    pub fn operations_list(&self, bucket: &str) -> BucketOperationListCall<'a, C> {
2732        BucketOperationListCall {
2733            hub: self.hub,
2734            _bucket: bucket.to_string(),
2735            _page_token: Default::default(),
2736            _page_size: Default::default(),
2737            _filter: Default::default(),
2738            _delegate: Default::default(),
2739            _additional_params: Default::default(),
2740            _scopes: Default::default(),
2741        }
2742    }
2743}
2744
2745/// A builder providing access to all methods supported on *channel* resources.
2746/// It is not used directly, but through the [`Storage`] hub.
2747///
2748/// # Example
2749///
2750/// Instantiate a resource builder
2751///
2752/// ```test_harness,no_run
2753/// extern crate hyper;
2754/// extern crate hyper_rustls;
2755/// extern crate google_storage1 as storage1;
2756///
2757/// # async fn dox() {
2758/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2759///
2760/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2761/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2762///     secret,
2763///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2764/// ).build().await.unwrap();
2765///
2766/// let client = hyper_util::client::legacy::Client::builder(
2767///     hyper_util::rt::TokioExecutor::new()
2768/// )
2769/// .build(
2770///     hyper_rustls::HttpsConnectorBuilder::new()
2771///         .with_native_roots()
2772///         .unwrap()
2773///         .https_or_http()
2774///         .enable_http1()
2775///         .build()
2776/// );
2777/// let mut hub = Storage::new(client, auth);
2778/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2779/// // like `stop(...)`
2780/// // to build up your call.
2781/// let rb = hub.channels();
2782/// # }
2783/// ```
2784pub struct ChannelMethods<'a, C>
2785where
2786    C: 'a,
2787{
2788    hub: &'a Storage<C>,
2789}
2790
2791impl<'a, C> common::MethodsBuilder for ChannelMethods<'a, C> {}
2792
2793impl<'a, C> ChannelMethods<'a, C> {
2794    /// Create a builder to help you perform the following task:
2795    ///
2796    /// Stop watching resources through this channel
2797    ///
2798    /// # Arguments
2799    ///
2800    /// * `request` - No description provided.
2801    pub fn stop(&self, request: Channel) -> ChannelStopCall<'a, C> {
2802        ChannelStopCall {
2803            hub: self.hub,
2804            _request: request,
2805            _delegate: Default::default(),
2806            _additional_params: Default::default(),
2807            _scopes: Default::default(),
2808        }
2809    }
2810}
2811
2812/// A builder providing access to all methods supported on *defaultObjectAccessControl* resources.
2813/// It is not used directly, but through the [`Storage`] hub.
2814///
2815/// # Example
2816///
2817/// Instantiate a resource builder
2818///
2819/// ```test_harness,no_run
2820/// extern crate hyper;
2821/// extern crate hyper_rustls;
2822/// extern crate google_storage1 as storage1;
2823///
2824/// # async fn dox() {
2825/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2826///
2827/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2828/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2829///     secret,
2830///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2831/// ).build().await.unwrap();
2832///
2833/// let client = hyper_util::client::legacy::Client::builder(
2834///     hyper_util::rt::TokioExecutor::new()
2835/// )
2836/// .build(
2837///     hyper_rustls::HttpsConnectorBuilder::new()
2838///         .with_native_roots()
2839///         .unwrap()
2840///         .https_or_http()
2841///         .enable_http1()
2842///         .build()
2843/// );
2844/// let mut hub = Storage::new(client, auth);
2845/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2846/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
2847/// // to build up your call.
2848/// let rb = hub.default_object_access_controls();
2849/// # }
2850/// ```
2851pub struct DefaultObjectAccessControlMethods<'a, C>
2852where
2853    C: 'a,
2854{
2855    hub: &'a Storage<C>,
2856}
2857
2858impl<'a, C> common::MethodsBuilder for DefaultObjectAccessControlMethods<'a, C> {}
2859
2860impl<'a, C> DefaultObjectAccessControlMethods<'a, C> {
2861    /// Create a builder to help you perform the following task:
2862    ///
2863    /// Permanently deletes the default object ACL entry for the specified entity on the specified bucket.
2864    ///
2865    /// # Arguments
2866    ///
2867    /// * `bucket` - Name of a bucket.
2868    /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
2869    pub fn delete(
2870        &self,
2871        bucket: &str,
2872        entity: &str,
2873    ) -> DefaultObjectAccessControlDeleteCall<'a, C> {
2874        DefaultObjectAccessControlDeleteCall {
2875            hub: self.hub,
2876            _bucket: bucket.to_string(),
2877            _entity: entity.to_string(),
2878            _user_project: Default::default(),
2879            _delegate: Default::default(),
2880            _additional_params: Default::default(),
2881            _scopes: Default::default(),
2882        }
2883    }
2884
2885    /// Create a builder to help you perform the following task:
2886    ///
2887    /// Returns the default object ACL entry for the specified entity on the specified bucket.
2888    ///
2889    /// # Arguments
2890    ///
2891    /// * `bucket` - Name of a bucket.
2892    /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
2893    pub fn get(&self, bucket: &str, entity: &str) -> DefaultObjectAccessControlGetCall<'a, C> {
2894        DefaultObjectAccessControlGetCall {
2895            hub: self.hub,
2896            _bucket: bucket.to_string(),
2897            _entity: entity.to_string(),
2898            _user_project: Default::default(),
2899            _delegate: Default::default(),
2900            _additional_params: Default::default(),
2901            _scopes: Default::default(),
2902        }
2903    }
2904
2905    /// Create a builder to help you perform the following task:
2906    ///
2907    /// Creates a new default object ACL entry on the specified bucket.
2908    ///
2909    /// # Arguments
2910    ///
2911    /// * `request` - No description provided.
2912    /// * `bucket` - Name of a bucket.
2913    pub fn insert(
2914        &self,
2915        request: ObjectAccessControl,
2916        bucket: &str,
2917    ) -> DefaultObjectAccessControlInsertCall<'a, C> {
2918        DefaultObjectAccessControlInsertCall {
2919            hub: self.hub,
2920            _request: request,
2921            _bucket: bucket.to_string(),
2922            _user_project: Default::default(),
2923            _delegate: Default::default(),
2924            _additional_params: Default::default(),
2925            _scopes: Default::default(),
2926        }
2927    }
2928
2929    /// Create a builder to help you perform the following task:
2930    ///
2931    /// Retrieves default object ACL entries on the specified bucket.
2932    ///
2933    /// # Arguments
2934    ///
2935    /// * `bucket` - Name of a bucket.
2936    pub fn list(&self, bucket: &str) -> DefaultObjectAccessControlListCall<'a, C> {
2937        DefaultObjectAccessControlListCall {
2938            hub: self.hub,
2939            _bucket: bucket.to_string(),
2940            _user_project: Default::default(),
2941            _if_metageneration_not_match: Default::default(),
2942            _if_metageneration_match: Default::default(),
2943            _delegate: Default::default(),
2944            _additional_params: Default::default(),
2945            _scopes: Default::default(),
2946        }
2947    }
2948
2949    /// Create a builder to help you perform the following task:
2950    ///
2951    /// Patches a default object ACL entry on the specified bucket.
2952    ///
2953    /// # Arguments
2954    ///
2955    /// * `request` - No description provided.
2956    /// * `bucket` - Name of a bucket.
2957    /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
2958    pub fn patch(
2959        &self,
2960        request: ObjectAccessControl,
2961        bucket: &str,
2962        entity: &str,
2963    ) -> DefaultObjectAccessControlPatchCall<'a, C> {
2964        DefaultObjectAccessControlPatchCall {
2965            hub: self.hub,
2966            _request: request,
2967            _bucket: bucket.to_string(),
2968            _entity: entity.to_string(),
2969            _user_project: Default::default(),
2970            _delegate: Default::default(),
2971            _additional_params: Default::default(),
2972            _scopes: Default::default(),
2973        }
2974    }
2975
2976    /// Create a builder to help you perform the following task:
2977    ///
2978    /// Updates a default object ACL entry on the specified bucket.
2979    ///
2980    /// # Arguments
2981    ///
2982    /// * `request` - No description provided.
2983    /// * `bucket` - Name of a bucket.
2984    /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
2985    pub fn update(
2986        &self,
2987        request: ObjectAccessControl,
2988        bucket: &str,
2989        entity: &str,
2990    ) -> DefaultObjectAccessControlUpdateCall<'a, C> {
2991        DefaultObjectAccessControlUpdateCall {
2992            hub: self.hub,
2993            _request: request,
2994            _bucket: bucket.to_string(),
2995            _entity: entity.to_string(),
2996            _user_project: Default::default(),
2997            _delegate: Default::default(),
2998            _additional_params: Default::default(),
2999            _scopes: Default::default(),
3000        }
3001    }
3002}
3003
3004/// A builder providing access to all methods supported on *folder* resources.
3005/// It is not used directly, but through the [`Storage`] hub.
3006///
3007/// # Example
3008///
3009/// Instantiate a resource builder
3010///
3011/// ```test_harness,no_run
3012/// extern crate hyper;
3013/// extern crate hyper_rustls;
3014/// extern crate google_storage1 as storage1;
3015///
3016/// # async fn dox() {
3017/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3018///
3019/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3020/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3021///     secret,
3022///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3023/// ).build().await.unwrap();
3024///
3025/// let client = hyper_util::client::legacy::Client::builder(
3026///     hyper_util::rt::TokioExecutor::new()
3027/// )
3028/// .build(
3029///     hyper_rustls::HttpsConnectorBuilder::new()
3030///         .with_native_roots()
3031///         .unwrap()
3032///         .https_or_http()
3033///         .enable_http1()
3034///         .build()
3035/// );
3036/// let mut hub = Storage::new(client, auth);
3037/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3038/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)` and `rename(...)`
3039/// // to build up your call.
3040/// let rb = hub.folders();
3041/// # }
3042/// ```
3043pub struct FolderMethods<'a, C>
3044where
3045    C: 'a,
3046{
3047    hub: &'a Storage<C>,
3048}
3049
3050impl<'a, C> common::MethodsBuilder for FolderMethods<'a, C> {}
3051
3052impl<'a, C> FolderMethods<'a, C> {
3053    /// Create a builder to help you perform the following task:
3054    ///
3055    /// Permanently deletes a folder. Only applicable to buckets with hierarchical namespace enabled.
3056    ///
3057    /// # Arguments
3058    ///
3059    /// * `bucket` - Name of the bucket in which the folder resides.
3060    /// * `folder` - Name of a folder.
3061    pub fn delete(&self, bucket: &str, folder: &str) -> FolderDeleteCall<'a, C> {
3062        FolderDeleteCall {
3063            hub: self.hub,
3064            _bucket: bucket.to_string(),
3065            _folder: folder.to_string(),
3066            _if_metageneration_not_match: Default::default(),
3067            _if_metageneration_match: Default::default(),
3068            _delegate: Default::default(),
3069            _additional_params: Default::default(),
3070            _scopes: Default::default(),
3071        }
3072    }
3073
3074    /// Create a builder to help you perform the following task:
3075    ///
3076    /// Returns metadata for the specified folder. Only applicable to buckets with hierarchical namespace enabled.
3077    ///
3078    /// # Arguments
3079    ///
3080    /// * `bucket` - Name of the bucket in which the folder resides.
3081    /// * `folder` - Name of a folder.
3082    pub fn get(&self, bucket: &str, folder: &str) -> FolderGetCall<'a, C> {
3083        FolderGetCall {
3084            hub: self.hub,
3085            _bucket: bucket.to_string(),
3086            _folder: folder.to_string(),
3087            _if_metageneration_not_match: Default::default(),
3088            _if_metageneration_match: Default::default(),
3089            _delegate: Default::default(),
3090            _additional_params: Default::default(),
3091            _scopes: Default::default(),
3092        }
3093    }
3094
3095    /// Create a builder to help you perform the following task:
3096    ///
3097    /// Creates a new folder. Only applicable to buckets with hierarchical namespace enabled.
3098    ///
3099    /// # Arguments
3100    ///
3101    /// * `request` - No description provided.
3102    /// * `bucket` - Name of the bucket in which the folder resides.
3103    pub fn insert(&self, request: Folder, bucket: &str) -> FolderInsertCall<'a, C> {
3104        FolderInsertCall {
3105            hub: self.hub,
3106            _request: request,
3107            _bucket: bucket.to_string(),
3108            _recursive: Default::default(),
3109            _delegate: Default::default(),
3110            _additional_params: Default::default(),
3111            _scopes: Default::default(),
3112        }
3113    }
3114
3115    /// Create a builder to help you perform the following task:
3116    ///
3117    /// Retrieves a list of folders matching the criteria. Only applicable to buckets with hierarchical namespace enabled.
3118    ///
3119    /// # Arguments
3120    ///
3121    /// * `bucket` - Name of the bucket in which to look for folders.
3122    pub fn list(&self, bucket: &str) -> FolderListCall<'a, C> {
3123        FolderListCall {
3124            hub: self.hub,
3125            _bucket: bucket.to_string(),
3126            _start_offset: Default::default(),
3127            _prefix: Default::default(),
3128            _page_token: Default::default(),
3129            _page_size: Default::default(),
3130            _end_offset: Default::default(),
3131            _delimiter: Default::default(),
3132            _delegate: Default::default(),
3133            _additional_params: Default::default(),
3134            _scopes: Default::default(),
3135        }
3136    }
3137
3138    /// Create a builder to help you perform the following task:
3139    ///
3140    /// Renames a source folder to a destination folder. Only applicable to buckets with hierarchical namespace enabled.
3141    ///
3142    /// # Arguments
3143    ///
3144    /// * `bucket` - Name of the bucket in which the folders are in.
3145    /// * `sourceFolder` - Name of the source folder.
3146    /// * `destinationFolder` - Name of the destination folder.
3147    pub fn rename(
3148        &self,
3149        bucket: &str,
3150        source_folder: &str,
3151        destination_folder: &str,
3152    ) -> FolderRenameCall<'a, C> {
3153        FolderRenameCall {
3154            hub: self.hub,
3155            _bucket: bucket.to_string(),
3156            _source_folder: source_folder.to_string(),
3157            _destination_folder: destination_folder.to_string(),
3158            _if_source_metageneration_not_match: Default::default(),
3159            _if_source_metageneration_match: Default::default(),
3160            _delegate: Default::default(),
3161            _additional_params: Default::default(),
3162            _scopes: Default::default(),
3163        }
3164    }
3165}
3166
3167/// A builder providing access to all methods supported on *managedFolder* resources.
3168/// It is not used directly, but through the [`Storage`] hub.
3169///
3170/// # Example
3171///
3172/// Instantiate a resource builder
3173///
3174/// ```test_harness,no_run
3175/// extern crate hyper;
3176/// extern crate hyper_rustls;
3177/// extern crate google_storage1 as storage1;
3178///
3179/// # async fn dox() {
3180/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3181///
3182/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3183/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3184///     secret,
3185///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3186/// ).build().await.unwrap();
3187///
3188/// let client = hyper_util::client::legacy::Client::builder(
3189///     hyper_util::rt::TokioExecutor::new()
3190/// )
3191/// .build(
3192///     hyper_rustls::HttpsConnectorBuilder::new()
3193///         .with_native_roots()
3194///         .unwrap()
3195///         .https_or_http()
3196///         .enable_http1()
3197///         .build()
3198/// );
3199/// let mut hub = Storage::new(client, auth);
3200/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3201/// // like `delete(...)`, `get(...)`, `get_iam_policy(...)`, `insert(...)`, `list(...)`, `set_iam_policy(...)` and `test_iam_permissions(...)`
3202/// // to build up your call.
3203/// let rb = hub.managed_folders();
3204/// # }
3205/// ```
3206pub struct ManagedFolderMethods<'a, C>
3207where
3208    C: 'a,
3209{
3210    hub: &'a Storage<C>,
3211}
3212
3213impl<'a, C> common::MethodsBuilder for ManagedFolderMethods<'a, C> {}
3214
3215impl<'a, C> ManagedFolderMethods<'a, C> {
3216    /// Create a builder to help you perform the following task:
3217    ///
3218    /// Permanently deletes a managed folder.
3219    ///
3220    /// # Arguments
3221    ///
3222    /// * `bucket` - Name of the bucket containing the managed folder.
3223    /// * `managedFolder` - The managed folder name/path.
3224    pub fn delete(&self, bucket: &str, managed_folder: &str) -> ManagedFolderDeleteCall<'a, C> {
3225        ManagedFolderDeleteCall {
3226            hub: self.hub,
3227            _bucket: bucket.to_string(),
3228            _managed_folder: managed_folder.to_string(),
3229            _if_metageneration_not_match: Default::default(),
3230            _if_metageneration_match: Default::default(),
3231            _allow_non_empty: Default::default(),
3232            _delegate: Default::default(),
3233            _additional_params: Default::default(),
3234            _scopes: Default::default(),
3235        }
3236    }
3237
3238    /// Create a builder to help you perform the following task:
3239    ///
3240    /// Returns metadata of the specified managed folder.
3241    ///
3242    /// # Arguments
3243    ///
3244    /// * `bucket` - Name of the bucket containing the managed folder.
3245    /// * `managedFolder` - The managed folder name/path.
3246    pub fn get(&self, bucket: &str, managed_folder: &str) -> ManagedFolderGetCall<'a, C> {
3247        ManagedFolderGetCall {
3248            hub: self.hub,
3249            _bucket: bucket.to_string(),
3250            _managed_folder: managed_folder.to_string(),
3251            _if_metageneration_not_match: Default::default(),
3252            _if_metageneration_match: Default::default(),
3253            _delegate: Default::default(),
3254            _additional_params: Default::default(),
3255            _scopes: Default::default(),
3256        }
3257    }
3258
3259    /// Create a builder to help you perform the following task:
3260    ///
3261    /// Returns an IAM policy for the specified managed folder.
3262    ///
3263    /// # Arguments
3264    ///
3265    /// * `bucket` - Name of the bucket containing the managed folder.
3266    /// * `managedFolder` - The managed folder name/path.
3267    pub fn get_iam_policy(
3268        &self,
3269        bucket: &str,
3270        managed_folder: &str,
3271    ) -> ManagedFolderGetIamPolicyCall<'a, C> {
3272        ManagedFolderGetIamPolicyCall {
3273            hub: self.hub,
3274            _bucket: bucket.to_string(),
3275            _managed_folder: managed_folder.to_string(),
3276            _user_project: Default::default(),
3277            _options_requested_policy_version: Default::default(),
3278            _delegate: Default::default(),
3279            _additional_params: Default::default(),
3280            _scopes: Default::default(),
3281        }
3282    }
3283
3284    /// Create a builder to help you perform the following task:
3285    ///
3286    /// Creates a new managed folder.
3287    ///
3288    /// # Arguments
3289    ///
3290    /// * `request` - No description provided.
3291    /// * `bucket` - Name of the bucket containing the managed folder.
3292    pub fn insert(&self, request: ManagedFolder, bucket: &str) -> ManagedFolderInsertCall<'a, C> {
3293        ManagedFolderInsertCall {
3294            hub: self.hub,
3295            _request: request,
3296            _bucket: bucket.to_string(),
3297            _delegate: Default::default(),
3298            _additional_params: Default::default(),
3299            _scopes: Default::default(),
3300        }
3301    }
3302
3303    /// Create a builder to help you perform the following task:
3304    ///
3305    /// Lists managed folders in the given bucket.
3306    ///
3307    /// # Arguments
3308    ///
3309    /// * `bucket` - Name of the bucket containing the managed folder.
3310    pub fn list(&self, bucket: &str) -> ManagedFolderListCall<'a, C> {
3311        ManagedFolderListCall {
3312            hub: self.hub,
3313            _bucket: bucket.to_string(),
3314            _prefix: Default::default(),
3315            _page_token: Default::default(),
3316            _page_size: Default::default(),
3317            _delegate: Default::default(),
3318            _additional_params: Default::default(),
3319            _scopes: Default::default(),
3320        }
3321    }
3322
3323    /// Create a builder to help you perform the following task:
3324    ///
3325    /// Updates an IAM policy for the specified managed folder.
3326    ///
3327    /// # Arguments
3328    ///
3329    /// * `request` - No description provided.
3330    /// * `bucket` - Name of the bucket containing the managed folder.
3331    /// * `managedFolder` - The managed folder name/path.
3332    pub fn set_iam_policy(
3333        &self,
3334        request: Policy,
3335        bucket: &str,
3336        managed_folder: &str,
3337    ) -> ManagedFolderSetIamPolicyCall<'a, C> {
3338        ManagedFolderSetIamPolicyCall {
3339            hub: self.hub,
3340            _request: request,
3341            _bucket: bucket.to_string(),
3342            _managed_folder: managed_folder.to_string(),
3343            _user_project: Default::default(),
3344            _delegate: Default::default(),
3345            _additional_params: Default::default(),
3346            _scopes: Default::default(),
3347        }
3348    }
3349
3350    /// Create a builder to help you perform the following task:
3351    ///
3352    /// Tests a set of permissions on the given managed folder to see which, if any, are held by the caller.
3353    ///
3354    /// # Arguments
3355    ///
3356    /// * `bucket` - Name of the bucket containing the managed folder.
3357    /// * `managedFolder` - The managed folder name/path.
3358    /// * `permissions` - Permissions to test.
3359    pub fn test_iam_permissions(
3360        &self,
3361        bucket: &str,
3362        managed_folder: &str,
3363        permissions: &Vec<String>,
3364    ) -> ManagedFolderTestIamPermissionCall<'a, C> {
3365        ManagedFolderTestIamPermissionCall {
3366            hub: self.hub,
3367            _bucket: bucket.to_string(),
3368            _managed_folder: managed_folder.to_string(),
3369            _permissions: permissions.clone(),
3370            _user_project: Default::default(),
3371            _delegate: Default::default(),
3372            _additional_params: Default::default(),
3373            _scopes: Default::default(),
3374        }
3375    }
3376}
3377
3378/// A builder providing access to all methods supported on *notification* resources.
3379/// It is not used directly, but through the [`Storage`] hub.
3380///
3381/// # Example
3382///
3383/// Instantiate a resource builder
3384///
3385/// ```test_harness,no_run
3386/// extern crate hyper;
3387/// extern crate hyper_rustls;
3388/// extern crate google_storage1 as storage1;
3389///
3390/// # async fn dox() {
3391/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3392///
3393/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3394/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3395///     secret,
3396///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3397/// ).build().await.unwrap();
3398///
3399/// let client = hyper_util::client::legacy::Client::builder(
3400///     hyper_util::rt::TokioExecutor::new()
3401/// )
3402/// .build(
3403///     hyper_rustls::HttpsConnectorBuilder::new()
3404///         .with_native_roots()
3405///         .unwrap()
3406///         .https_or_http()
3407///         .enable_http1()
3408///         .build()
3409/// );
3410/// let mut hub = Storage::new(client, auth);
3411/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3412/// // like `delete(...)`, `get(...)`, `insert(...)` and `list(...)`
3413/// // to build up your call.
3414/// let rb = hub.notifications();
3415/// # }
3416/// ```
3417pub struct NotificationMethods<'a, C>
3418where
3419    C: 'a,
3420{
3421    hub: &'a Storage<C>,
3422}
3423
3424impl<'a, C> common::MethodsBuilder for NotificationMethods<'a, C> {}
3425
3426impl<'a, C> NotificationMethods<'a, C> {
3427    /// Create a builder to help you perform the following task:
3428    ///
3429    /// Permanently deletes a notification subscription.
3430    ///
3431    /// # Arguments
3432    ///
3433    /// * `bucket` - The parent bucket of the notification.
3434    /// * `notification` - ID of the notification to delete.
3435    pub fn delete(&self, bucket: &str, notification: &str) -> NotificationDeleteCall<'a, C> {
3436        NotificationDeleteCall {
3437            hub: self.hub,
3438            _bucket: bucket.to_string(),
3439            _notification: notification.to_string(),
3440            _user_project: Default::default(),
3441            _delegate: Default::default(),
3442            _additional_params: Default::default(),
3443            _scopes: Default::default(),
3444        }
3445    }
3446
3447    /// Create a builder to help you perform the following task:
3448    ///
3449    /// View a notification configuration.
3450    ///
3451    /// # Arguments
3452    ///
3453    /// * `bucket` - The parent bucket of the notification.
3454    /// * `notification` - Notification ID
3455    pub fn get(&self, bucket: &str, notification: &str) -> NotificationGetCall<'a, C> {
3456        NotificationGetCall {
3457            hub: self.hub,
3458            _bucket: bucket.to_string(),
3459            _notification: notification.to_string(),
3460            _user_project: Default::default(),
3461            _delegate: Default::default(),
3462            _additional_params: Default::default(),
3463            _scopes: Default::default(),
3464        }
3465    }
3466
3467    /// Create a builder to help you perform the following task:
3468    ///
3469    /// Creates a notification subscription for a given bucket.
3470    ///
3471    /// # Arguments
3472    ///
3473    /// * `request` - No description provided.
3474    /// * `bucket` - The parent bucket of the notification.
3475    pub fn insert(&self, request: Notification, bucket: &str) -> NotificationInsertCall<'a, C> {
3476        NotificationInsertCall {
3477            hub: self.hub,
3478            _request: request,
3479            _bucket: bucket.to_string(),
3480            _user_project: Default::default(),
3481            _delegate: Default::default(),
3482            _additional_params: Default::default(),
3483            _scopes: Default::default(),
3484        }
3485    }
3486
3487    /// Create a builder to help you perform the following task:
3488    ///
3489    /// Retrieves a list of notification subscriptions for a given bucket.
3490    ///
3491    /// # Arguments
3492    ///
3493    /// * `bucket` - Name of a Google Cloud Storage bucket.
3494    pub fn list(&self, bucket: &str) -> NotificationListCall<'a, C> {
3495        NotificationListCall {
3496            hub: self.hub,
3497            _bucket: bucket.to_string(),
3498            _user_project: Default::default(),
3499            _delegate: Default::default(),
3500            _additional_params: Default::default(),
3501            _scopes: Default::default(),
3502        }
3503    }
3504}
3505
3506/// A builder providing access to all methods supported on *objectAccessControl* resources.
3507/// It is not used directly, but through the [`Storage`] hub.
3508///
3509/// # Example
3510///
3511/// Instantiate a resource builder
3512///
3513/// ```test_harness,no_run
3514/// extern crate hyper;
3515/// extern crate hyper_rustls;
3516/// extern crate google_storage1 as storage1;
3517///
3518/// # async fn dox() {
3519/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3520///
3521/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3522/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3523///     secret,
3524///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3525/// ).build().await.unwrap();
3526///
3527/// let client = hyper_util::client::legacy::Client::builder(
3528///     hyper_util::rt::TokioExecutor::new()
3529/// )
3530/// .build(
3531///     hyper_rustls::HttpsConnectorBuilder::new()
3532///         .with_native_roots()
3533///         .unwrap()
3534///         .https_or_http()
3535///         .enable_http1()
3536///         .build()
3537/// );
3538/// let mut hub = Storage::new(client, auth);
3539/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3540/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
3541/// // to build up your call.
3542/// let rb = hub.object_access_controls();
3543/// # }
3544/// ```
3545pub struct ObjectAccessControlMethods<'a, C>
3546where
3547    C: 'a,
3548{
3549    hub: &'a Storage<C>,
3550}
3551
3552impl<'a, C> common::MethodsBuilder for ObjectAccessControlMethods<'a, C> {}
3553
3554impl<'a, C> ObjectAccessControlMethods<'a, C> {
3555    /// Create a builder to help you perform the following task:
3556    ///
3557    /// Permanently deletes the ACL entry for the specified entity on the specified object.
3558    ///
3559    /// # Arguments
3560    ///
3561    /// * `bucket` - Name of a bucket.
3562    /// * `object` - Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
3563    /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
3564    pub fn delete(
3565        &self,
3566        bucket: &str,
3567        object: &str,
3568        entity: &str,
3569    ) -> ObjectAccessControlDeleteCall<'a, C> {
3570        ObjectAccessControlDeleteCall {
3571            hub: self.hub,
3572            _bucket: bucket.to_string(),
3573            _object: object.to_string(),
3574            _entity: entity.to_string(),
3575            _user_project: Default::default(),
3576            _generation: Default::default(),
3577            _delegate: Default::default(),
3578            _additional_params: Default::default(),
3579            _scopes: Default::default(),
3580        }
3581    }
3582
3583    /// Create a builder to help you perform the following task:
3584    ///
3585    /// Returns the ACL entry for the specified entity on the specified object.
3586    ///
3587    /// # Arguments
3588    ///
3589    /// * `bucket` - Name of a bucket.
3590    /// * `object` - Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
3591    /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
3592    pub fn get(
3593        &self,
3594        bucket: &str,
3595        object: &str,
3596        entity: &str,
3597    ) -> ObjectAccessControlGetCall<'a, C> {
3598        ObjectAccessControlGetCall {
3599            hub: self.hub,
3600            _bucket: bucket.to_string(),
3601            _object: object.to_string(),
3602            _entity: entity.to_string(),
3603            _user_project: Default::default(),
3604            _generation: Default::default(),
3605            _delegate: Default::default(),
3606            _additional_params: Default::default(),
3607            _scopes: Default::default(),
3608        }
3609    }
3610
3611    /// Create a builder to help you perform the following task:
3612    ///
3613    /// Creates a new ACL entry on the specified object.
3614    ///
3615    /// # Arguments
3616    ///
3617    /// * `request` - No description provided.
3618    /// * `bucket` - Name of a bucket.
3619    /// * `object` - Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
3620    pub fn insert(
3621        &self,
3622        request: ObjectAccessControl,
3623        bucket: &str,
3624        object: &str,
3625    ) -> ObjectAccessControlInsertCall<'a, C> {
3626        ObjectAccessControlInsertCall {
3627            hub: self.hub,
3628            _request: request,
3629            _bucket: bucket.to_string(),
3630            _object: object.to_string(),
3631            _user_project: Default::default(),
3632            _generation: Default::default(),
3633            _delegate: Default::default(),
3634            _additional_params: Default::default(),
3635            _scopes: Default::default(),
3636        }
3637    }
3638
3639    /// Create a builder to help you perform the following task:
3640    ///
3641    /// Retrieves ACL entries on the specified object.
3642    ///
3643    /// # Arguments
3644    ///
3645    /// * `bucket` - Name of a bucket.
3646    /// * `object` - Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
3647    pub fn list(&self, bucket: &str, object: &str) -> ObjectAccessControlListCall<'a, C> {
3648        ObjectAccessControlListCall {
3649            hub: self.hub,
3650            _bucket: bucket.to_string(),
3651            _object: object.to_string(),
3652            _user_project: Default::default(),
3653            _generation: Default::default(),
3654            _delegate: Default::default(),
3655            _additional_params: Default::default(),
3656            _scopes: Default::default(),
3657        }
3658    }
3659
3660    /// Create a builder to help you perform the following task:
3661    ///
3662    /// Patches an ACL entry on the specified object.
3663    ///
3664    /// # Arguments
3665    ///
3666    /// * `request` - No description provided.
3667    /// * `bucket` - Name of a bucket.
3668    /// * `object` - Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
3669    /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
3670    pub fn patch(
3671        &self,
3672        request: ObjectAccessControl,
3673        bucket: &str,
3674        object: &str,
3675        entity: &str,
3676    ) -> ObjectAccessControlPatchCall<'a, C> {
3677        ObjectAccessControlPatchCall {
3678            hub: self.hub,
3679            _request: request,
3680            _bucket: bucket.to_string(),
3681            _object: object.to_string(),
3682            _entity: entity.to_string(),
3683            _user_project: Default::default(),
3684            _generation: Default::default(),
3685            _delegate: Default::default(),
3686            _additional_params: Default::default(),
3687            _scopes: Default::default(),
3688        }
3689    }
3690
3691    /// Create a builder to help you perform the following task:
3692    ///
3693    /// Updates an ACL entry on the specified object.
3694    ///
3695    /// # Arguments
3696    ///
3697    /// * `request` - No description provided.
3698    /// * `bucket` - Name of a bucket.
3699    /// * `object` - Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
3700    /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
3701    pub fn update(
3702        &self,
3703        request: ObjectAccessControl,
3704        bucket: &str,
3705        object: &str,
3706        entity: &str,
3707    ) -> ObjectAccessControlUpdateCall<'a, C> {
3708        ObjectAccessControlUpdateCall {
3709            hub: self.hub,
3710            _request: request,
3711            _bucket: bucket.to_string(),
3712            _object: object.to_string(),
3713            _entity: entity.to_string(),
3714            _user_project: Default::default(),
3715            _generation: Default::default(),
3716            _delegate: Default::default(),
3717            _additional_params: Default::default(),
3718            _scopes: Default::default(),
3719        }
3720    }
3721}
3722
3723/// A builder providing access to all methods supported on *object* resources.
3724/// It is not used directly, but through the [`Storage`] hub.
3725///
3726/// # Example
3727///
3728/// Instantiate a resource builder
3729///
3730/// ```test_harness,no_run
3731/// extern crate hyper;
3732/// extern crate hyper_rustls;
3733/// extern crate google_storage1 as storage1;
3734///
3735/// # async fn dox() {
3736/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3737///
3738/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3739/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3740///     secret,
3741///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3742/// ).build().await.unwrap();
3743///
3744/// let client = hyper_util::client::legacy::Client::builder(
3745///     hyper_util::rt::TokioExecutor::new()
3746/// )
3747/// .build(
3748///     hyper_rustls::HttpsConnectorBuilder::new()
3749///         .with_native_roots()
3750///         .unwrap()
3751///         .https_or_http()
3752///         .enable_http1()
3753///         .build()
3754/// );
3755/// let mut hub = Storage::new(client, auth);
3756/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3757/// // like `bulk_restore(...)`, `compose(...)`, `copy(...)`, `delete(...)`, `get(...)`, `get_iam_policy(...)`, `insert(...)`, `list(...)`, `patch(...)`, `restore(...)`, `rewrite(...)`, `set_iam_policy(...)`, `test_iam_permissions(...)`, `update(...)` and `watch_all(...)`
3758/// // to build up your call.
3759/// let rb = hub.objects();
3760/// # }
3761/// ```
3762pub struct ObjectMethods<'a, C>
3763where
3764    C: 'a,
3765{
3766    hub: &'a Storage<C>,
3767}
3768
3769impl<'a, C> common::MethodsBuilder for ObjectMethods<'a, C> {}
3770
3771impl<'a, C> ObjectMethods<'a, C> {
3772    /// Create a builder to help you perform the following task:
3773    ///
3774    /// Initiates a long-running bulk restore operation on the specified bucket.
3775    ///
3776    /// # Arguments
3777    ///
3778    /// * `request` - No description provided.
3779    /// * `bucket` - Name of the bucket in which the object resides.
3780    pub fn bulk_restore(
3781        &self,
3782        request: BulkRestoreObjectsRequest,
3783        bucket: &str,
3784    ) -> ObjectBulkRestoreCall<'a, C> {
3785        ObjectBulkRestoreCall {
3786            hub: self.hub,
3787            _request: request,
3788            _bucket: bucket.to_string(),
3789            _delegate: Default::default(),
3790            _additional_params: Default::default(),
3791            _scopes: Default::default(),
3792        }
3793    }
3794
3795    /// Create a builder to help you perform the following task:
3796    ///
3797    /// Concatenates a list of existing objects into a new object in the same bucket.
3798    ///
3799    /// # Arguments
3800    ///
3801    /// * `request` - No description provided.
3802    /// * `destinationBucket` - Name of the bucket containing the source objects. The destination object is stored in this bucket.
3803    /// * `destinationObject` - Name of the new object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
3804    pub fn compose(
3805        &self,
3806        request: ComposeRequest,
3807        destination_bucket: &str,
3808        destination_object: &str,
3809    ) -> ObjectComposeCall<'a, C> {
3810        ObjectComposeCall {
3811            hub: self.hub,
3812            _request: request,
3813            _destination_bucket: destination_bucket.to_string(),
3814            _destination_object: destination_object.to_string(),
3815            _user_project: Default::default(),
3816            _kms_key_name: Default::default(),
3817            _if_metageneration_match: Default::default(),
3818            _if_generation_match: Default::default(),
3819            _destination_predefined_acl: Default::default(),
3820            _delegate: Default::default(),
3821            _additional_params: Default::default(),
3822            _scopes: Default::default(),
3823        }
3824    }
3825
3826    /// Create a builder to help you perform the following task:
3827    ///
3828    /// Copies a source object to a destination object. Optionally overrides metadata.
3829    ///
3830    /// # Arguments
3831    ///
3832    /// * `request` - No description provided.
3833    /// * `sourceBucket` - Name of the bucket in which to find the source object.
3834    /// * `sourceObject` - Name of the source object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
3835    /// * `destinationBucket` - Name of the bucket in which to store the new object. Overrides the provided object metadata's bucket value, if any.For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
3836    /// * `destinationObject` - Name of the new object. Required when the object metadata is not otherwise provided. Overrides the object metadata's name value, if any.
3837    pub fn copy(
3838        &self,
3839        request: Object,
3840        source_bucket: &str,
3841        source_object: &str,
3842        destination_bucket: &str,
3843        destination_object: &str,
3844    ) -> ObjectCopyCall<'a, C> {
3845        ObjectCopyCall {
3846            hub: self.hub,
3847            _request: request,
3848            _source_bucket: source_bucket.to_string(),
3849            _source_object: source_object.to_string(),
3850            _destination_bucket: destination_bucket.to_string(),
3851            _destination_object: destination_object.to_string(),
3852            _user_project: Default::default(),
3853            _source_generation: Default::default(),
3854            _projection: Default::default(),
3855            _if_source_metageneration_not_match: Default::default(),
3856            _if_source_metageneration_match: Default::default(),
3857            _if_source_generation_not_match: Default::default(),
3858            _if_source_generation_match: Default::default(),
3859            _if_metageneration_not_match: Default::default(),
3860            _if_metageneration_match: Default::default(),
3861            _if_generation_not_match: Default::default(),
3862            _if_generation_match: Default::default(),
3863            _destination_predefined_acl: Default::default(),
3864            _destination_kms_key_name: Default::default(),
3865            _delegate: Default::default(),
3866            _additional_params: Default::default(),
3867            _scopes: Default::default(),
3868        }
3869    }
3870
3871    /// Create a builder to help you perform the following task:
3872    ///
3873    /// Deletes an object and its metadata. Deletions are permanent if versioning is not enabled for the bucket, or if the generation parameter is used.
3874    ///
3875    /// # Arguments
3876    ///
3877    /// * `bucket` - Name of the bucket in which the object resides.
3878    /// * `object` - Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
3879    pub fn delete(&self, bucket: &str, object: &str) -> ObjectDeleteCall<'a, C> {
3880        ObjectDeleteCall {
3881            hub: self.hub,
3882            _bucket: bucket.to_string(),
3883            _object: object.to_string(),
3884            _user_project: Default::default(),
3885            _if_metageneration_not_match: Default::default(),
3886            _if_metageneration_match: Default::default(),
3887            _if_generation_not_match: Default::default(),
3888            _if_generation_match: Default::default(),
3889            _generation: Default::default(),
3890            _delegate: Default::default(),
3891            _additional_params: Default::default(),
3892            _scopes: Default::default(),
3893        }
3894    }
3895
3896    /// Create a builder to help you perform the following task:
3897    ///
3898    /// Retrieves an object or its metadata.
3899    ///
3900    /// # Arguments
3901    ///
3902    /// * `bucket` - Name of the bucket in which the object resides.
3903    /// * `object` - Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
3904    pub fn get(&self, bucket: &str, object: &str) -> ObjectGetCall<'a, C> {
3905        ObjectGetCall {
3906            hub: self.hub,
3907            _bucket: bucket.to_string(),
3908            _object: object.to_string(),
3909            _user_project: Default::default(),
3910            _soft_deleted: Default::default(),
3911            _projection: Default::default(),
3912            _if_metageneration_not_match: Default::default(),
3913            _if_metageneration_match: Default::default(),
3914            _if_generation_not_match: Default::default(),
3915            _if_generation_match: Default::default(),
3916            _generation: Default::default(),
3917            _delegate: Default::default(),
3918            _additional_params: Default::default(),
3919            _scopes: Default::default(),
3920        }
3921    }
3922
3923    /// Create a builder to help you perform the following task:
3924    ///
3925    /// Returns an IAM policy for the specified object.
3926    ///
3927    /// # Arguments
3928    ///
3929    /// * `bucket` - Name of the bucket in which the object resides.
3930    /// * `object` - Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
3931    pub fn get_iam_policy(&self, bucket: &str, object: &str) -> ObjectGetIamPolicyCall<'a, C> {
3932        ObjectGetIamPolicyCall {
3933            hub: self.hub,
3934            _bucket: bucket.to_string(),
3935            _object: object.to_string(),
3936            _user_project: Default::default(),
3937            _generation: Default::default(),
3938            _delegate: Default::default(),
3939            _additional_params: Default::default(),
3940            _scopes: Default::default(),
3941        }
3942    }
3943
3944    /// Create a builder to help you perform the following task:
3945    ///
3946    /// Stores a new object and metadata.
3947    ///
3948    /// # Arguments
3949    ///
3950    /// * `request` - No description provided.
3951    /// * `bucket` - Name of the bucket in which to store the new object. Overrides the provided object metadata's bucket value, if any.
3952    pub fn insert(&self, request: Object, bucket: &str) -> ObjectInsertCall<'a, C> {
3953        ObjectInsertCall {
3954            hub: self.hub,
3955            _request: request,
3956            _bucket: bucket.to_string(),
3957            _user_project: Default::default(),
3958            _projection: Default::default(),
3959            _predefined_acl: Default::default(),
3960            _name: Default::default(),
3961            _kms_key_name: Default::default(),
3962            _if_metageneration_not_match: Default::default(),
3963            _if_metageneration_match: Default::default(),
3964            _if_generation_not_match: Default::default(),
3965            _if_generation_match: Default::default(),
3966            _content_encoding: Default::default(),
3967            _delegate: Default::default(),
3968            _additional_params: Default::default(),
3969            _scopes: Default::default(),
3970        }
3971    }
3972
3973    /// Create a builder to help you perform the following task:
3974    ///
3975    /// Retrieves a list of objects matching the criteria.
3976    ///
3977    /// # Arguments
3978    ///
3979    /// * `bucket` - Name of the bucket in which to look for objects.
3980    pub fn list(&self, bucket: &str) -> ObjectListCall<'a, C> {
3981        ObjectListCall {
3982            hub: self.hub,
3983            _bucket: bucket.to_string(),
3984            _versions: Default::default(),
3985            _user_project: Default::default(),
3986            _start_offset: Default::default(),
3987            _soft_deleted: Default::default(),
3988            _projection: Default::default(),
3989            _prefix: Default::default(),
3990            _page_token: Default::default(),
3991            _max_results: Default::default(),
3992            _match_glob: Default::default(),
3993            _include_trailing_delimiter: Default::default(),
3994            _include_folders_as_prefixes: Default::default(),
3995            _end_offset: Default::default(),
3996            _delimiter: Default::default(),
3997            _delegate: Default::default(),
3998            _additional_params: Default::default(),
3999            _scopes: Default::default(),
4000        }
4001    }
4002
4003    /// Create a builder to help you perform the following task:
4004    ///
4005    /// Patches an object's metadata.
4006    ///
4007    /// # Arguments
4008    ///
4009    /// * `request` - No description provided.
4010    /// * `bucket` - Name of the bucket in which the object resides.
4011    /// * `object` - Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
4012    pub fn patch(&self, request: Object, bucket: &str, object: &str) -> ObjectPatchCall<'a, C> {
4013        ObjectPatchCall {
4014            hub: self.hub,
4015            _request: request,
4016            _bucket: bucket.to_string(),
4017            _object: object.to_string(),
4018            _user_project: Default::default(),
4019            _projection: Default::default(),
4020            _predefined_acl: Default::default(),
4021            _override_unlocked_retention: Default::default(),
4022            _if_metageneration_not_match: Default::default(),
4023            _if_metageneration_match: Default::default(),
4024            _if_generation_not_match: Default::default(),
4025            _if_generation_match: Default::default(),
4026            _generation: Default::default(),
4027            _delegate: Default::default(),
4028            _additional_params: Default::default(),
4029            _scopes: Default::default(),
4030        }
4031    }
4032
4033    /// Create a builder to help you perform the following task:
4034    ///
4035    /// Restores a soft-deleted object.
4036    ///
4037    /// # Arguments
4038    ///
4039    /// * `bucket` - Name of the bucket in which the object resides.
4040    /// * `object` - Name of the object. For information about how to URL encode object names to be path safe, see Encoding URI Path Parts.
4041    /// * `generation` - Selects a specific revision of this object.
4042    pub fn restore(&self, bucket: &str, object: &str, generation: i64) -> ObjectRestoreCall<'a, C> {
4043        ObjectRestoreCall {
4044            hub: self.hub,
4045            _bucket: bucket.to_string(),
4046            _object: object.to_string(),
4047            _generation: generation,
4048            _user_project: Default::default(),
4049            _projection: Default::default(),
4050            _if_metageneration_not_match: Default::default(),
4051            _if_metageneration_match: Default::default(),
4052            _if_generation_not_match: Default::default(),
4053            _if_generation_match: Default::default(),
4054            _copy_source_acl: Default::default(),
4055            _delegate: Default::default(),
4056            _additional_params: Default::default(),
4057            _scopes: Default::default(),
4058        }
4059    }
4060
4061    /// Create a builder to help you perform the following task:
4062    ///
4063    /// Rewrites a source object to a destination object. Optionally overrides metadata.
4064    ///
4065    /// # Arguments
4066    ///
4067    /// * `request` - No description provided.
4068    /// * `sourceBucket` - Name of the bucket in which to find the source object.
4069    /// * `sourceObject` - Name of the source object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
4070    /// * `destinationBucket` - Name of the bucket in which to store the new object. Overrides the provided object metadata's bucket value, if any.
4071    /// * `destinationObject` - Name of the new object. Required when the object metadata is not otherwise provided. Overrides the object metadata's name value, if any. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
4072    pub fn rewrite(
4073        &self,
4074        request: Object,
4075        source_bucket: &str,
4076        source_object: &str,
4077        destination_bucket: &str,
4078        destination_object: &str,
4079    ) -> ObjectRewriteCall<'a, C> {
4080        ObjectRewriteCall {
4081            hub: self.hub,
4082            _request: request,
4083            _source_bucket: source_bucket.to_string(),
4084            _source_object: source_object.to_string(),
4085            _destination_bucket: destination_bucket.to_string(),
4086            _destination_object: destination_object.to_string(),
4087            _user_project: Default::default(),
4088            _source_generation: Default::default(),
4089            _rewrite_token: Default::default(),
4090            _projection: Default::default(),
4091            _max_bytes_rewritten_per_call: Default::default(),
4092            _if_source_metageneration_not_match: Default::default(),
4093            _if_source_metageneration_match: Default::default(),
4094            _if_source_generation_not_match: Default::default(),
4095            _if_source_generation_match: Default::default(),
4096            _if_metageneration_not_match: Default::default(),
4097            _if_metageneration_match: Default::default(),
4098            _if_generation_not_match: Default::default(),
4099            _if_generation_match: Default::default(),
4100            _destination_predefined_acl: Default::default(),
4101            _destination_kms_key_name: Default::default(),
4102            _delegate: Default::default(),
4103            _additional_params: Default::default(),
4104            _scopes: Default::default(),
4105        }
4106    }
4107
4108    /// Create a builder to help you perform the following task:
4109    ///
4110    /// Updates an IAM policy for the specified object.
4111    ///
4112    /// # Arguments
4113    ///
4114    /// * `request` - No description provided.
4115    /// * `bucket` - Name of the bucket in which the object resides.
4116    /// * `object` - Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
4117    pub fn set_iam_policy(
4118        &self,
4119        request: Policy,
4120        bucket: &str,
4121        object: &str,
4122    ) -> ObjectSetIamPolicyCall<'a, C> {
4123        ObjectSetIamPolicyCall {
4124            hub: self.hub,
4125            _request: request,
4126            _bucket: bucket.to_string(),
4127            _object: object.to_string(),
4128            _user_project: Default::default(),
4129            _generation: Default::default(),
4130            _delegate: Default::default(),
4131            _additional_params: Default::default(),
4132            _scopes: Default::default(),
4133        }
4134    }
4135
4136    /// Create a builder to help you perform the following task:
4137    ///
4138    /// Tests a set of permissions on the given object to see which, if any, are held by the caller.
4139    ///
4140    /// # Arguments
4141    ///
4142    /// * `bucket` - Name of the bucket in which the object resides.
4143    /// * `object` - Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
4144    /// * `permissions` - Permissions to test.
4145    pub fn test_iam_permissions(
4146        &self,
4147        bucket: &str,
4148        object: &str,
4149        permissions: &Vec<String>,
4150    ) -> ObjectTestIamPermissionCall<'a, C> {
4151        ObjectTestIamPermissionCall {
4152            hub: self.hub,
4153            _bucket: bucket.to_string(),
4154            _object: object.to_string(),
4155            _permissions: permissions.clone(),
4156            _user_project: Default::default(),
4157            _generation: Default::default(),
4158            _delegate: Default::default(),
4159            _additional_params: Default::default(),
4160            _scopes: Default::default(),
4161        }
4162    }
4163
4164    /// Create a builder to help you perform the following task:
4165    ///
4166    /// Updates an object's metadata.
4167    ///
4168    /// # Arguments
4169    ///
4170    /// * `request` - No description provided.
4171    /// * `bucket` - Name of the bucket in which the object resides.
4172    /// * `object` - Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
4173    pub fn update(&self, request: Object, bucket: &str, object: &str) -> ObjectUpdateCall<'a, C> {
4174        ObjectUpdateCall {
4175            hub: self.hub,
4176            _request: request,
4177            _bucket: bucket.to_string(),
4178            _object: object.to_string(),
4179            _user_project: Default::default(),
4180            _projection: Default::default(),
4181            _predefined_acl: Default::default(),
4182            _override_unlocked_retention: Default::default(),
4183            _if_metageneration_not_match: Default::default(),
4184            _if_metageneration_match: Default::default(),
4185            _if_generation_not_match: Default::default(),
4186            _if_generation_match: Default::default(),
4187            _generation: Default::default(),
4188            _delegate: Default::default(),
4189            _additional_params: Default::default(),
4190            _scopes: Default::default(),
4191        }
4192    }
4193
4194    /// Create a builder to help you perform the following task:
4195    ///
4196    /// Watch for changes on all objects in a bucket.
4197    ///
4198    /// # Arguments
4199    ///
4200    /// * `request` - No description provided.
4201    /// * `bucket` - Name of the bucket in which to look for objects.
4202    pub fn watch_all(&self, request: Channel, bucket: &str) -> ObjectWatchAllCall<'a, C> {
4203        ObjectWatchAllCall {
4204            hub: self.hub,
4205            _request: request,
4206            _bucket: bucket.to_string(),
4207            _versions: Default::default(),
4208            _user_project: Default::default(),
4209            _start_offset: Default::default(),
4210            _projection: Default::default(),
4211            _prefix: Default::default(),
4212            _page_token: Default::default(),
4213            _max_results: Default::default(),
4214            _include_trailing_delimiter: Default::default(),
4215            _end_offset: Default::default(),
4216            _delimiter: Default::default(),
4217            _delegate: Default::default(),
4218            _additional_params: Default::default(),
4219            _scopes: Default::default(),
4220        }
4221    }
4222}
4223
4224/// A builder providing access to all methods supported on *project* resources.
4225/// It is not used directly, but through the [`Storage`] hub.
4226///
4227/// # Example
4228///
4229/// Instantiate a resource builder
4230///
4231/// ```test_harness,no_run
4232/// extern crate hyper;
4233/// extern crate hyper_rustls;
4234/// extern crate google_storage1 as storage1;
4235///
4236/// # async fn dox() {
4237/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4238///
4239/// let secret: yup_oauth2::ApplicationSecret = Default::default();
4240/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4241///     secret,
4242///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4243/// ).build().await.unwrap();
4244///
4245/// let client = hyper_util::client::legacy::Client::builder(
4246///     hyper_util::rt::TokioExecutor::new()
4247/// )
4248/// .build(
4249///     hyper_rustls::HttpsConnectorBuilder::new()
4250///         .with_native_roots()
4251///         .unwrap()
4252///         .https_or_http()
4253///         .enable_http1()
4254///         .build()
4255/// );
4256/// let mut hub = Storage::new(client, auth);
4257/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4258/// // like `hmac_keys_create(...)`, `hmac_keys_delete(...)`, `hmac_keys_get(...)`, `hmac_keys_list(...)`, `hmac_keys_update(...)` and `service_account_get(...)`
4259/// // to build up your call.
4260/// let rb = hub.projects();
4261/// # }
4262/// ```
4263pub struct ProjectMethods<'a, C>
4264where
4265    C: 'a,
4266{
4267    hub: &'a Storage<C>,
4268}
4269
4270impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
4271
4272impl<'a, C> ProjectMethods<'a, C> {
4273    /// Create a builder to help you perform the following task:
4274    ///
4275    /// Creates a new HMAC key for the specified service account.
4276    ///
4277    /// # Arguments
4278    ///
4279    /// * `projectId` - Project ID owning the service account.
4280    /// * `serviceAccountEmail` - Email address of the service account.
4281    pub fn hmac_keys_create(
4282        &self,
4283        project_id: &str,
4284        service_account_email: &str,
4285    ) -> ProjectHmacKeyCreateCall<'a, C> {
4286        ProjectHmacKeyCreateCall {
4287            hub: self.hub,
4288            _project_id: project_id.to_string(),
4289            _service_account_email: service_account_email.to_string(),
4290            _user_project: Default::default(),
4291            _delegate: Default::default(),
4292            _additional_params: Default::default(),
4293            _scopes: Default::default(),
4294        }
4295    }
4296
4297    /// Create a builder to help you perform the following task:
4298    ///
4299    /// Deletes an HMAC key.
4300    ///
4301    /// # Arguments
4302    ///
4303    /// * `projectId` - Project ID owning the requested key
4304    /// * `accessId` - Name of the HMAC key to be deleted.
4305    pub fn hmac_keys_delete(
4306        &self,
4307        project_id: &str,
4308        access_id: &str,
4309    ) -> ProjectHmacKeyDeleteCall<'a, C> {
4310        ProjectHmacKeyDeleteCall {
4311            hub: self.hub,
4312            _project_id: project_id.to_string(),
4313            _access_id: access_id.to_string(),
4314            _user_project: Default::default(),
4315            _delegate: Default::default(),
4316            _additional_params: Default::default(),
4317            _scopes: Default::default(),
4318        }
4319    }
4320
4321    /// Create a builder to help you perform the following task:
4322    ///
4323    /// Retrieves an HMAC key's metadata
4324    ///
4325    /// # Arguments
4326    ///
4327    /// * `projectId` - Project ID owning the service account of the requested key.
4328    /// * `accessId` - Name of the HMAC key.
4329    pub fn hmac_keys_get(&self, project_id: &str, access_id: &str) -> ProjectHmacKeyGetCall<'a, C> {
4330        ProjectHmacKeyGetCall {
4331            hub: self.hub,
4332            _project_id: project_id.to_string(),
4333            _access_id: access_id.to_string(),
4334            _user_project: Default::default(),
4335            _delegate: Default::default(),
4336            _additional_params: Default::default(),
4337            _scopes: Default::default(),
4338        }
4339    }
4340
4341    /// Create a builder to help you perform the following task:
4342    ///
4343    /// Retrieves a list of HMAC keys matching the criteria.
4344    ///
4345    /// # Arguments
4346    ///
4347    /// * `projectId` - Name of the project in which to look for HMAC keys.
4348    pub fn hmac_keys_list(&self, project_id: &str) -> ProjectHmacKeyListCall<'a, C> {
4349        ProjectHmacKeyListCall {
4350            hub: self.hub,
4351            _project_id: project_id.to_string(),
4352            _user_project: Default::default(),
4353            _show_deleted_keys: Default::default(),
4354            _service_account_email: Default::default(),
4355            _page_token: Default::default(),
4356            _max_results: Default::default(),
4357            _delegate: Default::default(),
4358            _additional_params: Default::default(),
4359            _scopes: Default::default(),
4360        }
4361    }
4362
4363    /// Create a builder to help you perform the following task:
4364    ///
4365    /// Updates the state of an HMAC key. See the HMAC Key resource descriptor for valid states.
4366    ///
4367    /// # Arguments
4368    ///
4369    /// * `request` - No description provided.
4370    /// * `projectId` - Project ID owning the service account of the updated key.
4371    /// * `accessId` - Name of the HMAC key being updated.
4372    pub fn hmac_keys_update(
4373        &self,
4374        request: HmacKeyMetadata,
4375        project_id: &str,
4376        access_id: &str,
4377    ) -> ProjectHmacKeyUpdateCall<'a, C> {
4378        ProjectHmacKeyUpdateCall {
4379            hub: self.hub,
4380            _request: request,
4381            _project_id: project_id.to_string(),
4382            _access_id: access_id.to_string(),
4383            _user_project: Default::default(),
4384            _delegate: Default::default(),
4385            _additional_params: Default::default(),
4386            _scopes: Default::default(),
4387        }
4388    }
4389
4390    /// Create a builder to help you perform the following task:
4391    ///
4392    /// Get the email address of this project's Google Cloud Storage service account.
4393    ///
4394    /// # Arguments
4395    ///
4396    /// * `projectId` - Project ID
4397    pub fn service_account_get(&self, project_id: &str) -> ProjectServiceAccountGetCall<'a, C> {
4398        ProjectServiceAccountGetCall {
4399            hub: self.hub,
4400            _project_id: project_id.to_string(),
4401            _user_project: Default::default(),
4402            _delegate: Default::default(),
4403            _additional_params: Default::default(),
4404            _scopes: Default::default(),
4405        }
4406    }
4407}
4408
4409// ###################
4410// CallBuilders   ###
4411// #################
4412
4413/// Disables an Anywhere Cache instance.
4414///
4415/// A builder for the *disable* method supported by a *anywhereCach* resource.
4416/// It is not used directly, but through a [`AnywhereCachMethods`] instance.
4417///
4418/// # Example
4419///
4420/// Instantiate a resource method builder
4421///
4422/// ```test_harness,no_run
4423/// # extern crate hyper;
4424/// # extern crate hyper_rustls;
4425/// # extern crate google_storage1 as storage1;
4426/// # async fn dox() {
4427/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4428///
4429/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4430/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4431/// #     secret,
4432/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4433/// # ).build().await.unwrap();
4434///
4435/// # let client = hyper_util::client::legacy::Client::builder(
4436/// #     hyper_util::rt::TokioExecutor::new()
4437/// # )
4438/// # .build(
4439/// #     hyper_rustls::HttpsConnectorBuilder::new()
4440/// #         .with_native_roots()
4441/// #         .unwrap()
4442/// #         .https_or_http()
4443/// #         .enable_http1()
4444/// #         .build()
4445/// # );
4446/// # let mut hub = Storage::new(client, auth);
4447/// // You can configure optional parameters by calling the respective setters at will, and
4448/// // execute the final call using `doit()`.
4449/// // Values shown here are possibly random and not representative !
4450/// let result = hub.anywhere_caches().disable("bucket", "anywhereCacheId")
4451///              .doit().await;
4452/// # }
4453/// ```
4454pub struct AnywhereCachDisableCall<'a, C>
4455where
4456    C: 'a,
4457{
4458    hub: &'a Storage<C>,
4459    _bucket: String,
4460    _anywhere_cache_id: String,
4461    _delegate: Option<&'a mut dyn common::Delegate>,
4462    _additional_params: HashMap<String, String>,
4463    _scopes: BTreeSet<String>,
4464}
4465
4466impl<'a, C> common::CallBuilder for AnywhereCachDisableCall<'a, C> {}
4467
4468impl<'a, C> AnywhereCachDisableCall<'a, C>
4469where
4470    C: common::Connector,
4471{
4472    /// Perform the operation you have build so far.
4473    pub async fn doit(mut self) -> common::Result<(common::Response, AnywhereCache)> {
4474        use std::borrow::Cow;
4475        use std::io::{Read, Seek};
4476
4477        use common::{url::Params, ToParts};
4478        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4479
4480        let mut dd = common::DefaultDelegate;
4481        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4482        dlg.begin(common::MethodInfo {
4483            id: "storage.anywhereCaches.disable",
4484            http_method: hyper::Method::POST,
4485        });
4486
4487        for &field in ["alt", "bucket", "anywhereCacheId"].iter() {
4488            if self._additional_params.contains_key(field) {
4489                dlg.finished(false);
4490                return Err(common::Error::FieldClash(field));
4491            }
4492        }
4493
4494        let mut params = Params::with_capacity(4 + self._additional_params.len());
4495        params.push("bucket", self._bucket);
4496        params.push("anywhereCacheId", self._anywhere_cache_id);
4497
4498        params.extend(self._additional_params.iter());
4499
4500        params.push("alt", "json");
4501        let mut url =
4502            self.hub._base_url.clone() + "b/{bucket}/anywhereCaches/{anywhereCacheId}/disable";
4503        if self._scopes.is_empty() {
4504            self._scopes
4505                .insert(Scope::CloudPlatform.as_ref().to_string());
4506        }
4507
4508        #[allow(clippy::single_element_loop)]
4509        for &(find_this, param_name) in [
4510            ("{bucket}", "bucket"),
4511            ("{anywhereCacheId}", "anywhereCacheId"),
4512        ]
4513        .iter()
4514        {
4515            url = params.uri_replacement(url, param_name, find_this, false);
4516        }
4517        {
4518            let to_remove = ["anywhereCacheId", "bucket"];
4519            params.remove_params(&to_remove);
4520        }
4521
4522        let url = params.parse_with_url(&url);
4523
4524        loop {
4525            let token = match self
4526                .hub
4527                .auth
4528                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4529                .await
4530            {
4531                Ok(token) => token,
4532                Err(e) => match dlg.token(e) {
4533                    Ok(token) => token,
4534                    Err(e) => {
4535                        dlg.finished(false);
4536                        return Err(common::Error::MissingToken(e));
4537                    }
4538                },
4539            };
4540            let mut req_result = {
4541                let client = &self.hub.client;
4542                dlg.pre_request();
4543                let mut req_builder = hyper::Request::builder()
4544                    .method(hyper::Method::POST)
4545                    .uri(url.as_str())
4546                    .header(USER_AGENT, self.hub._user_agent.clone());
4547
4548                if let Some(token) = token.as_ref() {
4549                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4550                }
4551
4552                let request = req_builder
4553                    .header(CONTENT_LENGTH, 0_u64)
4554                    .body(common::to_body::<String>(None));
4555
4556                client.request(request.unwrap()).await
4557            };
4558
4559            match req_result {
4560                Err(err) => {
4561                    if let common::Retry::After(d) = dlg.http_error(&err) {
4562                        sleep(d).await;
4563                        continue;
4564                    }
4565                    dlg.finished(false);
4566                    return Err(common::Error::HttpError(err));
4567                }
4568                Ok(res) => {
4569                    let (mut parts, body) = res.into_parts();
4570                    let mut body = common::Body::new(body);
4571                    if !parts.status.is_success() {
4572                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4573                        let error = serde_json::from_str(&common::to_string(&bytes));
4574                        let response = common::to_response(parts, bytes.into());
4575
4576                        if let common::Retry::After(d) =
4577                            dlg.http_failure(&response, error.as_ref().ok())
4578                        {
4579                            sleep(d).await;
4580                            continue;
4581                        }
4582
4583                        dlg.finished(false);
4584
4585                        return Err(match error {
4586                            Ok(value) => common::Error::BadRequest(value),
4587                            _ => common::Error::Failure(response),
4588                        });
4589                    }
4590                    let response = {
4591                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4592                        let encoded = common::to_string(&bytes);
4593                        match serde_json::from_str(&encoded) {
4594                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4595                            Err(error) => {
4596                                dlg.response_json_decode_error(&encoded, &error);
4597                                return Err(common::Error::JsonDecodeError(
4598                                    encoded.to_string(),
4599                                    error,
4600                                ));
4601                            }
4602                        }
4603                    };
4604
4605                    dlg.finished(true);
4606                    return Ok(response);
4607                }
4608            }
4609        }
4610    }
4611
4612    /// Name of the parent bucket.
4613    ///
4614    /// Sets the *bucket* path property to the given value.
4615    ///
4616    /// Even though the property as already been set when instantiating this call,
4617    /// we provide this method for API completeness.
4618    pub fn bucket(mut self, new_value: &str) -> AnywhereCachDisableCall<'a, C> {
4619        self._bucket = new_value.to_string();
4620        self
4621    }
4622    /// The ID of requested Anywhere Cache instance.
4623    ///
4624    /// Sets the *anywhere cache id* path property to the given value.
4625    ///
4626    /// Even though the property as already been set when instantiating this call,
4627    /// we provide this method for API completeness.
4628    pub fn anywhere_cache_id(mut self, new_value: &str) -> AnywhereCachDisableCall<'a, C> {
4629        self._anywhere_cache_id = new_value.to_string();
4630        self
4631    }
4632    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4633    /// while executing the actual API request.
4634    ///
4635    /// ````text
4636    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4637    /// ````
4638    ///
4639    /// Sets the *delegate* property to the given value.
4640    pub fn delegate(
4641        mut self,
4642        new_value: &'a mut dyn common::Delegate,
4643    ) -> AnywhereCachDisableCall<'a, C> {
4644        self._delegate = Some(new_value);
4645        self
4646    }
4647
4648    /// Set any additional parameter of the query string used in the request.
4649    /// It should be used to set parameters which are not yet available through their own
4650    /// setters.
4651    ///
4652    /// Please note that this method must not be used to set any of the known parameters
4653    /// which have their own setter method. If done anyway, the request will fail.
4654    ///
4655    /// # Additional Parameters
4656    ///
4657    /// * *alt* (query-string) - Data format for the response.
4658    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4659    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4660    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4661    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4662    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4663    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
4664    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4665    pub fn param<T>(mut self, name: T, value: T) -> AnywhereCachDisableCall<'a, C>
4666    where
4667        T: AsRef<str>,
4668    {
4669        self._additional_params
4670            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4671        self
4672    }
4673
4674    /// Identifies the authorization scope for the method you are building.
4675    ///
4676    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4677    /// [`Scope::CloudPlatform`].
4678    ///
4679    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4680    /// tokens for more than one scope.
4681    ///
4682    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4683    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4684    /// sufficient, a read-write scope will do as well.
4685    pub fn add_scope<St>(mut self, scope: St) -> AnywhereCachDisableCall<'a, C>
4686    where
4687        St: AsRef<str>,
4688    {
4689        self._scopes.insert(String::from(scope.as_ref()));
4690        self
4691    }
4692    /// Identifies the authorization scope(s) for the method you are building.
4693    ///
4694    /// See [`Self::add_scope()`] for details.
4695    pub fn add_scopes<I, St>(mut self, scopes: I) -> AnywhereCachDisableCall<'a, C>
4696    where
4697        I: IntoIterator<Item = St>,
4698        St: AsRef<str>,
4699    {
4700        self._scopes
4701            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4702        self
4703    }
4704
4705    /// Removes all scopes, and no default scope will be used either.
4706    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4707    /// for details).
4708    pub fn clear_scopes(mut self) -> AnywhereCachDisableCall<'a, C> {
4709        self._scopes.clear();
4710        self
4711    }
4712}
4713
4714/// Returns the metadata of an Anywhere Cache instance.
4715///
4716/// A builder for the *get* method supported by a *anywhereCach* resource.
4717/// It is not used directly, but through a [`AnywhereCachMethods`] instance.
4718///
4719/// # Example
4720///
4721/// Instantiate a resource method builder
4722///
4723/// ```test_harness,no_run
4724/// # extern crate hyper;
4725/// # extern crate hyper_rustls;
4726/// # extern crate google_storage1 as storage1;
4727/// # async fn dox() {
4728/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4729///
4730/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4731/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4732/// #     secret,
4733/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4734/// # ).build().await.unwrap();
4735///
4736/// # let client = hyper_util::client::legacy::Client::builder(
4737/// #     hyper_util::rt::TokioExecutor::new()
4738/// # )
4739/// # .build(
4740/// #     hyper_rustls::HttpsConnectorBuilder::new()
4741/// #         .with_native_roots()
4742/// #         .unwrap()
4743/// #         .https_or_http()
4744/// #         .enable_http1()
4745/// #         .build()
4746/// # );
4747/// # let mut hub = Storage::new(client, auth);
4748/// // You can configure optional parameters by calling the respective setters at will, and
4749/// // execute the final call using `doit()`.
4750/// // Values shown here are possibly random and not representative !
4751/// let result = hub.anywhere_caches().get("bucket", "anywhereCacheId")
4752///              .doit().await;
4753/// # }
4754/// ```
4755pub struct AnywhereCachGetCall<'a, C>
4756where
4757    C: 'a,
4758{
4759    hub: &'a Storage<C>,
4760    _bucket: String,
4761    _anywhere_cache_id: String,
4762    _delegate: Option<&'a mut dyn common::Delegate>,
4763    _additional_params: HashMap<String, String>,
4764    _scopes: BTreeSet<String>,
4765}
4766
4767impl<'a, C> common::CallBuilder for AnywhereCachGetCall<'a, C> {}
4768
4769impl<'a, C> AnywhereCachGetCall<'a, C>
4770where
4771    C: common::Connector,
4772{
4773    /// Perform the operation you have build so far.
4774    pub async fn doit(mut self) -> common::Result<(common::Response, AnywhereCache)> {
4775        use std::borrow::Cow;
4776        use std::io::{Read, Seek};
4777
4778        use common::{url::Params, ToParts};
4779        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4780
4781        let mut dd = common::DefaultDelegate;
4782        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4783        dlg.begin(common::MethodInfo {
4784            id: "storage.anywhereCaches.get",
4785            http_method: hyper::Method::GET,
4786        });
4787
4788        for &field in ["alt", "bucket", "anywhereCacheId"].iter() {
4789            if self._additional_params.contains_key(field) {
4790                dlg.finished(false);
4791                return Err(common::Error::FieldClash(field));
4792            }
4793        }
4794
4795        let mut params = Params::with_capacity(4 + self._additional_params.len());
4796        params.push("bucket", self._bucket);
4797        params.push("anywhereCacheId", self._anywhere_cache_id);
4798
4799        params.extend(self._additional_params.iter());
4800
4801        params.push("alt", "json");
4802        let mut url = self.hub._base_url.clone() + "b/{bucket}/anywhereCaches/{anywhereCacheId}";
4803        if self._scopes.is_empty() {
4804            self._scopes
4805                .insert(Scope::CloudPlatform.as_ref().to_string());
4806        }
4807
4808        #[allow(clippy::single_element_loop)]
4809        for &(find_this, param_name) in [
4810            ("{bucket}", "bucket"),
4811            ("{anywhereCacheId}", "anywhereCacheId"),
4812        ]
4813        .iter()
4814        {
4815            url = params.uri_replacement(url, param_name, find_this, false);
4816        }
4817        {
4818            let to_remove = ["anywhereCacheId", "bucket"];
4819            params.remove_params(&to_remove);
4820        }
4821
4822        let url = params.parse_with_url(&url);
4823
4824        loop {
4825            let token = match self
4826                .hub
4827                .auth
4828                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4829                .await
4830            {
4831                Ok(token) => token,
4832                Err(e) => match dlg.token(e) {
4833                    Ok(token) => token,
4834                    Err(e) => {
4835                        dlg.finished(false);
4836                        return Err(common::Error::MissingToken(e));
4837                    }
4838                },
4839            };
4840            let mut req_result = {
4841                let client = &self.hub.client;
4842                dlg.pre_request();
4843                let mut req_builder = hyper::Request::builder()
4844                    .method(hyper::Method::GET)
4845                    .uri(url.as_str())
4846                    .header(USER_AGENT, self.hub._user_agent.clone());
4847
4848                if let Some(token) = token.as_ref() {
4849                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4850                }
4851
4852                let request = req_builder
4853                    .header(CONTENT_LENGTH, 0_u64)
4854                    .body(common::to_body::<String>(None));
4855
4856                client.request(request.unwrap()).await
4857            };
4858
4859            match req_result {
4860                Err(err) => {
4861                    if let common::Retry::After(d) = dlg.http_error(&err) {
4862                        sleep(d).await;
4863                        continue;
4864                    }
4865                    dlg.finished(false);
4866                    return Err(common::Error::HttpError(err));
4867                }
4868                Ok(res) => {
4869                    let (mut parts, body) = res.into_parts();
4870                    let mut body = common::Body::new(body);
4871                    if !parts.status.is_success() {
4872                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4873                        let error = serde_json::from_str(&common::to_string(&bytes));
4874                        let response = common::to_response(parts, bytes.into());
4875
4876                        if let common::Retry::After(d) =
4877                            dlg.http_failure(&response, error.as_ref().ok())
4878                        {
4879                            sleep(d).await;
4880                            continue;
4881                        }
4882
4883                        dlg.finished(false);
4884
4885                        return Err(match error {
4886                            Ok(value) => common::Error::BadRequest(value),
4887                            _ => common::Error::Failure(response),
4888                        });
4889                    }
4890                    let response = {
4891                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4892                        let encoded = common::to_string(&bytes);
4893                        match serde_json::from_str(&encoded) {
4894                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4895                            Err(error) => {
4896                                dlg.response_json_decode_error(&encoded, &error);
4897                                return Err(common::Error::JsonDecodeError(
4898                                    encoded.to_string(),
4899                                    error,
4900                                ));
4901                            }
4902                        }
4903                    };
4904
4905                    dlg.finished(true);
4906                    return Ok(response);
4907                }
4908            }
4909        }
4910    }
4911
4912    /// Name of the parent bucket.
4913    ///
4914    /// Sets the *bucket* path property to the given value.
4915    ///
4916    /// Even though the property as already been set when instantiating this call,
4917    /// we provide this method for API completeness.
4918    pub fn bucket(mut self, new_value: &str) -> AnywhereCachGetCall<'a, C> {
4919        self._bucket = new_value.to_string();
4920        self
4921    }
4922    /// The ID of requested Anywhere Cache instance.
4923    ///
4924    /// Sets the *anywhere cache id* path property to the given value.
4925    ///
4926    /// Even though the property as already been set when instantiating this call,
4927    /// we provide this method for API completeness.
4928    pub fn anywhere_cache_id(mut self, new_value: &str) -> AnywhereCachGetCall<'a, C> {
4929        self._anywhere_cache_id = new_value.to_string();
4930        self
4931    }
4932    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4933    /// while executing the actual API request.
4934    ///
4935    /// ````text
4936    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4937    /// ````
4938    ///
4939    /// Sets the *delegate* property to the given value.
4940    pub fn delegate(
4941        mut self,
4942        new_value: &'a mut dyn common::Delegate,
4943    ) -> AnywhereCachGetCall<'a, C> {
4944        self._delegate = Some(new_value);
4945        self
4946    }
4947
4948    /// Set any additional parameter of the query string used in the request.
4949    /// It should be used to set parameters which are not yet available through their own
4950    /// setters.
4951    ///
4952    /// Please note that this method must not be used to set any of the known parameters
4953    /// which have their own setter method. If done anyway, the request will fail.
4954    ///
4955    /// # Additional Parameters
4956    ///
4957    /// * *alt* (query-string) - Data format for the response.
4958    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4959    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4960    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4961    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4962    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4963    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
4964    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4965    pub fn param<T>(mut self, name: T, value: T) -> AnywhereCachGetCall<'a, C>
4966    where
4967        T: AsRef<str>,
4968    {
4969        self._additional_params
4970            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4971        self
4972    }
4973
4974    /// Identifies the authorization scope for the method you are building.
4975    ///
4976    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4977    /// [`Scope::CloudPlatform`].
4978    ///
4979    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4980    /// tokens for more than one scope.
4981    ///
4982    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4983    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4984    /// sufficient, a read-write scope will do as well.
4985    pub fn add_scope<St>(mut self, scope: St) -> AnywhereCachGetCall<'a, C>
4986    where
4987        St: AsRef<str>,
4988    {
4989        self._scopes.insert(String::from(scope.as_ref()));
4990        self
4991    }
4992    /// Identifies the authorization scope(s) for the method you are building.
4993    ///
4994    /// See [`Self::add_scope()`] for details.
4995    pub fn add_scopes<I, St>(mut self, scopes: I) -> AnywhereCachGetCall<'a, C>
4996    where
4997        I: IntoIterator<Item = St>,
4998        St: AsRef<str>,
4999    {
5000        self._scopes
5001            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5002        self
5003    }
5004
5005    /// Removes all scopes, and no default scope will be used either.
5006    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5007    /// for details).
5008    pub fn clear_scopes(mut self) -> AnywhereCachGetCall<'a, C> {
5009        self._scopes.clear();
5010        self
5011    }
5012}
5013
5014/// Creates an Anywhere Cache instance.
5015///
5016/// A builder for the *insert* method supported by a *anywhereCach* resource.
5017/// It is not used directly, but through a [`AnywhereCachMethods`] instance.
5018///
5019/// # Example
5020///
5021/// Instantiate a resource method builder
5022///
5023/// ```test_harness,no_run
5024/// # extern crate hyper;
5025/// # extern crate hyper_rustls;
5026/// # extern crate google_storage1 as storage1;
5027/// use storage1::api::AnywhereCache;
5028/// # async fn dox() {
5029/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5030///
5031/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5032/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5033/// #     secret,
5034/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5035/// # ).build().await.unwrap();
5036///
5037/// # let client = hyper_util::client::legacy::Client::builder(
5038/// #     hyper_util::rt::TokioExecutor::new()
5039/// # )
5040/// # .build(
5041/// #     hyper_rustls::HttpsConnectorBuilder::new()
5042/// #         .with_native_roots()
5043/// #         .unwrap()
5044/// #         .https_or_http()
5045/// #         .enable_http1()
5046/// #         .build()
5047/// # );
5048/// # let mut hub = Storage::new(client, auth);
5049/// // As the method needs a request, you would usually fill it with the desired information
5050/// // into the respective structure. Some of the parts shown here might not be applicable !
5051/// // Values shown here are possibly random and not representative !
5052/// let mut req = AnywhereCache::default();
5053///
5054/// // You can configure optional parameters by calling the respective setters at will, and
5055/// // execute the final call using `doit()`.
5056/// // Values shown here are possibly random and not representative !
5057/// let result = hub.anywhere_caches().insert(req, "bucket")
5058///              .doit().await;
5059/// # }
5060/// ```
5061pub struct AnywhereCachInsertCall<'a, C>
5062where
5063    C: 'a,
5064{
5065    hub: &'a Storage<C>,
5066    _request: AnywhereCache,
5067    _bucket: String,
5068    _delegate: Option<&'a mut dyn common::Delegate>,
5069    _additional_params: HashMap<String, String>,
5070    _scopes: BTreeSet<String>,
5071}
5072
5073impl<'a, C> common::CallBuilder for AnywhereCachInsertCall<'a, C> {}
5074
5075impl<'a, C> AnywhereCachInsertCall<'a, C>
5076where
5077    C: common::Connector,
5078{
5079    /// Perform the operation you have build so far.
5080    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
5081        use std::borrow::Cow;
5082        use std::io::{Read, Seek};
5083
5084        use common::{url::Params, ToParts};
5085        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5086
5087        let mut dd = common::DefaultDelegate;
5088        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5089        dlg.begin(common::MethodInfo {
5090            id: "storage.anywhereCaches.insert",
5091            http_method: hyper::Method::POST,
5092        });
5093
5094        for &field in ["alt", "bucket"].iter() {
5095            if self._additional_params.contains_key(field) {
5096                dlg.finished(false);
5097                return Err(common::Error::FieldClash(field));
5098            }
5099        }
5100
5101        let mut params = Params::with_capacity(4 + self._additional_params.len());
5102        params.push("bucket", self._bucket);
5103
5104        params.extend(self._additional_params.iter());
5105
5106        params.push("alt", "json");
5107        let mut url = self.hub._base_url.clone() + "b/{bucket}/anywhereCaches";
5108        if self._scopes.is_empty() {
5109            self._scopes
5110                .insert(Scope::CloudPlatform.as_ref().to_string());
5111        }
5112
5113        #[allow(clippy::single_element_loop)]
5114        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
5115            url = params.uri_replacement(url, param_name, find_this, false);
5116        }
5117        {
5118            let to_remove = ["bucket"];
5119            params.remove_params(&to_remove);
5120        }
5121
5122        let url = params.parse_with_url(&url);
5123
5124        let mut json_mime_type = mime::APPLICATION_JSON;
5125        let mut request_value_reader = {
5126            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5127            common::remove_json_null_values(&mut value);
5128            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5129            serde_json::to_writer(&mut dst, &value).unwrap();
5130            dst
5131        };
5132        let request_size = request_value_reader
5133            .seek(std::io::SeekFrom::End(0))
5134            .unwrap();
5135        request_value_reader
5136            .seek(std::io::SeekFrom::Start(0))
5137            .unwrap();
5138
5139        loop {
5140            let token = match self
5141                .hub
5142                .auth
5143                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5144                .await
5145            {
5146                Ok(token) => token,
5147                Err(e) => match dlg.token(e) {
5148                    Ok(token) => token,
5149                    Err(e) => {
5150                        dlg.finished(false);
5151                        return Err(common::Error::MissingToken(e));
5152                    }
5153                },
5154            };
5155            request_value_reader
5156                .seek(std::io::SeekFrom::Start(0))
5157                .unwrap();
5158            let mut req_result = {
5159                let client = &self.hub.client;
5160                dlg.pre_request();
5161                let mut req_builder = hyper::Request::builder()
5162                    .method(hyper::Method::POST)
5163                    .uri(url.as_str())
5164                    .header(USER_AGENT, self.hub._user_agent.clone());
5165
5166                if let Some(token) = token.as_ref() {
5167                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5168                }
5169
5170                let request = req_builder
5171                    .header(CONTENT_TYPE, json_mime_type.to_string())
5172                    .header(CONTENT_LENGTH, request_size as u64)
5173                    .body(common::to_body(
5174                        request_value_reader.get_ref().clone().into(),
5175                    ));
5176
5177                client.request(request.unwrap()).await
5178            };
5179
5180            match req_result {
5181                Err(err) => {
5182                    if let common::Retry::After(d) = dlg.http_error(&err) {
5183                        sleep(d).await;
5184                        continue;
5185                    }
5186                    dlg.finished(false);
5187                    return Err(common::Error::HttpError(err));
5188                }
5189                Ok(res) => {
5190                    let (mut parts, body) = res.into_parts();
5191                    let mut body = common::Body::new(body);
5192                    if !parts.status.is_success() {
5193                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5194                        let error = serde_json::from_str(&common::to_string(&bytes));
5195                        let response = common::to_response(parts, bytes.into());
5196
5197                        if let common::Retry::After(d) =
5198                            dlg.http_failure(&response, error.as_ref().ok())
5199                        {
5200                            sleep(d).await;
5201                            continue;
5202                        }
5203
5204                        dlg.finished(false);
5205
5206                        return Err(match error {
5207                            Ok(value) => common::Error::BadRequest(value),
5208                            _ => common::Error::Failure(response),
5209                        });
5210                    }
5211                    let response = {
5212                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5213                        let encoded = common::to_string(&bytes);
5214                        match serde_json::from_str(&encoded) {
5215                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5216                            Err(error) => {
5217                                dlg.response_json_decode_error(&encoded, &error);
5218                                return Err(common::Error::JsonDecodeError(
5219                                    encoded.to_string(),
5220                                    error,
5221                                ));
5222                            }
5223                        }
5224                    };
5225
5226                    dlg.finished(true);
5227                    return Ok(response);
5228                }
5229            }
5230        }
5231    }
5232
5233    ///
5234    /// Sets the *request* property to the given value.
5235    ///
5236    /// Even though the property as already been set when instantiating this call,
5237    /// we provide this method for API completeness.
5238    pub fn request(mut self, new_value: AnywhereCache) -> AnywhereCachInsertCall<'a, C> {
5239        self._request = new_value;
5240        self
5241    }
5242    /// Name of the parent bucket.
5243    ///
5244    /// Sets the *bucket* path property to the given value.
5245    ///
5246    /// Even though the property as already been set when instantiating this call,
5247    /// we provide this method for API completeness.
5248    pub fn bucket(mut self, new_value: &str) -> AnywhereCachInsertCall<'a, C> {
5249        self._bucket = new_value.to_string();
5250        self
5251    }
5252    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5253    /// while executing the actual API request.
5254    ///
5255    /// ````text
5256    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5257    /// ````
5258    ///
5259    /// Sets the *delegate* property to the given value.
5260    pub fn delegate(
5261        mut self,
5262        new_value: &'a mut dyn common::Delegate,
5263    ) -> AnywhereCachInsertCall<'a, C> {
5264        self._delegate = Some(new_value);
5265        self
5266    }
5267
5268    /// Set any additional parameter of the query string used in the request.
5269    /// It should be used to set parameters which are not yet available through their own
5270    /// setters.
5271    ///
5272    /// Please note that this method must not be used to set any of the known parameters
5273    /// which have their own setter method. If done anyway, the request will fail.
5274    ///
5275    /// # Additional Parameters
5276    ///
5277    /// * *alt* (query-string) - Data format for the response.
5278    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5279    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5280    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5281    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5282    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5283    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
5284    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5285    pub fn param<T>(mut self, name: T, value: T) -> AnywhereCachInsertCall<'a, C>
5286    where
5287        T: AsRef<str>,
5288    {
5289        self._additional_params
5290            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5291        self
5292    }
5293
5294    /// Identifies the authorization scope for the method you are building.
5295    ///
5296    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5297    /// [`Scope::CloudPlatform`].
5298    ///
5299    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5300    /// tokens for more than one scope.
5301    ///
5302    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5303    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5304    /// sufficient, a read-write scope will do as well.
5305    pub fn add_scope<St>(mut self, scope: St) -> AnywhereCachInsertCall<'a, C>
5306    where
5307        St: AsRef<str>,
5308    {
5309        self._scopes.insert(String::from(scope.as_ref()));
5310        self
5311    }
5312    /// Identifies the authorization scope(s) for the method you are building.
5313    ///
5314    /// See [`Self::add_scope()`] for details.
5315    pub fn add_scopes<I, St>(mut self, scopes: I) -> AnywhereCachInsertCall<'a, C>
5316    where
5317        I: IntoIterator<Item = St>,
5318        St: AsRef<str>,
5319    {
5320        self._scopes
5321            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5322        self
5323    }
5324
5325    /// Removes all scopes, and no default scope will be used either.
5326    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5327    /// for details).
5328    pub fn clear_scopes(mut self) -> AnywhereCachInsertCall<'a, C> {
5329        self._scopes.clear();
5330        self
5331    }
5332}
5333
5334/// Returns a list of Anywhere Cache instances of the bucket matching the criteria.
5335///
5336/// A builder for the *list* method supported by a *anywhereCach* resource.
5337/// It is not used directly, but through a [`AnywhereCachMethods`] instance.
5338///
5339/// # Example
5340///
5341/// Instantiate a resource method builder
5342///
5343/// ```test_harness,no_run
5344/// # extern crate hyper;
5345/// # extern crate hyper_rustls;
5346/// # extern crate google_storage1 as storage1;
5347/// # async fn dox() {
5348/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5349///
5350/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5351/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5352/// #     secret,
5353/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5354/// # ).build().await.unwrap();
5355///
5356/// # let client = hyper_util::client::legacy::Client::builder(
5357/// #     hyper_util::rt::TokioExecutor::new()
5358/// # )
5359/// # .build(
5360/// #     hyper_rustls::HttpsConnectorBuilder::new()
5361/// #         .with_native_roots()
5362/// #         .unwrap()
5363/// #         .https_or_http()
5364/// #         .enable_http1()
5365/// #         .build()
5366/// # );
5367/// # let mut hub = Storage::new(client, auth);
5368/// // You can configure optional parameters by calling the respective setters at will, and
5369/// // execute the final call using `doit()`.
5370/// // Values shown here are possibly random and not representative !
5371/// let result = hub.anywhere_caches().list("bucket")
5372///              .page_token("dolor")
5373///              .page_size(-20)
5374///              .doit().await;
5375/// # }
5376/// ```
5377pub struct AnywhereCachListCall<'a, C>
5378where
5379    C: 'a,
5380{
5381    hub: &'a Storage<C>,
5382    _bucket: String,
5383    _page_token: Option<String>,
5384    _page_size: Option<i32>,
5385    _delegate: Option<&'a mut dyn common::Delegate>,
5386    _additional_params: HashMap<String, String>,
5387    _scopes: BTreeSet<String>,
5388}
5389
5390impl<'a, C> common::CallBuilder for AnywhereCachListCall<'a, C> {}
5391
5392impl<'a, C> AnywhereCachListCall<'a, C>
5393where
5394    C: common::Connector,
5395{
5396    /// Perform the operation you have build so far.
5397    pub async fn doit(mut self) -> common::Result<(common::Response, AnywhereCaches)> {
5398        use std::borrow::Cow;
5399        use std::io::{Read, Seek};
5400
5401        use common::{url::Params, ToParts};
5402        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5403
5404        let mut dd = common::DefaultDelegate;
5405        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5406        dlg.begin(common::MethodInfo {
5407            id: "storage.anywhereCaches.list",
5408            http_method: hyper::Method::GET,
5409        });
5410
5411        for &field in ["alt", "bucket", "pageToken", "pageSize"].iter() {
5412            if self._additional_params.contains_key(field) {
5413                dlg.finished(false);
5414                return Err(common::Error::FieldClash(field));
5415            }
5416        }
5417
5418        let mut params = Params::with_capacity(5 + self._additional_params.len());
5419        params.push("bucket", self._bucket);
5420        if let Some(value) = self._page_token.as_ref() {
5421            params.push("pageToken", value);
5422        }
5423        if let Some(value) = self._page_size.as_ref() {
5424            params.push("pageSize", value.to_string());
5425        }
5426
5427        params.extend(self._additional_params.iter());
5428
5429        params.push("alt", "json");
5430        let mut url = self.hub._base_url.clone() + "b/{bucket}/anywhereCaches";
5431        if self._scopes.is_empty() {
5432            self._scopes
5433                .insert(Scope::CloudPlatform.as_ref().to_string());
5434        }
5435
5436        #[allow(clippy::single_element_loop)]
5437        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
5438            url = params.uri_replacement(url, param_name, find_this, false);
5439        }
5440        {
5441            let to_remove = ["bucket"];
5442            params.remove_params(&to_remove);
5443        }
5444
5445        let url = params.parse_with_url(&url);
5446
5447        loop {
5448            let token = match self
5449                .hub
5450                .auth
5451                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5452                .await
5453            {
5454                Ok(token) => token,
5455                Err(e) => match dlg.token(e) {
5456                    Ok(token) => token,
5457                    Err(e) => {
5458                        dlg.finished(false);
5459                        return Err(common::Error::MissingToken(e));
5460                    }
5461                },
5462            };
5463            let mut req_result = {
5464                let client = &self.hub.client;
5465                dlg.pre_request();
5466                let mut req_builder = hyper::Request::builder()
5467                    .method(hyper::Method::GET)
5468                    .uri(url.as_str())
5469                    .header(USER_AGENT, self.hub._user_agent.clone());
5470
5471                if let Some(token) = token.as_ref() {
5472                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5473                }
5474
5475                let request = req_builder
5476                    .header(CONTENT_LENGTH, 0_u64)
5477                    .body(common::to_body::<String>(None));
5478
5479                client.request(request.unwrap()).await
5480            };
5481
5482            match req_result {
5483                Err(err) => {
5484                    if let common::Retry::After(d) = dlg.http_error(&err) {
5485                        sleep(d).await;
5486                        continue;
5487                    }
5488                    dlg.finished(false);
5489                    return Err(common::Error::HttpError(err));
5490                }
5491                Ok(res) => {
5492                    let (mut parts, body) = res.into_parts();
5493                    let mut body = common::Body::new(body);
5494                    if !parts.status.is_success() {
5495                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5496                        let error = serde_json::from_str(&common::to_string(&bytes));
5497                        let response = common::to_response(parts, bytes.into());
5498
5499                        if let common::Retry::After(d) =
5500                            dlg.http_failure(&response, error.as_ref().ok())
5501                        {
5502                            sleep(d).await;
5503                            continue;
5504                        }
5505
5506                        dlg.finished(false);
5507
5508                        return Err(match error {
5509                            Ok(value) => common::Error::BadRequest(value),
5510                            _ => common::Error::Failure(response),
5511                        });
5512                    }
5513                    let response = {
5514                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5515                        let encoded = common::to_string(&bytes);
5516                        match serde_json::from_str(&encoded) {
5517                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5518                            Err(error) => {
5519                                dlg.response_json_decode_error(&encoded, &error);
5520                                return Err(common::Error::JsonDecodeError(
5521                                    encoded.to_string(),
5522                                    error,
5523                                ));
5524                            }
5525                        }
5526                    };
5527
5528                    dlg.finished(true);
5529                    return Ok(response);
5530                }
5531            }
5532        }
5533    }
5534
5535    /// Name of the parent bucket.
5536    ///
5537    /// Sets the *bucket* path property to the given value.
5538    ///
5539    /// Even though the property as already been set when instantiating this call,
5540    /// we provide this method for API completeness.
5541    pub fn bucket(mut self, new_value: &str) -> AnywhereCachListCall<'a, C> {
5542        self._bucket = new_value.to_string();
5543        self
5544    }
5545    /// A previously-returned page token representing part of the larger set of results to view.
5546    ///
5547    /// Sets the *page token* query property to the given value.
5548    pub fn page_token(mut self, new_value: &str) -> AnywhereCachListCall<'a, C> {
5549        self._page_token = Some(new_value.to_string());
5550        self
5551    }
5552    /// Maximum number of items to return in a single page of responses. Maximum 1000.
5553    ///
5554    /// Sets the *page size* query property to the given value.
5555    pub fn page_size(mut self, new_value: i32) -> AnywhereCachListCall<'a, C> {
5556        self._page_size = Some(new_value);
5557        self
5558    }
5559    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5560    /// while executing the actual API request.
5561    ///
5562    /// ````text
5563    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5564    /// ````
5565    ///
5566    /// Sets the *delegate* property to the given value.
5567    pub fn delegate(
5568        mut self,
5569        new_value: &'a mut dyn common::Delegate,
5570    ) -> AnywhereCachListCall<'a, C> {
5571        self._delegate = Some(new_value);
5572        self
5573    }
5574
5575    /// Set any additional parameter of the query string used in the request.
5576    /// It should be used to set parameters which are not yet available through their own
5577    /// setters.
5578    ///
5579    /// Please note that this method must not be used to set any of the known parameters
5580    /// which have their own setter method. If done anyway, the request will fail.
5581    ///
5582    /// # Additional Parameters
5583    ///
5584    /// * *alt* (query-string) - Data format for the response.
5585    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5586    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5587    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5588    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5589    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5590    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
5591    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5592    pub fn param<T>(mut self, name: T, value: T) -> AnywhereCachListCall<'a, C>
5593    where
5594        T: AsRef<str>,
5595    {
5596        self._additional_params
5597            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5598        self
5599    }
5600
5601    /// Identifies the authorization scope for the method you are building.
5602    ///
5603    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5604    /// [`Scope::CloudPlatform`].
5605    ///
5606    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5607    /// tokens for more than one scope.
5608    ///
5609    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5610    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5611    /// sufficient, a read-write scope will do as well.
5612    pub fn add_scope<St>(mut self, scope: St) -> AnywhereCachListCall<'a, C>
5613    where
5614        St: AsRef<str>,
5615    {
5616        self._scopes.insert(String::from(scope.as_ref()));
5617        self
5618    }
5619    /// Identifies the authorization scope(s) for the method you are building.
5620    ///
5621    /// See [`Self::add_scope()`] for details.
5622    pub fn add_scopes<I, St>(mut self, scopes: I) -> AnywhereCachListCall<'a, C>
5623    where
5624        I: IntoIterator<Item = St>,
5625        St: AsRef<str>,
5626    {
5627        self._scopes
5628            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5629        self
5630    }
5631
5632    /// Removes all scopes, and no default scope will be used either.
5633    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5634    /// for details).
5635    pub fn clear_scopes(mut self) -> AnywhereCachListCall<'a, C> {
5636        self._scopes.clear();
5637        self
5638    }
5639}
5640
5641/// Pauses an Anywhere Cache instance.
5642///
5643/// A builder for the *pause* method supported by a *anywhereCach* resource.
5644/// It is not used directly, but through a [`AnywhereCachMethods`] instance.
5645///
5646/// # Example
5647///
5648/// Instantiate a resource method builder
5649///
5650/// ```test_harness,no_run
5651/// # extern crate hyper;
5652/// # extern crate hyper_rustls;
5653/// # extern crate google_storage1 as storage1;
5654/// # async fn dox() {
5655/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5656///
5657/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5658/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5659/// #     secret,
5660/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5661/// # ).build().await.unwrap();
5662///
5663/// # let client = hyper_util::client::legacy::Client::builder(
5664/// #     hyper_util::rt::TokioExecutor::new()
5665/// # )
5666/// # .build(
5667/// #     hyper_rustls::HttpsConnectorBuilder::new()
5668/// #         .with_native_roots()
5669/// #         .unwrap()
5670/// #         .https_or_http()
5671/// #         .enable_http1()
5672/// #         .build()
5673/// # );
5674/// # let mut hub = Storage::new(client, auth);
5675/// // You can configure optional parameters by calling the respective setters at will, and
5676/// // execute the final call using `doit()`.
5677/// // Values shown here are possibly random and not representative !
5678/// let result = hub.anywhere_caches().pause("bucket", "anywhereCacheId")
5679///              .doit().await;
5680/// # }
5681/// ```
5682pub struct AnywhereCachPauseCall<'a, C>
5683where
5684    C: 'a,
5685{
5686    hub: &'a Storage<C>,
5687    _bucket: String,
5688    _anywhere_cache_id: String,
5689    _delegate: Option<&'a mut dyn common::Delegate>,
5690    _additional_params: HashMap<String, String>,
5691    _scopes: BTreeSet<String>,
5692}
5693
5694impl<'a, C> common::CallBuilder for AnywhereCachPauseCall<'a, C> {}
5695
5696impl<'a, C> AnywhereCachPauseCall<'a, C>
5697where
5698    C: common::Connector,
5699{
5700    /// Perform the operation you have build so far.
5701    pub async fn doit(mut self) -> common::Result<(common::Response, AnywhereCache)> {
5702        use std::borrow::Cow;
5703        use std::io::{Read, Seek};
5704
5705        use common::{url::Params, ToParts};
5706        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5707
5708        let mut dd = common::DefaultDelegate;
5709        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5710        dlg.begin(common::MethodInfo {
5711            id: "storage.anywhereCaches.pause",
5712            http_method: hyper::Method::POST,
5713        });
5714
5715        for &field in ["alt", "bucket", "anywhereCacheId"].iter() {
5716            if self._additional_params.contains_key(field) {
5717                dlg.finished(false);
5718                return Err(common::Error::FieldClash(field));
5719            }
5720        }
5721
5722        let mut params = Params::with_capacity(4 + self._additional_params.len());
5723        params.push("bucket", self._bucket);
5724        params.push("anywhereCacheId", self._anywhere_cache_id);
5725
5726        params.extend(self._additional_params.iter());
5727
5728        params.push("alt", "json");
5729        let mut url =
5730            self.hub._base_url.clone() + "b/{bucket}/anywhereCaches/{anywhereCacheId}/pause";
5731        if self._scopes.is_empty() {
5732            self._scopes
5733                .insert(Scope::CloudPlatform.as_ref().to_string());
5734        }
5735
5736        #[allow(clippy::single_element_loop)]
5737        for &(find_this, param_name) in [
5738            ("{bucket}", "bucket"),
5739            ("{anywhereCacheId}", "anywhereCacheId"),
5740        ]
5741        .iter()
5742        {
5743            url = params.uri_replacement(url, param_name, find_this, false);
5744        }
5745        {
5746            let to_remove = ["anywhereCacheId", "bucket"];
5747            params.remove_params(&to_remove);
5748        }
5749
5750        let url = params.parse_with_url(&url);
5751
5752        loop {
5753            let token = match self
5754                .hub
5755                .auth
5756                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5757                .await
5758            {
5759                Ok(token) => token,
5760                Err(e) => match dlg.token(e) {
5761                    Ok(token) => token,
5762                    Err(e) => {
5763                        dlg.finished(false);
5764                        return Err(common::Error::MissingToken(e));
5765                    }
5766                },
5767            };
5768            let mut req_result = {
5769                let client = &self.hub.client;
5770                dlg.pre_request();
5771                let mut req_builder = hyper::Request::builder()
5772                    .method(hyper::Method::POST)
5773                    .uri(url.as_str())
5774                    .header(USER_AGENT, self.hub._user_agent.clone());
5775
5776                if let Some(token) = token.as_ref() {
5777                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5778                }
5779
5780                let request = req_builder
5781                    .header(CONTENT_LENGTH, 0_u64)
5782                    .body(common::to_body::<String>(None));
5783
5784                client.request(request.unwrap()).await
5785            };
5786
5787            match req_result {
5788                Err(err) => {
5789                    if let common::Retry::After(d) = dlg.http_error(&err) {
5790                        sleep(d).await;
5791                        continue;
5792                    }
5793                    dlg.finished(false);
5794                    return Err(common::Error::HttpError(err));
5795                }
5796                Ok(res) => {
5797                    let (mut parts, body) = res.into_parts();
5798                    let mut body = common::Body::new(body);
5799                    if !parts.status.is_success() {
5800                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5801                        let error = serde_json::from_str(&common::to_string(&bytes));
5802                        let response = common::to_response(parts, bytes.into());
5803
5804                        if let common::Retry::After(d) =
5805                            dlg.http_failure(&response, error.as_ref().ok())
5806                        {
5807                            sleep(d).await;
5808                            continue;
5809                        }
5810
5811                        dlg.finished(false);
5812
5813                        return Err(match error {
5814                            Ok(value) => common::Error::BadRequest(value),
5815                            _ => common::Error::Failure(response),
5816                        });
5817                    }
5818                    let response = {
5819                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5820                        let encoded = common::to_string(&bytes);
5821                        match serde_json::from_str(&encoded) {
5822                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5823                            Err(error) => {
5824                                dlg.response_json_decode_error(&encoded, &error);
5825                                return Err(common::Error::JsonDecodeError(
5826                                    encoded.to_string(),
5827                                    error,
5828                                ));
5829                            }
5830                        }
5831                    };
5832
5833                    dlg.finished(true);
5834                    return Ok(response);
5835                }
5836            }
5837        }
5838    }
5839
5840    /// Name of the parent bucket.
5841    ///
5842    /// Sets the *bucket* path property to the given value.
5843    ///
5844    /// Even though the property as already been set when instantiating this call,
5845    /// we provide this method for API completeness.
5846    pub fn bucket(mut self, new_value: &str) -> AnywhereCachPauseCall<'a, C> {
5847        self._bucket = new_value.to_string();
5848        self
5849    }
5850    /// The ID of requested Anywhere Cache instance.
5851    ///
5852    /// Sets the *anywhere cache id* path property to the given value.
5853    ///
5854    /// Even though the property as already been set when instantiating this call,
5855    /// we provide this method for API completeness.
5856    pub fn anywhere_cache_id(mut self, new_value: &str) -> AnywhereCachPauseCall<'a, C> {
5857        self._anywhere_cache_id = new_value.to_string();
5858        self
5859    }
5860    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5861    /// while executing the actual API request.
5862    ///
5863    /// ````text
5864    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5865    /// ````
5866    ///
5867    /// Sets the *delegate* property to the given value.
5868    pub fn delegate(
5869        mut self,
5870        new_value: &'a mut dyn common::Delegate,
5871    ) -> AnywhereCachPauseCall<'a, C> {
5872        self._delegate = Some(new_value);
5873        self
5874    }
5875
5876    /// Set any additional parameter of the query string used in the request.
5877    /// It should be used to set parameters which are not yet available through their own
5878    /// setters.
5879    ///
5880    /// Please note that this method must not be used to set any of the known parameters
5881    /// which have their own setter method. If done anyway, the request will fail.
5882    ///
5883    /// # Additional Parameters
5884    ///
5885    /// * *alt* (query-string) - Data format for the response.
5886    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5887    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5888    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5889    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5890    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5891    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
5892    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5893    pub fn param<T>(mut self, name: T, value: T) -> AnywhereCachPauseCall<'a, C>
5894    where
5895        T: AsRef<str>,
5896    {
5897        self._additional_params
5898            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5899        self
5900    }
5901
5902    /// Identifies the authorization scope for the method you are building.
5903    ///
5904    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5905    /// [`Scope::CloudPlatform`].
5906    ///
5907    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5908    /// tokens for more than one scope.
5909    ///
5910    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5911    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5912    /// sufficient, a read-write scope will do as well.
5913    pub fn add_scope<St>(mut self, scope: St) -> AnywhereCachPauseCall<'a, C>
5914    where
5915        St: AsRef<str>,
5916    {
5917        self._scopes.insert(String::from(scope.as_ref()));
5918        self
5919    }
5920    /// Identifies the authorization scope(s) for the method you are building.
5921    ///
5922    /// See [`Self::add_scope()`] for details.
5923    pub fn add_scopes<I, St>(mut self, scopes: I) -> AnywhereCachPauseCall<'a, C>
5924    where
5925        I: IntoIterator<Item = St>,
5926        St: AsRef<str>,
5927    {
5928        self._scopes
5929            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5930        self
5931    }
5932
5933    /// Removes all scopes, and no default scope will be used either.
5934    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5935    /// for details).
5936    pub fn clear_scopes(mut self) -> AnywhereCachPauseCall<'a, C> {
5937        self._scopes.clear();
5938        self
5939    }
5940}
5941
5942/// Resumes a paused or disabled Anywhere Cache instance.
5943///
5944/// A builder for the *resume* method supported by a *anywhereCach* resource.
5945/// It is not used directly, but through a [`AnywhereCachMethods`] instance.
5946///
5947/// # Example
5948///
5949/// Instantiate a resource method builder
5950///
5951/// ```test_harness,no_run
5952/// # extern crate hyper;
5953/// # extern crate hyper_rustls;
5954/// # extern crate google_storage1 as storage1;
5955/// # async fn dox() {
5956/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5957///
5958/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5959/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5960/// #     secret,
5961/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5962/// # ).build().await.unwrap();
5963///
5964/// # let client = hyper_util::client::legacy::Client::builder(
5965/// #     hyper_util::rt::TokioExecutor::new()
5966/// # )
5967/// # .build(
5968/// #     hyper_rustls::HttpsConnectorBuilder::new()
5969/// #         .with_native_roots()
5970/// #         .unwrap()
5971/// #         .https_or_http()
5972/// #         .enable_http1()
5973/// #         .build()
5974/// # );
5975/// # let mut hub = Storage::new(client, auth);
5976/// // You can configure optional parameters by calling the respective setters at will, and
5977/// // execute the final call using `doit()`.
5978/// // Values shown here are possibly random and not representative !
5979/// let result = hub.anywhere_caches().resume("bucket", "anywhereCacheId")
5980///              .doit().await;
5981/// # }
5982/// ```
5983pub struct AnywhereCachResumeCall<'a, C>
5984where
5985    C: 'a,
5986{
5987    hub: &'a Storage<C>,
5988    _bucket: String,
5989    _anywhere_cache_id: String,
5990    _delegate: Option<&'a mut dyn common::Delegate>,
5991    _additional_params: HashMap<String, String>,
5992    _scopes: BTreeSet<String>,
5993}
5994
5995impl<'a, C> common::CallBuilder for AnywhereCachResumeCall<'a, C> {}
5996
5997impl<'a, C> AnywhereCachResumeCall<'a, C>
5998where
5999    C: common::Connector,
6000{
6001    /// Perform the operation you have build so far.
6002    pub async fn doit(mut self) -> common::Result<(common::Response, AnywhereCache)> {
6003        use std::borrow::Cow;
6004        use std::io::{Read, Seek};
6005
6006        use common::{url::Params, ToParts};
6007        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6008
6009        let mut dd = common::DefaultDelegate;
6010        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6011        dlg.begin(common::MethodInfo {
6012            id: "storage.anywhereCaches.resume",
6013            http_method: hyper::Method::POST,
6014        });
6015
6016        for &field in ["alt", "bucket", "anywhereCacheId"].iter() {
6017            if self._additional_params.contains_key(field) {
6018                dlg.finished(false);
6019                return Err(common::Error::FieldClash(field));
6020            }
6021        }
6022
6023        let mut params = Params::with_capacity(4 + self._additional_params.len());
6024        params.push("bucket", self._bucket);
6025        params.push("anywhereCacheId", self._anywhere_cache_id);
6026
6027        params.extend(self._additional_params.iter());
6028
6029        params.push("alt", "json");
6030        let mut url =
6031            self.hub._base_url.clone() + "b/{bucket}/anywhereCaches/{anywhereCacheId}/resume";
6032        if self._scopes.is_empty() {
6033            self._scopes
6034                .insert(Scope::CloudPlatform.as_ref().to_string());
6035        }
6036
6037        #[allow(clippy::single_element_loop)]
6038        for &(find_this, param_name) in [
6039            ("{bucket}", "bucket"),
6040            ("{anywhereCacheId}", "anywhereCacheId"),
6041        ]
6042        .iter()
6043        {
6044            url = params.uri_replacement(url, param_name, find_this, false);
6045        }
6046        {
6047            let to_remove = ["anywhereCacheId", "bucket"];
6048            params.remove_params(&to_remove);
6049        }
6050
6051        let url = params.parse_with_url(&url);
6052
6053        loop {
6054            let token = match self
6055                .hub
6056                .auth
6057                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6058                .await
6059            {
6060                Ok(token) => token,
6061                Err(e) => match dlg.token(e) {
6062                    Ok(token) => token,
6063                    Err(e) => {
6064                        dlg.finished(false);
6065                        return Err(common::Error::MissingToken(e));
6066                    }
6067                },
6068            };
6069            let mut req_result = {
6070                let client = &self.hub.client;
6071                dlg.pre_request();
6072                let mut req_builder = hyper::Request::builder()
6073                    .method(hyper::Method::POST)
6074                    .uri(url.as_str())
6075                    .header(USER_AGENT, self.hub._user_agent.clone());
6076
6077                if let Some(token) = token.as_ref() {
6078                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6079                }
6080
6081                let request = req_builder
6082                    .header(CONTENT_LENGTH, 0_u64)
6083                    .body(common::to_body::<String>(None));
6084
6085                client.request(request.unwrap()).await
6086            };
6087
6088            match req_result {
6089                Err(err) => {
6090                    if let common::Retry::After(d) = dlg.http_error(&err) {
6091                        sleep(d).await;
6092                        continue;
6093                    }
6094                    dlg.finished(false);
6095                    return Err(common::Error::HttpError(err));
6096                }
6097                Ok(res) => {
6098                    let (mut parts, body) = res.into_parts();
6099                    let mut body = common::Body::new(body);
6100                    if !parts.status.is_success() {
6101                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6102                        let error = serde_json::from_str(&common::to_string(&bytes));
6103                        let response = common::to_response(parts, bytes.into());
6104
6105                        if let common::Retry::After(d) =
6106                            dlg.http_failure(&response, error.as_ref().ok())
6107                        {
6108                            sleep(d).await;
6109                            continue;
6110                        }
6111
6112                        dlg.finished(false);
6113
6114                        return Err(match error {
6115                            Ok(value) => common::Error::BadRequest(value),
6116                            _ => common::Error::Failure(response),
6117                        });
6118                    }
6119                    let response = {
6120                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6121                        let encoded = common::to_string(&bytes);
6122                        match serde_json::from_str(&encoded) {
6123                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6124                            Err(error) => {
6125                                dlg.response_json_decode_error(&encoded, &error);
6126                                return Err(common::Error::JsonDecodeError(
6127                                    encoded.to_string(),
6128                                    error,
6129                                ));
6130                            }
6131                        }
6132                    };
6133
6134                    dlg.finished(true);
6135                    return Ok(response);
6136                }
6137            }
6138        }
6139    }
6140
6141    /// Name of the parent bucket.
6142    ///
6143    /// Sets the *bucket* path property to the given value.
6144    ///
6145    /// Even though the property as already been set when instantiating this call,
6146    /// we provide this method for API completeness.
6147    pub fn bucket(mut self, new_value: &str) -> AnywhereCachResumeCall<'a, C> {
6148        self._bucket = new_value.to_string();
6149        self
6150    }
6151    /// The ID of requested Anywhere Cache instance.
6152    ///
6153    /// Sets the *anywhere cache id* path property to the given value.
6154    ///
6155    /// Even though the property as already been set when instantiating this call,
6156    /// we provide this method for API completeness.
6157    pub fn anywhere_cache_id(mut self, new_value: &str) -> AnywhereCachResumeCall<'a, C> {
6158        self._anywhere_cache_id = new_value.to_string();
6159        self
6160    }
6161    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6162    /// while executing the actual API request.
6163    ///
6164    /// ````text
6165    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6166    /// ````
6167    ///
6168    /// Sets the *delegate* property to the given value.
6169    pub fn delegate(
6170        mut self,
6171        new_value: &'a mut dyn common::Delegate,
6172    ) -> AnywhereCachResumeCall<'a, C> {
6173        self._delegate = Some(new_value);
6174        self
6175    }
6176
6177    /// Set any additional parameter of the query string used in the request.
6178    /// It should be used to set parameters which are not yet available through their own
6179    /// setters.
6180    ///
6181    /// Please note that this method must not be used to set any of the known parameters
6182    /// which have their own setter method. If done anyway, the request will fail.
6183    ///
6184    /// # Additional Parameters
6185    ///
6186    /// * *alt* (query-string) - Data format for the response.
6187    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6188    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6189    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6190    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6191    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6192    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
6193    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6194    pub fn param<T>(mut self, name: T, value: T) -> AnywhereCachResumeCall<'a, C>
6195    where
6196        T: AsRef<str>,
6197    {
6198        self._additional_params
6199            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6200        self
6201    }
6202
6203    /// Identifies the authorization scope for the method you are building.
6204    ///
6205    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6206    /// [`Scope::CloudPlatform`].
6207    ///
6208    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6209    /// tokens for more than one scope.
6210    ///
6211    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6212    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6213    /// sufficient, a read-write scope will do as well.
6214    pub fn add_scope<St>(mut self, scope: St) -> AnywhereCachResumeCall<'a, C>
6215    where
6216        St: AsRef<str>,
6217    {
6218        self._scopes.insert(String::from(scope.as_ref()));
6219        self
6220    }
6221    /// Identifies the authorization scope(s) for the method you are building.
6222    ///
6223    /// See [`Self::add_scope()`] for details.
6224    pub fn add_scopes<I, St>(mut self, scopes: I) -> AnywhereCachResumeCall<'a, C>
6225    where
6226        I: IntoIterator<Item = St>,
6227        St: AsRef<str>,
6228    {
6229        self._scopes
6230            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6231        self
6232    }
6233
6234    /// Removes all scopes, and no default scope will be used either.
6235    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6236    /// for details).
6237    pub fn clear_scopes(mut self) -> AnywhereCachResumeCall<'a, C> {
6238        self._scopes.clear();
6239        self
6240    }
6241}
6242
6243/// Updates the config(ttl and admissionPolicy) of an Anywhere Cache instance.
6244///
6245/// A builder for the *update* method supported by a *anywhereCach* resource.
6246/// It is not used directly, but through a [`AnywhereCachMethods`] instance.
6247///
6248/// # Example
6249///
6250/// Instantiate a resource method builder
6251///
6252/// ```test_harness,no_run
6253/// # extern crate hyper;
6254/// # extern crate hyper_rustls;
6255/// # extern crate google_storage1 as storage1;
6256/// use storage1::api::AnywhereCache;
6257/// # async fn dox() {
6258/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6259///
6260/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6261/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6262/// #     secret,
6263/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6264/// # ).build().await.unwrap();
6265///
6266/// # let client = hyper_util::client::legacy::Client::builder(
6267/// #     hyper_util::rt::TokioExecutor::new()
6268/// # )
6269/// # .build(
6270/// #     hyper_rustls::HttpsConnectorBuilder::new()
6271/// #         .with_native_roots()
6272/// #         .unwrap()
6273/// #         .https_or_http()
6274/// #         .enable_http1()
6275/// #         .build()
6276/// # );
6277/// # let mut hub = Storage::new(client, auth);
6278/// // As the method needs a request, you would usually fill it with the desired information
6279/// // into the respective structure. Some of the parts shown here might not be applicable !
6280/// // Values shown here are possibly random and not representative !
6281/// let mut req = AnywhereCache::default();
6282///
6283/// // You can configure optional parameters by calling the respective setters at will, and
6284/// // execute the final call using `doit()`.
6285/// // Values shown here are possibly random and not representative !
6286/// let result = hub.anywhere_caches().update(req, "bucket", "anywhereCacheId")
6287///              .doit().await;
6288/// # }
6289/// ```
6290pub struct AnywhereCachUpdateCall<'a, C>
6291where
6292    C: 'a,
6293{
6294    hub: &'a Storage<C>,
6295    _request: AnywhereCache,
6296    _bucket: String,
6297    _anywhere_cache_id: String,
6298    _delegate: Option<&'a mut dyn common::Delegate>,
6299    _additional_params: HashMap<String, String>,
6300    _scopes: BTreeSet<String>,
6301}
6302
6303impl<'a, C> common::CallBuilder for AnywhereCachUpdateCall<'a, C> {}
6304
6305impl<'a, C> AnywhereCachUpdateCall<'a, C>
6306where
6307    C: common::Connector,
6308{
6309    /// Perform the operation you have build so far.
6310    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
6311        use std::borrow::Cow;
6312        use std::io::{Read, Seek};
6313
6314        use common::{url::Params, ToParts};
6315        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6316
6317        let mut dd = common::DefaultDelegate;
6318        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6319        dlg.begin(common::MethodInfo {
6320            id: "storage.anywhereCaches.update",
6321            http_method: hyper::Method::PATCH,
6322        });
6323
6324        for &field in ["alt", "bucket", "anywhereCacheId"].iter() {
6325            if self._additional_params.contains_key(field) {
6326                dlg.finished(false);
6327                return Err(common::Error::FieldClash(field));
6328            }
6329        }
6330
6331        let mut params = Params::with_capacity(5 + self._additional_params.len());
6332        params.push("bucket", self._bucket);
6333        params.push("anywhereCacheId", self._anywhere_cache_id);
6334
6335        params.extend(self._additional_params.iter());
6336
6337        params.push("alt", "json");
6338        let mut url = self.hub._base_url.clone() + "b/{bucket}/anywhereCaches/{anywhereCacheId}";
6339        if self._scopes.is_empty() {
6340            self._scopes
6341                .insert(Scope::CloudPlatform.as_ref().to_string());
6342        }
6343
6344        #[allow(clippy::single_element_loop)]
6345        for &(find_this, param_name) in [
6346            ("{bucket}", "bucket"),
6347            ("{anywhereCacheId}", "anywhereCacheId"),
6348        ]
6349        .iter()
6350        {
6351            url = params.uri_replacement(url, param_name, find_this, false);
6352        }
6353        {
6354            let to_remove = ["anywhereCacheId", "bucket"];
6355            params.remove_params(&to_remove);
6356        }
6357
6358        let url = params.parse_with_url(&url);
6359
6360        let mut json_mime_type = mime::APPLICATION_JSON;
6361        let mut request_value_reader = {
6362            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6363            common::remove_json_null_values(&mut value);
6364            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6365            serde_json::to_writer(&mut dst, &value).unwrap();
6366            dst
6367        };
6368        let request_size = request_value_reader
6369            .seek(std::io::SeekFrom::End(0))
6370            .unwrap();
6371        request_value_reader
6372            .seek(std::io::SeekFrom::Start(0))
6373            .unwrap();
6374
6375        loop {
6376            let token = match self
6377                .hub
6378                .auth
6379                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6380                .await
6381            {
6382                Ok(token) => token,
6383                Err(e) => match dlg.token(e) {
6384                    Ok(token) => token,
6385                    Err(e) => {
6386                        dlg.finished(false);
6387                        return Err(common::Error::MissingToken(e));
6388                    }
6389                },
6390            };
6391            request_value_reader
6392                .seek(std::io::SeekFrom::Start(0))
6393                .unwrap();
6394            let mut req_result = {
6395                let client = &self.hub.client;
6396                dlg.pre_request();
6397                let mut req_builder = hyper::Request::builder()
6398                    .method(hyper::Method::PATCH)
6399                    .uri(url.as_str())
6400                    .header(USER_AGENT, self.hub._user_agent.clone());
6401
6402                if let Some(token) = token.as_ref() {
6403                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6404                }
6405
6406                let request = req_builder
6407                    .header(CONTENT_TYPE, json_mime_type.to_string())
6408                    .header(CONTENT_LENGTH, request_size as u64)
6409                    .body(common::to_body(
6410                        request_value_reader.get_ref().clone().into(),
6411                    ));
6412
6413                client.request(request.unwrap()).await
6414            };
6415
6416            match req_result {
6417                Err(err) => {
6418                    if let common::Retry::After(d) = dlg.http_error(&err) {
6419                        sleep(d).await;
6420                        continue;
6421                    }
6422                    dlg.finished(false);
6423                    return Err(common::Error::HttpError(err));
6424                }
6425                Ok(res) => {
6426                    let (mut parts, body) = res.into_parts();
6427                    let mut body = common::Body::new(body);
6428                    if !parts.status.is_success() {
6429                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6430                        let error = serde_json::from_str(&common::to_string(&bytes));
6431                        let response = common::to_response(parts, bytes.into());
6432
6433                        if let common::Retry::After(d) =
6434                            dlg.http_failure(&response, error.as_ref().ok())
6435                        {
6436                            sleep(d).await;
6437                            continue;
6438                        }
6439
6440                        dlg.finished(false);
6441
6442                        return Err(match error {
6443                            Ok(value) => common::Error::BadRequest(value),
6444                            _ => common::Error::Failure(response),
6445                        });
6446                    }
6447                    let response = {
6448                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6449                        let encoded = common::to_string(&bytes);
6450                        match serde_json::from_str(&encoded) {
6451                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6452                            Err(error) => {
6453                                dlg.response_json_decode_error(&encoded, &error);
6454                                return Err(common::Error::JsonDecodeError(
6455                                    encoded.to_string(),
6456                                    error,
6457                                ));
6458                            }
6459                        }
6460                    };
6461
6462                    dlg.finished(true);
6463                    return Ok(response);
6464                }
6465            }
6466        }
6467    }
6468
6469    ///
6470    /// Sets the *request* property to the given value.
6471    ///
6472    /// Even though the property as already been set when instantiating this call,
6473    /// we provide this method for API completeness.
6474    pub fn request(mut self, new_value: AnywhereCache) -> AnywhereCachUpdateCall<'a, C> {
6475        self._request = new_value;
6476        self
6477    }
6478    /// Name of the parent bucket.
6479    ///
6480    /// Sets the *bucket* path property to the given value.
6481    ///
6482    /// Even though the property as already been set when instantiating this call,
6483    /// we provide this method for API completeness.
6484    pub fn bucket(mut self, new_value: &str) -> AnywhereCachUpdateCall<'a, C> {
6485        self._bucket = new_value.to_string();
6486        self
6487    }
6488    /// The ID of requested Anywhere Cache instance.
6489    ///
6490    /// Sets the *anywhere cache id* path property to the given value.
6491    ///
6492    /// Even though the property as already been set when instantiating this call,
6493    /// we provide this method for API completeness.
6494    pub fn anywhere_cache_id(mut self, new_value: &str) -> AnywhereCachUpdateCall<'a, C> {
6495        self._anywhere_cache_id = new_value.to_string();
6496        self
6497    }
6498    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6499    /// while executing the actual API request.
6500    ///
6501    /// ````text
6502    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6503    /// ````
6504    ///
6505    /// Sets the *delegate* property to the given value.
6506    pub fn delegate(
6507        mut self,
6508        new_value: &'a mut dyn common::Delegate,
6509    ) -> AnywhereCachUpdateCall<'a, C> {
6510        self._delegate = Some(new_value);
6511        self
6512    }
6513
6514    /// Set any additional parameter of the query string used in the request.
6515    /// It should be used to set parameters which are not yet available through their own
6516    /// setters.
6517    ///
6518    /// Please note that this method must not be used to set any of the known parameters
6519    /// which have their own setter method. If done anyway, the request will fail.
6520    ///
6521    /// # Additional Parameters
6522    ///
6523    /// * *alt* (query-string) - Data format for the response.
6524    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6525    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6526    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6527    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6528    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6529    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
6530    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6531    pub fn param<T>(mut self, name: T, value: T) -> AnywhereCachUpdateCall<'a, C>
6532    where
6533        T: AsRef<str>,
6534    {
6535        self._additional_params
6536            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6537        self
6538    }
6539
6540    /// Identifies the authorization scope for the method you are building.
6541    ///
6542    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6543    /// [`Scope::CloudPlatform`].
6544    ///
6545    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6546    /// tokens for more than one scope.
6547    ///
6548    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6549    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6550    /// sufficient, a read-write scope will do as well.
6551    pub fn add_scope<St>(mut self, scope: St) -> AnywhereCachUpdateCall<'a, C>
6552    where
6553        St: AsRef<str>,
6554    {
6555        self._scopes.insert(String::from(scope.as_ref()));
6556        self
6557    }
6558    /// Identifies the authorization scope(s) for the method you are building.
6559    ///
6560    /// See [`Self::add_scope()`] for details.
6561    pub fn add_scopes<I, St>(mut self, scopes: I) -> AnywhereCachUpdateCall<'a, C>
6562    where
6563        I: IntoIterator<Item = St>,
6564        St: AsRef<str>,
6565    {
6566        self._scopes
6567            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6568        self
6569    }
6570
6571    /// Removes all scopes, and no default scope will be used either.
6572    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6573    /// for details).
6574    pub fn clear_scopes(mut self) -> AnywhereCachUpdateCall<'a, C> {
6575        self._scopes.clear();
6576        self
6577    }
6578}
6579
6580/// Permanently deletes the ACL entry for the specified entity on the specified bucket.
6581///
6582/// A builder for the *delete* method supported by a *bucketAccessControl* resource.
6583/// It is not used directly, but through a [`BucketAccessControlMethods`] instance.
6584///
6585/// # Example
6586///
6587/// Instantiate a resource method builder
6588///
6589/// ```test_harness,no_run
6590/// # extern crate hyper;
6591/// # extern crate hyper_rustls;
6592/// # extern crate google_storage1 as storage1;
6593/// # async fn dox() {
6594/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6595///
6596/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6597/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6598/// #     secret,
6599/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6600/// # ).build().await.unwrap();
6601///
6602/// # let client = hyper_util::client::legacy::Client::builder(
6603/// #     hyper_util::rt::TokioExecutor::new()
6604/// # )
6605/// # .build(
6606/// #     hyper_rustls::HttpsConnectorBuilder::new()
6607/// #         .with_native_roots()
6608/// #         .unwrap()
6609/// #         .https_or_http()
6610/// #         .enable_http1()
6611/// #         .build()
6612/// # );
6613/// # let mut hub = Storage::new(client, auth);
6614/// // You can configure optional parameters by calling the respective setters at will, and
6615/// // execute the final call using `doit()`.
6616/// // Values shown here are possibly random and not representative !
6617/// let result = hub.bucket_access_controls().delete("bucket", "entity")
6618///              .user_project("no")
6619///              .doit().await;
6620/// # }
6621/// ```
6622pub struct BucketAccessControlDeleteCall<'a, C>
6623where
6624    C: 'a,
6625{
6626    hub: &'a Storage<C>,
6627    _bucket: String,
6628    _entity: String,
6629    _user_project: Option<String>,
6630    _delegate: Option<&'a mut dyn common::Delegate>,
6631    _additional_params: HashMap<String, String>,
6632    _scopes: BTreeSet<String>,
6633}
6634
6635impl<'a, C> common::CallBuilder for BucketAccessControlDeleteCall<'a, C> {}
6636
6637impl<'a, C> BucketAccessControlDeleteCall<'a, C>
6638where
6639    C: common::Connector,
6640{
6641    /// Perform the operation you have build so far.
6642    pub async fn doit(mut self) -> common::Result<common::Response> {
6643        use std::borrow::Cow;
6644        use std::io::{Read, Seek};
6645
6646        use common::{url::Params, ToParts};
6647        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6648
6649        let mut dd = common::DefaultDelegate;
6650        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6651        dlg.begin(common::MethodInfo {
6652            id: "storage.bucketAccessControls.delete",
6653            http_method: hyper::Method::DELETE,
6654        });
6655
6656        for &field in ["bucket", "entity", "userProject"].iter() {
6657            if self._additional_params.contains_key(field) {
6658                dlg.finished(false);
6659                return Err(common::Error::FieldClash(field));
6660            }
6661        }
6662
6663        let mut params = Params::with_capacity(4 + self._additional_params.len());
6664        params.push("bucket", self._bucket);
6665        params.push("entity", self._entity);
6666        if let Some(value) = self._user_project.as_ref() {
6667            params.push("userProject", value);
6668        }
6669
6670        params.extend(self._additional_params.iter());
6671
6672        let mut url = self.hub._base_url.clone() + "b/{bucket}/acl/{entity}";
6673        if self._scopes.is_empty() {
6674            self._scopes
6675                .insert(Scope::CloudPlatform.as_ref().to_string());
6676        }
6677
6678        #[allow(clippy::single_element_loop)]
6679        for &(find_this, param_name) in [("{bucket}", "bucket"), ("{entity}", "entity")].iter() {
6680            url = params.uri_replacement(url, param_name, find_this, false);
6681        }
6682        {
6683            let to_remove = ["entity", "bucket"];
6684            params.remove_params(&to_remove);
6685        }
6686
6687        let url = params.parse_with_url(&url);
6688
6689        loop {
6690            let token = match self
6691                .hub
6692                .auth
6693                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6694                .await
6695            {
6696                Ok(token) => token,
6697                Err(e) => match dlg.token(e) {
6698                    Ok(token) => token,
6699                    Err(e) => {
6700                        dlg.finished(false);
6701                        return Err(common::Error::MissingToken(e));
6702                    }
6703                },
6704            };
6705            let mut req_result = {
6706                let client = &self.hub.client;
6707                dlg.pre_request();
6708                let mut req_builder = hyper::Request::builder()
6709                    .method(hyper::Method::DELETE)
6710                    .uri(url.as_str())
6711                    .header(USER_AGENT, self.hub._user_agent.clone());
6712
6713                if let Some(token) = token.as_ref() {
6714                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6715                }
6716
6717                let request = req_builder
6718                    .header(CONTENT_LENGTH, 0_u64)
6719                    .body(common::to_body::<String>(None));
6720
6721                client.request(request.unwrap()).await
6722            };
6723
6724            match req_result {
6725                Err(err) => {
6726                    if let common::Retry::After(d) = dlg.http_error(&err) {
6727                        sleep(d).await;
6728                        continue;
6729                    }
6730                    dlg.finished(false);
6731                    return Err(common::Error::HttpError(err));
6732                }
6733                Ok(res) => {
6734                    let (mut parts, body) = res.into_parts();
6735                    let mut body = common::Body::new(body);
6736                    if !parts.status.is_success() {
6737                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6738                        let error = serde_json::from_str(&common::to_string(&bytes));
6739                        let response = common::to_response(parts, bytes.into());
6740
6741                        if let common::Retry::After(d) =
6742                            dlg.http_failure(&response, error.as_ref().ok())
6743                        {
6744                            sleep(d).await;
6745                            continue;
6746                        }
6747
6748                        dlg.finished(false);
6749
6750                        return Err(match error {
6751                            Ok(value) => common::Error::BadRequest(value),
6752                            _ => common::Error::Failure(response),
6753                        });
6754                    }
6755                    let response = common::Response::from_parts(parts, body);
6756
6757                    dlg.finished(true);
6758                    return Ok(response);
6759                }
6760            }
6761        }
6762    }
6763
6764    /// Name of a bucket.
6765    ///
6766    /// Sets the *bucket* path property to the given value.
6767    ///
6768    /// Even though the property as already been set when instantiating this call,
6769    /// we provide this method for API completeness.
6770    pub fn bucket(mut self, new_value: &str) -> BucketAccessControlDeleteCall<'a, C> {
6771        self._bucket = new_value.to_string();
6772        self
6773    }
6774    /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
6775    ///
6776    /// Sets the *entity* path property to the given value.
6777    ///
6778    /// Even though the property as already been set when instantiating this call,
6779    /// we provide this method for API completeness.
6780    pub fn entity(mut self, new_value: &str) -> BucketAccessControlDeleteCall<'a, C> {
6781        self._entity = new_value.to_string();
6782        self
6783    }
6784    /// The project to be billed for this request. Required for Requester Pays buckets.
6785    ///
6786    /// Sets the *user project* query property to the given value.
6787    pub fn user_project(mut self, new_value: &str) -> BucketAccessControlDeleteCall<'a, C> {
6788        self._user_project = Some(new_value.to_string());
6789        self
6790    }
6791    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6792    /// while executing the actual API request.
6793    ///
6794    /// ````text
6795    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6796    /// ````
6797    ///
6798    /// Sets the *delegate* property to the given value.
6799    pub fn delegate(
6800        mut self,
6801        new_value: &'a mut dyn common::Delegate,
6802    ) -> BucketAccessControlDeleteCall<'a, C> {
6803        self._delegate = Some(new_value);
6804        self
6805    }
6806
6807    /// Set any additional parameter of the query string used in the request.
6808    /// It should be used to set parameters which are not yet available through their own
6809    /// setters.
6810    ///
6811    /// Please note that this method must not be used to set any of the known parameters
6812    /// which have their own setter method. If done anyway, the request will fail.
6813    ///
6814    /// # Additional Parameters
6815    ///
6816    /// * *alt* (query-string) - Data format for the response.
6817    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6818    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6819    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6820    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6821    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6822    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
6823    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6824    pub fn param<T>(mut self, name: T, value: T) -> BucketAccessControlDeleteCall<'a, C>
6825    where
6826        T: AsRef<str>,
6827    {
6828        self._additional_params
6829            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6830        self
6831    }
6832
6833    /// Identifies the authorization scope for the method you are building.
6834    ///
6835    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6836    /// [`Scope::CloudPlatform`].
6837    ///
6838    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6839    /// tokens for more than one scope.
6840    ///
6841    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6842    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6843    /// sufficient, a read-write scope will do as well.
6844    pub fn add_scope<St>(mut self, scope: St) -> BucketAccessControlDeleteCall<'a, C>
6845    where
6846        St: AsRef<str>,
6847    {
6848        self._scopes.insert(String::from(scope.as_ref()));
6849        self
6850    }
6851    /// Identifies the authorization scope(s) for the method you are building.
6852    ///
6853    /// See [`Self::add_scope()`] for details.
6854    pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketAccessControlDeleteCall<'a, C>
6855    where
6856        I: IntoIterator<Item = St>,
6857        St: AsRef<str>,
6858    {
6859        self._scopes
6860            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6861        self
6862    }
6863
6864    /// Removes all scopes, and no default scope will be used either.
6865    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6866    /// for details).
6867    pub fn clear_scopes(mut self) -> BucketAccessControlDeleteCall<'a, C> {
6868        self._scopes.clear();
6869        self
6870    }
6871}
6872
6873/// Returns the ACL entry for the specified entity on the specified bucket.
6874///
6875/// A builder for the *get* method supported by a *bucketAccessControl* resource.
6876/// It is not used directly, but through a [`BucketAccessControlMethods`] instance.
6877///
6878/// # Example
6879///
6880/// Instantiate a resource method builder
6881///
6882/// ```test_harness,no_run
6883/// # extern crate hyper;
6884/// # extern crate hyper_rustls;
6885/// # extern crate google_storage1 as storage1;
6886/// # async fn dox() {
6887/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6888///
6889/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6890/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6891/// #     secret,
6892/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6893/// # ).build().await.unwrap();
6894///
6895/// # let client = hyper_util::client::legacy::Client::builder(
6896/// #     hyper_util::rt::TokioExecutor::new()
6897/// # )
6898/// # .build(
6899/// #     hyper_rustls::HttpsConnectorBuilder::new()
6900/// #         .with_native_roots()
6901/// #         .unwrap()
6902/// #         .https_or_http()
6903/// #         .enable_http1()
6904/// #         .build()
6905/// # );
6906/// # let mut hub = Storage::new(client, auth);
6907/// // You can configure optional parameters by calling the respective setters at will, and
6908/// // execute the final call using `doit()`.
6909/// // Values shown here are possibly random and not representative !
6910/// let result = hub.bucket_access_controls().get("bucket", "entity")
6911///              .user_project("takimata")
6912///              .doit().await;
6913/// # }
6914/// ```
6915pub struct BucketAccessControlGetCall<'a, C>
6916where
6917    C: 'a,
6918{
6919    hub: &'a Storage<C>,
6920    _bucket: String,
6921    _entity: String,
6922    _user_project: Option<String>,
6923    _delegate: Option<&'a mut dyn common::Delegate>,
6924    _additional_params: HashMap<String, String>,
6925    _scopes: BTreeSet<String>,
6926}
6927
6928impl<'a, C> common::CallBuilder for BucketAccessControlGetCall<'a, C> {}
6929
6930impl<'a, C> BucketAccessControlGetCall<'a, C>
6931where
6932    C: common::Connector,
6933{
6934    /// Perform the operation you have build so far.
6935    pub async fn doit(mut self) -> common::Result<(common::Response, BucketAccessControl)> {
6936        use std::borrow::Cow;
6937        use std::io::{Read, Seek};
6938
6939        use common::{url::Params, ToParts};
6940        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6941
6942        let mut dd = common::DefaultDelegate;
6943        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6944        dlg.begin(common::MethodInfo {
6945            id: "storage.bucketAccessControls.get",
6946            http_method: hyper::Method::GET,
6947        });
6948
6949        for &field in ["alt", "bucket", "entity", "userProject"].iter() {
6950            if self._additional_params.contains_key(field) {
6951                dlg.finished(false);
6952                return Err(common::Error::FieldClash(field));
6953            }
6954        }
6955
6956        let mut params = Params::with_capacity(5 + self._additional_params.len());
6957        params.push("bucket", self._bucket);
6958        params.push("entity", self._entity);
6959        if let Some(value) = self._user_project.as_ref() {
6960            params.push("userProject", value);
6961        }
6962
6963        params.extend(self._additional_params.iter());
6964
6965        params.push("alt", "json");
6966        let mut url = self.hub._base_url.clone() + "b/{bucket}/acl/{entity}";
6967        if self._scopes.is_empty() {
6968            self._scopes
6969                .insert(Scope::CloudPlatform.as_ref().to_string());
6970        }
6971
6972        #[allow(clippy::single_element_loop)]
6973        for &(find_this, param_name) in [("{bucket}", "bucket"), ("{entity}", "entity")].iter() {
6974            url = params.uri_replacement(url, param_name, find_this, false);
6975        }
6976        {
6977            let to_remove = ["entity", "bucket"];
6978            params.remove_params(&to_remove);
6979        }
6980
6981        let url = params.parse_with_url(&url);
6982
6983        loop {
6984            let token = match self
6985                .hub
6986                .auth
6987                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6988                .await
6989            {
6990                Ok(token) => token,
6991                Err(e) => match dlg.token(e) {
6992                    Ok(token) => token,
6993                    Err(e) => {
6994                        dlg.finished(false);
6995                        return Err(common::Error::MissingToken(e));
6996                    }
6997                },
6998            };
6999            let mut req_result = {
7000                let client = &self.hub.client;
7001                dlg.pre_request();
7002                let mut req_builder = hyper::Request::builder()
7003                    .method(hyper::Method::GET)
7004                    .uri(url.as_str())
7005                    .header(USER_AGENT, self.hub._user_agent.clone());
7006
7007                if let Some(token) = token.as_ref() {
7008                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7009                }
7010
7011                let request = req_builder
7012                    .header(CONTENT_LENGTH, 0_u64)
7013                    .body(common::to_body::<String>(None));
7014
7015                client.request(request.unwrap()).await
7016            };
7017
7018            match req_result {
7019                Err(err) => {
7020                    if let common::Retry::After(d) = dlg.http_error(&err) {
7021                        sleep(d).await;
7022                        continue;
7023                    }
7024                    dlg.finished(false);
7025                    return Err(common::Error::HttpError(err));
7026                }
7027                Ok(res) => {
7028                    let (mut parts, body) = res.into_parts();
7029                    let mut body = common::Body::new(body);
7030                    if !parts.status.is_success() {
7031                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7032                        let error = serde_json::from_str(&common::to_string(&bytes));
7033                        let response = common::to_response(parts, bytes.into());
7034
7035                        if let common::Retry::After(d) =
7036                            dlg.http_failure(&response, error.as_ref().ok())
7037                        {
7038                            sleep(d).await;
7039                            continue;
7040                        }
7041
7042                        dlg.finished(false);
7043
7044                        return Err(match error {
7045                            Ok(value) => common::Error::BadRequest(value),
7046                            _ => common::Error::Failure(response),
7047                        });
7048                    }
7049                    let response = {
7050                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7051                        let encoded = common::to_string(&bytes);
7052                        match serde_json::from_str(&encoded) {
7053                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7054                            Err(error) => {
7055                                dlg.response_json_decode_error(&encoded, &error);
7056                                return Err(common::Error::JsonDecodeError(
7057                                    encoded.to_string(),
7058                                    error,
7059                                ));
7060                            }
7061                        }
7062                    };
7063
7064                    dlg.finished(true);
7065                    return Ok(response);
7066                }
7067            }
7068        }
7069    }
7070
7071    /// Name of a bucket.
7072    ///
7073    /// Sets the *bucket* path property to the given value.
7074    ///
7075    /// Even though the property as already been set when instantiating this call,
7076    /// we provide this method for API completeness.
7077    pub fn bucket(mut self, new_value: &str) -> BucketAccessControlGetCall<'a, C> {
7078        self._bucket = new_value.to_string();
7079        self
7080    }
7081    /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
7082    ///
7083    /// Sets the *entity* path property to the given value.
7084    ///
7085    /// Even though the property as already been set when instantiating this call,
7086    /// we provide this method for API completeness.
7087    pub fn entity(mut self, new_value: &str) -> BucketAccessControlGetCall<'a, C> {
7088        self._entity = new_value.to_string();
7089        self
7090    }
7091    /// The project to be billed for this request. Required for Requester Pays buckets.
7092    ///
7093    /// Sets the *user project* query property to the given value.
7094    pub fn user_project(mut self, new_value: &str) -> BucketAccessControlGetCall<'a, C> {
7095        self._user_project = Some(new_value.to_string());
7096        self
7097    }
7098    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7099    /// while executing the actual API request.
7100    ///
7101    /// ````text
7102    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7103    /// ````
7104    ///
7105    /// Sets the *delegate* property to the given value.
7106    pub fn delegate(
7107        mut self,
7108        new_value: &'a mut dyn common::Delegate,
7109    ) -> BucketAccessControlGetCall<'a, C> {
7110        self._delegate = Some(new_value);
7111        self
7112    }
7113
7114    /// Set any additional parameter of the query string used in the request.
7115    /// It should be used to set parameters which are not yet available through their own
7116    /// setters.
7117    ///
7118    /// Please note that this method must not be used to set any of the known parameters
7119    /// which have their own setter method. If done anyway, the request will fail.
7120    ///
7121    /// # Additional Parameters
7122    ///
7123    /// * *alt* (query-string) - Data format for the response.
7124    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7125    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7126    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7127    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7128    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7129    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
7130    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7131    pub fn param<T>(mut self, name: T, value: T) -> BucketAccessControlGetCall<'a, C>
7132    where
7133        T: AsRef<str>,
7134    {
7135        self._additional_params
7136            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7137        self
7138    }
7139
7140    /// Identifies the authorization scope for the method you are building.
7141    ///
7142    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7143    /// [`Scope::CloudPlatform`].
7144    ///
7145    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7146    /// tokens for more than one scope.
7147    ///
7148    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7149    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7150    /// sufficient, a read-write scope will do as well.
7151    pub fn add_scope<St>(mut self, scope: St) -> BucketAccessControlGetCall<'a, C>
7152    where
7153        St: AsRef<str>,
7154    {
7155        self._scopes.insert(String::from(scope.as_ref()));
7156        self
7157    }
7158    /// Identifies the authorization scope(s) for the method you are building.
7159    ///
7160    /// See [`Self::add_scope()`] for details.
7161    pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketAccessControlGetCall<'a, C>
7162    where
7163        I: IntoIterator<Item = St>,
7164        St: AsRef<str>,
7165    {
7166        self._scopes
7167            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7168        self
7169    }
7170
7171    /// Removes all scopes, and no default scope will be used either.
7172    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7173    /// for details).
7174    pub fn clear_scopes(mut self) -> BucketAccessControlGetCall<'a, C> {
7175        self._scopes.clear();
7176        self
7177    }
7178}
7179
7180/// Creates a new ACL entry on the specified bucket.
7181///
7182/// A builder for the *insert* method supported by a *bucketAccessControl* resource.
7183/// It is not used directly, but through a [`BucketAccessControlMethods`] instance.
7184///
7185/// # Example
7186///
7187/// Instantiate a resource method builder
7188///
7189/// ```test_harness,no_run
7190/// # extern crate hyper;
7191/// # extern crate hyper_rustls;
7192/// # extern crate google_storage1 as storage1;
7193/// use storage1::api::BucketAccessControl;
7194/// # async fn dox() {
7195/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7196///
7197/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7198/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7199/// #     secret,
7200/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7201/// # ).build().await.unwrap();
7202///
7203/// # let client = hyper_util::client::legacy::Client::builder(
7204/// #     hyper_util::rt::TokioExecutor::new()
7205/// # )
7206/// # .build(
7207/// #     hyper_rustls::HttpsConnectorBuilder::new()
7208/// #         .with_native_roots()
7209/// #         .unwrap()
7210/// #         .https_or_http()
7211/// #         .enable_http1()
7212/// #         .build()
7213/// # );
7214/// # let mut hub = Storage::new(client, auth);
7215/// // As the method needs a request, you would usually fill it with the desired information
7216/// // into the respective structure. Some of the parts shown here might not be applicable !
7217/// // Values shown here are possibly random and not representative !
7218/// let mut req = BucketAccessControl::default();
7219///
7220/// // You can configure optional parameters by calling the respective setters at will, and
7221/// // execute the final call using `doit()`.
7222/// // Values shown here are possibly random and not representative !
7223/// let result = hub.bucket_access_controls().insert(req, "bucket")
7224///              .user_project("voluptua.")
7225///              .doit().await;
7226/// # }
7227/// ```
7228pub struct BucketAccessControlInsertCall<'a, C>
7229where
7230    C: 'a,
7231{
7232    hub: &'a Storage<C>,
7233    _request: BucketAccessControl,
7234    _bucket: String,
7235    _user_project: Option<String>,
7236    _delegate: Option<&'a mut dyn common::Delegate>,
7237    _additional_params: HashMap<String, String>,
7238    _scopes: BTreeSet<String>,
7239}
7240
7241impl<'a, C> common::CallBuilder for BucketAccessControlInsertCall<'a, C> {}
7242
7243impl<'a, C> BucketAccessControlInsertCall<'a, C>
7244where
7245    C: common::Connector,
7246{
7247    /// Perform the operation you have build so far.
7248    pub async fn doit(mut self) -> common::Result<(common::Response, BucketAccessControl)> {
7249        use std::borrow::Cow;
7250        use std::io::{Read, Seek};
7251
7252        use common::{url::Params, ToParts};
7253        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7254
7255        let mut dd = common::DefaultDelegate;
7256        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7257        dlg.begin(common::MethodInfo {
7258            id: "storage.bucketAccessControls.insert",
7259            http_method: hyper::Method::POST,
7260        });
7261
7262        for &field in ["alt", "bucket", "userProject"].iter() {
7263            if self._additional_params.contains_key(field) {
7264                dlg.finished(false);
7265                return Err(common::Error::FieldClash(field));
7266            }
7267        }
7268
7269        let mut params = Params::with_capacity(5 + self._additional_params.len());
7270        params.push("bucket", self._bucket);
7271        if let Some(value) = self._user_project.as_ref() {
7272            params.push("userProject", value);
7273        }
7274
7275        params.extend(self._additional_params.iter());
7276
7277        params.push("alt", "json");
7278        let mut url = self.hub._base_url.clone() + "b/{bucket}/acl";
7279        if self._scopes.is_empty() {
7280            self._scopes
7281                .insert(Scope::CloudPlatform.as_ref().to_string());
7282        }
7283
7284        #[allow(clippy::single_element_loop)]
7285        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
7286            url = params.uri_replacement(url, param_name, find_this, false);
7287        }
7288        {
7289            let to_remove = ["bucket"];
7290            params.remove_params(&to_remove);
7291        }
7292
7293        let url = params.parse_with_url(&url);
7294
7295        let mut json_mime_type = mime::APPLICATION_JSON;
7296        let mut request_value_reader = {
7297            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7298            common::remove_json_null_values(&mut value);
7299            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7300            serde_json::to_writer(&mut dst, &value).unwrap();
7301            dst
7302        };
7303        let request_size = request_value_reader
7304            .seek(std::io::SeekFrom::End(0))
7305            .unwrap();
7306        request_value_reader
7307            .seek(std::io::SeekFrom::Start(0))
7308            .unwrap();
7309
7310        loop {
7311            let token = match self
7312                .hub
7313                .auth
7314                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7315                .await
7316            {
7317                Ok(token) => token,
7318                Err(e) => match dlg.token(e) {
7319                    Ok(token) => token,
7320                    Err(e) => {
7321                        dlg.finished(false);
7322                        return Err(common::Error::MissingToken(e));
7323                    }
7324                },
7325            };
7326            request_value_reader
7327                .seek(std::io::SeekFrom::Start(0))
7328                .unwrap();
7329            let mut req_result = {
7330                let client = &self.hub.client;
7331                dlg.pre_request();
7332                let mut req_builder = hyper::Request::builder()
7333                    .method(hyper::Method::POST)
7334                    .uri(url.as_str())
7335                    .header(USER_AGENT, self.hub._user_agent.clone());
7336
7337                if let Some(token) = token.as_ref() {
7338                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7339                }
7340
7341                let request = req_builder
7342                    .header(CONTENT_TYPE, json_mime_type.to_string())
7343                    .header(CONTENT_LENGTH, request_size as u64)
7344                    .body(common::to_body(
7345                        request_value_reader.get_ref().clone().into(),
7346                    ));
7347
7348                client.request(request.unwrap()).await
7349            };
7350
7351            match req_result {
7352                Err(err) => {
7353                    if let common::Retry::After(d) = dlg.http_error(&err) {
7354                        sleep(d).await;
7355                        continue;
7356                    }
7357                    dlg.finished(false);
7358                    return Err(common::Error::HttpError(err));
7359                }
7360                Ok(res) => {
7361                    let (mut parts, body) = res.into_parts();
7362                    let mut body = common::Body::new(body);
7363                    if !parts.status.is_success() {
7364                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7365                        let error = serde_json::from_str(&common::to_string(&bytes));
7366                        let response = common::to_response(parts, bytes.into());
7367
7368                        if let common::Retry::After(d) =
7369                            dlg.http_failure(&response, error.as_ref().ok())
7370                        {
7371                            sleep(d).await;
7372                            continue;
7373                        }
7374
7375                        dlg.finished(false);
7376
7377                        return Err(match error {
7378                            Ok(value) => common::Error::BadRequest(value),
7379                            _ => common::Error::Failure(response),
7380                        });
7381                    }
7382                    let response = {
7383                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7384                        let encoded = common::to_string(&bytes);
7385                        match serde_json::from_str(&encoded) {
7386                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7387                            Err(error) => {
7388                                dlg.response_json_decode_error(&encoded, &error);
7389                                return Err(common::Error::JsonDecodeError(
7390                                    encoded.to_string(),
7391                                    error,
7392                                ));
7393                            }
7394                        }
7395                    };
7396
7397                    dlg.finished(true);
7398                    return Ok(response);
7399                }
7400            }
7401        }
7402    }
7403
7404    ///
7405    /// Sets the *request* property to the given value.
7406    ///
7407    /// Even though the property as already been set when instantiating this call,
7408    /// we provide this method for API completeness.
7409    pub fn request(
7410        mut self,
7411        new_value: BucketAccessControl,
7412    ) -> BucketAccessControlInsertCall<'a, C> {
7413        self._request = new_value;
7414        self
7415    }
7416    /// Name of a bucket.
7417    ///
7418    /// Sets the *bucket* path property to the given value.
7419    ///
7420    /// Even though the property as already been set when instantiating this call,
7421    /// we provide this method for API completeness.
7422    pub fn bucket(mut self, new_value: &str) -> BucketAccessControlInsertCall<'a, C> {
7423        self._bucket = new_value.to_string();
7424        self
7425    }
7426    /// The project to be billed for this request. Required for Requester Pays buckets.
7427    ///
7428    /// Sets the *user project* query property to the given value.
7429    pub fn user_project(mut self, new_value: &str) -> BucketAccessControlInsertCall<'a, C> {
7430        self._user_project = Some(new_value.to_string());
7431        self
7432    }
7433    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7434    /// while executing the actual API request.
7435    ///
7436    /// ````text
7437    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7438    /// ````
7439    ///
7440    /// Sets the *delegate* property to the given value.
7441    pub fn delegate(
7442        mut self,
7443        new_value: &'a mut dyn common::Delegate,
7444    ) -> BucketAccessControlInsertCall<'a, C> {
7445        self._delegate = Some(new_value);
7446        self
7447    }
7448
7449    /// Set any additional parameter of the query string used in the request.
7450    /// It should be used to set parameters which are not yet available through their own
7451    /// setters.
7452    ///
7453    /// Please note that this method must not be used to set any of the known parameters
7454    /// which have their own setter method. If done anyway, the request will fail.
7455    ///
7456    /// # Additional Parameters
7457    ///
7458    /// * *alt* (query-string) - Data format for the response.
7459    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7460    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7461    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7462    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7463    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7464    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
7465    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7466    pub fn param<T>(mut self, name: T, value: T) -> BucketAccessControlInsertCall<'a, C>
7467    where
7468        T: AsRef<str>,
7469    {
7470        self._additional_params
7471            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7472        self
7473    }
7474
7475    /// Identifies the authorization scope for the method you are building.
7476    ///
7477    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7478    /// [`Scope::CloudPlatform`].
7479    ///
7480    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7481    /// tokens for more than one scope.
7482    ///
7483    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7484    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7485    /// sufficient, a read-write scope will do as well.
7486    pub fn add_scope<St>(mut self, scope: St) -> BucketAccessControlInsertCall<'a, C>
7487    where
7488        St: AsRef<str>,
7489    {
7490        self._scopes.insert(String::from(scope.as_ref()));
7491        self
7492    }
7493    /// Identifies the authorization scope(s) for the method you are building.
7494    ///
7495    /// See [`Self::add_scope()`] for details.
7496    pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketAccessControlInsertCall<'a, C>
7497    where
7498        I: IntoIterator<Item = St>,
7499        St: AsRef<str>,
7500    {
7501        self._scopes
7502            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7503        self
7504    }
7505
7506    /// Removes all scopes, and no default scope will be used either.
7507    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7508    /// for details).
7509    pub fn clear_scopes(mut self) -> BucketAccessControlInsertCall<'a, C> {
7510        self._scopes.clear();
7511        self
7512    }
7513}
7514
7515/// Retrieves ACL entries on the specified bucket.
7516///
7517/// A builder for the *list* method supported by a *bucketAccessControl* resource.
7518/// It is not used directly, but through a [`BucketAccessControlMethods`] instance.
7519///
7520/// # Example
7521///
7522/// Instantiate a resource method builder
7523///
7524/// ```test_harness,no_run
7525/// # extern crate hyper;
7526/// # extern crate hyper_rustls;
7527/// # extern crate google_storage1 as storage1;
7528/// # async fn dox() {
7529/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7530///
7531/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7532/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7533/// #     secret,
7534/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7535/// # ).build().await.unwrap();
7536///
7537/// # let client = hyper_util::client::legacy::Client::builder(
7538/// #     hyper_util::rt::TokioExecutor::new()
7539/// # )
7540/// # .build(
7541/// #     hyper_rustls::HttpsConnectorBuilder::new()
7542/// #         .with_native_roots()
7543/// #         .unwrap()
7544/// #         .https_or_http()
7545/// #         .enable_http1()
7546/// #         .build()
7547/// # );
7548/// # let mut hub = Storage::new(client, auth);
7549/// // You can configure optional parameters by calling the respective setters at will, and
7550/// // execute the final call using `doit()`.
7551/// // Values shown here are possibly random and not representative !
7552/// let result = hub.bucket_access_controls().list("bucket")
7553///              .user_project("erat")
7554///              .doit().await;
7555/// # }
7556/// ```
7557pub struct BucketAccessControlListCall<'a, C>
7558where
7559    C: 'a,
7560{
7561    hub: &'a Storage<C>,
7562    _bucket: String,
7563    _user_project: Option<String>,
7564    _delegate: Option<&'a mut dyn common::Delegate>,
7565    _additional_params: HashMap<String, String>,
7566    _scopes: BTreeSet<String>,
7567}
7568
7569impl<'a, C> common::CallBuilder for BucketAccessControlListCall<'a, C> {}
7570
7571impl<'a, C> BucketAccessControlListCall<'a, C>
7572where
7573    C: common::Connector,
7574{
7575    /// Perform the operation you have build so far.
7576    pub async fn doit(mut self) -> common::Result<(common::Response, BucketAccessControls)> {
7577        use std::borrow::Cow;
7578        use std::io::{Read, Seek};
7579
7580        use common::{url::Params, ToParts};
7581        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7582
7583        let mut dd = common::DefaultDelegate;
7584        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7585        dlg.begin(common::MethodInfo {
7586            id: "storage.bucketAccessControls.list",
7587            http_method: hyper::Method::GET,
7588        });
7589
7590        for &field in ["alt", "bucket", "userProject"].iter() {
7591            if self._additional_params.contains_key(field) {
7592                dlg.finished(false);
7593                return Err(common::Error::FieldClash(field));
7594            }
7595        }
7596
7597        let mut params = Params::with_capacity(4 + self._additional_params.len());
7598        params.push("bucket", self._bucket);
7599        if let Some(value) = self._user_project.as_ref() {
7600            params.push("userProject", value);
7601        }
7602
7603        params.extend(self._additional_params.iter());
7604
7605        params.push("alt", "json");
7606        let mut url = self.hub._base_url.clone() + "b/{bucket}/acl";
7607        if self._scopes.is_empty() {
7608            self._scopes
7609                .insert(Scope::CloudPlatform.as_ref().to_string());
7610        }
7611
7612        #[allow(clippy::single_element_loop)]
7613        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
7614            url = params.uri_replacement(url, param_name, find_this, false);
7615        }
7616        {
7617            let to_remove = ["bucket"];
7618            params.remove_params(&to_remove);
7619        }
7620
7621        let url = params.parse_with_url(&url);
7622
7623        loop {
7624            let token = match self
7625                .hub
7626                .auth
7627                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7628                .await
7629            {
7630                Ok(token) => token,
7631                Err(e) => match dlg.token(e) {
7632                    Ok(token) => token,
7633                    Err(e) => {
7634                        dlg.finished(false);
7635                        return Err(common::Error::MissingToken(e));
7636                    }
7637                },
7638            };
7639            let mut req_result = {
7640                let client = &self.hub.client;
7641                dlg.pre_request();
7642                let mut req_builder = hyper::Request::builder()
7643                    .method(hyper::Method::GET)
7644                    .uri(url.as_str())
7645                    .header(USER_AGENT, self.hub._user_agent.clone());
7646
7647                if let Some(token) = token.as_ref() {
7648                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7649                }
7650
7651                let request = req_builder
7652                    .header(CONTENT_LENGTH, 0_u64)
7653                    .body(common::to_body::<String>(None));
7654
7655                client.request(request.unwrap()).await
7656            };
7657
7658            match req_result {
7659                Err(err) => {
7660                    if let common::Retry::After(d) = dlg.http_error(&err) {
7661                        sleep(d).await;
7662                        continue;
7663                    }
7664                    dlg.finished(false);
7665                    return Err(common::Error::HttpError(err));
7666                }
7667                Ok(res) => {
7668                    let (mut parts, body) = res.into_parts();
7669                    let mut body = common::Body::new(body);
7670                    if !parts.status.is_success() {
7671                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7672                        let error = serde_json::from_str(&common::to_string(&bytes));
7673                        let response = common::to_response(parts, bytes.into());
7674
7675                        if let common::Retry::After(d) =
7676                            dlg.http_failure(&response, error.as_ref().ok())
7677                        {
7678                            sleep(d).await;
7679                            continue;
7680                        }
7681
7682                        dlg.finished(false);
7683
7684                        return Err(match error {
7685                            Ok(value) => common::Error::BadRequest(value),
7686                            _ => common::Error::Failure(response),
7687                        });
7688                    }
7689                    let response = {
7690                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7691                        let encoded = common::to_string(&bytes);
7692                        match serde_json::from_str(&encoded) {
7693                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7694                            Err(error) => {
7695                                dlg.response_json_decode_error(&encoded, &error);
7696                                return Err(common::Error::JsonDecodeError(
7697                                    encoded.to_string(),
7698                                    error,
7699                                ));
7700                            }
7701                        }
7702                    };
7703
7704                    dlg.finished(true);
7705                    return Ok(response);
7706                }
7707            }
7708        }
7709    }
7710
7711    /// Name of a bucket.
7712    ///
7713    /// Sets the *bucket* path property to the given value.
7714    ///
7715    /// Even though the property as already been set when instantiating this call,
7716    /// we provide this method for API completeness.
7717    pub fn bucket(mut self, new_value: &str) -> BucketAccessControlListCall<'a, C> {
7718        self._bucket = new_value.to_string();
7719        self
7720    }
7721    /// The project to be billed for this request. Required for Requester Pays buckets.
7722    ///
7723    /// Sets the *user project* query property to the given value.
7724    pub fn user_project(mut self, new_value: &str) -> BucketAccessControlListCall<'a, C> {
7725        self._user_project = Some(new_value.to_string());
7726        self
7727    }
7728    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7729    /// while executing the actual API request.
7730    ///
7731    /// ````text
7732    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7733    /// ````
7734    ///
7735    /// Sets the *delegate* property to the given value.
7736    pub fn delegate(
7737        mut self,
7738        new_value: &'a mut dyn common::Delegate,
7739    ) -> BucketAccessControlListCall<'a, C> {
7740        self._delegate = Some(new_value);
7741        self
7742    }
7743
7744    /// Set any additional parameter of the query string used in the request.
7745    /// It should be used to set parameters which are not yet available through their own
7746    /// setters.
7747    ///
7748    /// Please note that this method must not be used to set any of the known parameters
7749    /// which have their own setter method. If done anyway, the request will fail.
7750    ///
7751    /// # Additional Parameters
7752    ///
7753    /// * *alt* (query-string) - Data format for the response.
7754    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7755    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7756    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7757    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7758    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7759    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
7760    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7761    pub fn param<T>(mut self, name: T, value: T) -> BucketAccessControlListCall<'a, C>
7762    where
7763        T: AsRef<str>,
7764    {
7765        self._additional_params
7766            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7767        self
7768    }
7769
7770    /// Identifies the authorization scope for the method you are building.
7771    ///
7772    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7773    /// [`Scope::CloudPlatform`].
7774    ///
7775    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7776    /// tokens for more than one scope.
7777    ///
7778    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7779    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7780    /// sufficient, a read-write scope will do as well.
7781    pub fn add_scope<St>(mut self, scope: St) -> BucketAccessControlListCall<'a, C>
7782    where
7783        St: AsRef<str>,
7784    {
7785        self._scopes.insert(String::from(scope.as_ref()));
7786        self
7787    }
7788    /// Identifies the authorization scope(s) for the method you are building.
7789    ///
7790    /// See [`Self::add_scope()`] for details.
7791    pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketAccessControlListCall<'a, C>
7792    where
7793        I: IntoIterator<Item = St>,
7794        St: AsRef<str>,
7795    {
7796        self._scopes
7797            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7798        self
7799    }
7800
7801    /// Removes all scopes, and no default scope will be used either.
7802    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7803    /// for details).
7804    pub fn clear_scopes(mut self) -> BucketAccessControlListCall<'a, C> {
7805        self._scopes.clear();
7806        self
7807    }
7808}
7809
7810/// Patches an ACL entry on the specified bucket.
7811///
7812/// A builder for the *patch* method supported by a *bucketAccessControl* resource.
7813/// It is not used directly, but through a [`BucketAccessControlMethods`] instance.
7814///
7815/// # Example
7816///
7817/// Instantiate a resource method builder
7818///
7819/// ```test_harness,no_run
7820/// # extern crate hyper;
7821/// # extern crate hyper_rustls;
7822/// # extern crate google_storage1 as storage1;
7823/// use storage1::api::BucketAccessControl;
7824/// # async fn dox() {
7825/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7826///
7827/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7828/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7829/// #     secret,
7830/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7831/// # ).build().await.unwrap();
7832///
7833/// # let client = hyper_util::client::legacy::Client::builder(
7834/// #     hyper_util::rt::TokioExecutor::new()
7835/// # )
7836/// # .build(
7837/// #     hyper_rustls::HttpsConnectorBuilder::new()
7838/// #         .with_native_roots()
7839/// #         .unwrap()
7840/// #         .https_or_http()
7841/// #         .enable_http1()
7842/// #         .build()
7843/// # );
7844/// # let mut hub = Storage::new(client, auth);
7845/// // As the method needs a request, you would usually fill it with the desired information
7846/// // into the respective structure. Some of the parts shown here might not be applicable !
7847/// // Values shown here are possibly random and not representative !
7848/// let mut req = BucketAccessControl::default();
7849///
7850/// // You can configure optional parameters by calling the respective setters at will, and
7851/// // execute the final call using `doit()`.
7852/// // Values shown here are possibly random and not representative !
7853/// let result = hub.bucket_access_controls().patch(req, "bucket", "entity")
7854///              .user_project("sed")
7855///              .doit().await;
7856/// # }
7857/// ```
7858pub struct BucketAccessControlPatchCall<'a, C>
7859where
7860    C: 'a,
7861{
7862    hub: &'a Storage<C>,
7863    _request: BucketAccessControl,
7864    _bucket: String,
7865    _entity: String,
7866    _user_project: Option<String>,
7867    _delegate: Option<&'a mut dyn common::Delegate>,
7868    _additional_params: HashMap<String, String>,
7869    _scopes: BTreeSet<String>,
7870}
7871
7872impl<'a, C> common::CallBuilder for BucketAccessControlPatchCall<'a, C> {}
7873
7874impl<'a, C> BucketAccessControlPatchCall<'a, C>
7875where
7876    C: common::Connector,
7877{
7878    /// Perform the operation you have build so far.
7879    pub async fn doit(mut self) -> common::Result<(common::Response, BucketAccessControl)> {
7880        use std::borrow::Cow;
7881        use std::io::{Read, Seek};
7882
7883        use common::{url::Params, ToParts};
7884        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7885
7886        let mut dd = common::DefaultDelegate;
7887        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7888        dlg.begin(common::MethodInfo {
7889            id: "storage.bucketAccessControls.patch",
7890            http_method: hyper::Method::PATCH,
7891        });
7892
7893        for &field in ["alt", "bucket", "entity", "userProject"].iter() {
7894            if self._additional_params.contains_key(field) {
7895                dlg.finished(false);
7896                return Err(common::Error::FieldClash(field));
7897            }
7898        }
7899
7900        let mut params = Params::with_capacity(6 + self._additional_params.len());
7901        params.push("bucket", self._bucket);
7902        params.push("entity", self._entity);
7903        if let Some(value) = self._user_project.as_ref() {
7904            params.push("userProject", value);
7905        }
7906
7907        params.extend(self._additional_params.iter());
7908
7909        params.push("alt", "json");
7910        let mut url = self.hub._base_url.clone() + "b/{bucket}/acl/{entity}";
7911        if self._scopes.is_empty() {
7912            self._scopes
7913                .insert(Scope::CloudPlatform.as_ref().to_string());
7914        }
7915
7916        #[allow(clippy::single_element_loop)]
7917        for &(find_this, param_name) in [("{bucket}", "bucket"), ("{entity}", "entity")].iter() {
7918            url = params.uri_replacement(url, param_name, find_this, false);
7919        }
7920        {
7921            let to_remove = ["entity", "bucket"];
7922            params.remove_params(&to_remove);
7923        }
7924
7925        let url = params.parse_with_url(&url);
7926
7927        let mut json_mime_type = mime::APPLICATION_JSON;
7928        let mut request_value_reader = {
7929            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7930            common::remove_json_null_values(&mut value);
7931            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7932            serde_json::to_writer(&mut dst, &value).unwrap();
7933            dst
7934        };
7935        let request_size = request_value_reader
7936            .seek(std::io::SeekFrom::End(0))
7937            .unwrap();
7938        request_value_reader
7939            .seek(std::io::SeekFrom::Start(0))
7940            .unwrap();
7941
7942        loop {
7943            let token = match self
7944                .hub
7945                .auth
7946                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7947                .await
7948            {
7949                Ok(token) => token,
7950                Err(e) => match dlg.token(e) {
7951                    Ok(token) => token,
7952                    Err(e) => {
7953                        dlg.finished(false);
7954                        return Err(common::Error::MissingToken(e));
7955                    }
7956                },
7957            };
7958            request_value_reader
7959                .seek(std::io::SeekFrom::Start(0))
7960                .unwrap();
7961            let mut req_result = {
7962                let client = &self.hub.client;
7963                dlg.pre_request();
7964                let mut req_builder = hyper::Request::builder()
7965                    .method(hyper::Method::PATCH)
7966                    .uri(url.as_str())
7967                    .header(USER_AGENT, self.hub._user_agent.clone());
7968
7969                if let Some(token) = token.as_ref() {
7970                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7971                }
7972
7973                let request = req_builder
7974                    .header(CONTENT_TYPE, json_mime_type.to_string())
7975                    .header(CONTENT_LENGTH, request_size as u64)
7976                    .body(common::to_body(
7977                        request_value_reader.get_ref().clone().into(),
7978                    ));
7979
7980                client.request(request.unwrap()).await
7981            };
7982
7983            match req_result {
7984                Err(err) => {
7985                    if let common::Retry::After(d) = dlg.http_error(&err) {
7986                        sleep(d).await;
7987                        continue;
7988                    }
7989                    dlg.finished(false);
7990                    return Err(common::Error::HttpError(err));
7991                }
7992                Ok(res) => {
7993                    let (mut parts, body) = res.into_parts();
7994                    let mut body = common::Body::new(body);
7995                    if !parts.status.is_success() {
7996                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7997                        let error = serde_json::from_str(&common::to_string(&bytes));
7998                        let response = common::to_response(parts, bytes.into());
7999
8000                        if let common::Retry::After(d) =
8001                            dlg.http_failure(&response, error.as_ref().ok())
8002                        {
8003                            sleep(d).await;
8004                            continue;
8005                        }
8006
8007                        dlg.finished(false);
8008
8009                        return Err(match error {
8010                            Ok(value) => common::Error::BadRequest(value),
8011                            _ => common::Error::Failure(response),
8012                        });
8013                    }
8014                    let response = {
8015                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8016                        let encoded = common::to_string(&bytes);
8017                        match serde_json::from_str(&encoded) {
8018                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8019                            Err(error) => {
8020                                dlg.response_json_decode_error(&encoded, &error);
8021                                return Err(common::Error::JsonDecodeError(
8022                                    encoded.to_string(),
8023                                    error,
8024                                ));
8025                            }
8026                        }
8027                    };
8028
8029                    dlg.finished(true);
8030                    return Ok(response);
8031                }
8032            }
8033        }
8034    }
8035
8036    ///
8037    /// Sets the *request* property to the given value.
8038    ///
8039    /// Even though the property as already been set when instantiating this call,
8040    /// we provide this method for API completeness.
8041    pub fn request(
8042        mut self,
8043        new_value: BucketAccessControl,
8044    ) -> BucketAccessControlPatchCall<'a, C> {
8045        self._request = new_value;
8046        self
8047    }
8048    /// Name of a bucket.
8049    ///
8050    /// Sets the *bucket* path property to the given value.
8051    ///
8052    /// Even though the property as already been set when instantiating this call,
8053    /// we provide this method for API completeness.
8054    pub fn bucket(mut self, new_value: &str) -> BucketAccessControlPatchCall<'a, C> {
8055        self._bucket = new_value.to_string();
8056        self
8057    }
8058    /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
8059    ///
8060    /// Sets the *entity* path property to the given value.
8061    ///
8062    /// Even though the property as already been set when instantiating this call,
8063    /// we provide this method for API completeness.
8064    pub fn entity(mut self, new_value: &str) -> BucketAccessControlPatchCall<'a, C> {
8065        self._entity = new_value.to_string();
8066        self
8067    }
8068    /// The project to be billed for this request. Required for Requester Pays buckets.
8069    ///
8070    /// Sets the *user project* query property to the given value.
8071    pub fn user_project(mut self, new_value: &str) -> BucketAccessControlPatchCall<'a, C> {
8072        self._user_project = Some(new_value.to_string());
8073        self
8074    }
8075    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8076    /// while executing the actual API request.
8077    ///
8078    /// ````text
8079    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8080    /// ````
8081    ///
8082    /// Sets the *delegate* property to the given value.
8083    pub fn delegate(
8084        mut self,
8085        new_value: &'a mut dyn common::Delegate,
8086    ) -> BucketAccessControlPatchCall<'a, C> {
8087        self._delegate = Some(new_value);
8088        self
8089    }
8090
8091    /// Set any additional parameter of the query string used in the request.
8092    /// It should be used to set parameters which are not yet available through their own
8093    /// setters.
8094    ///
8095    /// Please note that this method must not be used to set any of the known parameters
8096    /// which have their own setter method. If done anyway, the request will fail.
8097    ///
8098    /// # Additional Parameters
8099    ///
8100    /// * *alt* (query-string) - Data format for the response.
8101    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8102    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8103    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8104    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8105    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8106    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
8107    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8108    pub fn param<T>(mut self, name: T, value: T) -> BucketAccessControlPatchCall<'a, C>
8109    where
8110        T: AsRef<str>,
8111    {
8112        self._additional_params
8113            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8114        self
8115    }
8116
8117    /// Identifies the authorization scope for the method you are building.
8118    ///
8119    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8120    /// [`Scope::CloudPlatform`].
8121    ///
8122    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8123    /// tokens for more than one scope.
8124    ///
8125    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8126    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8127    /// sufficient, a read-write scope will do as well.
8128    pub fn add_scope<St>(mut self, scope: St) -> BucketAccessControlPatchCall<'a, C>
8129    where
8130        St: AsRef<str>,
8131    {
8132        self._scopes.insert(String::from(scope.as_ref()));
8133        self
8134    }
8135    /// Identifies the authorization scope(s) for the method you are building.
8136    ///
8137    /// See [`Self::add_scope()`] for details.
8138    pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketAccessControlPatchCall<'a, C>
8139    where
8140        I: IntoIterator<Item = St>,
8141        St: AsRef<str>,
8142    {
8143        self._scopes
8144            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8145        self
8146    }
8147
8148    /// Removes all scopes, and no default scope will be used either.
8149    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8150    /// for details).
8151    pub fn clear_scopes(mut self) -> BucketAccessControlPatchCall<'a, C> {
8152        self._scopes.clear();
8153        self
8154    }
8155}
8156
8157/// Updates an ACL entry on the specified bucket.
8158///
8159/// A builder for the *update* method supported by a *bucketAccessControl* resource.
8160/// It is not used directly, but through a [`BucketAccessControlMethods`] instance.
8161///
8162/// # Example
8163///
8164/// Instantiate a resource method builder
8165///
8166/// ```test_harness,no_run
8167/// # extern crate hyper;
8168/// # extern crate hyper_rustls;
8169/// # extern crate google_storage1 as storage1;
8170/// use storage1::api::BucketAccessControl;
8171/// # async fn dox() {
8172/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8173///
8174/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8175/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8176/// #     secret,
8177/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8178/// # ).build().await.unwrap();
8179///
8180/// # let client = hyper_util::client::legacy::Client::builder(
8181/// #     hyper_util::rt::TokioExecutor::new()
8182/// # )
8183/// # .build(
8184/// #     hyper_rustls::HttpsConnectorBuilder::new()
8185/// #         .with_native_roots()
8186/// #         .unwrap()
8187/// #         .https_or_http()
8188/// #         .enable_http1()
8189/// #         .build()
8190/// # );
8191/// # let mut hub = Storage::new(client, auth);
8192/// // As the method needs a request, you would usually fill it with the desired information
8193/// // into the respective structure. Some of the parts shown here might not be applicable !
8194/// // Values shown here are possibly random and not representative !
8195/// let mut req = BucketAccessControl::default();
8196///
8197/// // You can configure optional parameters by calling the respective setters at will, and
8198/// // execute the final call using `doit()`.
8199/// // Values shown here are possibly random and not representative !
8200/// let result = hub.bucket_access_controls().update(req, "bucket", "entity")
8201///              .user_project("gubergren")
8202///              .doit().await;
8203/// # }
8204/// ```
8205pub struct BucketAccessControlUpdateCall<'a, C>
8206where
8207    C: 'a,
8208{
8209    hub: &'a Storage<C>,
8210    _request: BucketAccessControl,
8211    _bucket: String,
8212    _entity: String,
8213    _user_project: Option<String>,
8214    _delegate: Option<&'a mut dyn common::Delegate>,
8215    _additional_params: HashMap<String, String>,
8216    _scopes: BTreeSet<String>,
8217}
8218
8219impl<'a, C> common::CallBuilder for BucketAccessControlUpdateCall<'a, C> {}
8220
8221impl<'a, C> BucketAccessControlUpdateCall<'a, C>
8222where
8223    C: common::Connector,
8224{
8225    /// Perform the operation you have build so far.
8226    pub async fn doit(mut self) -> common::Result<(common::Response, BucketAccessControl)> {
8227        use std::borrow::Cow;
8228        use std::io::{Read, Seek};
8229
8230        use common::{url::Params, ToParts};
8231        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8232
8233        let mut dd = common::DefaultDelegate;
8234        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8235        dlg.begin(common::MethodInfo {
8236            id: "storage.bucketAccessControls.update",
8237            http_method: hyper::Method::PUT,
8238        });
8239
8240        for &field in ["alt", "bucket", "entity", "userProject"].iter() {
8241            if self._additional_params.contains_key(field) {
8242                dlg.finished(false);
8243                return Err(common::Error::FieldClash(field));
8244            }
8245        }
8246
8247        let mut params = Params::with_capacity(6 + self._additional_params.len());
8248        params.push("bucket", self._bucket);
8249        params.push("entity", self._entity);
8250        if let Some(value) = self._user_project.as_ref() {
8251            params.push("userProject", value);
8252        }
8253
8254        params.extend(self._additional_params.iter());
8255
8256        params.push("alt", "json");
8257        let mut url = self.hub._base_url.clone() + "b/{bucket}/acl/{entity}";
8258        if self._scopes.is_empty() {
8259            self._scopes
8260                .insert(Scope::CloudPlatform.as_ref().to_string());
8261        }
8262
8263        #[allow(clippy::single_element_loop)]
8264        for &(find_this, param_name) in [("{bucket}", "bucket"), ("{entity}", "entity")].iter() {
8265            url = params.uri_replacement(url, param_name, find_this, false);
8266        }
8267        {
8268            let to_remove = ["entity", "bucket"];
8269            params.remove_params(&to_remove);
8270        }
8271
8272        let url = params.parse_with_url(&url);
8273
8274        let mut json_mime_type = mime::APPLICATION_JSON;
8275        let mut request_value_reader = {
8276            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8277            common::remove_json_null_values(&mut value);
8278            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8279            serde_json::to_writer(&mut dst, &value).unwrap();
8280            dst
8281        };
8282        let request_size = request_value_reader
8283            .seek(std::io::SeekFrom::End(0))
8284            .unwrap();
8285        request_value_reader
8286            .seek(std::io::SeekFrom::Start(0))
8287            .unwrap();
8288
8289        loop {
8290            let token = match self
8291                .hub
8292                .auth
8293                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8294                .await
8295            {
8296                Ok(token) => token,
8297                Err(e) => match dlg.token(e) {
8298                    Ok(token) => token,
8299                    Err(e) => {
8300                        dlg.finished(false);
8301                        return Err(common::Error::MissingToken(e));
8302                    }
8303                },
8304            };
8305            request_value_reader
8306                .seek(std::io::SeekFrom::Start(0))
8307                .unwrap();
8308            let mut req_result = {
8309                let client = &self.hub.client;
8310                dlg.pre_request();
8311                let mut req_builder = hyper::Request::builder()
8312                    .method(hyper::Method::PUT)
8313                    .uri(url.as_str())
8314                    .header(USER_AGENT, self.hub._user_agent.clone());
8315
8316                if let Some(token) = token.as_ref() {
8317                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8318                }
8319
8320                let request = req_builder
8321                    .header(CONTENT_TYPE, json_mime_type.to_string())
8322                    .header(CONTENT_LENGTH, request_size as u64)
8323                    .body(common::to_body(
8324                        request_value_reader.get_ref().clone().into(),
8325                    ));
8326
8327                client.request(request.unwrap()).await
8328            };
8329
8330            match req_result {
8331                Err(err) => {
8332                    if let common::Retry::After(d) = dlg.http_error(&err) {
8333                        sleep(d).await;
8334                        continue;
8335                    }
8336                    dlg.finished(false);
8337                    return Err(common::Error::HttpError(err));
8338                }
8339                Ok(res) => {
8340                    let (mut parts, body) = res.into_parts();
8341                    let mut body = common::Body::new(body);
8342                    if !parts.status.is_success() {
8343                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8344                        let error = serde_json::from_str(&common::to_string(&bytes));
8345                        let response = common::to_response(parts, bytes.into());
8346
8347                        if let common::Retry::After(d) =
8348                            dlg.http_failure(&response, error.as_ref().ok())
8349                        {
8350                            sleep(d).await;
8351                            continue;
8352                        }
8353
8354                        dlg.finished(false);
8355
8356                        return Err(match error {
8357                            Ok(value) => common::Error::BadRequest(value),
8358                            _ => common::Error::Failure(response),
8359                        });
8360                    }
8361                    let response = {
8362                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8363                        let encoded = common::to_string(&bytes);
8364                        match serde_json::from_str(&encoded) {
8365                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8366                            Err(error) => {
8367                                dlg.response_json_decode_error(&encoded, &error);
8368                                return Err(common::Error::JsonDecodeError(
8369                                    encoded.to_string(),
8370                                    error,
8371                                ));
8372                            }
8373                        }
8374                    };
8375
8376                    dlg.finished(true);
8377                    return Ok(response);
8378                }
8379            }
8380        }
8381    }
8382
8383    ///
8384    /// Sets the *request* property to the given value.
8385    ///
8386    /// Even though the property as already been set when instantiating this call,
8387    /// we provide this method for API completeness.
8388    pub fn request(
8389        mut self,
8390        new_value: BucketAccessControl,
8391    ) -> BucketAccessControlUpdateCall<'a, C> {
8392        self._request = new_value;
8393        self
8394    }
8395    /// Name of a bucket.
8396    ///
8397    /// Sets the *bucket* path property to the given value.
8398    ///
8399    /// Even though the property as already been set when instantiating this call,
8400    /// we provide this method for API completeness.
8401    pub fn bucket(mut self, new_value: &str) -> BucketAccessControlUpdateCall<'a, C> {
8402        self._bucket = new_value.to_string();
8403        self
8404    }
8405    /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
8406    ///
8407    /// Sets the *entity* path property to the given value.
8408    ///
8409    /// Even though the property as already been set when instantiating this call,
8410    /// we provide this method for API completeness.
8411    pub fn entity(mut self, new_value: &str) -> BucketAccessControlUpdateCall<'a, C> {
8412        self._entity = new_value.to_string();
8413        self
8414    }
8415    /// The project to be billed for this request. Required for Requester Pays buckets.
8416    ///
8417    /// Sets the *user project* query property to the given value.
8418    pub fn user_project(mut self, new_value: &str) -> BucketAccessControlUpdateCall<'a, C> {
8419        self._user_project = Some(new_value.to_string());
8420        self
8421    }
8422    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8423    /// while executing the actual API request.
8424    ///
8425    /// ````text
8426    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8427    /// ````
8428    ///
8429    /// Sets the *delegate* property to the given value.
8430    pub fn delegate(
8431        mut self,
8432        new_value: &'a mut dyn common::Delegate,
8433    ) -> BucketAccessControlUpdateCall<'a, C> {
8434        self._delegate = Some(new_value);
8435        self
8436    }
8437
8438    /// Set any additional parameter of the query string used in the request.
8439    /// It should be used to set parameters which are not yet available through their own
8440    /// setters.
8441    ///
8442    /// Please note that this method must not be used to set any of the known parameters
8443    /// which have their own setter method. If done anyway, the request will fail.
8444    ///
8445    /// # Additional Parameters
8446    ///
8447    /// * *alt* (query-string) - Data format for the response.
8448    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8449    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8450    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8451    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8452    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8453    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
8454    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8455    pub fn param<T>(mut self, name: T, value: T) -> BucketAccessControlUpdateCall<'a, C>
8456    where
8457        T: AsRef<str>,
8458    {
8459        self._additional_params
8460            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8461        self
8462    }
8463
8464    /// Identifies the authorization scope for the method you are building.
8465    ///
8466    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8467    /// [`Scope::CloudPlatform`].
8468    ///
8469    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8470    /// tokens for more than one scope.
8471    ///
8472    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8473    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8474    /// sufficient, a read-write scope will do as well.
8475    pub fn add_scope<St>(mut self, scope: St) -> BucketAccessControlUpdateCall<'a, C>
8476    where
8477        St: AsRef<str>,
8478    {
8479        self._scopes.insert(String::from(scope.as_ref()));
8480        self
8481    }
8482    /// Identifies the authorization scope(s) for the method you are building.
8483    ///
8484    /// See [`Self::add_scope()`] for details.
8485    pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketAccessControlUpdateCall<'a, C>
8486    where
8487        I: IntoIterator<Item = St>,
8488        St: AsRef<str>,
8489    {
8490        self._scopes
8491            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8492        self
8493    }
8494
8495    /// Removes all scopes, and no default scope will be used either.
8496    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8497    /// for details).
8498    pub fn clear_scopes(mut self) -> BucketAccessControlUpdateCall<'a, C> {
8499        self._scopes.clear();
8500        self
8501    }
8502}
8503
8504/// Permanently deletes an empty bucket.
8505///
8506/// A builder for the *delete* method supported by a *bucket* resource.
8507/// It is not used directly, but through a [`BucketMethods`] instance.
8508///
8509/// # Example
8510///
8511/// Instantiate a resource method builder
8512///
8513/// ```test_harness,no_run
8514/// # extern crate hyper;
8515/// # extern crate hyper_rustls;
8516/// # extern crate google_storage1 as storage1;
8517/// # async fn dox() {
8518/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8519///
8520/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8521/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8522/// #     secret,
8523/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8524/// # ).build().await.unwrap();
8525///
8526/// # let client = hyper_util::client::legacy::Client::builder(
8527/// #     hyper_util::rt::TokioExecutor::new()
8528/// # )
8529/// # .build(
8530/// #     hyper_rustls::HttpsConnectorBuilder::new()
8531/// #         .with_native_roots()
8532/// #         .unwrap()
8533/// #         .https_or_http()
8534/// #         .enable_http1()
8535/// #         .build()
8536/// # );
8537/// # let mut hub = Storage::new(client, auth);
8538/// // You can configure optional parameters by calling the respective setters at will, and
8539/// // execute the final call using `doit()`.
8540/// // Values shown here are possibly random and not representative !
8541/// let result = hub.buckets().delete("bucket")
8542///              .user_project("accusam")
8543///              .if_metageneration_not_match(-78)
8544///              .if_metageneration_match(-34)
8545///              .doit().await;
8546/// # }
8547/// ```
8548pub struct BucketDeleteCall<'a, C>
8549where
8550    C: 'a,
8551{
8552    hub: &'a Storage<C>,
8553    _bucket: String,
8554    _user_project: Option<String>,
8555    _if_metageneration_not_match: Option<i64>,
8556    _if_metageneration_match: Option<i64>,
8557    _delegate: Option<&'a mut dyn common::Delegate>,
8558    _additional_params: HashMap<String, String>,
8559    _scopes: BTreeSet<String>,
8560}
8561
8562impl<'a, C> common::CallBuilder for BucketDeleteCall<'a, C> {}
8563
8564impl<'a, C> BucketDeleteCall<'a, C>
8565where
8566    C: common::Connector,
8567{
8568    /// Perform the operation you have build so far.
8569    pub async fn doit(mut self) -> common::Result<common::Response> {
8570        use std::borrow::Cow;
8571        use std::io::{Read, Seek};
8572
8573        use common::{url::Params, ToParts};
8574        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8575
8576        let mut dd = common::DefaultDelegate;
8577        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8578        dlg.begin(common::MethodInfo {
8579            id: "storage.buckets.delete",
8580            http_method: hyper::Method::DELETE,
8581        });
8582
8583        for &field in [
8584            "bucket",
8585            "userProject",
8586            "ifMetagenerationNotMatch",
8587            "ifMetagenerationMatch",
8588        ]
8589        .iter()
8590        {
8591            if self._additional_params.contains_key(field) {
8592                dlg.finished(false);
8593                return Err(common::Error::FieldClash(field));
8594            }
8595        }
8596
8597        let mut params = Params::with_capacity(5 + self._additional_params.len());
8598        params.push("bucket", self._bucket);
8599        if let Some(value) = self._user_project.as_ref() {
8600            params.push("userProject", value);
8601        }
8602        if let Some(value) = self._if_metageneration_not_match.as_ref() {
8603            params.push("ifMetagenerationNotMatch", value.to_string());
8604        }
8605        if let Some(value) = self._if_metageneration_match.as_ref() {
8606            params.push("ifMetagenerationMatch", value.to_string());
8607        }
8608
8609        params.extend(self._additional_params.iter());
8610
8611        let mut url = self.hub._base_url.clone() + "b/{bucket}";
8612        if self._scopes.is_empty() {
8613            self._scopes
8614                .insert(Scope::CloudPlatform.as_ref().to_string());
8615        }
8616
8617        #[allow(clippy::single_element_loop)]
8618        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
8619            url = params.uri_replacement(url, param_name, find_this, false);
8620        }
8621        {
8622            let to_remove = ["bucket"];
8623            params.remove_params(&to_remove);
8624        }
8625
8626        let url = params.parse_with_url(&url);
8627
8628        loop {
8629            let token = match self
8630                .hub
8631                .auth
8632                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8633                .await
8634            {
8635                Ok(token) => token,
8636                Err(e) => match dlg.token(e) {
8637                    Ok(token) => token,
8638                    Err(e) => {
8639                        dlg.finished(false);
8640                        return Err(common::Error::MissingToken(e));
8641                    }
8642                },
8643            };
8644            let mut req_result = {
8645                let client = &self.hub.client;
8646                dlg.pre_request();
8647                let mut req_builder = hyper::Request::builder()
8648                    .method(hyper::Method::DELETE)
8649                    .uri(url.as_str())
8650                    .header(USER_AGENT, self.hub._user_agent.clone());
8651
8652                if let Some(token) = token.as_ref() {
8653                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8654                }
8655
8656                let request = req_builder
8657                    .header(CONTENT_LENGTH, 0_u64)
8658                    .body(common::to_body::<String>(None));
8659
8660                client.request(request.unwrap()).await
8661            };
8662
8663            match req_result {
8664                Err(err) => {
8665                    if let common::Retry::After(d) = dlg.http_error(&err) {
8666                        sleep(d).await;
8667                        continue;
8668                    }
8669                    dlg.finished(false);
8670                    return Err(common::Error::HttpError(err));
8671                }
8672                Ok(res) => {
8673                    let (mut parts, body) = res.into_parts();
8674                    let mut body = common::Body::new(body);
8675                    if !parts.status.is_success() {
8676                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8677                        let error = serde_json::from_str(&common::to_string(&bytes));
8678                        let response = common::to_response(parts, bytes.into());
8679
8680                        if let common::Retry::After(d) =
8681                            dlg.http_failure(&response, error.as_ref().ok())
8682                        {
8683                            sleep(d).await;
8684                            continue;
8685                        }
8686
8687                        dlg.finished(false);
8688
8689                        return Err(match error {
8690                            Ok(value) => common::Error::BadRequest(value),
8691                            _ => common::Error::Failure(response),
8692                        });
8693                    }
8694                    let response = common::Response::from_parts(parts, body);
8695
8696                    dlg.finished(true);
8697                    return Ok(response);
8698                }
8699            }
8700        }
8701    }
8702
8703    /// Name of a bucket.
8704    ///
8705    /// Sets the *bucket* path property to the given value.
8706    ///
8707    /// Even though the property as already been set when instantiating this call,
8708    /// we provide this method for API completeness.
8709    pub fn bucket(mut self, new_value: &str) -> BucketDeleteCall<'a, C> {
8710        self._bucket = new_value.to_string();
8711        self
8712    }
8713    /// The project to be billed for this request. Required for Requester Pays buckets.
8714    ///
8715    /// Sets the *user project* query property to the given value.
8716    pub fn user_project(mut self, new_value: &str) -> BucketDeleteCall<'a, C> {
8717        self._user_project = Some(new_value.to_string());
8718        self
8719    }
8720    /// If set, only deletes the bucket if its metageneration does not match this value.
8721    ///
8722    /// Sets the *if metageneration not match* query property to the given value.
8723    pub fn if_metageneration_not_match(mut self, new_value: i64) -> BucketDeleteCall<'a, C> {
8724        self._if_metageneration_not_match = Some(new_value);
8725        self
8726    }
8727    /// If set, only deletes the bucket if its metageneration matches this value.
8728    ///
8729    /// Sets the *if metageneration match* query property to the given value.
8730    pub fn if_metageneration_match(mut self, new_value: i64) -> BucketDeleteCall<'a, C> {
8731        self._if_metageneration_match = Some(new_value);
8732        self
8733    }
8734    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8735    /// while executing the actual API request.
8736    ///
8737    /// ````text
8738    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8739    /// ````
8740    ///
8741    /// Sets the *delegate* property to the given value.
8742    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> BucketDeleteCall<'a, C> {
8743        self._delegate = Some(new_value);
8744        self
8745    }
8746
8747    /// Set any additional parameter of the query string used in the request.
8748    /// It should be used to set parameters which are not yet available through their own
8749    /// setters.
8750    ///
8751    /// Please note that this method must not be used to set any of the known parameters
8752    /// which have their own setter method. If done anyway, the request will fail.
8753    ///
8754    /// # Additional Parameters
8755    ///
8756    /// * *alt* (query-string) - Data format for the response.
8757    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8758    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8759    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8760    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8761    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8762    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
8763    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8764    pub fn param<T>(mut self, name: T, value: T) -> BucketDeleteCall<'a, C>
8765    where
8766        T: AsRef<str>,
8767    {
8768        self._additional_params
8769            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8770        self
8771    }
8772
8773    /// Identifies the authorization scope for the method you are building.
8774    ///
8775    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8776    /// [`Scope::CloudPlatform`].
8777    ///
8778    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8779    /// tokens for more than one scope.
8780    ///
8781    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8782    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8783    /// sufficient, a read-write scope will do as well.
8784    pub fn add_scope<St>(mut self, scope: St) -> BucketDeleteCall<'a, C>
8785    where
8786        St: AsRef<str>,
8787    {
8788        self._scopes.insert(String::from(scope.as_ref()));
8789        self
8790    }
8791    /// Identifies the authorization scope(s) for the method you are building.
8792    ///
8793    /// See [`Self::add_scope()`] for details.
8794    pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketDeleteCall<'a, C>
8795    where
8796        I: IntoIterator<Item = St>,
8797        St: AsRef<str>,
8798    {
8799        self._scopes
8800            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8801        self
8802    }
8803
8804    /// Removes all scopes, and no default scope will be used either.
8805    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8806    /// for details).
8807    pub fn clear_scopes(mut self) -> BucketDeleteCall<'a, C> {
8808        self._scopes.clear();
8809        self
8810    }
8811}
8812
8813/// Returns metadata for the specified bucket.
8814///
8815/// A builder for the *get* method supported by a *bucket* resource.
8816/// It is not used directly, but through a [`BucketMethods`] instance.
8817///
8818/// # Example
8819///
8820/// Instantiate a resource method builder
8821///
8822/// ```test_harness,no_run
8823/// # extern crate hyper;
8824/// # extern crate hyper_rustls;
8825/// # extern crate google_storage1 as storage1;
8826/// # async fn dox() {
8827/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8828///
8829/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8830/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8831/// #     secret,
8832/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8833/// # ).build().await.unwrap();
8834///
8835/// # let client = hyper_util::client::legacy::Client::builder(
8836/// #     hyper_util::rt::TokioExecutor::new()
8837/// # )
8838/// # .build(
8839/// #     hyper_rustls::HttpsConnectorBuilder::new()
8840/// #         .with_native_roots()
8841/// #         .unwrap()
8842/// #         .https_or_http()
8843/// #         .enable_http1()
8844/// #         .build()
8845/// # );
8846/// # let mut hub = Storage::new(client, auth);
8847/// // You can configure optional parameters by calling the respective setters at will, and
8848/// // execute the final call using `doit()`.
8849/// // Values shown here are possibly random and not representative !
8850/// let result = hub.buckets().get("bucket")
8851///              .user_project("dolore")
8852///              .projection("voluptua.")
8853///              .if_metageneration_not_match(-2)
8854///              .if_metageneration_match(-17)
8855///              .doit().await;
8856/// # }
8857/// ```
8858pub struct BucketGetCall<'a, C>
8859where
8860    C: 'a,
8861{
8862    hub: &'a Storage<C>,
8863    _bucket: String,
8864    _user_project: Option<String>,
8865    _projection: Option<String>,
8866    _if_metageneration_not_match: Option<i64>,
8867    _if_metageneration_match: Option<i64>,
8868    _delegate: Option<&'a mut dyn common::Delegate>,
8869    _additional_params: HashMap<String, String>,
8870    _scopes: BTreeSet<String>,
8871}
8872
8873impl<'a, C> common::CallBuilder for BucketGetCall<'a, C> {}
8874
8875impl<'a, C> BucketGetCall<'a, C>
8876where
8877    C: common::Connector,
8878{
8879    /// Perform the operation you have build so far.
8880    pub async fn doit(mut self) -> common::Result<(common::Response, Bucket)> {
8881        use std::borrow::Cow;
8882        use std::io::{Read, Seek};
8883
8884        use common::{url::Params, ToParts};
8885        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8886
8887        let mut dd = common::DefaultDelegate;
8888        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8889        dlg.begin(common::MethodInfo {
8890            id: "storage.buckets.get",
8891            http_method: hyper::Method::GET,
8892        });
8893
8894        for &field in [
8895            "alt",
8896            "bucket",
8897            "userProject",
8898            "projection",
8899            "ifMetagenerationNotMatch",
8900            "ifMetagenerationMatch",
8901        ]
8902        .iter()
8903        {
8904            if self._additional_params.contains_key(field) {
8905                dlg.finished(false);
8906                return Err(common::Error::FieldClash(field));
8907            }
8908        }
8909
8910        let mut params = Params::with_capacity(7 + self._additional_params.len());
8911        params.push("bucket", self._bucket);
8912        if let Some(value) = self._user_project.as_ref() {
8913            params.push("userProject", value);
8914        }
8915        if let Some(value) = self._projection.as_ref() {
8916            params.push("projection", value);
8917        }
8918        if let Some(value) = self._if_metageneration_not_match.as_ref() {
8919            params.push("ifMetagenerationNotMatch", value.to_string());
8920        }
8921        if let Some(value) = self._if_metageneration_match.as_ref() {
8922            params.push("ifMetagenerationMatch", value.to_string());
8923        }
8924
8925        params.extend(self._additional_params.iter());
8926
8927        params.push("alt", "json");
8928        let mut url = self.hub._base_url.clone() + "b/{bucket}";
8929        if self._scopes.is_empty() {
8930            self._scopes
8931                .insert(Scope::CloudPlatform.as_ref().to_string());
8932        }
8933
8934        #[allow(clippy::single_element_loop)]
8935        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
8936            url = params.uri_replacement(url, param_name, find_this, false);
8937        }
8938        {
8939            let to_remove = ["bucket"];
8940            params.remove_params(&to_remove);
8941        }
8942
8943        let url = params.parse_with_url(&url);
8944
8945        loop {
8946            let token = match self
8947                .hub
8948                .auth
8949                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8950                .await
8951            {
8952                Ok(token) => token,
8953                Err(e) => match dlg.token(e) {
8954                    Ok(token) => token,
8955                    Err(e) => {
8956                        dlg.finished(false);
8957                        return Err(common::Error::MissingToken(e));
8958                    }
8959                },
8960            };
8961            let mut req_result = {
8962                let client = &self.hub.client;
8963                dlg.pre_request();
8964                let mut req_builder = hyper::Request::builder()
8965                    .method(hyper::Method::GET)
8966                    .uri(url.as_str())
8967                    .header(USER_AGENT, self.hub._user_agent.clone());
8968
8969                if let Some(token) = token.as_ref() {
8970                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8971                }
8972
8973                let request = req_builder
8974                    .header(CONTENT_LENGTH, 0_u64)
8975                    .body(common::to_body::<String>(None));
8976
8977                client.request(request.unwrap()).await
8978            };
8979
8980            match req_result {
8981                Err(err) => {
8982                    if let common::Retry::After(d) = dlg.http_error(&err) {
8983                        sleep(d).await;
8984                        continue;
8985                    }
8986                    dlg.finished(false);
8987                    return Err(common::Error::HttpError(err));
8988                }
8989                Ok(res) => {
8990                    let (mut parts, body) = res.into_parts();
8991                    let mut body = common::Body::new(body);
8992                    if !parts.status.is_success() {
8993                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8994                        let error = serde_json::from_str(&common::to_string(&bytes));
8995                        let response = common::to_response(parts, bytes.into());
8996
8997                        if let common::Retry::After(d) =
8998                            dlg.http_failure(&response, error.as_ref().ok())
8999                        {
9000                            sleep(d).await;
9001                            continue;
9002                        }
9003
9004                        dlg.finished(false);
9005
9006                        return Err(match error {
9007                            Ok(value) => common::Error::BadRequest(value),
9008                            _ => common::Error::Failure(response),
9009                        });
9010                    }
9011                    let response = {
9012                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9013                        let encoded = common::to_string(&bytes);
9014                        match serde_json::from_str(&encoded) {
9015                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9016                            Err(error) => {
9017                                dlg.response_json_decode_error(&encoded, &error);
9018                                return Err(common::Error::JsonDecodeError(
9019                                    encoded.to_string(),
9020                                    error,
9021                                ));
9022                            }
9023                        }
9024                    };
9025
9026                    dlg.finished(true);
9027                    return Ok(response);
9028                }
9029            }
9030        }
9031    }
9032
9033    /// Name of a bucket.
9034    ///
9035    /// Sets the *bucket* path property to the given value.
9036    ///
9037    /// Even though the property as already been set when instantiating this call,
9038    /// we provide this method for API completeness.
9039    pub fn bucket(mut self, new_value: &str) -> BucketGetCall<'a, C> {
9040        self._bucket = new_value.to_string();
9041        self
9042    }
9043    /// The project to be billed for this request. Required for Requester Pays buckets.
9044    ///
9045    /// Sets the *user project* query property to the given value.
9046    pub fn user_project(mut self, new_value: &str) -> BucketGetCall<'a, C> {
9047        self._user_project = Some(new_value.to_string());
9048        self
9049    }
9050    /// Set of properties to return. Defaults to noAcl.
9051    ///
9052    /// Sets the *projection* query property to the given value.
9053    pub fn projection(mut self, new_value: &str) -> BucketGetCall<'a, C> {
9054        self._projection = Some(new_value.to_string());
9055        self
9056    }
9057    /// Makes the return of the bucket metadata conditional on whether the bucket's current metageneration does not match the given value.
9058    ///
9059    /// Sets the *if metageneration not match* query property to the given value.
9060    pub fn if_metageneration_not_match(mut self, new_value: i64) -> BucketGetCall<'a, C> {
9061        self._if_metageneration_not_match = Some(new_value);
9062        self
9063    }
9064    /// Makes the return of the bucket metadata conditional on whether the bucket's current metageneration matches the given value.
9065    ///
9066    /// Sets the *if metageneration match* query property to the given value.
9067    pub fn if_metageneration_match(mut self, new_value: i64) -> BucketGetCall<'a, C> {
9068        self._if_metageneration_match = Some(new_value);
9069        self
9070    }
9071    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9072    /// while executing the actual API request.
9073    ///
9074    /// ````text
9075    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9076    /// ````
9077    ///
9078    /// Sets the *delegate* property to the given value.
9079    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> BucketGetCall<'a, C> {
9080        self._delegate = Some(new_value);
9081        self
9082    }
9083
9084    /// Set any additional parameter of the query string used in the request.
9085    /// It should be used to set parameters which are not yet available through their own
9086    /// setters.
9087    ///
9088    /// Please note that this method must not be used to set any of the known parameters
9089    /// which have their own setter method. If done anyway, the request will fail.
9090    ///
9091    /// # Additional Parameters
9092    ///
9093    /// * *alt* (query-string) - Data format for the response.
9094    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9095    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9096    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9097    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9098    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9099    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
9100    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9101    pub fn param<T>(mut self, name: T, value: T) -> BucketGetCall<'a, C>
9102    where
9103        T: AsRef<str>,
9104    {
9105        self._additional_params
9106            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9107        self
9108    }
9109
9110    /// Identifies the authorization scope for the method you are building.
9111    ///
9112    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9113    /// [`Scope::CloudPlatform`].
9114    ///
9115    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9116    /// tokens for more than one scope.
9117    ///
9118    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9119    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9120    /// sufficient, a read-write scope will do as well.
9121    pub fn add_scope<St>(mut self, scope: St) -> BucketGetCall<'a, C>
9122    where
9123        St: AsRef<str>,
9124    {
9125        self._scopes.insert(String::from(scope.as_ref()));
9126        self
9127    }
9128    /// Identifies the authorization scope(s) for the method you are building.
9129    ///
9130    /// See [`Self::add_scope()`] for details.
9131    pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketGetCall<'a, C>
9132    where
9133        I: IntoIterator<Item = St>,
9134        St: AsRef<str>,
9135    {
9136        self._scopes
9137            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9138        self
9139    }
9140
9141    /// Removes all scopes, and no default scope will be used either.
9142    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9143    /// for details).
9144    pub fn clear_scopes(mut self) -> BucketGetCall<'a, C> {
9145        self._scopes.clear();
9146        self
9147    }
9148}
9149
9150/// Returns an IAM policy for the specified bucket.
9151///
9152/// A builder for the *getIamPolicy* method supported by a *bucket* resource.
9153/// It is not used directly, but through a [`BucketMethods`] instance.
9154///
9155/// # Example
9156///
9157/// Instantiate a resource method builder
9158///
9159/// ```test_harness,no_run
9160/// # extern crate hyper;
9161/// # extern crate hyper_rustls;
9162/// # extern crate google_storage1 as storage1;
9163/// # async fn dox() {
9164/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9165///
9166/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9167/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9168/// #     secret,
9169/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9170/// # ).build().await.unwrap();
9171///
9172/// # let client = hyper_util::client::legacy::Client::builder(
9173/// #     hyper_util::rt::TokioExecutor::new()
9174/// # )
9175/// # .build(
9176/// #     hyper_rustls::HttpsConnectorBuilder::new()
9177/// #         .with_native_roots()
9178/// #         .unwrap()
9179/// #         .https_or_http()
9180/// #         .enable_http1()
9181/// #         .build()
9182/// # );
9183/// # let mut hub = Storage::new(client, auth);
9184/// // You can configure optional parameters by calling the respective setters at will, and
9185/// // execute the final call using `doit()`.
9186/// // Values shown here are possibly random and not representative !
9187/// let result = hub.buckets().get_iam_policy("bucket")
9188///              .user_project("Lorem")
9189///              .options_requested_policy_version(-38)
9190///              .doit().await;
9191/// # }
9192/// ```
9193pub struct BucketGetIamPolicyCall<'a, C>
9194where
9195    C: 'a,
9196{
9197    hub: &'a Storage<C>,
9198    _bucket: String,
9199    _user_project: Option<String>,
9200    _options_requested_policy_version: Option<i32>,
9201    _delegate: Option<&'a mut dyn common::Delegate>,
9202    _additional_params: HashMap<String, String>,
9203    _scopes: BTreeSet<String>,
9204}
9205
9206impl<'a, C> common::CallBuilder for BucketGetIamPolicyCall<'a, C> {}
9207
9208impl<'a, C> BucketGetIamPolicyCall<'a, C>
9209where
9210    C: common::Connector,
9211{
9212    /// Perform the operation you have build so far.
9213    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
9214        use std::borrow::Cow;
9215        use std::io::{Read, Seek};
9216
9217        use common::{url::Params, ToParts};
9218        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9219
9220        let mut dd = common::DefaultDelegate;
9221        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9222        dlg.begin(common::MethodInfo {
9223            id: "storage.buckets.getIamPolicy",
9224            http_method: hyper::Method::GET,
9225        });
9226
9227        for &field in [
9228            "alt",
9229            "bucket",
9230            "userProject",
9231            "optionsRequestedPolicyVersion",
9232        ]
9233        .iter()
9234        {
9235            if self._additional_params.contains_key(field) {
9236                dlg.finished(false);
9237                return Err(common::Error::FieldClash(field));
9238            }
9239        }
9240
9241        let mut params = Params::with_capacity(5 + self._additional_params.len());
9242        params.push("bucket", self._bucket);
9243        if let Some(value) = self._user_project.as_ref() {
9244            params.push("userProject", value);
9245        }
9246        if let Some(value) = self._options_requested_policy_version.as_ref() {
9247            params.push("optionsRequestedPolicyVersion", value.to_string());
9248        }
9249
9250        params.extend(self._additional_params.iter());
9251
9252        params.push("alt", "json");
9253        let mut url = self.hub._base_url.clone() + "b/{bucket}/iam";
9254        if self._scopes.is_empty() {
9255            self._scopes
9256                .insert(Scope::CloudPlatform.as_ref().to_string());
9257        }
9258
9259        #[allow(clippy::single_element_loop)]
9260        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
9261            url = params.uri_replacement(url, param_name, find_this, false);
9262        }
9263        {
9264            let to_remove = ["bucket"];
9265            params.remove_params(&to_remove);
9266        }
9267
9268        let url = params.parse_with_url(&url);
9269
9270        loop {
9271            let token = match self
9272                .hub
9273                .auth
9274                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9275                .await
9276            {
9277                Ok(token) => token,
9278                Err(e) => match dlg.token(e) {
9279                    Ok(token) => token,
9280                    Err(e) => {
9281                        dlg.finished(false);
9282                        return Err(common::Error::MissingToken(e));
9283                    }
9284                },
9285            };
9286            let mut req_result = {
9287                let client = &self.hub.client;
9288                dlg.pre_request();
9289                let mut req_builder = hyper::Request::builder()
9290                    .method(hyper::Method::GET)
9291                    .uri(url.as_str())
9292                    .header(USER_AGENT, self.hub._user_agent.clone());
9293
9294                if let Some(token) = token.as_ref() {
9295                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9296                }
9297
9298                let request = req_builder
9299                    .header(CONTENT_LENGTH, 0_u64)
9300                    .body(common::to_body::<String>(None));
9301
9302                client.request(request.unwrap()).await
9303            };
9304
9305            match req_result {
9306                Err(err) => {
9307                    if let common::Retry::After(d) = dlg.http_error(&err) {
9308                        sleep(d).await;
9309                        continue;
9310                    }
9311                    dlg.finished(false);
9312                    return Err(common::Error::HttpError(err));
9313                }
9314                Ok(res) => {
9315                    let (mut parts, body) = res.into_parts();
9316                    let mut body = common::Body::new(body);
9317                    if !parts.status.is_success() {
9318                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9319                        let error = serde_json::from_str(&common::to_string(&bytes));
9320                        let response = common::to_response(parts, bytes.into());
9321
9322                        if let common::Retry::After(d) =
9323                            dlg.http_failure(&response, error.as_ref().ok())
9324                        {
9325                            sleep(d).await;
9326                            continue;
9327                        }
9328
9329                        dlg.finished(false);
9330
9331                        return Err(match error {
9332                            Ok(value) => common::Error::BadRequest(value),
9333                            _ => common::Error::Failure(response),
9334                        });
9335                    }
9336                    let response = {
9337                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9338                        let encoded = common::to_string(&bytes);
9339                        match serde_json::from_str(&encoded) {
9340                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9341                            Err(error) => {
9342                                dlg.response_json_decode_error(&encoded, &error);
9343                                return Err(common::Error::JsonDecodeError(
9344                                    encoded.to_string(),
9345                                    error,
9346                                ));
9347                            }
9348                        }
9349                    };
9350
9351                    dlg.finished(true);
9352                    return Ok(response);
9353                }
9354            }
9355        }
9356    }
9357
9358    /// Name of a bucket.
9359    ///
9360    /// Sets the *bucket* path property to the given value.
9361    ///
9362    /// Even though the property as already been set when instantiating this call,
9363    /// we provide this method for API completeness.
9364    pub fn bucket(mut self, new_value: &str) -> BucketGetIamPolicyCall<'a, C> {
9365        self._bucket = new_value.to_string();
9366        self
9367    }
9368    /// The project to be billed for this request. Required for Requester Pays buckets.
9369    ///
9370    /// Sets the *user project* query property to the given value.
9371    pub fn user_project(mut self, new_value: &str) -> BucketGetIamPolicyCall<'a, C> {
9372        self._user_project = Some(new_value.to_string());
9373        self
9374    }
9375    /// The IAM policy format version to be returned. If the optionsRequestedPolicyVersion is for an older version that doesn't support part of the requested IAM policy, the request fails.
9376    ///
9377    /// Sets the *options requested policy version* query property to the given value.
9378    pub fn options_requested_policy_version(
9379        mut self,
9380        new_value: i32,
9381    ) -> BucketGetIamPolicyCall<'a, C> {
9382        self._options_requested_policy_version = Some(new_value);
9383        self
9384    }
9385    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9386    /// while executing the actual API request.
9387    ///
9388    /// ````text
9389    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9390    /// ````
9391    ///
9392    /// Sets the *delegate* property to the given value.
9393    pub fn delegate(
9394        mut self,
9395        new_value: &'a mut dyn common::Delegate,
9396    ) -> BucketGetIamPolicyCall<'a, C> {
9397        self._delegate = Some(new_value);
9398        self
9399    }
9400
9401    /// Set any additional parameter of the query string used in the request.
9402    /// It should be used to set parameters which are not yet available through their own
9403    /// setters.
9404    ///
9405    /// Please note that this method must not be used to set any of the known parameters
9406    /// which have their own setter method. If done anyway, the request will fail.
9407    ///
9408    /// # Additional Parameters
9409    ///
9410    /// * *alt* (query-string) - Data format for the response.
9411    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9412    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9413    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9414    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9415    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9416    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
9417    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9418    pub fn param<T>(mut self, name: T, value: T) -> BucketGetIamPolicyCall<'a, C>
9419    where
9420        T: AsRef<str>,
9421    {
9422        self._additional_params
9423            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9424        self
9425    }
9426
9427    /// Identifies the authorization scope for the method you are building.
9428    ///
9429    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9430    /// [`Scope::CloudPlatform`].
9431    ///
9432    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9433    /// tokens for more than one scope.
9434    ///
9435    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9436    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9437    /// sufficient, a read-write scope will do as well.
9438    pub fn add_scope<St>(mut self, scope: St) -> BucketGetIamPolicyCall<'a, C>
9439    where
9440        St: AsRef<str>,
9441    {
9442        self._scopes.insert(String::from(scope.as_ref()));
9443        self
9444    }
9445    /// Identifies the authorization scope(s) for the method you are building.
9446    ///
9447    /// See [`Self::add_scope()`] for details.
9448    pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketGetIamPolicyCall<'a, C>
9449    where
9450        I: IntoIterator<Item = St>,
9451        St: AsRef<str>,
9452    {
9453        self._scopes
9454            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9455        self
9456    }
9457
9458    /// Removes all scopes, and no default scope will be used either.
9459    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9460    /// for details).
9461    pub fn clear_scopes(mut self) -> BucketGetIamPolicyCall<'a, C> {
9462        self._scopes.clear();
9463        self
9464    }
9465}
9466
9467/// Returns the storage layout configuration for the specified bucket. Note that this operation requires storage.objects.list permission.
9468///
9469/// A builder for the *getStorageLayout* method supported by a *bucket* resource.
9470/// It is not used directly, but through a [`BucketMethods`] instance.
9471///
9472/// # Example
9473///
9474/// Instantiate a resource method builder
9475///
9476/// ```test_harness,no_run
9477/// # extern crate hyper;
9478/// # extern crate hyper_rustls;
9479/// # extern crate google_storage1 as storage1;
9480/// # async fn dox() {
9481/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9482///
9483/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9484/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9485/// #     secret,
9486/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9487/// # ).build().await.unwrap();
9488///
9489/// # let client = hyper_util::client::legacy::Client::builder(
9490/// #     hyper_util::rt::TokioExecutor::new()
9491/// # )
9492/// # .build(
9493/// #     hyper_rustls::HttpsConnectorBuilder::new()
9494/// #         .with_native_roots()
9495/// #         .unwrap()
9496/// #         .https_or_http()
9497/// #         .enable_http1()
9498/// #         .build()
9499/// # );
9500/// # let mut hub = Storage::new(client, auth);
9501/// // You can configure optional parameters by calling the respective setters at will, and
9502/// // execute the final call using `doit()`.
9503/// // Values shown here are possibly random and not representative !
9504/// let result = hub.buckets().get_storage_layout("bucket")
9505///              .prefix("est")
9506///              .doit().await;
9507/// # }
9508/// ```
9509pub struct BucketGetStorageLayoutCall<'a, C>
9510where
9511    C: 'a,
9512{
9513    hub: &'a Storage<C>,
9514    _bucket: String,
9515    _prefix: Option<String>,
9516    _delegate: Option<&'a mut dyn common::Delegate>,
9517    _additional_params: HashMap<String, String>,
9518    _scopes: BTreeSet<String>,
9519}
9520
9521impl<'a, C> common::CallBuilder for BucketGetStorageLayoutCall<'a, C> {}
9522
9523impl<'a, C> BucketGetStorageLayoutCall<'a, C>
9524where
9525    C: common::Connector,
9526{
9527    /// Perform the operation you have build so far.
9528    pub async fn doit(mut self) -> common::Result<(common::Response, BucketStorageLayout)> {
9529        use std::borrow::Cow;
9530        use std::io::{Read, Seek};
9531
9532        use common::{url::Params, ToParts};
9533        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9534
9535        let mut dd = common::DefaultDelegate;
9536        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9537        dlg.begin(common::MethodInfo {
9538            id: "storage.buckets.getStorageLayout",
9539            http_method: hyper::Method::GET,
9540        });
9541
9542        for &field in ["alt", "bucket", "prefix"].iter() {
9543            if self._additional_params.contains_key(field) {
9544                dlg.finished(false);
9545                return Err(common::Error::FieldClash(field));
9546            }
9547        }
9548
9549        let mut params = Params::with_capacity(4 + self._additional_params.len());
9550        params.push("bucket", self._bucket);
9551        if let Some(value) = self._prefix.as_ref() {
9552            params.push("prefix", value);
9553        }
9554
9555        params.extend(self._additional_params.iter());
9556
9557        params.push("alt", "json");
9558        let mut url = self.hub._base_url.clone() + "b/{bucket}/storageLayout";
9559        if self._scopes.is_empty() {
9560            self._scopes
9561                .insert(Scope::CloudPlatform.as_ref().to_string());
9562        }
9563
9564        #[allow(clippy::single_element_loop)]
9565        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
9566            url = params.uri_replacement(url, param_name, find_this, false);
9567        }
9568        {
9569            let to_remove = ["bucket"];
9570            params.remove_params(&to_remove);
9571        }
9572
9573        let url = params.parse_with_url(&url);
9574
9575        loop {
9576            let token = match self
9577                .hub
9578                .auth
9579                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9580                .await
9581            {
9582                Ok(token) => token,
9583                Err(e) => match dlg.token(e) {
9584                    Ok(token) => token,
9585                    Err(e) => {
9586                        dlg.finished(false);
9587                        return Err(common::Error::MissingToken(e));
9588                    }
9589                },
9590            };
9591            let mut req_result = {
9592                let client = &self.hub.client;
9593                dlg.pre_request();
9594                let mut req_builder = hyper::Request::builder()
9595                    .method(hyper::Method::GET)
9596                    .uri(url.as_str())
9597                    .header(USER_AGENT, self.hub._user_agent.clone());
9598
9599                if let Some(token) = token.as_ref() {
9600                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9601                }
9602
9603                let request = req_builder
9604                    .header(CONTENT_LENGTH, 0_u64)
9605                    .body(common::to_body::<String>(None));
9606
9607                client.request(request.unwrap()).await
9608            };
9609
9610            match req_result {
9611                Err(err) => {
9612                    if let common::Retry::After(d) = dlg.http_error(&err) {
9613                        sleep(d).await;
9614                        continue;
9615                    }
9616                    dlg.finished(false);
9617                    return Err(common::Error::HttpError(err));
9618                }
9619                Ok(res) => {
9620                    let (mut parts, body) = res.into_parts();
9621                    let mut body = common::Body::new(body);
9622                    if !parts.status.is_success() {
9623                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9624                        let error = serde_json::from_str(&common::to_string(&bytes));
9625                        let response = common::to_response(parts, bytes.into());
9626
9627                        if let common::Retry::After(d) =
9628                            dlg.http_failure(&response, error.as_ref().ok())
9629                        {
9630                            sleep(d).await;
9631                            continue;
9632                        }
9633
9634                        dlg.finished(false);
9635
9636                        return Err(match error {
9637                            Ok(value) => common::Error::BadRequest(value),
9638                            _ => common::Error::Failure(response),
9639                        });
9640                    }
9641                    let response = {
9642                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9643                        let encoded = common::to_string(&bytes);
9644                        match serde_json::from_str(&encoded) {
9645                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9646                            Err(error) => {
9647                                dlg.response_json_decode_error(&encoded, &error);
9648                                return Err(common::Error::JsonDecodeError(
9649                                    encoded.to_string(),
9650                                    error,
9651                                ));
9652                            }
9653                        }
9654                    };
9655
9656                    dlg.finished(true);
9657                    return Ok(response);
9658                }
9659            }
9660        }
9661    }
9662
9663    /// Name of a bucket.
9664    ///
9665    /// Sets the *bucket* path property to the given value.
9666    ///
9667    /// Even though the property as already been set when instantiating this call,
9668    /// we provide this method for API completeness.
9669    pub fn bucket(mut self, new_value: &str) -> BucketGetStorageLayoutCall<'a, C> {
9670        self._bucket = new_value.to_string();
9671        self
9672    }
9673    /// An optional prefix used for permission check. It is useful when the caller only has storage.objects.list permission under a specific prefix.
9674    ///
9675    /// Sets the *prefix* query property to the given value.
9676    pub fn prefix(mut self, new_value: &str) -> BucketGetStorageLayoutCall<'a, C> {
9677        self._prefix = Some(new_value.to_string());
9678        self
9679    }
9680    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9681    /// while executing the actual API request.
9682    ///
9683    /// ````text
9684    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9685    /// ````
9686    ///
9687    /// Sets the *delegate* property to the given value.
9688    pub fn delegate(
9689        mut self,
9690        new_value: &'a mut dyn common::Delegate,
9691    ) -> BucketGetStorageLayoutCall<'a, C> {
9692        self._delegate = Some(new_value);
9693        self
9694    }
9695
9696    /// Set any additional parameter of the query string used in the request.
9697    /// It should be used to set parameters which are not yet available through their own
9698    /// setters.
9699    ///
9700    /// Please note that this method must not be used to set any of the known parameters
9701    /// which have their own setter method. If done anyway, the request will fail.
9702    ///
9703    /// # Additional Parameters
9704    ///
9705    /// * *alt* (query-string) - Data format for the response.
9706    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9707    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9708    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9709    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9710    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9711    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
9712    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9713    pub fn param<T>(mut self, name: T, value: T) -> BucketGetStorageLayoutCall<'a, C>
9714    where
9715        T: AsRef<str>,
9716    {
9717        self._additional_params
9718            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9719        self
9720    }
9721
9722    /// Identifies the authorization scope for the method you are building.
9723    ///
9724    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9725    /// [`Scope::CloudPlatform`].
9726    ///
9727    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9728    /// tokens for more than one scope.
9729    ///
9730    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9731    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9732    /// sufficient, a read-write scope will do as well.
9733    pub fn add_scope<St>(mut self, scope: St) -> BucketGetStorageLayoutCall<'a, C>
9734    where
9735        St: AsRef<str>,
9736    {
9737        self._scopes.insert(String::from(scope.as_ref()));
9738        self
9739    }
9740    /// Identifies the authorization scope(s) for the method you are building.
9741    ///
9742    /// See [`Self::add_scope()`] for details.
9743    pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketGetStorageLayoutCall<'a, C>
9744    where
9745        I: IntoIterator<Item = St>,
9746        St: AsRef<str>,
9747    {
9748        self._scopes
9749            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9750        self
9751    }
9752
9753    /// Removes all scopes, and no default scope will be used either.
9754    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9755    /// for details).
9756    pub fn clear_scopes(mut self) -> BucketGetStorageLayoutCall<'a, C> {
9757        self._scopes.clear();
9758        self
9759    }
9760}
9761
9762/// Creates a new bucket.
9763///
9764/// A builder for the *insert* method supported by a *bucket* resource.
9765/// It is not used directly, but through a [`BucketMethods`] instance.
9766///
9767/// # Example
9768///
9769/// Instantiate a resource method builder
9770///
9771/// ```test_harness,no_run
9772/// # extern crate hyper;
9773/// # extern crate hyper_rustls;
9774/// # extern crate google_storage1 as storage1;
9775/// use storage1::api::Bucket;
9776/// # async fn dox() {
9777/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9778///
9779/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9780/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9781/// #     secret,
9782/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9783/// # ).build().await.unwrap();
9784///
9785/// # let client = hyper_util::client::legacy::Client::builder(
9786/// #     hyper_util::rt::TokioExecutor::new()
9787/// # )
9788/// # .build(
9789/// #     hyper_rustls::HttpsConnectorBuilder::new()
9790/// #         .with_native_roots()
9791/// #         .unwrap()
9792/// #         .https_or_http()
9793/// #         .enable_http1()
9794/// #         .build()
9795/// # );
9796/// # let mut hub = Storage::new(client, auth);
9797/// // As the method needs a request, you would usually fill it with the desired information
9798/// // into the respective structure. Some of the parts shown here might not be applicable !
9799/// // Values shown here are possibly random and not representative !
9800/// let mut req = Bucket::default();
9801///
9802/// // You can configure optional parameters by calling the respective setters at will, and
9803/// // execute the final call using `doit()`.
9804/// // Values shown here are possibly random and not representative !
9805/// let result = hub.buckets().insert(req, "project")
9806///              .user_project("sed")
9807///              .projection("sit")
9808///              .predefined_default_object_acl("et")
9809///              .predefined_acl("tempor")
9810///              .enable_object_retention(true)
9811///              .doit().await;
9812/// # }
9813/// ```
9814pub struct BucketInsertCall<'a, C>
9815where
9816    C: 'a,
9817{
9818    hub: &'a Storage<C>,
9819    _request: Bucket,
9820    _project: String,
9821    _user_project: Option<String>,
9822    _projection: Option<String>,
9823    _predefined_default_object_acl: Option<String>,
9824    _predefined_acl: Option<String>,
9825    _enable_object_retention: Option<bool>,
9826    _delegate: Option<&'a mut dyn common::Delegate>,
9827    _additional_params: HashMap<String, String>,
9828    _scopes: BTreeSet<String>,
9829}
9830
9831impl<'a, C> common::CallBuilder for BucketInsertCall<'a, C> {}
9832
9833impl<'a, C> BucketInsertCall<'a, C>
9834where
9835    C: common::Connector,
9836{
9837    /// Perform the operation you have build so far.
9838    pub async fn doit(mut self) -> common::Result<(common::Response, Bucket)> {
9839        use std::borrow::Cow;
9840        use std::io::{Read, Seek};
9841
9842        use common::{url::Params, ToParts};
9843        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9844
9845        let mut dd = common::DefaultDelegate;
9846        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9847        dlg.begin(common::MethodInfo {
9848            id: "storage.buckets.insert",
9849            http_method: hyper::Method::POST,
9850        });
9851
9852        for &field in [
9853            "alt",
9854            "project",
9855            "userProject",
9856            "projection",
9857            "predefinedDefaultObjectAcl",
9858            "predefinedAcl",
9859            "enableObjectRetention",
9860        ]
9861        .iter()
9862        {
9863            if self._additional_params.contains_key(field) {
9864                dlg.finished(false);
9865                return Err(common::Error::FieldClash(field));
9866            }
9867        }
9868
9869        let mut params = Params::with_capacity(9 + self._additional_params.len());
9870        params.push("project", self._project);
9871        if let Some(value) = self._user_project.as_ref() {
9872            params.push("userProject", value);
9873        }
9874        if let Some(value) = self._projection.as_ref() {
9875            params.push("projection", value);
9876        }
9877        if let Some(value) = self._predefined_default_object_acl.as_ref() {
9878            params.push("predefinedDefaultObjectAcl", value);
9879        }
9880        if let Some(value) = self._predefined_acl.as_ref() {
9881            params.push("predefinedAcl", value);
9882        }
9883        if let Some(value) = self._enable_object_retention.as_ref() {
9884            params.push("enableObjectRetention", value.to_string());
9885        }
9886
9887        params.extend(self._additional_params.iter());
9888
9889        params.push("alt", "json");
9890        let mut url = self.hub._base_url.clone() + "b";
9891        if self._scopes.is_empty() {
9892            self._scopes
9893                .insert(Scope::CloudPlatform.as_ref().to_string());
9894        }
9895
9896        let url = params.parse_with_url(&url);
9897
9898        let mut json_mime_type = mime::APPLICATION_JSON;
9899        let mut request_value_reader = {
9900            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9901            common::remove_json_null_values(&mut value);
9902            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9903            serde_json::to_writer(&mut dst, &value).unwrap();
9904            dst
9905        };
9906        let request_size = request_value_reader
9907            .seek(std::io::SeekFrom::End(0))
9908            .unwrap();
9909        request_value_reader
9910            .seek(std::io::SeekFrom::Start(0))
9911            .unwrap();
9912
9913        loop {
9914            let token = match self
9915                .hub
9916                .auth
9917                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9918                .await
9919            {
9920                Ok(token) => token,
9921                Err(e) => match dlg.token(e) {
9922                    Ok(token) => token,
9923                    Err(e) => {
9924                        dlg.finished(false);
9925                        return Err(common::Error::MissingToken(e));
9926                    }
9927                },
9928            };
9929            request_value_reader
9930                .seek(std::io::SeekFrom::Start(0))
9931                .unwrap();
9932            let mut req_result = {
9933                let client = &self.hub.client;
9934                dlg.pre_request();
9935                let mut req_builder = hyper::Request::builder()
9936                    .method(hyper::Method::POST)
9937                    .uri(url.as_str())
9938                    .header(USER_AGENT, self.hub._user_agent.clone());
9939
9940                if let Some(token) = token.as_ref() {
9941                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9942                }
9943
9944                let request = req_builder
9945                    .header(CONTENT_TYPE, json_mime_type.to_string())
9946                    .header(CONTENT_LENGTH, request_size as u64)
9947                    .body(common::to_body(
9948                        request_value_reader.get_ref().clone().into(),
9949                    ));
9950
9951                client.request(request.unwrap()).await
9952            };
9953
9954            match req_result {
9955                Err(err) => {
9956                    if let common::Retry::After(d) = dlg.http_error(&err) {
9957                        sleep(d).await;
9958                        continue;
9959                    }
9960                    dlg.finished(false);
9961                    return Err(common::Error::HttpError(err));
9962                }
9963                Ok(res) => {
9964                    let (mut parts, body) = res.into_parts();
9965                    let mut body = common::Body::new(body);
9966                    if !parts.status.is_success() {
9967                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9968                        let error = serde_json::from_str(&common::to_string(&bytes));
9969                        let response = common::to_response(parts, bytes.into());
9970
9971                        if let common::Retry::After(d) =
9972                            dlg.http_failure(&response, error.as_ref().ok())
9973                        {
9974                            sleep(d).await;
9975                            continue;
9976                        }
9977
9978                        dlg.finished(false);
9979
9980                        return Err(match error {
9981                            Ok(value) => common::Error::BadRequest(value),
9982                            _ => common::Error::Failure(response),
9983                        });
9984                    }
9985                    let response = {
9986                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9987                        let encoded = common::to_string(&bytes);
9988                        match serde_json::from_str(&encoded) {
9989                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9990                            Err(error) => {
9991                                dlg.response_json_decode_error(&encoded, &error);
9992                                return Err(common::Error::JsonDecodeError(
9993                                    encoded.to_string(),
9994                                    error,
9995                                ));
9996                            }
9997                        }
9998                    };
9999
10000                    dlg.finished(true);
10001                    return Ok(response);
10002                }
10003            }
10004        }
10005    }
10006
10007    ///
10008    /// Sets the *request* property to the given value.
10009    ///
10010    /// Even though the property as already been set when instantiating this call,
10011    /// we provide this method for API completeness.
10012    pub fn request(mut self, new_value: Bucket) -> BucketInsertCall<'a, C> {
10013        self._request = new_value;
10014        self
10015    }
10016    /// A valid API project identifier.
10017    ///
10018    /// Sets the *project* query property to the given value.
10019    ///
10020    /// Even though the property as already been set when instantiating this call,
10021    /// we provide this method for API completeness.
10022    pub fn project(mut self, new_value: &str) -> BucketInsertCall<'a, C> {
10023        self._project = new_value.to_string();
10024        self
10025    }
10026    /// The project to be billed for this request.
10027    ///
10028    /// Sets the *user project* query property to the given value.
10029    pub fn user_project(mut self, new_value: &str) -> BucketInsertCall<'a, C> {
10030        self._user_project = Some(new_value.to_string());
10031        self
10032    }
10033    /// Set of properties to return. Defaults to noAcl, unless the bucket resource specifies acl or defaultObjectAcl properties, when it defaults to full.
10034    ///
10035    /// Sets the *projection* query property to the given value.
10036    pub fn projection(mut self, new_value: &str) -> BucketInsertCall<'a, C> {
10037        self._projection = Some(new_value.to_string());
10038        self
10039    }
10040    /// Apply a predefined set of default object access controls to this bucket.
10041    ///
10042    /// Sets the *predefined default object acl* query property to the given value.
10043    pub fn predefined_default_object_acl(mut self, new_value: &str) -> BucketInsertCall<'a, C> {
10044        self._predefined_default_object_acl = Some(new_value.to_string());
10045        self
10046    }
10047    /// Apply a predefined set of access controls to this bucket.
10048    ///
10049    /// Sets the *predefined acl* query property to the given value.
10050    pub fn predefined_acl(mut self, new_value: &str) -> BucketInsertCall<'a, C> {
10051        self._predefined_acl = Some(new_value.to_string());
10052        self
10053    }
10054    /// When set to true, object retention is enabled for this bucket.
10055    ///
10056    /// Sets the *enable object retention* query property to the given value.
10057    pub fn enable_object_retention(mut self, new_value: bool) -> BucketInsertCall<'a, C> {
10058        self._enable_object_retention = Some(new_value);
10059        self
10060    }
10061    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10062    /// while executing the actual API request.
10063    ///
10064    /// ````text
10065    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10066    /// ````
10067    ///
10068    /// Sets the *delegate* property to the given value.
10069    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> BucketInsertCall<'a, C> {
10070        self._delegate = Some(new_value);
10071        self
10072    }
10073
10074    /// Set any additional parameter of the query string used in the request.
10075    /// It should be used to set parameters which are not yet available through their own
10076    /// setters.
10077    ///
10078    /// Please note that this method must not be used to set any of the known parameters
10079    /// which have their own setter method. If done anyway, the request will fail.
10080    ///
10081    /// # Additional Parameters
10082    ///
10083    /// * *alt* (query-string) - Data format for the response.
10084    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10085    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10086    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10087    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10088    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10089    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
10090    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10091    pub fn param<T>(mut self, name: T, value: T) -> BucketInsertCall<'a, C>
10092    where
10093        T: AsRef<str>,
10094    {
10095        self._additional_params
10096            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10097        self
10098    }
10099
10100    /// Identifies the authorization scope for the method you are building.
10101    ///
10102    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10103    /// [`Scope::CloudPlatform`].
10104    ///
10105    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10106    /// tokens for more than one scope.
10107    ///
10108    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10109    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10110    /// sufficient, a read-write scope will do as well.
10111    pub fn add_scope<St>(mut self, scope: St) -> BucketInsertCall<'a, C>
10112    where
10113        St: AsRef<str>,
10114    {
10115        self._scopes.insert(String::from(scope.as_ref()));
10116        self
10117    }
10118    /// Identifies the authorization scope(s) for the method you are building.
10119    ///
10120    /// See [`Self::add_scope()`] for details.
10121    pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketInsertCall<'a, C>
10122    where
10123        I: IntoIterator<Item = St>,
10124        St: AsRef<str>,
10125    {
10126        self._scopes
10127            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10128        self
10129    }
10130
10131    /// Removes all scopes, and no default scope will be used either.
10132    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10133    /// for details).
10134    pub fn clear_scopes(mut self) -> BucketInsertCall<'a, C> {
10135        self._scopes.clear();
10136        self
10137    }
10138}
10139
10140/// Retrieves a list of buckets for a given project.
10141///
10142/// A builder for the *list* method supported by a *bucket* resource.
10143/// It is not used directly, but through a [`BucketMethods`] instance.
10144///
10145/// # Example
10146///
10147/// Instantiate a resource method builder
10148///
10149/// ```test_harness,no_run
10150/// # extern crate hyper;
10151/// # extern crate hyper_rustls;
10152/// # extern crate google_storage1 as storage1;
10153/// # async fn dox() {
10154/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10155///
10156/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10157/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10158/// #     secret,
10159/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10160/// # ).build().await.unwrap();
10161///
10162/// # let client = hyper_util::client::legacy::Client::builder(
10163/// #     hyper_util::rt::TokioExecutor::new()
10164/// # )
10165/// # .build(
10166/// #     hyper_rustls::HttpsConnectorBuilder::new()
10167/// #         .with_native_roots()
10168/// #         .unwrap()
10169/// #         .https_or_http()
10170/// #         .enable_http1()
10171/// #         .build()
10172/// # );
10173/// # let mut hub = Storage::new(client, auth);
10174/// // You can configure optional parameters by calling the respective setters at will, and
10175/// // execute the final call using `doit()`.
10176/// // Values shown here are possibly random and not representative !
10177/// let result = hub.buckets().list("project")
10178///              .user_project("sed")
10179///              .projection("diam")
10180///              .prefix("dolores")
10181///              .page_token("dolores")
10182///              .max_results(33)
10183///              .doit().await;
10184/// # }
10185/// ```
10186pub struct BucketListCall<'a, C>
10187where
10188    C: 'a,
10189{
10190    hub: &'a Storage<C>,
10191    _project: String,
10192    _user_project: Option<String>,
10193    _projection: Option<String>,
10194    _prefix: Option<String>,
10195    _page_token: Option<String>,
10196    _max_results: Option<u32>,
10197    _delegate: Option<&'a mut dyn common::Delegate>,
10198    _additional_params: HashMap<String, String>,
10199    _scopes: BTreeSet<String>,
10200}
10201
10202impl<'a, C> common::CallBuilder for BucketListCall<'a, C> {}
10203
10204impl<'a, C> BucketListCall<'a, C>
10205where
10206    C: common::Connector,
10207{
10208    /// Perform the operation you have build so far.
10209    pub async fn doit(mut self) -> common::Result<(common::Response, Buckets)> {
10210        use std::borrow::Cow;
10211        use std::io::{Read, Seek};
10212
10213        use common::{url::Params, ToParts};
10214        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10215
10216        let mut dd = common::DefaultDelegate;
10217        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10218        dlg.begin(common::MethodInfo {
10219            id: "storage.buckets.list",
10220            http_method: hyper::Method::GET,
10221        });
10222
10223        for &field in [
10224            "alt",
10225            "project",
10226            "userProject",
10227            "projection",
10228            "prefix",
10229            "pageToken",
10230            "maxResults",
10231        ]
10232        .iter()
10233        {
10234            if self._additional_params.contains_key(field) {
10235                dlg.finished(false);
10236                return Err(common::Error::FieldClash(field));
10237            }
10238        }
10239
10240        let mut params = Params::with_capacity(8 + self._additional_params.len());
10241        params.push("project", self._project);
10242        if let Some(value) = self._user_project.as_ref() {
10243            params.push("userProject", value);
10244        }
10245        if let Some(value) = self._projection.as_ref() {
10246            params.push("projection", value);
10247        }
10248        if let Some(value) = self._prefix.as_ref() {
10249            params.push("prefix", value);
10250        }
10251        if let Some(value) = self._page_token.as_ref() {
10252            params.push("pageToken", value);
10253        }
10254        if let Some(value) = self._max_results.as_ref() {
10255            params.push("maxResults", value.to_string());
10256        }
10257
10258        params.extend(self._additional_params.iter());
10259
10260        params.push("alt", "json");
10261        let mut url = self.hub._base_url.clone() + "b";
10262        if self._scopes.is_empty() {
10263            self._scopes
10264                .insert(Scope::CloudPlatform.as_ref().to_string());
10265        }
10266
10267        let url = params.parse_with_url(&url);
10268
10269        loop {
10270            let token = match self
10271                .hub
10272                .auth
10273                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10274                .await
10275            {
10276                Ok(token) => token,
10277                Err(e) => match dlg.token(e) {
10278                    Ok(token) => token,
10279                    Err(e) => {
10280                        dlg.finished(false);
10281                        return Err(common::Error::MissingToken(e));
10282                    }
10283                },
10284            };
10285            let mut req_result = {
10286                let client = &self.hub.client;
10287                dlg.pre_request();
10288                let mut req_builder = hyper::Request::builder()
10289                    .method(hyper::Method::GET)
10290                    .uri(url.as_str())
10291                    .header(USER_AGENT, self.hub._user_agent.clone());
10292
10293                if let Some(token) = token.as_ref() {
10294                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10295                }
10296
10297                let request = req_builder
10298                    .header(CONTENT_LENGTH, 0_u64)
10299                    .body(common::to_body::<String>(None));
10300
10301                client.request(request.unwrap()).await
10302            };
10303
10304            match req_result {
10305                Err(err) => {
10306                    if let common::Retry::After(d) = dlg.http_error(&err) {
10307                        sleep(d).await;
10308                        continue;
10309                    }
10310                    dlg.finished(false);
10311                    return Err(common::Error::HttpError(err));
10312                }
10313                Ok(res) => {
10314                    let (mut parts, body) = res.into_parts();
10315                    let mut body = common::Body::new(body);
10316                    if !parts.status.is_success() {
10317                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10318                        let error = serde_json::from_str(&common::to_string(&bytes));
10319                        let response = common::to_response(parts, bytes.into());
10320
10321                        if let common::Retry::After(d) =
10322                            dlg.http_failure(&response, error.as_ref().ok())
10323                        {
10324                            sleep(d).await;
10325                            continue;
10326                        }
10327
10328                        dlg.finished(false);
10329
10330                        return Err(match error {
10331                            Ok(value) => common::Error::BadRequest(value),
10332                            _ => common::Error::Failure(response),
10333                        });
10334                    }
10335                    let response = {
10336                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10337                        let encoded = common::to_string(&bytes);
10338                        match serde_json::from_str(&encoded) {
10339                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10340                            Err(error) => {
10341                                dlg.response_json_decode_error(&encoded, &error);
10342                                return Err(common::Error::JsonDecodeError(
10343                                    encoded.to_string(),
10344                                    error,
10345                                ));
10346                            }
10347                        }
10348                    };
10349
10350                    dlg.finished(true);
10351                    return Ok(response);
10352                }
10353            }
10354        }
10355    }
10356
10357    /// A valid API project identifier.
10358    ///
10359    /// Sets the *project* query property to the given value.
10360    ///
10361    /// Even though the property as already been set when instantiating this call,
10362    /// we provide this method for API completeness.
10363    pub fn project(mut self, new_value: &str) -> BucketListCall<'a, C> {
10364        self._project = new_value.to_string();
10365        self
10366    }
10367    /// The project to be billed for this request.
10368    ///
10369    /// Sets the *user project* query property to the given value.
10370    pub fn user_project(mut self, new_value: &str) -> BucketListCall<'a, C> {
10371        self._user_project = Some(new_value.to_string());
10372        self
10373    }
10374    /// Set of properties to return. Defaults to noAcl.
10375    ///
10376    /// Sets the *projection* query property to the given value.
10377    pub fn projection(mut self, new_value: &str) -> BucketListCall<'a, C> {
10378        self._projection = Some(new_value.to_string());
10379        self
10380    }
10381    /// Filter results to buckets whose names begin with this prefix.
10382    ///
10383    /// Sets the *prefix* query property to the given value.
10384    pub fn prefix(mut self, new_value: &str) -> BucketListCall<'a, C> {
10385        self._prefix = Some(new_value.to_string());
10386        self
10387    }
10388    /// A previously-returned page token representing part of the larger set of results to view.
10389    ///
10390    /// Sets the *page token* query property to the given value.
10391    pub fn page_token(mut self, new_value: &str) -> BucketListCall<'a, C> {
10392        self._page_token = Some(new_value.to_string());
10393        self
10394    }
10395    /// Maximum number of buckets to return in a single response. The service will use this parameter or 1,000 items, whichever is smaller.
10396    ///
10397    /// Sets the *max results* query property to the given value.
10398    pub fn max_results(mut self, new_value: u32) -> BucketListCall<'a, C> {
10399        self._max_results = Some(new_value);
10400        self
10401    }
10402    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10403    /// while executing the actual API request.
10404    ///
10405    /// ````text
10406    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10407    /// ````
10408    ///
10409    /// Sets the *delegate* property to the given value.
10410    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> BucketListCall<'a, C> {
10411        self._delegate = Some(new_value);
10412        self
10413    }
10414
10415    /// Set any additional parameter of the query string used in the request.
10416    /// It should be used to set parameters which are not yet available through their own
10417    /// setters.
10418    ///
10419    /// Please note that this method must not be used to set any of the known parameters
10420    /// which have their own setter method. If done anyway, the request will fail.
10421    ///
10422    /// # Additional Parameters
10423    ///
10424    /// * *alt* (query-string) - Data format for the response.
10425    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10426    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10427    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10428    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10429    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10430    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
10431    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10432    pub fn param<T>(mut self, name: T, value: T) -> BucketListCall<'a, C>
10433    where
10434        T: AsRef<str>,
10435    {
10436        self._additional_params
10437            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10438        self
10439    }
10440
10441    /// Identifies the authorization scope for the method you are building.
10442    ///
10443    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10444    /// [`Scope::CloudPlatform`].
10445    ///
10446    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10447    /// tokens for more than one scope.
10448    ///
10449    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10450    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10451    /// sufficient, a read-write scope will do as well.
10452    pub fn add_scope<St>(mut self, scope: St) -> BucketListCall<'a, C>
10453    where
10454        St: AsRef<str>,
10455    {
10456        self._scopes.insert(String::from(scope.as_ref()));
10457        self
10458    }
10459    /// Identifies the authorization scope(s) for the method you are building.
10460    ///
10461    /// See [`Self::add_scope()`] for details.
10462    pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketListCall<'a, C>
10463    where
10464        I: IntoIterator<Item = St>,
10465        St: AsRef<str>,
10466    {
10467        self._scopes
10468            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10469        self
10470    }
10471
10472    /// Removes all scopes, and no default scope will be used either.
10473    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10474    /// for details).
10475    pub fn clear_scopes(mut self) -> BucketListCall<'a, C> {
10476        self._scopes.clear();
10477        self
10478    }
10479}
10480
10481/// Locks retention policy on a bucket.
10482///
10483/// A builder for the *lockRetentionPolicy* method supported by a *bucket* resource.
10484/// It is not used directly, but through a [`BucketMethods`] instance.
10485///
10486/// # Example
10487///
10488/// Instantiate a resource method builder
10489///
10490/// ```test_harness,no_run
10491/// # extern crate hyper;
10492/// # extern crate hyper_rustls;
10493/// # extern crate google_storage1 as storage1;
10494/// # async fn dox() {
10495/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10496///
10497/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10498/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10499/// #     secret,
10500/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10501/// # ).build().await.unwrap();
10502///
10503/// # let client = hyper_util::client::legacy::Client::builder(
10504/// #     hyper_util::rt::TokioExecutor::new()
10505/// # )
10506/// # .build(
10507/// #     hyper_rustls::HttpsConnectorBuilder::new()
10508/// #         .with_native_roots()
10509/// #         .unwrap()
10510/// #         .https_or_http()
10511/// #         .enable_http1()
10512/// #         .build()
10513/// # );
10514/// # let mut hub = Storage::new(client, auth);
10515/// // You can configure optional parameters by calling the respective setters at will, and
10516/// // execute the final call using `doit()`.
10517/// // Values shown here are possibly random and not representative !
10518/// let result = hub.buckets().lock_retention_policy("bucket", -11)
10519///              .user_project("et")
10520///              .doit().await;
10521/// # }
10522/// ```
10523pub struct BucketLockRetentionPolicyCall<'a, C>
10524where
10525    C: 'a,
10526{
10527    hub: &'a Storage<C>,
10528    _bucket: String,
10529    _if_metageneration_match: i64,
10530    _user_project: Option<String>,
10531    _delegate: Option<&'a mut dyn common::Delegate>,
10532    _additional_params: HashMap<String, String>,
10533    _scopes: BTreeSet<String>,
10534}
10535
10536impl<'a, C> common::CallBuilder for BucketLockRetentionPolicyCall<'a, C> {}
10537
10538impl<'a, C> BucketLockRetentionPolicyCall<'a, C>
10539where
10540    C: common::Connector,
10541{
10542    /// Perform the operation you have build so far.
10543    pub async fn doit(mut self) -> common::Result<(common::Response, Bucket)> {
10544        use std::borrow::Cow;
10545        use std::io::{Read, Seek};
10546
10547        use common::{url::Params, ToParts};
10548        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10549
10550        let mut dd = common::DefaultDelegate;
10551        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10552        dlg.begin(common::MethodInfo {
10553            id: "storage.buckets.lockRetentionPolicy",
10554            http_method: hyper::Method::POST,
10555        });
10556
10557        for &field in ["alt", "bucket", "ifMetagenerationMatch", "userProject"].iter() {
10558            if self._additional_params.contains_key(field) {
10559                dlg.finished(false);
10560                return Err(common::Error::FieldClash(field));
10561            }
10562        }
10563
10564        let mut params = Params::with_capacity(5 + self._additional_params.len());
10565        params.push("bucket", self._bucket);
10566        params.push(
10567            "ifMetagenerationMatch",
10568            self._if_metageneration_match.to_string(),
10569        );
10570        if let Some(value) = self._user_project.as_ref() {
10571            params.push("userProject", value);
10572        }
10573
10574        params.extend(self._additional_params.iter());
10575
10576        params.push("alt", "json");
10577        let mut url = self.hub._base_url.clone() + "b/{bucket}/lockRetentionPolicy";
10578        if self._scopes.is_empty() {
10579            self._scopes
10580                .insert(Scope::CloudPlatform.as_ref().to_string());
10581        }
10582
10583        #[allow(clippy::single_element_loop)]
10584        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
10585            url = params.uri_replacement(url, param_name, find_this, false);
10586        }
10587        {
10588            let to_remove = ["bucket"];
10589            params.remove_params(&to_remove);
10590        }
10591
10592        let url = params.parse_with_url(&url);
10593
10594        loop {
10595            let token = match self
10596                .hub
10597                .auth
10598                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10599                .await
10600            {
10601                Ok(token) => token,
10602                Err(e) => match dlg.token(e) {
10603                    Ok(token) => token,
10604                    Err(e) => {
10605                        dlg.finished(false);
10606                        return Err(common::Error::MissingToken(e));
10607                    }
10608                },
10609            };
10610            let mut req_result = {
10611                let client = &self.hub.client;
10612                dlg.pre_request();
10613                let mut req_builder = hyper::Request::builder()
10614                    .method(hyper::Method::POST)
10615                    .uri(url.as_str())
10616                    .header(USER_AGENT, self.hub._user_agent.clone());
10617
10618                if let Some(token) = token.as_ref() {
10619                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10620                }
10621
10622                let request = req_builder
10623                    .header(CONTENT_LENGTH, 0_u64)
10624                    .body(common::to_body::<String>(None));
10625
10626                client.request(request.unwrap()).await
10627            };
10628
10629            match req_result {
10630                Err(err) => {
10631                    if let common::Retry::After(d) = dlg.http_error(&err) {
10632                        sleep(d).await;
10633                        continue;
10634                    }
10635                    dlg.finished(false);
10636                    return Err(common::Error::HttpError(err));
10637                }
10638                Ok(res) => {
10639                    let (mut parts, body) = res.into_parts();
10640                    let mut body = common::Body::new(body);
10641                    if !parts.status.is_success() {
10642                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10643                        let error = serde_json::from_str(&common::to_string(&bytes));
10644                        let response = common::to_response(parts, bytes.into());
10645
10646                        if let common::Retry::After(d) =
10647                            dlg.http_failure(&response, error.as_ref().ok())
10648                        {
10649                            sleep(d).await;
10650                            continue;
10651                        }
10652
10653                        dlg.finished(false);
10654
10655                        return Err(match error {
10656                            Ok(value) => common::Error::BadRequest(value),
10657                            _ => common::Error::Failure(response),
10658                        });
10659                    }
10660                    let response = {
10661                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10662                        let encoded = common::to_string(&bytes);
10663                        match serde_json::from_str(&encoded) {
10664                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10665                            Err(error) => {
10666                                dlg.response_json_decode_error(&encoded, &error);
10667                                return Err(common::Error::JsonDecodeError(
10668                                    encoded.to_string(),
10669                                    error,
10670                                ));
10671                            }
10672                        }
10673                    };
10674
10675                    dlg.finished(true);
10676                    return Ok(response);
10677                }
10678            }
10679        }
10680    }
10681
10682    /// Name of a bucket.
10683    ///
10684    /// Sets the *bucket* path property to the given value.
10685    ///
10686    /// Even though the property as already been set when instantiating this call,
10687    /// we provide this method for API completeness.
10688    pub fn bucket(mut self, new_value: &str) -> BucketLockRetentionPolicyCall<'a, C> {
10689        self._bucket = new_value.to_string();
10690        self
10691    }
10692    /// Makes the operation conditional on whether bucket's current metageneration matches the given value.
10693    ///
10694    /// Sets the *if metageneration match* query property to the given value.
10695    ///
10696    /// Even though the property as already been set when instantiating this call,
10697    /// we provide this method for API completeness.
10698    pub fn if_metageneration_match(
10699        mut self,
10700        new_value: i64,
10701    ) -> BucketLockRetentionPolicyCall<'a, C> {
10702        self._if_metageneration_match = new_value;
10703        self
10704    }
10705    /// The project to be billed for this request. Required for Requester Pays buckets.
10706    ///
10707    /// Sets the *user project* query property to the given value.
10708    pub fn user_project(mut self, new_value: &str) -> BucketLockRetentionPolicyCall<'a, C> {
10709        self._user_project = Some(new_value.to_string());
10710        self
10711    }
10712    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10713    /// while executing the actual API request.
10714    ///
10715    /// ````text
10716    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10717    /// ````
10718    ///
10719    /// Sets the *delegate* property to the given value.
10720    pub fn delegate(
10721        mut self,
10722        new_value: &'a mut dyn common::Delegate,
10723    ) -> BucketLockRetentionPolicyCall<'a, C> {
10724        self._delegate = Some(new_value);
10725        self
10726    }
10727
10728    /// Set any additional parameter of the query string used in the request.
10729    /// It should be used to set parameters which are not yet available through their own
10730    /// setters.
10731    ///
10732    /// Please note that this method must not be used to set any of the known parameters
10733    /// which have their own setter method. If done anyway, the request will fail.
10734    ///
10735    /// # Additional Parameters
10736    ///
10737    /// * *alt* (query-string) - Data format for the response.
10738    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10739    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10740    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10741    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10742    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10743    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
10744    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10745    pub fn param<T>(mut self, name: T, value: T) -> BucketLockRetentionPolicyCall<'a, C>
10746    where
10747        T: AsRef<str>,
10748    {
10749        self._additional_params
10750            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10751        self
10752    }
10753
10754    /// Identifies the authorization scope for the method you are building.
10755    ///
10756    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10757    /// [`Scope::CloudPlatform`].
10758    ///
10759    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10760    /// tokens for more than one scope.
10761    ///
10762    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10763    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10764    /// sufficient, a read-write scope will do as well.
10765    pub fn add_scope<St>(mut self, scope: St) -> BucketLockRetentionPolicyCall<'a, C>
10766    where
10767        St: AsRef<str>,
10768    {
10769        self._scopes.insert(String::from(scope.as_ref()));
10770        self
10771    }
10772    /// Identifies the authorization scope(s) for the method you are building.
10773    ///
10774    /// See [`Self::add_scope()`] for details.
10775    pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketLockRetentionPolicyCall<'a, C>
10776    where
10777        I: IntoIterator<Item = St>,
10778        St: AsRef<str>,
10779    {
10780        self._scopes
10781            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10782        self
10783    }
10784
10785    /// Removes all scopes, and no default scope will be used either.
10786    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10787    /// for details).
10788    pub fn clear_scopes(mut self) -> BucketLockRetentionPolicyCall<'a, C> {
10789        self._scopes.clear();
10790        self
10791    }
10792}
10793
10794/// Patches a bucket. Changes to the bucket will be readable immediately after writing, but configuration changes may take time to propagate.
10795///
10796/// A builder for the *patch* method supported by a *bucket* resource.
10797/// It is not used directly, but through a [`BucketMethods`] instance.
10798///
10799/// # Example
10800///
10801/// Instantiate a resource method builder
10802///
10803/// ```test_harness,no_run
10804/// # extern crate hyper;
10805/// # extern crate hyper_rustls;
10806/// # extern crate google_storage1 as storage1;
10807/// use storage1::api::Bucket;
10808/// # async fn dox() {
10809/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10810///
10811/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10812/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10813/// #     secret,
10814/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10815/// # ).build().await.unwrap();
10816///
10817/// # let client = hyper_util::client::legacy::Client::builder(
10818/// #     hyper_util::rt::TokioExecutor::new()
10819/// # )
10820/// # .build(
10821/// #     hyper_rustls::HttpsConnectorBuilder::new()
10822/// #         .with_native_roots()
10823/// #         .unwrap()
10824/// #         .https_or_http()
10825/// #         .enable_http1()
10826/// #         .build()
10827/// # );
10828/// # let mut hub = Storage::new(client, auth);
10829/// // As the method needs a request, you would usually fill it with the desired information
10830/// // into the respective structure. Some of the parts shown here might not be applicable !
10831/// // Values shown here are possibly random and not representative !
10832/// let mut req = Bucket::default();
10833///
10834/// // You can configure optional parameters by calling the respective setters at will, and
10835/// // execute the final call using `doit()`.
10836/// // Values shown here are possibly random and not representative !
10837/// let result = hub.buckets().patch(req, "bucket")
10838///              .user_project("sed")
10839///              .projection("no")
10840///              .predefined_default_object_acl("nonumy")
10841///              .predefined_acl("At")
10842///              .if_metageneration_not_match(-45)
10843///              .if_metageneration_match(-32)
10844///              .doit().await;
10845/// # }
10846/// ```
10847pub struct BucketPatchCall<'a, C>
10848where
10849    C: 'a,
10850{
10851    hub: &'a Storage<C>,
10852    _request: Bucket,
10853    _bucket: String,
10854    _user_project: Option<String>,
10855    _projection: Option<String>,
10856    _predefined_default_object_acl: Option<String>,
10857    _predefined_acl: Option<String>,
10858    _if_metageneration_not_match: Option<i64>,
10859    _if_metageneration_match: Option<i64>,
10860    _delegate: Option<&'a mut dyn common::Delegate>,
10861    _additional_params: HashMap<String, String>,
10862    _scopes: BTreeSet<String>,
10863}
10864
10865impl<'a, C> common::CallBuilder for BucketPatchCall<'a, C> {}
10866
10867impl<'a, C> BucketPatchCall<'a, C>
10868where
10869    C: common::Connector,
10870{
10871    /// Perform the operation you have build so far.
10872    pub async fn doit(mut self) -> common::Result<(common::Response, Bucket)> {
10873        use std::borrow::Cow;
10874        use std::io::{Read, Seek};
10875
10876        use common::{url::Params, ToParts};
10877        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10878
10879        let mut dd = common::DefaultDelegate;
10880        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10881        dlg.begin(common::MethodInfo {
10882            id: "storage.buckets.patch",
10883            http_method: hyper::Method::PATCH,
10884        });
10885
10886        for &field in [
10887            "alt",
10888            "bucket",
10889            "userProject",
10890            "projection",
10891            "predefinedDefaultObjectAcl",
10892            "predefinedAcl",
10893            "ifMetagenerationNotMatch",
10894            "ifMetagenerationMatch",
10895        ]
10896        .iter()
10897        {
10898            if self._additional_params.contains_key(field) {
10899                dlg.finished(false);
10900                return Err(common::Error::FieldClash(field));
10901            }
10902        }
10903
10904        let mut params = Params::with_capacity(10 + self._additional_params.len());
10905        params.push("bucket", self._bucket);
10906        if let Some(value) = self._user_project.as_ref() {
10907            params.push("userProject", value);
10908        }
10909        if let Some(value) = self._projection.as_ref() {
10910            params.push("projection", value);
10911        }
10912        if let Some(value) = self._predefined_default_object_acl.as_ref() {
10913            params.push("predefinedDefaultObjectAcl", value);
10914        }
10915        if let Some(value) = self._predefined_acl.as_ref() {
10916            params.push("predefinedAcl", value);
10917        }
10918        if let Some(value) = self._if_metageneration_not_match.as_ref() {
10919            params.push("ifMetagenerationNotMatch", value.to_string());
10920        }
10921        if let Some(value) = self._if_metageneration_match.as_ref() {
10922            params.push("ifMetagenerationMatch", value.to_string());
10923        }
10924
10925        params.extend(self._additional_params.iter());
10926
10927        params.push("alt", "json");
10928        let mut url = self.hub._base_url.clone() + "b/{bucket}";
10929        if self._scopes.is_empty() {
10930            self._scopes
10931                .insert(Scope::CloudPlatform.as_ref().to_string());
10932        }
10933
10934        #[allow(clippy::single_element_loop)]
10935        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
10936            url = params.uri_replacement(url, param_name, find_this, false);
10937        }
10938        {
10939            let to_remove = ["bucket"];
10940            params.remove_params(&to_remove);
10941        }
10942
10943        let url = params.parse_with_url(&url);
10944
10945        let mut json_mime_type = mime::APPLICATION_JSON;
10946        let mut request_value_reader = {
10947            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10948            common::remove_json_null_values(&mut value);
10949            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10950            serde_json::to_writer(&mut dst, &value).unwrap();
10951            dst
10952        };
10953        let request_size = request_value_reader
10954            .seek(std::io::SeekFrom::End(0))
10955            .unwrap();
10956        request_value_reader
10957            .seek(std::io::SeekFrom::Start(0))
10958            .unwrap();
10959
10960        loop {
10961            let token = match self
10962                .hub
10963                .auth
10964                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10965                .await
10966            {
10967                Ok(token) => token,
10968                Err(e) => match dlg.token(e) {
10969                    Ok(token) => token,
10970                    Err(e) => {
10971                        dlg.finished(false);
10972                        return Err(common::Error::MissingToken(e));
10973                    }
10974                },
10975            };
10976            request_value_reader
10977                .seek(std::io::SeekFrom::Start(0))
10978                .unwrap();
10979            let mut req_result = {
10980                let client = &self.hub.client;
10981                dlg.pre_request();
10982                let mut req_builder = hyper::Request::builder()
10983                    .method(hyper::Method::PATCH)
10984                    .uri(url.as_str())
10985                    .header(USER_AGENT, self.hub._user_agent.clone());
10986
10987                if let Some(token) = token.as_ref() {
10988                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10989                }
10990
10991                let request = req_builder
10992                    .header(CONTENT_TYPE, json_mime_type.to_string())
10993                    .header(CONTENT_LENGTH, request_size as u64)
10994                    .body(common::to_body(
10995                        request_value_reader.get_ref().clone().into(),
10996                    ));
10997
10998                client.request(request.unwrap()).await
10999            };
11000
11001            match req_result {
11002                Err(err) => {
11003                    if let common::Retry::After(d) = dlg.http_error(&err) {
11004                        sleep(d).await;
11005                        continue;
11006                    }
11007                    dlg.finished(false);
11008                    return Err(common::Error::HttpError(err));
11009                }
11010                Ok(res) => {
11011                    let (mut parts, body) = res.into_parts();
11012                    let mut body = common::Body::new(body);
11013                    if !parts.status.is_success() {
11014                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11015                        let error = serde_json::from_str(&common::to_string(&bytes));
11016                        let response = common::to_response(parts, bytes.into());
11017
11018                        if let common::Retry::After(d) =
11019                            dlg.http_failure(&response, error.as_ref().ok())
11020                        {
11021                            sleep(d).await;
11022                            continue;
11023                        }
11024
11025                        dlg.finished(false);
11026
11027                        return Err(match error {
11028                            Ok(value) => common::Error::BadRequest(value),
11029                            _ => common::Error::Failure(response),
11030                        });
11031                    }
11032                    let response = {
11033                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11034                        let encoded = common::to_string(&bytes);
11035                        match serde_json::from_str(&encoded) {
11036                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11037                            Err(error) => {
11038                                dlg.response_json_decode_error(&encoded, &error);
11039                                return Err(common::Error::JsonDecodeError(
11040                                    encoded.to_string(),
11041                                    error,
11042                                ));
11043                            }
11044                        }
11045                    };
11046
11047                    dlg.finished(true);
11048                    return Ok(response);
11049                }
11050            }
11051        }
11052    }
11053
11054    ///
11055    /// Sets the *request* property to the given value.
11056    ///
11057    /// Even though the property as already been set when instantiating this call,
11058    /// we provide this method for API completeness.
11059    pub fn request(mut self, new_value: Bucket) -> BucketPatchCall<'a, C> {
11060        self._request = new_value;
11061        self
11062    }
11063    /// Name of a bucket.
11064    ///
11065    /// Sets the *bucket* path property to the given value.
11066    ///
11067    /// Even though the property as already been set when instantiating this call,
11068    /// we provide this method for API completeness.
11069    pub fn bucket(mut self, new_value: &str) -> BucketPatchCall<'a, C> {
11070        self._bucket = new_value.to_string();
11071        self
11072    }
11073    /// The project to be billed for this request. Required for Requester Pays buckets.
11074    ///
11075    /// Sets the *user project* query property to the given value.
11076    pub fn user_project(mut self, new_value: &str) -> BucketPatchCall<'a, C> {
11077        self._user_project = Some(new_value.to_string());
11078        self
11079    }
11080    /// Set of properties to return. Defaults to full.
11081    ///
11082    /// Sets the *projection* query property to the given value.
11083    pub fn projection(mut self, new_value: &str) -> BucketPatchCall<'a, C> {
11084        self._projection = Some(new_value.to_string());
11085        self
11086    }
11087    /// Apply a predefined set of default object access controls to this bucket.
11088    ///
11089    /// Sets the *predefined default object acl* query property to the given value.
11090    pub fn predefined_default_object_acl(mut self, new_value: &str) -> BucketPatchCall<'a, C> {
11091        self._predefined_default_object_acl = Some(new_value.to_string());
11092        self
11093    }
11094    /// Apply a predefined set of access controls to this bucket.
11095    ///
11096    /// Sets the *predefined acl* query property to the given value.
11097    pub fn predefined_acl(mut self, new_value: &str) -> BucketPatchCall<'a, C> {
11098        self._predefined_acl = Some(new_value.to_string());
11099        self
11100    }
11101    /// Makes the return of the bucket metadata conditional on whether the bucket's current metageneration does not match the given value.
11102    ///
11103    /// Sets the *if metageneration not match* query property to the given value.
11104    pub fn if_metageneration_not_match(mut self, new_value: i64) -> BucketPatchCall<'a, C> {
11105        self._if_metageneration_not_match = Some(new_value);
11106        self
11107    }
11108    /// Makes the return of the bucket metadata conditional on whether the bucket's current metageneration matches the given value.
11109    ///
11110    /// Sets the *if metageneration match* query property to the given value.
11111    pub fn if_metageneration_match(mut self, new_value: i64) -> BucketPatchCall<'a, C> {
11112        self._if_metageneration_match = Some(new_value);
11113        self
11114    }
11115    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11116    /// while executing the actual API request.
11117    ///
11118    /// ````text
11119    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11120    /// ````
11121    ///
11122    /// Sets the *delegate* property to the given value.
11123    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> BucketPatchCall<'a, C> {
11124        self._delegate = Some(new_value);
11125        self
11126    }
11127
11128    /// Set any additional parameter of the query string used in the request.
11129    /// It should be used to set parameters which are not yet available through their own
11130    /// setters.
11131    ///
11132    /// Please note that this method must not be used to set any of the known parameters
11133    /// which have their own setter method. If done anyway, the request will fail.
11134    ///
11135    /// # Additional Parameters
11136    ///
11137    /// * *alt* (query-string) - Data format for the response.
11138    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11139    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11140    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11141    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11142    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11143    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
11144    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11145    pub fn param<T>(mut self, name: T, value: T) -> BucketPatchCall<'a, C>
11146    where
11147        T: AsRef<str>,
11148    {
11149        self._additional_params
11150            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11151        self
11152    }
11153
11154    /// Identifies the authorization scope for the method you are building.
11155    ///
11156    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11157    /// [`Scope::CloudPlatform`].
11158    ///
11159    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11160    /// tokens for more than one scope.
11161    ///
11162    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11163    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11164    /// sufficient, a read-write scope will do as well.
11165    pub fn add_scope<St>(mut self, scope: St) -> BucketPatchCall<'a, C>
11166    where
11167        St: AsRef<str>,
11168    {
11169        self._scopes.insert(String::from(scope.as_ref()));
11170        self
11171    }
11172    /// Identifies the authorization scope(s) for the method you are building.
11173    ///
11174    /// See [`Self::add_scope()`] for details.
11175    pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketPatchCall<'a, C>
11176    where
11177        I: IntoIterator<Item = St>,
11178        St: AsRef<str>,
11179    {
11180        self._scopes
11181            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11182        self
11183    }
11184
11185    /// Removes all scopes, and no default scope will be used either.
11186    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11187    /// for details).
11188    pub fn clear_scopes(mut self) -> BucketPatchCall<'a, C> {
11189        self._scopes.clear();
11190        self
11191    }
11192}
11193
11194/// Updates an IAM policy for the specified bucket.
11195///
11196/// A builder for the *setIamPolicy* method supported by a *bucket* resource.
11197/// It is not used directly, but through a [`BucketMethods`] instance.
11198///
11199/// # Example
11200///
11201/// Instantiate a resource method builder
11202///
11203/// ```test_harness,no_run
11204/// # extern crate hyper;
11205/// # extern crate hyper_rustls;
11206/// # extern crate google_storage1 as storage1;
11207/// use storage1::api::Policy;
11208/// # async fn dox() {
11209/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11210///
11211/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11212/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11213/// #     secret,
11214/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11215/// # ).build().await.unwrap();
11216///
11217/// # let client = hyper_util::client::legacy::Client::builder(
11218/// #     hyper_util::rt::TokioExecutor::new()
11219/// # )
11220/// # .build(
11221/// #     hyper_rustls::HttpsConnectorBuilder::new()
11222/// #         .with_native_roots()
11223/// #         .unwrap()
11224/// #         .https_or_http()
11225/// #         .enable_http1()
11226/// #         .build()
11227/// # );
11228/// # let mut hub = Storage::new(client, auth);
11229/// // As the method needs a request, you would usually fill it with the desired information
11230/// // into the respective structure. Some of the parts shown here might not be applicable !
11231/// // Values shown here are possibly random and not representative !
11232/// let mut req = Policy::default();
11233///
11234/// // You can configure optional parameters by calling the respective setters at will, and
11235/// // execute the final call using `doit()`.
11236/// // Values shown here are possibly random and not representative !
11237/// let result = hub.buckets().set_iam_policy(req, "bucket")
11238///              .user_project("sadipscing")
11239///              .doit().await;
11240/// # }
11241/// ```
11242pub struct BucketSetIamPolicyCall<'a, C>
11243where
11244    C: 'a,
11245{
11246    hub: &'a Storage<C>,
11247    _request: Policy,
11248    _bucket: String,
11249    _user_project: Option<String>,
11250    _delegate: Option<&'a mut dyn common::Delegate>,
11251    _additional_params: HashMap<String, String>,
11252    _scopes: BTreeSet<String>,
11253}
11254
11255impl<'a, C> common::CallBuilder for BucketSetIamPolicyCall<'a, C> {}
11256
11257impl<'a, C> BucketSetIamPolicyCall<'a, C>
11258where
11259    C: common::Connector,
11260{
11261    /// Perform the operation you have build so far.
11262    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
11263        use std::borrow::Cow;
11264        use std::io::{Read, Seek};
11265
11266        use common::{url::Params, ToParts};
11267        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11268
11269        let mut dd = common::DefaultDelegate;
11270        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11271        dlg.begin(common::MethodInfo {
11272            id: "storage.buckets.setIamPolicy",
11273            http_method: hyper::Method::PUT,
11274        });
11275
11276        for &field in ["alt", "bucket", "userProject"].iter() {
11277            if self._additional_params.contains_key(field) {
11278                dlg.finished(false);
11279                return Err(common::Error::FieldClash(field));
11280            }
11281        }
11282
11283        let mut params = Params::with_capacity(5 + self._additional_params.len());
11284        params.push("bucket", self._bucket);
11285        if let Some(value) = self._user_project.as_ref() {
11286            params.push("userProject", value);
11287        }
11288
11289        params.extend(self._additional_params.iter());
11290
11291        params.push("alt", "json");
11292        let mut url = self.hub._base_url.clone() + "b/{bucket}/iam";
11293        if self._scopes.is_empty() {
11294            self._scopes
11295                .insert(Scope::CloudPlatform.as_ref().to_string());
11296        }
11297
11298        #[allow(clippy::single_element_loop)]
11299        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
11300            url = params.uri_replacement(url, param_name, find_this, false);
11301        }
11302        {
11303            let to_remove = ["bucket"];
11304            params.remove_params(&to_remove);
11305        }
11306
11307        let url = params.parse_with_url(&url);
11308
11309        let mut json_mime_type = mime::APPLICATION_JSON;
11310        let mut request_value_reader = {
11311            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11312            common::remove_json_null_values(&mut value);
11313            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11314            serde_json::to_writer(&mut dst, &value).unwrap();
11315            dst
11316        };
11317        let request_size = request_value_reader
11318            .seek(std::io::SeekFrom::End(0))
11319            .unwrap();
11320        request_value_reader
11321            .seek(std::io::SeekFrom::Start(0))
11322            .unwrap();
11323
11324        loop {
11325            let token = match self
11326                .hub
11327                .auth
11328                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11329                .await
11330            {
11331                Ok(token) => token,
11332                Err(e) => match dlg.token(e) {
11333                    Ok(token) => token,
11334                    Err(e) => {
11335                        dlg.finished(false);
11336                        return Err(common::Error::MissingToken(e));
11337                    }
11338                },
11339            };
11340            request_value_reader
11341                .seek(std::io::SeekFrom::Start(0))
11342                .unwrap();
11343            let mut req_result = {
11344                let client = &self.hub.client;
11345                dlg.pre_request();
11346                let mut req_builder = hyper::Request::builder()
11347                    .method(hyper::Method::PUT)
11348                    .uri(url.as_str())
11349                    .header(USER_AGENT, self.hub._user_agent.clone());
11350
11351                if let Some(token) = token.as_ref() {
11352                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11353                }
11354
11355                let request = req_builder
11356                    .header(CONTENT_TYPE, json_mime_type.to_string())
11357                    .header(CONTENT_LENGTH, request_size as u64)
11358                    .body(common::to_body(
11359                        request_value_reader.get_ref().clone().into(),
11360                    ));
11361
11362                client.request(request.unwrap()).await
11363            };
11364
11365            match req_result {
11366                Err(err) => {
11367                    if let common::Retry::After(d) = dlg.http_error(&err) {
11368                        sleep(d).await;
11369                        continue;
11370                    }
11371                    dlg.finished(false);
11372                    return Err(common::Error::HttpError(err));
11373                }
11374                Ok(res) => {
11375                    let (mut parts, body) = res.into_parts();
11376                    let mut body = common::Body::new(body);
11377                    if !parts.status.is_success() {
11378                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11379                        let error = serde_json::from_str(&common::to_string(&bytes));
11380                        let response = common::to_response(parts, bytes.into());
11381
11382                        if let common::Retry::After(d) =
11383                            dlg.http_failure(&response, error.as_ref().ok())
11384                        {
11385                            sleep(d).await;
11386                            continue;
11387                        }
11388
11389                        dlg.finished(false);
11390
11391                        return Err(match error {
11392                            Ok(value) => common::Error::BadRequest(value),
11393                            _ => common::Error::Failure(response),
11394                        });
11395                    }
11396                    let response = {
11397                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11398                        let encoded = common::to_string(&bytes);
11399                        match serde_json::from_str(&encoded) {
11400                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11401                            Err(error) => {
11402                                dlg.response_json_decode_error(&encoded, &error);
11403                                return Err(common::Error::JsonDecodeError(
11404                                    encoded.to_string(),
11405                                    error,
11406                                ));
11407                            }
11408                        }
11409                    };
11410
11411                    dlg.finished(true);
11412                    return Ok(response);
11413                }
11414            }
11415        }
11416    }
11417
11418    ///
11419    /// Sets the *request* property to the given value.
11420    ///
11421    /// Even though the property as already been set when instantiating this call,
11422    /// we provide this method for API completeness.
11423    pub fn request(mut self, new_value: Policy) -> BucketSetIamPolicyCall<'a, C> {
11424        self._request = new_value;
11425        self
11426    }
11427    /// Name of a bucket.
11428    ///
11429    /// Sets the *bucket* path property to the given value.
11430    ///
11431    /// Even though the property as already been set when instantiating this call,
11432    /// we provide this method for API completeness.
11433    pub fn bucket(mut self, new_value: &str) -> BucketSetIamPolicyCall<'a, C> {
11434        self._bucket = new_value.to_string();
11435        self
11436    }
11437    /// The project to be billed for this request. Required for Requester Pays buckets.
11438    ///
11439    /// Sets the *user project* query property to the given value.
11440    pub fn user_project(mut self, new_value: &str) -> BucketSetIamPolicyCall<'a, C> {
11441        self._user_project = Some(new_value.to_string());
11442        self
11443    }
11444    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11445    /// while executing the actual API request.
11446    ///
11447    /// ````text
11448    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11449    /// ````
11450    ///
11451    /// Sets the *delegate* property to the given value.
11452    pub fn delegate(
11453        mut self,
11454        new_value: &'a mut dyn common::Delegate,
11455    ) -> BucketSetIamPolicyCall<'a, C> {
11456        self._delegate = Some(new_value);
11457        self
11458    }
11459
11460    /// Set any additional parameter of the query string used in the request.
11461    /// It should be used to set parameters which are not yet available through their own
11462    /// setters.
11463    ///
11464    /// Please note that this method must not be used to set any of the known parameters
11465    /// which have their own setter method. If done anyway, the request will fail.
11466    ///
11467    /// # Additional Parameters
11468    ///
11469    /// * *alt* (query-string) - Data format for the response.
11470    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11471    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11472    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11473    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11474    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11475    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
11476    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11477    pub fn param<T>(mut self, name: T, value: T) -> BucketSetIamPolicyCall<'a, C>
11478    where
11479        T: AsRef<str>,
11480    {
11481        self._additional_params
11482            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11483        self
11484    }
11485
11486    /// Identifies the authorization scope for the method you are building.
11487    ///
11488    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11489    /// [`Scope::CloudPlatform`].
11490    ///
11491    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11492    /// tokens for more than one scope.
11493    ///
11494    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11495    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11496    /// sufficient, a read-write scope will do as well.
11497    pub fn add_scope<St>(mut self, scope: St) -> BucketSetIamPolicyCall<'a, C>
11498    where
11499        St: AsRef<str>,
11500    {
11501        self._scopes.insert(String::from(scope.as_ref()));
11502        self
11503    }
11504    /// Identifies the authorization scope(s) for the method you are building.
11505    ///
11506    /// See [`Self::add_scope()`] for details.
11507    pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketSetIamPolicyCall<'a, C>
11508    where
11509        I: IntoIterator<Item = St>,
11510        St: AsRef<str>,
11511    {
11512        self._scopes
11513            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11514        self
11515    }
11516
11517    /// Removes all scopes, and no default scope will be used either.
11518    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11519    /// for details).
11520    pub fn clear_scopes(mut self) -> BucketSetIamPolicyCall<'a, C> {
11521        self._scopes.clear();
11522        self
11523    }
11524}
11525
11526/// Tests a set of permissions on the given bucket to see which, if any, are held by the caller.
11527///
11528/// A builder for the *testIamPermissions* method supported by a *bucket* resource.
11529/// It is not used directly, but through a [`BucketMethods`] instance.
11530///
11531/// # Example
11532///
11533/// Instantiate a resource method builder
11534///
11535/// ```test_harness,no_run
11536/// # extern crate hyper;
11537/// # extern crate hyper_rustls;
11538/// # extern crate google_storage1 as storage1;
11539/// # async fn dox() {
11540/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11541///
11542/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11543/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11544/// #     secret,
11545/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11546/// # ).build().await.unwrap();
11547///
11548/// # let client = hyper_util::client::legacy::Client::builder(
11549/// #     hyper_util::rt::TokioExecutor::new()
11550/// # )
11551/// # .build(
11552/// #     hyper_rustls::HttpsConnectorBuilder::new()
11553/// #         .with_native_roots()
11554/// #         .unwrap()
11555/// #         .https_or_http()
11556/// #         .enable_http1()
11557/// #         .build()
11558/// # );
11559/// # let mut hub = Storage::new(client, auth);
11560/// // You can configure optional parameters by calling the respective setters at will, and
11561/// // execute the final call using `doit()`.
11562/// // Values shown here are possibly random and not representative !
11563/// let result = hub.buckets().test_iam_permissions("bucket", &vec!["aliquyam".into()])
11564///              .user_project("amet")
11565///              .doit().await;
11566/// # }
11567/// ```
11568pub struct BucketTestIamPermissionCall<'a, C>
11569where
11570    C: 'a,
11571{
11572    hub: &'a Storage<C>,
11573    _bucket: String,
11574    _permissions: Vec<String>,
11575    _user_project: Option<String>,
11576    _delegate: Option<&'a mut dyn common::Delegate>,
11577    _additional_params: HashMap<String, String>,
11578    _scopes: BTreeSet<String>,
11579}
11580
11581impl<'a, C> common::CallBuilder for BucketTestIamPermissionCall<'a, C> {}
11582
11583impl<'a, C> BucketTestIamPermissionCall<'a, C>
11584where
11585    C: common::Connector,
11586{
11587    /// Perform the operation you have build so far.
11588    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
11589        use std::borrow::Cow;
11590        use std::io::{Read, Seek};
11591
11592        use common::{url::Params, ToParts};
11593        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11594
11595        let mut dd = common::DefaultDelegate;
11596        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11597        dlg.begin(common::MethodInfo {
11598            id: "storage.buckets.testIamPermissions",
11599            http_method: hyper::Method::GET,
11600        });
11601
11602        for &field in ["alt", "bucket", "permissions", "userProject"].iter() {
11603            if self._additional_params.contains_key(field) {
11604                dlg.finished(false);
11605                return Err(common::Error::FieldClash(field));
11606            }
11607        }
11608
11609        let mut params = Params::with_capacity(5 + self._additional_params.len());
11610        params.push("bucket", self._bucket);
11611        if !self._permissions.is_empty() {
11612            for f in self._permissions.iter() {
11613                params.push("permissions", f);
11614            }
11615        }
11616        if let Some(value) = self._user_project.as_ref() {
11617            params.push("userProject", value);
11618        }
11619
11620        params.extend(self._additional_params.iter());
11621
11622        params.push("alt", "json");
11623        let mut url = self.hub._base_url.clone() + "b/{bucket}/iam/testPermissions";
11624        if self._scopes.is_empty() {
11625            self._scopes
11626                .insert(Scope::CloudPlatform.as_ref().to_string());
11627        }
11628
11629        #[allow(clippy::single_element_loop)]
11630        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
11631            url = params.uri_replacement(url, param_name, find_this, false);
11632        }
11633        {
11634            let to_remove = ["bucket"];
11635            params.remove_params(&to_remove);
11636        }
11637
11638        let url = params.parse_with_url(&url);
11639
11640        loop {
11641            let token = match self
11642                .hub
11643                .auth
11644                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11645                .await
11646            {
11647                Ok(token) => token,
11648                Err(e) => match dlg.token(e) {
11649                    Ok(token) => token,
11650                    Err(e) => {
11651                        dlg.finished(false);
11652                        return Err(common::Error::MissingToken(e));
11653                    }
11654                },
11655            };
11656            let mut req_result = {
11657                let client = &self.hub.client;
11658                dlg.pre_request();
11659                let mut req_builder = hyper::Request::builder()
11660                    .method(hyper::Method::GET)
11661                    .uri(url.as_str())
11662                    .header(USER_AGENT, self.hub._user_agent.clone());
11663
11664                if let Some(token) = token.as_ref() {
11665                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11666                }
11667
11668                let request = req_builder
11669                    .header(CONTENT_LENGTH, 0_u64)
11670                    .body(common::to_body::<String>(None));
11671
11672                client.request(request.unwrap()).await
11673            };
11674
11675            match req_result {
11676                Err(err) => {
11677                    if let common::Retry::After(d) = dlg.http_error(&err) {
11678                        sleep(d).await;
11679                        continue;
11680                    }
11681                    dlg.finished(false);
11682                    return Err(common::Error::HttpError(err));
11683                }
11684                Ok(res) => {
11685                    let (mut parts, body) = res.into_parts();
11686                    let mut body = common::Body::new(body);
11687                    if !parts.status.is_success() {
11688                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11689                        let error = serde_json::from_str(&common::to_string(&bytes));
11690                        let response = common::to_response(parts, bytes.into());
11691
11692                        if let common::Retry::After(d) =
11693                            dlg.http_failure(&response, error.as_ref().ok())
11694                        {
11695                            sleep(d).await;
11696                            continue;
11697                        }
11698
11699                        dlg.finished(false);
11700
11701                        return Err(match error {
11702                            Ok(value) => common::Error::BadRequest(value),
11703                            _ => common::Error::Failure(response),
11704                        });
11705                    }
11706                    let response = {
11707                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11708                        let encoded = common::to_string(&bytes);
11709                        match serde_json::from_str(&encoded) {
11710                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11711                            Err(error) => {
11712                                dlg.response_json_decode_error(&encoded, &error);
11713                                return Err(common::Error::JsonDecodeError(
11714                                    encoded.to_string(),
11715                                    error,
11716                                ));
11717                            }
11718                        }
11719                    };
11720
11721                    dlg.finished(true);
11722                    return Ok(response);
11723                }
11724            }
11725        }
11726    }
11727
11728    /// Name of a bucket.
11729    ///
11730    /// Sets the *bucket* path property to the given value.
11731    ///
11732    /// Even though the property as already been set when instantiating this call,
11733    /// we provide this method for API completeness.
11734    pub fn bucket(mut self, new_value: &str) -> BucketTestIamPermissionCall<'a, C> {
11735        self._bucket = new_value.to_string();
11736        self
11737    }
11738    /// Permissions to test.
11739    ///
11740    /// Append the given value to the *permissions* query property.
11741    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
11742    ///
11743    /// Even though the property as already been set when instantiating this call,
11744    /// we provide this method for API completeness.
11745    pub fn add_permissions(mut self, new_value: &str) -> BucketTestIamPermissionCall<'a, C> {
11746        self._permissions.push(new_value.to_string());
11747        self
11748    }
11749    /// The project to be billed for this request. Required for Requester Pays buckets.
11750    ///
11751    /// Sets the *user project* query property to the given value.
11752    pub fn user_project(mut self, new_value: &str) -> BucketTestIamPermissionCall<'a, C> {
11753        self._user_project = Some(new_value.to_string());
11754        self
11755    }
11756    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11757    /// while executing the actual API request.
11758    ///
11759    /// ````text
11760    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11761    /// ````
11762    ///
11763    /// Sets the *delegate* property to the given value.
11764    pub fn delegate(
11765        mut self,
11766        new_value: &'a mut dyn common::Delegate,
11767    ) -> BucketTestIamPermissionCall<'a, C> {
11768        self._delegate = Some(new_value);
11769        self
11770    }
11771
11772    /// Set any additional parameter of the query string used in the request.
11773    /// It should be used to set parameters which are not yet available through their own
11774    /// setters.
11775    ///
11776    /// Please note that this method must not be used to set any of the known parameters
11777    /// which have their own setter method. If done anyway, the request will fail.
11778    ///
11779    /// # Additional Parameters
11780    ///
11781    /// * *alt* (query-string) - Data format for the response.
11782    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11783    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11784    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11785    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11786    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11787    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
11788    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11789    pub fn param<T>(mut self, name: T, value: T) -> BucketTestIamPermissionCall<'a, C>
11790    where
11791        T: AsRef<str>,
11792    {
11793        self._additional_params
11794            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11795        self
11796    }
11797
11798    /// Identifies the authorization scope for the method you are building.
11799    ///
11800    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11801    /// [`Scope::CloudPlatform`].
11802    ///
11803    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11804    /// tokens for more than one scope.
11805    ///
11806    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11807    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11808    /// sufficient, a read-write scope will do as well.
11809    pub fn add_scope<St>(mut self, scope: St) -> BucketTestIamPermissionCall<'a, C>
11810    where
11811        St: AsRef<str>,
11812    {
11813        self._scopes.insert(String::from(scope.as_ref()));
11814        self
11815    }
11816    /// Identifies the authorization scope(s) for the method you are building.
11817    ///
11818    /// See [`Self::add_scope()`] for details.
11819    pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketTestIamPermissionCall<'a, C>
11820    where
11821        I: IntoIterator<Item = St>,
11822        St: AsRef<str>,
11823    {
11824        self._scopes
11825            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11826        self
11827    }
11828
11829    /// Removes all scopes, and no default scope will be used either.
11830    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11831    /// for details).
11832    pub fn clear_scopes(mut self) -> BucketTestIamPermissionCall<'a, C> {
11833        self._scopes.clear();
11834        self
11835    }
11836}
11837
11838/// Updates a bucket. Changes to the bucket will be readable immediately after writing, but configuration changes may take time to propagate.
11839///
11840/// A builder for the *update* method supported by a *bucket* resource.
11841/// It is not used directly, but through a [`BucketMethods`] instance.
11842///
11843/// # Example
11844///
11845/// Instantiate a resource method builder
11846///
11847/// ```test_harness,no_run
11848/// # extern crate hyper;
11849/// # extern crate hyper_rustls;
11850/// # extern crate google_storage1 as storage1;
11851/// use storage1::api::Bucket;
11852/// # async fn dox() {
11853/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11854///
11855/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11856/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11857/// #     secret,
11858/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11859/// # ).build().await.unwrap();
11860///
11861/// # let client = hyper_util::client::legacy::Client::builder(
11862/// #     hyper_util::rt::TokioExecutor::new()
11863/// # )
11864/// # .build(
11865/// #     hyper_rustls::HttpsConnectorBuilder::new()
11866/// #         .with_native_roots()
11867/// #         .unwrap()
11868/// #         .https_or_http()
11869/// #         .enable_http1()
11870/// #         .build()
11871/// # );
11872/// # let mut hub = Storage::new(client, auth);
11873/// // As the method needs a request, you would usually fill it with the desired information
11874/// // into the respective structure. Some of the parts shown here might not be applicable !
11875/// // Values shown here are possibly random and not representative !
11876/// let mut req = Bucket::default();
11877///
11878/// // You can configure optional parameters by calling the respective setters at will, and
11879/// // execute the final call using `doit()`.
11880/// // Values shown here are possibly random and not representative !
11881/// let result = hub.buckets().update(req, "bucket")
11882///              .user_project("et")
11883///              .projection("sea")
11884///              .predefined_default_object_acl("consetetur")
11885///              .predefined_acl("consetetur")
11886///              .if_metageneration_not_match(-65)
11887///              .if_metageneration_match(-7)
11888///              .doit().await;
11889/// # }
11890/// ```
11891pub struct BucketUpdateCall<'a, C>
11892where
11893    C: 'a,
11894{
11895    hub: &'a Storage<C>,
11896    _request: Bucket,
11897    _bucket: String,
11898    _user_project: Option<String>,
11899    _projection: Option<String>,
11900    _predefined_default_object_acl: Option<String>,
11901    _predefined_acl: Option<String>,
11902    _if_metageneration_not_match: Option<i64>,
11903    _if_metageneration_match: Option<i64>,
11904    _delegate: Option<&'a mut dyn common::Delegate>,
11905    _additional_params: HashMap<String, String>,
11906    _scopes: BTreeSet<String>,
11907}
11908
11909impl<'a, C> common::CallBuilder for BucketUpdateCall<'a, C> {}
11910
11911impl<'a, C> BucketUpdateCall<'a, C>
11912where
11913    C: common::Connector,
11914{
11915    /// Perform the operation you have build so far.
11916    pub async fn doit(mut self) -> common::Result<(common::Response, Bucket)> {
11917        use std::borrow::Cow;
11918        use std::io::{Read, Seek};
11919
11920        use common::{url::Params, ToParts};
11921        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11922
11923        let mut dd = common::DefaultDelegate;
11924        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11925        dlg.begin(common::MethodInfo {
11926            id: "storage.buckets.update",
11927            http_method: hyper::Method::PUT,
11928        });
11929
11930        for &field in [
11931            "alt",
11932            "bucket",
11933            "userProject",
11934            "projection",
11935            "predefinedDefaultObjectAcl",
11936            "predefinedAcl",
11937            "ifMetagenerationNotMatch",
11938            "ifMetagenerationMatch",
11939        ]
11940        .iter()
11941        {
11942            if self._additional_params.contains_key(field) {
11943                dlg.finished(false);
11944                return Err(common::Error::FieldClash(field));
11945            }
11946        }
11947
11948        let mut params = Params::with_capacity(10 + self._additional_params.len());
11949        params.push("bucket", self._bucket);
11950        if let Some(value) = self._user_project.as_ref() {
11951            params.push("userProject", value);
11952        }
11953        if let Some(value) = self._projection.as_ref() {
11954            params.push("projection", value);
11955        }
11956        if let Some(value) = self._predefined_default_object_acl.as_ref() {
11957            params.push("predefinedDefaultObjectAcl", value);
11958        }
11959        if let Some(value) = self._predefined_acl.as_ref() {
11960            params.push("predefinedAcl", value);
11961        }
11962        if let Some(value) = self._if_metageneration_not_match.as_ref() {
11963            params.push("ifMetagenerationNotMatch", value.to_string());
11964        }
11965        if let Some(value) = self._if_metageneration_match.as_ref() {
11966            params.push("ifMetagenerationMatch", value.to_string());
11967        }
11968
11969        params.extend(self._additional_params.iter());
11970
11971        params.push("alt", "json");
11972        let mut url = self.hub._base_url.clone() + "b/{bucket}";
11973        if self._scopes.is_empty() {
11974            self._scopes
11975                .insert(Scope::CloudPlatform.as_ref().to_string());
11976        }
11977
11978        #[allow(clippy::single_element_loop)]
11979        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
11980            url = params.uri_replacement(url, param_name, find_this, false);
11981        }
11982        {
11983            let to_remove = ["bucket"];
11984            params.remove_params(&to_remove);
11985        }
11986
11987        let url = params.parse_with_url(&url);
11988
11989        let mut json_mime_type = mime::APPLICATION_JSON;
11990        let mut request_value_reader = {
11991            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11992            common::remove_json_null_values(&mut value);
11993            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11994            serde_json::to_writer(&mut dst, &value).unwrap();
11995            dst
11996        };
11997        let request_size = request_value_reader
11998            .seek(std::io::SeekFrom::End(0))
11999            .unwrap();
12000        request_value_reader
12001            .seek(std::io::SeekFrom::Start(0))
12002            .unwrap();
12003
12004        loop {
12005            let token = match self
12006                .hub
12007                .auth
12008                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12009                .await
12010            {
12011                Ok(token) => token,
12012                Err(e) => match dlg.token(e) {
12013                    Ok(token) => token,
12014                    Err(e) => {
12015                        dlg.finished(false);
12016                        return Err(common::Error::MissingToken(e));
12017                    }
12018                },
12019            };
12020            request_value_reader
12021                .seek(std::io::SeekFrom::Start(0))
12022                .unwrap();
12023            let mut req_result = {
12024                let client = &self.hub.client;
12025                dlg.pre_request();
12026                let mut req_builder = hyper::Request::builder()
12027                    .method(hyper::Method::PUT)
12028                    .uri(url.as_str())
12029                    .header(USER_AGENT, self.hub._user_agent.clone());
12030
12031                if let Some(token) = token.as_ref() {
12032                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12033                }
12034
12035                let request = req_builder
12036                    .header(CONTENT_TYPE, json_mime_type.to_string())
12037                    .header(CONTENT_LENGTH, request_size as u64)
12038                    .body(common::to_body(
12039                        request_value_reader.get_ref().clone().into(),
12040                    ));
12041
12042                client.request(request.unwrap()).await
12043            };
12044
12045            match req_result {
12046                Err(err) => {
12047                    if let common::Retry::After(d) = dlg.http_error(&err) {
12048                        sleep(d).await;
12049                        continue;
12050                    }
12051                    dlg.finished(false);
12052                    return Err(common::Error::HttpError(err));
12053                }
12054                Ok(res) => {
12055                    let (mut parts, body) = res.into_parts();
12056                    let mut body = common::Body::new(body);
12057                    if !parts.status.is_success() {
12058                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12059                        let error = serde_json::from_str(&common::to_string(&bytes));
12060                        let response = common::to_response(parts, bytes.into());
12061
12062                        if let common::Retry::After(d) =
12063                            dlg.http_failure(&response, error.as_ref().ok())
12064                        {
12065                            sleep(d).await;
12066                            continue;
12067                        }
12068
12069                        dlg.finished(false);
12070
12071                        return Err(match error {
12072                            Ok(value) => common::Error::BadRequest(value),
12073                            _ => common::Error::Failure(response),
12074                        });
12075                    }
12076                    let response = {
12077                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12078                        let encoded = common::to_string(&bytes);
12079                        match serde_json::from_str(&encoded) {
12080                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12081                            Err(error) => {
12082                                dlg.response_json_decode_error(&encoded, &error);
12083                                return Err(common::Error::JsonDecodeError(
12084                                    encoded.to_string(),
12085                                    error,
12086                                ));
12087                            }
12088                        }
12089                    };
12090
12091                    dlg.finished(true);
12092                    return Ok(response);
12093                }
12094            }
12095        }
12096    }
12097
12098    ///
12099    /// Sets the *request* property to the given value.
12100    ///
12101    /// Even though the property as already been set when instantiating this call,
12102    /// we provide this method for API completeness.
12103    pub fn request(mut self, new_value: Bucket) -> BucketUpdateCall<'a, C> {
12104        self._request = new_value;
12105        self
12106    }
12107    /// Name of a bucket.
12108    ///
12109    /// Sets the *bucket* path property to the given value.
12110    ///
12111    /// Even though the property as already been set when instantiating this call,
12112    /// we provide this method for API completeness.
12113    pub fn bucket(mut self, new_value: &str) -> BucketUpdateCall<'a, C> {
12114        self._bucket = new_value.to_string();
12115        self
12116    }
12117    /// The project to be billed for this request. Required for Requester Pays buckets.
12118    ///
12119    /// Sets the *user project* query property to the given value.
12120    pub fn user_project(mut self, new_value: &str) -> BucketUpdateCall<'a, C> {
12121        self._user_project = Some(new_value.to_string());
12122        self
12123    }
12124    /// Set of properties to return. Defaults to full.
12125    ///
12126    /// Sets the *projection* query property to the given value.
12127    pub fn projection(mut self, new_value: &str) -> BucketUpdateCall<'a, C> {
12128        self._projection = Some(new_value.to_string());
12129        self
12130    }
12131    /// Apply a predefined set of default object access controls to this bucket.
12132    ///
12133    /// Sets the *predefined default object acl* query property to the given value.
12134    pub fn predefined_default_object_acl(mut self, new_value: &str) -> BucketUpdateCall<'a, C> {
12135        self._predefined_default_object_acl = Some(new_value.to_string());
12136        self
12137    }
12138    /// Apply a predefined set of access controls to this bucket.
12139    ///
12140    /// Sets the *predefined acl* query property to the given value.
12141    pub fn predefined_acl(mut self, new_value: &str) -> BucketUpdateCall<'a, C> {
12142        self._predefined_acl = Some(new_value.to_string());
12143        self
12144    }
12145    /// Makes the return of the bucket metadata conditional on whether the bucket's current metageneration does not match the given value.
12146    ///
12147    /// Sets the *if metageneration not match* query property to the given value.
12148    pub fn if_metageneration_not_match(mut self, new_value: i64) -> BucketUpdateCall<'a, C> {
12149        self._if_metageneration_not_match = Some(new_value);
12150        self
12151    }
12152    /// Makes the return of the bucket metadata conditional on whether the bucket's current metageneration matches the given value.
12153    ///
12154    /// Sets the *if metageneration match* query property to the given value.
12155    pub fn if_metageneration_match(mut self, new_value: i64) -> BucketUpdateCall<'a, C> {
12156        self._if_metageneration_match = Some(new_value);
12157        self
12158    }
12159    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12160    /// while executing the actual API request.
12161    ///
12162    /// ````text
12163    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12164    /// ````
12165    ///
12166    /// Sets the *delegate* property to the given value.
12167    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> BucketUpdateCall<'a, C> {
12168        self._delegate = Some(new_value);
12169        self
12170    }
12171
12172    /// Set any additional parameter of the query string used in the request.
12173    /// It should be used to set parameters which are not yet available through their own
12174    /// setters.
12175    ///
12176    /// Please note that this method must not be used to set any of the known parameters
12177    /// which have their own setter method. If done anyway, the request will fail.
12178    ///
12179    /// # Additional Parameters
12180    ///
12181    /// * *alt* (query-string) - Data format for the response.
12182    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12183    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12184    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12185    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12186    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12187    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
12188    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12189    pub fn param<T>(mut self, name: T, value: T) -> BucketUpdateCall<'a, C>
12190    where
12191        T: AsRef<str>,
12192    {
12193        self._additional_params
12194            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12195        self
12196    }
12197
12198    /// Identifies the authorization scope for the method you are building.
12199    ///
12200    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12201    /// [`Scope::CloudPlatform`].
12202    ///
12203    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12204    /// tokens for more than one scope.
12205    ///
12206    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12207    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12208    /// sufficient, a read-write scope will do as well.
12209    pub fn add_scope<St>(mut self, scope: St) -> BucketUpdateCall<'a, C>
12210    where
12211        St: AsRef<str>,
12212    {
12213        self._scopes.insert(String::from(scope.as_ref()));
12214        self
12215    }
12216    /// Identifies the authorization scope(s) for the method you are building.
12217    ///
12218    /// See [`Self::add_scope()`] for details.
12219    pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketUpdateCall<'a, C>
12220    where
12221        I: IntoIterator<Item = St>,
12222        St: AsRef<str>,
12223    {
12224        self._scopes
12225            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12226        self
12227    }
12228
12229    /// Removes all scopes, and no default scope will be used either.
12230    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12231    /// for details).
12232    pub fn clear_scopes(mut self) -> BucketUpdateCall<'a, C> {
12233        self._scopes.clear();
12234        self
12235    }
12236}
12237
12238/// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed.
12239///
12240/// A builder for the *operations.cancel* method supported by a *bucket* resource.
12241/// It is not used directly, but through a [`BucketMethods`] instance.
12242///
12243/// # Example
12244///
12245/// Instantiate a resource method builder
12246///
12247/// ```test_harness,no_run
12248/// # extern crate hyper;
12249/// # extern crate hyper_rustls;
12250/// # extern crate google_storage1 as storage1;
12251/// # async fn dox() {
12252/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12253///
12254/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12255/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12256/// #     secret,
12257/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12258/// # ).build().await.unwrap();
12259///
12260/// # let client = hyper_util::client::legacy::Client::builder(
12261/// #     hyper_util::rt::TokioExecutor::new()
12262/// # )
12263/// # .build(
12264/// #     hyper_rustls::HttpsConnectorBuilder::new()
12265/// #         .with_native_roots()
12266/// #         .unwrap()
12267/// #         .https_or_http()
12268/// #         .enable_http1()
12269/// #         .build()
12270/// # );
12271/// # let mut hub = Storage::new(client, auth);
12272/// // You can configure optional parameters by calling the respective setters at will, and
12273/// // execute the final call using `doit()`.
12274/// // Values shown here are possibly random and not representative !
12275/// let result = hub.buckets().operations_cancel("bucket", "operationId")
12276///              .doit().await;
12277/// # }
12278/// ```
12279pub struct BucketOperationCancelCall<'a, C>
12280where
12281    C: 'a,
12282{
12283    hub: &'a Storage<C>,
12284    _bucket: String,
12285    _operation_id: String,
12286    _delegate: Option<&'a mut dyn common::Delegate>,
12287    _additional_params: HashMap<String, String>,
12288    _scopes: BTreeSet<String>,
12289}
12290
12291impl<'a, C> common::CallBuilder for BucketOperationCancelCall<'a, C> {}
12292
12293impl<'a, C> BucketOperationCancelCall<'a, C>
12294where
12295    C: common::Connector,
12296{
12297    /// Perform the operation you have build so far.
12298    pub async fn doit(mut self) -> common::Result<common::Response> {
12299        use std::borrow::Cow;
12300        use std::io::{Read, Seek};
12301
12302        use common::{url::Params, ToParts};
12303        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12304
12305        let mut dd = common::DefaultDelegate;
12306        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12307        dlg.begin(common::MethodInfo {
12308            id: "storage.buckets.operations.cancel",
12309            http_method: hyper::Method::POST,
12310        });
12311
12312        for &field in ["bucket", "operationId"].iter() {
12313            if self._additional_params.contains_key(field) {
12314                dlg.finished(false);
12315                return Err(common::Error::FieldClash(field));
12316            }
12317        }
12318
12319        let mut params = Params::with_capacity(3 + self._additional_params.len());
12320        params.push("bucket", self._bucket);
12321        params.push("operationId", self._operation_id);
12322
12323        params.extend(self._additional_params.iter());
12324
12325        let mut url = self.hub._base_url.clone() + "b/{bucket}/operations/{operationId}/cancel";
12326        if self._scopes.is_empty() {
12327            self._scopes
12328                .insert(Scope::CloudPlatform.as_ref().to_string());
12329        }
12330
12331        #[allow(clippy::single_element_loop)]
12332        for &(find_this, param_name) in
12333            [("{bucket}", "bucket"), ("{operationId}", "operationId")].iter()
12334        {
12335            url = params.uri_replacement(url, param_name, find_this, false);
12336        }
12337        {
12338            let to_remove = ["operationId", "bucket"];
12339            params.remove_params(&to_remove);
12340        }
12341
12342        let url = params.parse_with_url(&url);
12343
12344        loop {
12345            let token = match self
12346                .hub
12347                .auth
12348                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12349                .await
12350            {
12351                Ok(token) => token,
12352                Err(e) => match dlg.token(e) {
12353                    Ok(token) => token,
12354                    Err(e) => {
12355                        dlg.finished(false);
12356                        return Err(common::Error::MissingToken(e));
12357                    }
12358                },
12359            };
12360            let mut req_result = {
12361                let client = &self.hub.client;
12362                dlg.pre_request();
12363                let mut req_builder = hyper::Request::builder()
12364                    .method(hyper::Method::POST)
12365                    .uri(url.as_str())
12366                    .header(USER_AGENT, self.hub._user_agent.clone());
12367
12368                if let Some(token) = token.as_ref() {
12369                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12370                }
12371
12372                let request = req_builder
12373                    .header(CONTENT_LENGTH, 0_u64)
12374                    .body(common::to_body::<String>(None));
12375
12376                client.request(request.unwrap()).await
12377            };
12378
12379            match req_result {
12380                Err(err) => {
12381                    if let common::Retry::After(d) = dlg.http_error(&err) {
12382                        sleep(d).await;
12383                        continue;
12384                    }
12385                    dlg.finished(false);
12386                    return Err(common::Error::HttpError(err));
12387                }
12388                Ok(res) => {
12389                    let (mut parts, body) = res.into_parts();
12390                    let mut body = common::Body::new(body);
12391                    if !parts.status.is_success() {
12392                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12393                        let error = serde_json::from_str(&common::to_string(&bytes));
12394                        let response = common::to_response(parts, bytes.into());
12395
12396                        if let common::Retry::After(d) =
12397                            dlg.http_failure(&response, error.as_ref().ok())
12398                        {
12399                            sleep(d).await;
12400                            continue;
12401                        }
12402
12403                        dlg.finished(false);
12404
12405                        return Err(match error {
12406                            Ok(value) => common::Error::BadRequest(value),
12407                            _ => common::Error::Failure(response),
12408                        });
12409                    }
12410                    let response = common::Response::from_parts(parts, body);
12411
12412                    dlg.finished(true);
12413                    return Ok(response);
12414                }
12415            }
12416        }
12417    }
12418
12419    /// The parent bucket of the operation resource.
12420    ///
12421    /// Sets the *bucket* path property to the given value.
12422    ///
12423    /// Even though the property as already been set when instantiating this call,
12424    /// we provide this method for API completeness.
12425    pub fn bucket(mut self, new_value: &str) -> BucketOperationCancelCall<'a, C> {
12426        self._bucket = new_value.to_string();
12427        self
12428    }
12429    /// The ID of the operation resource.
12430    ///
12431    /// Sets the *operation id* path property to the given value.
12432    ///
12433    /// Even though the property as already been set when instantiating this call,
12434    /// we provide this method for API completeness.
12435    pub fn operation_id(mut self, new_value: &str) -> BucketOperationCancelCall<'a, C> {
12436        self._operation_id = new_value.to_string();
12437        self
12438    }
12439    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12440    /// while executing the actual API request.
12441    ///
12442    /// ````text
12443    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12444    /// ````
12445    ///
12446    /// Sets the *delegate* property to the given value.
12447    pub fn delegate(
12448        mut self,
12449        new_value: &'a mut dyn common::Delegate,
12450    ) -> BucketOperationCancelCall<'a, C> {
12451        self._delegate = Some(new_value);
12452        self
12453    }
12454
12455    /// Set any additional parameter of the query string used in the request.
12456    /// It should be used to set parameters which are not yet available through their own
12457    /// setters.
12458    ///
12459    /// Please note that this method must not be used to set any of the known parameters
12460    /// which have their own setter method. If done anyway, the request will fail.
12461    ///
12462    /// # Additional Parameters
12463    ///
12464    /// * *alt* (query-string) - Data format for the response.
12465    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12466    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12467    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12468    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12469    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12470    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
12471    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12472    pub fn param<T>(mut self, name: T, value: T) -> BucketOperationCancelCall<'a, C>
12473    where
12474        T: AsRef<str>,
12475    {
12476        self._additional_params
12477            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12478        self
12479    }
12480
12481    /// Identifies the authorization scope for the method you are building.
12482    ///
12483    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12484    /// [`Scope::CloudPlatform`].
12485    ///
12486    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12487    /// tokens for more than one scope.
12488    ///
12489    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12490    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12491    /// sufficient, a read-write scope will do as well.
12492    pub fn add_scope<St>(mut self, scope: St) -> BucketOperationCancelCall<'a, C>
12493    where
12494        St: AsRef<str>,
12495    {
12496        self._scopes.insert(String::from(scope.as_ref()));
12497        self
12498    }
12499    /// Identifies the authorization scope(s) for the method you are building.
12500    ///
12501    /// See [`Self::add_scope()`] for details.
12502    pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketOperationCancelCall<'a, C>
12503    where
12504        I: IntoIterator<Item = St>,
12505        St: AsRef<str>,
12506    {
12507        self._scopes
12508            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12509        self
12510    }
12511
12512    /// Removes all scopes, and no default scope will be used either.
12513    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12514    /// for details).
12515    pub fn clear_scopes(mut self) -> BucketOperationCancelCall<'a, C> {
12516        self._scopes.clear();
12517        self
12518    }
12519}
12520
12521/// Gets the latest state of a long-running operation.
12522///
12523/// A builder for the *operations.get* method supported by a *bucket* resource.
12524/// It is not used directly, but through a [`BucketMethods`] instance.
12525///
12526/// # Example
12527///
12528/// Instantiate a resource method builder
12529///
12530/// ```test_harness,no_run
12531/// # extern crate hyper;
12532/// # extern crate hyper_rustls;
12533/// # extern crate google_storage1 as storage1;
12534/// # async fn dox() {
12535/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12536///
12537/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12538/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12539/// #     secret,
12540/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12541/// # ).build().await.unwrap();
12542///
12543/// # let client = hyper_util::client::legacy::Client::builder(
12544/// #     hyper_util::rt::TokioExecutor::new()
12545/// # )
12546/// # .build(
12547/// #     hyper_rustls::HttpsConnectorBuilder::new()
12548/// #         .with_native_roots()
12549/// #         .unwrap()
12550/// #         .https_or_http()
12551/// #         .enable_http1()
12552/// #         .build()
12553/// # );
12554/// # let mut hub = Storage::new(client, auth);
12555/// // You can configure optional parameters by calling the respective setters at will, and
12556/// // execute the final call using `doit()`.
12557/// // Values shown here are possibly random and not representative !
12558/// let result = hub.buckets().operations_get("bucket", "operationId")
12559///              .doit().await;
12560/// # }
12561/// ```
12562pub struct BucketOperationGetCall<'a, C>
12563where
12564    C: 'a,
12565{
12566    hub: &'a Storage<C>,
12567    _bucket: String,
12568    _operation_id: String,
12569    _delegate: Option<&'a mut dyn common::Delegate>,
12570    _additional_params: HashMap<String, String>,
12571    _scopes: BTreeSet<String>,
12572}
12573
12574impl<'a, C> common::CallBuilder for BucketOperationGetCall<'a, C> {}
12575
12576impl<'a, C> BucketOperationGetCall<'a, C>
12577where
12578    C: common::Connector,
12579{
12580    /// Perform the operation you have build so far.
12581    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
12582        use std::borrow::Cow;
12583        use std::io::{Read, Seek};
12584
12585        use common::{url::Params, ToParts};
12586        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12587
12588        let mut dd = common::DefaultDelegate;
12589        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12590        dlg.begin(common::MethodInfo {
12591            id: "storage.buckets.operations.get",
12592            http_method: hyper::Method::GET,
12593        });
12594
12595        for &field in ["alt", "bucket", "operationId"].iter() {
12596            if self._additional_params.contains_key(field) {
12597                dlg.finished(false);
12598                return Err(common::Error::FieldClash(field));
12599            }
12600        }
12601
12602        let mut params = Params::with_capacity(4 + self._additional_params.len());
12603        params.push("bucket", self._bucket);
12604        params.push("operationId", self._operation_id);
12605
12606        params.extend(self._additional_params.iter());
12607
12608        params.push("alt", "json");
12609        let mut url = self.hub._base_url.clone() + "b/{bucket}/operations/{operationId}";
12610        if self._scopes.is_empty() {
12611            self._scopes
12612                .insert(Scope::CloudPlatform.as_ref().to_string());
12613        }
12614
12615        #[allow(clippy::single_element_loop)]
12616        for &(find_this, param_name) in
12617            [("{bucket}", "bucket"), ("{operationId}", "operationId")].iter()
12618        {
12619            url = params.uri_replacement(url, param_name, find_this, false);
12620        }
12621        {
12622            let to_remove = ["operationId", "bucket"];
12623            params.remove_params(&to_remove);
12624        }
12625
12626        let url = params.parse_with_url(&url);
12627
12628        loop {
12629            let token = match self
12630                .hub
12631                .auth
12632                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12633                .await
12634            {
12635                Ok(token) => token,
12636                Err(e) => match dlg.token(e) {
12637                    Ok(token) => token,
12638                    Err(e) => {
12639                        dlg.finished(false);
12640                        return Err(common::Error::MissingToken(e));
12641                    }
12642                },
12643            };
12644            let mut req_result = {
12645                let client = &self.hub.client;
12646                dlg.pre_request();
12647                let mut req_builder = hyper::Request::builder()
12648                    .method(hyper::Method::GET)
12649                    .uri(url.as_str())
12650                    .header(USER_AGENT, self.hub._user_agent.clone());
12651
12652                if let Some(token) = token.as_ref() {
12653                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12654                }
12655
12656                let request = req_builder
12657                    .header(CONTENT_LENGTH, 0_u64)
12658                    .body(common::to_body::<String>(None));
12659
12660                client.request(request.unwrap()).await
12661            };
12662
12663            match req_result {
12664                Err(err) => {
12665                    if let common::Retry::After(d) = dlg.http_error(&err) {
12666                        sleep(d).await;
12667                        continue;
12668                    }
12669                    dlg.finished(false);
12670                    return Err(common::Error::HttpError(err));
12671                }
12672                Ok(res) => {
12673                    let (mut parts, body) = res.into_parts();
12674                    let mut body = common::Body::new(body);
12675                    if !parts.status.is_success() {
12676                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12677                        let error = serde_json::from_str(&common::to_string(&bytes));
12678                        let response = common::to_response(parts, bytes.into());
12679
12680                        if let common::Retry::After(d) =
12681                            dlg.http_failure(&response, error.as_ref().ok())
12682                        {
12683                            sleep(d).await;
12684                            continue;
12685                        }
12686
12687                        dlg.finished(false);
12688
12689                        return Err(match error {
12690                            Ok(value) => common::Error::BadRequest(value),
12691                            _ => common::Error::Failure(response),
12692                        });
12693                    }
12694                    let response = {
12695                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12696                        let encoded = common::to_string(&bytes);
12697                        match serde_json::from_str(&encoded) {
12698                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12699                            Err(error) => {
12700                                dlg.response_json_decode_error(&encoded, &error);
12701                                return Err(common::Error::JsonDecodeError(
12702                                    encoded.to_string(),
12703                                    error,
12704                                ));
12705                            }
12706                        }
12707                    };
12708
12709                    dlg.finished(true);
12710                    return Ok(response);
12711                }
12712            }
12713        }
12714    }
12715
12716    /// The parent bucket of the operation resource.
12717    ///
12718    /// Sets the *bucket* path property to the given value.
12719    ///
12720    /// Even though the property as already been set when instantiating this call,
12721    /// we provide this method for API completeness.
12722    pub fn bucket(mut self, new_value: &str) -> BucketOperationGetCall<'a, C> {
12723        self._bucket = new_value.to_string();
12724        self
12725    }
12726    /// The ID of the operation resource.
12727    ///
12728    /// Sets the *operation id* path property to the given value.
12729    ///
12730    /// Even though the property as already been set when instantiating this call,
12731    /// we provide this method for API completeness.
12732    pub fn operation_id(mut self, new_value: &str) -> BucketOperationGetCall<'a, C> {
12733        self._operation_id = new_value.to_string();
12734        self
12735    }
12736    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12737    /// while executing the actual API request.
12738    ///
12739    /// ````text
12740    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12741    /// ````
12742    ///
12743    /// Sets the *delegate* property to the given value.
12744    pub fn delegate(
12745        mut self,
12746        new_value: &'a mut dyn common::Delegate,
12747    ) -> BucketOperationGetCall<'a, C> {
12748        self._delegate = Some(new_value);
12749        self
12750    }
12751
12752    /// Set any additional parameter of the query string used in the request.
12753    /// It should be used to set parameters which are not yet available through their own
12754    /// setters.
12755    ///
12756    /// Please note that this method must not be used to set any of the known parameters
12757    /// which have their own setter method. If done anyway, the request will fail.
12758    ///
12759    /// # Additional Parameters
12760    ///
12761    /// * *alt* (query-string) - Data format for the response.
12762    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12763    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12764    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12765    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12766    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12767    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
12768    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12769    pub fn param<T>(mut self, name: T, value: T) -> BucketOperationGetCall<'a, C>
12770    where
12771        T: AsRef<str>,
12772    {
12773        self._additional_params
12774            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12775        self
12776    }
12777
12778    /// Identifies the authorization scope for the method you are building.
12779    ///
12780    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12781    /// [`Scope::CloudPlatform`].
12782    ///
12783    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12784    /// tokens for more than one scope.
12785    ///
12786    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12787    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12788    /// sufficient, a read-write scope will do as well.
12789    pub fn add_scope<St>(mut self, scope: St) -> BucketOperationGetCall<'a, C>
12790    where
12791        St: AsRef<str>,
12792    {
12793        self._scopes.insert(String::from(scope.as_ref()));
12794        self
12795    }
12796    /// Identifies the authorization scope(s) for the method you are building.
12797    ///
12798    /// See [`Self::add_scope()`] for details.
12799    pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketOperationGetCall<'a, C>
12800    where
12801        I: IntoIterator<Item = St>,
12802        St: AsRef<str>,
12803    {
12804        self._scopes
12805            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12806        self
12807    }
12808
12809    /// Removes all scopes, and no default scope will be used either.
12810    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12811    /// for details).
12812    pub fn clear_scopes(mut self) -> BucketOperationGetCall<'a, C> {
12813        self._scopes.clear();
12814        self
12815    }
12816}
12817
12818/// Lists operations that match the specified filter in the request.
12819///
12820/// A builder for the *operations.list* method supported by a *bucket* resource.
12821/// It is not used directly, but through a [`BucketMethods`] instance.
12822///
12823/// # Example
12824///
12825/// Instantiate a resource method builder
12826///
12827/// ```test_harness,no_run
12828/// # extern crate hyper;
12829/// # extern crate hyper_rustls;
12830/// # extern crate google_storage1 as storage1;
12831/// # async fn dox() {
12832/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12833///
12834/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12835/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12836/// #     secret,
12837/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12838/// # ).build().await.unwrap();
12839///
12840/// # let client = hyper_util::client::legacy::Client::builder(
12841/// #     hyper_util::rt::TokioExecutor::new()
12842/// # )
12843/// # .build(
12844/// #     hyper_rustls::HttpsConnectorBuilder::new()
12845/// #         .with_native_roots()
12846/// #         .unwrap()
12847/// #         .https_or_http()
12848/// #         .enable_http1()
12849/// #         .build()
12850/// # );
12851/// # let mut hub = Storage::new(client, auth);
12852/// // You can configure optional parameters by calling the respective setters at will, and
12853/// // execute the final call using `doit()`.
12854/// // Values shown here are possibly random and not representative !
12855/// let result = hub.buckets().operations_list("bucket")
12856///              .page_token("sit")
12857///              .page_size(-93)
12858///              .filter("eos")
12859///              .doit().await;
12860/// # }
12861/// ```
12862pub struct BucketOperationListCall<'a, C>
12863where
12864    C: 'a,
12865{
12866    hub: &'a Storage<C>,
12867    _bucket: String,
12868    _page_token: Option<String>,
12869    _page_size: Option<i32>,
12870    _filter: Option<String>,
12871    _delegate: Option<&'a mut dyn common::Delegate>,
12872    _additional_params: HashMap<String, String>,
12873    _scopes: BTreeSet<String>,
12874}
12875
12876impl<'a, C> common::CallBuilder for BucketOperationListCall<'a, C> {}
12877
12878impl<'a, C> BucketOperationListCall<'a, C>
12879where
12880    C: common::Connector,
12881{
12882    /// Perform the operation you have build so far.
12883    pub async fn doit(
12884        mut self,
12885    ) -> common::Result<(common::Response, GoogleLongrunningListOperationsResponse)> {
12886        use std::borrow::Cow;
12887        use std::io::{Read, Seek};
12888
12889        use common::{url::Params, ToParts};
12890        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12891
12892        let mut dd = common::DefaultDelegate;
12893        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12894        dlg.begin(common::MethodInfo {
12895            id: "storage.buckets.operations.list",
12896            http_method: hyper::Method::GET,
12897        });
12898
12899        for &field in ["alt", "bucket", "pageToken", "pageSize", "filter"].iter() {
12900            if self._additional_params.contains_key(field) {
12901                dlg.finished(false);
12902                return Err(common::Error::FieldClash(field));
12903            }
12904        }
12905
12906        let mut params = Params::with_capacity(6 + self._additional_params.len());
12907        params.push("bucket", self._bucket);
12908        if let Some(value) = self._page_token.as_ref() {
12909            params.push("pageToken", value);
12910        }
12911        if let Some(value) = self._page_size.as_ref() {
12912            params.push("pageSize", value.to_string());
12913        }
12914        if let Some(value) = self._filter.as_ref() {
12915            params.push("filter", value);
12916        }
12917
12918        params.extend(self._additional_params.iter());
12919
12920        params.push("alt", "json");
12921        let mut url = self.hub._base_url.clone() + "b/{bucket}/operations";
12922        if self._scopes.is_empty() {
12923            self._scopes
12924                .insert(Scope::CloudPlatform.as_ref().to_string());
12925        }
12926
12927        #[allow(clippy::single_element_loop)]
12928        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
12929            url = params.uri_replacement(url, param_name, find_this, false);
12930        }
12931        {
12932            let to_remove = ["bucket"];
12933            params.remove_params(&to_remove);
12934        }
12935
12936        let url = params.parse_with_url(&url);
12937
12938        loop {
12939            let token = match self
12940                .hub
12941                .auth
12942                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12943                .await
12944            {
12945                Ok(token) => token,
12946                Err(e) => match dlg.token(e) {
12947                    Ok(token) => token,
12948                    Err(e) => {
12949                        dlg.finished(false);
12950                        return Err(common::Error::MissingToken(e));
12951                    }
12952                },
12953            };
12954            let mut req_result = {
12955                let client = &self.hub.client;
12956                dlg.pre_request();
12957                let mut req_builder = hyper::Request::builder()
12958                    .method(hyper::Method::GET)
12959                    .uri(url.as_str())
12960                    .header(USER_AGENT, self.hub._user_agent.clone());
12961
12962                if let Some(token) = token.as_ref() {
12963                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12964                }
12965
12966                let request = req_builder
12967                    .header(CONTENT_LENGTH, 0_u64)
12968                    .body(common::to_body::<String>(None));
12969
12970                client.request(request.unwrap()).await
12971            };
12972
12973            match req_result {
12974                Err(err) => {
12975                    if let common::Retry::After(d) = dlg.http_error(&err) {
12976                        sleep(d).await;
12977                        continue;
12978                    }
12979                    dlg.finished(false);
12980                    return Err(common::Error::HttpError(err));
12981                }
12982                Ok(res) => {
12983                    let (mut parts, body) = res.into_parts();
12984                    let mut body = common::Body::new(body);
12985                    if !parts.status.is_success() {
12986                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12987                        let error = serde_json::from_str(&common::to_string(&bytes));
12988                        let response = common::to_response(parts, bytes.into());
12989
12990                        if let common::Retry::After(d) =
12991                            dlg.http_failure(&response, error.as_ref().ok())
12992                        {
12993                            sleep(d).await;
12994                            continue;
12995                        }
12996
12997                        dlg.finished(false);
12998
12999                        return Err(match error {
13000                            Ok(value) => common::Error::BadRequest(value),
13001                            _ => common::Error::Failure(response),
13002                        });
13003                    }
13004                    let response = {
13005                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13006                        let encoded = common::to_string(&bytes);
13007                        match serde_json::from_str(&encoded) {
13008                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13009                            Err(error) => {
13010                                dlg.response_json_decode_error(&encoded, &error);
13011                                return Err(common::Error::JsonDecodeError(
13012                                    encoded.to_string(),
13013                                    error,
13014                                ));
13015                            }
13016                        }
13017                    };
13018
13019                    dlg.finished(true);
13020                    return Ok(response);
13021                }
13022            }
13023        }
13024    }
13025
13026    /// Name of the bucket in which to look for operations.
13027    ///
13028    /// Sets the *bucket* path property to the given value.
13029    ///
13030    /// Even though the property as already been set when instantiating this call,
13031    /// we provide this method for API completeness.
13032    pub fn bucket(mut self, new_value: &str) -> BucketOperationListCall<'a, C> {
13033        self._bucket = new_value.to_string();
13034        self
13035    }
13036    /// A previously-returned page token representing part of the larger set of results to view.
13037    ///
13038    /// Sets the *page token* query property to the given value.
13039    pub fn page_token(mut self, new_value: &str) -> BucketOperationListCall<'a, C> {
13040        self._page_token = Some(new_value.to_string());
13041        self
13042    }
13043    /// Maximum number of items to return in a single page of responses. Fewer total results may be returned than requested. The service uses this parameter or 100 items, whichever is smaller.
13044    ///
13045    /// Sets the *page size* query property to the given value.
13046    pub fn page_size(mut self, new_value: i32) -> BucketOperationListCall<'a, C> {
13047        self._page_size = Some(new_value);
13048        self
13049    }
13050    /// A filter to narrow down results to a preferred subset. The filtering language is documented in more detail in [AIP-160](https://google.aip.dev/160).
13051    ///
13052    /// Sets the *filter* query property to the given value.
13053    pub fn filter(mut self, new_value: &str) -> BucketOperationListCall<'a, C> {
13054        self._filter = Some(new_value.to_string());
13055        self
13056    }
13057    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13058    /// while executing the actual API request.
13059    ///
13060    /// ````text
13061    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13062    /// ````
13063    ///
13064    /// Sets the *delegate* property to the given value.
13065    pub fn delegate(
13066        mut self,
13067        new_value: &'a mut dyn common::Delegate,
13068    ) -> BucketOperationListCall<'a, C> {
13069        self._delegate = Some(new_value);
13070        self
13071    }
13072
13073    /// Set any additional parameter of the query string used in the request.
13074    /// It should be used to set parameters which are not yet available through their own
13075    /// setters.
13076    ///
13077    /// Please note that this method must not be used to set any of the known parameters
13078    /// which have their own setter method. If done anyway, the request will fail.
13079    ///
13080    /// # Additional Parameters
13081    ///
13082    /// * *alt* (query-string) - Data format for the response.
13083    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13084    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13085    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13086    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13087    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13088    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
13089    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13090    pub fn param<T>(mut self, name: T, value: T) -> BucketOperationListCall<'a, C>
13091    where
13092        T: AsRef<str>,
13093    {
13094        self._additional_params
13095            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13096        self
13097    }
13098
13099    /// Identifies the authorization scope for the method you are building.
13100    ///
13101    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13102    /// [`Scope::CloudPlatform`].
13103    ///
13104    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13105    /// tokens for more than one scope.
13106    ///
13107    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13108    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13109    /// sufficient, a read-write scope will do as well.
13110    pub fn add_scope<St>(mut self, scope: St) -> BucketOperationListCall<'a, C>
13111    where
13112        St: AsRef<str>,
13113    {
13114        self._scopes.insert(String::from(scope.as_ref()));
13115        self
13116    }
13117    /// Identifies the authorization scope(s) for the method you are building.
13118    ///
13119    /// See [`Self::add_scope()`] for details.
13120    pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketOperationListCall<'a, C>
13121    where
13122        I: IntoIterator<Item = St>,
13123        St: AsRef<str>,
13124    {
13125        self._scopes
13126            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13127        self
13128    }
13129
13130    /// Removes all scopes, and no default scope will be used either.
13131    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13132    /// for details).
13133    pub fn clear_scopes(mut self) -> BucketOperationListCall<'a, C> {
13134        self._scopes.clear();
13135        self
13136    }
13137}
13138
13139/// Stop watching resources through this channel
13140///
13141/// A builder for the *stop* method supported by a *channel* resource.
13142/// It is not used directly, but through a [`ChannelMethods`] instance.
13143///
13144/// # Example
13145///
13146/// Instantiate a resource method builder
13147///
13148/// ```test_harness,no_run
13149/// # extern crate hyper;
13150/// # extern crate hyper_rustls;
13151/// # extern crate google_storage1 as storage1;
13152/// use storage1::api::Channel;
13153/// # async fn dox() {
13154/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13155///
13156/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13157/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13158/// #     secret,
13159/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13160/// # ).build().await.unwrap();
13161///
13162/// # let client = hyper_util::client::legacy::Client::builder(
13163/// #     hyper_util::rt::TokioExecutor::new()
13164/// # )
13165/// # .build(
13166/// #     hyper_rustls::HttpsConnectorBuilder::new()
13167/// #         .with_native_roots()
13168/// #         .unwrap()
13169/// #         .https_or_http()
13170/// #         .enable_http1()
13171/// #         .build()
13172/// # );
13173/// # let mut hub = Storage::new(client, auth);
13174/// // As the method needs a request, you would usually fill it with the desired information
13175/// // into the respective structure. Some of the parts shown here might not be applicable !
13176/// // Values shown here are possibly random and not representative !
13177/// let mut req = Channel::default();
13178///
13179/// // You can configure optional parameters by calling the respective setters at will, and
13180/// // execute the final call using `doit()`.
13181/// // Values shown here are possibly random and not representative !
13182/// let result = hub.channels().stop(req)
13183///              .doit().await;
13184/// # }
13185/// ```
13186pub struct ChannelStopCall<'a, C>
13187where
13188    C: 'a,
13189{
13190    hub: &'a Storage<C>,
13191    _request: Channel,
13192    _delegate: Option<&'a mut dyn common::Delegate>,
13193    _additional_params: HashMap<String, String>,
13194    _scopes: BTreeSet<String>,
13195}
13196
13197impl<'a, C> common::CallBuilder for ChannelStopCall<'a, C> {}
13198
13199impl<'a, C> ChannelStopCall<'a, C>
13200where
13201    C: common::Connector,
13202{
13203    /// Perform the operation you have build so far.
13204    pub async fn doit(mut self) -> common::Result<common::Response> {
13205        use std::borrow::Cow;
13206        use std::io::{Read, Seek};
13207
13208        use common::{url::Params, ToParts};
13209        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13210
13211        let mut dd = common::DefaultDelegate;
13212        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13213        dlg.begin(common::MethodInfo {
13214            id: "storage.channels.stop",
13215            http_method: hyper::Method::POST,
13216        });
13217
13218        for &field in [].iter() {
13219            if self._additional_params.contains_key(field) {
13220                dlg.finished(false);
13221                return Err(common::Error::FieldClash(field));
13222            }
13223        }
13224
13225        let mut params = Params::with_capacity(2 + self._additional_params.len());
13226
13227        params.extend(self._additional_params.iter());
13228
13229        let mut url = self.hub._base_url.clone() + "channels/stop";
13230        if self._scopes.is_empty() {
13231            self._scopes
13232                .insert(Scope::CloudPlatform.as_ref().to_string());
13233        }
13234
13235        let url = params.parse_with_url(&url);
13236
13237        let mut json_mime_type = mime::APPLICATION_JSON;
13238        let mut request_value_reader = {
13239            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13240            common::remove_json_null_values(&mut value);
13241            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13242            serde_json::to_writer(&mut dst, &value).unwrap();
13243            dst
13244        };
13245        let request_size = request_value_reader
13246            .seek(std::io::SeekFrom::End(0))
13247            .unwrap();
13248        request_value_reader
13249            .seek(std::io::SeekFrom::Start(0))
13250            .unwrap();
13251
13252        loop {
13253            let token = match self
13254                .hub
13255                .auth
13256                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13257                .await
13258            {
13259                Ok(token) => token,
13260                Err(e) => match dlg.token(e) {
13261                    Ok(token) => token,
13262                    Err(e) => {
13263                        dlg.finished(false);
13264                        return Err(common::Error::MissingToken(e));
13265                    }
13266                },
13267            };
13268            request_value_reader
13269                .seek(std::io::SeekFrom::Start(0))
13270                .unwrap();
13271            let mut req_result = {
13272                let client = &self.hub.client;
13273                dlg.pre_request();
13274                let mut req_builder = hyper::Request::builder()
13275                    .method(hyper::Method::POST)
13276                    .uri(url.as_str())
13277                    .header(USER_AGENT, self.hub._user_agent.clone());
13278
13279                if let Some(token) = token.as_ref() {
13280                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13281                }
13282
13283                let request = req_builder
13284                    .header(CONTENT_TYPE, json_mime_type.to_string())
13285                    .header(CONTENT_LENGTH, request_size as u64)
13286                    .body(common::to_body(
13287                        request_value_reader.get_ref().clone().into(),
13288                    ));
13289
13290                client.request(request.unwrap()).await
13291            };
13292
13293            match req_result {
13294                Err(err) => {
13295                    if let common::Retry::After(d) = dlg.http_error(&err) {
13296                        sleep(d).await;
13297                        continue;
13298                    }
13299                    dlg.finished(false);
13300                    return Err(common::Error::HttpError(err));
13301                }
13302                Ok(res) => {
13303                    let (mut parts, body) = res.into_parts();
13304                    let mut body = common::Body::new(body);
13305                    if !parts.status.is_success() {
13306                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13307                        let error = serde_json::from_str(&common::to_string(&bytes));
13308                        let response = common::to_response(parts, bytes.into());
13309
13310                        if let common::Retry::After(d) =
13311                            dlg.http_failure(&response, error.as_ref().ok())
13312                        {
13313                            sleep(d).await;
13314                            continue;
13315                        }
13316
13317                        dlg.finished(false);
13318
13319                        return Err(match error {
13320                            Ok(value) => common::Error::BadRequest(value),
13321                            _ => common::Error::Failure(response),
13322                        });
13323                    }
13324                    let response = common::Response::from_parts(parts, body);
13325
13326                    dlg.finished(true);
13327                    return Ok(response);
13328                }
13329            }
13330        }
13331    }
13332
13333    ///
13334    /// Sets the *request* property to the given value.
13335    ///
13336    /// Even though the property as already been set when instantiating this call,
13337    /// we provide this method for API completeness.
13338    pub fn request(mut self, new_value: Channel) -> ChannelStopCall<'a, C> {
13339        self._request = new_value;
13340        self
13341    }
13342    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13343    /// while executing the actual API request.
13344    ///
13345    /// ````text
13346    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13347    /// ````
13348    ///
13349    /// Sets the *delegate* property to the given value.
13350    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChannelStopCall<'a, C> {
13351        self._delegate = Some(new_value);
13352        self
13353    }
13354
13355    /// Set any additional parameter of the query string used in the request.
13356    /// It should be used to set parameters which are not yet available through their own
13357    /// setters.
13358    ///
13359    /// Please note that this method must not be used to set any of the known parameters
13360    /// which have their own setter method. If done anyway, the request will fail.
13361    ///
13362    /// # Additional Parameters
13363    ///
13364    /// * *alt* (query-string) - Data format for the response.
13365    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13366    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13367    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13368    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13369    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13370    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
13371    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13372    pub fn param<T>(mut self, name: T, value: T) -> ChannelStopCall<'a, C>
13373    where
13374        T: AsRef<str>,
13375    {
13376        self._additional_params
13377            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13378        self
13379    }
13380
13381    /// Identifies the authorization scope for the method you are building.
13382    ///
13383    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13384    /// [`Scope::CloudPlatform`].
13385    ///
13386    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13387    /// tokens for more than one scope.
13388    ///
13389    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13390    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13391    /// sufficient, a read-write scope will do as well.
13392    pub fn add_scope<St>(mut self, scope: St) -> ChannelStopCall<'a, C>
13393    where
13394        St: AsRef<str>,
13395    {
13396        self._scopes.insert(String::from(scope.as_ref()));
13397        self
13398    }
13399    /// Identifies the authorization scope(s) for the method you are building.
13400    ///
13401    /// See [`Self::add_scope()`] for details.
13402    pub fn add_scopes<I, St>(mut self, scopes: I) -> ChannelStopCall<'a, C>
13403    where
13404        I: IntoIterator<Item = St>,
13405        St: AsRef<str>,
13406    {
13407        self._scopes
13408            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13409        self
13410    }
13411
13412    /// Removes all scopes, and no default scope will be used either.
13413    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13414    /// for details).
13415    pub fn clear_scopes(mut self) -> ChannelStopCall<'a, C> {
13416        self._scopes.clear();
13417        self
13418    }
13419}
13420
13421/// Permanently deletes the default object ACL entry for the specified entity on the specified bucket.
13422///
13423/// A builder for the *delete* method supported by a *defaultObjectAccessControl* resource.
13424/// It is not used directly, but through a [`DefaultObjectAccessControlMethods`] instance.
13425///
13426/// # Example
13427///
13428/// Instantiate a resource method builder
13429///
13430/// ```test_harness,no_run
13431/// # extern crate hyper;
13432/// # extern crate hyper_rustls;
13433/// # extern crate google_storage1 as storage1;
13434/// # async fn dox() {
13435/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13436///
13437/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13438/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13439/// #     secret,
13440/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13441/// # ).build().await.unwrap();
13442///
13443/// # let client = hyper_util::client::legacy::Client::builder(
13444/// #     hyper_util::rt::TokioExecutor::new()
13445/// # )
13446/// # .build(
13447/// #     hyper_rustls::HttpsConnectorBuilder::new()
13448/// #         .with_native_roots()
13449/// #         .unwrap()
13450/// #         .https_or_http()
13451/// #         .enable_http1()
13452/// #         .build()
13453/// # );
13454/// # let mut hub = Storage::new(client, auth);
13455/// // You can configure optional parameters by calling the respective setters at will, and
13456/// // execute the final call using `doit()`.
13457/// // Values shown here are possibly random and not representative !
13458/// let result = hub.default_object_access_controls().delete("bucket", "entity")
13459///              .user_project("Stet")
13460///              .doit().await;
13461/// # }
13462/// ```
13463pub struct DefaultObjectAccessControlDeleteCall<'a, C>
13464where
13465    C: 'a,
13466{
13467    hub: &'a Storage<C>,
13468    _bucket: String,
13469    _entity: String,
13470    _user_project: Option<String>,
13471    _delegate: Option<&'a mut dyn common::Delegate>,
13472    _additional_params: HashMap<String, String>,
13473    _scopes: BTreeSet<String>,
13474}
13475
13476impl<'a, C> common::CallBuilder for DefaultObjectAccessControlDeleteCall<'a, C> {}
13477
13478impl<'a, C> DefaultObjectAccessControlDeleteCall<'a, C>
13479where
13480    C: common::Connector,
13481{
13482    /// Perform the operation you have build so far.
13483    pub async fn doit(mut self) -> common::Result<common::Response> {
13484        use std::borrow::Cow;
13485        use std::io::{Read, Seek};
13486
13487        use common::{url::Params, ToParts};
13488        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13489
13490        let mut dd = common::DefaultDelegate;
13491        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13492        dlg.begin(common::MethodInfo {
13493            id: "storage.defaultObjectAccessControls.delete",
13494            http_method: hyper::Method::DELETE,
13495        });
13496
13497        for &field in ["bucket", "entity", "userProject"].iter() {
13498            if self._additional_params.contains_key(field) {
13499                dlg.finished(false);
13500                return Err(common::Error::FieldClash(field));
13501            }
13502        }
13503
13504        let mut params = Params::with_capacity(4 + self._additional_params.len());
13505        params.push("bucket", self._bucket);
13506        params.push("entity", self._entity);
13507        if let Some(value) = self._user_project.as_ref() {
13508            params.push("userProject", value);
13509        }
13510
13511        params.extend(self._additional_params.iter());
13512
13513        let mut url = self.hub._base_url.clone() + "b/{bucket}/defaultObjectAcl/{entity}";
13514        if self._scopes.is_empty() {
13515            self._scopes
13516                .insert(Scope::CloudPlatform.as_ref().to_string());
13517        }
13518
13519        #[allow(clippy::single_element_loop)]
13520        for &(find_this, param_name) in [("{bucket}", "bucket"), ("{entity}", "entity")].iter() {
13521            url = params.uri_replacement(url, param_name, find_this, false);
13522        }
13523        {
13524            let to_remove = ["entity", "bucket"];
13525            params.remove_params(&to_remove);
13526        }
13527
13528        let url = params.parse_with_url(&url);
13529
13530        loop {
13531            let token = match self
13532                .hub
13533                .auth
13534                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13535                .await
13536            {
13537                Ok(token) => token,
13538                Err(e) => match dlg.token(e) {
13539                    Ok(token) => token,
13540                    Err(e) => {
13541                        dlg.finished(false);
13542                        return Err(common::Error::MissingToken(e));
13543                    }
13544                },
13545            };
13546            let mut req_result = {
13547                let client = &self.hub.client;
13548                dlg.pre_request();
13549                let mut req_builder = hyper::Request::builder()
13550                    .method(hyper::Method::DELETE)
13551                    .uri(url.as_str())
13552                    .header(USER_AGENT, self.hub._user_agent.clone());
13553
13554                if let Some(token) = token.as_ref() {
13555                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13556                }
13557
13558                let request = req_builder
13559                    .header(CONTENT_LENGTH, 0_u64)
13560                    .body(common::to_body::<String>(None));
13561
13562                client.request(request.unwrap()).await
13563            };
13564
13565            match req_result {
13566                Err(err) => {
13567                    if let common::Retry::After(d) = dlg.http_error(&err) {
13568                        sleep(d).await;
13569                        continue;
13570                    }
13571                    dlg.finished(false);
13572                    return Err(common::Error::HttpError(err));
13573                }
13574                Ok(res) => {
13575                    let (mut parts, body) = res.into_parts();
13576                    let mut body = common::Body::new(body);
13577                    if !parts.status.is_success() {
13578                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13579                        let error = serde_json::from_str(&common::to_string(&bytes));
13580                        let response = common::to_response(parts, bytes.into());
13581
13582                        if let common::Retry::After(d) =
13583                            dlg.http_failure(&response, error.as_ref().ok())
13584                        {
13585                            sleep(d).await;
13586                            continue;
13587                        }
13588
13589                        dlg.finished(false);
13590
13591                        return Err(match error {
13592                            Ok(value) => common::Error::BadRequest(value),
13593                            _ => common::Error::Failure(response),
13594                        });
13595                    }
13596                    let response = common::Response::from_parts(parts, body);
13597
13598                    dlg.finished(true);
13599                    return Ok(response);
13600                }
13601            }
13602        }
13603    }
13604
13605    /// Name of a bucket.
13606    ///
13607    /// Sets the *bucket* path property to the given value.
13608    ///
13609    /// Even though the property as already been set when instantiating this call,
13610    /// we provide this method for API completeness.
13611    pub fn bucket(mut self, new_value: &str) -> DefaultObjectAccessControlDeleteCall<'a, C> {
13612        self._bucket = new_value.to_string();
13613        self
13614    }
13615    /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
13616    ///
13617    /// Sets the *entity* path property to the given value.
13618    ///
13619    /// Even though the property as already been set when instantiating this call,
13620    /// we provide this method for API completeness.
13621    pub fn entity(mut self, new_value: &str) -> DefaultObjectAccessControlDeleteCall<'a, C> {
13622        self._entity = new_value.to_string();
13623        self
13624    }
13625    /// The project to be billed for this request. Required for Requester Pays buckets.
13626    ///
13627    /// Sets the *user project* query property to the given value.
13628    pub fn user_project(mut self, new_value: &str) -> DefaultObjectAccessControlDeleteCall<'a, C> {
13629        self._user_project = Some(new_value.to_string());
13630        self
13631    }
13632    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13633    /// while executing the actual API request.
13634    ///
13635    /// ````text
13636    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13637    /// ````
13638    ///
13639    /// Sets the *delegate* property to the given value.
13640    pub fn delegate(
13641        mut self,
13642        new_value: &'a mut dyn common::Delegate,
13643    ) -> DefaultObjectAccessControlDeleteCall<'a, C> {
13644        self._delegate = Some(new_value);
13645        self
13646    }
13647
13648    /// Set any additional parameter of the query string used in the request.
13649    /// It should be used to set parameters which are not yet available through their own
13650    /// setters.
13651    ///
13652    /// Please note that this method must not be used to set any of the known parameters
13653    /// which have their own setter method. If done anyway, the request will fail.
13654    ///
13655    /// # Additional Parameters
13656    ///
13657    /// * *alt* (query-string) - Data format for the response.
13658    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13659    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13660    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13661    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13662    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13663    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
13664    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13665    pub fn param<T>(mut self, name: T, value: T) -> DefaultObjectAccessControlDeleteCall<'a, C>
13666    where
13667        T: AsRef<str>,
13668    {
13669        self._additional_params
13670            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13671        self
13672    }
13673
13674    /// Identifies the authorization scope for the method you are building.
13675    ///
13676    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13677    /// [`Scope::CloudPlatform`].
13678    ///
13679    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13680    /// tokens for more than one scope.
13681    ///
13682    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13683    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13684    /// sufficient, a read-write scope will do as well.
13685    pub fn add_scope<St>(mut self, scope: St) -> DefaultObjectAccessControlDeleteCall<'a, C>
13686    where
13687        St: AsRef<str>,
13688    {
13689        self._scopes.insert(String::from(scope.as_ref()));
13690        self
13691    }
13692    /// Identifies the authorization scope(s) for the method you are building.
13693    ///
13694    /// See [`Self::add_scope()`] for details.
13695    pub fn add_scopes<I, St>(mut self, scopes: I) -> DefaultObjectAccessControlDeleteCall<'a, C>
13696    where
13697        I: IntoIterator<Item = St>,
13698        St: AsRef<str>,
13699    {
13700        self._scopes
13701            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13702        self
13703    }
13704
13705    /// Removes all scopes, and no default scope will be used either.
13706    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13707    /// for details).
13708    pub fn clear_scopes(mut self) -> DefaultObjectAccessControlDeleteCall<'a, C> {
13709        self._scopes.clear();
13710        self
13711    }
13712}
13713
13714/// Returns the default object ACL entry for the specified entity on the specified bucket.
13715///
13716/// A builder for the *get* method supported by a *defaultObjectAccessControl* resource.
13717/// It is not used directly, but through a [`DefaultObjectAccessControlMethods`] instance.
13718///
13719/// # Example
13720///
13721/// Instantiate a resource method builder
13722///
13723/// ```test_harness,no_run
13724/// # extern crate hyper;
13725/// # extern crate hyper_rustls;
13726/// # extern crate google_storage1 as storage1;
13727/// # async fn dox() {
13728/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13729///
13730/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13731/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13732/// #     secret,
13733/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13734/// # ).build().await.unwrap();
13735///
13736/// # let client = hyper_util::client::legacy::Client::builder(
13737/// #     hyper_util::rt::TokioExecutor::new()
13738/// # )
13739/// # .build(
13740/// #     hyper_rustls::HttpsConnectorBuilder::new()
13741/// #         .with_native_roots()
13742/// #         .unwrap()
13743/// #         .https_or_http()
13744/// #         .enable_http1()
13745/// #         .build()
13746/// # );
13747/// # let mut hub = Storage::new(client, auth);
13748/// // You can configure optional parameters by calling the respective setters at will, and
13749/// // execute the final call using `doit()`.
13750/// // Values shown here are possibly random and not representative !
13751/// let result = hub.default_object_access_controls().get("bucket", "entity")
13752///              .user_project("et")
13753///              .doit().await;
13754/// # }
13755/// ```
13756pub struct DefaultObjectAccessControlGetCall<'a, C>
13757where
13758    C: 'a,
13759{
13760    hub: &'a Storage<C>,
13761    _bucket: String,
13762    _entity: String,
13763    _user_project: Option<String>,
13764    _delegate: Option<&'a mut dyn common::Delegate>,
13765    _additional_params: HashMap<String, String>,
13766    _scopes: BTreeSet<String>,
13767}
13768
13769impl<'a, C> common::CallBuilder for DefaultObjectAccessControlGetCall<'a, C> {}
13770
13771impl<'a, C> DefaultObjectAccessControlGetCall<'a, C>
13772where
13773    C: common::Connector,
13774{
13775    /// Perform the operation you have build so far.
13776    pub async fn doit(mut self) -> common::Result<(common::Response, ObjectAccessControl)> {
13777        use std::borrow::Cow;
13778        use std::io::{Read, Seek};
13779
13780        use common::{url::Params, ToParts};
13781        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13782
13783        let mut dd = common::DefaultDelegate;
13784        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13785        dlg.begin(common::MethodInfo {
13786            id: "storage.defaultObjectAccessControls.get",
13787            http_method: hyper::Method::GET,
13788        });
13789
13790        for &field in ["alt", "bucket", "entity", "userProject"].iter() {
13791            if self._additional_params.contains_key(field) {
13792                dlg.finished(false);
13793                return Err(common::Error::FieldClash(field));
13794            }
13795        }
13796
13797        let mut params = Params::with_capacity(5 + self._additional_params.len());
13798        params.push("bucket", self._bucket);
13799        params.push("entity", self._entity);
13800        if let Some(value) = self._user_project.as_ref() {
13801            params.push("userProject", value);
13802        }
13803
13804        params.extend(self._additional_params.iter());
13805
13806        params.push("alt", "json");
13807        let mut url = self.hub._base_url.clone() + "b/{bucket}/defaultObjectAcl/{entity}";
13808        if self._scopes.is_empty() {
13809            self._scopes
13810                .insert(Scope::CloudPlatform.as_ref().to_string());
13811        }
13812
13813        #[allow(clippy::single_element_loop)]
13814        for &(find_this, param_name) in [("{bucket}", "bucket"), ("{entity}", "entity")].iter() {
13815            url = params.uri_replacement(url, param_name, find_this, false);
13816        }
13817        {
13818            let to_remove = ["entity", "bucket"];
13819            params.remove_params(&to_remove);
13820        }
13821
13822        let url = params.parse_with_url(&url);
13823
13824        loop {
13825            let token = match self
13826                .hub
13827                .auth
13828                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13829                .await
13830            {
13831                Ok(token) => token,
13832                Err(e) => match dlg.token(e) {
13833                    Ok(token) => token,
13834                    Err(e) => {
13835                        dlg.finished(false);
13836                        return Err(common::Error::MissingToken(e));
13837                    }
13838                },
13839            };
13840            let mut req_result = {
13841                let client = &self.hub.client;
13842                dlg.pre_request();
13843                let mut req_builder = hyper::Request::builder()
13844                    .method(hyper::Method::GET)
13845                    .uri(url.as_str())
13846                    .header(USER_AGENT, self.hub._user_agent.clone());
13847
13848                if let Some(token) = token.as_ref() {
13849                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13850                }
13851
13852                let request = req_builder
13853                    .header(CONTENT_LENGTH, 0_u64)
13854                    .body(common::to_body::<String>(None));
13855
13856                client.request(request.unwrap()).await
13857            };
13858
13859            match req_result {
13860                Err(err) => {
13861                    if let common::Retry::After(d) = dlg.http_error(&err) {
13862                        sleep(d).await;
13863                        continue;
13864                    }
13865                    dlg.finished(false);
13866                    return Err(common::Error::HttpError(err));
13867                }
13868                Ok(res) => {
13869                    let (mut parts, body) = res.into_parts();
13870                    let mut body = common::Body::new(body);
13871                    if !parts.status.is_success() {
13872                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13873                        let error = serde_json::from_str(&common::to_string(&bytes));
13874                        let response = common::to_response(parts, bytes.into());
13875
13876                        if let common::Retry::After(d) =
13877                            dlg.http_failure(&response, error.as_ref().ok())
13878                        {
13879                            sleep(d).await;
13880                            continue;
13881                        }
13882
13883                        dlg.finished(false);
13884
13885                        return Err(match error {
13886                            Ok(value) => common::Error::BadRequest(value),
13887                            _ => common::Error::Failure(response),
13888                        });
13889                    }
13890                    let response = {
13891                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13892                        let encoded = common::to_string(&bytes);
13893                        match serde_json::from_str(&encoded) {
13894                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13895                            Err(error) => {
13896                                dlg.response_json_decode_error(&encoded, &error);
13897                                return Err(common::Error::JsonDecodeError(
13898                                    encoded.to_string(),
13899                                    error,
13900                                ));
13901                            }
13902                        }
13903                    };
13904
13905                    dlg.finished(true);
13906                    return Ok(response);
13907                }
13908            }
13909        }
13910    }
13911
13912    /// Name of a bucket.
13913    ///
13914    /// Sets the *bucket* path property to the given value.
13915    ///
13916    /// Even though the property as already been set when instantiating this call,
13917    /// we provide this method for API completeness.
13918    pub fn bucket(mut self, new_value: &str) -> DefaultObjectAccessControlGetCall<'a, C> {
13919        self._bucket = new_value.to_string();
13920        self
13921    }
13922    /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
13923    ///
13924    /// Sets the *entity* path property to the given value.
13925    ///
13926    /// Even though the property as already been set when instantiating this call,
13927    /// we provide this method for API completeness.
13928    pub fn entity(mut self, new_value: &str) -> DefaultObjectAccessControlGetCall<'a, C> {
13929        self._entity = new_value.to_string();
13930        self
13931    }
13932    /// The project to be billed for this request. Required for Requester Pays buckets.
13933    ///
13934    /// Sets the *user project* query property to the given value.
13935    pub fn user_project(mut self, new_value: &str) -> DefaultObjectAccessControlGetCall<'a, C> {
13936        self._user_project = Some(new_value.to_string());
13937        self
13938    }
13939    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13940    /// while executing the actual API request.
13941    ///
13942    /// ````text
13943    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13944    /// ````
13945    ///
13946    /// Sets the *delegate* property to the given value.
13947    pub fn delegate(
13948        mut self,
13949        new_value: &'a mut dyn common::Delegate,
13950    ) -> DefaultObjectAccessControlGetCall<'a, C> {
13951        self._delegate = Some(new_value);
13952        self
13953    }
13954
13955    /// Set any additional parameter of the query string used in the request.
13956    /// It should be used to set parameters which are not yet available through their own
13957    /// setters.
13958    ///
13959    /// Please note that this method must not be used to set any of the known parameters
13960    /// which have their own setter method. If done anyway, the request will fail.
13961    ///
13962    /// # Additional Parameters
13963    ///
13964    /// * *alt* (query-string) - Data format for the response.
13965    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13966    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13967    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13968    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13969    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13970    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
13971    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13972    pub fn param<T>(mut self, name: T, value: T) -> DefaultObjectAccessControlGetCall<'a, C>
13973    where
13974        T: AsRef<str>,
13975    {
13976        self._additional_params
13977            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13978        self
13979    }
13980
13981    /// Identifies the authorization scope for the method you are building.
13982    ///
13983    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13984    /// [`Scope::CloudPlatform`].
13985    ///
13986    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13987    /// tokens for more than one scope.
13988    ///
13989    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13990    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13991    /// sufficient, a read-write scope will do as well.
13992    pub fn add_scope<St>(mut self, scope: St) -> DefaultObjectAccessControlGetCall<'a, C>
13993    where
13994        St: AsRef<str>,
13995    {
13996        self._scopes.insert(String::from(scope.as_ref()));
13997        self
13998    }
13999    /// Identifies the authorization scope(s) for the method you are building.
14000    ///
14001    /// See [`Self::add_scope()`] for details.
14002    pub fn add_scopes<I, St>(mut self, scopes: I) -> DefaultObjectAccessControlGetCall<'a, C>
14003    where
14004        I: IntoIterator<Item = St>,
14005        St: AsRef<str>,
14006    {
14007        self._scopes
14008            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14009        self
14010    }
14011
14012    /// Removes all scopes, and no default scope will be used either.
14013    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14014    /// for details).
14015    pub fn clear_scopes(mut self) -> DefaultObjectAccessControlGetCall<'a, C> {
14016        self._scopes.clear();
14017        self
14018    }
14019}
14020
14021/// Creates a new default object ACL entry on the specified bucket.
14022///
14023/// A builder for the *insert* method supported by a *defaultObjectAccessControl* resource.
14024/// It is not used directly, but through a [`DefaultObjectAccessControlMethods`] instance.
14025///
14026/// # Example
14027///
14028/// Instantiate a resource method builder
14029///
14030/// ```test_harness,no_run
14031/// # extern crate hyper;
14032/// # extern crate hyper_rustls;
14033/// # extern crate google_storage1 as storage1;
14034/// use storage1::api::ObjectAccessControl;
14035/// # async fn dox() {
14036/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14037///
14038/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14039/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14040/// #     secret,
14041/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14042/// # ).build().await.unwrap();
14043///
14044/// # let client = hyper_util::client::legacy::Client::builder(
14045/// #     hyper_util::rt::TokioExecutor::new()
14046/// # )
14047/// # .build(
14048/// #     hyper_rustls::HttpsConnectorBuilder::new()
14049/// #         .with_native_roots()
14050/// #         .unwrap()
14051/// #         .https_or_http()
14052/// #         .enable_http1()
14053/// #         .build()
14054/// # );
14055/// # let mut hub = Storage::new(client, auth);
14056/// // As the method needs a request, you would usually fill it with the desired information
14057/// // into the respective structure. Some of the parts shown here might not be applicable !
14058/// // Values shown here are possibly random and not representative !
14059/// let mut req = ObjectAccessControl::default();
14060///
14061/// // You can configure optional parameters by calling the respective setters at will, and
14062/// // execute the final call using `doit()`.
14063/// // Values shown here are possibly random and not representative !
14064/// let result = hub.default_object_access_controls().insert(req, "bucket")
14065///              .user_project("et")
14066///              .doit().await;
14067/// # }
14068/// ```
14069pub struct DefaultObjectAccessControlInsertCall<'a, C>
14070where
14071    C: 'a,
14072{
14073    hub: &'a Storage<C>,
14074    _request: ObjectAccessControl,
14075    _bucket: String,
14076    _user_project: Option<String>,
14077    _delegate: Option<&'a mut dyn common::Delegate>,
14078    _additional_params: HashMap<String, String>,
14079    _scopes: BTreeSet<String>,
14080}
14081
14082impl<'a, C> common::CallBuilder for DefaultObjectAccessControlInsertCall<'a, C> {}
14083
14084impl<'a, C> DefaultObjectAccessControlInsertCall<'a, C>
14085where
14086    C: common::Connector,
14087{
14088    /// Perform the operation you have build so far.
14089    pub async fn doit(mut self) -> common::Result<(common::Response, ObjectAccessControl)> {
14090        use std::borrow::Cow;
14091        use std::io::{Read, Seek};
14092
14093        use common::{url::Params, ToParts};
14094        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14095
14096        let mut dd = common::DefaultDelegate;
14097        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14098        dlg.begin(common::MethodInfo {
14099            id: "storage.defaultObjectAccessControls.insert",
14100            http_method: hyper::Method::POST,
14101        });
14102
14103        for &field in ["alt", "bucket", "userProject"].iter() {
14104            if self._additional_params.contains_key(field) {
14105                dlg.finished(false);
14106                return Err(common::Error::FieldClash(field));
14107            }
14108        }
14109
14110        let mut params = Params::with_capacity(5 + self._additional_params.len());
14111        params.push("bucket", self._bucket);
14112        if let Some(value) = self._user_project.as_ref() {
14113            params.push("userProject", value);
14114        }
14115
14116        params.extend(self._additional_params.iter());
14117
14118        params.push("alt", "json");
14119        let mut url = self.hub._base_url.clone() + "b/{bucket}/defaultObjectAcl";
14120        if self._scopes.is_empty() {
14121            self._scopes
14122                .insert(Scope::CloudPlatform.as_ref().to_string());
14123        }
14124
14125        #[allow(clippy::single_element_loop)]
14126        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
14127            url = params.uri_replacement(url, param_name, find_this, false);
14128        }
14129        {
14130            let to_remove = ["bucket"];
14131            params.remove_params(&to_remove);
14132        }
14133
14134        let url = params.parse_with_url(&url);
14135
14136        let mut json_mime_type = mime::APPLICATION_JSON;
14137        let mut request_value_reader = {
14138            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14139            common::remove_json_null_values(&mut value);
14140            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14141            serde_json::to_writer(&mut dst, &value).unwrap();
14142            dst
14143        };
14144        let request_size = request_value_reader
14145            .seek(std::io::SeekFrom::End(0))
14146            .unwrap();
14147        request_value_reader
14148            .seek(std::io::SeekFrom::Start(0))
14149            .unwrap();
14150
14151        loop {
14152            let token = match self
14153                .hub
14154                .auth
14155                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14156                .await
14157            {
14158                Ok(token) => token,
14159                Err(e) => match dlg.token(e) {
14160                    Ok(token) => token,
14161                    Err(e) => {
14162                        dlg.finished(false);
14163                        return Err(common::Error::MissingToken(e));
14164                    }
14165                },
14166            };
14167            request_value_reader
14168                .seek(std::io::SeekFrom::Start(0))
14169                .unwrap();
14170            let mut req_result = {
14171                let client = &self.hub.client;
14172                dlg.pre_request();
14173                let mut req_builder = hyper::Request::builder()
14174                    .method(hyper::Method::POST)
14175                    .uri(url.as_str())
14176                    .header(USER_AGENT, self.hub._user_agent.clone());
14177
14178                if let Some(token) = token.as_ref() {
14179                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14180                }
14181
14182                let request = req_builder
14183                    .header(CONTENT_TYPE, json_mime_type.to_string())
14184                    .header(CONTENT_LENGTH, request_size as u64)
14185                    .body(common::to_body(
14186                        request_value_reader.get_ref().clone().into(),
14187                    ));
14188
14189                client.request(request.unwrap()).await
14190            };
14191
14192            match req_result {
14193                Err(err) => {
14194                    if let common::Retry::After(d) = dlg.http_error(&err) {
14195                        sleep(d).await;
14196                        continue;
14197                    }
14198                    dlg.finished(false);
14199                    return Err(common::Error::HttpError(err));
14200                }
14201                Ok(res) => {
14202                    let (mut parts, body) = res.into_parts();
14203                    let mut body = common::Body::new(body);
14204                    if !parts.status.is_success() {
14205                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14206                        let error = serde_json::from_str(&common::to_string(&bytes));
14207                        let response = common::to_response(parts, bytes.into());
14208
14209                        if let common::Retry::After(d) =
14210                            dlg.http_failure(&response, error.as_ref().ok())
14211                        {
14212                            sleep(d).await;
14213                            continue;
14214                        }
14215
14216                        dlg.finished(false);
14217
14218                        return Err(match error {
14219                            Ok(value) => common::Error::BadRequest(value),
14220                            _ => common::Error::Failure(response),
14221                        });
14222                    }
14223                    let response = {
14224                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14225                        let encoded = common::to_string(&bytes);
14226                        match serde_json::from_str(&encoded) {
14227                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14228                            Err(error) => {
14229                                dlg.response_json_decode_error(&encoded, &error);
14230                                return Err(common::Error::JsonDecodeError(
14231                                    encoded.to_string(),
14232                                    error,
14233                                ));
14234                            }
14235                        }
14236                    };
14237
14238                    dlg.finished(true);
14239                    return Ok(response);
14240                }
14241            }
14242        }
14243    }
14244
14245    ///
14246    /// Sets the *request* property to the given value.
14247    ///
14248    /// Even though the property as already been set when instantiating this call,
14249    /// we provide this method for API completeness.
14250    pub fn request(
14251        mut self,
14252        new_value: ObjectAccessControl,
14253    ) -> DefaultObjectAccessControlInsertCall<'a, C> {
14254        self._request = new_value;
14255        self
14256    }
14257    /// Name of a bucket.
14258    ///
14259    /// Sets the *bucket* path property to the given value.
14260    ///
14261    /// Even though the property as already been set when instantiating this call,
14262    /// we provide this method for API completeness.
14263    pub fn bucket(mut self, new_value: &str) -> DefaultObjectAccessControlInsertCall<'a, C> {
14264        self._bucket = new_value.to_string();
14265        self
14266    }
14267    /// The project to be billed for this request. Required for Requester Pays buckets.
14268    ///
14269    /// Sets the *user project* query property to the given value.
14270    pub fn user_project(mut self, new_value: &str) -> DefaultObjectAccessControlInsertCall<'a, C> {
14271        self._user_project = Some(new_value.to_string());
14272        self
14273    }
14274    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14275    /// while executing the actual API request.
14276    ///
14277    /// ````text
14278    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14279    /// ````
14280    ///
14281    /// Sets the *delegate* property to the given value.
14282    pub fn delegate(
14283        mut self,
14284        new_value: &'a mut dyn common::Delegate,
14285    ) -> DefaultObjectAccessControlInsertCall<'a, C> {
14286        self._delegate = Some(new_value);
14287        self
14288    }
14289
14290    /// Set any additional parameter of the query string used in the request.
14291    /// It should be used to set parameters which are not yet available through their own
14292    /// setters.
14293    ///
14294    /// Please note that this method must not be used to set any of the known parameters
14295    /// which have their own setter method. If done anyway, the request will fail.
14296    ///
14297    /// # Additional Parameters
14298    ///
14299    /// * *alt* (query-string) - Data format for the response.
14300    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14301    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14302    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14303    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14304    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14305    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
14306    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14307    pub fn param<T>(mut self, name: T, value: T) -> DefaultObjectAccessControlInsertCall<'a, C>
14308    where
14309        T: AsRef<str>,
14310    {
14311        self._additional_params
14312            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14313        self
14314    }
14315
14316    /// Identifies the authorization scope for the method you are building.
14317    ///
14318    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14319    /// [`Scope::CloudPlatform`].
14320    ///
14321    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14322    /// tokens for more than one scope.
14323    ///
14324    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14325    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14326    /// sufficient, a read-write scope will do as well.
14327    pub fn add_scope<St>(mut self, scope: St) -> DefaultObjectAccessControlInsertCall<'a, C>
14328    where
14329        St: AsRef<str>,
14330    {
14331        self._scopes.insert(String::from(scope.as_ref()));
14332        self
14333    }
14334    /// Identifies the authorization scope(s) for the method you are building.
14335    ///
14336    /// See [`Self::add_scope()`] for details.
14337    pub fn add_scopes<I, St>(mut self, scopes: I) -> DefaultObjectAccessControlInsertCall<'a, C>
14338    where
14339        I: IntoIterator<Item = St>,
14340        St: AsRef<str>,
14341    {
14342        self._scopes
14343            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14344        self
14345    }
14346
14347    /// Removes all scopes, and no default scope will be used either.
14348    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14349    /// for details).
14350    pub fn clear_scopes(mut self) -> DefaultObjectAccessControlInsertCall<'a, C> {
14351        self._scopes.clear();
14352        self
14353    }
14354}
14355
14356/// Retrieves default object ACL entries on the specified bucket.
14357///
14358/// A builder for the *list* method supported by a *defaultObjectAccessControl* resource.
14359/// It is not used directly, but through a [`DefaultObjectAccessControlMethods`] instance.
14360///
14361/// # Example
14362///
14363/// Instantiate a resource method builder
14364///
14365/// ```test_harness,no_run
14366/// # extern crate hyper;
14367/// # extern crate hyper_rustls;
14368/// # extern crate google_storage1 as storage1;
14369/// # async fn dox() {
14370/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14371///
14372/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14373/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14374/// #     secret,
14375/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14376/// # ).build().await.unwrap();
14377///
14378/// # let client = hyper_util::client::legacy::Client::builder(
14379/// #     hyper_util::rt::TokioExecutor::new()
14380/// # )
14381/// # .build(
14382/// #     hyper_rustls::HttpsConnectorBuilder::new()
14383/// #         .with_native_roots()
14384/// #         .unwrap()
14385/// #         .https_or_http()
14386/// #         .enable_http1()
14387/// #         .build()
14388/// # );
14389/// # let mut hub = Storage::new(client, auth);
14390/// // You can configure optional parameters by calling the respective setters at will, and
14391/// // execute the final call using `doit()`.
14392/// // Values shown here are possibly random and not representative !
14393/// let result = hub.default_object_access_controls().list("bucket")
14394///              .user_project("dolore")
14395///              .if_metageneration_not_match(-40)
14396///              .if_metageneration_match(-51)
14397///              .doit().await;
14398/// # }
14399/// ```
14400pub struct DefaultObjectAccessControlListCall<'a, C>
14401where
14402    C: 'a,
14403{
14404    hub: &'a Storage<C>,
14405    _bucket: String,
14406    _user_project: Option<String>,
14407    _if_metageneration_not_match: Option<i64>,
14408    _if_metageneration_match: Option<i64>,
14409    _delegate: Option<&'a mut dyn common::Delegate>,
14410    _additional_params: HashMap<String, String>,
14411    _scopes: BTreeSet<String>,
14412}
14413
14414impl<'a, C> common::CallBuilder for DefaultObjectAccessControlListCall<'a, C> {}
14415
14416impl<'a, C> DefaultObjectAccessControlListCall<'a, C>
14417where
14418    C: common::Connector,
14419{
14420    /// Perform the operation you have build so far.
14421    pub async fn doit(mut self) -> common::Result<(common::Response, ObjectAccessControls)> {
14422        use std::borrow::Cow;
14423        use std::io::{Read, Seek};
14424
14425        use common::{url::Params, ToParts};
14426        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14427
14428        let mut dd = common::DefaultDelegate;
14429        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14430        dlg.begin(common::MethodInfo {
14431            id: "storage.defaultObjectAccessControls.list",
14432            http_method: hyper::Method::GET,
14433        });
14434
14435        for &field in [
14436            "alt",
14437            "bucket",
14438            "userProject",
14439            "ifMetagenerationNotMatch",
14440            "ifMetagenerationMatch",
14441        ]
14442        .iter()
14443        {
14444            if self._additional_params.contains_key(field) {
14445                dlg.finished(false);
14446                return Err(common::Error::FieldClash(field));
14447            }
14448        }
14449
14450        let mut params = Params::with_capacity(6 + self._additional_params.len());
14451        params.push("bucket", self._bucket);
14452        if let Some(value) = self._user_project.as_ref() {
14453            params.push("userProject", value);
14454        }
14455        if let Some(value) = self._if_metageneration_not_match.as_ref() {
14456            params.push("ifMetagenerationNotMatch", value.to_string());
14457        }
14458        if let Some(value) = self._if_metageneration_match.as_ref() {
14459            params.push("ifMetagenerationMatch", value.to_string());
14460        }
14461
14462        params.extend(self._additional_params.iter());
14463
14464        params.push("alt", "json");
14465        let mut url = self.hub._base_url.clone() + "b/{bucket}/defaultObjectAcl";
14466        if self._scopes.is_empty() {
14467            self._scopes
14468                .insert(Scope::CloudPlatform.as_ref().to_string());
14469        }
14470
14471        #[allow(clippy::single_element_loop)]
14472        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
14473            url = params.uri_replacement(url, param_name, find_this, false);
14474        }
14475        {
14476            let to_remove = ["bucket"];
14477            params.remove_params(&to_remove);
14478        }
14479
14480        let url = params.parse_with_url(&url);
14481
14482        loop {
14483            let token = match self
14484                .hub
14485                .auth
14486                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14487                .await
14488            {
14489                Ok(token) => token,
14490                Err(e) => match dlg.token(e) {
14491                    Ok(token) => token,
14492                    Err(e) => {
14493                        dlg.finished(false);
14494                        return Err(common::Error::MissingToken(e));
14495                    }
14496                },
14497            };
14498            let mut req_result = {
14499                let client = &self.hub.client;
14500                dlg.pre_request();
14501                let mut req_builder = hyper::Request::builder()
14502                    .method(hyper::Method::GET)
14503                    .uri(url.as_str())
14504                    .header(USER_AGENT, self.hub._user_agent.clone());
14505
14506                if let Some(token) = token.as_ref() {
14507                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14508                }
14509
14510                let request = req_builder
14511                    .header(CONTENT_LENGTH, 0_u64)
14512                    .body(common::to_body::<String>(None));
14513
14514                client.request(request.unwrap()).await
14515            };
14516
14517            match req_result {
14518                Err(err) => {
14519                    if let common::Retry::After(d) = dlg.http_error(&err) {
14520                        sleep(d).await;
14521                        continue;
14522                    }
14523                    dlg.finished(false);
14524                    return Err(common::Error::HttpError(err));
14525                }
14526                Ok(res) => {
14527                    let (mut parts, body) = res.into_parts();
14528                    let mut body = common::Body::new(body);
14529                    if !parts.status.is_success() {
14530                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14531                        let error = serde_json::from_str(&common::to_string(&bytes));
14532                        let response = common::to_response(parts, bytes.into());
14533
14534                        if let common::Retry::After(d) =
14535                            dlg.http_failure(&response, error.as_ref().ok())
14536                        {
14537                            sleep(d).await;
14538                            continue;
14539                        }
14540
14541                        dlg.finished(false);
14542
14543                        return Err(match error {
14544                            Ok(value) => common::Error::BadRequest(value),
14545                            _ => common::Error::Failure(response),
14546                        });
14547                    }
14548                    let response = {
14549                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14550                        let encoded = common::to_string(&bytes);
14551                        match serde_json::from_str(&encoded) {
14552                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14553                            Err(error) => {
14554                                dlg.response_json_decode_error(&encoded, &error);
14555                                return Err(common::Error::JsonDecodeError(
14556                                    encoded.to_string(),
14557                                    error,
14558                                ));
14559                            }
14560                        }
14561                    };
14562
14563                    dlg.finished(true);
14564                    return Ok(response);
14565                }
14566            }
14567        }
14568    }
14569
14570    /// Name of a bucket.
14571    ///
14572    /// Sets the *bucket* path property to the given value.
14573    ///
14574    /// Even though the property as already been set when instantiating this call,
14575    /// we provide this method for API completeness.
14576    pub fn bucket(mut self, new_value: &str) -> DefaultObjectAccessControlListCall<'a, C> {
14577        self._bucket = new_value.to_string();
14578        self
14579    }
14580    /// The project to be billed for this request. Required for Requester Pays buckets.
14581    ///
14582    /// Sets the *user project* query property to the given value.
14583    pub fn user_project(mut self, new_value: &str) -> DefaultObjectAccessControlListCall<'a, C> {
14584        self._user_project = Some(new_value.to_string());
14585        self
14586    }
14587    /// If present, only return default ACL listing if the bucket's current metageneration does not match the given value.
14588    ///
14589    /// Sets the *if metageneration not match* query property to the given value.
14590    pub fn if_metageneration_not_match(
14591        mut self,
14592        new_value: i64,
14593    ) -> DefaultObjectAccessControlListCall<'a, C> {
14594        self._if_metageneration_not_match = Some(new_value);
14595        self
14596    }
14597    /// If present, only return default ACL listing if the bucket's current metageneration matches this value.
14598    ///
14599    /// Sets the *if metageneration match* query property to the given value.
14600    pub fn if_metageneration_match(
14601        mut self,
14602        new_value: i64,
14603    ) -> DefaultObjectAccessControlListCall<'a, C> {
14604        self._if_metageneration_match = Some(new_value);
14605        self
14606    }
14607    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14608    /// while executing the actual API request.
14609    ///
14610    /// ````text
14611    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14612    /// ````
14613    ///
14614    /// Sets the *delegate* property to the given value.
14615    pub fn delegate(
14616        mut self,
14617        new_value: &'a mut dyn common::Delegate,
14618    ) -> DefaultObjectAccessControlListCall<'a, C> {
14619        self._delegate = Some(new_value);
14620        self
14621    }
14622
14623    /// Set any additional parameter of the query string used in the request.
14624    /// It should be used to set parameters which are not yet available through their own
14625    /// setters.
14626    ///
14627    /// Please note that this method must not be used to set any of the known parameters
14628    /// which have their own setter method. If done anyway, the request will fail.
14629    ///
14630    /// # Additional Parameters
14631    ///
14632    /// * *alt* (query-string) - Data format for the response.
14633    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14634    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14635    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14636    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14637    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14638    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
14639    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14640    pub fn param<T>(mut self, name: T, value: T) -> DefaultObjectAccessControlListCall<'a, C>
14641    where
14642        T: AsRef<str>,
14643    {
14644        self._additional_params
14645            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14646        self
14647    }
14648
14649    /// Identifies the authorization scope for the method you are building.
14650    ///
14651    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14652    /// [`Scope::CloudPlatform`].
14653    ///
14654    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14655    /// tokens for more than one scope.
14656    ///
14657    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14658    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14659    /// sufficient, a read-write scope will do as well.
14660    pub fn add_scope<St>(mut self, scope: St) -> DefaultObjectAccessControlListCall<'a, C>
14661    where
14662        St: AsRef<str>,
14663    {
14664        self._scopes.insert(String::from(scope.as_ref()));
14665        self
14666    }
14667    /// Identifies the authorization scope(s) for the method you are building.
14668    ///
14669    /// See [`Self::add_scope()`] for details.
14670    pub fn add_scopes<I, St>(mut self, scopes: I) -> DefaultObjectAccessControlListCall<'a, C>
14671    where
14672        I: IntoIterator<Item = St>,
14673        St: AsRef<str>,
14674    {
14675        self._scopes
14676            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14677        self
14678    }
14679
14680    /// Removes all scopes, and no default scope will be used either.
14681    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14682    /// for details).
14683    pub fn clear_scopes(mut self) -> DefaultObjectAccessControlListCall<'a, C> {
14684        self._scopes.clear();
14685        self
14686    }
14687}
14688
14689/// Patches a default object ACL entry on the specified bucket.
14690///
14691/// A builder for the *patch* method supported by a *defaultObjectAccessControl* resource.
14692/// It is not used directly, but through a [`DefaultObjectAccessControlMethods`] instance.
14693///
14694/// # Example
14695///
14696/// Instantiate a resource method builder
14697///
14698/// ```test_harness,no_run
14699/// # extern crate hyper;
14700/// # extern crate hyper_rustls;
14701/// # extern crate google_storage1 as storage1;
14702/// use storage1::api::ObjectAccessControl;
14703/// # async fn dox() {
14704/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14705///
14706/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14707/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14708/// #     secret,
14709/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14710/// # ).build().await.unwrap();
14711///
14712/// # let client = hyper_util::client::legacy::Client::builder(
14713/// #     hyper_util::rt::TokioExecutor::new()
14714/// # )
14715/// # .build(
14716/// #     hyper_rustls::HttpsConnectorBuilder::new()
14717/// #         .with_native_roots()
14718/// #         .unwrap()
14719/// #         .https_or_http()
14720/// #         .enable_http1()
14721/// #         .build()
14722/// # );
14723/// # let mut hub = Storage::new(client, auth);
14724/// // As the method needs a request, you would usually fill it with the desired information
14725/// // into the respective structure. Some of the parts shown here might not be applicable !
14726/// // Values shown here are possibly random and not representative !
14727/// let mut req = ObjectAccessControl::default();
14728///
14729/// // You can configure optional parameters by calling the respective setters at will, and
14730/// // execute the final call using `doit()`.
14731/// // Values shown here are possibly random and not representative !
14732/// let result = hub.default_object_access_controls().patch(req, "bucket", "entity")
14733///              .user_project("erat")
14734///              .doit().await;
14735/// # }
14736/// ```
14737pub struct DefaultObjectAccessControlPatchCall<'a, C>
14738where
14739    C: 'a,
14740{
14741    hub: &'a Storage<C>,
14742    _request: ObjectAccessControl,
14743    _bucket: String,
14744    _entity: String,
14745    _user_project: Option<String>,
14746    _delegate: Option<&'a mut dyn common::Delegate>,
14747    _additional_params: HashMap<String, String>,
14748    _scopes: BTreeSet<String>,
14749}
14750
14751impl<'a, C> common::CallBuilder for DefaultObjectAccessControlPatchCall<'a, C> {}
14752
14753impl<'a, C> DefaultObjectAccessControlPatchCall<'a, C>
14754where
14755    C: common::Connector,
14756{
14757    /// Perform the operation you have build so far.
14758    pub async fn doit(mut self) -> common::Result<(common::Response, ObjectAccessControl)> {
14759        use std::borrow::Cow;
14760        use std::io::{Read, Seek};
14761
14762        use common::{url::Params, ToParts};
14763        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14764
14765        let mut dd = common::DefaultDelegate;
14766        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14767        dlg.begin(common::MethodInfo {
14768            id: "storage.defaultObjectAccessControls.patch",
14769            http_method: hyper::Method::PATCH,
14770        });
14771
14772        for &field in ["alt", "bucket", "entity", "userProject"].iter() {
14773            if self._additional_params.contains_key(field) {
14774                dlg.finished(false);
14775                return Err(common::Error::FieldClash(field));
14776            }
14777        }
14778
14779        let mut params = Params::with_capacity(6 + self._additional_params.len());
14780        params.push("bucket", self._bucket);
14781        params.push("entity", self._entity);
14782        if let Some(value) = self._user_project.as_ref() {
14783            params.push("userProject", value);
14784        }
14785
14786        params.extend(self._additional_params.iter());
14787
14788        params.push("alt", "json");
14789        let mut url = self.hub._base_url.clone() + "b/{bucket}/defaultObjectAcl/{entity}";
14790        if self._scopes.is_empty() {
14791            self._scopes
14792                .insert(Scope::CloudPlatform.as_ref().to_string());
14793        }
14794
14795        #[allow(clippy::single_element_loop)]
14796        for &(find_this, param_name) in [("{bucket}", "bucket"), ("{entity}", "entity")].iter() {
14797            url = params.uri_replacement(url, param_name, find_this, false);
14798        }
14799        {
14800            let to_remove = ["entity", "bucket"];
14801            params.remove_params(&to_remove);
14802        }
14803
14804        let url = params.parse_with_url(&url);
14805
14806        let mut json_mime_type = mime::APPLICATION_JSON;
14807        let mut request_value_reader = {
14808            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14809            common::remove_json_null_values(&mut value);
14810            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14811            serde_json::to_writer(&mut dst, &value).unwrap();
14812            dst
14813        };
14814        let request_size = request_value_reader
14815            .seek(std::io::SeekFrom::End(0))
14816            .unwrap();
14817        request_value_reader
14818            .seek(std::io::SeekFrom::Start(0))
14819            .unwrap();
14820
14821        loop {
14822            let token = match self
14823                .hub
14824                .auth
14825                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14826                .await
14827            {
14828                Ok(token) => token,
14829                Err(e) => match dlg.token(e) {
14830                    Ok(token) => token,
14831                    Err(e) => {
14832                        dlg.finished(false);
14833                        return Err(common::Error::MissingToken(e));
14834                    }
14835                },
14836            };
14837            request_value_reader
14838                .seek(std::io::SeekFrom::Start(0))
14839                .unwrap();
14840            let mut req_result = {
14841                let client = &self.hub.client;
14842                dlg.pre_request();
14843                let mut req_builder = hyper::Request::builder()
14844                    .method(hyper::Method::PATCH)
14845                    .uri(url.as_str())
14846                    .header(USER_AGENT, self.hub._user_agent.clone());
14847
14848                if let Some(token) = token.as_ref() {
14849                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14850                }
14851
14852                let request = req_builder
14853                    .header(CONTENT_TYPE, json_mime_type.to_string())
14854                    .header(CONTENT_LENGTH, request_size as u64)
14855                    .body(common::to_body(
14856                        request_value_reader.get_ref().clone().into(),
14857                    ));
14858
14859                client.request(request.unwrap()).await
14860            };
14861
14862            match req_result {
14863                Err(err) => {
14864                    if let common::Retry::After(d) = dlg.http_error(&err) {
14865                        sleep(d).await;
14866                        continue;
14867                    }
14868                    dlg.finished(false);
14869                    return Err(common::Error::HttpError(err));
14870                }
14871                Ok(res) => {
14872                    let (mut parts, body) = res.into_parts();
14873                    let mut body = common::Body::new(body);
14874                    if !parts.status.is_success() {
14875                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14876                        let error = serde_json::from_str(&common::to_string(&bytes));
14877                        let response = common::to_response(parts, bytes.into());
14878
14879                        if let common::Retry::After(d) =
14880                            dlg.http_failure(&response, error.as_ref().ok())
14881                        {
14882                            sleep(d).await;
14883                            continue;
14884                        }
14885
14886                        dlg.finished(false);
14887
14888                        return Err(match error {
14889                            Ok(value) => common::Error::BadRequest(value),
14890                            _ => common::Error::Failure(response),
14891                        });
14892                    }
14893                    let response = {
14894                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14895                        let encoded = common::to_string(&bytes);
14896                        match serde_json::from_str(&encoded) {
14897                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14898                            Err(error) => {
14899                                dlg.response_json_decode_error(&encoded, &error);
14900                                return Err(common::Error::JsonDecodeError(
14901                                    encoded.to_string(),
14902                                    error,
14903                                ));
14904                            }
14905                        }
14906                    };
14907
14908                    dlg.finished(true);
14909                    return Ok(response);
14910                }
14911            }
14912        }
14913    }
14914
14915    ///
14916    /// Sets the *request* property to the given value.
14917    ///
14918    /// Even though the property as already been set when instantiating this call,
14919    /// we provide this method for API completeness.
14920    pub fn request(
14921        mut self,
14922        new_value: ObjectAccessControl,
14923    ) -> DefaultObjectAccessControlPatchCall<'a, C> {
14924        self._request = new_value;
14925        self
14926    }
14927    /// Name of a bucket.
14928    ///
14929    /// Sets the *bucket* path property to the given value.
14930    ///
14931    /// Even though the property as already been set when instantiating this call,
14932    /// we provide this method for API completeness.
14933    pub fn bucket(mut self, new_value: &str) -> DefaultObjectAccessControlPatchCall<'a, C> {
14934        self._bucket = new_value.to_string();
14935        self
14936    }
14937    /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
14938    ///
14939    /// Sets the *entity* path property to the given value.
14940    ///
14941    /// Even though the property as already been set when instantiating this call,
14942    /// we provide this method for API completeness.
14943    pub fn entity(mut self, new_value: &str) -> DefaultObjectAccessControlPatchCall<'a, C> {
14944        self._entity = new_value.to_string();
14945        self
14946    }
14947    /// The project to be billed for this request. Required for Requester Pays buckets.
14948    ///
14949    /// Sets the *user project* query property to the given value.
14950    pub fn user_project(mut self, new_value: &str) -> DefaultObjectAccessControlPatchCall<'a, C> {
14951        self._user_project = Some(new_value.to_string());
14952        self
14953    }
14954    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14955    /// while executing the actual API request.
14956    ///
14957    /// ````text
14958    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14959    /// ````
14960    ///
14961    /// Sets the *delegate* property to the given value.
14962    pub fn delegate(
14963        mut self,
14964        new_value: &'a mut dyn common::Delegate,
14965    ) -> DefaultObjectAccessControlPatchCall<'a, C> {
14966        self._delegate = Some(new_value);
14967        self
14968    }
14969
14970    /// Set any additional parameter of the query string used in the request.
14971    /// It should be used to set parameters which are not yet available through their own
14972    /// setters.
14973    ///
14974    /// Please note that this method must not be used to set any of the known parameters
14975    /// which have their own setter method. If done anyway, the request will fail.
14976    ///
14977    /// # Additional Parameters
14978    ///
14979    /// * *alt* (query-string) - Data format for the response.
14980    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14981    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14982    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14983    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14984    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14985    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
14986    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14987    pub fn param<T>(mut self, name: T, value: T) -> DefaultObjectAccessControlPatchCall<'a, C>
14988    where
14989        T: AsRef<str>,
14990    {
14991        self._additional_params
14992            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14993        self
14994    }
14995
14996    /// Identifies the authorization scope for the method you are building.
14997    ///
14998    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14999    /// [`Scope::CloudPlatform`].
15000    ///
15001    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15002    /// tokens for more than one scope.
15003    ///
15004    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15005    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15006    /// sufficient, a read-write scope will do as well.
15007    pub fn add_scope<St>(mut self, scope: St) -> DefaultObjectAccessControlPatchCall<'a, C>
15008    where
15009        St: AsRef<str>,
15010    {
15011        self._scopes.insert(String::from(scope.as_ref()));
15012        self
15013    }
15014    /// Identifies the authorization scope(s) for the method you are building.
15015    ///
15016    /// See [`Self::add_scope()`] for details.
15017    pub fn add_scopes<I, St>(mut self, scopes: I) -> DefaultObjectAccessControlPatchCall<'a, C>
15018    where
15019        I: IntoIterator<Item = St>,
15020        St: AsRef<str>,
15021    {
15022        self._scopes
15023            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15024        self
15025    }
15026
15027    /// Removes all scopes, and no default scope will be used either.
15028    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15029    /// for details).
15030    pub fn clear_scopes(mut self) -> DefaultObjectAccessControlPatchCall<'a, C> {
15031        self._scopes.clear();
15032        self
15033    }
15034}
15035
15036/// Updates a default object ACL entry on the specified bucket.
15037///
15038/// A builder for the *update* method supported by a *defaultObjectAccessControl* resource.
15039/// It is not used directly, but through a [`DefaultObjectAccessControlMethods`] instance.
15040///
15041/// # Example
15042///
15043/// Instantiate a resource method builder
15044///
15045/// ```test_harness,no_run
15046/// # extern crate hyper;
15047/// # extern crate hyper_rustls;
15048/// # extern crate google_storage1 as storage1;
15049/// use storage1::api::ObjectAccessControl;
15050/// # async fn dox() {
15051/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15052///
15053/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15054/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15055/// #     secret,
15056/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15057/// # ).build().await.unwrap();
15058///
15059/// # let client = hyper_util::client::legacy::Client::builder(
15060/// #     hyper_util::rt::TokioExecutor::new()
15061/// # )
15062/// # .build(
15063/// #     hyper_rustls::HttpsConnectorBuilder::new()
15064/// #         .with_native_roots()
15065/// #         .unwrap()
15066/// #         .https_or_http()
15067/// #         .enable_http1()
15068/// #         .build()
15069/// # );
15070/// # let mut hub = Storage::new(client, auth);
15071/// // As the method needs a request, you would usually fill it with the desired information
15072/// // into the respective structure. Some of the parts shown here might not be applicable !
15073/// // Values shown here are possibly random and not representative !
15074/// let mut req = ObjectAccessControl::default();
15075///
15076/// // You can configure optional parameters by calling the respective setters at will, and
15077/// // execute the final call using `doit()`.
15078/// // Values shown here are possibly random and not representative !
15079/// let result = hub.default_object_access_controls().update(req, "bucket", "entity")
15080///              .user_project("accusam")
15081///              .doit().await;
15082/// # }
15083/// ```
15084pub struct DefaultObjectAccessControlUpdateCall<'a, C>
15085where
15086    C: 'a,
15087{
15088    hub: &'a Storage<C>,
15089    _request: ObjectAccessControl,
15090    _bucket: String,
15091    _entity: String,
15092    _user_project: Option<String>,
15093    _delegate: Option<&'a mut dyn common::Delegate>,
15094    _additional_params: HashMap<String, String>,
15095    _scopes: BTreeSet<String>,
15096}
15097
15098impl<'a, C> common::CallBuilder for DefaultObjectAccessControlUpdateCall<'a, C> {}
15099
15100impl<'a, C> DefaultObjectAccessControlUpdateCall<'a, C>
15101where
15102    C: common::Connector,
15103{
15104    /// Perform the operation you have build so far.
15105    pub async fn doit(mut self) -> common::Result<(common::Response, ObjectAccessControl)> {
15106        use std::borrow::Cow;
15107        use std::io::{Read, Seek};
15108
15109        use common::{url::Params, ToParts};
15110        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15111
15112        let mut dd = common::DefaultDelegate;
15113        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15114        dlg.begin(common::MethodInfo {
15115            id: "storage.defaultObjectAccessControls.update",
15116            http_method: hyper::Method::PUT,
15117        });
15118
15119        for &field in ["alt", "bucket", "entity", "userProject"].iter() {
15120            if self._additional_params.contains_key(field) {
15121                dlg.finished(false);
15122                return Err(common::Error::FieldClash(field));
15123            }
15124        }
15125
15126        let mut params = Params::with_capacity(6 + self._additional_params.len());
15127        params.push("bucket", self._bucket);
15128        params.push("entity", self._entity);
15129        if let Some(value) = self._user_project.as_ref() {
15130            params.push("userProject", value);
15131        }
15132
15133        params.extend(self._additional_params.iter());
15134
15135        params.push("alt", "json");
15136        let mut url = self.hub._base_url.clone() + "b/{bucket}/defaultObjectAcl/{entity}";
15137        if self._scopes.is_empty() {
15138            self._scopes
15139                .insert(Scope::CloudPlatform.as_ref().to_string());
15140        }
15141
15142        #[allow(clippy::single_element_loop)]
15143        for &(find_this, param_name) in [("{bucket}", "bucket"), ("{entity}", "entity")].iter() {
15144            url = params.uri_replacement(url, param_name, find_this, false);
15145        }
15146        {
15147            let to_remove = ["entity", "bucket"];
15148            params.remove_params(&to_remove);
15149        }
15150
15151        let url = params.parse_with_url(&url);
15152
15153        let mut json_mime_type = mime::APPLICATION_JSON;
15154        let mut request_value_reader = {
15155            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15156            common::remove_json_null_values(&mut value);
15157            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15158            serde_json::to_writer(&mut dst, &value).unwrap();
15159            dst
15160        };
15161        let request_size = request_value_reader
15162            .seek(std::io::SeekFrom::End(0))
15163            .unwrap();
15164        request_value_reader
15165            .seek(std::io::SeekFrom::Start(0))
15166            .unwrap();
15167
15168        loop {
15169            let token = match self
15170                .hub
15171                .auth
15172                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15173                .await
15174            {
15175                Ok(token) => token,
15176                Err(e) => match dlg.token(e) {
15177                    Ok(token) => token,
15178                    Err(e) => {
15179                        dlg.finished(false);
15180                        return Err(common::Error::MissingToken(e));
15181                    }
15182                },
15183            };
15184            request_value_reader
15185                .seek(std::io::SeekFrom::Start(0))
15186                .unwrap();
15187            let mut req_result = {
15188                let client = &self.hub.client;
15189                dlg.pre_request();
15190                let mut req_builder = hyper::Request::builder()
15191                    .method(hyper::Method::PUT)
15192                    .uri(url.as_str())
15193                    .header(USER_AGENT, self.hub._user_agent.clone());
15194
15195                if let Some(token) = token.as_ref() {
15196                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15197                }
15198
15199                let request = req_builder
15200                    .header(CONTENT_TYPE, json_mime_type.to_string())
15201                    .header(CONTENT_LENGTH, request_size as u64)
15202                    .body(common::to_body(
15203                        request_value_reader.get_ref().clone().into(),
15204                    ));
15205
15206                client.request(request.unwrap()).await
15207            };
15208
15209            match req_result {
15210                Err(err) => {
15211                    if let common::Retry::After(d) = dlg.http_error(&err) {
15212                        sleep(d).await;
15213                        continue;
15214                    }
15215                    dlg.finished(false);
15216                    return Err(common::Error::HttpError(err));
15217                }
15218                Ok(res) => {
15219                    let (mut parts, body) = res.into_parts();
15220                    let mut body = common::Body::new(body);
15221                    if !parts.status.is_success() {
15222                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15223                        let error = serde_json::from_str(&common::to_string(&bytes));
15224                        let response = common::to_response(parts, bytes.into());
15225
15226                        if let common::Retry::After(d) =
15227                            dlg.http_failure(&response, error.as_ref().ok())
15228                        {
15229                            sleep(d).await;
15230                            continue;
15231                        }
15232
15233                        dlg.finished(false);
15234
15235                        return Err(match error {
15236                            Ok(value) => common::Error::BadRequest(value),
15237                            _ => common::Error::Failure(response),
15238                        });
15239                    }
15240                    let response = {
15241                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15242                        let encoded = common::to_string(&bytes);
15243                        match serde_json::from_str(&encoded) {
15244                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15245                            Err(error) => {
15246                                dlg.response_json_decode_error(&encoded, &error);
15247                                return Err(common::Error::JsonDecodeError(
15248                                    encoded.to_string(),
15249                                    error,
15250                                ));
15251                            }
15252                        }
15253                    };
15254
15255                    dlg.finished(true);
15256                    return Ok(response);
15257                }
15258            }
15259        }
15260    }
15261
15262    ///
15263    /// Sets the *request* property to the given value.
15264    ///
15265    /// Even though the property as already been set when instantiating this call,
15266    /// we provide this method for API completeness.
15267    pub fn request(
15268        mut self,
15269        new_value: ObjectAccessControl,
15270    ) -> DefaultObjectAccessControlUpdateCall<'a, C> {
15271        self._request = new_value;
15272        self
15273    }
15274    /// Name of a bucket.
15275    ///
15276    /// Sets the *bucket* path property to the given value.
15277    ///
15278    /// Even though the property as already been set when instantiating this call,
15279    /// we provide this method for API completeness.
15280    pub fn bucket(mut self, new_value: &str) -> DefaultObjectAccessControlUpdateCall<'a, C> {
15281        self._bucket = new_value.to_string();
15282        self
15283    }
15284    /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
15285    ///
15286    /// Sets the *entity* path property to the given value.
15287    ///
15288    /// Even though the property as already been set when instantiating this call,
15289    /// we provide this method for API completeness.
15290    pub fn entity(mut self, new_value: &str) -> DefaultObjectAccessControlUpdateCall<'a, C> {
15291        self._entity = new_value.to_string();
15292        self
15293    }
15294    /// The project to be billed for this request. Required for Requester Pays buckets.
15295    ///
15296    /// Sets the *user project* query property to the given value.
15297    pub fn user_project(mut self, new_value: &str) -> DefaultObjectAccessControlUpdateCall<'a, C> {
15298        self._user_project = Some(new_value.to_string());
15299        self
15300    }
15301    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15302    /// while executing the actual API request.
15303    ///
15304    /// ````text
15305    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15306    /// ````
15307    ///
15308    /// Sets the *delegate* property to the given value.
15309    pub fn delegate(
15310        mut self,
15311        new_value: &'a mut dyn common::Delegate,
15312    ) -> DefaultObjectAccessControlUpdateCall<'a, C> {
15313        self._delegate = Some(new_value);
15314        self
15315    }
15316
15317    /// Set any additional parameter of the query string used in the request.
15318    /// It should be used to set parameters which are not yet available through their own
15319    /// setters.
15320    ///
15321    /// Please note that this method must not be used to set any of the known parameters
15322    /// which have their own setter method. If done anyway, the request will fail.
15323    ///
15324    /// # Additional Parameters
15325    ///
15326    /// * *alt* (query-string) - Data format for the response.
15327    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15328    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15329    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15330    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15331    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15332    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
15333    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15334    pub fn param<T>(mut self, name: T, value: T) -> DefaultObjectAccessControlUpdateCall<'a, C>
15335    where
15336        T: AsRef<str>,
15337    {
15338        self._additional_params
15339            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15340        self
15341    }
15342
15343    /// Identifies the authorization scope for the method you are building.
15344    ///
15345    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15346    /// [`Scope::CloudPlatform`].
15347    ///
15348    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15349    /// tokens for more than one scope.
15350    ///
15351    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15352    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15353    /// sufficient, a read-write scope will do as well.
15354    pub fn add_scope<St>(mut self, scope: St) -> DefaultObjectAccessControlUpdateCall<'a, C>
15355    where
15356        St: AsRef<str>,
15357    {
15358        self._scopes.insert(String::from(scope.as_ref()));
15359        self
15360    }
15361    /// Identifies the authorization scope(s) for the method you are building.
15362    ///
15363    /// See [`Self::add_scope()`] for details.
15364    pub fn add_scopes<I, St>(mut self, scopes: I) -> DefaultObjectAccessControlUpdateCall<'a, C>
15365    where
15366        I: IntoIterator<Item = St>,
15367        St: AsRef<str>,
15368    {
15369        self._scopes
15370            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15371        self
15372    }
15373
15374    /// Removes all scopes, and no default scope will be used either.
15375    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15376    /// for details).
15377    pub fn clear_scopes(mut self) -> DefaultObjectAccessControlUpdateCall<'a, C> {
15378        self._scopes.clear();
15379        self
15380    }
15381}
15382
15383/// Permanently deletes a folder. Only applicable to buckets with hierarchical namespace enabled.
15384///
15385/// A builder for the *delete* method supported by a *folder* resource.
15386/// It is not used directly, but through a [`FolderMethods`] instance.
15387///
15388/// # Example
15389///
15390/// Instantiate a resource method builder
15391///
15392/// ```test_harness,no_run
15393/// # extern crate hyper;
15394/// # extern crate hyper_rustls;
15395/// # extern crate google_storage1 as storage1;
15396/// # async fn dox() {
15397/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15398///
15399/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15400/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15401/// #     secret,
15402/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15403/// # ).build().await.unwrap();
15404///
15405/// # let client = hyper_util::client::legacy::Client::builder(
15406/// #     hyper_util::rt::TokioExecutor::new()
15407/// # )
15408/// # .build(
15409/// #     hyper_rustls::HttpsConnectorBuilder::new()
15410/// #         .with_native_roots()
15411/// #         .unwrap()
15412/// #         .https_or_http()
15413/// #         .enable_http1()
15414/// #         .build()
15415/// # );
15416/// # let mut hub = Storage::new(client, auth);
15417/// // You can configure optional parameters by calling the respective setters at will, and
15418/// // execute the final call using `doit()`.
15419/// // Values shown here are possibly random and not representative !
15420/// let result = hub.folders().delete("bucket", "folder")
15421///              .if_metageneration_not_match(-51)
15422///              .if_metageneration_match(-22)
15423///              .doit().await;
15424/// # }
15425/// ```
15426pub struct FolderDeleteCall<'a, C>
15427where
15428    C: 'a,
15429{
15430    hub: &'a Storage<C>,
15431    _bucket: String,
15432    _folder: String,
15433    _if_metageneration_not_match: Option<i64>,
15434    _if_metageneration_match: Option<i64>,
15435    _delegate: Option<&'a mut dyn common::Delegate>,
15436    _additional_params: HashMap<String, String>,
15437    _scopes: BTreeSet<String>,
15438}
15439
15440impl<'a, C> common::CallBuilder for FolderDeleteCall<'a, C> {}
15441
15442impl<'a, C> FolderDeleteCall<'a, C>
15443where
15444    C: common::Connector,
15445{
15446    /// Perform the operation you have build so far.
15447    pub async fn doit(mut self) -> common::Result<common::Response> {
15448        use std::borrow::Cow;
15449        use std::io::{Read, Seek};
15450
15451        use common::{url::Params, ToParts};
15452        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15453
15454        let mut dd = common::DefaultDelegate;
15455        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15456        dlg.begin(common::MethodInfo {
15457            id: "storage.folders.delete",
15458            http_method: hyper::Method::DELETE,
15459        });
15460
15461        for &field in [
15462            "bucket",
15463            "folder",
15464            "ifMetagenerationNotMatch",
15465            "ifMetagenerationMatch",
15466        ]
15467        .iter()
15468        {
15469            if self._additional_params.contains_key(field) {
15470                dlg.finished(false);
15471                return Err(common::Error::FieldClash(field));
15472            }
15473        }
15474
15475        let mut params = Params::with_capacity(5 + self._additional_params.len());
15476        params.push("bucket", self._bucket);
15477        params.push("folder", self._folder);
15478        if let Some(value) = self._if_metageneration_not_match.as_ref() {
15479            params.push("ifMetagenerationNotMatch", value.to_string());
15480        }
15481        if let Some(value) = self._if_metageneration_match.as_ref() {
15482            params.push("ifMetagenerationMatch", value.to_string());
15483        }
15484
15485        params.extend(self._additional_params.iter());
15486
15487        let mut url = self.hub._base_url.clone() + "b/{bucket}/folders/{folder}";
15488        if self._scopes.is_empty() {
15489            self._scopes
15490                .insert(Scope::CloudPlatform.as_ref().to_string());
15491        }
15492
15493        #[allow(clippy::single_element_loop)]
15494        for &(find_this, param_name) in [("{bucket}", "bucket"), ("{folder}", "folder")].iter() {
15495            url = params.uri_replacement(url, param_name, find_this, false);
15496        }
15497        {
15498            let to_remove = ["folder", "bucket"];
15499            params.remove_params(&to_remove);
15500        }
15501
15502        let url = params.parse_with_url(&url);
15503
15504        loop {
15505            let token = match self
15506                .hub
15507                .auth
15508                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15509                .await
15510            {
15511                Ok(token) => token,
15512                Err(e) => match dlg.token(e) {
15513                    Ok(token) => token,
15514                    Err(e) => {
15515                        dlg.finished(false);
15516                        return Err(common::Error::MissingToken(e));
15517                    }
15518                },
15519            };
15520            let mut req_result = {
15521                let client = &self.hub.client;
15522                dlg.pre_request();
15523                let mut req_builder = hyper::Request::builder()
15524                    .method(hyper::Method::DELETE)
15525                    .uri(url.as_str())
15526                    .header(USER_AGENT, self.hub._user_agent.clone());
15527
15528                if let Some(token) = token.as_ref() {
15529                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15530                }
15531
15532                let request = req_builder
15533                    .header(CONTENT_LENGTH, 0_u64)
15534                    .body(common::to_body::<String>(None));
15535
15536                client.request(request.unwrap()).await
15537            };
15538
15539            match req_result {
15540                Err(err) => {
15541                    if let common::Retry::After(d) = dlg.http_error(&err) {
15542                        sleep(d).await;
15543                        continue;
15544                    }
15545                    dlg.finished(false);
15546                    return Err(common::Error::HttpError(err));
15547                }
15548                Ok(res) => {
15549                    let (mut parts, body) = res.into_parts();
15550                    let mut body = common::Body::new(body);
15551                    if !parts.status.is_success() {
15552                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15553                        let error = serde_json::from_str(&common::to_string(&bytes));
15554                        let response = common::to_response(parts, bytes.into());
15555
15556                        if let common::Retry::After(d) =
15557                            dlg.http_failure(&response, error.as_ref().ok())
15558                        {
15559                            sleep(d).await;
15560                            continue;
15561                        }
15562
15563                        dlg.finished(false);
15564
15565                        return Err(match error {
15566                            Ok(value) => common::Error::BadRequest(value),
15567                            _ => common::Error::Failure(response),
15568                        });
15569                    }
15570                    let response = common::Response::from_parts(parts, body);
15571
15572                    dlg.finished(true);
15573                    return Ok(response);
15574                }
15575            }
15576        }
15577    }
15578
15579    /// Name of the bucket in which the folder resides.
15580    ///
15581    /// Sets the *bucket* path property to the given value.
15582    ///
15583    /// Even though the property as already been set when instantiating this call,
15584    /// we provide this method for API completeness.
15585    pub fn bucket(mut self, new_value: &str) -> FolderDeleteCall<'a, C> {
15586        self._bucket = new_value.to_string();
15587        self
15588    }
15589    /// Name of a folder.
15590    ///
15591    /// Sets the *folder* path property to the given value.
15592    ///
15593    /// Even though the property as already been set when instantiating this call,
15594    /// we provide this method for API completeness.
15595    pub fn folder(mut self, new_value: &str) -> FolderDeleteCall<'a, C> {
15596        self._folder = new_value.to_string();
15597        self
15598    }
15599    /// If set, only deletes the folder if its metageneration does not match this value.
15600    ///
15601    /// Sets the *if metageneration not match* query property to the given value.
15602    pub fn if_metageneration_not_match(mut self, new_value: i64) -> FolderDeleteCall<'a, C> {
15603        self._if_metageneration_not_match = Some(new_value);
15604        self
15605    }
15606    /// If set, only deletes the folder if its metageneration matches this value.
15607    ///
15608    /// Sets the *if metageneration match* query property to the given value.
15609    pub fn if_metageneration_match(mut self, new_value: i64) -> FolderDeleteCall<'a, C> {
15610        self._if_metageneration_match = Some(new_value);
15611        self
15612    }
15613    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15614    /// while executing the actual API request.
15615    ///
15616    /// ````text
15617    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15618    /// ````
15619    ///
15620    /// Sets the *delegate* property to the given value.
15621    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FolderDeleteCall<'a, C> {
15622        self._delegate = Some(new_value);
15623        self
15624    }
15625
15626    /// Set any additional parameter of the query string used in the request.
15627    /// It should be used to set parameters which are not yet available through their own
15628    /// setters.
15629    ///
15630    /// Please note that this method must not be used to set any of the known parameters
15631    /// which have their own setter method. If done anyway, the request will fail.
15632    ///
15633    /// # Additional Parameters
15634    ///
15635    /// * *alt* (query-string) - Data format for the response.
15636    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15637    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15638    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15639    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15640    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15641    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
15642    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15643    pub fn param<T>(mut self, name: T, value: T) -> FolderDeleteCall<'a, C>
15644    where
15645        T: AsRef<str>,
15646    {
15647        self._additional_params
15648            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15649        self
15650    }
15651
15652    /// Identifies the authorization scope for the method you are building.
15653    ///
15654    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15655    /// [`Scope::CloudPlatform`].
15656    ///
15657    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15658    /// tokens for more than one scope.
15659    ///
15660    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15661    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15662    /// sufficient, a read-write scope will do as well.
15663    pub fn add_scope<St>(mut self, scope: St) -> FolderDeleteCall<'a, C>
15664    where
15665        St: AsRef<str>,
15666    {
15667        self._scopes.insert(String::from(scope.as_ref()));
15668        self
15669    }
15670    /// Identifies the authorization scope(s) for the method you are building.
15671    ///
15672    /// See [`Self::add_scope()`] for details.
15673    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderDeleteCall<'a, C>
15674    where
15675        I: IntoIterator<Item = St>,
15676        St: AsRef<str>,
15677    {
15678        self._scopes
15679            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15680        self
15681    }
15682
15683    /// Removes all scopes, and no default scope will be used either.
15684    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15685    /// for details).
15686    pub fn clear_scopes(mut self) -> FolderDeleteCall<'a, C> {
15687        self._scopes.clear();
15688        self
15689    }
15690}
15691
15692/// Returns metadata for the specified folder. Only applicable to buckets with hierarchical namespace enabled.
15693///
15694/// A builder for the *get* method supported by a *folder* resource.
15695/// It is not used directly, but through a [`FolderMethods`] instance.
15696///
15697/// # Example
15698///
15699/// Instantiate a resource method builder
15700///
15701/// ```test_harness,no_run
15702/// # extern crate hyper;
15703/// # extern crate hyper_rustls;
15704/// # extern crate google_storage1 as storage1;
15705/// # async fn dox() {
15706/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15707///
15708/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15709/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15710/// #     secret,
15711/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15712/// # ).build().await.unwrap();
15713///
15714/// # let client = hyper_util::client::legacy::Client::builder(
15715/// #     hyper_util::rt::TokioExecutor::new()
15716/// # )
15717/// # .build(
15718/// #     hyper_rustls::HttpsConnectorBuilder::new()
15719/// #         .with_native_roots()
15720/// #         .unwrap()
15721/// #         .https_or_http()
15722/// #         .enable_http1()
15723/// #         .build()
15724/// # );
15725/// # let mut hub = Storage::new(client, auth);
15726/// // You can configure optional parameters by calling the respective setters at will, and
15727/// // execute the final call using `doit()`.
15728/// // Values shown here are possibly random and not representative !
15729/// let result = hub.folders().get("bucket", "folder")
15730///              .if_metageneration_not_match(-22)
15731///              .if_metageneration_match(-48)
15732///              .doit().await;
15733/// # }
15734/// ```
15735pub struct FolderGetCall<'a, C>
15736where
15737    C: 'a,
15738{
15739    hub: &'a Storage<C>,
15740    _bucket: String,
15741    _folder: String,
15742    _if_metageneration_not_match: Option<i64>,
15743    _if_metageneration_match: Option<i64>,
15744    _delegate: Option<&'a mut dyn common::Delegate>,
15745    _additional_params: HashMap<String, String>,
15746    _scopes: BTreeSet<String>,
15747}
15748
15749impl<'a, C> common::CallBuilder for FolderGetCall<'a, C> {}
15750
15751impl<'a, C> FolderGetCall<'a, C>
15752where
15753    C: common::Connector,
15754{
15755    /// Perform the operation you have build so far.
15756    pub async fn doit(mut self) -> common::Result<(common::Response, Folder)> {
15757        use std::borrow::Cow;
15758        use std::io::{Read, Seek};
15759
15760        use common::{url::Params, ToParts};
15761        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15762
15763        let mut dd = common::DefaultDelegate;
15764        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15765        dlg.begin(common::MethodInfo {
15766            id: "storage.folders.get",
15767            http_method: hyper::Method::GET,
15768        });
15769
15770        for &field in [
15771            "alt",
15772            "bucket",
15773            "folder",
15774            "ifMetagenerationNotMatch",
15775            "ifMetagenerationMatch",
15776        ]
15777        .iter()
15778        {
15779            if self._additional_params.contains_key(field) {
15780                dlg.finished(false);
15781                return Err(common::Error::FieldClash(field));
15782            }
15783        }
15784
15785        let mut params = Params::with_capacity(6 + self._additional_params.len());
15786        params.push("bucket", self._bucket);
15787        params.push("folder", self._folder);
15788        if let Some(value) = self._if_metageneration_not_match.as_ref() {
15789            params.push("ifMetagenerationNotMatch", value.to_string());
15790        }
15791        if let Some(value) = self._if_metageneration_match.as_ref() {
15792            params.push("ifMetagenerationMatch", value.to_string());
15793        }
15794
15795        params.extend(self._additional_params.iter());
15796
15797        params.push("alt", "json");
15798        let mut url = self.hub._base_url.clone() + "b/{bucket}/folders/{folder}";
15799        if self._scopes.is_empty() {
15800            self._scopes
15801                .insert(Scope::CloudPlatform.as_ref().to_string());
15802        }
15803
15804        #[allow(clippy::single_element_loop)]
15805        for &(find_this, param_name) in [("{bucket}", "bucket"), ("{folder}", "folder")].iter() {
15806            url = params.uri_replacement(url, param_name, find_this, false);
15807        }
15808        {
15809            let to_remove = ["folder", "bucket"];
15810            params.remove_params(&to_remove);
15811        }
15812
15813        let url = params.parse_with_url(&url);
15814
15815        loop {
15816            let token = match self
15817                .hub
15818                .auth
15819                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15820                .await
15821            {
15822                Ok(token) => token,
15823                Err(e) => match dlg.token(e) {
15824                    Ok(token) => token,
15825                    Err(e) => {
15826                        dlg.finished(false);
15827                        return Err(common::Error::MissingToken(e));
15828                    }
15829                },
15830            };
15831            let mut req_result = {
15832                let client = &self.hub.client;
15833                dlg.pre_request();
15834                let mut req_builder = hyper::Request::builder()
15835                    .method(hyper::Method::GET)
15836                    .uri(url.as_str())
15837                    .header(USER_AGENT, self.hub._user_agent.clone());
15838
15839                if let Some(token) = token.as_ref() {
15840                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15841                }
15842
15843                let request = req_builder
15844                    .header(CONTENT_LENGTH, 0_u64)
15845                    .body(common::to_body::<String>(None));
15846
15847                client.request(request.unwrap()).await
15848            };
15849
15850            match req_result {
15851                Err(err) => {
15852                    if let common::Retry::After(d) = dlg.http_error(&err) {
15853                        sleep(d).await;
15854                        continue;
15855                    }
15856                    dlg.finished(false);
15857                    return Err(common::Error::HttpError(err));
15858                }
15859                Ok(res) => {
15860                    let (mut parts, body) = res.into_parts();
15861                    let mut body = common::Body::new(body);
15862                    if !parts.status.is_success() {
15863                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15864                        let error = serde_json::from_str(&common::to_string(&bytes));
15865                        let response = common::to_response(parts, bytes.into());
15866
15867                        if let common::Retry::After(d) =
15868                            dlg.http_failure(&response, error.as_ref().ok())
15869                        {
15870                            sleep(d).await;
15871                            continue;
15872                        }
15873
15874                        dlg.finished(false);
15875
15876                        return Err(match error {
15877                            Ok(value) => common::Error::BadRequest(value),
15878                            _ => common::Error::Failure(response),
15879                        });
15880                    }
15881                    let response = {
15882                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15883                        let encoded = common::to_string(&bytes);
15884                        match serde_json::from_str(&encoded) {
15885                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15886                            Err(error) => {
15887                                dlg.response_json_decode_error(&encoded, &error);
15888                                return Err(common::Error::JsonDecodeError(
15889                                    encoded.to_string(),
15890                                    error,
15891                                ));
15892                            }
15893                        }
15894                    };
15895
15896                    dlg.finished(true);
15897                    return Ok(response);
15898                }
15899            }
15900        }
15901    }
15902
15903    /// Name of the bucket in which the folder resides.
15904    ///
15905    /// Sets the *bucket* path property to the given value.
15906    ///
15907    /// Even though the property as already been set when instantiating this call,
15908    /// we provide this method for API completeness.
15909    pub fn bucket(mut self, new_value: &str) -> FolderGetCall<'a, C> {
15910        self._bucket = new_value.to_string();
15911        self
15912    }
15913    /// Name of a folder.
15914    ///
15915    /// Sets the *folder* path property to the given value.
15916    ///
15917    /// Even though the property as already been set when instantiating this call,
15918    /// we provide this method for API completeness.
15919    pub fn folder(mut self, new_value: &str) -> FolderGetCall<'a, C> {
15920        self._folder = new_value.to_string();
15921        self
15922    }
15923    /// Makes the return of the folder metadata conditional on whether the folder's current metageneration does not match the given value.
15924    ///
15925    /// Sets the *if metageneration not match* query property to the given value.
15926    pub fn if_metageneration_not_match(mut self, new_value: i64) -> FolderGetCall<'a, C> {
15927        self._if_metageneration_not_match = Some(new_value);
15928        self
15929    }
15930    /// Makes the return of the folder metadata conditional on whether the folder's current metageneration matches the given value.
15931    ///
15932    /// Sets the *if metageneration match* query property to the given value.
15933    pub fn if_metageneration_match(mut self, new_value: i64) -> FolderGetCall<'a, C> {
15934        self._if_metageneration_match = Some(new_value);
15935        self
15936    }
15937    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15938    /// while executing the actual API request.
15939    ///
15940    /// ````text
15941    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15942    /// ````
15943    ///
15944    /// Sets the *delegate* property to the given value.
15945    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FolderGetCall<'a, C> {
15946        self._delegate = Some(new_value);
15947        self
15948    }
15949
15950    /// Set any additional parameter of the query string used in the request.
15951    /// It should be used to set parameters which are not yet available through their own
15952    /// setters.
15953    ///
15954    /// Please note that this method must not be used to set any of the known parameters
15955    /// which have their own setter method. If done anyway, the request will fail.
15956    ///
15957    /// # Additional Parameters
15958    ///
15959    /// * *alt* (query-string) - Data format for the response.
15960    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15961    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15962    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15963    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15964    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15965    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
15966    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15967    pub fn param<T>(mut self, name: T, value: T) -> FolderGetCall<'a, C>
15968    where
15969        T: AsRef<str>,
15970    {
15971        self._additional_params
15972            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15973        self
15974    }
15975
15976    /// Identifies the authorization scope for the method you are building.
15977    ///
15978    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15979    /// [`Scope::CloudPlatform`].
15980    ///
15981    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15982    /// tokens for more than one scope.
15983    ///
15984    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15985    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15986    /// sufficient, a read-write scope will do as well.
15987    pub fn add_scope<St>(mut self, scope: St) -> FolderGetCall<'a, C>
15988    where
15989        St: AsRef<str>,
15990    {
15991        self._scopes.insert(String::from(scope.as_ref()));
15992        self
15993    }
15994    /// Identifies the authorization scope(s) for the method you are building.
15995    ///
15996    /// See [`Self::add_scope()`] for details.
15997    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderGetCall<'a, C>
15998    where
15999        I: IntoIterator<Item = St>,
16000        St: AsRef<str>,
16001    {
16002        self._scopes
16003            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16004        self
16005    }
16006
16007    /// Removes all scopes, and no default scope will be used either.
16008    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16009    /// for details).
16010    pub fn clear_scopes(mut self) -> FolderGetCall<'a, C> {
16011        self._scopes.clear();
16012        self
16013    }
16014}
16015
16016/// Creates a new folder. Only applicable to buckets with hierarchical namespace enabled.
16017///
16018/// A builder for the *insert* method supported by a *folder* resource.
16019/// It is not used directly, but through a [`FolderMethods`] instance.
16020///
16021/// # Example
16022///
16023/// Instantiate a resource method builder
16024///
16025/// ```test_harness,no_run
16026/// # extern crate hyper;
16027/// # extern crate hyper_rustls;
16028/// # extern crate google_storage1 as storage1;
16029/// use storage1::api::Folder;
16030/// # async fn dox() {
16031/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16032///
16033/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16034/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16035/// #     secret,
16036/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16037/// # ).build().await.unwrap();
16038///
16039/// # let client = hyper_util::client::legacy::Client::builder(
16040/// #     hyper_util::rt::TokioExecutor::new()
16041/// # )
16042/// # .build(
16043/// #     hyper_rustls::HttpsConnectorBuilder::new()
16044/// #         .with_native_roots()
16045/// #         .unwrap()
16046/// #         .https_or_http()
16047/// #         .enable_http1()
16048/// #         .build()
16049/// # );
16050/// # let mut hub = Storage::new(client, auth);
16051/// // As the method needs a request, you would usually fill it with the desired information
16052/// // into the respective structure. Some of the parts shown here might not be applicable !
16053/// // Values shown here are possibly random and not representative !
16054/// let mut req = Folder::default();
16055///
16056/// // You can configure optional parameters by calling the respective setters at will, and
16057/// // execute the final call using `doit()`.
16058/// // Values shown here are possibly random and not representative !
16059/// let result = hub.folders().insert(req, "bucket")
16060///              .recursive(true)
16061///              .doit().await;
16062/// # }
16063/// ```
16064pub struct FolderInsertCall<'a, C>
16065where
16066    C: 'a,
16067{
16068    hub: &'a Storage<C>,
16069    _request: Folder,
16070    _bucket: String,
16071    _recursive: Option<bool>,
16072    _delegate: Option<&'a mut dyn common::Delegate>,
16073    _additional_params: HashMap<String, String>,
16074    _scopes: BTreeSet<String>,
16075}
16076
16077impl<'a, C> common::CallBuilder for FolderInsertCall<'a, C> {}
16078
16079impl<'a, C> FolderInsertCall<'a, C>
16080where
16081    C: common::Connector,
16082{
16083    /// Perform the operation you have build so far.
16084    pub async fn doit(mut self) -> common::Result<(common::Response, Folder)> {
16085        use std::borrow::Cow;
16086        use std::io::{Read, Seek};
16087
16088        use common::{url::Params, ToParts};
16089        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16090
16091        let mut dd = common::DefaultDelegate;
16092        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16093        dlg.begin(common::MethodInfo {
16094            id: "storage.folders.insert",
16095            http_method: hyper::Method::POST,
16096        });
16097
16098        for &field in ["alt", "bucket", "recursive"].iter() {
16099            if self._additional_params.contains_key(field) {
16100                dlg.finished(false);
16101                return Err(common::Error::FieldClash(field));
16102            }
16103        }
16104
16105        let mut params = Params::with_capacity(5 + self._additional_params.len());
16106        params.push("bucket", self._bucket);
16107        if let Some(value) = self._recursive.as_ref() {
16108            params.push("recursive", value.to_string());
16109        }
16110
16111        params.extend(self._additional_params.iter());
16112
16113        params.push("alt", "json");
16114        let mut url = self.hub._base_url.clone() + "b/{bucket}/folders";
16115        if self._scopes.is_empty() {
16116            self._scopes
16117                .insert(Scope::CloudPlatform.as_ref().to_string());
16118        }
16119
16120        #[allow(clippy::single_element_loop)]
16121        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
16122            url = params.uri_replacement(url, param_name, find_this, false);
16123        }
16124        {
16125            let to_remove = ["bucket"];
16126            params.remove_params(&to_remove);
16127        }
16128
16129        let url = params.parse_with_url(&url);
16130
16131        let mut json_mime_type = mime::APPLICATION_JSON;
16132        let mut request_value_reader = {
16133            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16134            common::remove_json_null_values(&mut value);
16135            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16136            serde_json::to_writer(&mut dst, &value).unwrap();
16137            dst
16138        };
16139        let request_size = request_value_reader
16140            .seek(std::io::SeekFrom::End(0))
16141            .unwrap();
16142        request_value_reader
16143            .seek(std::io::SeekFrom::Start(0))
16144            .unwrap();
16145
16146        loop {
16147            let token = match self
16148                .hub
16149                .auth
16150                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16151                .await
16152            {
16153                Ok(token) => token,
16154                Err(e) => match dlg.token(e) {
16155                    Ok(token) => token,
16156                    Err(e) => {
16157                        dlg.finished(false);
16158                        return Err(common::Error::MissingToken(e));
16159                    }
16160                },
16161            };
16162            request_value_reader
16163                .seek(std::io::SeekFrom::Start(0))
16164                .unwrap();
16165            let mut req_result = {
16166                let client = &self.hub.client;
16167                dlg.pre_request();
16168                let mut req_builder = hyper::Request::builder()
16169                    .method(hyper::Method::POST)
16170                    .uri(url.as_str())
16171                    .header(USER_AGENT, self.hub._user_agent.clone());
16172
16173                if let Some(token) = token.as_ref() {
16174                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16175                }
16176
16177                let request = req_builder
16178                    .header(CONTENT_TYPE, json_mime_type.to_string())
16179                    .header(CONTENT_LENGTH, request_size as u64)
16180                    .body(common::to_body(
16181                        request_value_reader.get_ref().clone().into(),
16182                    ));
16183
16184                client.request(request.unwrap()).await
16185            };
16186
16187            match req_result {
16188                Err(err) => {
16189                    if let common::Retry::After(d) = dlg.http_error(&err) {
16190                        sleep(d).await;
16191                        continue;
16192                    }
16193                    dlg.finished(false);
16194                    return Err(common::Error::HttpError(err));
16195                }
16196                Ok(res) => {
16197                    let (mut parts, body) = res.into_parts();
16198                    let mut body = common::Body::new(body);
16199                    if !parts.status.is_success() {
16200                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16201                        let error = serde_json::from_str(&common::to_string(&bytes));
16202                        let response = common::to_response(parts, bytes.into());
16203
16204                        if let common::Retry::After(d) =
16205                            dlg.http_failure(&response, error.as_ref().ok())
16206                        {
16207                            sleep(d).await;
16208                            continue;
16209                        }
16210
16211                        dlg.finished(false);
16212
16213                        return Err(match error {
16214                            Ok(value) => common::Error::BadRequest(value),
16215                            _ => common::Error::Failure(response),
16216                        });
16217                    }
16218                    let response = {
16219                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16220                        let encoded = common::to_string(&bytes);
16221                        match serde_json::from_str(&encoded) {
16222                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16223                            Err(error) => {
16224                                dlg.response_json_decode_error(&encoded, &error);
16225                                return Err(common::Error::JsonDecodeError(
16226                                    encoded.to_string(),
16227                                    error,
16228                                ));
16229                            }
16230                        }
16231                    };
16232
16233                    dlg.finished(true);
16234                    return Ok(response);
16235                }
16236            }
16237        }
16238    }
16239
16240    ///
16241    /// Sets the *request* property to the given value.
16242    ///
16243    /// Even though the property as already been set when instantiating this call,
16244    /// we provide this method for API completeness.
16245    pub fn request(mut self, new_value: Folder) -> FolderInsertCall<'a, C> {
16246        self._request = new_value;
16247        self
16248    }
16249    /// Name of the bucket in which the folder resides.
16250    ///
16251    /// Sets the *bucket* path property to the given value.
16252    ///
16253    /// Even though the property as already been set when instantiating this call,
16254    /// we provide this method for API completeness.
16255    pub fn bucket(mut self, new_value: &str) -> FolderInsertCall<'a, C> {
16256        self._bucket = new_value.to_string();
16257        self
16258    }
16259    /// If true, any parent folder which doesn’t exist will be created automatically.
16260    ///
16261    /// Sets the *recursive* query property to the given value.
16262    pub fn recursive(mut self, new_value: bool) -> FolderInsertCall<'a, C> {
16263        self._recursive = Some(new_value);
16264        self
16265    }
16266    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16267    /// while executing the actual API request.
16268    ///
16269    /// ````text
16270    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16271    /// ````
16272    ///
16273    /// Sets the *delegate* property to the given value.
16274    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FolderInsertCall<'a, C> {
16275        self._delegate = Some(new_value);
16276        self
16277    }
16278
16279    /// Set any additional parameter of the query string used in the request.
16280    /// It should be used to set parameters which are not yet available through their own
16281    /// setters.
16282    ///
16283    /// Please note that this method must not be used to set any of the known parameters
16284    /// which have their own setter method. If done anyway, the request will fail.
16285    ///
16286    /// # Additional Parameters
16287    ///
16288    /// * *alt* (query-string) - Data format for the response.
16289    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16290    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16291    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16292    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16293    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16294    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
16295    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16296    pub fn param<T>(mut self, name: T, value: T) -> FolderInsertCall<'a, C>
16297    where
16298        T: AsRef<str>,
16299    {
16300        self._additional_params
16301            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16302        self
16303    }
16304
16305    /// Identifies the authorization scope for the method you are building.
16306    ///
16307    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16308    /// [`Scope::CloudPlatform`].
16309    ///
16310    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16311    /// tokens for more than one scope.
16312    ///
16313    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16314    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16315    /// sufficient, a read-write scope will do as well.
16316    pub fn add_scope<St>(mut self, scope: St) -> FolderInsertCall<'a, C>
16317    where
16318        St: AsRef<str>,
16319    {
16320        self._scopes.insert(String::from(scope.as_ref()));
16321        self
16322    }
16323    /// Identifies the authorization scope(s) for the method you are building.
16324    ///
16325    /// See [`Self::add_scope()`] for details.
16326    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderInsertCall<'a, C>
16327    where
16328        I: IntoIterator<Item = St>,
16329        St: AsRef<str>,
16330    {
16331        self._scopes
16332            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16333        self
16334    }
16335
16336    /// Removes all scopes, and no default scope will be used either.
16337    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16338    /// for details).
16339    pub fn clear_scopes(mut self) -> FolderInsertCall<'a, C> {
16340        self._scopes.clear();
16341        self
16342    }
16343}
16344
16345/// Retrieves a list of folders matching the criteria. Only applicable to buckets with hierarchical namespace enabled.
16346///
16347/// A builder for the *list* method supported by a *folder* resource.
16348/// It is not used directly, but through a [`FolderMethods`] instance.
16349///
16350/// # Example
16351///
16352/// Instantiate a resource method builder
16353///
16354/// ```test_harness,no_run
16355/// # extern crate hyper;
16356/// # extern crate hyper_rustls;
16357/// # extern crate google_storage1 as storage1;
16358/// # async fn dox() {
16359/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16360///
16361/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16362/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16363/// #     secret,
16364/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16365/// # ).build().await.unwrap();
16366///
16367/// # let client = hyper_util::client::legacy::Client::builder(
16368/// #     hyper_util::rt::TokioExecutor::new()
16369/// # )
16370/// # .build(
16371/// #     hyper_rustls::HttpsConnectorBuilder::new()
16372/// #         .with_native_roots()
16373/// #         .unwrap()
16374/// #         .https_or_http()
16375/// #         .enable_http1()
16376/// #         .build()
16377/// # );
16378/// # let mut hub = Storage::new(client, auth);
16379/// // You can configure optional parameters by calling the respective setters at will, and
16380/// // execute the final call using `doit()`.
16381/// // Values shown here are possibly random and not representative !
16382/// let result = hub.folders().list("bucket")
16383///              .start_offset("gubergren")
16384///              .prefix("justo")
16385///              .page_token("sea")
16386///              .page_size(-96)
16387///              .end_offset("sit")
16388///              .delimiter("aliquyam")
16389///              .doit().await;
16390/// # }
16391/// ```
16392pub struct FolderListCall<'a, C>
16393where
16394    C: 'a,
16395{
16396    hub: &'a Storage<C>,
16397    _bucket: String,
16398    _start_offset: Option<String>,
16399    _prefix: Option<String>,
16400    _page_token: Option<String>,
16401    _page_size: Option<i32>,
16402    _end_offset: Option<String>,
16403    _delimiter: Option<String>,
16404    _delegate: Option<&'a mut dyn common::Delegate>,
16405    _additional_params: HashMap<String, String>,
16406    _scopes: BTreeSet<String>,
16407}
16408
16409impl<'a, C> common::CallBuilder for FolderListCall<'a, C> {}
16410
16411impl<'a, C> FolderListCall<'a, C>
16412where
16413    C: common::Connector,
16414{
16415    /// Perform the operation you have build so far.
16416    pub async fn doit(mut self) -> common::Result<(common::Response, Folders)> {
16417        use std::borrow::Cow;
16418        use std::io::{Read, Seek};
16419
16420        use common::{url::Params, ToParts};
16421        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16422
16423        let mut dd = common::DefaultDelegate;
16424        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16425        dlg.begin(common::MethodInfo {
16426            id: "storage.folders.list",
16427            http_method: hyper::Method::GET,
16428        });
16429
16430        for &field in [
16431            "alt",
16432            "bucket",
16433            "startOffset",
16434            "prefix",
16435            "pageToken",
16436            "pageSize",
16437            "endOffset",
16438            "delimiter",
16439        ]
16440        .iter()
16441        {
16442            if self._additional_params.contains_key(field) {
16443                dlg.finished(false);
16444                return Err(common::Error::FieldClash(field));
16445            }
16446        }
16447
16448        let mut params = Params::with_capacity(9 + self._additional_params.len());
16449        params.push("bucket", self._bucket);
16450        if let Some(value) = self._start_offset.as_ref() {
16451            params.push("startOffset", value);
16452        }
16453        if let Some(value) = self._prefix.as_ref() {
16454            params.push("prefix", value);
16455        }
16456        if let Some(value) = self._page_token.as_ref() {
16457            params.push("pageToken", value);
16458        }
16459        if let Some(value) = self._page_size.as_ref() {
16460            params.push("pageSize", value.to_string());
16461        }
16462        if let Some(value) = self._end_offset.as_ref() {
16463            params.push("endOffset", value);
16464        }
16465        if let Some(value) = self._delimiter.as_ref() {
16466            params.push("delimiter", value);
16467        }
16468
16469        params.extend(self._additional_params.iter());
16470
16471        params.push("alt", "json");
16472        let mut url = self.hub._base_url.clone() + "b/{bucket}/folders";
16473        if self._scopes.is_empty() {
16474            self._scopes
16475                .insert(Scope::CloudPlatform.as_ref().to_string());
16476        }
16477
16478        #[allow(clippy::single_element_loop)]
16479        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
16480            url = params.uri_replacement(url, param_name, find_this, false);
16481        }
16482        {
16483            let to_remove = ["bucket"];
16484            params.remove_params(&to_remove);
16485        }
16486
16487        let url = params.parse_with_url(&url);
16488
16489        loop {
16490            let token = match self
16491                .hub
16492                .auth
16493                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16494                .await
16495            {
16496                Ok(token) => token,
16497                Err(e) => match dlg.token(e) {
16498                    Ok(token) => token,
16499                    Err(e) => {
16500                        dlg.finished(false);
16501                        return Err(common::Error::MissingToken(e));
16502                    }
16503                },
16504            };
16505            let mut req_result = {
16506                let client = &self.hub.client;
16507                dlg.pre_request();
16508                let mut req_builder = hyper::Request::builder()
16509                    .method(hyper::Method::GET)
16510                    .uri(url.as_str())
16511                    .header(USER_AGENT, self.hub._user_agent.clone());
16512
16513                if let Some(token) = token.as_ref() {
16514                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16515                }
16516
16517                let request = req_builder
16518                    .header(CONTENT_LENGTH, 0_u64)
16519                    .body(common::to_body::<String>(None));
16520
16521                client.request(request.unwrap()).await
16522            };
16523
16524            match req_result {
16525                Err(err) => {
16526                    if let common::Retry::After(d) = dlg.http_error(&err) {
16527                        sleep(d).await;
16528                        continue;
16529                    }
16530                    dlg.finished(false);
16531                    return Err(common::Error::HttpError(err));
16532                }
16533                Ok(res) => {
16534                    let (mut parts, body) = res.into_parts();
16535                    let mut body = common::Body::new(body);
16536                    if !parts.status.is_success() {
16537                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16538                        let error = serde_json::from_str(&common::to_string(&bytes));
16539                        let response = common::to_response(parts, bytes.into());
16540
16541                        if let common::Retry::After(d) =
16542                            dlg.http_failure(&response, error.as_ref().ok())
16543                        {
16544                            sleep(d).await;
16545                            continue;
16546                        }
16547
16548                        dlg.finished(false);
16549
16550                        return Err(match error {
16551                            Ok(value) => common::Error::BadRequest(value),
16552                            _ => common::Error::Failure(response),
16553                        });
16554                    }
16555                    let response = {
16556                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16557                        let encoded = common::to_string(&bytes);
16558                        match serde_json::from_str(&encoded) {
16559                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16560                            Err(error) => {
16561                                dlg.response_json_decode_error(&encoded, &error);
16562                                return Err(common::Error::JsonDecodeError(
16563                                    encoded.to_string(),
16564                                    error,
16565                                ));
16566                            }
16567                        }
16568                    };
16569
16570                    dlg.finished(true);
16571                    return Ok(response);
16572                }
16573            }
16574        }
16575    }
16576
16577    /// Name of the bucket in which to look for folders.
16578    ///
16579    /// Sets the *bucket* path property to the given value.
16580    ///
16581    /// Even though the property as already been set when instantiating this call,
16582    /// we provide this method for API completeness.
16583    pub fn bucket(mut self, new_value: &str) -> FolderListCall<'a, C> {
16584        self._bucket = new_value.to_string();
16585        self
16586    }
16587    /// Filter results to folders whose names are lexicographically equal to or after startOffset. If endOffset is also set, the folders listed will have names between startOffset (inclusive) and endOffset (exclusive).
16588    ///
16589    /// Sets the *start offset* query property to the given value.
16590    pub fn start_offset(mut self, new_value: &str) -> FolderListCall<'a, C> {
16591        self._start_offset = Some(new_value.to_string());
16592        self
16593    }
16594    /// Filter results to folders whose paths begin with this prefix. If set, the value must either be an empty string or end with a '/'.
16595    ///
16596    /// Sets the *prefix* query property to the given value.
16597    pub fn prefix(mut self, new_value: &str) -> FolderListCall<'a, C> {
16598        self._prefix = Some(new_value.to_string());
16599        self
16600    }
16601    /// A previously-returned page token representing part of the larger set of results to view.
16602    ///
16603    /// Sets the *page token* query property to the given value.
16604    pub fn page_token(mut self, new_value: &str) -> FolderListCall<'a, C> {
16605        self._page_token = Some(new_value.to_string());
16606        self
16607    }
16608    /// Maximum number of items to return in a single page of responses.
16609    ///
16610    /// Sets the *page size* query property to the given value.
16611    pub fn page_size(mut self, new_value: i32) -> FolderListCall<'a, C> {
16612        self._page_size = Some(new_value);
16613        self
16614    }
16615    /// Filter results to folders whose names are lexicographically before endOffset. If startOffset is also set, the folders listed will have names between startOffset (inclusive) and endOffset (exclusive).
16616    ///
16617    /// Sets the *end offset* query property to the given value.
16618    pub fn end_offset(mut self, new_value: &str) -> FolderListCall<'a, C> {
16619        self._end_offset = Some(new_value.to_string());
16620        self
16621    }
16622    /// Returns results in a directory-like mode. The only supported value is '/'. If set, items will only contain folders that either exactly match the prefix, or are one level below the prefix.
16623    ///
16624    /// Sets the *delimiter* query property to the given value.
16625    pub fn delimiter(mut self, new_value: &str) -> FolderListCall<'a, C> {
16626        self._delimiter = Some(new_value.to_string());
16627        self
16628    }
16629    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16630    /// while executing the actual API request.
16631    ///
16632    /// ````text
16633    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16634    /// ````
16635    ///
16636    /// Sets the *delegate* property to the given value.
16637    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FolderListCall<'a, C> {
16638        self._delegate = Some(new_value);
16639        self
16640    }
16641
16642    /// Set any additional parameter of the query string used in the request.
16643    /// It should be used to set parameters which are not yet available through their own
16644    /// setters.
16645    ///
16646    /// Please note that this method must not be used to set any of the known parameters
16647    /// which have their own setter method. If done anyway, the request will fail.
16648    ///
16649    /// # Additional Parameters
16650    ///
16651    /// * *alt* (query-string) - Data format for the response.
16652    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16653    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16654    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16655    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16656    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16657    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
16658    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16659    pub fn param<T>(mut self, name: T, value: T) -> FolderListCall<'a, C>
16660    where
16661        T: AsRef<str>,
16662    {
16663        self._additional_params
16664            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16665        self
16666    }
16667
16668    /// Identifies the authorization scope for the method you are building.
16669    ///
16670    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16671    /// [`Scope::CloudPlatform`].
16672    ///
16673    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16674    /// tokens for more than one scope.
16675    ///
16676    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16677    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16678    /// sufficient, a read-write scope will do as well.
16679    pub fn add_scope<St>(mut self, scope: St) -> FolderListCall<'a, C>
16680    where
16681        St: AsRef<str>,
16682    {
16683        self._scopes.insert(String::from(scope.as_ref()));
16684        self
16685    }
16686    /// Identifies the authorization scope(s) for the method you are building.
16687    ///
16688    /// See [`Self::add_scope()`] for details.
16689    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderListCall<'a, C>
16690    where
16691        I: IntoIterator<Item = St>,
16692        St: AsRef<str>,
16693    {
16694        self._scopes
16695            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16696        self
16697    }
16698
16699    /// Removes all scopes, and no default scope will be used either.
16700    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16701    /// for details).
16702    pub fn clear_scopes(mut self) -> FolderListCall<'a, C> {
16703        self._scopes.clear();
16704        self
16705    }
16706}
16707
16708/// Renames a source folder to a destination folder. Only applicable to buckets with hierarchical namespace enabled.
16709///
16710/// A builder for the *rename* method supported by a *folder* resource.
16711/// It is not used directly, but through a [`FolderMethods`] instance.
16712///
16713/// # Example
16714///
16715/// Instantiate a resource method builder
16716///
16717/// ```test_harness,no_run
16718/// # extern crate hyper;
16719/// # extern crate hyper_rustls;
16720/// # extern crate google_storage1 as storage1;
16721/// # async fn dox() {
16722/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16723///
16724/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16725/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16726/// #     secret,
16727/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16728/// # ).build().await.unwrap();
16729///
16730/// # let client = hyper_util::client::legacy::Client::builder(
16731/// #     hyper_util::rt::TokioExecutor::new()
16732/// # )
16733/// # .build(
16734/// #     hyper_rustls::HttpsConnectorBuilder::new()
16735/// #         .with_native_roots()
16736/// #         .unwrap()
16737/// #         .https_or_http()
16738/// #         .enable_http1()
16739/// #         .build()
16740/// # );
16741/// # let mut hub = Storage::new(client, auth);
16742/// // You can configure optional parameters by calling the respective setters at will, and
16743/// // execute the final call using `doit()`.
16744/// // Values shown here are possibly random and not representative !
16745/// let result = hub.folders().rename("bucket", "sourceFolder", "destinationFolder")
16746///              .if_source_metageneration_not_match(-46)
16747///              .if_source_metageneration_match(-62)
16748///              .doit().await;
16749/// # }
16750/// ```
16751pub struct FolderRenameCall<'a, C>
16752where
16753    C: 'a,
16754{
16755    hub: &'a Storage<C>,
16756    _bucket: String,
16757    _source_folder: String,
16758    _destination_folder: String,
16759    _if_source_metageneration_not_match: Option<i64>,
16760    _if_source_metageneration_match: Option<i64>,
16761    _delegate: Option<&'a mut dyn common::Delegate>,
16762    _additional_params: HashMap<String, String>,
16763    _scopes: BTreeSet<String>,
16764}
16765
16766impl<'a, C> common::CallBuilder for FolderRenameCall<'a, C> {}
16767
16768impl<'a, C> FolderRenameCall<'a, C>
16769where
16770    C: common::Connector,
16771{
16772    /// Perform the operation you have build so far.
16773    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
16774        use std::borrow::Cow;
16775        use std::io::{Read, Seek};
16776
16777        use common::{url::Params, ToParts};
16778        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16779
16780        let mut dd = common::DefaultDelegate;
16781        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16782        dlg.begin(common::MethodInfo {
16783            id: "storage.folders.rename",
16784            http_method: hyper::Method::POST,
16785        });
16786
16787        for &field in [
16788            "alt",
16789            "bucket",
16790            "sourceFolder",
16791            "destinationFolder",
16792            "ifSourceMetagenerationNotMatch",
16793            "ifSourceMetagenerationMatch",
16794        ]
16795        .iter()
16796        {
16797            if self._additional_params.contains_key(field) {
16798                dlg.finished(false);
16799                return Err(common::Error::FieldClash(field));
16800            }
16801        }
16802
16803        let mut params = Params::with_capacity(7 + self._additional_params.len());
16804        params.push("bucket", self._bucket);
16805        params.push("sourceFolder", self._source_folder);
16806        params.push("destinationFolder", self._destination_folder);
16807        if let Some(value) = self._if_source_metageneration_not_match.as_ref() {
16808            params.push("ifSourceMetagenerationNotMatch", value.to_string());
16809        }
16810        if let Some(value) = self._if_source_metageneration_match.as_ref() {
16811            params.push("ifSourceMetagenerationMatch", value.to_string());
16812        }
16813
16814        params.extend(self._additional_params.iter());
16815
16816        params.push("alt", "json");
16817        let mut url = self.hub._base_url.clone()
16818            + "b/{bucket}/folders/{sourceFolder}/renameTo/folders/{destinationFolder}";
16819        if self._scopes.is_empty() {
16820            self._scopes
16821                .insert(Scope::CloudPlatform.as_ref().to_string());
16822        }
16823
16824        #[allow(clippy::single_element_loop)]
16825        for &(find_this, param_name) in [
16826            ("{bucket}", "bucket"),
16827            ("{sourceFolder}", "sourceFolder"),
16828            ("{destinationFolder}", "destinationFolder"),
16829        ]
16830        .iter()
16831        {
16832            url = params.uri_replacement(url, param_name, find_this, false);
16833        }
16834        {
16835            let to_remove = ["destinationFolder", "sourceFolder", "bucket"];
16836            params.remove_params(&to_remove);
16837        }
16838
16839        let url = params.parse_with_url(&url);
16840
16841        loop {
16842            let token = match self
16843                .hub
16844                .auth
16845                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16846                .await
16847            {
16848                Ok(token) => token,
16849                Err(e) => match dlg.token(e) {
16850                    Ok(token) => token,
16851                    Err(e) => {
16852                        dlg.finished(false);
16853                        return Err(common::Error::MissingToken(e));
16854                    }
16855                },
16856            };
16857            let mut req_result = {
16858                let client = &self.hub.client;
16859                dlg.pre_request();
16860                let mut req_builder = hyper::Request::builder()
16861                    .method(hyper::Method::POST)
16862                    .uri(url.as_str())
16863                    .header(USER_AGENT, self.hub._user_agent.clone());
16864
16865                if let Some(token) = token.as_ref() {
16866                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16867                }
16868
16869                let request = req_builder
16870                    .header(CONTENT_LENGTH, 0_u64)
16871                    .body(common::to_body::<String>(None));
16872
16873                client.request(request.unwrap()).await
16874            };
16875
16876            match req_result {
16877                Err(err) => {
16878                    if let common::Retry::After(d) = dlg.http_error(&err) {
16879                        sleep(d).await;
16880                        continue;
16881                    }
16882                    dlg.finished(false);
16883                    return Err(common::Error::HttpError(err));
16884                }
16885                Ok(res) => {
16886                    let (mut parts, body) = res.into_parts();
16887                    let mut body = common::Body::new(body);
16888                    if !parts.status.is_success() {
16889                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16890                        let error = serde_json::from_str(&common::to_string(&bytes));
16891                        let response = common::to_response(parts, bytes.into());
16892
16893                        if let common::Retry::After(d) =
16894                            dlg.http_failure(&response, error.as_ref().ok())
16895                        {
16896                            sleep(d).await;
16897                            continue;
16898                        }
16899
16900                        dlg.finished(false);
16901
16902                        return Err(match error {
16903                            Ok(value) => common::Error::BadRequest(value),
16904                            _ => common::Error::Failure(response),
16905                        });
16906                    }
16907                    let response = {
16908                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16909                        let encoded = common::to_string(&bytes);
16910                        match serde_json::from_str(&encoded) {
16911                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16912                            Err(error) => {
16913                                dlg.response_json_decode_error(&encoded, &error);
16914                                return Err(common::Error::JsonDecodeError(
16915                                    encoded.to_string(),
16916                                    error,
16917                                ));
16918                            }
16919                        }
16920                    };
16921
16922                    dlg.finished(true);
16923                    return Ok(response);
16924                }
16925            }
16926        }
16927    }
16928
16929    /// Name of the bucket in which the folders are in.
16930    ///
16931    /// Sets the *bucket* path property to the given value.
16932    ///
16933    /// Even though the property as already been set when instantiating this call,
16934    /// we provide this method for API completeness.
16935    pub fn bucket(mut self, new_value: &str) -> FolderRenameCall<'a, C> {
16936        self._bucket = new_value.to_string();
16937        self
16938    }
16939    /// Name of the source folder.
16940    ///
16941    /// Sets the *source folder* path property to the given value.
16942    ///
16943    /// Even though the property as already been set when instantiating this call,
16944    /// we provide this method for API completeness.
16945    pub fn source_folder(mut self, new_value: &str) -> FolderRenameCall<'a, C> {
16946        self._source_folder = new_value.to_string();
16947        self
16948    }
16949    /// Name of the destination folder.
16950    ///
16951    /// Sets the *destination folder* path property to the given value.
16952    ///
16953    /// Even though the property as already been set when instantiating this call,
16954    /// we provide this method for API completeness.
16955    pub fn destination_folder(mut self, new_value: &str) -> FolderRenameCall<'a, C> {
16956        self._destination_folder = new_value.to_string();
16957        self
16958    }
16959    /// Makes the operation conditional on whether the source object's current metageneration does not match the given value.
16960    ///
16961    /// Sets the *if source metageneration not match* query property to the given value.
16962    pub fn if_source_metageneration_not_match(mut self, new_value: i64) -> FolderRenameCall<'a, C> {
16963        self._if_source_metageneration_not_match = Some(new_value);
16964        self
16965    }
16966    /// Makes the operation conditional on whether the source object's current metageneration matches the given value.
16967    ///
16968    /// Sets the *if source metageneration match* query property to the given value.
16969    pub fn if_source_metageneration_match(mut self, new_value: i64) -> FolderRenameCall<'a, C> {
16970        self._if_source_metageneration_match = Some(new_value);
16971        self
16972    }
16973    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16974    /// while executing the actual API request.
16975    ///
16976    /// ````text
16977    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16978    /// ````
16979    ///
16980    /// Sets the *delegate* property to the given value.
16981    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FolderRenameCall<'a, C> {
16982        self._delegate = Some(new_value);
16983        self
16984    }
16985
16986    /// Set any additional parameter of the query string used in the request.
16987    /// It should be used to set parameters which are not yet available through their own
16988    /// setters.
16989    ///
16990    /// Please note that this method must not be used to set any of the known parameters
16991    /// which have their own setter method. If done anyway, the request will fail.
16992    ///
16993    /// # Additional Parameters
16994    ///
16995    /// * *alt* (query-string) - Data format for the response.
16996    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16997    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16998    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16999    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17000    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17001    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
17002    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17003    pub fn param<T>(mut self, name: T, value: T) -> FolderRenameCall<'a, C>
17004    where
17005        T: AsRef<str>,
17006    {
17007        self._additional_params
17008            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17009        self
17010    }
17011
17012    /// Identifies the authorization scope for the method you are building.
17013    ///
17014    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17015    /// [`Scope::CloudPlatform`].
17016    ///
17017    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17018    /// tokens for more than one scope.
17019    ///
17020    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17021    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17022    /// sufficient, a read-write scope will do as well.
17023    pub fn add_scope<St>(mut self, scope: St) -> FolderRenameCall<'a, C>
17024    where
17025        St: AsRef<str>,
17026    {
17027        self._scopes.insert(String::from(scope.as_ref()));
17028        self
17029    }
17030    /// Identifies the authorization scope(s) for the method you are building.
17031    ///
17032    /// See [`Self::add_scope()`] for details.
17033    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderRenameCall<'a, C>
17034    where
17035        I: IntoIterator<Item = St>,
17036        St: AsRef<str>,
17037    {
17038        self._scopes
17039            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17040        self
17041    }
17042
17043    /// Removes all scopes, and no default scope will be used either.
17044    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17045    /// for details).
17046    pub fn clear_scopes(mut self) -> FolderRenameCall<'a, C> {
17047        self._scopes.clear();
17048        self
17049    }
17050}
17051
17052/// Permanently deletes a managed folder.
17053///
17054/// A builder for the *delete* method supported by a *managedFolder* resource.
17055/// It is not used directly, but through a [`ManagedFolderMethods`] instance.
17056///
17057/// # Example
17058///
17059/// Instantiate a resource method builder
17060///
17061/// ```test_harness,no_run
17062/// # extern crate hyper;
17063/// # extern crate hyper_rustls;
17064/// # extern crate google_storage1 as storage1;
17065/// # async fn dox() {
17066/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17067///
17068/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17069/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17070/// #     secret,
17071/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17072/// # ).build().await.unwrap();
17073///
17074/// # let client = hyper_util::client::legacy::Client::builder(
17075/// #     hyper_util::rt::TokioExecutor::new()
17076/// # )
17077/// # .build(
17078/// #     hyper_rustls::HttpsConnectorBuilder::new()
17079/// #         .with_native_roots()
17080/// #         .unwrap()
17081/// #         .https_or_http()
17082/// #         .enable_http1()
17083/// #         .build()
17084/// # );
17085/// # let mut hub = Storage::new(client, auth);
17086/// // You can configure optional parameters by calling the respective setters at will, and
17087/// // execute the final call using `doit()`.
17088/// // Values shown here are possibly random and not representative !
17089/// let result = hub.managed_folders().delete("bucket", "managedFolder")
17090///              .if_metageneration_not_match(-61)
17091///              .if_metageneration_match(-2)
17092///              .allow_non_empty(true)
17093///              .doit().await;
17094/// # }
17095/// ```
17096pub struct ManagedFolderDeleteCall<'a, C>
17097where
17098    C: 'a,
17099{
17100    hub: &'a Storage<C>,
17101    _bucket: String,
17102    _managed_folder: String,
17103    _if_metageneration_not_match: Option<i64>,
17104    _if_metageneration_match: Option<i64>,
17105    _allow_non_empty: Option<bool>,
17106    _delegate: Option<&'a mut dyn common::Delegate>,
17107    _additional_params: HashMap<String, String>,
17108    _scopes: BTreeSet<String>,
17109}
17110
17111impl<'a, C> common::CallBuilder for ManagedFolderDeleteCall<'a, C> {}
17112
17113impl<'a, C> ManagedFolderDeleteCall<'a, C>
17114where
17115    C: common::Connector,
17116{
17117    /// Perform the operation you have build so far.
17118    pub async fn doit(mut self) -> common::Result<common::Response> {
17119        use std::borrow::Cow;
17120        use std::io::{Read, Seek};
17121
17122        use common::{url::Params, ToParts};
17123        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17124
17125        let mut dd = common::DefaultDelegate;
17126        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17127        dlg.begin(common::MethodInfo {
17128            id: "storage.managedFolders.delete",
17129            http_method: hyper::Method::DELETE,
17130        });
17131
17132        for &field in [
17133            "bucket",
17134            "managedFolder",
17135            "ifMetagenerationNotMatch",
17136            "ifMetagenerationMatch",
17137            "allowNonEmpty",
17138        ]
17139        .iter()
17140        {
17141            if self._additional_params.contains_key(field) {
17142                dlg.finished(false);
17143                return Err(common::Error::FieldClash(field));
17144            }
17145        }
17146
17147        let mut params = Params::with_capacity(6 + self._additional_params.len());
17148        params.push("bucket", self._bucket);
17149        params.push("managedFolder", self._managed_folder);
17150        if let Some(value) = self._if_metageneration_not_match.as_ref() {
17151            params.push("ifMetagenerationNotMatch", value.to_string());
17152        }
17153        if let Some(value) = self._if_metageneration_match.as_ref() {
17154            params.push("ifMetagenerationMatch", value.to_string());
17155        }
17156        if let Some(value) = self._allow_non_empty.as_ref() {
17157            params.push("allowNonEmpty", value.to_string());
17158        }
17159
17160        params.extend(self._additional_params.iter());
17161
17162        let mut url = self.hub._base_url.clone() + "b/{bucket}/managedFolders/{managedFolder}";
17163        if self._scopes.is_empty() {
17164            self._scopes
17165                .insert(Scope::CloudPlatform.as_ref().to_string());
17166        }
17167
17168        #[allow(clippy::single_element_loop)]
17169        for &(find_this, param_name) in
17170            [("{bucket}", "bucket"), ("{managedFolder}", "managedFolder")].iter()
17171        {
17172            url = params.uri_replacement(url, param_name, find_this, false);
17173        }
17174        {
17175            let to_remove = ["managedFolder", "bucket"];
17176            params.remove_params(&to_remove);
17177        }
17178
17179        let url = params.parse_with_url(&url);
17180
17181        loop {
17182            let token = match self
17183                .hub
17184                .auth
17185                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17186                .await
17187            {
17188                Ok(token) => token,
17189                Err(e) => match dlg.token(e) {
17190                    Ok(token) => token,
17191                    Err(e) => {
17192                        dlg.finished(false);
17193                        return Err(common::Error::MissingToken(e));
17194                    }
17195                },
17196            };
17197            let mut req_result = {
17198                let client = &self.hub.client;
17199                dlg.pre_request();
17200                let mut req_builder = hyper::Request::builder()
17201                    .method(hyper::Method::DELETE)
17202                    .uri(url.as_str())
17203                    .header(USER_AGENT, self.hub._user_agent.clone());
17204
17205                if let Some(token) = token.as_ref() {
17206                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17207                }
17208
17209                let request = req_builder
17210                    .header(CONTENT_LENGTH, 0_u64)
17211                    .body(common::to_body::<String>(None));
17212
17213                client.request(request.unwrap()).await
17214            };
17215
17216            match req_result {
17217                Err(err) => {
17218                    if let common::Retry::After(d) = dlg.http_error(&err) {
17219                        sleep(d).await;
17220                        continue;
17221                    }
17222                    dlg.finished(false);
17223                    return Err(common::Error::HttpError(err));
17224                }
17225                Ok(res) => {
17226                    let (mut parts, body) = res.into_parts();
17227                    let mut body = common::Body::new(body);
17228                    if !parts.status.is_success() {
17229                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17230                        let error = serde_json::from_str(&common::to_string(&bytes));
17231                        let response = common::to_response(parts, bytes.into());
17232
17233                        if let common::Retry::After(d) =
17234                            dlg.http_failure(&response, error.as_ref().ok())
17235                        {
17236                            sleep(d).await;
17237                            continue;
17238                        }
17239
17240                        dlg.finished(false);
17241
17242                        return Err(match error {
17243                            Ok(value) => common::Error::BadRequest(value),
17244                            _ => common::Error::Failure(response),
17245                        });
17246                    }
17247                    let response = common::Response::from_parts(parts, body);
17248
17249                    dlg.finished(true);
17250                    return Ok(response);
17251                }
17252            }
17253        }
17254    }
17255
17256    /// Name of the bucket containing the managed folder.
17257    ///
17258    /// Sets the *bucket* path property to the given value.
17259    ///
17260    /// Even though the property as already been set when instantiating this call,
17261    /// we provide this method for API completeness.
17262    pub fn bucket(mut self, new_value: &str) -> ManagedFolderDeleteCall<'a, C> {
17263        self._bucket = new_value.to_string();
17264        self
17265    }
17266    /// The managed folder name/path.
17267    ///
17268    /// Sets the *managed folder* path property to the given value.
17269    ///
17270    /// Even though the property as already been set when instantiating this call,
17271    /// we provide this method for API completeness.
17272    pub fn managed_folder(mut self, new_value: &str) -> ManagedFolderDeleteCall<'a, C> {
17273        self._managed_folder = new_value.to_string();
17274        self
17275    }
17276    /// If set, only deletes the managed folder if its metageneration does not match this value.
17277    ///
17278    /// Sets the *if metageneration not match* query property to the given value.
17279    pub fn if_metageneration_not_match(mut self, new_value: i64) -> ManagedFolderDeleteCall<'a, C> {
17280        self._if_metageneration_not_match = Some(new_value);
17281        self
17282    }
17283    /// If set, only deletes the managed folder if its metageneration matches this value.
17284    ///
17285    /// Sets the *if metageneration match* query property to the given value.
17286    pub fn if_metageneration_match(mut self, new_value: i64) -> ManagedFolderDeleteCall<'a, C> {
17287        self._if_metageneration_match = Some(new_value);
17288        self
17289    }
17290    /// Allows the deletion of a managed folder even if it is not empty. A managed folder is empty if there are no objects or managed folders that it applies to. Callers must have storage.managedFolders.setIamPolicy permission.
17291    ///
17292    /// Sets the *allow non empty* query property to the given value.
17293    pub fn allow_non_empty(mut self, new_value: bool) -> ManagedFolderDeleteCall<'a, C> {
17294        self._allow_non_empty = Some(new_value);
17295        self
17296    }
17297    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17298    /// while executing the actual API request.
17299    ///
17300    /// ````text
17301    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17302    /// ````
17303    ///
17304    /// Sets the *delegate* property to the given value.
17305    pub fn delegate(
17306        mut self,
17307        new_value: &'a mut dyn common::Delegate,
17308    ) -> ManagedFolderDeleteCall<'a, C> {
17309        self._delegate = Some(new_value);
17310        self
17311    }
17312
17313    /// Set any additional parameter of the query string used in the request.
17314    /// It should be used to set parameters which are not yet available through their own
17315    /// setters.
17316    ///
17317    /// Please note that this method must not be used to set any of the known parameters
17318    /// which have their own setter method. If done anyway, the request will fail.
17319    ///
17320    /// # Additional Parameters
17321    ///
17322    /// * *alt* (query-string) - Data format for the response.
17323    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17324    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17325    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17326    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17327    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17328    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
17329    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17330    pub fn param<T>(mut self, name: T, value: T) -> ManagedFolderDeleteCall<'a, C>
17331    where
17332        T: AsRef<str>,
17333    {
17334        self._additional_params
17335            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17336        self
17337    }
17338
17339    /// Identifies the authorization scope for the method you are building.
17340    ///
17341    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17342    /// [`Scope::CloudPlatform`].
17343    ///
17344    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17345    /// tokens for more than one scope.
17346    ///
17347    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17348    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17349    /// sufficient, a read-write scope will do as well.
17350    pub fn add_scope<St>(mut self, scope: St) -> ManagedFolderDeleteCall<'a, C>
17351    where
17352        St: AsRef<str>,
17353    {
17354        self._scopes.insert(String::from(scope.as_ref()));
17355        self
17356    }
17357    /// Identifies the authorization scope(s) for the method you are building.
17358    ///
17359    /// See [`Self::add_scope()`] for details.
17360    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedFolderDeleteCall<'a, C>
17361    where
17362        I: IntoIterator<Item = St>,
17363        St: AsRef<str>,
17364    {
17365        self._scopes
17366            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17367        self
17368    }
17369
17370    /// Removes all scopes, and no default scope will be used either.
17371    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17372    /// for details).
17373    pub fn clear_scopes(mut self) -> ManagedFolderDeleteCall<'a, C> {
17374        self._scopes.clear();
17375        self
17376    }
17377}
17378
17379/// Returns metadata of the specified managed folder.
17380///
17381/// A builder for the *get* method supported by a *managedFolder* resource.
17382/// It is not used directly, but through a [`ManagedFolderMethods`] instance.
17383///
17384/// # Example
17385///
17386/// Instantiate a resource method builder
17387///
17388/// ```test_harness,no_run
17389/// # extern crate hyper;
17390/// # extern crate hyper_rustls;
17391/// # extern crate google_storage1 as storage1;
17392/// # async fn dox() {
17393/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17394///
17395/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17396/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17397/// #     secret,
17398/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17399/// # ).build().await.unwrap();
17400///
17401/// # let client = hyper_util::client::legacy::Client::builder(
17402/// #     hyper_util::rt::TokioExecutor::new()
17403/// # )
17404/// # .build(
17405/// #     hyper_rustls::HttpsConnectorBuilder::new()
17406/// #         .with_native_roots()
17407/// #         .unwrap()
17408/// #         .https_or_http()
17409/// #         .enable_http1()
17410/// #         .build()
17411/// # );
17412/// # let mut hub = Storage::new(client, auth);
17413/// // You can configure optional parameters by calling the respective setters at will, and
17414/// // execute the final call using `doit()`.
17415/// // Values shown here are possibly random and not representative !
17416/// let result = hub.managed_folders().get("bucket", "managedFolder")
17417///              .if_metageneration_not_match(-62)
17418///              .if_metageneration_match(-45)
17419///              .doit().await;
17420/// # }
17421/// ```
17422pub struct ManagedFolderGetCall<'a, C>
17423where
17424    C: 'a,
17425{
17426    hub: &'a Storage<C>,
17427    _bucket: String,
17428    _managed_folder: String,
17429    _if_metageneration_not_match: Option<i64>,
17430    _if_metageneration_match: Option<i64>,
17431    _delegate: Option<&'a mut dyn common::Delegate>,
17432    _additional_params: HashMap<String, String>,
17433    _scopes: BTreeSet<String>,
17434}
17435
17436impl<'a, C> common::CallBuilder for ManagedFolderGetCall<'a, C> {}
17437
17438impl<'a, C> ManagedFolderGetCall<'a, C>
17439where
17440    C: common::Connector,
17441{
17442    /// Perform the operation you have build so far.
17443    pub async fn doit(mut self) -> common::Result<(common::Response, ManagedFolder)> {
17444        use std::borrow::Cow;
17445        use std::io::{Read, Seek};
17446
17447        use common::{url::Params, ToParts};
17448        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17449
17450        let mut dd = common::DefaultDelegate;
17451        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17452        dlg.begin(common::MethodInfo {
17453            id: "storage.managedFolders.get",
17454            http_method: hyper::Method::GET,
17455        });
17456
17457        for &field in [
17458            "alt",
17459            "bucket",
17460            "managedFolder",
17461            "ifMetagenerationNotMatch",
17462            "ifMetagenerationMatch",
17463        ]
17464        .iter()
17465        {
17466            if self._additional_params.contains_key(field) {
17467                dlg.finished(false);
17468                return Err(common::Error::FieldClash(field));
17469            }
17470        }
17471
17472        let mut params = Params::with_capacity(6 + self._additional_params.len());
17473        params.push("bucket", self._bucket);
17474        params.push("managedFolder", self._managed_folder);
17475        if let Some(value) = self._if_metageneration_not_match.as_ref() {
17476            params.push("ifMetagenerationNotMatch", value.to_string());
17477        }
17478        if let Some(value) = self._if_metageneration_match.as_ref() {
17479            params.push("ifMetagenerationMatch", value.to_string());
17480        }
17481
17482        params.extend(self._additional_params.iter());
17483
17484        params.push("alt", "json");
17485        let mut url = self.hub._base_url.clone() + "b/{bucket}/managedFolders/{managedFolder}";
17486        if self._scopes.is_empty() {
17487            self._scopes
17488                .insert(Scope::CloudPlatform.as_ref().to_string());
17489        }
17490
17491        #[allow(clippy::single_element_loop)]
17492        for &(find_this, param_name) in
17493            [("{bucket}", "bucket"), ("{managedFolder}", "managedFolder")].iter()
17494        {
17495            url = params.uri_replacement(url, param_name, find_this, false);
17496        }
17497        {
17498            let to_remove = ["managedFolder", "bucket"];
17499            params.remove_params(&to_remove);
17500        }
17501
17502        let url = params.parse_with_url(&url);
17503
17504        loop {
17505            let token = match self
17506                .hub
17507                .auth
17508                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17509                .await
17510            {
17511                Ok(token) => token,
17512                Err(e) => match dlg.token(e) {
17513                    Ok(token) => token,
17514                    Err(e) => {
17515                        dlg.finished(false);
17516                        return Err(common::Error::MissingToken(e));
17517                    }
17518                },
17519            };
17520            let mut req_result = {
17521                let client = &self.hub.client;
17522                dlg.pre_request();
17523                let mut req_builder = hyper::Request::builder()
17524                    .method(hyper::Method::GET)
17525                    .uri(url.as_str())
17526                    .header(USER_AGENT, self.hub._user_agent.clone());
17527
17528                if let Some(token) = token.as_ref() {
17529                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17530                }
17531
17532                let request = req_builder
17533                    .header(CONTENT_LENGTH, 0_u64)
17534                    .body(common::to_body::<String>(None));
17535
17536                client.request(request.unwrap()).await
17537            };
17538
17539            match req_result {
17540                Err(err) => {
17541                    if let common::Retry::After(d) = dlg.http_error(&err) {
17542                        sleep(d).await;
17543                        continue;
17544                    }
17545                    dlg.finished(false);
17546                    return Err(common::Error::HttpError(err));
17547                }
17548                Ok(res) => {
17549                    let (mut parts, body) = res.into_parts();
17550                    let mut body = common::Body::new(body);
17551                    if !parts.status.is_success() {
17552                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17553                        let error = serde_json::from_str(&common::to_string(&bytes));
17554                        let response = common::to_response(parts, bytes.into());
17555
17556                        if let common::Retry::After(d) =
17557                            dlg.http_failure(&response, error.as_ref().ok())
17558                        {
17559                            sleep(d).await;
17560                            continue;
17561                        }
17562
17563                        dlg.finished(false);
17564
17565                        return Err(match error {
17566                            Ok(value) => common::Error::BadRequest(value),
17567                            _ => common::Error::Failure(response),
17568                        });
17569                    }
17570                    let response = {
17571                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17572                        let encoded = common::to_string(&bytes);
17573                        match serde_json::from_str(&encoded) {
17574                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17575                            Err(error) => {
17576                                dlg.response_json_decode_error(&encoded, &error);
17577                                return Err(common::Error::JsonDecodeError(
17578                                    encoded.to_string(),
17579                                    error,
17580                                ));
17581                            }
17582                        }
17583                    };
17584
17585                    dlg.finished(true);
17586                    return Ok(response);
17587                }
17588            }
17589        }
17590    }
17591
17592    /// Name of the bucket containing the managed folder.
17593    ///
17594    /// Sets the *bucket* path property to the given value.
17595    ///
17596    /// Even though the property as already been set when instantiating this call,
17597    /// we provide this method for API completeness.
17598    pub fn bucket(mut self, new_value: &str) -> ManagedFolderGetCall<'a, C> {
17599        self._bucket = new_value.to_string();
17600        self
17601    }
17602    /// The managed folder name/path.
17603    ///
17604    /// Sets the *managed folder* path property to the given value.
17605    ///
17606    /// Even though the property as already been set when instantiating this call,
17607    /// we provide this method for API completeness.
17608    pub fn managed_folder(mut self, new_value: &str) -> ManagedFolderGetCall<'a, C> {
17609        self._managed_folder = new_value.to_string();
17610        self
17611    }
17612    /// Makes the return of the managed folder metadata conditional on whether the managed folder's current metageneration does not match the given value.
17613    ///
17614    /// Sets the *if metageneration not match* query property to the given value.
17615    pub fn if_metageneration_not_match(mut self, new_value: i64) -> ManagedFolderGetCall<'a, C> {
17616        self._if_metageneration_not_match = Some(new_value);
17617        self
17618    }
17619    /// Makes the return of the managed folder metadata conditional on whether the managed folder's current metageneration matches the given value.
17620    ///
17621    /// Sets the *if metageneration match* query property to the given value.
17622    pub fn if_metageneration_match(mut self, new_value: i64) -> ManagedFolderGetCall<'a, C> {
17623        self._if_metageneration_match = Some(new_value);
17624        self
17625    }
17626    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17627    /// while executing the actual API request.
17628    ///
17629    /// ````text
17630    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17631    /// ````
17632    ///
17633    /// Sets the *delegate* property to the given value.
17634    pub fn delegate(
17635        mut self,
17636        new_value: &'a mut dyn common::Delegate,
17637    ) -> ManagedFolderGetCall<'a, C> {
17638        self._delegate = Some(new_value);
17639        self
17640    }
17641
17642    /// Set any additional parameter of the query string used in the request.
17643    /// It should be used to set parameters which are not yet available through their own
17644    /// setters.
17645    ///
17646    /// Please note that this method must not be used to set any of the known parameters
17647    /// which have their own setter method. If done anyway, the request will fail.
17648    ///
17649    /// # Additional Parameters
17650    ///
17651    /// * *alt* (query-string) - Data format for the response.
17652    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17653    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17654    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17655    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17656    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17657    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
17658    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17659    pub fn param<T>(mut self, name: T, value: T) -> ManagedFolderGetCall<'a, C>
17660    where
17661        T: AsRef<str>,
17662    {
17663        self._additional_params
17664            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17665        self
17666    }
17667
17668    /// Identifies the authorization scope for the method you are building.
17669    ///
17670    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17671    /// [`Scope::CloudPlatform`].
17672    ///
17673    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17674    /// tokens for more than one scope.
17675    ///
17676    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17677    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17678    /// sufficient, a read-write scope will do as well.
17679    pub fn add_scope<St>(mut self, scope: St) -> ManagedFolderGetCall<'a, C>
17680    where
17681        St: AsRef<str>,
17682    {
17683        self._scopes.insert(String::from(scope.as_ref()));
17684        self
17685    }
17686    /// Identifies the authorization scope(s) for the method you are building.
17687    ///
17688    /// See [`Self::add_scope()`] for details.
17689    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedFolderGetCall<'a, C>
17690    where
17691        I: IntoIterator<Item = St>,
17692        St: AsRef<str>,
17693    {
17694        self._scopes
17695            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17696        self
17697    }
17698
17699    /// Removes all scopes, and no default scope will be used either.
17700    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17701    /// for details).
17702    pub fn clear_scopes(mut self) -> ManagedFolderGetCall<'a, C> {
17703        self._scopes.clear();
17704        self
17705    }
17706}
17707
17708/// Returns an IAM policy for the specified managed folder.
17709///
17710/// A builder for the *getIamPolicy* method supported by a *managedFolder* resource.
17711/// It is not used directly, but through a [`ManagedFolderMethods`] instance.
17712///
17713/// # Example
17714///
17715/// Instantiate a resource method builder
17716///
17717/// ```test_harness,no_run
17718/// # extern crate hyper;
17719/// # extern crate hyper_rustls;
17720/// # extern crate google_storage1 as storage1;
17721/// # async fn dox() {
17722/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17723///
17724/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17725/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17726/// #     secret,
17727/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17728/// # ).build().await.unwrap();
17729///
17730/// # let client = hyper_util::client::legacy::Client::builder(
17731/// #     hyper_util::rt::TokioExecutor::new()
17732/// # )
17733/// # .build(
17734/// #     hyper_rustls::HttpsConnectorBuilder::new()
17735/// #         .with_native_roots()
17736/// #         .unwrap()
17737/// #         .https_or_http()
17738/// #         .enable_http1()
17739/// #         .build()
17740/// # );
17741/// # let mut hub = Storage::new(client, auth);
17742/// // You can configure optional parameters by calling the respective setters at will, and
17743/// // execute the final call using `doit()`.
17744/// // Values shown here are possibly random and not representative !
17745/// let result = hub.managed_folders().get_iam_policy("bucket", "managedFolder")
17746///              .user_project("duo")
17747///              .options_requested_policy_version(-53)
17748///              .doit().await;
17749/// # }
17750/// ```
17751pub struct ManagedFolderGetIamPolicyCall<'a, C>
17752where
17753    C: 'a,
17754{
17755    hub: &'a Storage<C>,
17756    _bucket: String,
17757    _managed_folder: String,
17758    _user_project: Option<String>,
17759    _options_requested_policy_version: Option<i32>,
17760    _delegate: Option<&'a mut dyn common::Delegate>,
17761    _additional_params: HashMap<String, String>,
17762    _scopes: BTreeSet<String>,
17763}
17764
17765impl<'a, C> common::CallBuilder for ManagedFolderGetIamPolicyCall<'a, C> {}
17766
17767impl<'a, C> ManagedFolderGetIamPolicyCall<'a, C>
17768where
17769    C: common::Connector,
17770{
17771    /// Perform the operation you have build so far.
17772    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
17773        use std::borrow::Cow;
17774        use std::io::{Read, Seek};
17775
17776        use common::{url::Params, ToParts};
17777        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17778
17779        let mut dd = common::DefaultDelegate;
17780        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17781        dlg.begin(common::MethodInfo {
17782            id: "storage.managedFolders.getIamPolicy",
17783            http_method: hyper::Method::GET,
17784        });
17785
17786        for &field in [
17787            "alt",
17788            "bucket",
17789            "managedFolder",
17790            "userProject",
17791            "optionsRequestedPolicyVersion",
17792        ]
17793        .iter()
17794        {
17795            if self._additional_params.contains_key(field) {
17796                dlg.finished(false);
17797                return Err(common::Error::FieldClash(field));
17798            }
17799        }
17800
17801        let mut params = Params::with_capacity(6 + self._additional_params.len());
17802        params.push("bucket", self._bucket);
17803        params.push("managedFolder", self._managed_folder);
17804        if let Some(value) = self._user_project.as_ref() {
17805            params.push("userProject", value);
17806        }
17807        if let Some(value) = self._options_requested_policy_version.as_ref() {
17808            params.push("optionsRequestedPolicyVersion", value.to_string());
17809        }
17810
17811        params.extend(self._additional_params.iter());
17812
17813        params.push("alt", "json");
17814        let mut url = self.hub._base_url.clone() + "b/{bucket}/managedFolders/{managedFolder}/iam";
17815        if self._scopes.is_empty() {
17816            self._scopes
17817                .insert(Scope::CloudPlatform.as_ref().to_string());
17818        }
17819
17820        #[allow(clippy::single_element_loop)]
17821        for &(find_this, param_name) in
17822            [("{bucket}", "bucket"), ("{managedFolder}", "managedFolder")].iter()
17823        {
17824            url = params.uri_replacement(url, param_name, find_this, false);
17825        }
17826        {
17827            let to_remove = ["managedFolder", "bucket"];
17828            params.remove_params(&to_remove);
17829        }
17830
17831        let url = params.parse_with_url(&url);
17832
17833        loop {
17834            let token = match self
17835                .hub
17836                .auth
17837                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17838                .await
17839            {
17840                Ok(token) => token,
17841                Err(e) => match dlg.token(e) {
17842                    Ok(token) => token,
17843                    Err(e) => {
17844                        dlg.finished(false);
17845                        return Err(common::Error::MissingToken(e));
17846                    }
17847                },
17848            };
17849            let mut req_result = {
17850                let client = &self.hub.client;
17851                dlg.pre_request();
17852                let mut req_builder = hyper::Request::builder()
17853                    .method(hyper::Method::GET)
17854                    .uri(url.as_str())
17855                    .header(USER_AGENT, self.hub._user_agent.clone());
17856
17857                if let Some(token) = token.as_ref() {
17858                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17859                }
17860
17861                let request = req_builder
17862                    .header(CONTENT_LENGTH, 0_u64)
17863                    .body(common::to_body::<String>(None));
17864
17865                client.request(request.unwrap()).await
17866            };
17867
17868            match req_result {
17869                Err(err) => {
17870                    if let common::Retry::After(d) = dlg.http_error(&err) {
17871                        sleep(d).await;
17872                        continue;
17873                    }
17874                    dlg.finished(false);
17875                    return Err(common::Error::HttpError(err));
17876                }
17877                Ok(res) => {
17878                    let (mut parts, body) = res.into_parts();
17879                    let mut body = common::Body::new(body);
17880                    if !parts.status.is_success() {
17881                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17882                        let error = serde_json::from_str(&common::to_string(&bytes));
17883                        let response = common::to_response(parts, bytes.into());
17884
17885                        if let common::Retry::After(d) =
17886                            dlg.http_failure(&response, error.as_ref().ok())
17887                        {
17888                            sleep(d).await;
17889                            continue;
17890                        }
17891
17892                        dlg.finished(false);
17893
17894                        return Err(match error {
17895                            Ok(value) => common::Error::BadRequest(value),
17896                            _ => common::Error::Failure(response),
17897                        });
17898                    }
17899                    let response = {
17900                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17901                        let encoded = common::to_string(&bytes);
17902                        match serde_json::from_str(&encoded) {
17903                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17904                            Err(error) => {
17905                                dlg.response_json_decode_error(&encoded, &error);
17906                                return Err(common::Error::JsonDecodeError(
17907                                    encoded.to_string(),
17908                                    error,
17909                                ));
17910                            }
17911                        }
17912                    };
17913
17914                    dlg.finished(true);
17915                    return Ok(response);
17916                }
17917            }
17918        }
17919    }
17920
17921    /// Name of the bucket containing the managed folder.
17922    ///
17923    /// Sets the *bucket* path property to the given value.
17924    ///
17925    /// Even though the property as already been set when instantiating this call,
17926    /// we provide this method for API completeness.
17927    pub fn bucket(mut self, new_value: &str) -> ManagedFolderGetIamPolicyCall<'a, C> {
17928        self._bucket = new_value.to_string();
17929        self
17930    }
17931    /// The managed folder name/path.
17932    ///
17933    /// Sets the *managed folder* path property to the given value.
17934    ///
17935    /// Even though the property as already been set when instantiating this call,
17936    /// we provide this method for API completeness.
17937    pub fn managed_folder(mut self, new_value: &str) -> ManagedFolderGetIamPolicyCall<'a, C> {
17938        self._managed_folder = new_value.to_string();
17939        self
17940    }
17941    /// The project to be billed for this request. Required for Requester Pays buckets.
17942    ///
17943    /// Sets the *user project* query property to the given value.
17944    pub fn user_project(mut self, new_value: &str) -> ManagedFolderGetIamPolicyCall<'a, C> {
17945        self._user_project = Some(new_value.to_string());
17946        self
17947    }
17948    /// The IAM policy format version to be returned. If the optionsRequestedPolicyVersion is for an older version that doesn't support part of the requested IAM policy, the request fails.
17949    ///
17950    /// Sets the *options requested policy version* query property to the given value.
17951    pub fn options_requested_policy_version(
17952        mut self,
17953        new_value: i32,
17954    ) -> ManagedFolderGetIamPolicyCall<'a, C> {
17955        self._options_requested_policy_version = Some(new_value);
17956        self
17957    }
17958    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17959    /// while executing the actual API request.
17960    ///
17961    /// ````text
17962    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17963    /// ````
17964    ///
17965    /// Sets the *delegate* property to the given value.
17966    pub fn delegate(
17967        mut self,
17968        new_value: &'a mut dyn common::Delegate,
17969    ) -> ManagedFolderGetIamPolicyCall<'a, C> {
17970        self._delegate = Some(new_value);
17971        self
17972    }
17973
17974    /// Set any additional parameter of the query string used in the request.
17975    /// It should be used to set parameters which are not yet available through their own
17976    /// setters.
17977    ///
17978    /// Please note that this method must not be used to set any of the known parameters
17979    /// which have their own setter method. If done anyway, the request will fail.
17980    ///
17981    /// # Additional Parameters
17982    ///
17983    /// * *alt* (query-string) - Data format for the response.
17984    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17985    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17986    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17987    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17988    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17989    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
17990    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17991    pub fn param<T>(mut self, name: T, value: T) -> ManagedFolderGetIamPolicyCall<'a, C>
17992    where
17993        T: AsRef<str>,
17994    {
17995        self._additional_params
17996            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17997        self
17998    }
17999
18000    /// Identifies the authorization scope for the method you are building.
18001    ///
18002    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18003    /// [`Scope::CloudPlatform`].
18004    ///
18005    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18006    /// tokens for more than one scope.
18007    ///
18008    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18009    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18010    /// sufficient, a read-write scope will do as well.
18011    pub fn add_scope<St>(mut self, scope: St) -> ManagedFolderGetIamPolicyCall<'a, C>
18012    where
18013        St: AsRef<str>,
18014    {
18015        self._scopes.insert(String::from(scope.as_ref()));
18016        self
18017    }
18018    /// Identifies the authorization scope(s) for the method you are building.
18019    ///
18020    /// See [`Self::add_scope()`] for details.
18021    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedFolderGetIamPolicyCall<'a, C>
18022    where
18023        I: IntoIterator<Item = St>,
18024        St: AsRef<str>,
18025    {
18026        self._scopes
18027            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18028        self
18029    }
18030
18031    /// Removes all scopes, and no default scope will be used either.
18032    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18033    /// for details).
18034    pub fn clear_scopes(mut self) -> ManagedFolderGetIamPolicyCall<'a, C> {
18035        self._scopes.clear();
18036        self
18037    }
18038}
18039
18040/// Creates a new managed folder.
18041///
18042/// A builder for the *insert* method supported by a *managedFolder* resource.
18043/// It is not used directly, but through a [`ManagedFolderMethods`] instance.
18044///
18045/// # Example
18046///
18047/// Instantiate a resource method builder
18048///
18049/// ```test_harness,no_run
18050/// # extern crate hyper;
18051/// # extern crate hyper_rustls;
18052/// # extern crate google_storage1 as storage1;
18053/// use storage1::api::ManagedFolder;
18054/// # async fn dox() {
18055/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18056///
18057/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18058/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18059/// #     secret,
18060/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18061/// # ).build().await.unwrap();
18062///
18063/// # let client = hyper_util::client::legacy::Client::builder(
18064/// #     hyper_util::rt::TokioExecutor::new()
18065/// # )
18066/// # .build(
18067/// #     hyper_rustls::HttpsConnectorBuilder::new()
18068/// #         .with_native_roots()
18069/// #         .unwrap()
18070/// #         .https_or_http()
18071/// #         .enable_http1()
18072/// #         .build()
18073/// # );
18074/// # let mut hub = Storage::new(client, auth);
18075/// // As the method needs a request, you would usually fill it with the desired information
18076/// // into the respective structure. Some of the parts shown here might not be applicable !
18077/// // Values shown here are possibly random and not representative !
18078/// let mut req = ManagedFolder::default();
18079///
18080/// // You can configure optional parameters by calling the respective setters at will, and
18081/// // execute the final call using `doit()`.
18082/// // Values shown here are possibly random and not representative !
18083/// let result = hub.managed_folders().insert(req, "bucket")
18084///              .doit().await;
18085/// # }
18086/// ```
18087pub struct ManagedFolderInsertCall<'a, C>
18088where
18089    C: 'a,
18090{
18091    hub: &'a Storage<C>,
18092    _request: ManagedFolder,
18093    _bucket: String,
18094    _delegate: Option<&'a mut dyn common::Delegate>,
18095    _additional_params: HashMap<String, String>,
18096    _scopes: BTreeSet<String>,
18097}
18098
18099impl<'a, C> common::CallBuilder for ManagedFolderInsertCall<'a, C> {}
18100
18101impl<'a, C> ManagedFolderInsertCall<'a, C>
18102where
18103    C: common::Connector,
18104{
18105    /// Perform the operation you have build so far.
18106    pub async fn doit(mut self) -> common::Result<(common::Response, ManagedFolder)> {
18107        use std::borrow::Cow;
18108        use std::io::{Read, Seek};
18109
18110        use common::{url::Params, ToParts};
18111        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18112
18113        let mut dd = common::DefaultDelegate;
18114        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18115        dlg.begin(common::MethodInfo {
18116            id: "storage.managedFolders.insert",
18117            http_method: hyper::Method::POST,
18118        });
18119
18120        for &field in ["alt", "bucket"].iter() {
18121            if self._additional_params.contains_key(field) {
18122                dlg.finished(false);
18123                return Err(common::Error::FieldClash(field));
18124            }
18125        }
18126
18127        let mut params = Params::with_capacity(4 + self._additional_params.len());
18128        params.push("bucket", self._bucket);
18129
18130        params.extend(self._additional_params.iter());
18131
18132        params.push("alt", "json");
18133        let mut url = self.hub._base_url.clone() + "b/{bucket}/managedFolders";
18134        if self._scopes.is_empty() {
18135            self._scopes
18136                .insert(Scope::CloudPlatform.as_ref().to_string());
18137        }
18138
18139        #[allow(clippy::single_element_loop)]
18140        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
18141            url = params.uri_replacement(url, param_name, find_this, false);
18142        }
18143        {
18144            let to_remove = ["bucket"];
18145            params.remove_params(&to_remove);
18146        }
18147
18148        let url = params.parse_with_url(&url);
18149
18150        let mut json_mime_type = mime::APPLICATION_JSON;
18151        let mut request_value_reader = {
18152            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18153            common::remove_json_null_values(&mut value);
18154            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18155            serde_json::to_writer(&mut dst, &value).unwrap();
18156            dst
18157        };
18158        let request_size = request_value_reader
18159            .seek(std::io::SeekFrom::End(0))
18160            .unwrap();
18161        request_value_reader
18162            .seek(std::io::SeekFrom::Start(0))
18163            .unwrap();
18164
18165        loop {
18166            let token = match self
18167                .hub
18168                .auth
18169                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18170                .await
18171            {
18172                Ok(token) => token,
18173                Err(e) => match dlg.token(e) {
18174                    Ok(token) => token,
18175                    Err(e) => {
18176                        dlg.finished(false);
18177                        return Err(common::Error::MissingToken(e));
18178                    }
18179                },
18180            };
18181            request_value_reader
18182                .seek(std::io::SeekFrom::Start(0))
18183                .unwrap();
18184            let mut req_result = {
18185                let client = &self.hub.client;
18186                dlg.pre_request();
18187                let mut req_builder = hyper::Request::builder()
18188                    .method(hyper::Method::POST)
18189                    .uri(url.as_str())
18190                    .header(USER_AGENT, self.hub._user_agent.clone());
18191
18192                if let Some(token) = token.as_ref() {
18193                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18194                }
18195
18196                let request = req_builder
18197                    .header(CONTENT_TYPE, json_mime_type.to_string())
18198                    .header(CONTENT_LENGTH, request_size as u64)
18199                    .body(common::to_body(
18200                        request_value_reader.get_ref().clone().into(),
18201                    ));
18202
18203                client.request(request.unwrap()).await
18204            };
18205
18206            match req_result {
18207                Err(err) => {
18208                    if let common::Retry::After(d) = dlg.http_error(&err) {
18209                        sleep(d).await;
18210                        continue;
18211                    }
18212                    dlg.finished(false);
18213                    return Err(common::Error::HttpError(err));
18214                }
18215                Ok(res) => {
18216                    let (mut parts, body) = res.into_parts();
18217                    let mut body = common::Body::new(body);
18218                    if !parts.status.is_success() {
18219                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18220                        let error = serde_json::from_str(&common::to_string(&bytes));
18221                        let response = common::to_response(parts, bytes.into());
18222
18223                        if let common::Retry::After(d) =
18224                            dlg.http_failure(&response, error.as_ref().ok())
18225                        {
18226                            sleep(d).await;
18227                            continue;
18228                        }
18229
18230                        dlg.finished(false);
18231
18232                        return Err(match error {
18233                            Ok(value) => common::Error::BadRequest(value),
18234                            _ => common::Error::Failure(response),
18235                        });
18236                    }
18237                    let response = {
18238                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18239                        let encoded = common::to_string(&bytes);
18240                        match serde_json::from_str(&encoded) {
18241                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18242                            Err(error) => {
18243                                dlg.response_json_decode_error(&encoded, &error);
18244                                return Err(common::Error::JsonDecodeError(
18245                                    encoded.to_string(),
18246                                    error,
18247                                ));
18248                            }
18249                        }
18250                    };
18251
18252                    dlg.finished(true);
18253                    return Ok(response);
18254                }
18255            }
18256        }
18257    }
18258
18259    ///
18260    /// Sets the *request* property to the given value.
18261    ///
18262    /// Even though the property as already been set when instantiating this call,
18263    /// we provide this method for API completeness.
18264    pub fn request(mut self, new_value: ManagedFolder) -> ManagedFolderInsertCall<'a, C> {
18265        self._request = new_value;
18266        self
18267    }
18268    /// Name of the bucket containing the managed folder.
18269    ///
18270    /// Sets the *bucket* path property to the given value.
18271    ///
18272    /// Even though the property as already been set when instantiating this call,
18273    /// we provide this method for API completeness.
18274    pub fn bucket(mut self, new_value: &str) -> ManagedFolderInsertCall<'a, C> {
18275        self._bucket = new_value.to_string();
18276        self
18277    }
18278    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18279    /// while executing the actual API request.
18280    ///
18281    /// ````text
18282    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18283    /// ````
18284    ///
18285    /// Sets the *delegate* property to the given value.
18286    pub fn delegate(
18287        mut self,
18288        new_value: &'a mut dyn common::Delegate,
18289    ) -> ManagedFolderInsertCall<'a, C> {
18290        self._delegate = Some(new_value);
18291        self
18292    }
18293
18294    /// Set any additional parameter of the query string used in the request.
18295    /// It should be used to set parameters which are not yet available through their own
18296    /// setters.
18297    ///
18298    /// Please note that this method must not be used to set any of the known parameters
18299    /// which have their own setter method. If done anyway, the request will fail.
18300    ///
18301    /// # Additional Parameters
18302    ///
18303    /// * *alt* (query-string) - Data format for the response.
18304    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18305    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18306    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18307    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18308    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18309    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
18310    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18311    pub fn param<T>(mut self, name: T, value: T) -> ManagedFolderInsertCall<'a, C>
18312    where
18313        T: AsRef<str>,
18314    {
18315        self._additional_params
18316            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18317        self
18318    }
18319
18320    /// Identifies the authorization scope for the method you are building.
18321    ///
18322    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18323    /// [`Scope::CloudPlatform`].
18324    ///
18325    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18326    /// tokens for more than one scope.
18327    ///
18328    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18329    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18330    /// sufficient, a read-write scope will do as well.
18331    pub fn add_scope<St>(mut self, scope: St) -> ManagedFolderInsertCall<'a, C>
18332    where
18333        St: AsRef<str>,
18334    {
18335        self._scopes.insert(String::from(scope.as_ref()));
18336        self
18337    }
18338    /// Identifies the authorization scope(s) for the method you are building.
18339    ///
18340    /// See [`Self::add_scope()`] for details.
18341    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedFolderInsertCall<'a, C>
18342    where
18343        I: IntoIterator<Item = St>,
18344        St: AsRef<str>,
18345    {
18346        self._scopes
18347            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18348        self
18349    }
18350
18351    /// Removes all scopes, and no default scope will be used either.
18352    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18353    /// for details).
18354    pub fn clear_scopes(mut self) -> ManagedFolderInsertCall<'a, C> {
18355        self._scopes.clear();
18356        self
18357    }
18358}
18359
18360/// Lists managed folders in the given bucket.
18361///
18362/// A builder for the *list* method supported by a *managedFolder* resource.
18363/// It is not used directly, but through a [`ManagedFolderMethods`] instance.
18364///
18365/// # Example
18366///
18367/// Instantiate a resource method builder
18368///
18369/// ```test_harness,no_run
18370/// # extern crate hyper;
18371/// # extern crate hyper_rustls;
18372/// # extern crate google_storage1 as storage1;
18373/// # async fn dox() {
18374/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18375///
18376/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18377/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18378/// #     secret,
18379/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18380/// # ).build().await.unwrap();
18381///
18382/// # let client = hyper_util::client::legacy::Client::builder(
18383/// #     hyper_util::rt::TokioExecutor::new()
18384/// # )
18385/// # .build(
18386/// #     hyper_rustls::HttpsConnectorBuilder::new()
18387/// #         .with_native_roots()
18388/// #         .unwrap()
18389/// #         .https_or_http()
18390/// #         .enable_http1()
18391/// #         .build()
18392/// # );
18393/// # let mut hub = Storage::new(client, auth);
18394/// // You can configure optional parameters by calling the respective setters at will, and
18395/// // execute the final call using `doit()`.
18396/// // Values shown here are possibly random and not representative !
18397/// let result = hub.managed_folders().list("bucket")
18398///              .prefix("rebum.")
18399///              .page_token("dolor")
18400///              .page_size(-6)
18401///              .doit().await;
18402/// # }
18403/// ```
18404pub struct ManagedFolderListCall<'a, C>
18405where
18406    C: 'a,
18407{
18408    hub: &'a Storage<C>,
18409    _bucket: String,
18410    _prefix: Option<String>,
18411    _page_token: Option<String>,
18412    _page_size: Option<i32>,
18413    _delegate: Option<&'a mut dyn common::Delegate>,
18414    _additional_params: HashMap<String, String>,
18415    _scopes: BTreeSet<String>,
18416}
18417
18418impl<'a, C> common::CallBuilder for ManagedFolderListCall<'a, C> {}
18419
18420impl<'a, C> ManagedFolderListCall<'a, C>
18421where
18422    C: common::Connector,
18423{
18424    /// Perform the operation you have build so far.
18425    pub async fn doit(mut self) -> common::Result<(common::Response, ManagedFolders)> {
18426        use std::borrow::Cow;
18427        use std::io::{Read, Seek};
18428
18429        use common::{url::Params, ToParts};
18430        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18431
18432        let mut dd = common::DefaultDelegate;
18433        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18434        dlg.begin(common::MethodInfo {
18435            id: "storage.managedFolders.list",
18436            http_method: hyper::Method::GET,
18437        });
18438
18439        for &field in ["alt", "bucket", "prefix", "pageToken", "pageSize"].iter() {
18440            if self._additional_params.contains_key(field) {
18441                dlg.finished(false);
18442                return Err(common::Error::FieldClash(field));
18443            }
18444        }
18445
18446        let mut params = Params::with_capacity(6 + self._additional_params.len());
18447        params.push("bucket", self._bucket);
18448        if let Some(value) = self._prefix.as_ref() {
18449            params.push("prefix", value);
18450        }
18451        if let Some(value) = self._page_token.as_ref() {
18452            params.push("pageToken", value);
18453        }
18454        if let Some(value) = self._page_size.as_ref() {
18455            params.push("pageSize", value.to_string());
18456        }
18457
18458        params.extend(self._additional_params.iter());
18459
18460        params.push("alt", "json");
18461        let mut url = self.hub._base_url.clone() + "b/{bucket}/managedFolders";
18462        if self._scopes.is_empty() {
18463            self._scopes
18464                .insert(Scope::CloudPlatform.as_ref().to_string());
18465        }
18466
18467        #[allow(clippy::single_element_loop)]
18468        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
18469            url = params.uri_replacement(url, param_name, find_this, false);
18470        }
18471        {
18472            let to_remove = ["bucket"];
18473            params.remove_params(&to_remove);
18474        }
18475
18476        let url = params.parse_with_url(&url);
18477
18478        loop {
18479            let token = match self
18480                .hub
18481                .auth
18482                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18483                .await
18484            {
18485                Ok(token) => token,
18486                Err(e) => match dlg.token(e) {
18487                    Ok(token) => token,
18488                    Err(e) => {
18489                        dlg.finished(false);
18490                        return Err(common::Error::MissingToken(e));
18491                    }
18492                },
18493            };
18494            let mut req_result = {
18495                let client = &self.hub.client;
18496                dlg.pre_request();
18497                let mut req_builder = hyper::Request::builder()
18498                    .method(hyper::Method::GET)
18499                    .uri(url.as_str())
18500                    .header(USER_AGENT, self.hub._user_agent.clone());
18501
18502                if let Some(token) = token.as_ref() {
18503                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18504                }
18505
18506                let request = req_builder
18507                    .header(CONTENT_LENGTH, 0_u64)
18508                    .body(common::to_body::<String>(None));
18509
18510                client.request(request.unwrap()).await
18511            };
18512
18513            match req_result {
18514                Err(err) => {
18515                    if let common::Retry::After(d) = dlg.http_error(&err) {
18516                        sleep(d).await;
18517                        continue;
18518                    }
18519                    dlg.finished(false);
18520                    return Err(common::Error::HttpError(err));
18521                }
18522                Ok(res) => {
18523                    let (mut parts, body) = res.into_parts();
18524                    let mut body = common::Body::new(body);
18525                    if !parts.status.is_success() {
18526                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18527                        let error = serde_json::from_str(&common::to_string(&bytes));
18528                        let response = common::to_response(parts, bytes.into());
18529
18530                        if let common::Retry::After(d) =
18531                            dlg.http_failure(&response, error.as_ref().ok())
18532                        {
18533                            sleep(d).await;
18534                            continue;
18535                        }
18536
18537                        dlg.finished(false);
18538
18539                        return Err(match error {
18540                            Ok(value) => common::Error::BadRequest(value),
18541                            _ => common::Error::Failure(response),
18542                        });
18543                    }
18544                    let response = {
18545                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18546                        let encoded = common::to_string(&bytes);
18547                        match serde_json::from_str(&encoded) {
18548                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18549                            Err(error) => {
18550                                dlg.response_json_decode_error(&encoded, &error);
18551                                return Err(common::Error::JsonDecodeError(
18552                                    encoded.to_string(),
18553                                    error,
18554                                ));
18555                            }
18556                        }
18557                    };
18558
18559                    dlg.finished(true);
18560                    return Ok(response);
18561                }
18562            }
18563        }
18564    }
18565
18566    /// Name of the bucket containing the managed folder.
18567    ///
18568    /// Sets the *bucket* path property to the given value.
18569    ///
18570    /// Even though the property as already been set when instantiating this call,
18571    /// we provide this method for API completeness.
18572    pub fn bucket(mut self, new_value: &str) -> ManagedFolderListCall<'a, C> {
18573        self._bucket = new_value.to_string();
18574        self
18575    }
18576    /// The managed folder name/path prefix to filter the output list of results.
18577    ///
18578    /// Sets the *prefix* query property to the given value.
18579    pub fn prefix(mut self, new_value: &str) -> ManagedFolderListCall<'a, C> {
18580        self._prefix = Some(new_value.to_string());
18581        self
18582    }
18583    /// A previously-returned page token representing part of the larger set of results to view.
18584    ///
18585    /// Sets the *page token* query property to the given value.
18586    pub fn page_token(mut self, new_value: &str) -> ManagedFolderListCall<'a, C> {
18587        self._page_token = Some(new_value.to_string());
18588        self
18589    }
18590    /// Maximum number of items to return in a single page of responses.
18591    ///
18592    /// Sets the *page size* query property to the given value.
18593    pub fn page_size(mut self, new_value: i32) -> ManagedFolderListCall<'a, C> {
18594        self._page_size = Some(new_value);
18595        self
18596    }
18597    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18598    /// while executing the actual API request.
18599    ///
18600    /// ````text
18601    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18602    /// ````
18603    ///
18604    /// Sets the *delegate* property to the given value.
18605    pub fn delegate(
18606        mut self,
18607        new_value: &'a mut dyn common::Delegate,
18608    ) -> ManagedFolderListCall<'a, C> {
18609        self._delegate = Some(new_value);
18610        self
18611    }
18612
18613    /// Set any additional parameter of the query string used in the request.
18614    /// It should be used to set parameters which are not yet available through their own
18615    /// setters.
18616    ///
18617    /// Please note that this method must not be used to set any of the known parameters
18618    /// which have their own setter method. If done anyway, the request will fail.
18619    ///
18620    /// # Additional Parameters
18621    ///
18622    /// * *alt* (query-string) - Data format for the response.
18623    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18624    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18625    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18626    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18627    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18628    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
18629    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18630    pub fn param<T>(mut self, name: T, value: T) -> ManagedFolderListCall<'a, C>
18631    where
18632        T: AsRef<str>,
18633    {
18634        self._additional_params
18635            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18636        self
18637    }
18638
18639    /// Identifies the authorization scope for the method you are building.
18640    ///
18641    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18642    /// [`Scope::CloudPlatform`].
18643    ///
18644    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18645    /// tokens for more than one scope.
18646    ///
18647    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18648    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18649    /// sufficient, a read-write scope will do as well.
18650    pub fn add_scope<St>(mut self, scope: St) -> ManagedFolderListCall<'a, C>
18651    where
18652        St: AsRef<str>,
18653    {
18654        self._scopes.insert(String::from(scope.as_ref()));
18655        self
18656    }
18657    /// Identifies the authorization scope(s) for the method you are building.
18658    ///
18659    /// See [`Self::add_scope()`] for details.
18660    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedFolderListCall<'a, C>
18661    where
18662        I: IntoIterator<Item = St>,
18663        St: AsRef<str>,
18664    {
18665        self._scopes
18666            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18667        self
18668    }
18669
18670    /// Removes all scopes, and no default scope will be used either.
18671    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18672    /// for details).
18673    pub fn clear_scopes(mut self) -> ManagedFolderListCall<'a, C> {
18674        self._scopes.clear();
18675        self
18676    }
18677}
18678
18679/// Updates an IAM policy for the specified managed folder.
18680///
18681/// A builder for the *setIamPolicy* method supported by a *managedFolder* resource.
18682/// It is not used directly, but through a [`ManagedFolderMethods`] instance.
18683///
18684/// # Example
18685///
18686/// Instantiate a resource method builder
18687///
18688/// ```test_harness,no_run
18689/// # extern crate hyper;
18690/// # extern crate hyper_rustls;
18691/// # extern crate google_storage1 as storage1;
18692/// use storage1::api::Policy;
18693/// # async fn dox() {
18694/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18695///
18696/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18697/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18698/// #     secret,
18699/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18700/// # ).build().await.unwrap();
18701///
18702/// # let client = hyper_util::client::legacy::Client::builder(
18703/// #     hyper_util::rt::TokioExecutor::new()
18704/// # )
18705/// # .build(
18706/// #     hyper_rustls::HttpsConnectorBuilder::new()
18707/// #         .with_native_roots()
18708/// #         .unwrap()
18709/// #         .https_or_http()
18710/// #         .enable_http1()
18711/// #         .build()
18712/// # );
18713/// # let mut hub = Storage::new(client, auth);
18714/// // As the method needs a request, you would usually fill it with the desired information
18715/// // into the respective structure. Some of the parts shown here might not be applicable !
18716/// // Values shown here are possibly random and not representative !
18717/// let mut req = Policy::default();
18718///
18719/// // You can configure optional parameters by calling the respective setters at will, and
18720/// // execute the final call using `doit()`.
18721/// // Values shown here are possibly random and not representative !
18722/// let result = hub.managed_folders().set_iam_policy(req, "bucket", "managedFolder")
18723///              .user_project("no")
18724///              .doit().await;
18725/// # }
18726/// ```
18727pub struct ManagedFolderSetIamPolicyCall<'a, C>
18728where
18729    C: 'a,
18730{
18731    hub: &'a Storage<C>,
18732    _request: Policy,
18733    _bucket: String,
18734    _managed_folder: String,
18735    _user_project: Option<String>,
18736    _delegate: Option<&'a mut dyn common::Delegate>,
18737    _additional_params: HashMap<String, String>,
18738    _scopes: BTreeSet<String>,
18739}
18740
18741impl<'a, C> common::CallBuilder for ManagedFolderSetIamPolicyCall<'a, C> {}
18742
18743impl<'a, C> ManagedFolderSetIamPolicyCall<'a, C>
18744where
18745    C: common::Connector,
18746{
18747    /// Perform the operation you have build so far.
18748    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
18749        use std::borrow::Cow;
18750        use std::io::{Read, Seek};
18751
18752        use common::{url::Params, ToParts};
18753        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18754
18755        let mut dd = common::DefaultDelegate;
18756        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18757        dlg.begin(common::MethodInfo {
18758            id: "storage.managedFolders.setIamPolicy",
18759            http_method: hyper::Method::PUT,
18760        });
18761
18762        for &field in ["alt", "bucket", "managedFolder", "userProject"].iter() {
18763            if self._additional_params.contains_key(field) {
18764                dlg.finished(false);
18765                return Err(common::Error::FieldClash(field));
18766            }
18767        }
18768
18769        let mut params = Params::with_capacity(6 + self._additional_params.len());
18770        params.push("bucket", self._bucket);
18771        params.push("managedFolder", self._managed_folder);
18772        if let Some(value) = self._user_project.as_ref() {
18773            params.push("userProject", value);
18774        }
18775
18776        params.extend(self._additional_params.iter());
18777
18778        params.push("alt", "json");
18779        let mut url = self.hub._base_url.clone() + "b/{bucket}/managedFolders/{managedFolder}/iam";
18780        if self._scopes.is_empty() {
18781            self._scopes
18782                .insert(Scope::CloudPlatform.as_ref().to_string());
18783        }
18784
18785        #[allow(clippy::single_element_loop)]
18786        for &(find_this, param_name) in
18787            [("{bucket}", "bucket"), ("{managedFolder}", "managedFolder")].iter()
18788        {
18789            url = params.uri_replacement(url, param_name, find_this, false);
18790        }
18791        {
18792            let to_remove = ["managedFolder", "bucket"];
18793            params.remove_params(&to_remove);
18794        }
18795
18796        let url = params.parse_with_url(&url);
18797
18798        let mut json_mime_type = mime::APPLICATION_JSON;
18799        let mut request_value_reader = {
18800            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18801            common::remove_json_null_values(&mut value);
18802            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18803            serde_json::to_writer(&mut dst, &value).unwrap();
18804            dst
18805        };
18806        let request_size = request_value_reader
18807            .seek(std::io::SeekFrom::End(0))
18808            .unwrap();
18809        request_value_reader
18810            .seek(std::io::SeekFrom::Start(0))
18811            .unwrap();
18812
18813        loop {
18814            let token = match self
18815                .hub
18816                .auth
18817                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18818                .await
18819            {
18820                Ok(token) => token,
18821                Err(e) => match dlg.token(e) {
18822                    Ok(token) => token,
18823                    Err(e) => {
18824                        dlg.finished(false);
18825                        return Err(common::Error::MissingToken(e));
18826                    }
18827                },
18828            };
18829            request_value_reader
18830                .seek(std::io::SeekFrom::Start(0))
18831                .unwrap();
18832            let mut req_result = {
18833                let client = &self.hub.client;
18834                dlg.pre_request();
18835                let mut req_builder = hyper::Request::builder()
18836                    .method(hyper::Method::PUT)
18837                    .uri(url.as_str())
18838                    .header(USER_AGENT, self.hub._user_agent.clone());
18839
18840                if let Some(token) = token.as_ref() {
18841                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18842                }
18843
18844                let request = req_builder
18845                    .header(CONTENT_TYPE, json_mime_type.to_string())
18846                    .header(CONTENT_LENGTH, request_size as u64)
18847                    .body(common::to_body(
18848                        request_value_reader.get_ref().clone().into(),
18849                    ));
18850
18851                client.request(request.unwrap()).await
18852            };
18853
18854            match req_result {
18855                Err(err) => {
18856                    if let common::Retry::After(d) = dlg.http_error(&err) {
18857                        sleep(d).await;
18858                        continue;
18859                    }
18860                    dlg.finished(false);
18861                    return Err(common::Error::HttpError(err));
18862                }
18863                Ok(res) => {
18864                    let (mut parts, body) = res.into_parts();
18865                    let mut body = common::Body::new(body);
18866                    if !parts.status.is_success() {
18867                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18868                        let error = serde_json::from_str(&common::to_string(&bytes));
18869                        let response = common::to_response(parts, bytes.into());
18870
18871                        if let common::Retry::After(d) =
18872                            dlg.http_failure(&response, error.as_ref().ok())
18873                        {
18874                            sleep(d).await;
18875                            continue;
18876                        }
18877
18878                        dlg.finished(false);
18879
18880                        return Err(match error {
18881                            Ok(value) => common::Error::BadRequest(value),
18882                            _ => common::Error::Failure(response),
18883                        });
18884                    }
18885                    let response = {
18886                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18887                        let encoded = common::to_string(&bytes);
18888                        match serde_json::from_str(&encoded) {
18889                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18890                            Err(error) => {
18891                                dlg.response_json_decode_error(&encoded, &error);
18892                                return Err(common::Error::JsonDecodeError(
18893                                    encoded.to_string(),
18894                                    error,
18895                                ));
18896                            }
18897                        }
18898                    };
18899
18900                    dlg.finished(true);
18901                    return Ok(response);
18902                }
18903            }
18904        }
18905    }
18906
18907    ///
18908    /// Sets the *request* property to the given value.
18909    ///
18910    /// Even though the property as already been set when instantiating this call,
18911    /// we provide this method for API completeness.
18912    pub fn request(mut self, new_value: Policy) -> ManagedFolderSetIamPolicyCall<'a, C> {
18913        self._request = new_value;
18914        self
18915    }
18916    /// Name of the bucket containing the managed folder.
18917    ///
18918    /// Sets the *bucket* path property to the given value.
18919    ///
18920    /// Even though the property as already been set when instantiating this call,
18921    /// we provide this method for API completeness.
18922    pub fn bucket(mut self, new_value: &str) -> ManagedFolderSetIamPolicyCall<'a, C> {
18923        self._bucket = new_value.to_string();
18924        self
18925    }
18926    /// The managed folder name/path.
18927    ///
18928    /// Sets the *managed folder* path property to the given value.
18929    ///
18930    /// Even though the property as already been set when instantiating this call,
18931    /// we provide this method for API completeness.
18932    pub fn managed_folder(mut self, new_value: &str) -> ManagedFolderSetIamPolicyCall<'a, C> {
18933        self._managed_folder = new_value.to_string();
18934        self
18935    }
18936    /// The project to be billed for this request. Required for Requester Pays buckets.
18937    ///
18938    /// Sets the *user project* query property to the given value.
18939    pub fn user_project(mut self, new_value: &str) -> ManagedFolderSetIamPolicyCall<'a, C> {
18940        self._user_project = Some(new_value.to_string());
18941        self
18942    }
18943    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18944    /// while executing the actual API request.
18945    ///
18946    /// ````text
18947    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18948    /// ````
18949    ///
18950    /// Sets the *delegate* property to the given value.
18951    pub fn delegate(
18952        mut self,
18953        new_value: &'a mut dyn common::Delegate,
18954    ) -> ManagedFolderSetIamPolicyCall<'a, C> {
18955        self._delegate = Some(new_value);
18956        self
18957    }
18958
18959    /// Set any additional parameter of the query string used in the request.
18960    /// It should be used to set parameters which are not yet available through their own
18961    /// setters.
18962    ///
18963    /// Please note that this method must not be used to set any of the known parameters
18964    /// which have their own setter method. If done anyway, the request will fail.
18965    ///
18966    /// # Additional Parameters
18967    ///
18968    /// * *alt* (query-string) - Data format for the response.
18969    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18970    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18971    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18972    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18973    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18974    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
18975    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18976    pub fn param<T>(mut self, name: T, value: T) -> ManagedFolderSetIamPolicyCall<'a, C>
18977    where
18978        T: AsRef<str>,
18979    {
18980        self._additional_params
18981            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18982        self
18983    }
18984
18985    /// Identifies the authorization scope for the method you are building.
18986    ///
18987    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18988    /// [`Scope::CloudPlatform`].
18989    ///
18990    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18991    /// tokens for more than one scope.
18992    ///
18993    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18994    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18995    /// sufficient, a read-write scope will do as well.
18996    pub fn add_scope<St>(mut self, scope: St) -> ManagedFolderSetIamPolicyCall<'a, C>
18997    where
18998        St: AsRef<str>,
18999    {
19000        self._scopes.insert(String::from(scope.as_ref()));
19001        self
19002    }
19003    /// Identifies the authorization scope(s) for the method you are building.
19004    ///
19005    /// See [`Self::add_scope()`] for details.
19006    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedFolderSetIamPolicyCall<'a, C>
19007    where
19008        I: IntoIterator<Item = St>,
19009        St: AsRef<str>,
19010    {
19011        self._scopes
19012            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19013        self
19014    }
19015
19016    /// Removes all scopes, and no default scope will be used either.
19017    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19018    /// for details).
19019    pub fn clear_scopes(mut self) -> ManagedFolderSetIamPolicyCall<'a, C> {
19020        self._scopes.clear();
19021        self
19022    }
19023}
19024
19025/// Tests a set of permissions on the given managed folder to see which, if any, are held by the caller.
19026///
19027/// A builder for the *testIamPermissions* method supported by a *managedFolder* resource.
19028/// It is not used directly, but through a [`ManagedFolderMethods`] instance.
19029///
19030/// # Example
19031///
19032/// Instantiate a resource method builder
19033///
19034/// ```test_harness,no_run
19035/// # extern crate hyper;
19036/// # extern crate hyper_rustls;
19037/// # extern crate google_storage1 as storage1;
19038/// # async fn dox() {
19039/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19040///
19041/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19042/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19043/// #     secret,
19044/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19045/// # ).build().await.unwrap();
19046///
19047/// # let client = hyper_util::client::legacy::Client::builder(
19048/// #     hyper_util::rt::TokioExecutor::new()
19049/// # )
19050/// # .build(
19051/// #     hyper_rustls::HttpsConnectorBuilder::new()
19052/// #         .with_native_roots()
19053/// #         .unwrap()
19054/// #         .https_or_http()
19055/// #         .enable_http1()
19056/// #         .build()
19057/// # );
19058/// # let mut hub = Storage::new(client, auth);
19059/// // You can configure optional parameters by calling the respective setters at will, and
19060/// // execute the final call using `doit()`.
19061/// // Values shown here are possibly random and not representative !
19062/// let result = hub.managed_folders().test_iam_permissions("bucket", "managedFolder", &vec!["kasd".into()])
19063///              .user_project("Lorem")
19064///              .doit().await;
19065/// # }
19066/// ```
19067pub struct ManagedFolderTestIamPermissionCall<'a, C>
19068where
19069    C: 'a,
19070{
19071    hub: &'a Storage<C>,
19072    _bucket: String,
19073    _managed_folder: String,
19074    _permissions: Vec<String>,
19075    _user_project: Option<String>,
19076    _delegate: Option<&'a mut dyn common::Delegate>,
19077    _additional_params: HashMap<String, String>,
19078    _scopes: BTreeSet<String>,
19079}
19080
19081impl<'a, C> common::CallBuilder for ManagedFolderTestIamPermissionCall<'a, C> {}
19082
19083impl<'a, C> ManagedFolderTestIamPermissionCall<'a, C>
19084where
19085    C: common::Connector,
19086{
19087    /// Perform the operation you have build so far.
19088    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
19089        use std::borrow::Cow;
19090        use std::io::{Read, Seek};
19091
19092        use common::{url::Params, ToParts};
19093        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19094
19095        let mut dd = common::DefaultDelegate;
19096        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19097        dlg.begin(common::MethodInfo {
19098            id: "storage.managedFolders.testIamPermissions",
19099            http_method: hyper::Method::GET,
19100        });
19101
19102        for &field in [
19103            "alt",
19104            "bucket",
19105            "managedFolder",
19106            "permissions",
19107            "userProject",
19108        ]
19109        .iter()
19110        {
19111            if self._additional_params.contains_key(field) {
19112                dlg.finished(false);
19113                return Err(common::Error::FieldClash(field));
19114            }
19115        }
19116
19117        let mut params = Params::with_capacity(6 + self._additional_params.len());
19118        params.push("bucket", self._bucket);
19119        params.push("managedFolder", self._managed_folder);
19120        if !self._permissions.is_empty() {
19121            for f in self._permissions.iter() {
19122                params.push("permissions", f);
19123            }
19124        }
19125        if let Some(value) = self._user_project.as_ref() {
19126            params.push("userProject", value);
19127        }
19128
19129        params.extend(self._additional_params.iter());
19130
19131        params.push("alt", "json");
19132        let mut url = self.hub._base_url.clone()
19133            + "b/{bucket}/managedFolders/{managedFolder}/iam/testPermissions";
19134        if self._scopes.is_empty() {
19135            self._scopes
19136                .insert(Scope::CloudPlatform.as_ref().to_string());
19137        }
19138
19139        #[allow(clippy::single_element_loop)]
19140        for &(find_this, param_name) in
19141            [("{bucket}", "bucket"), ("{managedFolder}", "managedFolder")].iter()
19142        {
19143            url = params.uri_replacement(url, param_name, find_this, false);
19144        }
19145        {
19146            let to_remove = ["managedFolder", "bucket"];
19147            params.remove_params(&to_remove);
19148        }
19149
19150        let url = params.parse_with_url(&url);
19151
19152        loop {
19153            let token = match self
19154                .hub
19155                .auth
19156                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19157                .await
19158            {
19159                Ok(token) => token,
19160                Err(e) => match dlg.token(e) {
19161                    Ok(token) => token,
19162                    Err(e) => {
19163                        dlg.finished(false);
19164                        return Err(common::Error::MissingToken(e));
19165                    }
19166                },
19167            };
19168            let mut req_result = {
19169                let client = &self.hub.client;
19170                dlg.pre_request();
19171                let mut req_builder = hyper::Request::builder()
19172                    .method(hyper::Method::GET)
19173                    .uri(url.as_str())
19174                    .header(USER_AGENT, self.hub._user_agent.clone());
19175
19176                if let Some(token) = token.as_ref() {
19177                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19178                }
19179
19180                let request = req_builder
19181                    .header(CONTENT_LENGTH, 0_u64)
19182                    .body(common::to_body::<String>(None));
19183
19184                client.request(request.unwrap()).await
19185            };
19186
19187            match req_result {
19188                Err(err) => {
19189                    if let common::Retry::After(d) = dlg.http_error(&err) {
19190                        sleep(d).await;
19191                        continue;
19192                    }
19193                    dlg.finished(false);
19194                    return Err(common::Error::HttpError(err));
19195                }
19196                Ok(res) => {
19197                    let (mut parts, body) = res.into_parts();
19198                    let mut body = common::Body::new(body);
19199                    if !parts.status.is_success() {
19200                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19201                        let error = serde_json::from_str(&common::to_string(&bytes));
19202                        let response = common::to_response(parts, bytes.into());
19203
19204                        if let common::Retry::After(d) =
19205                            dlg.http_failure(&response, error.as_ref().ok())
19206                        {
19207                            sleep(d).await;
19208                            continue;
19209                        }
19210
19211                        dlg.finished(false);
19212
19213                        return Err(match error {
19214                            Ok(value) => common::Error::BadRequest(value),
19215                            _ => common::Error::Failure(response),
19216                        });
19217                    }
19218                    let response = {
19219                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19220                        let encoded = common::to_string(&bytes);
19221                        match serde_json::from_str(&encoded) {
19222                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19223                            Err(error) => {
19224                                dlg.response_json_decode_error(&encoded, &error);
19225                                return Err(common::Error::JsonDecodeError(
19226                                    encoded.to_string(),
19227                                    error,
19228                                ));
19229                            }
19230                        }
19231                    };
19232
19233                    dlg.finished(true);
19234                    return Ok(response);
19235                }
19236            }
19237        }
19238    }
19239
19240    /// Name of the bucket containing the managed folder.
19241    ///
19242    /// Sets the *bucket* path property to the given value.
19243    ///
19244    /// Even though the property as already been set when instantiating this call,
19245    /// we provide this method for API completeness.
19246    pub fn bucket(mut self, new_value: &str) -> ManagedFolderTestIamPermissionCall<'a, C> {
19247        self._bucket = new_value.to_string();
19248        self
19249    }
19250    /// The managed folder name/path.
19251    ///
19252    /// Sets the *managed folder* path property to the given value.
19253    ///
19254    /// Even though the property as already been set when instantiating this call,
19255    /// we provide this method for API completeness.
19256    pub fn managed_folder(mut self, new_value: &str) -> ManagedFolderTestIamPermissionCall<'a, C> {
19257        self._managed_folder = new_value.to_string();
19258        self
19259    }
19260    /// Permissions to test.
19261    ///
19262    /// Append the given value to the *permissions* query property.
19263    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
19264    ///
19265    /// Even though the property as already been set when instantiating this call,
19266    /// we provide this method for API completeness.
19267    pub fn add_permissions(mut self, new_value: &str) -> ManagedFolderTestIamPermissionCall<'a, C> {
19268        self._permissions.push(new_value.to_string());
19269        self
19270    }
19271    /// The project to be billed for this request. Required for Requester Pays buckets.
19272    ///
19273    /// Sets the *user project* query property to the given value.
19274    pub fn user_project(mut self, new_value: &str) -> ManagedFolderTestIamPermissionCall<'a, C> {
19275        self._user_project = Some(new_value.to_string());
19276        self
19277    }
19278    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19279    /// while executing the actual API request.
19280    ///
19281    /// ````text
19282    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19283    /// ````
19284    ///
19285    /// Sets the *delegate* property to the given value.
19286    pub fn delegate(
19287        mut self,
19288        new_value: &'a mut dyn common::Delegate,
19289    ) -> ManagedFolderTestIamPermissionCall<'a, C> {
19290        self._delegate = Some(new_value);
19291        self
19292    }
19293
19294    /// Set any additional parameter of the query string used in the request.
19295    /// It should be used to set parameters which are not yet available through their own
19296    /// setters.
19297    ///
19298    /// Please note that this method must not be used to set any of the known parameters
19299    /// which have their own setter method. If done anyway, the request will fail.
19300    ///
19301    /// # Additional Parameters
19302    ///
19303    /// * *alt* (query-string) - Data format for the response.
19304    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19305    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
19306    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19307    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19308    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19309    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
19310    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
19311    pub fn param<T>(mut self, name: T, value: T) -> ManagedFolderTestIamPermissionCall<'a, C>
19312    where
19313        T: AsRef<str>,
19314    {
19315        self._additional_params
19316            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19317        self
19318    }
19319
19320    /// Identifies the authorization scope for the method you are building.
19321    ///
19322    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19323    /// [`Scope::CloudPlatform`].
19324    ///
19325    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19326    /// tokens for more than one scope.
19327    ///
19328    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19329    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19330    /// sufficient, a read-write scope will do as well.
19331    pub fn add_scope<St>(mut self, scope: St) -> ManagedFolderTestIamPermissionCall<'a, C>
19332    where
19333        St: AsRef<str>,
19334    {
19335        self._scopes.insert(String::from(scope.as_ref()));
19336        self
19337    }
19338    /// Identifies the authorization scope(s) for the method you are building.
19339    ///
19340    /// See [`Self::add_scope()`] for details.
19341    pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedFolderTestIamPermissionCall<'a, C>
19342    where
19343        I: IntoIterator<Item = St>,
19344        St: AsRef<str>,
19345    {
19346        self._scopes
19347            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19348        self
19349    }
19350
19351    /// Removes all scopes, and no default scope will be used either.
19352    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19353    /// for details).
19354    pub fn clear_scopes(mut self) -> ManagedFolderTestIamPermissionCall<'a, C> {
19355        self._scopes.clear();
19356        self
19357    }
19358}
19359
19360/// Permanently deletes a notification subscription.
19361///
19362/// A builder for the *delete* method supported by a *notification* resource.
19363/// It is not used directly, but through a [`NotificationMethods`] instance.
19364///
19365/// # Example
19366///
19367/// Instantiate a resource method builder
19368///
19369/// ```test_harness,no_run
19370/// # extern crate hyper;
19371/// # extern crate hyper_rustls;
19372/// # extern crate google_storage1 as storage1;
19373/// # async fn dox() {
19374/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19375///
19376/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19377/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19378/// #     secret,
19379/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19380/// # ).build().await.unwrap();
19381///
19382/// # let client = hyper_util::client::legacy::Client::builder(
19383/// #     hyper_util::rt::TokioExecutor::new()
19384/// # )
19385/// # .build(
19386/// #     hyper_rustls::HttpsConnectorBuilder::new()
19387/// #         .with_native_roots()
19388/// #         .unwrap()
19389/// #         .https_or_http()
19390/// #         .enable_http1()
19391/// #         .build()
19392/// # );
19393/// # let mut hub = Storage::new(client, auth);
19394/// // You can configure optional parameters by calling the respective setters at will, and
19395/// // execute the final call using `doit()`.
19396/// // Values shown here are possibly random and not representative !
19397/// let result = hub.notifications().delete("bucket", "notification")
19398///              .user_project("rebum.")
19399///              .doit().await;
19400/// # }
19401/// ```
19402pub struct NotificationDeleteCall<'a, C>
19403where
19404    C: 'a,
19405{
19406    hub: &'a Storage<C>,
19407    _bucket: String,
19408    _notification: String,
19409    _user_project: Option<String>,
19410    _delegate: Option<&'a mut dyn common::Delegate>,
19411    _additional_params: HashMap<String, String>,
19412    _scopes: BTreeSet<String>,
19413}
19414
19415impl<'a, C> common::CallBuilder for NotificationDeleteCall<'a, C> {}
19416
19417impl<'a, C> NotificationDeleteCall<'a, C>
19418where
19419    C: common::Connector,
19420{
19421    /// Perform the operation you have build so far.
19422    pub async fn doit(mut self) -> common::Result<common::Response> {
19423        use std::borrow::Cow;
19424        use std::io::{Read, Seek};
19425
19426        use common::{url::Params, ToParts};
19427        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19428
19429        let mut dd = common::DefaultDelegate;
19430        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19431        dlg.begin(common::MethodInfo {
19432            id: "storage.notifications.delete",
19433            http_method: hyper::Method::DELETE,
19434        });
19435
19436        for &field in ["bucket", "notification", "userProject"].iter() {
19437            if self._additional_params.contains_key(field) {
19438                dlg.finished(false);
19439                return Err(common::Error::FieldClash(field));
19440            }
19441        }
19442
19443        let mut params = Params::with_capacity(4 + self._additional_params.len());
19444        params.push("bucket", self._bucket);
19445        params.push("notification", self._notification);
19446        if let Some(value) = self._user_project.as_ref() {
19447            params.push("userProject", value);
19448        }
19449
19450        params.extend(self._additional_params.iter());
19451
19452        let mut url = self.hub._base_url.clone() + "b/{bucket}/notificationConfigs/{notification}";
19453        if self._scopes.is_empty() {
19454            self._scopes
19455                .insert(Scope::CloudPlatform.as_ref().to_string());
19456        }
19457
19458        #[allow(clippy::single_element_loop)]
19459        for &(find_this, param_name) in
19460            [("{bucket}", "bucket"), ("{notification}", "notification")].iter()
19461        {
19462            url = params.uri_replacement(url, param_name, find_this, false);
19463        }
19464        {
19465            let to_remove = ["notification", "bucket"];
19466            params.remove_params(&to_remove);
19467        }
19468
19469        let url = params.parse_with_url(&url);
19470
19471        loop {
19472            let token = match self
19473                .hub
19474                .auth
19475                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19476                .await
19477            {
19478                Ok(token) => token,
19479                Err(e) => match dlg.token(e) {
19480                    Ok(token) => token,
19481                    Err(e) => {
19482                        dlg.finished(false);
19483                        return Err(common::Error::MissingToken(e));
19484                    }
19485                },
19486            };
19487            let mut req_result = {
19488                let client = &self.hub.client;
19489                dlg.pre_request();
19490                let mut req_builder = hyper::Request::builder()
19491                    .method(hyper::Method::DELETE)
19492                    .uri(url.as_str())
19493                    .header(USER_AGENT, self.hub._user_agent.clone());
19494
19495                if let Some(token) = token.as_ref() {
19496                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19497                }
19498
19499                let request = req_builder
19500                    .header(CONTENT_LENGTH, 0_u64)
19501                    .body(common::to_body::<String>(None));
19502
19503                client.request(request.unwrap()).await
19504            };
19505
19506            match req_result {
19507                Err(err) => {
19508                    if let common::Retry::After(d) = dlg.http_error(&err) {
19509                        sleep(d).await;
19510                        continue;
19511                    }
19512                    dlg.finished(false);
19513                    return Err(common::Error::HttpError(err));
19514                }
19515                Ok(res) => {
19516                    let (mut parts, body) = res.into_parts();
19517                    let mut body = common::Body::new(body);
19518                    if !parts.status.is_success() {
19519                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19520                        let error = serde_json::from_str(&common::to_string(&bytes));
19521                        let response = common::to_response(parts, bytes.into());
19522
19523                        if let common::Retry::After(d) =
19524                            dlg.http_failure(&response, error.as_ref().ok())
19525                        {
19526                            sleep(d).await;
19527                            continue;
19528                        }
19529
19530                        dlg.finished(false);
19531
19532                        return Err(match error {
19533                            Ok(value) => common::Error::BadRequest(value),
19534                            _ => common::Error::Failure(response),
19535                        });
19536                    }
19537                    let response = common::Response::from_parts(parts, body);
19538
19539                    dlg.finished(true);
19540                    return Ok(response);
19541                }
19542            }
19543        }
19544    }
19545
19546    /// The parent bucket of the notification.
19547    ///
19548    /// Sets the *bucket* path property to the given value.
19549    ///
19550    /// Even though the property as already been set when instantiating this call,
19551    /// we provide this method for API completeness.
19552    pub fn bucket(mut self, new_value: &str) -> NotificationDeleteCall<'a, C> {
19553        self._bucket = new_value.to_string();
19554        self
19555    }
19556    /// ID of the notification to delete.
19557    ///
19558    /// Sets the *notification* path property to the given value.
19559    ///
19560    /// Even though the property as already been set when instantiating this call,
19561    /// we provide this method for API completeness.
19562    pub fn notification(mut self, new_value: &str) -> NotificationDeleteCall<'a, C> {
19563        self._notification = new_value.to_string();
19564        self
19565    }
19566    /// The project to be billed for this request. Required for Requester Pays buckets.
19567    ///
19568    /// Sets the *user project* query property to the given value.
19569    pub fn user_project(mut self, new_value: &str) -> NotificationDeleteCall<'a, C> {
19570        self._user_project = Some(new_value.to_string());
19571        self
19572    }
19573    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19574    /// while executing the actual API request.
19575    ///
19576    /// ````text
19577    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19578    /// ````
19579    ///
19580    /// Sets the *delegate* property to the given value.
19581    pub fn delegate(
19582        mut self,
19583        new_value: &'a mut dyn common::Delegate,
19584    ) -> NotificationDeleteCall<'a, C> {
19585        self._delegate = Some(new_value);
19586        self
19587    }
19588
19589    /// Set any additional parameter of the query string used in the request.
19590    /// It should be used to set parameters which are not yet available through their own
19591    /// setters.
19592    ///
19593    /// Please note that this method must not be used to set any of the known parameters
19594    /// which have their own setter method. If done anyway, the request will fail.
19595    ///
19596    /// # Additional Parameters
19597    ///
19598    /// * *alt* (query-string) - Data format for the response.
19599    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19600    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
19601    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19602    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19603    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19604    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
19605    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
19606    pub fn param<T>(mut self, name: T, value: T) -> NotificationDeleteCall<'a, C>
19607    where
19608        T: AsRef<str>,
19609    {
19610        self._additional_params
19611            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19612        self
19613    }
19614
19615    /// Identifies the authorization scope for the method you are building.
19616    ///
19617    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19618    /// [`Scope::CloudPlatform`].
19619    ///
19620    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19621    /// tokens for more than one scope.
19622    ///
19623    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19624    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19625    /// sufficient, a read-write scope will do as well.
19626    pub fn add_scope<St>(mut self, scope: St) -> NotificationDeleteCall<'a, C>
19627    where
19628        St: AsRef<str>,
19629    {
19630        self._scopes.insert(String::from(scope.as_ref()));
19631        self
19632    }
19633    /// Identifies the authorization scope(s) for the method you are building.
19634    ///
19635    /// See [`Self::add_scope()`] for details.
19636    pub fn add_scopes<I, St>(mut self, scopes: I) -> NotificationDeleteCall<'a, C>
19637    where
19638        I: IntoIterator<Item = St>,
19639        St: AsRef<str>,
19640    {
19641        self._scopes
19642            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19643        self
19644    }
19645
19646    /// Removes all scopes, and no default scope will be used either.
19647    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19648    /// for details).
19649    pub fn clear_scopes(mut self) -> NotificationDeleteCall<'a, C> {
19650        self._scopes.clear();
19651        self
19652    }
19653}
19654
19655/// View a notification configuration.
19656///
19657/// A builder for the *get* method supported by a *notification* resource.
19658/// It is not used directly, but through a [`NotificationMethods`] instance.
19659///
19660/// # Example
19661///
19662/// Instantiate a resource method builder
19663///
19664/// ```test_harness,no_run
19665/// # extern crate hyper;
19666/// # extern crate hyper_rustls;
19667/// # extern crate google_storage1 as storage1;
19668/// # async fn dox() {
19669/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19670///
19671/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19672/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19673/// #     secret,
19674/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19675/// # ).build().await.unwrap();
19676///
19677/// # let client = hyper_util::client::legacy::Client::builder(
19678/// #     hyper_util::rt::TokioExecutor::new()
19679/// # )
19680/// # .build(
19681/// #     hyper_rustls::HttpsConnectorBuilder::new()
19682/// #         .with_native_roots()
19683/// #         .unwrap()
19684/// #         .https_or_http()
19685/// #         .enable_http1()
19686/// #         .build()
19687/// # );
19688/// # let mut hub = Storage::new(client, auth);
19689/// // You can configure optional parameters by calling the respective setters at will, and
19690/// // execute the final call using `doit()`.
19691/// // Values shown here are possibly random and not representative !
19692/// let result = hub.notifications().get("bucket", "notification")
19693///              .user_project("eos")
19694///              .doit().await;
19695/// # }
19696/// ```
19697pub struct NotificationGetCall<'a, C>
19698where
19699    C: 'a,
19700{
19701    hub: &'a Storage<C>,
19702    _bucket: String,
19703    _notification: String,
19704    _user_project: Option<String>,
19705    _delegate: Option<&'a mut dyn common::Delegate>,
19706    _additional_params: HashMap<String, String>,
19707    _scopes: BTreeSet<String>,
19708}
19709
19710impl<'a, C> common::CallBuilder for NotificationGetCall<'a, C> {}
19711
19712impl<'a, C> NotificationGetCall<'a, C>
19713where
19714    C: common::Connector,
19715{
19716    /// Perform the operation you have build so far.
19717    pub async fn doit(mut self) -> common::Result<(common::Response, Notification)> {
19718        use std::borrow::Cow;
19719        use std::io::{Read, Seek};
19720
19721        use common::{url::Params, ToParts};
19722        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19723
19724        let mut dd = common::DefaultDelegate;
19725        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19726        dlg.begin(common::MethodInfo {
19727            id: "storage.notifications.get",
19728            http_method: hyper::Method::GET,
19729        });
19730
19731        for &field in ["alt", "bucket", "notification", "userProject"].iter() {
19732            if self._additional_params.contains_key(field) {
19733                dlg.finished(false);
19734                return Err(common::Error::FieldClash(field));
19735            }
19736        }
19737
19738        let mut params = Params::with_capacity(5 + self._additional_params.len());
19739        params.push("bucket", self._bucket);
19740        params.push("notification", self._notification);
19741        if let Some(value) = self._user_project.as_ref() {
19742            params.push("userProject", value);
19743        }
19744
19745        params.extend(self._additional_params.iter());
19746
19747        params.push("alt", "json");
19748        let mut url = self.hub._base_url.clone() + "b/{bucket}/notificationConfigs/{notification}";
19749        if self._scopes.is_empty() {
19750            self._scopes
19751                .insert(Scope::CloudPlatform.as_ref().to_string());
19752        }
19753
19754        #[allow(clippy::single_element_loop)]
19755        for &(find_this, param_name) in
19756            [("{bucket}", "bucket"), ("{notification}", "notification")].iter()
19757        {
19758            url = params.uri_replacement(url, param_name, find_this, false);
19759        }
19760        {
19761            let to_remove = ["notification", "bucket"];
19762            params.remove_params(&to_remove);
19763        }
19764
19765        let url = params.parse_with_url(&url);
19766
19767        loop {
19768            let token = match self
19769                .hub
19770                .auth
19771                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19772                .await
19773            {
19774                Ok(token) => token,
19775                Err(e) => match dlg.token(e) {
19776                    Ok(token) => token,
19777                    Err(e) => {
19778                        dlg.finished(false);
19779                        return Err(common::Error::MissingToken(e));
19780                    }
19781                },
19782            };
19783            let mut req_result = {
19784                let client = &self.hub.client;
19785                dlg.pre_request();
19786                let mut req_builder = hyper::Request::builder()
19787                    .method(hyper::Method::GET)
19788                    .uri(url.as_str())
19789                    .header(USER_AGENT, self.hub._user_agent.clone());
19790
19791                if let Some(token) = token.as_ref() {
19792                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19793                }
19794
19795                let request = req_builder
19796                    .header(CONTENT_LENGTH, 0_u64)
19797                    .body(common::to_body::<String>(None));
19798
19799                client.request(request.unwrap()).await
19800            };
19801
19802            match req_result {
19803                Err(err) => {
19804                    if let common::Retry::After(d) = dlg.http_error(&err) {
19805                        sleep(d).await;
19806                        continue;
19807                    }
19808                    dlg.finished(false);
19809                    return Err(common::Error::HttpError(err));
19810                }
19811                Ok(res) => {
19812                    let (mut parts, body) = res.into_parts();
19813                    let mut body = common::Body::new(body);
19814                    if !parts.status.is_success() {
19815                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19816                        let error = serde_json::from_str(&common::to_string(&bytes));
19817                        let response = common::to_response(parts, bytes.into());
19818
19819                        if let common::Retry::After(d) =
19820                            dlg.http_failure(&response, error.as_ref().ok())
19821                        {
19822                            sleep(d).await;
19823                            continue;
19824                        }
19825
19826                        dlg.finished(false);
19827
19828                        return Err(match error {
19829                            Ok(value) => common::Error::BadRequest(value),
19830                            _ => common::Error::Failure(response),
19831                        });
19832                    }
19833                    let response = {
19834                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19835                        let encoded = common::to_string(&bytes);
19836                        match serde_json::from_str(&encoded) {
19837                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19838                            Err(error) => {
19839                                dlg.response_json_decode_error(&encoded, &error);
19840                                return Err(common::Error::JsonDecodeError(
19841                                    encoded.to_string(),
19842                                    error,
19843                                ));
19844                            }
19845                        }
19846                    };
19847
19848                    dlg.finished(true);
19849                    return Ok(response);
19850                }
19851            }
19852        }
19853    }
19854
19855    /// The parent bucket of the notification.
19856    ///
19857    /// Sets the *bucket* path property to the given value.
19858    ///
19859    /// Even though the property as already been set when instantiating this call,
19860    /// we provide this method for API completeness.
19861    pub fn bucket(mut self, new_value: &str) -> NotificationGetCall<'a, C> {
19862        self._bucket = new_value.to_string();
19863        self
19864    }
19865    /// Notification ID
19866    ///
19867    /// Sets the *notification* path property to the given value.
19868    ///
19869    /// Even though the property as already been set when instantiating this call,
19870    /// we provide this method for API completeness.
19871    pub fn notification(mut self, new_value: &str) -> NotificationGetCall<'a, C> {
19872        self._notification = new_value.to_string();
19873        self
19874    }
19875    /// The project to be billed for this request. Required for Requester Pays buckets.
19876    ///
19877    /// Sets the *user project* query property to the given value.
19878    pub fn user_project(mut self, new_value: &str) -> NotificationGetCall<'a, C> {
19879        self._user_project = Some(new_value.to_string());
19880        self
19881    }
19882    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19883    /// while executing the actual API request.
19884    ///
19885    /// ````text
19886    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19887    /// ````
19888    ///
19889    /// Sets the *delegate* property to the given value.
19890    pub fn delegate(
19891        mut self,
19892        new_value: &'a mut dyn common::Delegate,
19893    ) -> NotificationGetCall<'a, C> {
19894        self._delegate = Some(new_value);
19895        self
19896    }
19897
19898    /// Set any additional parameter of the query string used in the request.
19899    /// It should be used to set parameters which are not yet available through their own
19900    /// setters.
19901    ///
19902    /// Please note that this method must not be used to set any of the known parameters
19903    /// which have their own setter method. If done anyway, the request will fail.
19904    ///
19905    /// # Additional Parameters
19906    ///
19907    /// * *alt* (query-string) - Data format for the response.
19908    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19909    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
19910    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19911    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19912    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19913    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
19914    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
19915    pub fn param<T>(mut self, name: T, value: T) -> NotificationGetCall<'a, C>
19916    where
19917        T: AsRef<str>,
19918    {
19919        self._additional_params
19920            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19921        self
19922    }
19923
19924    /// Identifies the authorization scope for the method you are building.
19925    ///
19926    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19927    /// [`Scope::CloudPlatform`].
19928    ///
19929    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19930    /// tokens for more than one scope.
19931    ///
19932    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19933    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19934    /// sufficient, a read-write scope will do as well.
19935    pub fn add_scope<St>(mut self, scope: St) -> NotificationGetCall<'a, C>
19936    where
19937        St: AsRef<str>,
19938    {
19939        self._scopes.insert(String::from(scope.as_ref()));
19940        self
19941    }
19942    /// Identifies the authorization scope(s) for the method you are building.
19943    ///
19944    /// See [`Self::add_scope()`] for details.
19945    pub fn add_scopes<I, St>(mut self, scopes: I) -> NotificationGetCall<'a, C>
19946    where
19947        I: IntoIterator<Item = St>,
19948        St: AsRef<str>,
19949    {
19950        self._scopes
19951            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19952        self
19953    }
19954
19955    /// Removes all scopes, and no default scope will be used either.
19956    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19957    /// for details).
19958    pub fn clear_scopes(mut self) -> NotificationGetCall<'a, C> {
19959        self._scopes.clear();
19960        self
19961    }
19962}
19963
19964/// Creates a notification subscription for a given bucket.
19965///
19966/// A builder for the *insert* method supported by a *notification* resource.
19967/// It is not used directly, but through a [`NotificationMethods`] instance.
19968///
19969/// # Example
19970///
19971/// Instantiate a resource method builder
19972///
19973/// ```test_harness,no_run
19974/// # extern crate hyper;
19975/// # extern crate hyper_rustls;
19976/// # extern crate google_storage1 as storage1;
19977/// use storage1::api::Notification;
19978/// # async fn dox() {
19979/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19980///
19981/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19982/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19983/// #     secret,
19984/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19985/// # ).build().await.unwrap();
19986///
19987/// # let client = hyper_util::client::legacy::Client::builder(
19988/// #     hyper_util::rt::TokioExecutor::new()
19989/// # )
19990/// # .build(
19991/// #     hyper_rustls::HttpsConnectorBuilder::new()
19992/// #         .with_native_roots()
19993/// #         .unwrap()
19994/// #         .https_or_http()
19995/// #         .enable_http1()
19996/// #         .build()
19997/// # );
19998/// # let mut hub = Storage::new(client, auth);
19999/// // As the method needs a request, you would usually fill it with the desired information
20000/// // into the respective structure. Some of the parts shown here might not be applicable !
20001/// // Values shown here are possibly random and not representative !
20002/// let mut req = Notification::default();
20003///
20004/// // You can configure optional parameters by calling the respective setters at will, and
20005/// // execute the final call using `doit()`.
20006/// // Values shown here are possibly random and not representative !
20007/// let result = hub.notifications().insert(req, "bucket")
20008///              .user_project("dolore")
20009///              .doit().await;
20010/// # }
20011/// ```
20012pub struct NotificationInsertCall<'a, C>
20013where
20014    C: 'a,
20015{
20016    hub: &'a Storage<C>,
20017    _request: Notification,
20018    _bucket: String,
20019    _user_project: Option<String>,
20020    _delegate: Option<&'a mut dyn common::Delegate>,
20021    _additional_params: HashMap<String, String>,
20022    _scopes: BTreeSet<String>,
20023}
20024
20025impl<'a, C> common::CallBuilder for NotificationInsertCall<'a, C> {}
20026
20027impl<'a, C> NotificationInsertCall<'a, C>
20028where
20029    C: common::Connector,
20030{
20031    /// Perform the operation you have build so far.
20032    pub async fn doit(mut self) -> common::Result<(common::Response, Notification)> {
20033        use std::borrow::Cow;
20034        use std::io::{Read, Seek};
20035
20036        use common::{url::Params, ToParts};
20037        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20038
20039        let mut dd = common::DefaultDelegate;
20040        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20041        dlg.begin(common::MethodInfo {
20042            id: "storage.notifications.insert",
20043            http_method: hyper::Method::POST,
20044        });
20045
20046        for &field in ["alt", "bucket", "userProject"].iter() {
20047            if self._additional_params.contains_key(field) {
20048                dlg.finished(false);
20049                return Err(common::Error::FieldClash(field));
20050            }
20051        }
20052
20053        let mut params = Params::with_capacity(5 + self._additional_params.len());
20054        params.push("bucket", self._bucket);
20055        if let Some(value) = self._user_project.as_ref() {
20056            params.push("userProject", value);
20057        }
20058
20059        params.extend(self._additional_params.iter());
20060
20061        params.push("alt", "json");
20062        let mut url = self.hub._base_url.clone() + "b/{bucket}/notificationConfigs";
20063        if self._scopes.is_empty() {
20064            self._scopes
20065                .insert(Scope::CloudPlatform.as_ref().to_string());
20066        }
20067
20068        #[allow(clippy::single_element_loop)]
20069        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
20070            url = params.uri_replacement(url, param_name, find_this, false);
20071        }
20072        {
20073            let to_remove = ["bucket"];
20074            params.remove_params(&to_remove);
20075        }
20076
20077        let url = params.parse_with_url(&url);
20078
20079        let mut json_mime_type = mime::APPLICATION_JSON;
20080        let mut request_value_reader = {
20081            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20082            common::remove_json_null_values(&mut value);
20083            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20084            serde_json::to_writer(&mut dst, &value).unwrap();
20085            dst
20086        };
20087        let request_size = request_value_reader
20088            .seek(std::io::SeekFrom::End(0))
20089            .unwrap();
20090        request_value_reader
20091            .seek(std::io::SeekFrom::Start(0))
20092            .unwrap();
20093
20094        loop {
20095            let token = match self
20096                .hub
20097                .auth
20098                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20099                .await
20100            {
20101                Ok(token) => token,
20102                Err(e) => match dlg.token(e) {
20103                    Ok(token) => token,
20104                    Err(e) => {
20105                        dlg.finished(false);
20106                        return Err(common::Error::MissingToken(e));
20107                    }
20108                },
20109            };
20110            request_value_reader
20111                .seek(std::io::SeekFrom::Start(0))
20112                .unwrap();
20113            let mut req_result = {
20114                let client = &self.hub.client;
20115                dlg.pre_request();
20116                let mut req_builder = hyper::Request::builder()
20117                    .method(hyper::Method::POST)
20118                    .uri(url.as_str())
20119                    .header(USER_AGENT, self.hub._user_agent.clone());
20120
20121                if let Some(token) = token.as_ref() {
20122                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20123                }
20124
20125                let request = req_builder
20126                    .header(CONTENT_TYPE, json_mime_type.to_string())
20127                    .header(CONTENT_LENGTH, request_size as u64)
20128                    .body(common::to_body(
20129                        request_value_reader.get_ref().clone().into(),
20130                    ));
20131
20132                client.request(request.unwrap()).await
20133            };
20134
20135            match req_result {
20136                Err(err) => {
20137                    if let common::Retry::After(d) = dlg.http_error(&err) {
20138                        sleep(d).await;
20139                        continue;
20140                    }
20141                    dlg.finished(false);
20142                    return Err(common::Error::HttpError(err));
20143                }
20144                Ok(res) => {
20145                    let (mut parts, body) = res.into_parts();
20146                    let mut body = common::Body::new(body);
20147                    if !parts.status.is_success() {
20148                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20149                        let error = serde_json::from_str(&common::to_string(&bytes));
20150                        let response = common::to_response(parts, bytes.into());
20151
20152                        if let common::Retry::After(d) =
20153                            dlg.http_failure(&response, error.as_ref().ok())
20154                        {
20155                            sleep(d).await;
20156                            continue;
20157                        }
20158
20159                        dlg.finished(false);
20160
20161                        return Err(match error {
20162                            Ok(value) => common::Error::BadRequest(value),
20163                            _ => common::Error::Failure(response),
20164                        });
20165                    }
20166                    let response = {
20167                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20168                        let encoded = common::to_string(&bytes);
20169                        match serde_json::from_str(&encoded) {
20170                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20171                            Err(error) => {
20172                                dlg.response_json_decode_error(&encoded, &error);
20173                                return Err(common::Error::JsonDecodeError(
20174                                    encoded.to_string(),
20175                                    error,
20176                                ));
20177                            }
20178                        }
20179                    };
20180
20181                    dlg.finished(true);
20182                    return Ok(response);
20183                }
20184            }
20185        }
20186    }
20187
20188    ///
20189    /// Sets the *request* property to the given value.
20190    ///
20191    /// Even though the property as already been set when instantiating this call,
20192    /// we provide this method for API completeness.
20193    pub fn request(mut self, new_value: Notification) -> NotificationInsertCall<'a, C> {
20194        self._request = new_value;
20195        self
20196    }
20197    /// The parent bucket of the notification.
20198    ///
20199    /// Sets the *bucket* path property to the given value.
20200    ///
20201    /// Even though the property as already been set when instantiating this call,
20202    /// we provide this method for API completeness.
20203    pub fn bucket(mut self, new_value: &str) -> NotificationInsertCall<'a, C> {
20204        self._bucket = new_value.to_string();
20205        self
20206    }
20207    /// The project to be billed for this request. Required for Requester Pays buckets.
20208    ///
20209    /// Sets the *user project* query property to the given value.
20210    pub fn user_project(mut self, new_value: &str) -> NotificationInsertCall<'a, C> {
20211        self._user_project = Some(new_value.to_string());
20212        self
20213    }
20214    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20215    /// while executing the actual API request.
20216    ///
20217    /// ````text
20218    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20219    /// ````
20220    ///
20221    /// Sets the *delegate* property to the given value.
20222    pub fn delegate(
20223        mut self,
20224        new_value: &'a mut dyn common::Delegate,
20225    ) -> NotificationInsertCall<'a, C> {
20226        self._delegate = Some(new_value);
20227        self
20228    }
20229
20230    /// Set any additional parameter of the query string used in the request.
20231    /// It should be used to set parameters which are not yet available through their own
20232    /// setters.
20233    ///
20234    /// Please note that this method must not be used to set any of the known parameters
20235    /// which have their own setter method. If done anyway, the request will fail.
20236    ///
20237    /// # Additional Parameters
20238    ///
20239    /// * *alt* (query-string) - Data format for the response.
20240    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20241    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
20242    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20243    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20244    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
20245    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
20246    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
20247    pub fn param<T>(mut self, name: T, value: T) -> NotificationInsertCall<'a, C>
20248    where
20249        T: AsRef<str>,
20250    {
20251        self._additional_params
20252            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20253        self
20254    }
20255
20256    /// Identifies the authorization scope for the method you are building.
20257    ///
20258    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20259    /// [`Scope::CloudPlatform`].
20260    ///
20261    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20262    /// tokens for more than one scope.
20263    ///
20264    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20265    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20266    /// sufficient, a read-write scope will do as well.
20267    pub fn add_scope<St>(mut self, scope: St) -> NotificationInsertCall<'a, C>
20268    where
20269        St: AsRef<str>,
20270    {
20271        self._scopes.insert(String::from(scope.as_ref()));
20272        self
20273    }
20274    /// Identifies the authorization scope(s) for the method you are building.
20275    ///
20276    /// See [`Self::add_scope()`] for details.
20277    pub fn add_scopes<I, St>(mut self, scopes: I) -> NotificationInsertCall<'a, C>
20278    where
20279        I: IntoIterator<Item = St>,
20280        St: AsRef<str>,
20281    {
20282        self._scopes
20283            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20284        self
20285    }
20286
20287    /// Removes all scopes, and no default scope will be used either.
20288    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20289    /// for details).
20290    pub fn clear_scopes(mut self) -> NotificationInsertCall<'a, C> {
20291        self._scopes.clear();
20292        self
20293    }
20294}
20295
20296/// Retrieves a list of notification subscriptions for a given bucket.
20297///
20298/// A builder for the *list* method supported by a *notification* resource.
20299/// It is not used directly, but through a [`NotificationMethods`] instance.
20300///
20301/// # Example
20302///
20303/// Instantiate a resource method builder
20304///
20305/// ```test_harness,no_run
20306/// # extern crate hyper;
20307/// # extern crate hyper_rustls;
20308/// # extern crate google_storage1 as storage1;
20309/// # async fn dox() {
20310/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20311///
20312/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20313/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20314/// #     secret,
20315/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20316/// # ).build().await.unwrap();
20317///
20318/// # let client = hyper_util::client::legacy::Client::builder(
20319/// #     hyper_util::rt::TokioExecutor::new()
20320/// # )
20321/// # .build(
20322/// #     hyper_rustls::HttpsConnectorBuilder::new()
20323/// #         .with_native_roots()
20324/// #         .unwrap()
20325/// #         .https_or_http()
20326/// #         .enable_http1()
20327/// #         .build()
20328/// # );
20329/// # let mut hub = Storage::new(client, auth);
20330/// // You can configure optional parameters by calling the respective setters at will, and
20331/// // execute the final call using `doit()`.
20332/// // Values shown here are possibly random and not representative !
20333/// let result = hub.notifications().list("bucket")
20334///              .user_project("ut")
20335///              .doit().await;
20336/// # }
20337/// ```
20338pub struct NotificationListCall<'a, C>
20339where
20340    C: 'a,
20341{
20342    hub: &'a Storage<C>,
20343    _bucket: String,
20344    _user_project: Option<String>,
20345    _delegate: Option<&'a mut dyn common::Delegate>,
20346    _additional_params: HashMap<String, String>,
20347    _scopes: BTreeSet<String>,
20348}
20349
20350impl<'a, C> common::CallBuilder for NotificationListCall<'a, C> {}
20351
20352impl<'a, C> NotificationListCall<'a, C>
20353where
20354    C: common::Connector,
20355{
20356    /// Perform the operation you have build so far.
20357    pub async fn doit(mut self) -> common::Result<(common::Response, Notifications)> {
20358        use std::borrow::Cow;
20359        use std::io::{Read, Seek};
20360
20361        use common::{url::Params, ToParts};
20362        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20363
20364        let mut dd = common::DefaultDelegate;
20365        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20366        dlg.begin(common::MethodInfo {
20367            id: "storage.notifications.list",
20368            http_method: hyper::Method::GET,
20369        });
20370
20371        for &field in ["alt", "bucket", "userProject"].iter() {
20372            if self._additional_params.contains_key(field) {
20373                dlg.finished(false);
20374                return Err(common::Error::FieldClash(field));
20375            }
20376        }
20377
20378        let mut params = Params::with_capacity(4 + self._additional_params.len());
20379        params.push("bucket", self._bucket);
20380        if let Some(value) = self._user_project.as_ref() {
20381            params.push("userProject", value);
20382        }
20383
20384        params.extend(self._additional_params.iter());
20385
20386        params.push("alt", "json");
20387        let mut url = self.hub._base_url.clone() + "b/{bucket}/notificationConfigs";
20388        if self._scopes.is_empty() {
20389            self._scopes
20390                .insert(Scope::CloudPlatform.as_ref().to_string());
20391        }
20392
20393        #[allow(clippy::single_element_loop)]
20394        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
20395            url = params.uri_replacement(url, param_name, find_this, false);
20396        }
20397        {
20398            let to_remove = ["bucket"];
20399            params.remove_params(&to_remove);
20400        }
20401
20402        let url = params.parse_with_url(&url);
20403
20404        loop {
20405            let token = match self
20406                .hub
20407                .auth
20408                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20409                .await
20410            {
20411                Ok(token) => token,
20412                Err(e) => match dlg.token(e) {
20413                    Ok(token) => token,
20414                    Err(e) => {
20415                        dlg.finished(false);
20416                        return Err(common::Error::MissingToken(e));
20417                    }
20418                },
20419            };
20420            let mut req_result = {
20421                let client = &self.hub.client;
20422                dlg.pre_request();
20423                let mut req_builder = hyper::Request::builder()
20424                    .method(hyper::Method::GET)
20425                    .uri(url.as_str())
20426                    .header(USER_AGENT, self.hub._user_agent.clone());
20427
20428                if let Some(token) = token.as_ref() {
20429                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20430                }
20431
20432                let request = req_builder
20433                    .header(CONTENT_LENGTH, 0_u64)
20434                    .body(common::to_body::<String>(None));
20435
20436                client.request(request.unwrap()).await
20437            };
20438
20439            match req_result {
20440                Err(err) => {
20441                    if let common::Retry::After(d) = dlg.http_error(&err) {
20442                        sleep(d).await;
20443                        continue;
20444                    }
20445                    dlg.finished(false);
20446                    return Err(common::Error::HttpError(err));
20447                }
20448                Ok(res) => {
20449                    let (mut parts, body) = res.into_parts();
20450                    let mut body = common::Body::new(body);
20451                    if !parts.status.is_success() {
20452                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20453                        let error = serde_json::from_str(&common::to_string(&bytes));
20454                        let response = common::to_response(parts, bytes.into());
20455
20456                        if let common::Retry::After(d) =
20457                            dlg.http_failure(&response, error.as_ref().ok())
20458                        {
20459                            sleep(d).await;
20460                            continue;
20461                        }
20462
20463                        dlg.finished(false);
20464
20465                        return Err(match error {
20466                            Ok(value) => common::Error::BadRequest(value),
20467                            _ => common::Error::Failure(response),
20468                        });
20469                    }
20470                    let response = {
20471                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20472                        let encoded = common::to_string(&bytes);
20473                        match serde_json::from_str(&encoded) {
20474                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20475                            Err(error) => {
20476                                dlg.response_json_decode_error(&encoded, &error);
20477                                return Err(common::Error::JsonDecodeError(
20478                                    encoded.to_string(),
20479                                    error,
20480                                ));
20481                            }
20482                        }
20483                    };
20484
20485                    dlg.finished(true);
20486                    return Ok(response);
20487                }
20488            }
20489        }
20490    }
20491
20492    /// Name of a Google Cloud Storage bucket.
20493    ///
20494    /// Sets the *bucket* path property to the given value.
20495    ///
20496    /// Even though the property as already been set when instantiating this call,
20497    /// we provide this method for API completeness.
20498    pub fn bucket(mut self, new_value: &str) -> NotificationListCall<'a, C> {
20499        self._bucket = new_value.to_string();
20500        self
20501    }
20502    /// The project to be billed for this request. Required for Requester Pays buckets.
20503    ///
20504    /// Sets the *user project* query property to the given value.
20505    pub fn user_project(mut self, new_value: &str) -> NotificationListCall<'a, C> {
20506        self._user_project = Some(new_value.to_string());
20507        self
20508    }
20509    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20510    /// while executing the actual API request.
20511    ///
20512    /// ````text
20513    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20514    /// ````
20515    ///
20516    /// Sets the *delegate* property to the given value.
20517    pub fn delegate(
20518        mut self,
20519        new_value: &'a mut dyn common::Delegate,
20520    ) -> NotificationListCall<'a, C> {
20521        self._delegate = Some(new_value);
20522        self
20523    }
20524
20525    /// Set any additional parameter of the query string used in the request.
20526    /// It should be used to set parameters which are not yet available through their own
20527    /// setters.
20528    ///
20529    /// Please note that this method must not be used to set any of the known parameters
20530    /// which have their own setter method. If done anyway, the request will fail.
20531    ///
20532    /// # Additional Parameters
20533    ///
20534    /// * *alt* (query-string) - Data format for the response.
20535    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20536    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
20537    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20538    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20539    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
20540    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
20541    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
20542    pub fn param<T>(mut self, name: T, value: T) -> NotificationListCall<'a, C>
20543    where
20544        T: AsRef<str>,
20545    {
20546        self._additional_params
20547            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20548        self
20549    }
20550
20551    /// Identifies the authorization scope for the method you are building.
20552    ///
20553    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20554    /// [`Scope::CloudPlatform`].
20555    ///
20556    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20557    /// tokens for more than one scope.
20558    ///
20559    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20560    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20561    /// sufficient, a read-write scope will do as well.
20562    pub fn add_scope<St>(mut self, scope: St) -> NotificationListCall<'a, C>
20563    where
20564        St: AsRef<str>,
20565    {
20566        self._scopes.insert(String::from(scope.as_ref()));
20567        self
20568    }
20569    /// Identifies the authorization scope(s) for the method you are building.
20570    ///
20571    /// See [`Self::add_scope()`] for details.
20572    pub fn add_scopes<I, St>(mut self, scopes: I) -> NotificationListCall<'a, C>
20573    where
20574        I: IntoIterator<Item = St>,
20575        St: AsRef<str>,
20576    {
20577        self._scopes
20578            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20579        self
20580    }
20581
20582    /// Removes all scopes, and no default scope will be used either.
20583    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20584    /// for details).
20585    pub fn clear_scopes(mut self) -> NotificationListCall<'a, C> {
20586        self._scopes.clear();
20587        self
20588    }
20589}
20590
20591/// Permanently deletes the ACL entry for the specified entity on the specified object.
20592///
20593/// A builder for the *delete* method supported by a *objectAccessControl* resource.
20594/// It is not used directly, but through a [`ObjectAccessControlMethods`] instance.
20595///
20596/// # Example
20597///
20598/// Instantiate a resource method builder
20599///
20600/// ```test_harness,no_run
20601/// # extern crate hyper;
20602/// # extern crate hyper_rustls;
20603/// # extern crate google_storage1 as storage1;
20604/// # async fn dox() {
20605/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20606///
20607/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20608/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20609/// #     secret,
20610/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20611/// # ).build().await.unwrap();
20612///
20613/// # let client = hyper_util::client::legacy::Client::builder(
20614/// #     hyper_util::rt::TokioExecutor::new()
20615/// # )
20616/// # .build(
20617/// #     hyper_rustls::HttpsConnectorBuilder::new()
20618/// #         .with_native_roots()
20619/// #         .unwrap()
20620/// #         .https_or_http()
20621/// #         .enable_http1()
20622/// #         .build()
20623/// # );
20624/// # let mut hub = Storage::new(client, auth);
20625/// // You can configure optional parameters by calling the respective setters at will, and
20626/// // execute the final call using `doit()`.
20627/// // Values shown here are possibly random and not representative !
20628/// let result = hub.object_access_controls().delete("bucket", "object", "entity")
20629///              .user_project("duo")
20630///              .generation(-45)
20631///              .doit().await;
20632/// # }
20633/// ```
20634pub struct ObjectAccessControlDeleteCall<'a, C>
20635where
20636    C: 'a,
20637{
20638    hub: &'a Storage<C>,
20639    _bucket: String,
20640    _object: String,
20641    _entity: String,
20642    _user_project: Option<String>,
20643    _generation: Option<i64>,
20644    _delegate: Option<&'a mut dyn common::Delegate>,
20645    _additional_params: HashMap<String, String>,
20646    _scopes: BTreeSet<String>,
20647}
20648
20649impl<'a, C> common::CallBuilder for ObjectAccessControlDeleteCall<'a, C> {}
20650
20651impl<'a, C> ObjectAccessControlDeleteCall<'a, C>
20652where
20653    C: common::Connector,
20654{
20655    /// Perform the operation you have build so far.
20656    pub async fn doit(mut self) -> common::Result<common::Response> {
20657        use std::borrow::Cow;
20658        use std::io::{Read, Seek};
20659
20660        use common::{url::Params, ToParts};
20661        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20662
20663        let mut dd = common::DefaultDelegate;
20664        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20665        dlg.begin(common::MethodInfo {
20666            id: "storage.objectAccessControls.delete",
20667            http_method: hyper::Method::DELETE,
20668        });
20669
20670        for &field in ["bucket", "object", "entity", "userProject", "generation"].iter() {
20671            if self._additional_params.contains_key(field) {
20672                dlg.finished(false);
20673                return Err(common::Error::FieldClash(field));
20674            }
20675        }
20676
20677        let mut params = Params::with_capacity(6 + self._additional_params.len());
20678        params.push("bucket", self._bucket);
20679        params.push("object", self._object);
20680        params.push("entity", self._entity);
20681        if let Some(value) = self._user_project.as_ref() {
20682            params.push("userProject", value);
20683        }
20684        if let Some(value) = self._generation.as_ref() {
20685            params.push("generation", value.to_string());
20686        }
20687
20688        params.extend(self._additional_params.iter());
20689
20690        let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}/acl/{entity}";
20691        if self._scopes.is_empty() {
20692            self._scopes
20693                .insert(Scope::CloudPlatform.as_ref().to_string());
20694        }
20695
20696        #[allow(clippy::single_element_loop)]
20697        for &(find_this, param_name) in [
20698            ("{bucket}", "bucket"),
20699            ("{object}", "object"),
20700            ("{entity}", "entity"),
20701        ]
20702        .iter()
20703        {
20704            url = params.uri_replacement(url, param_name, find_this, false);
20705        }
20706        {
20707            let to_remove = ["entity", "object", "bucket"];
20708            params.remove_params(&to_remove);
20709        }
20710
20711        let url = params.parse_with_url(&url);
20712
20713        loop {
20714            let token = match self
20715                .hub
20716                .auth
20717                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20718                .await
20719            {
20720                Ok(token) => token,
20721                Err(e) => match dlg.token(e) {
20722                    Ok(token) => token,
20723                    Err(e) => {
20724                        dlg.finished(false);
20725                        return Err(common::Error::MissingToken(e));
20726                    }
20727                },
20728            };
20729            let mut req_result = {
20730                let client = &self.hub.client;
20731                dlg.pre_request();
20732                let mut req_builder = hyper::Request::builder()
20733                    .method(hyper::Method::DELETE)
20734                    .uri(url.as_str())
20735                    .header(USER_AGENT, self.hub._user_agent.clone());
20736
20737                if let Some(token) = token.as_ref() {
20738                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20739                }
20740
20741                let request = req_builder
20742                    .header(CONTENT_LENGTH, 0_u64)
20743                    .body(common::to_body::<String>(None));
20744
20745                client.request(request.unwrap()).await
20746            };
20747
20748            match req_result {
20749                Err(err) => {
20750                    if let common::Retry::After(d) = dlg.http_error(&err) {
20751                        sleep(d).await;
20752                        continue;
20753                    }
20754                    dlg.finished(false);
20755                    return Err(common::Error::HttpError(err));
20756                }
20757                Ok(res) => {
20758                    let (mut parts, body) = res.into_parts();
20759                    let mut body = common::Body::new(body);
20760                    if !parts.status.is_success() {
20761                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20762                        let error = serde_json::from_str(&common::to_string(&bytes));
20763                        let response = common::to_response(parts, bytes.into());
20764
20765                        if let common::Retry::After(d) =
20766                            dlg.http_failure(&response, error.as_ref().ok())
20767                        {
20768                            sleep(d).await;
20769                            continue;
20770                        }
20771
20772                        dlg.finished(false);
20773
20774                        return Err(match error {
20775                            Ok(value) => common::Error::BadRequest(value),
20776                            _ => common::Error::Failure(response),
20777                        });
20778                    }
20779                    let response = common::Response::from_parts(parts, body);
20780
20781                    dlg.finished(true);
20782                    return Ok(response);
20783                }
20784            }
20785        }
20786    }
20787
20788    /// Name of a bucket.
20789    ///
20790    /// Sets the *bucket* path property to the given value.
20791    ///
20792    /// Even though the property as already been set when instantiating this call,
20793    /// we provide this method for API completeness.
20794    pub fn bucket(mut self, new_value: &str) -> ObjectAccessControlDeleteCall<'a, C> {
20795        self._bucket = new_value.to_string();
20796        self
20797    }
20798    /// Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
20799    ///
20800    /// Sets the *object* path property to the given value.
20801    ///
20802    /// Even though the property as already been set when instantiating this call,
20803    /// we provide this method for API completeness.
20804    pub fn object(mut self, new_value: &str) -> ObjectAccessControlDeleteCall<'a, C> {
20805        self._object = new_value.to_string();
20806        self
20807    }
20808    /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
20809    ///
20810    /// Sets the *entity* path property to the given value.
20811    ///
20812    /// Even though the property as already been set when instantiating this call,
20813    /// we provide this method for API completeness.
20814    pub fn entity(mut self, new_value: &str) -> ObjectAccessControlDeleteCall<'a, C> {
20815        self._entity = new_value.to_string();
20816        self
20817    }
20818    /// The project to be billed for this request. Required for Requester Pays buckets.
20819    ///
20820    /// Sets the *user project* query property to the given value.
20821    pub fn user_project(mut self, new_value: &str) -> ObjectAccessControlDeleteCall<'a, C> {
20822        self._user_project = Some(new_value.to_string());
20823        self
20824    }
20825    /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
20826    ///
20827    /// Sets the *generation* query property to the given value.
20828    pub fn generation(mut self, new_value: i64) -> ObjectAccessControlDeleteCall<'a, C> {
20829        self._generation = Some(new_value);
20830        self
20831    }
20832    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20833    /// while executing the actual API request.
20834    ///
20835    /// ````text
20836    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20837    /// ````
20838    ///
20839    /// Sets the *delegate* property to the given value.
20840    pub fn delegate(
20841        mut self,
20842        new_value: &'a mut dyn common::Delegate,
20843    ) -> ObjectAccessControlDeleteCall<'a, C> {
20844        self._delegate = Some(new_value);
20845        self
20846    }
20847
20848    /// Set any additional parameter of the query string used in the request.
20849    /// It should be used to set parameters which are not yet available through their own
20850    /// setters.
20851    ///
20852    /// Please note that this method must not be used to set any of the known parameters
20853    /// which have their own setter method. If done anyway, the request will fail.
20854    ///
20855    /// # Additional Parameters
20856    ///
20857    /// * *alt* (query-string) - Data format for the response.
20858    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20859    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
20860    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20861    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20862    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
20863    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
20864    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
20865    pub fn param<T>(mut self, name: T, value: T) -> ObjectAccessControlDeleteCall<'a, C>
20866    where
20867        T: AsRef<str>,
20868    {
20869        self._additional_params
20870            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20871        self
20872    }
20873
20874    /// Identifies the authorization scope for the method you are building.
20875    ///
20876    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20877    /// [`Scope::CloudPlatform`].
20878    ///
20879    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20880    /// tokens for more than one scope.
20881    ///
20882    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20883    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20884    /// sufficient, a read-write scope will do as well.
20885    pub fn add_scope<St>(mut self, scope: St) -> ObjectAccessControlDeleteCall<'a, C>
20886    where
20887        St: AsRef<str>,
20888    {
20889        self._scopes.insert(String::from(scope.as_ref()));
20890        self
20891    }
20892    /// Identifies the authorization scope(s) for the method you are building.
20893    ///
20894    /// See [`Self::add_scope()`] for details.
20895    pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectAccessControlDeleteCall<'a, C>
20896    where
20897        I: IntoIterator<Item = St>,
20898        St: AsRef<str>,
20899    {
20900        self._scopes
20901            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20902        self
20903    }
20904
20905    /// Removes all scopes, and no default scope will be used either.
20906    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20907    /// for details).
20908    pub fn clear_scopes(mut self) -> ObjectAccessControlDeleteCall<'a, C> {
20909        self._scopes.clear();
20910        self
20911    }
20912}
20913
20914/// Returns the ACL entry for the specified entity on the specified object.
20915///
20916/// A builder for the *get* method supported by a *objectAccessControl* resource.
20917/// It is not used directly, but through a [`ObjectAccessControlMethods`] instance.
20918///
20919/// # Example
20920///
20921/// Instantiate a resource method builder
20922///
20923/// ```test_harness,no_run
20924/// # extern crate hyper;
20925/// # extern crate hyper_rustls;
20926/// # extern crate google_storage1 as storage1;
20927/// # async fn dox() {
20928/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20929///
20930/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20931/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20932/// #     secret,
20933/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20934/// # ).build().await.unwrap();
20935///
20936/// # let client = hyper_util::client::legacy::Client::builder(
20937/// #     hyper_util::rt::TokioExecutor::new()
20938/// # )
20939/// # .build(
20940/// #     hyper_rustls::HttpsConnectorBuilder::new()
20941/// #         .with_native_roots()
20942/// #         .unwrap()
20943/// #         .https_or_http()
20944/// #         .enable_http1()
20945/// #         .build()
20946/// # );
20947/// # let mut hub = Storage::new(client, auth);
20948/// // You can configure optional parameters by calling the respective setters at will, and
20949/// // execute the final call using `doit()`.
20950/// // Values shown here are possibly random and not representative !
20951/// let result = hub.object_access_controls().get("bucket", "object", "entity")
20952///              .user_project("kasd")
20953///              .generation(-95)
20954///              .doit().await;
20955/// # }
20956/// ```
20957pub struct ObjectAccessControlGetCall<'a, C>
20958where
20959    C: 'a,
20960{
20961    hub: &'a Storage<C>,
20962    _bucket: String,
20963    _object: String,
20964    _entity: String,
20965    _user_project: Option<String>,
20966    _generation: Option<i64>,
20967    _delegate: Option<&'a mut dyn common::Delegate>,
20968    _additional_params: HashMap<String, String>,
20969    _scopes: BTreeSet<String>,
20970}
20971
20972impl<'a, C> common::CallBuilder for ObjectAccessControlGetCall<'a, C> {}
20973
20974impl<'a, C> ObjectAccessControlGetCall<'a, C>
20975where
20976    C: common::Connector,
20977{
20978    /// Perform the operation you have build so far.
20979    pub async fn doit(mut self) -> common::Result<(common::Response, ObjectAccessControl)> {
20980        use std::borrow::Cow;
20981        use std::io::{Read, Seek};
20982
20983        use common::{url::Params, ToParts};
20984        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20985
20986        let mut dd = common::DefaultDelegate;
20987        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20988        dlg.begin(common::MethodInfo {
20989            id: "storage.objectAccessControls.get",
20990            http_method: hyper::Method::GET,
20991        });
20992
20993        for &field in [
20994            "alt",
20995            "bucket",
20996            "object",
20997            "entity",
20998            "userProject",
20999            "generation",
21000        ]
21001        .iter()
21002        {
21003            if self._additional_params.contains_key(field) {
21004                dlg.finished(false);
21005                return Err(common::Error::FieldClash(field));
21006            }
21007        }
21008
21009        let mut params = Params::with_capacity(7 + self._additional_params.len());
21010        params.push("bucket", self._bucket);
21011        params.push("object", self._object);
21012        params.push("entity", self._entity);
21013        if let Some(value) = self._user_project.as_ref() {
21014            params.push("userProject", value);
21015        }
21016        if let Some(value) = self._generation.as_ref() {
21017            params.push("generation", value.to_string());
21018        }
21019
21020        params.extend(self._additional_params.iter());
21021
21022        params.push("alt", "json");
21023        let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}/acl/{entity}";
21024        if self._scopes.is_empty() {
21025            self._scopes
21026                .insert(Scope::CloudPlatform.as_ref().to_string());
21027        }
21028
21029        #[allow(clippy::single_element_loop)]
21030        for &(find_this, param_name) in [
21031            ("{bucket}", "bucket"),
21032            ("{object}", "object"),
21033            ("{entity}", "entity"),
21034        ]
21035        .iter()
21036        {
21037            url = params.uri_replacement(url, param_name, find_this, false);
21038        }
21039        {
21040            let to_remove = ["entity", "object", "bucket"];
21041            params.remove_params(&to_remove);
21042        }
21043
21044        let url = params.parse_with_url(&url);
21045
21046        loop {
21047            let token = match self
21048                .hub
21049                .auth
21050                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21051                .await
21052            {
21053                Ok(token) => token,
21054                Err(e) => match dlg.token(e) {
21055                    Ok(token) => token,
21056                    Err(e) => {
21057                        dlg.finished(false);
21058                        return Err(common::Error::MissingToken(e));
21059                    }
21060                },
21061            };
21062            let mut req_result = {
21063                let client = &self.hub.client;
21064                dlg.pre_request();
21065                let mut req_builder = hyper::Request::builder()
21066                    .method(hyper::Method::GET)
21067                    .uri(url.as_str())
21068                    .header(USER_AGENT, self.hub._user_agent.clone());
21069
21070                if let Some(token) = token.as_ref() {
21071                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21072                }
21073
21074                let request = req_builder
21075                    .header(CONTENT_LENGTH, 0_u64)
21076                    .body(common::to_body::<String>(None));
21077
21078                client.request(request.unwrap()).await
21079            };
21080
21081            match req_result {
21082                Err(err) => {
21083                    if let common::Retry::After(d) = dlg.http_error(&err) {
21084                        sleep(d).await;
21085                        continue;
21086                    }
21087                    dlg.finished(false);
21088                    return Err(common::Error::HttpError(err));
21089                }
21090                Ok(res) => {
21091                    let (mut parts, body) = res.into_parts();
21092                    let mut body = common::Body::new(body);
21093                    if !parts.status.is_success() {
21094                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21095                        let error = serde_json::from_str(&common::to_string(&bytes));
21096                        let response = common::to_response(parts, bytes.into());
21097
21098                        if let common::Retry::After(d) =
21099                            dlg.http_failure(&response, error.as_ref().ok())
21100                        {
21101                            sleep(d).await;
21102                            continue;
21103                        }
21104
21105                        dlg.finished(false);
21106
21107                        return Err(match error {
21108                            Ok(value) => common::Error::BadRequest(value),
21109                            _ => common::Error::Failure(response),
21110                        });
21111                    }
21112                    let response = {
21113                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21114                        let encoded = common::to_string(&bytes);
21115                        match serde_json::from_str(&encoded) {
21116                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21117                            Err(error) => {
21118                                dlg.response_json_decode_error(&encoded, &error);
21119                                return Err(common::Error::JsonDecodeError(
21120                                    encoded.to_string(),
21121                                    error,
21122                                ));
21123                            }
21124                        }
21125                    };
21126
21127                    dlg.finished(true);
21128                    return Ok(response);
21129                }
21130            }
21131        }
21132    }
21133
21134    /// Name of a bucket.
21135    ///
21136    /// Sets the *bucket* path property to the given value.
21137    ///
21138    /// Even though the property as already been set when instantiating this call,
21139    /// we provide this method for API completeness.
21140    pub fn bucket(mut self, new_value: &str) -> ObjectAccessControlGetCall<'a, C> {
21141        self._bucket = new_value.to_string();
21142        self
21143    }
21144    /// Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
21145    ///
21146    /// Sets the *object* path property to the given value.
21147    ///
21148    /// Even though the property as already been set when instantiating this call,
21149    /// we provide this method for API completeness.
21150    pub fn object(mut self, new_value: &str) -> ObjectAccessControlGetCall<'a, C> {
21151        self._object = new_value.to_string();
21152        self
21153    }
21154    /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
21155    ///
21156    /// Sets the *entity* path property to the given value.
21157    ///
21158    /// Even though the property as already been set when instantiating this call,
21159    /// we provide this method for API completeness.
21160    pub fn entity(mut self, new_value: &str) -> ObjectAccessControlGetCall<'a, C> {
21161        self._entity = new_value.to_string();
21162        self
21163    }
21164    /// The project to be billed for this request. Required for Requester Pays buckets.
21165    ///
21166    /// Sets the *user project* query property to the given value.
21167    pub fn user_project(mut self, new_value: &str) -> ObjectAccessControlGetCall<'a, C> {
21168        self._user_project = Some(new_value.to_string());
21169        self
21170    }
21171    /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
21172    ///
21173    /// Sets the *generation* query property to the given value.
21174    pub fn generation(mut self, new_value: i64) -> ObjectAccessControlGetCall<'a, C> {
21175        self._generation = Some(new_value);
21176        self
21177    }
21178    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21179    /// while executing the actual API request.
21180    ///
21181    /// ````text
21182    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21183    /// ````
21184    ///
21185    /// Sets the *delegate* property to the given value.
21186    pub fn delegate(
21187        mut self,
21188        new_value: &'a mut dyn common::Delegate,
21189    ) -> ObjectAccessControlGetCall<'a, C> {
21190        self._delegate = Some(new_value);
21191        self
21192    }
21193
21194    /// Set any additional parameter of the query string used in the request.
21195    /// It should be used to set parameters which are not yet available through their own
21196    /// setters.
21197    ///
21198    /// Please note that this method must not be used to set any of the known parameters
21199    /// which have their own setter method. If done anyway, the request will fail.
21200    ///
21201    /// # Additional Parameters
21202    ///
21203    /// * *alt* (query-string) - Data format for the response.
21204    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21205    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
21206    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21207    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21208    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21209    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
21210    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21211    pub fn param<T>(mut self, name: T, value: T) -> ObjectAccessControlGetCall<'a, C>
21212    where
21213        T: AsRef<str>,
21214    {
21215        self._additional_params
21216            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21217        self
21218    }
21219
21220    /// Identifies the authorization scope for the method you are building.
21221    ///
21222    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21223    /// [`Scope::CloudPlatform`].
21224    ///
21225    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21226    /// tokens for more than one scope.
21227    ///
21228    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21229    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21230    /// sufficient, a read-write scope will do as well.
21231    pub fn add_scope<St>(mut self, scope: St) -> ObjectAccessControlGetCall<'a, C>
21232    where
21233        St: AsRef<str>,
21234    {
21235        self._scopes.insert(String::from(scope.as_ref()));
21236        self
21237    }
21238    /// Identifies the authorization scope(s) for the method you are building.
21239    ///
21240    /// See [`Self::add_scope()`] for details.
21241    pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectAccessControlGetCall<'a, C>
21242    where
21243        I: IntoIterator<Item = St>,
21244        St: AsRef<str>,
21245    {
21246        self._scopes
21247            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21248        self
21249    }
21250
21251    /// Removes all scopes, and no default scope will be used either.
21252    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21253    /// for details).
21254    pub fn clear_scopes(mut self) -> ObjectAccessControlGetCall<'a, C> {
21255        self._scopes.clear();
21256        self
21257    }
21258}
21259
21260/// Creates a new ACL entry on the specified object.
21261///
21262/// A builder for the *insert* method supported by a *objectAccessControl* resource.
21263/// It is not used directly, but through a [`ObjectAccessControlMethods`] instance.
21264///
21265/// # Example
21266///
21267/// Instantiate a resource method builder
21268///
21269/// ```test_harness,no_run
21270/// # extern crate hyper;
21271/// # extern crate hyper_rustls;
21272/// # extern crate google_storage1 as storage1;
21273/// use storage1::api::ObjectAccessControl;
21274/// # async fn dox() {
21275/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21276///
21277/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21278/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21279/// #     secret,
21280/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21281/// # ).build().await.unwrap();
21282///
21283/// # let client = hyper_util::client::legacy::Client::builder(
21284/// #     hyper_util::rt::TokioExecutor::new()
21285/// # )
21286/// # .build(
21287/// #     hyper_rustls::HttpsConnectorBuilder::new()
21288/// #         .with_native_roots()
21289/// #         .unwrap()
21290/// #         .https_or_http()
21291/// #         .enable_http1()
21292/// #         .build()
21293/// # );
21294/// # let mut hub = Storage::new(client, auth);
21295/// // As the method needs a request, you would usually fill it with the desired information
21296/// // into the respective structure. Some of the parts shown here might not be applicable !
21297/// // Values shown here are possibly random and not representative !
21298/// let mut req = ObjectAccessControl::default();
21299///
21300/// // You can configure optional parameters by calling the respective setters at will, and
21301/// // execute the final call using `doit()`.
21302/// // Values shown here are possibly random and not representative !
21303/// let result = hub.object_access_controls().insert(req, "bucket", "object")
21304///              .user_project("et")
21305///              .generation(-56)
21306///              .doit().await;
21307/// # }
21308/// ```
21309pub struct ObjectAccessControlInsertCall<'a, C>
21310where
21311    C: 'a,
21312{
21313    hub: &'a Storage<C>,
21314    _request: ObjectAccessControl,
21315    _bucket: String,
21316    _object: String,
21317    _user_project: Option<String>,
21318    _generation: Option<i64>,
21319    _delegate: Option<&'a mut dyn common::Delegate>,
21320    _additional_params: HashMap<String, String>,
21321    _scopes: BTreeSet<String>,
21322}
21323
21324impl<'a, C> common::CallBuilder for ObjectAccessControlInsertCall<'a, C> {}
21325
21326impl<'a, C> ObjectAccessControlInsertCall<'a, C>
21327where
21328    C: common::Connector,
21329{
21330    /// Perform the operation you have build so far.
21331    pub async fn doit(mut self) -> common::Result<(common::Response, ObjectAccessControl)> {
21332        use std::borrow::Cow;
21333        use std::io::{Read, Seek};
21334
21335        use common::{url::Params, ToParts};
21336        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21337
21338        let mut dd = common::DefaultDelegate;
21339        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21340        dlg.begin(common::MethodInfo {
21341            id: "storage.objectAccessControls.insert",
21342            http_method: hyper::Method::POST,
21343        });
21344
21345        for &field in ["alt", "bucket", "object", "userProject", "generation"].iter() {
21346            if self._additional_params.contains_key(field) {
21347                dlg.finished(false);
21348                return Err(common::Error::FieldClash(field));
21349            }
21350        }
21351
21352        let mut params = Params::with_capacity(7 + self._additional_params.len());
21353        params.push("bucket", self._bucket);
21354        params.push("object", self._object);
21355        if let Some(value) = self._user_project.as_ref() {
21356            params.push("userProject", value);
21357        }
21358        if let Some(value) = self._generation.as_ref() {
21359            params.push("generation", value.to_string());
21360        }
21361
21362        params.extend(self._additional_params.iter());
21363
21364        params.push("alt", "json");
21365        let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}/acl";
21366        if self._scopes.is_empty() {
21367            self._scopes
21368                .insert(Scope::CloudPlatform.as_ref().to_string());
21369        }
21370
21371        #[allow(clippy::single_element_loop)]
21372        for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object")].iter() {
21373            url = params.uri_replacement(url, param_name, find_this, false);
21374        }
21375        {
21376            let to_remove = ["object", "bucket"];
21377            params.remove_params(&to_remove);
21378        }
21379
21380        let url = params.parse_with_url(&url);
21381
21382        let mut json_mime_type = mime::APPLICATION_JSON;
21383        let mut request_value_reader = {
21384            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21385            common::remove_json_null_values(&mut value);
21386            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21387            serde_json::to_writer(&mut dst, &value).unwrap();
21388            dst
21389        };
21390        let request_size = request_value_reader
21391            .seek(std::io::SeekFrom::End(0))
21392            .unwrap();
21393        request_value_reader
21394            .seek(std::io::SeekFrom::Start(0))
21395            .unwrap();
21396
21397        loop {
21398            let token = match self
21399                .hub
21400                .auth
21401                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21402                .await
21403            {
21404                Ok(token) => token,
21405                Err(e) => match dlg.token(e) {
21406                    Ok(token) => token,
21407                    Err(e) => {
21408                        dlg.finished(false);
21409                        return Err(common::Error::MissingToken(e));
21410                    }
21411                },
21412            };
21413            request_value_reader
21414                .seek(std::io::SeekFrom::Start(0))
21415                .unwrap();
21416            let mut req_result = {
21417                let client = &self.hub.client;
21418                dlg.pre_request();
21419                let mut req_builder = hyper::Request::builder()
21420                    .method(hyper::Method::POST)
21421                    .uri(url.as_str())
21422                    .header(USER_AGENT, self.hub._user_agent.clone());
21423
21424                if let Some(token) = token.as_ref() {
21425                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21426                }
21427
21428                let request = req_builder
21429                    .header(CONTENT_TYPE, json_mime_type.to_string())
21430                    .header(CONTENT_LENGTH, request_size as u64)
21431                    .body(common::to_body(
21432                        request_value_reader.get_ref().clone().into(),
21433                    ));
21434
21435                client.request(request.unwrap()).await
21436            };
21437
21438            match req_result {
21439                Err(err) => {
21440                    if let common::Retry::After(d) = dlg.http_error(&err) {
21441                        sleep(d).await;
21442                        continue;
21443                    }
21444                    dlg.finished(false);
21445                    return Err(common::Error::HttpError(err));
21446                }
21447                Ok(res) => {
21448                    let (mut parts, body) = res.into_parts();
21449                    let mut body = common::Body::new(body);
21450                    if !parts.status.is_success() {
21451                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21452                        let error = serde_json::from_str(&common::to_string(&bytes));
21453                        let response = common::to_response(parts, bytes.into());
21454
21455                        if let common::Retry::After(d) =
21456                            dlg.http_failure(&response, error.as_ref().ok())
21457                        {
21458                            sleep(d).await;
21459                            continue;
21460                        }
21461
21462                        dlg.finished(false);
21463
21464                        return Err(match error {
21465                            Ok(value) => common::Error::BadRequest(value),
21466                            _ => common::Error::Failure(response),
21467                        });
21468                    }
21469                    let response = {
21470                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21471                        let encoded = common::to_string(&bytes);
21472                        match serde_json::from_str(&encoded) {
21473                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21474                            Err(error) => {
21475                                dlg.response_json_decode_error(&encoded, &error);
21476                                return Err(common::Error::JsonDecodeError(
21477                                    encoded.to_string(),
21478                                    error,
21479                                ));
21480                            }
21481                        }
21482                    };
21483
21484                    dlg.finished(true);
21485                    return Ok(response);
21486                }
21487            }
21488        }
21489    }
21490
21491    ///
21492    /// Sets the *request* property to the given value.
21493    ///
21494    /// Even though the property as already been set when instantiating this call,
21495    /// we provide this method for API completeness.
21496    pub fn request(
21497        mut self,
21498        new_value: ObjectAccessControl,
21499    ) -> ObjectAccessControlInsertCall<'a, C> {
21500        self._request = new_value;
21501        self
21502    }
21503    /// Name of a bucket.
21504    ///
21505    /// Sets the *bucket* path property to the given value.
21506    ///
21507    /// Even though the property as already been set when instantiating this call,
21508    /// we provide this method for API completeness.
21509    pub fn bucket(mut self, new_value: &str) -> ObjectAccessControlInsertCall<'a, C> {
21510        self._bucket = new_value.to_string();
21511        self
21512    }
21513    /// Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
21514    ///
21515    /// Sets the *object* path property to the given value.
21516    ///
21517    /// Even though the property as already been set when instantiating this call,
21518    /// we provide this method for API completeness.
21519    pub fn object(mut self, new_value: &str) -> ObjectAccessControlInsertCall<'a, C> {
21520        self._object = new_value.to_string();
21521        self
21522    }
21523    /// The project to be billed for this request. Required for Requester Pays buckets.
21524    ///
21525    /// Sets the *user project* query property to the given value.
21526    pub fn user_project(mut self, new_value: &str) -> ObjectAccessControlInsertCall<'a, C> {
21527        self._user_project = Some(new_value.to_string());
21528        self
21529    }
21530    /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
21531    ///
21532    /// Sets the *generation* query property to the given value.
21533    pub fn generation(mut self, new_value: i64) -> ObjectAccessControlInsertCall<'a, C> {
21534        self._generation = Some(new_value);
21535        self
21536    }
21537    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21538    /// while executing the actual API request.
21539    ///
21540    /// ````text
21541    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21542    /// ````
21543    ///
21544    /// Sets the *delegate* property to the given value.
21545    pub fn delegate(
21546        mut self,
21547        new_value: &'a mut dyn common::Delegate,
21548    ) -> ObjectAccessControlInsertCall<'a, C> {
21549        self._delegate = Some(new_value);
21550        self
21551    }
21552
21553    /// Set any additional parameter of the query string used in the request.
21554    /// It should be used to set parameters which are not yet available through their own
21555    /// setters.
21556    ///
21557    /// Please note that this method must not be used to set any of the known parameters
21558    /// which have their own setter method. If done anyway, the request will fail.
21559    ///
21560    /// # Additional Parameters
21561    ///
21562    /// * *alt* (query-string) - Data format for the response.
21563    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21564    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
21565    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21566    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21567    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21568    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
21569    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21570    pub fn param<T>(mut self, name: T, value: T) -> ObjectAccessControlInsertCall<'a, C>
21571    where
21572        T: AsRef<str>,
21573    {
21574        self._additional_params
21575            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21576        self
21577    }
21578
21579    /// Identifies the authorization scope for the method you are building.
21580    ///
21581    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21582    /// [`Scope::CloudPlatform`].
21583    ///
21584    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21585    /// tokens for more than one scope.
21586    ///
21587    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21588    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21589    /// sufficient, a read-write scope will do as well.
21590    pub fn add_scope<St>(mut self, scope: St) -> ObjectAccessControlInsertCall<'a, C>
21591    where
21592        St: AsRef<str>,
21593    {
21594        self._scopes.insert(String::from(scope.as_ref()));
21595        self
21596    }
21597    /// Identifies the authorization scope(s) for the method you are building.
21598    ///
21599    /// See [`Self::add_scope()`] for details.
21600    pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectAccessControlInsertCall<'a, C>
21601    where
21602        I: IntoIterator<Item = St>,
21603        St: AsRef<str>,
21604    {
21605        self._scopes
21606            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21607        self
21608    }
21609
21610    /// Removes all scopes, and no default scope will be used either.
21611    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21612    /// for details).
21613    pub fn clear_scopes(mut self) -> ObjectAccessControlInsertCall<'a, C> {
21614        self._scopes.clear();
21615        self
21616    }
21617}
21618
21619/// Retrieves ACL entries on the specified object.
21620///
21621/// A builder for the *list* method supported by a *objectAccessControl* resource.
21622/// It is not used directly, but through a [`ObjectAccessControlMethods`] instance.
21623///
21624/// # Example
21625///
21626/// Instantiate a resource method builder
21627///
21628/// ```test_harness,no_run
21629/// # extern crate hyper;
21630/// # extern crate hyper_rustls;
21631/// # extern crate google_storage1 as storage1;
21632/// # async fn dox() {
21633/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21634///
21635/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21636/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21637/// #     secret,
21638/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21639/// # ).build().await.unwrap();
21640///
21641/// # let client = hyper_util::client::legacy::Client::builder(
21642/// #     hyper_util::rt::TokioExecutor::new()
21643/// # )
21644/// # .build(
21645/// #     hyper_rustls::HttpsConnectorBuilder::new()
21646/// #         .with_native_roots()
21647/// #         .unwrap()
21648/// #         .https_or_http()
21649/// #         .enable_http1()
21650/// #         .build()
21651/// # );
21652/// # let mut hub = Storage::new(client, auth);
21653/// // You can configure optional parameters by calling the respective setters at will, and
21654/// // execute the final call using `doit()`.
21655/// // Values shown here are possibly random and not representative !
21656/// let result = hub.object_access_controls().list("bucket", "object")
21657///              .user_project("rebum.")
21658///              .generation(-27)
21659///              .doit().await;
21660/// # }
21661/// ```
21662pub struct ObjectAccessControlListCall<'a, C>
21663where
21664    C: 'a,
21665{
21666    hub: &'a Storage<C>,
21667    _bucket: String,
21668    _object: String,
21669    _user_project: Option<String>,
21670    _generation: Option<i64>,
21671    _delegate: Option<&'a mut dyn common::Delegate>,
21672    _additional_params: HashMap<String, String>,
21673    _scopes: BTreeSet<String>,
21674}
21675
21676impl<'a, C> common::CallBuilder for ObjectAccessControlListCall<'a, C> {}
21677
21678impl<'a, C> ObjectAccessControlListCall<'a, C>
21679where
21680    C: common::Connector,
21681{
21682    /// Perform the operation you have build so far.
21683    pub async fn doit(mut self) -> common::Result<(common::Response, ObjectAccessControls)> {
21684        use std::borrow::Cow;
21685        use std::io::{Read, Seek};
21686
21687        use common::{url::Params, ToParts};
21688        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21689
21690        let mut dd = common::DefaultDelegate;
21691        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21692        dlg.begin(common::MethodInfo {
21693            id: "storage.objectAccessControls.list",
21694            http_method: hyper::Method::GET,
21695        });
21696
21697        for &field in ["alt", "bucket", "object", "userProject", "generation"].iter() {
21698            if self._additional_params.contains_key(field) {
21699                dlg.finished(false);
21700                return Err(common::Error::FieldClash(field));
21701            }
21702        }
21703
21704        let mut params = Params::with_capacity(6 + self._additional_params.len());
21705        params.push("bucket", self._bucket);
21706        params.push("object", self._object);
21707        if let Some(value) = self._user_project.as_ref() {
21708            params.push("userProject", value);
21709        }
21710        if let Some(value) = self._generation.as_ref() {
21711            params.push("generation", value.to_string());
21712        }
21713
21714        params.extend(self._additional_params.iter());
21715
21716        params.push("alt", "json");
21717        let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}/acl";
21718        if self._scopes.is_empty() {
21719            self._scopes
21720                .insert(Scope::CloudPlatform.as_ref().to_string());
21721        }
21722
21723        #[allow(clippy::single_element_loop)]
21724        for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object")].iter() {
21725            url = params.uri_replacement(url, param_name, find_this, false);
21726        }
21727        {
21728            let to_remove = ["object", "bucket"];
21729            params.remove_params(&to_remove);
21730        }
21731
21732        let url = params.parse_with_url(&url);
21733
21734        loop {
21735            let token = match self
21736                .hub
21737                .auth
21738                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21739                .await
21740            {
21741                Ok(token) => token,
21742                Err(e) => match dlg.token(e) {
21743                    Ok(token) => token,
21744                    Err(e) => {
21745                        dlg.finished(false);
21746                        return Err(common::Error::MissingToken(e));
21747                    }
21748                },
21749            };
21750            let mut req_result = {
21751                let client = &self.hub.client;
21752                dlg.pre_request();
21753                let mut req_builder = hyper::Request::builder()
21754                    .method(hyper::Method::GET)
21755                    .uri(url.as_str())
21756                    .header(USER_AGENT, self.hub._user_agent.clone());
21757
21758                if let Some(token) = token.as_ref() {
21759                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21760                }
21761
21762                let request = req_builder
21763                    .header(CONTENT_LENGTH, 0_u64)
21764                    .body(common::to_body::<String>(None));
21765
21766                client.request(request.unwrap()).await
21767            };
21768
21769            match req_result {
21770                Err(err) => {
21771                    if let common::Retry::After(d) = dlg.http_error(&err) {
21772                        sleep(d).await;
21773                        continue;
21774                    }
21775                    dlg.finished(false);
21776                    return Err(common::Error::HttpError(err));
21777                }
21778                Ok(res) => {
21779                    let (mut parts, body) = res.into_parts();
21780                    let mut body = common::Body::new(body);
21781                    if !parts.status.is_success() {
21782                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21783                        let error = serde_json::from_str(&common::to_string(&bytes));
21784                        let response = common::to_response(parts, bytes.into());
21785
21786                        if let common::Retry::After(d) =
21787                            dlg.http_failure(&response, error.as_ref().ok())
21788                        {
21789                            sleep(d).await;
21790                            continue;
21791                        }
21792
21793                        dlg.finished(false);
21794
21795                        return Err(match error {
21796                            Ok(value) => common::Error::BadRequest(value),
21797                            _ => common::Error::Failure(response),
21798                        });
21799                    }
21800                    let response = {
21801                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21802                        let encoded = common::to_string(&bytes);
21803                        match serde_json::from_str(&encoded) {
21804                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21805                            Err(error) => {
21806                                dlg.response_json_decode_error(&encoded, &error);
21807                                return Err(common::Error::JsonDecodeError(
21808                                    encoded.to_string(),
21809                                    error,
21810                                ));
21811                            }
21812                        }
21813                    };
21814
21815                    dlg.finished(true);
21816                    return Ok(response);
21817                }
21818            }
21819        }
21820    }
21821
21822    /// Name of a bucket.
21823    ///
21824    /// Sets the *bucket* path property to the given value.
21825    ///
21826    /// Even though the property as already been set when instantiating this call,
21827    /// we provide this method for API completeness.
21828    pub fn bucket(mut self, new_value: &str) -> ObjectAccessControlListCall<'a, C> {
21829        self._bucket = new_value.to_string();
21830        self
21831    }
21832    /// Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
21833    ///
21834    /// Sets the *object* path property to the given value.
21835    ///
21836    /// Even though the property as already been set when instantiating this call,
21837    /// we provide this method for API completeness.
21838    pub fn object(mut self, new_value: &str) -> ObjectAccessControlListCall<'a, C> {
21839        self._object = new_value.to_string();
21840        self
21841    }
21842    /// The project to be billed for this request. Required for Requester Pays buckets.
21843    ///
21844    /// Sets the *user project* query property to the given value.
21845    pub fn user_project(mut self, new_value: &str) -> ObjectAccessControlListCall<'a, C> {
21846        self._user_project = Some(new_value.to_string());
21847        self
21848    }
21849    /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
21850    ///
21851    /// Sets the *generation* query property to the given value.
21852    pub fn generation(mut self, new_value: i64) -> ObjectAccessControlListCall<'a, C> {
21853        self._generation = Some(new_value);
21854        self
21855    }
21856    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21857    /// while executing the actual API request.
21858    ///
21859    /// ````text
21860    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21861    /// ````
21862    ///
21863    /// Sets the *delegate* property to the given value.
21864    pub fn delegate(
21865        mut self,
21866        new_value: &'a mut dyn common::Delegate,
21867    ) -> ObjectAccessControlListCall<'a, C> {
21868        self._delegate = Some(new_value);
21869        self
21870    }
21871
21872    /// Set any additional parameter of the query string used in the request.
21873    /// It should be used to set parameters which are not yet available through their own
21874    /// setters.
21875    ///
21876    /// Please note that this method must not be used to set any of the known parameters
21877    /// which have their own setter method. If done anyway, the request will fail.
21878    ///
21879    /// # Additional Parameters
21880    ///
21881    /// * *alt* (query-string) - Data format for the response.
21882    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21883    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
21884    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21885    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21886    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21887    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
21888    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21889    pub fn param<T>(mut self, name: T, value: T) -> ObjectAccessControlListCall<'a, C>
21890    where
21891        T: AsRef<str>,
21892    {
21893        self._additional_params
21894            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21895        self
21896    }
21897
21898    /// Identifies the authorization scope for the method you are building.
21899    ///
21900    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21901    /// [`Scope::CloudPlatform`].
21902    ///
21903    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21904    /// tokens for more than one scope.
21905    ///
21906    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21907    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21908    /// sufficient, a read-write scope will do as well.
21909    pub fn add_scope<St>(mut self, scope: St) -> ObjectAccessControlListCall<'a, C>
21910    where
21911        St: AsRef<str>,
21912    {
21913        self._scopes.insert(String::from(scope.as_ref()));
21914        self
21915    }
21916    /// Identifies the authorization scope(s) for the method you are building.
21917    ///
21918    /// See [`Self::add_scope()`] for details.
21919    pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectAccessControlListCall<'a, C>
21920    where
21921        I: IntoIterator<Item = St>,
21922        St: AsRef<str>,
21923    {
21924        self._scopes
21925            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21926        self
21927    }
21928
21929    /// Removes all scopes, and no default scope will be used either.
21930    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21931    /// for details).
21932    pub fn clear_scopes(mut self) -> ObjectAccessControlListCall<'a, C> {
21933        self._scopes.clear();
21934        self
21935    }
21936}
21937
21938/// Patches an ACL entry on the specified object.
21939///
21940/// A builder for the *patch* method supported by a *objectAccessControl* resource.
21941/// It is not used directly, but through a [`ObjectAccessControlMethods`] instance.
21942///
21943/// # Example
21944///
21945/// Instantiate a resource method builder
21946///
21947/// ```test_harness,no_run
21948/// # extern crate hyper;
21949/// # extern crate hyper_rustls;
21950/// # extern crate google_storage1 as storage1;
21951/// use storage1::api::ObjectAccessControl;
21952/// # async fn dox() {
21953/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21954///
21955/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21956/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21957/// #     secret,
21958/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21959/// # ).build().await.unwrap();
21960///
21961/// # let client = hyper_util::client::legacy::Client::builder(
21962/// #     hyper_util::rt::TokioExecutor::new()
21963/// # )
21964/// # .build(
21965/// #     hyper_rustls::HttpsConnectorBuilder::new()
21966/// #         .with_native_roots()
21967/// #         .unwrap()
21968/// #         .https_or_http()
21969/// #         .enable_http1()
21970/// #         .build()
21971/// # );
21972/// # let mut hub = Storage::new(client, auth);
21973/// // As the method needs a request, you would usually fill it with the desired information
21974/// // into the respective structure. Some of the parts shown here might not be applicable !
21975/// // Values shown here are possibly random and not representative !
21976/// let mut req = ObjectAccessControl::default();
21977///
21978/// // You can configure optional parameters by calling the respective setters at will, and
21979/// // execute the final call using `doit()`.
21980/// // Values shown here are possibly random and not representative !
21981/// let result = hub.object_access_controls().patch(req, "bucket", "object", "entity")
21982///              .user_project("aliquyam")
21983///              .generation(-37)
21984///              .doit().await;
21985/// # }
21986/// ```
21987pub struct ObjectAccessControlPatchCall<'a, C>
21988where
21989    C: 'a,
21990{
21991    hub: &'a Storage<C>,
21992    _request: ObjectAccessControl,
21993    _bucket: String,
21994    _object: String,
21995    _entity: String,
21996    _user_project: Option<String>,
21997    _generation: Option<i64>,
21998    _delegate: Option<&'a mut dyn common::Delegate>,
21999    _additional_params: HashMap<String, String>,
22000    _scopes: BTreeSet<String>,
22001}
22002
22003impl<'a, C> common::CallBuilder for ObjectAccessControlPatchCall<'a, C> {}
22004
22005impl<'a, C> ObjectAccessControlPatchCall<'a, C>
22006where
22007    C: common::Connector,
22008{
22009    /// Perform the operation you have build so far.
22010    pub async fn doit(mut self) -> common::Result<(common::Response, ObjectAccessControl)> {
22011        use std::borrow::Cow;
22012        use std::io::{Read, Seek};
22013
22014        use common::{url::Params, ToParts};
22015        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22016
22017        let mut dd = common::DefaultDelegate;
22018        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22019        dlg.begin(common::MethodInfo {
22020            id: "storage.objectAccessControls.patch",
22021            http_method: hyper::Method::PATCH,
22022        });
22023
22024        for &field in [
22025            "alt",
22026            "bucket",
22027            "object",
22028            "entity",
22029            "userProject",
22030            "generation",
22031        ]
22032        .iter()
22033        {
22034            if self._additional_params.contains_key(field) {
22035                dlg.finished(false);
22036                return Err(common::Error::FieldClash(field));
22037            }
22038        }
22039
22040        let mut params = Params::with_capacity(8 + self._additional_params.len());
22041        params.push("bucket", self._bucket);
22042        params.push("object", self._object);
22043        params.push("entity", self._entity);
22044        if let Some(value) = self._user_project.as_ref() {
22045            params.push("userProject", value);
22046        }
22047        if let Some(value) = self._generation.as_ref() {
22048            params.push("generation", value.to_string());
22049        }
22050
22051        params.extend(self._additional_params.iter());
22052
22053        params.push("alt", "json");
22054        let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}/acl/{entity}";
22055        if self._scopes.is_empty() {
22056            self._scopes
22057                .insert(Scope::CloudPlatform.as_ref().to_string());
22058        }
22059
22060        #[allow(clippy::single_element_loop)]
22061        for &(find_this, param_name) in [
22062            ("{bucket}", "bucket"),
22063            ("{object}", "object"),
22064            ("{entity}", "entity"),
22065        ]
22066        .iter()
22067        {
22068            url = params.uri_replacement(url, param_name, find_this, false);
22069        }
22070        {
22071            let to_remove = ["entity", "object", "bucket"];
22072            params.remove_params(&to_remove);
22073        }
22074
22075        let url = params.parse_with_url(&url);
22076
22077        let mut json_mime_type = mime::APPLICATION_JSON;
22078        let mut request_value_reader = {
22079            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22080            common::remove_json_null_values(&mut value);
22081            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22082            serde_json::to_writer(&mut dst, &value).unwrap();
22083            dst
22084        };
22085        let request_size = request_value_reader
22086            .seek(std::io::SeekFrom::End(0))
22087            .unwrap();
22088        request_value_reader
22089            .seek(std::io::SeekFrom::Start(0))
22090            .unwrap();
22091
22092        loop {
22093            let token = match self
22094                .hub
22095                .auth
22096                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22097                .await
22098            {
22099                Ok(token) => token,
22100                Err(e) => match dlg.token(e) {
22101                    Ok(token) => token,
22102                    Err(e) => {
22103                        dlg.finished(false);
22104                        return Err(common::Error::MissingToken(e));
22105                    }
22106                },
22107            };
22108            request_value_reader
22109                .seek(std::io::SeekFrom::Start(0))
22110                .unwrap();
22111            let mut req_result = {
22112                let client = &self.hub.client;
22113                dlg.pre_request();
22114                let mut req_builder = hyper::Request::builder()
22115                    .method(hyper::Method::PATCH)
22116                    .uri(url.as_str())
22117                    .header(USER_AGENT, self.hub._user_agent.clone());
22118
22119                if let Some(token) = token.as_ref() {
22120                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22121                }
22122
22123                let request = req_builder
22124                    .header(CONTENT_TYPE, json_mime_type.to_string())
22125                    .header(CONTENT_LENGTH, request_size as u64)
22126                    .body(common::to_body(
22127                        request_value_reader.get_ref().clone().into(),
22128                    ));
22129
22130                client.request(request.unwrap()).await
22131            };
22132
22133            match req_result {
22134                Err(err) => {
22135                    if let common::Retry::After(d) = dlg.http_error(&err) {
22136                        sleep(d).await;
22137                        continue;
22138                    }
22139                    dlg.finished(false);
22140                    return Err(common::Error::HttpError(err));
22141                }
22142                Ok(res) => {
22143                    let (mut parts, body) = res.into_parts();
22144                    let mut body = common::Body::new(body);
22145                    if !parts.status.is_success() {
22146                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22147                        let error = serde_json::from_str(&common::to_string(&bytes));
22148                        let response = common::to_response(parts, bytes.into());
22149
22150                        if let common::Retry::After(d) =
22151                            dlg.http_failure(&response, error.as_ref().ok())
22152                        {
22153                            sleep(d).await;
22154                            continue;
22155                        }
22156
22157                        dlg.finished(false);
22158
22159                        return Err(match error {
22160                            Ok(value) => common::Error::BadRequest(value),
22161                            _ => common::Error::Failure(response),
22162                        });
22163                    }
22164                    let response = {
22165                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22166                        let encoded = common::to_string(&bytes);
22167                        match serde_json::from_str(&encoded) {
22168                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22169                            Err(error) => {
22170                                dlg.response_json_decode_error(&encoded, &error);
22171                                return Err(common::Error::JsonDecodeError(
22172                                    encoded.to_string(),
22173                                    error,
22174                                ));
22175                            }
22176                        }
22177                    };
22178
22179                    dlg.finished(true);
22180                    return Ok(response);
22181                }
22182            }
22183        }
22184    }
22185
22186    ///
22187    /// Sets the *request* property to the given value.
22188    ///
22189    /// Even though the property as already been set when instantiating this call,
22190    /// we provide this method for API completeness.
22191    pub fn request(
22192        mut self,
22193        new_value: ObjectAccessControl,
22194    ) -> ObjectAccessControlPatchCall<'a, C> {
22195        self._request = new_value;
22196        self
22197    }
22198    /// Name of a bucket.
22199    ///
22200    /// Sets the *bucket* path property to the given value.
22201    ///
22202    /// Even though the property as already been set when instantiating this call,
22203    /// we provide this method for API completeness.
22204    pub fn bucket(mut self, new_value: &str) -> ObjectAccessControlPatchCall<'a, C> {
22205        self._bucket = new_value.to_string();
22206        self
22207    }
22208    /// Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
22209    ///
22210    /// Sets the *object* path property to the given value.
22211    ///
22212    /// Even though the property as already been set when instantiating this call,
22213    /// we provide this method for API completeness.
22214    pub fn object(mut self, new_value: &str) -> ObjectAccessControlPatchCall<'a, C> {
22215        self._object = new_value.to_string();
22216        self
22217    }
22218    /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
22219    ///
22220    /// Sets the *entity* path property to the given value.
22221    ///
22222    /// Even though the property as already been set when instantiating this call,
22223    /// we provide this method for API completeness.
22224    pub fn entity(mut self, new_value: &str) -> ObjectAccessControlPatchCall<'a, C> {
22225        self._entity = new_value.to_string();
22226        self
22227    }
22228    /// The project to be billed for this request. Required for Requester Pays buckets.
22229    ///
22230    /// Sets the *user project* query property to the given value.
22231    pub fn user_project(mut self, new_value: &str) -> ObjectAccessControlPatchCall<'a, C> {
22232        self._user_project = Some(new_value.to_string());
22233        self
22234    }
22235    /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
22236    ///
22237    /// Sets the *generation* query property to the given value.
22238    pub fn generation(mut self, new_value: i64) -> ObjectAccessControlPatchCall<'a, C> {
22239        self._generation = Some(new_value);
22240        self
22241    }
22242    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22243    /// while executing the actual API request.
22244    ///
22245    /// ````text
22246    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22247    /// ````
22248    ///
22249    /// Sets the *delegate* property to the given value.
22250    pub fn delegate(
22251        mut self,
22252        new_value: &'a mut dyn common::Delegate,
22253    ) -> ObjectAccessControlPatchCall<'a, C> {
22254        self._delegate = Some(new_value);
22255        self
22256    }
22257
22258    /// Set any additional parameter of the query string used in the request.
22259    /// It should be used to set parameters which are not yet available through their own
22260    /// setters.
22261    ///
22262    /// Please note that this method must not be used to set any of the known parameters
22263    /// which have their own setter method. If done anyway, the request will fail.
22264    ///
22265    /// # Additional Parameters
22266    ///
22267    /// * *alt* (query-string) - Data format for the response.
22268    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22269    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
22270    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22271    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22272    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
22273    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
22274    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
22275    pub fn param<T>(mut self, name: T, value: T) -> ObjectAccessControlPatchCall<'a, C>
22276    where
22277        T: AsRef<str>,
22278    {
22279        self._additional_params
22280            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22281        self
22282    }
22283
22284    /// Identifies the authorization scope for the method you are building.
22285    ///
22286    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22287    /// [`Scope::CloudPlatform`].
22288    ///
22289    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22290    /// tokens for more than one scope.
22291    ///
22292    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22293    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22294    /// sufficient, a read-write scope will do as well.
22295    pub fn add_scope<St>(mut self, scope: St) -> ObjectAccessControlPatchCall<'a, C>
22296    where
22297        St: AsRef<str>,
22298    {
22299        self._scopes.insert(String::from(scope.as_ref()));
22300        self
22301    }
22302    /// Identifies the authorization scope(s) for the method you are building.
22303    ///
22304    /// See [`Self::add_scope()`] for details.
22305    pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectAccessControlPatchCall<'a, C>
22306    where
22307        I: IntoIterator<Item = St>,
22308        St: AsRef<str>,
22309    {
22310        self._scopes
22311            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22312        self
22313    }
22314
22315    /// Removes all scopes, and no default scope will be used either.
22316    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22317    /// for details).
22318    pub fn clear_scopes(mut self) -> ObjectAccessControlPatchCall<'a, C> {
22319        self._scopes.clear();
22320        self
22321    }
22322}
22323
22324/// Updates an ACL entry on the specified object.
22325///
22326/// A builder for the *update* method supported by a *objectAccessControl* resource.
22327/// It is not used directly, but through a [`ObjectAccessControlMethods`] instance.
22328///
22329/// # Example
22330///
22331/// Instantiate a resource method builder
22332///
22333/// ```test_harness,no_run
22334/// # extern crate hyper;
22335/// # extern crate hyper_rustls;
22336/// # extern crate google_storage1 as storage1;
22337/// use storage1::api::ObjectAccessControl;
22338/// # async fn dox() {
22339/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22340///
22341/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22342/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22343/// #     secret,
22344/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22345/// # ).build().await.unwrap();
22346///
22347/// # let client = hyper_util::client::legacy::Client::builder(
22348/// #     hyper_util::rt::TokioExecutor::new()
22349/// # )
22350/// # .build(
22351/// #     hyper_rustls::HttpsConnectorBuilder::new()
22352/// #         .with_native_roots()
22353/// #         .unwrap()
22354/// #         .https_or_http()
22355/// #         .enable_http1()
22356/// #         .build()
22357/// # );
22358/// # let mut hub = Storage::new(client, auth);
22359/// // As the method needs a request, you would usually fill it with the desired information
22360/// // into the respective structure. Some of the parts shown here might not be applicable !
22361/// // Values shown here are possibly random and not representative !
22362/// let mut req = ObjectAccessControl::default();
22363///
22364/// // You can configure optional parameters by calling the respective setters at will, and
22365/// // execute the final call using `doit()`.
22366/// // Values shown here are possibly random and not representative !
22367/// let result = hub.object_access_controls().update(req, "bucket", "object", "entity")
22368///              .user_project("dolores")
22369///              .generation(-96)
22370///              .doit().await;
22371/// # }
22372/// ```
22373pub struct ObjectAccessControlUpdateCall<'a, C>
22374where
22375    C: 'a,
22376{
22377    hub: &'a Storage<C>,
22378    _request: ObjectAccessControl,
22379    _bucket: String,
22380    _object: String,
22381    _entity: String,
22382    _user_project: Option<String>,
22383    _generation: Option<i64>,
22384    _delegate: Option<&'a mut dyn common::Delegate>,
22385    _additional_params: HashMap<String, String>,
22386    _scopes: BTreeSet<String>,
22387}
22388
22389impl<'a, C> common::CallBuilder for ObjectAccessControlUpdateCall<'a, C> {}
22390
22391impl<'a, C> ObjectAccessControlUpdateCall<'a, C>
22392where
22393    C: common::Connector,
22394{
22395    /// Perform the operation you have build so far.
22396    pub async fn doit(mut self) -> common::Result<(common::Response, ObjectAccessControl)> {
22397        use std::borrow::Cow;
22398        use std::io::{Read, Seek};
22399
22400        use common::{url::Params, ToParts};
22401        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22402
22403        let mut dd = common::DefaultDelegate;
22404        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22405        dlg.begin(common::MethodInfo {
22406            id: "storage.objectAccessControls.update",
22407            http_method: hyper::Method::PUT,
22408        });
22409
22410        for &field in [
22411            "alt",
22412            "bucket",
22413            "object",
22414            "entity",
22415            "userProject",
22416            "generation",
22417        ]
22418        .iter()
22419        {
22420            if self._additional_params.contains_key(field) {
22421                dlg.finished(false);
22422                return Err(common::Error::FieldClash(field));
22423            }
22424        }
22425
22426        let mut params = Params::with_capacity(8 + self._additional_params.len());
22427        params.push("bucket", self._bucket);
22428        params.push("object", self._object);
22429        params.push("entity", self._entity);
22430        if let Some(value) = self._user_project.as_ref() {
22431            params.push("userProject", value);
22432        }
22433        if let Some(value) = self._generation.as_ref() {
22434            params.push("generation", value.to_string());
22435        }
22436
22437        params.extend(self._additional_params.iter());
22438
22439        params.push("alt", "json");
22440        let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}/acl/{entity}";
22441        if self._scopes.is_empty() {
22442            self._scopes
22443                .insert(Scope::CloudPlatform.as_ref().to_string());
22444        }
22445
22446        #[allow(clippy::single_element_loop)]
22447        for &(find_this, param_name) in [
22448            ("{bucket}", "bucket"),
22449            ("{object}", "object"),
22450            ("{entity}", "entity"),
22451        ]
22452        .iter()
22453        {
22454            url = params.uri_replacement(url, param_name, find_this, false);
22455        }
22456        {
22457            let to_remove = ["entity", "object", "bucket"];
22458            params.remove_params(&to_remove);
22459        }
22460
22461        let url = params.parse_with_url(&url);
22462
22463        let mut json_mime_type = mime::APPLICATION_JSON;
22464        let mut request_value_reader = {
22465            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22466            common::remove_json_null_values(&mut value);
22467            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22468            serde_json::to_writer(&mut dst, &value).unwrap();
22469            dst
22470        };
22471        let request_size = request_value_reader
22472            .seek(std::io::SeekFrom::End(0))
22473            .unwrap();
22474        request_value_reader
22475            .seek(std::io::SeekFrom::Start(0))
22476            .unwrap();
22477
22478        loop {
22479            let token = match self
22480                .hub
22481                .auth
22482                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22483                .await
22484            {
22485                Ok(token) => token,
22486                Err(e) => match dlg.token(e) {
22487                    Ok(token) => token,
22488                    Err(e) => {
22489                        dlg.finished(false);
22490                        return Err(common::Error::MissingToken(e));
22491                    }
22492                },
22493            };
22494            request_value_reader
22495                .seek(std::io::SeekFrom::Start(0))
22496                .unwrap();
22497            let mut req_result = {
22498                let client = &self.hub.client;
22499                dlg.pre_request();
22500                let mut req_builder = hyper::Request::builder()
22501                    .method(hyper::Method::PUT)
22502                    .uri(url.as_str())
22503                    .header(USER_AGENT, self.hub._user_agent.clone());
22504
22505                if let Some(token) = token.as_ref() {
22506                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22507                }
22508
22509                let request = req_builder
22510                    .header(CONTENT_TYPE, json_mime_type.to_string())
22511                    .header(CONTENT_LENGTH, request_size as u64)
22512                    .body(common::to_body(
22513                        request_value_reader.get_ref().clone().into(),
22514                    ));
22515
22516                client.request(request.unwrap()).await
22517            };
22518
22519            match req_result {
22520                Err(err) => {
22521                    if let common::Retry::After(d) = dlg.http_error(&err) {
22522                        sleep(d).await;
22523                        continue;
22524                    }
22525                    dlg.finished(false);
22526                    return Err(common::Error::HttpError(err));
22527                }
22528                Ok(res) => {
22529                    let (mut parts, body) = res.into_parts();
22530                    let mut body = common::Body::new(body);
22531                    if !parts.status.is_success() {
22532                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22533                        let error = serde_json::from_str(&common::to_string(&bytes));
22534                        let response = common::to_response(parts, bytes.into());
22535
22536                        if let common::Retry::After(d) =
22537                            dlg.http_failure(&response, error.as_ref().ok())
22538                        {
22539                            sleep(d).await;
22540                            continue;
22541                        }
22542
22543                        dlg.finished(false);
22544
22545                        return Err(match error {
22546                            Ok(value) => common::Error::BadRequest(value),
22547                            _ => common::Error::Failure(response),
22548                        });
22549                    }
22550                    let response = {
22551                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22552                        let encoded = common::to_string(&bytes);
22553                        match serde_json::from_str(&encoded) {
22554                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22555                            Err(error) => {
22556                                dlg.response_json_decode_error(&encoded, &error);
22557                                return Err(common::Error::JsonDecodeError(
22558                                    encoded.to_string(),
22559                                    error,
22560                                ));
22561                            }
22562                        }
22563                    };
22564
22565                    dlg.finished(true);
22566                    return Ok(response);
22567                }
22568            }
22569        }
22570    }
22571
22572    ///
22573    /// Sets the *request* property to the given value.
22574    ///
22575    /// Even though the property as already been set when instantiating this call,
22576    /// we provide this method for API completeness.
22577    pub fn request(
22578        mut self,
22579        new_value: ObjectAccessControl,
22580    ) -> ObjectAccessControlUpdateCall<'a, C> {
22581        self._request = new_value;
22582        self
22583    }
22584    /// Name of a bucket.
22585    ///
22586    /// Sets the *bucket* path property to the given value.
22587    ///
22588    /// Even though the property as already been set when instantiating this call,
22589    /// we provide this method for API completeness.
22590    pub fn bucket(mut self, new_value: &str) -> ObjectAccessControlUpdateCall<'a, C> {
22591        self._bucket = new_value.to_string();
22592        self
22593    }
22594    /// Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
22595    ///
22596    /// Sets the *object* path property to the given value.
22597    ///
22598    /// Even though the property as already been set when instantiating this call,
22599    /// we provide this method for API completeness.
22600    pub fn object(mut self, new_value: &str) -> ObjectAccessControlUpdateCall<'a, C> {
22601        self._object = new_value.to_string();
22602        self
22603    }
22604    /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
22605    ///
22606    /// Sets the *entity* path property to the given value.
22607    ///
22608    /// Even though the property as already been set when instantiating this call,
22609    /// we provide this method for API completeness.
22610    pub fn entity(mut self, new_value: &str) -> ObjectAccessControlUpdateCall<'a, C> {
22611        self._entity = new_value.to_string();
22612        self
22613    }
22614    /// The project to be billed for this request. Required for Requester Pays buckets.
22615    ///
22616    /// Sets the *user project* query property to the given value.
22617    pub fn user_project(mut self, new_value: &str) -> ObjectAccessControlUpdateCall<'a, C> {
22618        self._user_project = Some(new_value.to_string());
22619        self
22620    }
22621    /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
22622    ///
22623    /// Sets the *generation* query property to the given value.
22624    pub fn generation(mut self, new_value: i64) -> ObjectAccessControlUpdateCall<'a, C> {
22625        self._generation = Some(new_value);
22626        self
22627    }
22628    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22629    /// while executing the actual API request.
22630    ///
22631    /// ````text
22632    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22633    /// ````
22634    ///
22635    /// Sets the *delegate* property to the given value.
22636    pub fn delegate(
22637        mut self,
22638        new_value: &'a mut dyn common::Delegate,
22639    ) -> ObjectAccessControlUpdateCall<'a, C> {
22640        self._delegate = Some(new_value);
22641        self
22642    }
22643
22644    /// Set any additional parameter of the query string used in the request.
22645    /// It should be used to set parameters which are not yet available through their own
22646    /// setters.
22647    ///
22648    /// Please note that this method must not be used to set any of the known parameters
22649    /// which have their own setter method. If done anyway, the request will fail.
22650    ///
22651    /// # Additional Parameters
22652    ///
22653    /// * *alt* (query-string) - Data format for the response.
22654    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22655    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
22656    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22657    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22658    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
22659    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
22660    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
22661    pub fn param<T>(mut self, name: T, value: T) -> ObjectAccessControlUpdateCall<'a, C>
22662    where
22663        T: AsRef<str>,
22664    {
22665        self._additional_params
22666            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22667        self
22668    }
22669
22670    /// Identifies the authorization scope for the method you are building.
22671    ///
22672    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22673    /// [`Scope::CloudPlatform`].
22674    ///
22675    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22676    /// tokens for more than one scope.
22677    ///
22678    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22679    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22680    /// sufficient, a read-write scope will do as well.
22681    pub fn add_scope<St>(mut self, scope: St) -> ObjectAccessControlUpdateCall<'a, C>
22682    where
22683        St: AsRef<str>,
22684    {
22685        self._scopes.insert(String::from(scope.as_ref()));
22686        self
22687    }
22688    /// Identifies the authorization scope(s) for the method you are building.
22689    ///
22690    /// See [`Self::add_scope()`] for details.
22691    pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectAccessControlUpdateCall<'a, C>
22692    where
22693        I: IntoIterator<Item = St>,
22694        St: AsRef<str>,
22695    {
22696        self._scopes
22697            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22698        self
22699    }
22700
22701    /// Removes all scopes, and no default scope will be used either.
22702    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22703    /// for details).
22704    pub fn clear_scopes(mut self) -> ObjectAccessControlUpdateCall<'a, C> {
22705        self._scopes.clear();
22706        self
22707    }
22708}
22709
22710/// Initiates a long-running bulk restore operation on the specified bucket.
22711///
22712/// A builder for the *bulkRestore* method supported by a *object* resource.
22713/// It is not used directly, but through a [`ObjectMethods`] instance.
22714///
22715/// # Example
22716///
22717/// Instantiate a resource method builder
22718///
22719/// ```test_harness,no_run
22720/// # extern crate hyper;
22721/// # extern crate hyper_rustls;
22722/// # extern crate google_storage1 as storage1;
22723/// use storage1::api::BulkRestoreObjectsRequest;
22724/// # async fn dox() {
22725/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22726///
22727/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22728/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22729/// #     secret,
22730/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22731/// # ).build().await.unwrap();
22732///
22733/// # let client = hyper_util::client::legacy::Client::builder(
22734/// #     hyper_util::rt::TokioExecutor::new()
22735/// # )
22736/// # .build(
22737/// #     hyper_rustls::HttpsConnectorBuilder::new()
22738/// #         .with_native_roots()
22739/// #         .unwrap()
22740/// #         .https_or_http()
22741/// #         .enable_http1()
22742/// #         .build()
22743/// # );
22744/// # let mut hub = Storage::new(client, auth);
22745/// // As the method needs a request, you would usually fill it with the desired information
22746/// // into the respective structure. Some of the parts shown here might not be applicable !
22747/// // Values shown here are possibly random and not representative !
22748/// let mut req = BulkRestoreObjectsRequest::default();
22749///
22750/// // You can configure optional parameters by calling the respective setters at will, and
22751/// // execute the final call using `doit()`.
22752/// // Values shown here are possibly random and not representative !
22753/// let result = hub.objects().bulk_restore(req, "bucket")
22754///              .doit().await;
22755/// # }
22756/// ```
22757pub struct ObjectBulkRestoreCall<'a, C>
22758where
22759    C: 'a,
22760{
22761    hub: &'a Storage<C>,
22762    _request: BulkRestoreObjectsRequest,
22763    _bucket: String,
22764    _delegate: Option<&'a mut dyn common::Delegate>,
22765    _additional_params: HashMap<String, String>,
22766    _scopes: BTreeSet<String>,
22767}
22768
22769impl<'a, C> common::CallBuilder for ObjectBulkRestoreCall<'a, C> {}
22770
22771impl<'a, C> ObjectBulkRestoreCall<'a, C>
22772where
22773    C: common::Connector,
22774{
22775    /// Perform the operation you have build so far.
22776    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
22777        use std::borrow::Cow;
22778        use std::io::{Read, Seek};
22779
22780        use common::{url::Params, ToParts};
22781        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22782
22783        let mut dd = common::DefaultDelegate;
22784        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22785        dlg.begin(common::MethodInfo {
22786            id: "storage.objects.bulkRestore",
22787            http_method: hyper::Method::POST,
22788        });
22789
22790        for &field in ["alt", "bucket"].iter() {
22791            if self._additional_params.contains_key(field) {
22792                dlg.finished(false);
22793                return Err(common::Error::FieldClash(field));
22794            }
22795        }
22796
22797        let mut params = Params::with_capacity(4 + self._additional_params.len());
22798        params.push("bucket", self._bucket);
22799
22800        params.extend(self._additional_params.iter());
22801
22802        params.push("alt", "json");
22803        let mut url = self.hub._base_url.clone() + "b/{bucket}/o/bulkRestore";
22804        if self._scopes.is_empty() {
22805            self._scopes
22806                .insert(Scope::CloudPlatform.as_ref().to_string());
22807        }
22808
22809        #[allow(clippy::single_element_loop)]
22810        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
22811            url = params.uri_replacement(url, param_name, find_this, false);
22812        }
22813        {
22814            let to_remove = ["bucket"];
22815            params.remove_params(&to_remove);
22816        }
22817
22818        let url = params.parse_with_url(&url);
22819
22820        let mut json_mime_type = mime::APPLICATION_JSON;
22821        let mut request_value_reader = {
22822            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22823            common::remove_json_null_values(&mut value);
22824            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22825            serde_json::to_writer(&mut dst, &value).unwrap();
22826            dst
22827        };
22828        let request_size = request_value_reader
22829            .seek(std::io::SeekFrom::End(0))
22830            .unwrap();
22831        request_value_reader
22832            .seek(std::io::SeekFrom::Start(0))
22833            .unwrap();
22834
22835        loop {
22836            let token = match self
22837                .hub
22838                .auth
22839                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22840                .await
22841            {
22842                Ok(token) => token,
22843                Err(e) => match dlg.token(e) {
22844                    Ok(token) => token,
22845                    Err(e) => {
22846                        dlg.finished(false);
22847                        return Err(common::Error::MissingToken(e));
22848                    }
22849                },
22850            };
22851            request_value_reader
22852                .seek(std::io::SeekFrom::Start(0))
22853                .unwrap();
22854            let mut req_result = {
22855                let client = &self.hub.client;
22856                dlg.pre_request();
22857                let mut req_builder = hyper::Request::builder()
22858                    .method(hyper::Method::POST)
22859                    .uri(url.as_str())
22860                    .header(USER_AGENT, self.hub._user_agent.clone());
22861
22862                if let Some(token) = token.as_ref() {
22863                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22864                }
22865
22866                let request = req_builder
22867                    .header(CONTENT_TYPE, json_mime_type.to_string())
22868                    .header(CONTENT_LENGTH, request_size as u64)
22869                    .body(common::to_body(
22870                        request_value_reader.get_ref().clone().into(),
22871                    ));
22872
22873                client.request(request.unwrap()).await
22874            };
22875
22876            match req_result {
22877                Err(err) => {
22878                    if let common::Retry::After(d) = dlg.http_error(&err) {
22879                        sleep(d).await;
22880                        continue;
22881                    }
22882                    dlg.finished(false);
22883                    return Err(common::Error::HttpError(err));
22884                }
22885                Ok(res) => {
22886                    let (mut parts, body) = res.into_parts();
22887                    let mut body = common::Body::new(body);
22888                    if !parts.status.is_success() {
22889                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22890                        let error = serde_json::from_str(&common::to_string(&bytes));
22891                        let response = common::to_response(parts, bytes.into());
22892
22893                        if let common::Retry::After(d) =
22894                            dlg.http_failure(&response, error.as_ref().ok())
22895                        {
22896                            sleep(d).await;
22897                            continue;
22898                        }
22899
22900                        dlg.finished(false);
22901
22902                        return Err(match error {
22903                            Ok(value) => common::Error::BadRequest(value),
22904                            _ => common::Error::Failure(response),
22905                        });
22906                    }
22907                    let response = {
22908                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22909                        let encoded = common::to_string(&bytes);
22910                        match serde_json::from_str(&encoded) {
22911                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22912                            Err(error) => {
22913                                dlg.response_json_decode_error(&encoded, &error);
22914                                return Err(common::Error::JsonDecodeError(
22915                                    encoded.to_string(),
22916                                    error,
22917                                ));
22918                            }
22919                        }
22920                    };
22921
22922                    dlg.finished(true);
22923                    return Ok(response);
22924                }
22925            }
22926        }
22927    }
22928
22929    ///
22930    /// Sets the *request* property to the given value.
22931    ///
22932    /// Even though the property as already been set when instantiating this call,
22933    /// we provide this method for API completeness.
22934    pub fn request(mut self, new_value: BulkRestoreObjectsRequest) -> ObjectBulkRestoreCall<'a, C> {
22935        self._request = new_value;
22936        self
22937    }
22938    /// Name of the bucket in which the object resides.
22939    ///
22940    /// Sets the *bucket* path property to the given value.
22941    ///
22942    /// Even though the property as already been set when instantiating this call,
22943    /// we provide this method for API completeness.
22944    pub fn bucket(mut self, new_value: &str) -> ObjectBulkRestoreCall<'a, C> {
22945        self._bucket = new_value.to_string();
22946        self
22947    }
22948    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22949    /// while executing the actual API request.
22950    ///
22951    /// ````text
22952    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22953    /// ````
22954    ///
22955    /// Sets the *delegate* property to the given value.
22956    pub fn delegate(
22957        mut self,
22958        new_value: &'a mut dyn common::Delegate,
22959    ) -> ObjectBulkRestoreCall<'a, C> {
22960        self._delegate = Some(new_value);
22961        self
22962    }
22963
22964    /// Set any additional parameter of the query string used in the request.
22965    /// It should be used to set parameters which are not yet available through their own
22966    /// setters.
22967    ///
22968    /// Please note that this method must not be used to set any of the known parameters
22969    /// which have their own setter method. If done anyway, the request will fail.
22970    ///
22971    /// # Additional Parameters
22972    ///
22973    /// * *alt* (query-string) - Data format for the response.
22974    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22975    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
22976    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22977    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22978    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
22979    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
22980    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
22981    pub fn param<T>(mut self, name: T, value: T) -> ObjectBulkRestoreCall<'a, C>
22982    where
22983        T: AsRef<str>,
22984    {
22985        self._additional_params
22986            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22987        self
22988    }
22989
22990    /// Identifies the authorization scope for the method you are building.
22991    ///
22992    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22993    /// [`Scope::CloudPlatform`].
22994    ///
22995    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22996    /// tokens for more than one scope.
22997    ///
22998    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22999    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23000    /// sufficient, a read-write scope will do as well.
23001    pub fn add_scope<St>(mut self, scope: St) -> ObjectBulkRestoreCall<'a, C>
23002    where
23003        St: AsRef<str>,
23004    {
23005        self._scopes.insert(String::from(scope.as_ref()));
23006        self
23007    }
23008    /// Identifies the authorization scope(s) for the method you are building.
23009    ///
23010    /// See [`Self::add_scope()`] for details.
23011    pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectBulkRestoreCall<'a, C>
23012    where
23013        I: IntoIterator<Item = St>,
23014        St: AsRef<str>,
23015    {
23016        self._scopes
23017            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23018        self
23019    }
23020
23021    /// Removes all scopes, and no default scope will be used either.
23022    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23023    /// for details).
23024    pub fn clear_scopes(mut self) -> ObjectBulkRestoreCall<'a, C> {
23025        self._scopes.clear();
23026        self
23027    }
23028}
23029
23030/// Concatenates a list of existing objects into a new object in the same bucket.
23031///
23032/// A builder for the *compose* method supported by a *object* resource.
23033/// It is not used directly, but through a [`ObjectMethods`] instance.
23034///
23035/// # Example
23036///
23037/// Instantiate a resource method builder
23038///
23039/// ```test_harness,no_run
23040/// # extern crate hyper;
23041/// # extern crate hyper_rustls;
23042/// # extern crate google_storage1 as storage1;
23043/// use storage1::api::ComposeRequest;
23044/// # async fn dox() {
23045/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23046///
23047/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23048/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23049/// #     secret,
23050/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23051/// # ).build().await.unwrap();
23052///
23053/// # let client = hyper_util::client::legacy::Client::builder(
23054/// #     hyper_util::rt::TokioExecutor::new()
23055/// # )
23056/// # .build(
23057/// #     hyper_rustls::HttpsConnectorBuilder::new()
23058/// #         .with_native_roots()
23059/// #         .unwrap()
23060/// #         .https_or_http()
23061/// #         .enable_http1()
23062/// #         .build()
23063/// # );
23064/// # let mut hub = Storage::new(client, auth);
23065/// // As the method needs a request, you would usually fill it with the desired information
23066/// // into the respective structure. Some of the parts shown here might not be applicable !
23067/// // Values shown here are possibly random and not representative !
23068/// let mut req = ComposeRequest::default();
23069///
23070/// // You can configure optional parameters by calling the respective setters at will, and
23071/// // execute the final call using `doit()`.
23072/// // Values shown here are possibly random and not representative !
23073/// let result = hub.objects().compose(req, "destinationBucket", "destinationObject")
23074///              .user_project("clita")
23075///              .kms_key_name("dolor")
23076///              .if_metageneration_match(-82)
23077///              .if_generation_match(-83)
23078///              .destination_predefined_acl("diam")
23079///              .doit().await;
23080/// # }
23081/// ```
23082pub struct ObjectComposeCall<'a, C>
23083where
23084    C: 'a,
23085{
23086    hub: &'a Storage<C>,
23087    _request: ComposeRequest,
23088    _destination_bucket: String,
23089    _destination_object: String,
23090    _user_project: Option<String>,
23091    _kms_key_name: Option<String>,
23092    _if_metageneration_match: Option<i64>,
23093    _if_generation_match: Option<i64>,
23094    _destination_predefined_acl: Option<String>,
23095    _delegate: Option<&'a mut dyn common::Delegate>,
23096    _additional_params: HashMap<String, String>,
23097    _scopes: BTreeSet<String>,
23098}
23099
23100impl<'a, C> common::CallBuilder for ObjectComposeCall<'a, C> {}
23101
23102impl<'a, C> ObjectComposeCall<'a, C>
23103where
23104    C: common::Connector,
23105{
23106    /// Perform the operation you have build so far.
23107    pub async fn doit(mut self) -> common::Result<(common::Response, Object)> {
23108        use std::borrow::Cow;
23109        use std::io::{Read, Seek};
23110
23111        use common::{url::Params, ToParts};
23112        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23113
23114        let mut dd = common::DefaultDelegate;
23115        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23116        dlg.begin(common::MethodInfo {
23117            id: "storage.objects.compose",
23118            http_method: hyper::Method::POST,
23119        });
23120
23121        for &field in [
23122            "alt",
23123            "destinationBucket",
23124            "destinationObject",
23125            "userProject",
23126            "kmsKeyName",
23127            "ifMetagenerationMatch",
23128            "ifGenerationMatch",
23129            "destinationPredefinedAcl",
23130        ]
23131        .iter()
23132        {
23133            if self._additional_params.contains_key(field) {
23134                dlg.finished(false);
23135                return Err(common::Error::FieldClash(field));
23136            }
23137        }
23138
23139        let mut params = Params::with_capacity(10 + self._additional_params.len());
23140        params.push("destinationBucket", self._destination_bucket);
23141        params.push("destinationObject", self._destination_object);
23142        if let Some(value) = self._user_project.as_ref() {
23143            params.push("userProject", value);
23144        }
23145        if let Some(value) = self._kms_key_name.as_ref() {
23146            params.push("kmsKeyName", value);
23147        }
23148        if let Some(value) = self._if_metageneration_match.as_ref() {
23149            params.push("ifMetagenerationMatch", value.to_string());
23150        }
23151        if let Some(value) = self._if_generation_match.as_ref() {
23152            params.push("ifGenerationMatch", value.to_string());
23153        }
23154        if let Some(value) = self._destination_predefined_acl.as_ref() {
23155            params.push("destinationPredefinedAcl", value);
23156        }
23157
23158        params.extend(self._additional_params.iter());
23159
23160        params.push("alt", "json");
23161        let mut url =
23162            self.hub._base_url.clone() + "b/{destinationBucket}/o/{destinationObject}/compose";
23163        if self._scopes.is_empty() {
23164            self._scopes
23165                .insert(Scope::CloudPlatform.as_ref().to_string());
23166        }
23167
23168        #[allow(clippy::single_element_loop)]
23169        for &(find_this, param_name) in [
23170            ("{destinationBucket}", "destinationBucket"),
23171            ("{destinationObject}", "destinationObject"),
23172        ]
23173        .iter()
23174        {
23175            url = params.uri_replacement(url, param_name, find_this, false);
23176        }
23177        {
23178            let to_remove = ["destinationObject", "destinationBucket"];
23179            params.remove_params(&to_remove);
23180        }
23181
23182        let url = params.parse_with_url(&url);
23183
23184        let mut json_mime_type = mime::APPLICATION_JSON;
23185        let mut request_value_reader = {
23186            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23187            common::remove_json_null_values(&mut value);
23188            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23189            serde_json::to_writer(&mut dst, &value).unwrap();
23190            dst
23191        };
23192        let request_size = request_value_reader
23193            .seek(std::io::SeekFrom::End(0))
23194            .unwrap();
23195        request_value_reader
23196            .seek(std::io::SeekFrom::Start(0))
23197            .unwrap();
23198
23199        loop {
23200            let token = match self
23201                .hub
23202                .auth
23203                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23204                .await
23205            {
23206                Ok(token) => token,
23207                Err(e) => match dlg.token(e) {
23208                    Ok(token) => token,
23209                    Err(e) => {
23210                        dlg.finished(false);
23211                        return Err(common::Error::MissingToken(e));
23212                    }
23213                },
23214            };
23215            request_value_reader
23216                .seek(std::io::SeekFrom::Start(0))
23217                .unwrap();
23218            let mut req_result = {
23219                let client = &self.hub.client;
23220                dlg.pre_request();
23221                let mut req_builder = hyper::Request::builder()
23222                    .method(hyper::Method::POST)
23223                    .uri(url.as_str())
23224                    .header(USER_AGENT, self.hub._user_agent.clone());
23225
23226                if let Some(token) = token.as_ref() {
23227                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23228                }
23229
23230                let request = req_builder
23231                    .header(CONTENT_TYPE, json_mime_type.to_string())
23232                    .header(CONTENT_LENGTH, request_size as u64)
23233                    .body(common::to_body(
23234                        request_value_reader.get_ref().clone().into(),
23235                    ));
23236
23237                client.request(request.unwrap()).await
23238            };
23239
23240            match req_result {
23241                Err(err) => {
23242                    if let common::Retry::After(d) = dlg.http_error(&err) {
23243                        sleep(d).await;
23244                        continue;
23245                    }
23246                    dlg.finished(false);
23247                    return Err(common::Error::HttpError(err));
23248                }
23249                Ok(res) => {
23250                    let (mut parts, body) = res.into_parts();
23251                    let mut body = common::Body::new(body);
23252                    if !parts.status.is_success() {
23253                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23254                        let error = serde_json::from_str(&common::to_string(&bytes));
23255                        let response = common::to_response(parts, bytes.into());
23256
23257                        if let common::Retry::After(d) =
23258                            dlg.http_failure(&response, error.as_ref().ok())
23259                        {
23260                            sleep(d).await;
23261                            continue;
23262                        }
23263
23264                        dlg.finished(false);
23265
23266                        return Err(match error {
23267                            Ok(value) => common::Error::BadRequest(value),
23268                            _ => common::Error::Failure(response),
23269                        });
23270                    }
23271                    let response = {
23272                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23273                        let encoded = common::to_string(&bytes);
23274                        match serde_json::from_str(&encoded) {
23275                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23276                            Err(error) => {
23277                                dlg.response_json_decode_error(&encoded, &error);
23278                                return Err(common::Error::JsonDecodeError(
23279                                    encoded.to_string(),
23280                                    error,
23281                                ));
23282                            }
23283                        }
23284                    };
23285
23286                    dlg.finished(true);
23287                    return Ok(response);
23288                }
23289            }
23290        }
23291    }
23292
23293    ///
23294    /// Sets the *request* property to the given value.
23295    ///
23296    /// Even though the property as already been set when instantiating this call,
23297    /// we provide this method for API completeness.
23298    pub fn request(mut self, new_value: ComposeRequest) -> ObjectComposeCall<'a, C> {
23299        self._request = new_value;
23300        self
23301    }
23302    /// Name of the bucket containing the source objects. The destination object is stored in this bucket.
23303    ///
23304    /// Sets the *destination bucket* path property to the given value.
23305    ///
23306    /// Even though the property as already been set when instantiating this call,
23307    /// we provide this method for API completeness.
23308    pub fn destination_bucket(mut self, new_value: &str) -> ObjectComposeCall<'a, C> {
23309        self._destination_bucket = new_value.to_string();
23310        self
23311    }
23312    /// Name of the new object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
23313    ///
23314    /// Sets the *destination object* path property to the given value.
23315    ///
23316    /// Even though the property as already been set when instantiating this call,
23317    /// we provide this method for API completeness.
23318    pub fn destination_object(mut self, new_value: &str) -> ObjectComposeCall<'a, C> {
23319        self._destination_object = new_value.to_string();
23320        self
23321    }
23322    /// The project to be billed for this request. Required for Requester Pays buckets.
23323    ///
23324    /// Sets the *user project* query property to the given value.
23325    pub fn user_project(mut self, new_value: &str) -> ObjectComposeCall<'a, C> {
23326        self._user_project = Some(new_value.to_string());
23327        self
23328    }
23329    /// Resource name of the Cloud KMS key, of the form projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key, that will be used to encrypt the object. Overrides the object metadata's kms_key_name value, if any.
23330    ///
23331    /// Sets the *kms key name* query property to the given value.
23332    pub fn kms_key_name(mut self, new_value: &str) -> ObjectComposeCall<'a, C> {
23333        self._kms_key_name = Some(new_value.to_string());
23334        self
23335    }
23336    /// Makes the operation conditional on whether the object's current metageneration matches the given value.
23337    ///
23338    /// Sets the *if metageneration match* query property to the given value.
23339    pub fn if_metageneration_match(mut self, new_value: i64) -> ObjectComposeCall<'a, C> {
23340        self._if_metageneration_match = Some(new_value);
23341        self
23342    }
23343    /// Makes the operation conditional on whether the object's current generation matches the given value. Setting to 0 makes the operation succeed only if there are no live versions of the object.
23344    ///
23345    /// Sets the *if generation match* query property to the given value.
23346    pub fn if_generation_match(mut self, new_value: i64) -> ObjectComposeCall<'a, C> {
23347        self._if_generation_match = Some(new_value);
23348        self
23349    }
23350    /// Apply a predefined set of access controls to the destination object.
23351    ///
23352    /// Sets the *destination predefined acl* query property to the given value.
23353    pub fn destination_predefined_acl(mut self, new_value: &str) -> ObjectComposeCall<'a, C> {
23354        self._destination_predefined_acl = Some(new_value.to_string());
23355        self
23356    }
23357    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23358    /// while executing the actual API request.
23359    ///
23360    /// ````text
23361    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23362    /// ````
23363    ///
23364    /// Sets the *delegate* property to the given value.
23365    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ObjectComposeCall<'a, C> {
23366        self._delegate = Some(new_value);
23367        self
23368    }
23369
23370    /// Set any additional parameter of the query string used in the request.
23371    /// It should be used to set parameters which are not yet available through their own
23372    /// setters.
23373    ///
23374    /// Please note that this method must not be used to set any of the known parameters
23375    /// which have their own setter method. If done anyway, the request will fail.
23376    ///
23377    /// # Additional Parameters
23378    ///
23379    /// * *alt* (query-string) - Data format for the response.
23380    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23381    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
23382    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23383    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23384    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
23385    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
23386    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
23387    pub fn param<T>(mut self, name: T, value: T) -> ObjectComposeCall<'a, C>
23388    where
23389        T: AsRef<str>,
23390    {
23391        self._additional_params
23392            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23393        self
23394    }
23395
23396    /// Identifies the authorization scope for the method you are building.
23397    ///
23398    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23399    /// [`Scope::CloudPlatform`].
23400    ///
23401    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23402    /// tokens for more than one scope.
23403    ///
23404    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23405    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23406    /// sufficient, a read-write scope will do as well.
23407    pub fn add_scope<St>(mut self, scope: St) -> ObjectComposeCall<'a, C>
23408    where
23409        St: AsRef<str>,
23410    {
23411        self._scopes.insert(String::from(scope.as_ref()));
23412        self
23413    }
23414    /// Identifies the authorization scope(s) for the method you are building.
23415    ///
23416    /// See [`Self::add_scope()`] for details.
23417    pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectComposeCall<'a, C>
23418    where
23419        I: IntoIterator<Item = St>,
23420        St: AsRef<str>,
23421    {
23422        self._scopes
23423            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23424        self
23425    }
23426
23427    /// Removes all scopes, and no default scope will be used either.
23428    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23429    /// for details).
23430    pub fn clear_scopes(mut self) -> ObjectComposeCall<'a, C> {
23431        self._scopes.clear();
23432        self
23433    }
23434}
23435
23436/// Copies a source object to a destination object. Optionally overrides metadata.
23437///
23438/// A builder for the *copy* method supported by a *object* resource.
23439/// It is not used directly, but through a [`ObjectMethods`] instance.
23440///
23441/// # Example
23442///
23443/// Instantiate a resource method builder
23444///
23445/// ```test_harness,no_run
23446/// # extern crate hyper;
23447/// # extern crate hyper_rustls;
23448/// # extern crate google_storage1 as storage1;
23449/// use storage1::api::Object;
23450/// # async fn dox() {
23451/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23452///
23453/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23454/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23455/// #     secret,
23456/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23457/// # ).build().await.unwrap();
23458///
23459/// # let client = hyper_util::client::legacy::Client::builder(
23460/// #     hyper_util::rt::TokioExecutor::new()
23461/// # )
23462/// # .build(
23463/// #     hyper_rustls::HttpsConnectorBuilder::new()
23464/// #         .with_native_roots()
23465/// #         .unwrap()
23466/// #         .https_or_http()
23467/// #         .enable_http1()
23468/// #         .build()
23469/// # );
23470/// # let mut hub = Storage::new(client, auth);
23471/// // As the method needs a request, you would usually fill it with the desired information
23472/// // into the respective structure. Some of the parts shown here might not be applicable !
23473/// // Values shown here are possibly random and not representative !
23474/// let mut req = Object::default();
23475///
23476/// // You can configure optional parameters by calling the respective setters at will, and
23477/// // execute the final call using `doit()`.
23478/// // Values shown here are possibly random and not representative !
23479/// let result = hub.objects().copy(req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject")
23480///              .user_project("tempor")
23481///              .source_generation(-43)
23482///              .projection("est")
23483///              .if_source_metageneration_not_match(-9)
23484///              .if_source_metageneration_match(-99)
23485///              .if_source_generation_not_match(-79)
23486///              .if_source_generation_match(-77)
23487///              .if_metageneration_not_match(-81)
23488///              .if_metageneration_match(-71)
23489///              .if_generation_not_match(-5)
23490///              .if_generation_match(-73)
23491///              .destination_predefined_acl("dolores")
23492///              .destination_kms_key_name("consetetur")
23493///              .doit().await;
23494/// # }
23495/// ```
23496pub struct ObjectCopyCall<'a, C>
23497where
23498    C: 'a,
23499{
23500    hub: &'a Storage<C>,
23501    _request: Object,
23502    _source_bucket: String,
23503    _source_object: String,
23504    _destination_bucket: String,
23505    _destination_object: String,
23506    _user_project: Option<String>,
23507    _source_generation: Option<i64>,
23508    _projection: Option<String>,
23509    _if_source_metageneration_not_match: Option<i64>,
23510    _if_source_metageneration_match: Option<i64>,
23511    _if_source_generation_not_match: Option<i64>,
23512    _if_source_generation_match: Option<i64>,
23513    _if_metageneration_not_match: Option<i64>,
23514    _if_metageneration_match: Option<i64>,
23515    _if_generation_not_match: Option<i64>,
23516    _if_generation_match: Option<i64>,
23517    _destination_predefined_acl: Option<String>,
23518    _destination_kms_key_name: Option<String>,
23519    _delegate: Option<&'a mut dyn common::Delegate>,
23520    _additional_params: HashMap<String, String>,
23521    _scopes: BTreeSet<String>,
23522}
23523
23524impl<'a, C> common::CallBuilder for ObjectCopyCall<'a, C> {}
23525
23526impl<'a, C> ObjectCopyCall<'a, C>
23527where
23528    C: common::Connector,
23529{
23530    /// Perform the operation you have build so far.
23531    pub async fn doit(mut self) -> common::Result<(common::Response, Object)> {
23532        use std::borrow::Cow;
23533        use std::io::{Read, Seek};
23534
23535        use common::{url::Params, ToParts};
23536        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23537
23538        let mut dd = common::DefaultDelegate;
23539        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23540        dlg.begin(common::MethodInfo {
23541            id: "storage.objects.copy",
23542            http_method: hyper::Method::POST,
23543        });
23544
23545        for &field in [
23546            "alt",
23547            "sourceBucket",
23548            "sourceObject",
23549            "destinationBucket",
23550            "destinationObject",
23551            "userProject",
23552            "sourceGeneration",
23553            "projection",
23554            "ifSourceMetagenerationNotMatch",
23555            "ifSourceMetagenerationMatch",
23556            "ifSourceGenerationNotMatch",
23557            "ifSourceGenerationMatch",
23558            "ifMetagenerationNotMatch",
23559            "ifMetagenerationMatch",
23560            "ifGenerationNotMatch",
23561            "ifGenerationMatch",
23562            "destinationPredefinedAcl",
23563            "destinationKmsKeyName",
23564        ]
23565        .iter()
23566        {
23567            if self._additional_params.contains_key(field) {
23568                dlg.finished(false);
23569                return Err(common::Error::FieldClash(field));
23570            }
23571        }
23572
23573        let mut params = Params::with_capacity(20 + self._additional_params.len());
23574        params.push("sourceBucket", self._source_bucket);
23575        params.push("sourceObject", self._source_object);
23576        params.push("destinationBucket", self._destination_bucket);
23577        params.push("destinationObject", self._destination_object);
23578        if let Some(value) = self._user_project.as_ref() {
23579            params.push("userProject", value);
23580        }
23581        if let Some(value) = self._source_generation.as_ref() {
23582            params.push("sourceGeneration", value.to_string());
23583        }
23584        if let Some(value) = self._projection.as_ref() {
23585            params.push("projection", value);
23586        }
23587        if let Some(value) = self._if_source_metageneration_not_match.as_ref() {
23588            params.push("ifSourceMetagenerationNotMatch", value.to_string());
23589        }
23590        if let Some(value) = self._if_source_metageneration_match.as_ref() {
23591            params.push("ifSourceMetagenerationMatch", value.to_string());
23592        }
23593        if let Some(value) = self._if_source_generation_not_match.as_ref() {
23594            params.push("ifSourceGenerationNotMatch", value.to_string());
23595        }
23596        if let Some(value) = self._if_source_generation_match.as_ref() {
23597            params.push("ifSourceGenerationMatch", value.to_string());
23598        }
23599        if let Some(value) = self._if_metageneration_not_match.as_ref() {
23600            params.push("ifMetagenerationNotMatch", value.to_string());
23601        }
23602        if let Some(value) = self._if_metageneration_match.as_ref() {
23603            params.push("ifMetagenerationMatch", value.to_string());
23604        }
23605        if let Some(value) = self._if_generation_not_match.as_ref() {
23606            params.push("ifGenerationNotMatch", value.to_string());
23607        }
23608        if let Some(value) = self._if_generation_match.as_ref() {
23609            params.push("ifGenerationMatch", value.to_string());
23610        }
23611        if let Some(value) = self._destination_predefined_acl.as_ref() {
23612            params.push("destinationPredefinedAcl", value);
23613        }
23614        if let Some(value) = self._destination_kms_key_name.as_ref() {
23615            params.push("destinationKmsKeyName", value);
23616        }
23617
23618        params.extend(self._additional_params.iter());
23619
23620        params.push("alt", "json");
23621        let mut url = self.hub._base_url.clone() + "b/{sourceBucket}/o/{sourceObject}/copyTo/b/{destinationBucket}/o/{destinationObject}";
23622        if self._scopes.is_empty() {
23623            self._scopes
23624                .insert(Scope::CloudPlatform.as_ref().to_string());
23625        }
23626
23627        #[allow(clippy::single_element_loop)]
23628        for &(find_this, param_name) in [
23629            ("{sourceBucket}", "sourceBucket"),
23630            ("{sourceObject}", "sourceObject"),
23631            ("{destinationBucket}", "destinationBucket"),
23632            ("{destinationObject}", "destinationObject"),
23633        ]
23634        .iter()
23635        {
23636            url = params.uri_replacement(url, param_name, find_this, false);
23637        }
23638        {
23639            let to_remove = [
23640                "destinationObject",
23641                "destinationBucket",
23642                "sourceObject",
23643                "sourceBucket",
23644            ];
23645            params.remove_params(&to_remove);
23646        }
23647
23648        let url = params.parse_with_url(&url);
23649
23650        let mut json_mime_type = mime::APPLICATION_JSON;
23651        let mut request_value_reader = {
23652            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23653            common::remove_json_null_values(&mut value);
23654            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23655            serde_json::to_writer(&mut dst, &value).unwrap();
23656            dst
23657        };
23658        let request_size = request_value_reader
23659            .seek(std::io::SeekFrom::End(0))
23660            .unwrap();
23661        request_value_reader
23662            .seek(std::io::SeekFrom::Start(0))
23663            .unwrap();
23664
23665        loop {
23666            let token = match self
23667                .hub
23668                .auth
23669                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23670                .await
23671            {
23672                Ok(token) => token,
23673                Err(e) => match dlg.token(e) {
23674                    Ok(token) => token,
23675                    Err(e) => {
23676                        dlg.finished(false);
23677                        return Err(common::Error::MissingToken(e));
23678                    }
23679                },
23680            };
23681            request_value_reader
23682                .seek(std::io::SeekFrom::Start(0))
23683                .unwrap();
23684            let mut req_result = {
23685                let client = &self.hub.client;
23686                dlg.pre_request();
23687                let mut req_builder = hyper::Request::builder()
23688                    .method(hyper::Method::POST)
23689                    .uri(url.as_str())
23690                    .header(USER_AGENT, self.hub._user_agent.clone());
23691
23692                if let Some(token) = token.as_ref() {
23693                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23694                }
23695
23696                let request = req_builder
23697                    .header(CONTENT_TYPE, json_mime_type.to_string())
23698                    .header(CONTENT_LENGTH, request_size as u64)
23699                    .body(common::to_body(
23700                        request_value_reader.get_ref().clone().into(),
23701                    ));
23702
23703                client.request(request.unwrap()).await
23704            };
23705
23706            match req_result {
23707                Err(err) => {
23708                    if let common::Retry::After(d) = dlg.http_error(&err) {
23709                        sleep(d).await;
23710                        continue;
23711                    }
23712                    dlg.finished(false);
23713                    return Err(common::Error::HttpError(err));
23714                }
23715                Ok(res) => {
23716                    let (mut parts, body) = res.into_parts();
23717                    let mut body = common::Body::new(body);
23718                    if !parts.status.is_success() {
23719                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23720                        let error = serde_json::from_str(&common::to_string(&bytes));
23721                        let response = common::to_response(parts, bytes.into());
23722
23723                        if let common::Retry::After(d) =
23724                            dlg.http_failure(&response, error.as_ref().ok())
23725                        {
23726                            sleep(d).await;
23727                            continue;
23728                        }
23729
23730                        dlg.finished(false);
23731
23732                        return Err(match error {
23733                            Ok(value) => common::Error::BadRequest(value),
23734                            _ => common::Error::Failure(response),
23735                        });
23736                    }
23737                    let response = {
23738                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23739                        let encoded = common::to_string(&bytes);
23740                        match serde_json::from_str(&encoded) {
23741                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23742                            Err(error) => {
23743                                dlg.response_json_decode_error(&encoded, &error);
23744                                return Err(common::Error::JsonDecodeError(
23745                                    encoded.to_string(),
23746                                    error,
23747                                ));
23748                            }
23749                        }
23750                    };
23751
23752                    dlg.finished(true);
23753                    return Ok(response);
23754                }
23755            }
23756        }
23757    }
23758
23759    ///
23760    /// Sets the *request* property to the given value.
23761    ///
23762    /// Even though the property as already been set when instantiating this call,
23763    /// we provide this method for API completeness.
23764    pub fn request(mut self, new_value: Object) -> ObjectCopyCall<'a, C> {
23765        self._request = new_value;
23766        self
23767    }
23768    /// Name of the bucket in which to find the source object.
23769    ///
23770    /// Sets the *source bucket* path property to the given value.
23771    ///
23772    /// Even though the property as already been set when instantiating this call,
23773    /// we provide this method for API completeness.
23774    pub fn source_bucket(mut self, new_value: &str) -> ObjectCopyCall<'a, C> {
23775        self._source_bucket = new_value.to_string();
23776        self
23777    }
23778    /// Name of the source object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
23779    ///
23780    /// Sets the *source object* path property to the given value.
23781    ///
23782    /// Even though the property as already been set when instantiating this call,
23783    /// we provide this method for API completeness.
23784    pub fn source_object(mut self, new_value: &str) -> ObjectCopyCall<'a, C> {
23785        self._source_object = new_value.to_string();
23786        self
23787    }
23788    /// Name of the bucket in which to store the new object. Overrides the provided object metadata's bucket value, if any.For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
23789    ///
23790    /// Sets the *destination bucket* path property to the given value.
23791    ///
23792    /// Even though the property as already been set when instantiating this call,
23793    /// we provide this method for API completeness.
23794    pub fn destination_bucket(mut self, new_value: &str) -> ObjectCopyCall<'a, C> {
23795        self._destination_bucket = new_value.to_string();
23796        self
23797    }
23798    /// Name of the new object. Required when the object metadata is not otherwise provided. Overrides the object metadata's name value, if any.
23799    ///
23800    /// Sets the *destination object* path property to the given value.
23801    ///
23802    /// Even though the property as already been set when instantiating this call,
23803    /// we provide this method for API completeness.
23804    pub fn destination_object(mut self, new_value: &str) -> ObjectCopyCall<'a, C> {
23805        self._destination_object = new_value.to_string();
23806        self
23807    }
23808    /// The project to be billed for this request. Required for Requester Pays buckets.
23809    ///
23810    /// Sets the *user project* query property to the given value.
23811    pub fn user_project(mut self, new_value: &str) -> ObjectCopyCall<'a, C> {
23812        self._user_project = Some(new_value.to_string());
23813        self
23814    }
23815    /// If present, selects a specific revision of the source object (as opposed to the latest version, the default).
23816    ///
23817    /// Sets the *source generation* query property to the given value.
23818    pub fn source_generation(mut self, new_value: i64) -> ObjectCopyCall<'a, C> {
23819        self._source_generation = Some(new_value);
23820        self
23821    }
23822    /// Set of properties to return. Defaults to noAcl, unless the object resource specifies the acl property, when it defaults to full.
23823    ///
23824    /// Sets the *projection* query property to the given value.
23825    pub fn projection(mut self, new_value: &str) -> ObjectCopyCall<'a, C> {
23826        self._projection = Some(new_value.to_string());
23827        self
23828    }
23829    /// Makes the operation conditional on whether the source object's current metageneration does not match the given value.
23830    ///
23831    /// Sets the *if source metageneration not match* query property to the given value.
23832    pub fn if_source_metageneration_not_match(mut self, new_value: i64) -> ObjectCopyCall<'a, C> {
23833        self._if_source_metageneration_not_match = Some(new_value);
23834        self
23835    }
23836    /// Makes the operation conditional on whether the source object's current metageneration matches the given value.
23837    ///
23838    /// Sets the *if source metageneration match* query property to the given value.
23839    pub fn if_source_metageneration_match(mut self, new_value: i64) -> ObjectCopyCall<'a, C> {
23840        self._if_source_metageneration_match = Some(new_value);
23841        self
23842    }
23843    /// Makes the operation conditional on whether the source object's current generation does not match the given value.
23844    ///
23845    /// Sets the *if source generation not match* query property to the given value.
23846    pub fn if_source_generation_not_match(mut self, new_value: i64) -> ObjectCopyCall<'a, C> {
23847        self._if_source_generation_not_match = Some(new_value);
23848        self
23849    }
23850    /// Makes the operation conditional on whether the source object's current generation matches the given value.
23851    ///
23852    /// Sets the *if source generation match* query property to the given value.
23853    pub fn if_source_generation_match(mut self, new_value: i64) -> ObjectCopyCall<'a, C> {
23854        self._if_source_generation_match = Some(new_value);
23855        self
23856    }
23857    /// Makes the operation conditional on whether the destination object's current metageneration does not match the given value.
23858    ///
23859    /// Sets the *if metageneration not match* query property to the given value.
23860    pub fn if_metageneration_not_match(mut self, new_value: i64) -> ObjectCopyCall<'a, C> {
23861        self._if_metageneration_not_match = Some(new_value);
23862        self
23863    }
23864    /// Makes the operation conditional on whether the destination object's current metageneration matches the given value.
23865    ///
23866    /// Sets the *if metageneration match* query property to the given value.
23867    pub fn if_metageneration_match(mut self, new_value: i64) -> ObjectCopyCall<'a, C> {
23868        self._if_metageneration_match = Some(new_value);
23869        self
23870    }
23871    /// Makes the operation conditional on whether the destination object's current generation does not match the given value. If no live object exists, the precondition fails. Setting to 0 makes the operation succeed only if there is a live version of the object.
23872    ///
23873    /// Sets the *if generation not match* query property to the given value.
23874    pub fn if_generation_not_match(mut self, new_value: i64) -> ObjectCopyCall<'a, C> {
23875        self._if_generation_not_match = Some(new_value);
23876        self
23877    }
23878    /// Makes the operation conditional on whether the destination object's current generation matches the given value. Setting to 0 makes the operation succeed only if there are no live versions of the object.
23879    ///
23880    /// Sets the *if generation match* query property to the given value.
23881    pub fn if_generation_match(mut self, new_value: i64) -> ObjectCopyCall<'a, C> {
23882        self._if_generation_match = Some(new_value);
23883        self
23884    }
23885    /// Apply a predefined set of access controls to the destination object.
23886    ///
23887    /// Sets the *destination predefined acl* query property to the given value.
23888    pub fn destination_predefined_acl(mut self, new_value: &str) -> ObjectCopyCall<'a, C> {
23889        self._destination_predefined_acl = Some(new_value.to_string());
23890        self
23891    }
23892    /// Resource name of the Cloud KMS key, of the form projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key, that will be used to encrypt the object. Overrides the object metadata's kms_key_name value, if any.
23893    ///
23894    /// Sets the *destination kms key name* query property to the given value.
23895    pub fn destination_kms_key_name(mut self, new_value: &str) -> ObjectCopyCall<'a, C> {
23896        self._destination_kms_key_name = Some(new_value.to_string());
23897        self
23898    }
23899    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23900    /// while executing the actual API request.
23901    ///
23902    /// ````text
23903    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23904    /// ````
23905    ///
23906    /// Sets the *delegate* property to the given value.
23907    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ObjectCopyCall<'a, C> {
23908        self._delegate = Some(new_value);
23909        self
23910    }
23911
23912    /// Set any additional parameter of the query string used in the request.
23913    /// It should be used to set parameters which are not yet available through their own
23914    /// setters.
23915    ///
23916    /// Please note that this method must not be used to set any of the known parameters
23917    /// which have their own setter method. If done anyway, the request will fail.
23918    ///
23919    /// # Additional Parameters
23920    ///
23921    /// * *alt* (query-string) - Data format for the response.
23922    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23923    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
23924    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23925    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23926    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
23927    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
23928    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
23929    pub fn param<T>(mut self, name: T, value: T) -> ObjectCopyCall<'a, C>
23930    where
23931        T: AsRef<str>,
23932    {
23933        self._additional_params
23934            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23935        self
23936    }
23937
23938    /// Identifies the authorization scope for the method you are building.
23939    ///
23940    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23941    /// [`Scope::CloudPlatform`].
23942    ///
23943    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23944    /// tokens for more than one scope.
23945    ///
23946    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23947    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23948    /// sufficient, a read-write scope will do as well.
23949    pub fn add_scope<St>(mut self, scope: St) -> ObjectCopyCall<'a, C>
23950    where
23951        St: AsRef<str>,
23952    {
23953        self._scopes.insert(String::from(scope.as_ref()));
23954        self
23955    }
23956    /// Identifies the authorization scope(s) for the method you are building.
23957    ///
23958    /// See [`Self::add_scope()`] for details.
23959    pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectCopyCall<'a, C>
23960    where
23961        I: IntoIterator<Item = St>,
23962        St: AsRef<str>,
23963    {
23964        self._scopes
23965            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23966        self
23967    }
23968
23969    /// Removes all scopes, and no default scope will be used either.
23970    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23971    /// for details).
23972    pub fn clear_scopes(mut self) -> ObjectCopyCall<'a, C> {
23973        self._scopes.clear();
23974        self
23975    }
23976}
23977
23978/// Deletes an object and its metadata. Deletions are permanent if versioning is not enabled for the bucket, or if the generation parameter is used.
23979///
23980/// A builder for the *delete* method supported by a *object* resource.
23981/// It is not used directly, but through a [`ObjectMethods`] instance.
23982///
23983/// # Example
23984///
23985/// Instantiate a resource method builder
23986///
23987/// ```test_harness,no_run
23988/// # extern crate hyper;
23989/// # extern crate hyper_rustls;
23990/// # extern crate google_storage1 as storage1;
23991/// # async fn dox() {
23992/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23993///
23994/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23995/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23996/// #     secret,
23997/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23998/// # ).build().await.unwrap();
23999///
24000/// # let client = hyper_util::client::legacy::Client::builder(
24001/// #     hyper_util::rt::TokioExecutor::new()
24002/// # )
24003/// # .build(
24004/// #     hyper_rustls::HttpsConnectorBuilder::new()
24005/// #         .with_native_roots()
24006/// #         .unwrap()
24007/// #         .https_or_http()
24008/// #         .enable_http1()
24009/// #         .build()
24010/// # );
24011/// # let mut hub = Storage::new(client, auth);
24012/// // You can configure optional parameters by calling the respective setters at will, and
24013/// // execute the final call using `doit()`.
24014/// // Values shown here are possibly random and not representative !
24015/// let result = hub.objects().delete("bucket", "object")
24016///              .user_project("sadipscing")
24017///              .if_metageneration_not_match(-42)
24018///              .if_metageneration_match(-10)
24019///              .if_generation_not_match(-50)
24020///              .if_generation_match(-15)
24021///              .generation(-62)
24022///              .doit().await;
24023/// # }
24024/// ```
24025pub struct ObjectDeleteCall<'a, C>
24026where
24027    C: 'a,
24028{
24029    hub: &'a Storage<C>,
24030    _bucket: String,
24031    _object: String,
24032    _user_project: Option<String>,
24033    _if_metageneration_not_match: Option<i64>,
24034    _if_metageneration_match: Option<i64>,
24035    _if_generation_not_match: Option<i64>,
24036    _if_generation_match: Option<i64>,
24037    _generation: Option<i64>,
24038    _delegate: Option<&'a mut dyn common::Delegate>,
24039    _additional_params: HashMap<String, String>,
24040    _scopes: BTreeSet<String>,
24041}
24042
24043impl<'a, C> common::CallBuilder for ObjectDeleteCall<'a, C> {}
24044
24045impl<'a, C> ObjectDeleteCall<'a, C>
24046where
24047    C: common::Connector,
24048{
24049    /// Perform the operation you have build so far.
24050    pub async fn doit(mut self) -> common::Result<common::Response> {
24051        use std::borrow::Cow;
24052        use std::io::{Read, Seek};
24053
24054        use common::{url::Params, ToParts};
24055        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24056
24057        let mut dd = common::DefaultDelegate;
24058        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24059        dlg.begin(common::MethodInfo {
24060            id: "storage.objects.delete",
24061            http_method: hyper::Method::DELETE,
24062        });
24063
24064        for &field in [
24065            "bucket",
24066            "object",
24067            "userProject",
24068            "ifMetagenerationNotMatch",
24069            "ifMetagenerationMatch",
24070            "ifGenerationNotMatch",
24071            "ifGenerationMatch",
24072            "generation",
24073        ]
24074        .iter()
24075        {
24076            if self._additional_params.contains_key(field) {
24077                dlg.finished(false);
24078                return Err(common::Error::FieldClash(field));
24079            }
24080        }
24081
24082        let mut params = Params::with_capacity(9 + self._additional_params.len());
24083        params.push("bucket", self._bucket);
24084        params.push("object", self._object);
24085        if let Some(value) = self._user_project.as_ref() {
24086            params.push("userProject", value);
24087        }
24088        if let Some(value) = self._if_metageneration_not_match.as_ref() {
24089            params.push("ifMetagenerationNotMatch", value.to_string());
24090        }
24091        if let Some(value) = self._if_metageneration_match.as_ref() {
24092            params.push("ifMetagenerationMatch", value.to_string());
24093        }
24094        if let Some(value) = self._if_generation_not_match.as_ref() {
24095            params.push("ifGenerationNotMatch", value.to_string());
24096        }
24097        if let Some(value) = self._if_generation_match.as_ref() {
24098            params.push("ifGenerationMatch", value.to_string());
24099        }
24100        if let Some(value) = self._generation.as_ref() {
24101            params.push("generation", value.to_string());
24102        }
24103
24104        params.extend(self._additional_params.iter());
24105
24106        let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}";
24107        if self._scopes.is_empty() {
24108            self._scopes
24109                .insert(Scope::CloudPlatform.as_ref().to_string());
24110        }
24111
24112        #[allow(clippy::single_element_loop)]
24113        for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object")].iter() {
24114            url = params.uri_replacement(url, param_name, find_this, false);
24115        }
24116        {
24117            let to_remove = ["object", "bucket"];
24118            params.remove_params(&to_remove);
24119        }
24120
24121        let url = params.parse_with_url(&url);
24122
24123        loop {
24124            let token = match self
24125                .hub
24126                .auth
24127                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24128                .await
24129            {
24130                Ok(token) => token,
24131                Err(e) => match dlg.token(e) {
24132                    Ok(token) => token,
24133                    Err(e) => {
24134                        dlg.finished(false);
24135                        return Err(common::Error::MissingToken(e));
24136                    }
24137                },
24138            };
24139            let mut req_result = {
24140                let client = &self.hub.client;
24141                dlg.pre_request();
24142                let mut req_builder = hyper::Request::builder()
24143                    .method(hyper::Method::DELETE)
24144                    .uri(url.as_str())
24145                    .header(USER_AGENT, self.hub._user_agent.clone());
24146
24147                if let Some(token) = token.as_ref() {
24148                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24149                }
24150
24151                let request = req_builder
24152                    .header(CONTENT_LENGTH, 0_u64)
24153                    .body(common::to_body::<String>(None));
24154
24155                client.request(request.unwrap()).await
24156            };
24157
24158            match req_result {
24159                Err(err) => {
24160                    if let common::Retry::After(d) = dlg.http_error(&err) {
24161                        sleep(d).await;
24162                        continue;
24163                    }
24164                    dlg.finished(false);
24165                    return Err(common::Error::HttpError(err));
24166                }
24167                Ok(res) => {
24168                    let (mut parts, body) = res.into_parts();
24169                    let mut body = common::Body::new(body);
24170                    if !parts.status.is_success() {
24171                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24172                        let error = serde_json::from_str(&common::to_string(&bytes));
24173                        let response = common::to_response(parts, bytes.into());
24174
24175                        if let common::Retry::After(d) =
24176                            dlg.http_failure(&response, error.as_ref().ok())
24177                        {
24178                            sleep(d).await;
24179                            continue;
24180                        }
24181
24182                        dlg.finished(false);
24183
24184                        return Err(match error {
24185                            Ok(value) => common::Error::BadRequest(value),
24186                            _ => common::Error::Failure(response),
24187                        });
24188                    }
24189                    let response = common::Response::from_parts(parts, body);
24190
24191                    dlg.finished(true);
24192                    return Ok(response);
24193                }
24194            }
24195        }
24196    }
24197
24198    /// Name of the bucket in which the object resides.
24199    ///
24200    /// Sets the *bucket* path property to the given value.
24201    ///
24202    /// Even though the property as already been set when instantiating this call,
24203    /// we provide this method for API completeness.
24204    pub fn bucket(mut self, new_value: &str) -> ObjectDeleteCall<'a, C> {
24205        self._bucket = new_value.to_string();
24206        self
24207    }
24208    /// Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
24209    ///
24210    /// Sets the *object* path property to the given value.
24211    ///
24212    /// Even though the property as already been set when instantiating this call,
24213    /// we provide this method for API completeness.
24214    pub fn object(mut self, new_value: &str) -> ObjectDeleteCall<'a, C> {
24215        self._object = new_value.to_string();
24216        self
24217    }
24218    /// The project to be billed for this request. Required for Requester Pays buckets.
24219    ///
24220    /// Sets the *user project* query property to the given value.
24221    pub fn user_project(mut self, new_value: &str) -> ObjectDeleteCall<'a, C> {
24222        self._user_project = Some(new_value.to_string());
24223        self
24224    }
24225    /// Makes the operation conditional on whether the object's current metageneration does not match the given value.
24226    ///
24227    /// Sets the *if metageneration not match* query property to the given value.
24228    pub fn if_metageneration_not_match(mut self, new_value: i64) -> ObjectDeleteCall<'a, C> {
24229        self._if_metageneration_not_match = Some(new_value);
24230        self
24231    }
24232    /// Makes the operation conditional on whether the object's current metageneration matches the given value.
24233    ///
24234    /// Sets the *if metageneration match* query property to the given value.
24235    pub fn if_metageneration_match(mut self, new_value: i64) -> ObjectDeleteCall<'a, C> {
24236        self._if_metageneration_match = Some(new_value);
24237        self
24238    }
24239    /// Makes the operation conditional on whether the object's current generation does not match the given value. If no live object exists, the precondition fails. Setting to 0 makes the operation succeed only if there is a live version of the object.
24240    ///
24241    /// Sets the *if generation not match* query property to the given value.
24242    pub fn if_generation_not_match(mut self, new_value: i64) -> ObjectDeleteCall<'a, C> {
24243        self._if_generation_not_match = Some(new_value);
24244        self
24245    }
24246    /// Makes the operation conditional on whether the object's current generation matches the given value. Setting to 0 makes the operation succeed only if there are no live versions of the object.
24247    ///
24248    /// Sets the *if generation match* query property to the given value.
24249    pub fn if_generation_match(mut self, new_value: i64) -> ObjectDeleteCall<'a, C> {
24250        self._if_generation_match = Some(new_value);
24251        self
24252    }
24253    /// If present, permanently deletes a specific revision of this object (as opposed to the latest version, the default).
24254    ///
24255    /// Sets the *generation* query property to the given value.
24256    pub fn generation(mut self, new_value: i64) -> ObjectDeleteCall<'a, C> {
24257        self._generation = Some(new_value);
24258        self
24259    }
24260    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24261    /// while executing the actual API request.
24262    ///
24263    /// ````text
24264    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24265    /// ````
24266    ///
24267    /// Sets the *delegate* property to the given value.
24268    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ObjectDeleteCall<'a, C> {
24269        self._delegate = Some(new_value);
24270        self
24271    }
24272
24273    /// Set any additional parameter of the query string used in the request.
24274    /// It should be used to set parameters which are not yet available through their own
24275    /// setters.
24276    ///
24277    /// Please note that this method must not be used to set any of the known parameters
24278    /// which have their own setter method. If done anyway, the request will fail.
24279    ///
24280    /// # Additional Parameters
24281    ///
24282    /// * *alt* (query-string) - Data format for the response.
24283    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24284    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
24285    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24286    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24287    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
24288    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
24289    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
24290    pub fn param<T>(mut self, name: T, value: T) -> ObjectDeleteCall<'a, C>
24291    where
24292        T: AsRef<str>,
24293    {
24294        self._additional_params
24295            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24296        self
24297    }
24298
24299    /// Identifies the authorization scope for the method you are building.
24300    ///
24301    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24302    /// [`Scope::CloudPlatform`].
24303    ///
24304    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24305    /// tokens for more than one scope.
24306    ///
24307    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24308    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24309    /// sufficient, a read-write scope will do as well.
24310    pub fn add_scope<St>(mut self, scope: St) -> ObjectDeleteCall<'a, C>
24311    where
24312        St: AsRef<str>,
24313    {
24314        self._scopes.insert(String::from(scope.as_ref()));
24315        self
24316    }
24317    /// Identifies the authorization scope(s) for the method you are building.
24318    ///
24319    /// See [`Self::add_scope()`] for details.
24320    pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectDeleteCall<'a, C>
24321    where
24322        I: IntoIterator<Item = St>,
24323        St: AsRef<str>,
24324    {
24325        self._scopes
24326            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24327        self
24328    }
24329
24330    /// Removes all scopes, and no default scope will be used either.
24331    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24332    /// for details).
24333    pub fn clear_scopes(mut self) -> ObjectDeleteCall<'a, C> {
24334        self._scopes.clear();
24335        self
24336    }
24337}
24338
24339/// Retrieves an object or its metadata.
24340///
24341/// This method supports **media download**. To enable it, adjust the builder like this:
24342/// `.param("alt", "media")`.
24343/// Please note that due to missing multi-part support on the server side, you will only receive the media,
24344/// but not the `Object` structure that you would usually get. The latter will be a default value.
24345///
24346/// A builder for the *get* method supported by a *object* resource.
24347/// It is not used directly, but through a [`ObjectMethods`] instance.
24348///
24349/// # Example
24350///
24351/// Instantiate a resource method builder
24352///
24353/// ```test_harness,no_run
24354/// # extern crate hyper;
24355/// # extern crate hyper_rustls;
24356/// # extern crate google_storage1 as storage1;
24357/// # async fn dox() {
24358/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24359///
24360/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24361/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
24362/// #     secret,
24363/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24364/// # ).build().await.unwrap();
24365///
24366/// # let client = hyper_util::client::legacy::Client::builder(
24367/// #     hyper_util::rt::TokioExecutor::new()
24368/// # )
24369/// # .build(
24370/// #     hyper_rustls::HttpsConnectorBuilder::new()
24371/// #         .with_native_roots()
24372/// #         .unwrap()
24373/// #         .https_or_http()
24374/// #         .enable_http1()
24375/// #         .build()
24376/// # );
24377/// # let mut hub = Storage::new(client, auth);
24378/// // You can configure optional parameters by calling the respective setters at will, and
24379/// // execute the final call using `doit()`.
24380/// // Values shown here are possibly random and not representative !
24381/// let result = hub.objects().get("bucket", "object")
24382///              .user_project("sit")
24383///              .soft_deleted(true)
24384///              .projection("Lorem")
24385///              .if_metageneration_not_match(-21)
24386///              .if_metageneration_match(-88)
24387///              .if_generation_not_match(-1)
24388///              .if_generation_match(-80)
24389///              .generation(-91)
24390///              .doit().await;
24391/// # }
24392/// ```
24393pub struct ObjectGetCall<'a, C>
24394where
24395    C: 'a,
24396{
24397    hub: &'a Storage<C>,
24398    _bucket: String,
24399    _object: String,
24400    _user_project: Option<String>,
24401    _soft_deleted: Option<bool>,
24402    _projection: Option<String>,
24403    _if_metageneration_not_match: Option<i64>,
24404    _if_metageneration_match: Option<i64>,
24405    _if_generation_not_match: Option<i64>,
24406    _if_generation_match: Option<i64>,
24407    _generation: Option<i64>,
24408    _delegate: Option<&'a mut dyn common::Delegate>,
24409    _additional_params: HashMap<String, String>,
24410    _scopes: BTreeSet<String>,
24411}
24412
24413impl<'a, C> common::CallBuilder for ObjectGetCall<'a, C> {}
24414
24415impl<'a, C> ObjectGetCall<'a, C>
24416where
24417    C: common::Connector,
24418{
24419    /// Perform the operation you have build so far.
24420    pub async fn doit(mut self) -> common::Result<(common::Response, Object)> {
24421        use std::borrow::Cow;
24422        use std::io::{Read, Seek};
24423
24424        use common::{url::Params, ToParts};
24425        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24426
24427        let mut dd = common::DefaultDelegate;
24428        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24429        dlg.begin(common::MethodInfo {
24430            id: "storage.objects.get",
24431            http_method: hyper::Method::GET,
24432        });
24433
24434        for &field in [
24435            "bucket",
24436            "object",
24437            "userProject",
24438            "softDeleted",
24439            "projection",
24440            "ifMetagenerationNotMatch",
24441            "ifMetagenerationMatch",
24442            "ifGenerationNotMatch",
24443            "ifGenerationMatch",
24444            "generation",
24445        ]
24446        .iter()
24447        {
24448            if self._additional_params.contains_key(field) {
24449                dlg.finished(false);
24450                return Err(common::Error::FieldClash(field));
24451            }
24452        }
24453
24454        let mut params = Params::with_capacity(11 + self._additional_params.len());
24455        params.push("bucket", self._bucket);
24456        params.push("object", self._object);
24457        if let Some(value) = self._user_project.as_ref() {
24458            params.push("userProject", value);
24459        }
24460        if let Some(value) = self._soft_deleted.as_ref() {
24461            params.push("softDeleted", value.to_string());
24462        }
24463        if let Some(value) = self._projection.as_ref() {
24464            params.push("projection", value);
24465        }
24466        if let Some(value) = self._if_metageneration_not_match.as_ref() {
24467            params.push("ifMetagenerationNotMatch", value.to_string());
24468        }
24469        if let Some(value) = self._if_metageneration_match.as_ref() {
24470            params.push("ifMetagenerationMatch", value.to_string());
24471        }
24472        if let Some(value) = self._if_generation_not_match.as_ref() {
24473            params.push("ifGenerationNotMatch", value.to_string());
24474        }
24475        if let Some(value) = self._if_generation_match.as_ref() {
24476            params.push("ifGenerationMatch", value.to_string());
24477        }
24478        if let Some(value) = self._generation.as_ref() {
24479            params.push("generation", value.to_string());
24480        }
24481
24482        params.extend(self._additional_params.iter());
24483
24484        let (alt_field_missing, enable_resource_parsing) = {
24485            if let Some(value) = params.get("alt") {
24486                (false, value == "json")
24487            } else {
24488                (true, true)
24489            }
24490        };
24491        if alt_field_missing {
24492            params.push("alt", "json");
24493        }
24494        let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}";
24495        if self._scopes.is_empty() {
24496            self._scopes
24497                .insert(Scope::CloudPlatform.as_ref().to_string());
24498        }
24499
24500        #[allow(clippy::single_element_loop)]
24501        for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object")].iter() {
24502            url = params.uri_replacement(url, param_name, find_this, false);
24503        }
24504        {
24505            let to_remove = ["object", "bucket"];
24506            params.remove_params(&to_remove);
24507        }
24508
24509        let url = params.parse_with_url(&url);
24510
24511        loop {
24512            let token = match self
24513                .hub
24514                .auth
24515                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24516                .await
24517            {
24518                Ok(token) => token,
24519                Err(e) => match dlg.token(e) {
24520                    Ok(token) => token,
24521                    Err(e) => {
24522                        dlg.finished(false);
24523                        return Err(common::Error::MissingToken(e));
24524                    }
24525                },
24526            };
24527            let mut req_result = {
24528                let client = &self.hub.client;
24529                dlg.pre_request();
24530                let mut req_builder = hyper::Request::builder()
24531                    .method(hyper::Method::GET)
24532                    .uri(url.as_str())
24533                    .header(USER_AGENT, self.hub._user_agent.clone());
24534
24535                if let Some(token) = token.as_ref() {
24536                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24537                }
24538
24539                let request = req_builder
24540                    .header(CONTENT_LENGTH, 0_u64)
24541                    .body(common::to_body::<String>(None));
24542
24543                client.request(request.unwrap()).await
24544            };
24545
24546            match req_result {
24547                Err(err) => {
24548                    if let common::Retry::After(d) = dlg.http_error(&err) {
24549                        sleep(d).await;
24550                        continue;
24551                    }
24552                    dlg.finished(false);
24553                    return Err(common::Error::HttpError(err));
24554                }
24555                Ok(res) => {
24556                    let (mut parts, body) = res.into_parts();
24557                    let mut body = common::Body::new(body);
24558                    if !parts.status.is_success() {
24559                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24560                        let error = serde_json::from_str(&common::to_string(&bytes));
24561                        let response = common::to_response(parts, bytes.into());
24562
24563                        if let common::Retry::After(d) =
24564                            dlg.http_failure(&response, error.as_ref().ok())
24565                        {
24566                            sleep(d).await;
24567                            continue;
24568                        }
24569
24570                        dlg.finished(false);
24571
24572                        return Err(match error {
24573                            Ok(value) => common::Error::BadRequest(value),
24574                            _ => common::Error::Failure(response),
24575                        });
24576                    }
24577                    let response = if enable_resource_parsing {
24578                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24579                        let encoded = common::to_string(&bytes);
24580                        match serde_json::from_str(&encoded) {
24581                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24582                            Err(error) => {
24583                                dlg.response_json_decode_error(&encoded, &error);
24584                                return Err(common::Error::JsonDecodeError(
24585                                    encoded.to_string(),
24586                                    error,
24587                                ));
24588                            }
24589                        }
24590                    } else {
24591                        (
24592                            common::Response::from_parts(parts, body),
24593                            Default::default(),
24594                        )
24595                    };
24596
24597                    dlg.finished(true);
24598                    return Ok(response);
24599                }
24600            }
24601        }
24602    }
24603
24604    /// Name of the bucket in which the object resides.
24605    ///
24606    /// Sets the *bucket* path property to the given value.
24607    ///
24608    /// Even though the property as already been set when instantiating this call,
24609    /// we provide this method for API completeness.
24610    pub fn bucket(mut self, new_value: &str) -> ObjectGetCall<'a, C> {
24611        self._bucket = new_value.to_string();
24612        self
24613    }
24614    /// Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
24615    ///
24616    /// Sets the *object* path property to the given value.
24617    ///
24618    /// Even though the property as already been set when instantiating this call,
24619    /// we provide this method for API completeness.
24620    pub fn object(mut self, new_value: &str) -> ObjectGetCall<'a, C> {
24621        self._object = new_value.to_string();
24622        self
24623    }
24624    /// The project to be billed for this request. Required for Requester Pays buckets.
24625    ///
24626    /// Sets the *user project* query property to the given value.
24627    pub fn user_project(mut self, new_value: &str) -> ObjectGetCall<'a, C> {
24628        self._user_project = Some(new_value.to_string());
24629        self
24630    }
24631    /// If true, only soft-deleted object versions will be listed. The default is false. For more information, see Soft Delete.
24632    ///
24633    /// Sets the *soft deleted* query property to the given value.
24634    pub fn soft_deleted(mut self, new_value: bool) -> ObjectGetCall<'a, C> {
24635        self._soft_deleted = Some(new_value);
24636        self
24637    }
24638    /// Set of properties to return. Defaults to noAcl.
24639    ///
24640    /// Sets the *projection* query property to the given value.
24641    pub fn projection(mut self, new_value: &str) -> ObjectGetCall<'a, C> {
24642        self._projection = Some(new_value.to_string());
24643        self
24644    }
24645    /// Makes the operation conditional on whether the object's current metageneration does not match the given value.
24646    ///
24647    /// Sets the *if metageneration not match* query property to the given value.
24648    pub fn if_metageneration_not_match(mut self, new_value: i64) -> ObjectGetCall<'a, C> {
24649        self._if_metageneration_not_match = Some(new_value);
24650        self
24651    }
24652    /// Makes the operation conditional on whether the object's current metageneration matches the given value.
24653    ///
24654    /// Sets the *if metageneration match* query property to the given value.
24655    pub fn if_metageneration_match(mut self, new_value: i64) -> ObjectGetCall<'a, C> {
24656        self._if_metageneration_match = Some(new_value);
24657        self
24658    }
24659    /// Makes the operation conditional on whether the object's current generation does not match the given value. If no live object exists, the precondition fails. Setting to 0 makes the operation succeed only if there is a live version of the object.
24660    ///
24661    /// Sets the *if generation not match* query property to the given value.
24662    pub fn if_generation_not_match(mut self, new_value: i64) -> ObjectGetCall<'a, C> {
24663        self._if_generation_not_match = Some(new_value);
24664        self
24665    }
24666    /// Makes the operation conditional on whether the object's current generation matches the given value. Setting to 0 makes the operation succeed only if there are no live versions of the object.
24667    ///
24668    /// Sets the *if generation match* query property to the given value.
24669    pub fn if_generation_match(mut self, new_value: i64) -> ObjectGetCall<'a, C> {
24670        self._if_generation_match = Some(new_value);
24671        self
24672    }
24673    /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
24674    ///
24675    /// Sets the *generation* query property to the given value.
24676    pub fn generation(mut self, new_value: i64) -> ObjectGetCall<'a, C> {
24677        self._generation = Some(new_value);
24678        self
24679    }
24680    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24681    /// while executing the actual API request.
24682    ///
24683    /// ````text
24684    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24685    /// ````
24686    ///
24687    /// Sets the *delegate* property to the given value.
24688    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ObjectGetCall<'a, C> {
24689        self._delegate = Some(new_value);
24690        self
24691    }
24692
24693    /// Set any additional parameter of the query string used in the request.
24694    /// It should be used to set parameters which are not yet available through their own
24695    /// setters.
24696    ///
24697    /// Please note that this method must not be used to set any of the known parameters
24698    /// which have their own setter method. If done anyway, the request will fail.
24699    ///
24700    /// # Additional Parameters
24701    ///
24702    /// * *alt* (query-string) - Data format for the response.
24703    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24704    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
24705    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24706    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24707    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
24708    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
24709    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
24710    pub fn param<T>(mut self, name: T, value: T) -> ObjectGetCall<'a, C>
24711    where
24712        T: AsRef<str>,
24713    {
24714        self._additional_params
24715            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24716        self
24717    }
24718
24719    /// Identifies the authorization scope for the method you are building.
24720    ///
24721    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24722    /// [`Scope::CloudPlatform`].
24723    ///
24724    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24725    /// tokens for more than one scope.
24726    ///
24727    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24728    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24729    /// sufficient, a read-write scope will do as well.
24730    pub fn add_scope<St>(mut self, scope: St) -> ObjectGetCall<'a, C>
24731    where
24732        St: AsRef<str>,
24733    {
24734        self._scopes.insert(String::from(scope.as_ref()));
24735        self
24736    }
24737    /// Identifies the authorization scope(s) for the method you are building.
24738    ///
24739    /// See [`Self::add_scope()`] for details.
24740    pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectGetCall<'a, C>
24741    where
24742        I: IntoIterator<Item = St>,
24743        St: AsRef<str>,
24744    {
24745        self._scopes
24746            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24747        self
24748    }
24749
24750    /// Removes all scopes, and no default scope will be used either.
24751    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24752    /// for details).
24753    pub fn clear_scopes(mut self) -> ObjectGetCall<'a, C> {
24754        self._scopes.clear();
24755        self
24756    }
24757}
24758
24759/// Returns an IAM policy for the specified object.
24760///
24761/// A builder for the *getIamPolicy* method supported by a *object* resource.
24762/// It is not used directly, but through a [`ObjectMethods`] instance.
24763///
24764/// # Example
24765///
24766/// Instantiate a resource method builder
24767///
24768/// ```test_harness,no_run
24769/// # extern crate hyper;
24770/// # extern crate hyper_rustls;
24771/// # extern crate google_storage1 as storage1;
24772/// # async fn dox() {
24773/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24774///
24775/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24776/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
24777/// #     secret,
24778/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24779/// # ).build().await.unwrap();
24780///
24781/// # let client = hyper_util::client::legacy::Client::builder(
24782/// #     hyper_util::rt::TokioExecutor::new()
24783/// # )
24784/// # .build(
24785/// #     hyper_rustls::HttpsConnectorBuilder::new()
24786/// #         .with_native_roots()
24787/// #         .unwrap()
24788/// #         .https_or_http()
24789/// #         .enable_http1()
24790/// #         .build()
24791/// # );
24792/// # let mut hub = Storage::new(client, auth);
24793/// // You can configure optional parameters by calling the respective setters at will, and
24794/// // execute the final call using `doit()`.
24795/// // Values shown here are possibly random and not representative !
24796/// let result = hub.objects().get_iam_policy("bucket", "object")
24797///              .user_project("kasd")
24798///              .generation(-21)
24799///              .doit().await;
24800/// # }
24801/// ```
24802pub struct ObjectGetIamPolicyCall<'a, C>
24803where
24804    C: 'a,
24805{
24806    hub: &'a Storage<C>,
24807    _bucket: String,
24808    _object: String,
24809    _user_project: Option<String>,
24810    _generation: Option<i64>,
24811    _delegate: Option<&'a mut dyn common::Delegate>,
24812    _additional_params: HashMap<String, String>,
24813    _scopes: BTreeSet<String>,
24814}
24815
24816impl<'a, C> common::CallBuilder for ObjectGetIamPolicyCall<'a, C> {}
24817
24818impl<'a, C> ObjectGetIamPolicyCall<'a, C>
24819where
24820    C: common::Connector,
24821{
24822    /// Perform the operation you have build so far.
24823    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
24824        use std::borrow::Cow;
24825        use std::io::{Read, Seek};
24826
24827        use common::{url::Params, ToParts};
24828        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24829
24830        let mut dd = common::DefaultDelegate;
24831        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24832        dlg.begin(common::MethodInfo {
24833            id: "storage.objects.getIamPolicy",
24834            http_method: hyper::Method::GET,
24835        });
24836
24837        for &field in ["alt", "bucket", "object", "userProject", "generation"].iter() {
24838            if self._additional_params.contains_key(field) {
24839                dlg.finished(false);
24840                return Err(common::Error::FieldClash(field));
24841            }
24842        }
24843
24844        let mut params = Params::with_capacity(6 + self._additional_params.len());
24845        params.push("bucket", self._bucket);
24846        params.push("object", self._object);
24847        if let Some(value) = self._user_project.as_ref() {
24848            params.push("userProject", value);
24849        }
24850        if let Some(value) = self._generation.as_ref() {
24851            params.push("generation", value.to_string());
24852        }
24853
24854        params.extend(self._additional_params.iter());
24855
24856        params.push("alt", "json");
24857        let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}/iam";
24858        if self._scopes.is_empty() {
24859            self._scopes
24860                .insert(Scope::CloudPlatform.as_ref().to_string());
24861        }
24862
24863        #[allow(clippy::single_element_loop)]
24864        for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object")].iter() {
24865            url = params.uri_replacement(url, param_name, find_this, false);
24866        }
24867        {
24868            let to_remove = ["object", "bucket"];
24869            params.remove_params(&to_remove);
24870        }
24871
24872        let url = params.parse_with_url(&url);
24873
24874        loop {
24875            let token = match self
24876                .hub
24877                .auth
24878                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24879                .await
24880            {
24881                Ok(token) => token,
24882                Err(e) => match dlg.token(e) {
24883                    Ok(token) => token,
24884                    Err(e) => {
24885                        dlg.finished(false);
24886                        return Err(common::Error::MissingToken(e));
24887                    }
24888                },
24889            };
24890            let mut req_result = {
24891                let client = &self.hub.client;
24892                dlg.pre_request();
24893                let mut req_builder = hyper::Request::builder()
24894                    .method(hyper::Method::GET)
24895                    .uri(url.as_str())
24896                    .header(USER_AGENT, self.hub._user_agent.clone());
24897
24898                if let Some(token) = token.as_ref() {
24899                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24900                }
24901
24902                let request = req_builder
24903                    .header(CONTENT_LENGTH, 0_u64)
24904                    .body(common::to_body::<String>(None));
24905
24906                client.request(request.unwrap()).await
24907            };
24908
24909            match req_result {
24910                Err(err) => {
24911                    if let common::Retry::After(d) = dlg.http_error(&err) {
24912                        sleep(d).await;
24913                        continue;
24914                    }
24915                    dlg.finished(false);
24916                    return Err(common::Error::HttpError(err));
24917                }
24918                Ok(res) => {
24919                    let (mut parts, body) = res.into_parts();
24920                    let mut body = common::Body::new(body);
24921                    if !parts.status.is_success() {
24922                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24923                        let error = serde_json::from_str(&common::to_string(&bytes));
24924                        let response = common::to_response(parts, bytes.into());
24925
24926                        if let common::Retry::After(d) =
24927                            dlg.http_failure(&response, error.as_ref().ok())
24928                        {
24929                            sleep(d).await;
24930                            continue;
24931                        }
24932
24933                        dlg.finished(false);
24934
24935                        return Err(match error {
24936                            Ok(value) => common::Error::BadRequest(value),
24937                            _ => common::Error::Failure(response),
24938                        });
24939                    }
24940                    let response = {
24941                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24942                        let encoded = common::to_string(&bytes);
24943                        match serde_json::from_str(&encoded) {
24944                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24945                            Err(error) => {
24946                                dlg.response_json_decode_error(&encoded, &error);
24947                                return Err(common::Error::JsonDecodeError(
24948                                    encoded.to_string(),
24949                                    error,
24950                                ));
24951                            }
24952                        }
24953                    };
24954
24955                    dlg.finished(true);
24956                    return Ok(response);
24957                }
24958            }
24959        }
24960    }
24961
24962    /// Name of the bucket in which the object resides.
24963    ///
24964    /// Sets the *bucket* path property to the given value.
24965    ///
24966    /// Even though the property as already been set when instantiating this call,
24967    /// we provide this method for API completeness.
24968    pub fn bucket(mut self, new_value: &str) -> ObjectGetIamPolicyCall<'a, C> {
24969        self._bucket = new_value.to_string();
24970        self
24971    }
24972    /// Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
24973    ///
24974    /// Sets the *object* path property to the given value.
24975    ///
24976    /// Even though the property as already been set when instantiating this call,
24977    /// we provide this method for API completeness.
24978    pub fn object(mut self, new_value: &str) -> ObjectGetIamPolicyCall<'a, C> {
24979        self._object = new_value.to_string();
24980        self
24981    }
24982    /// The project to be billed for this request. Required for Requester Pays buckets.
24983    ///
24984    /// Sets the *user project* query property to the given value.
24985    pub fn user_project(mut self, new_value: &str) -> ObjectGetIamPolicyCall<'a, C> {
24986        self._user_project = Some(new_value.to_string());
24987        self
24988    }
24989    /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
24990    ///
24991    /// Sets the *generation* query property to the given value.
24992    pub fn generation(mut self, new_value: i64) -> ObjectGetIamPolicyCall<'a, C> {
24993        self._generation = Some(new_value);
24994        self
24995    }
24996    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24997    /// while executing the actual API request.
24998    ///
24999    /// ````text
25000    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25001    /// ````
25002    ///
25003    /// Sets the *delegate* property to the given value.
25004    pub fn delegate(
25005        mut self,
25006        new_value: &'a mut dyn common::Delegate,
25007    ) -> ObjectGetIamPolicyCall<'a, C> {
25008        self._delegate = Some(new_value);
25009        self
25010    }
25011
25012    /// Set any additional parameter of the query string used in the request.
25013    /// It should be used to set parameters which are not yet available through their own
25014    /// setters.
25015    ///
25016    /// Please note that this method must not be used to set any of the known parameters
25017    /// which have their own setter method. If done anyway, the request will fail.
25018    ///
25019    /// # Additional Parameters
25020    ///
25021    /// * *alt* (query-string) - Data format for the response.
25022    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25023    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
25024    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25025    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25026    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
25027    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
25028    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
25029    pub fn param<T>(mut self, name: T, value: T) -> ObjectGetIamPolicyCall<'a, C>
25030    where
25031        T: AsRef<str>,
25032    {
25033        self._additional_params
25034            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25035        self
25036    }
25037
25038    /// Identifies the authorization scope for the method you are building.
25039    ///
25040    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25041    /// [`Scope::CloudPlatform`].
25042    ///
25043    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25044    /// tokens for more than one scope.
25045    ///
25046    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25047    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25048    /// sufficient, a read-write scope will do as well.
25049    pub fn add_scope<St>(mut self, scope: St) -> ObjectGetIamPolicyCall<'a, C>
25050    where
25051        St: AsRef<str>,
25052    {
25053        self._scopes.insert(String::from(scope.as_ref()));
25054        self
25055    }
25056    /// Identifies the authorization scope(s) for the method you are building.
25057    ///
25058    /// See [`Self::add_scope()`] for details.
25059    pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectGetIamPolicyCall<'a, C>
25060    where
25061        I: IntoIterator<Item = St>,
25062        St: AsRef<str>,
25063    {
25064        self._scopes
25065            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25066        self
25067    }
25068
25069    /// Removes all scopes, and no default scope will be used either.
25070    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25071    /// for details).
25072    pub fn clear_scopes(mut self) -> ObjectGetIamPolicyCall<'a, C> {
25073        self._scopes.clear();
25074        self
25075    }
25076}
25077
25078/// Stores a new object and metadata.
25079///
25080/// A builder for the *insert* method supported by a *object* resource.
25081/// It is not used directly, but through a [`ObjectMethods`] instance.
25082///
25083/// # Example
25084///
25085/// Instantiate a resource method builder
25086///
25087/// ```test_harness,no_run
25088/// # extern crate hyper;
25089/// # extern crate hyper_rustls;
25090/// # extern crate google_storage1 as storage1;
25091/// use storage1::api::Object;
25092/// use std::fs;
25093/// # async fn dox() {
25094/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25095///
25096/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25097/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
25098/// #     secret,
25099/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25100/// # ).build().await.unwrap();
25101///
25102/// # let client = hyper_util::client::legacy::Client::builder(
25103/// #     hyper_util::rt::TokioExecutor::new()
25104/// # )
25105/// # .build(
25106/// #     hyper_rustls::HttpsConnectorBuilder::new()
25107/// #         .with_native_roots()
25108/// #         .unwrap()
25109/// #         .https_or_http()
25110/// #         .enable_http1()
25111/// #         .build()
25112/// # );
25113/// # let mut hub = Storage::new(client, auth);
25114/// // As the method needs a request, you would usually fill it with the desired information
25115/// // into the respective structure. Some of the parts shown here might not be applicable !
25116/// // Values shown here are possibly random and not representative !
25117/// let mut req = Object::default();
25118///
25119/// // You can configure optional parameters by calling the respective setters at will, and
25120/// // execute the final call using `upload_resumable(...)`.
25121/// // Values shown here are possibly random and not representative !
25122/// let result = hub.objects().insert(req, "bucket")
25123///              .user_project("At")
25124///              .projection("erat")
25125///              .predefined_acl("clita")
25126///              .name("vero")
25127///              .kms_key_name("invidunt")
25128///              .if_metageneration_not_match(-91)
25129///              .if_metageneration_match(-81)
25130///              .if_generation_not_match(-31)
25131///              .if_generation_match(-19)
25132///              .content_encoding("ipsum")
25133///              .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
25134/// # }
25135/// ```
25136pub struct ObjectInsertCall<'a, C>
25137where
25138    C: 'a,
25139{
25140    hub: &'a Storage<C>,
25141    _request: Object,
25142    _bucket: String,
25143    _user_project: Option<String>,
25144    _projection: Option<String>,
25145    _predefined_acl: Option<String>,
25146    _name: Option<String>,
25147    _kms_key_name: Option<String>,
25148    _if_metageneration_not_match: Option<i64>,
25149    _if_metageneration_match: Option<i64>,
25150    _if_generation_not_match: Option<i64>,
25151    _if_generation_match: Option<i64>,
25152    _content_encoding: Option<String>,
25153    _delegate: Option<&'a mut dyn common::Delegate>,
25154    _additional_params: HashMap<String, String>,
25155    _scopes: BTreeSet<String>,
25156}
25157
25158impl<'a, C> common::CallBuilder for ObjectInsertCall<'a, C> {}
25159
25160impl<'a, C> ObjectInsertCall<'a, C>
25161where
25162    C: common::Connector,
25163{
25164    /// Perform the operation you have build so far.
25165    async fn doit<RS>(
25166        mut self,
25167        mut reader: RS,
25168        reader_mime_type: mime::Mime,
25169        protocol: common::UploadProtocol,
25170    ) -> common::Result<(common::Response, Object)>
25171    where
25172        RS: common::ReadSeek,
25173    {
25174        use std::borrow::Cow;
25175        use std::io::{Read, Seek};
25176
25177        use common::{url::Params, ToParts};
25178        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25179
25180        let mut dd = common::DefaultDelegate;
25181        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25182        dlg.begin(common::MethodInfo {
25183            id: "storage.objects.insert",
25184            http_method: hyper::Method::POST,
25185        });
25186
25187        for &field in [
25188            "alt",
25189            "bucket",
25190            "userProject",
25191            "projection",
25192            "predefinedAcl",
25193            "name",
25194            "kmsKeyName",
25195            "ifMetagenerationNotMatch",
25196            "ifMetagenerationMatch",
25197            "ifGenerationNotMatch",
25198            "ifGenerationMatch",
25199            "contentEncoding",
25200        ]
25201        .iter()
25202        {
25203            if self._additional_params.contains_key(field) {
25204                dlg.finished(false);
25205                return Err(common::Error::FieldClash(field));
25206            }
25207        }
25208
25209        let mut params = Params::with_capacity(14 + self._additional_params.len());
25210        params.push("bucket", self._bucket);
25211        if let Some(value) = self._user_project.as_ref() {
25212            params.push("userProject", value);
25213        }
25214        if let Some(value) = self._projection.as_ref() {
25215            params.push("projection", value);
25216        }
25217        if let Some(value) = self._predefined_acl.as_ref() {
25218            params.push("predefinedAcl", value);
25219        }
25220        if let Some(value) = self._name.as_ref() {
25221            params.push("name", value);
25222        }
25223        if let Some(value) = self._kms_key_name.as_ref() {
25224            params.push("kmsKeyName", value);
25225        }
25226        if let Some(value) = self._if_metageneration_not_match.as_ref() {
25227            params.push("ifMetagenerationNotMatch", value.to_string());
25228        }
25229        if let Some(value) = self._if_metageneration_match.as_ref() {
25230            params.push("ifMetagenerationMatch", value.to_string());
25231        }
25232        if let Some(value) = self._if_generation_not_match.as_ref() {
25233            params.push("ifGenerationNotMatch", value.to_string());
25234        }
25235        if let Some(value) = self._if_generation_match.as_ref() {
25236            params.push("ifGenerationMatch", value.to_string());
25237        }
25238        if let Some(value) = self._content_encoding.as_ref() {
25239            params.push("contentEncoding", value);
25240        }
25241
25242        params.extend(self._additional_params.iter());
25243
25244        params.push("alt", "json");
25245        let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
25246            (
25247                self.hub._root_url.clone() + "resumable/upload/storage/v1/b/{bucket}/o",
25248                "resumable",
25249            )
25250        } else if protocol == common::UploadProtocol::Simple {
25251            (
25252                self.hub._root_url.clone() + "upload/storage/v1/b/{bucket}/o",
25253                "multipart",
25254            )
25255        } else {
25256            unreachable!()
25257        };
25258        params.push("uploadType", upload_type);
25259        if self._scopes.is_empty() {
25260            self._scopes
25261                .insert(Scope::CloudPlatform.as_ref().to_string());
25262        }
25263
25264        #[allow(clippy::single_element_loop)]
25265        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
25266            url = params.uri_replacement(url, param_name, find_this, false);
25267        }
25268        {
25269            let to_remove = ["bucket"];
25270            params.remove_params(&to_remove);
25271        }
25272
25273        let url = params.parse_with_url(&url);
25274
25275        let mut json_mime_type = mime::APPLICATION_JSON;
25276        let mut request_value_reader = {
25277            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25278            common::remove_json_null_values(&mut value);
25279            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25280            serde_json::to_writer(&mut dst, &value).unwrap();
25281            dst
25282        };
25283        let request_size = request_value_reader
25284            .seek(std::io::SeekFrom::End(0))
25285            .unwrap();
25286        request_value_reader
25287            .seek(std::io::SeekFrom::Start(0))
25288            .unwrap();
25289
25290        let mut upload_url_from_server;
25291
25292        loop {
25293            let token = match self
25294                .hub
25295                .auth
25296                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25297                .await
25298            {
25299                Ok(token) => token,
25300                Err(e) => match dlg.token(e) {
25301                    Ok(token) => token,
25302                    Err(e) => {
25303                        dlg.finished(false);
25304                        return Err(common::Error::MissingToken(e));
25305                    }
25306                },
25307            };
25308            request_value_reader
25309                .seek(std::io::SeekFrom::Start(0))
25310                .unwrap();
25311            let mut req_result = {
25312                let mut mp_reader: common::MultiPartReader = Default::default();
25313                let (mut body_reader, content_type) = match protocol {
25314                    common::UploadProtocol::Simple => {
25315                        mp_reader.reserve_exact(2);
25316                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
25317                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
25318
25319                        mp_reader
25320                            .add_part(
25321                                &mut request_value_reader,
25322                                request_size,
25323                                json_mime_type.clone(),
25324                            )
25325                            .add_part(&mut reader, size, reader_mime_type.clone());
25326                        (
25327                            &mut mp_reader as &mut (dyn std::io::Read + Send),
25328                            common::MultiPartReader::mime_type(),
25329                        )
25330                    }
25331                    _ => (
25332                        &mut request_value_reader as &mut (dyn std::io::Read + Send),
25333                        json_mime_type.clone(),
25334                    ),
25335                };
25336                let client = &self.hub.client;
25337                dlg.pre_request();
25338                let mut req_builder = hyper::Request::builder()
25339                    .method(hyper::Method::POST)
25340                    .uri(url.as_str())
25341                    .header(USER_AGENT, self.hub._user_agent.clone());
25342
25343                if let Some(token) = token.as_ref() {
25344                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25345                }
25346
25347                upload_url_from_server = true;
25348                if protocol == common::UploadProtocol::Resumable {
25349                    req_builder = req_builder
25350                        .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
25351                }
25352
25353                let mut body_reader_bytes = vec![];
25354                body_reader.read_to_end(&mut body_reader_bytes).unwrap();
25355                let request = req_builder
25356                    .header(CONTENT_TYPE, content_type.to_string())
25357                    .body(common::to_body(body_reader_bytes.into()));
25358
25359                client.request(request.unwrap()).await
25360            };
25361
25362            match req_result {
25363                Err(err) => {
25364                    if let common::Retry::After(d) = dlg.http_error(&err) {
25365                        sleep(d).await;
25366                        continue;
25367                    }
25368                    dlg.finished(false);
25369                    return Err(common::Error::HttpError(err));
25370                }
25371                Ok(res) => {
25372                    let (mut parts, body) = res.into_parts();
25373                    let mut body = common::Body::new(body);
25374                    if !parts.status.is_success() {
25375                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25376                        let error = serde_json::from_str(&common::to_string(&bytes));
25377                        let response = common::to_response(parts, bytes.into());
25378
25379                        if let common::Retry::After(d) =
25380                            dlg.http_failure(&response, error.as_ref().ok())
25381                        {
25382                            sleep(d).await;
25383                            continue;
25384                        }
25385
25386                        dlg.finished(false);
25387
25388                        return Err(match error {
25389                            Ok(value) => common::Error::BadRequest(value),
25390                            _ => common::Error::Failure(response),
25391                        });
25392                    }
25393                    if protocol == common::UploadProtocol::Resumable {
25394                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
25395                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
25396
25397                        let upload_result = {
25398                            let url_str = &parts
25399                                .headers
25400                                .get("Location")
25401                                .expect("LOCATION header is part of protocol")
25402                                .to_str()
25403                                .unwrap();
25404                            if upload_url_from_server {
25405                                dlg.store_upload_url(Some(url_str));
25406                            }
25407
25408                            common::ResumableUploadHelper {
25409                                client: &self.hub.client,
25410                                delegate: dlg,
25411                                start_at: if upload_url_from_server {
25412                                    Some(0)
25413                                } else {
25414                                    None
25415                                },
25416                                auth: &self.hub.auth,
25417                                user_agent: &self.hub._user_agent,
25418                                // TODO: Check this assumption
25419                                auth_header: format!(
25420                                    "Bearer {}",
25421                                    token
25422                                        .ok_or_else(|| common::Error::MissingToken(
25423                                            "resumable upload requires token".into()
25424                                        ))?
25425                                        .as_str()
25426                                ),
25427                                url: url_str,
25428                                reader: &mut reader,
25429                                media_type: reader_mime_type.clone(),
25430                                content_length: size,
25431                            }
25432                            .upload()
25433                            .await
25434                        };
25435                        match upload_result {
25436                            None => {
25437                                dlg.finished(false);
25438                                return Err(common::Error::Cancelled);
25439                            }
25440                            Some(Err(err)) => {
25441                                dlg.finished(false);
25442                                return Err(common::Error::HttpError(err));
25443                            }
25444                            Some(Ok(response)) => {
25445                                (parts, body) = response.into_parts();
25446                                if !parts.status.is_success() {
25447                                    dlg.store_upload_url(None);
25448                                    dlg.finished(false);
25449                                    return Err(common::Error::Failure(
25450                                        common::Response::from_parts(parts, body),
25451                                    ));
25452                                }
25453                            }
25454                        }
25455                    }
25456                    let response = {
25457                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25458                        let encoded = common::to_string(&bytes);
25459                        match serde_json::from_str(&encoded) {
25460                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25461                            Err(error) => {
25462                                dlg.response_json_decode_error(&encoded, &error);
25463                                return Err(common::Error::JsonDecodeError(
25464                                    encoded.to_string(),
25465                                    error,
25466                                ));
25467                            }
25468                        }
25469                    };
25470
25471                    dlg.finished(true);
25472                    return Ok(response);
25473                }
25474            }
25475        }
25476    }
25477
25478    /// Upload media in a resumable fashion.
25479    /// Even if the upload fails or is interrupted, it can be resumed for a
25480    /// certain amount of time as the server maintains state temporarily.
25481    ///
25482    /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
25483    /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
25484    /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
25485    /// `cancel_chunk_upload(...)`.
25486    ///
25487    /// * *multipart*: yes
25488    /// * *max size*: 0kb
25489    /// * *valid mime types*: '*/*'
25490    pub async fn upload_resumable<RS>(
25491        self,
25492        resumeable_stream: RS,
25493        mime_type: mime::Mime,
25494    ) -> common::Result<(common::Response, Object)>
25495    where
25496        RS: common::ReadSeek,
25497    {
25498        self.doit(
25499            resumeable_stream,
25500            mime_type,
25501            common::UploadProtocol::Resumable,
25502        )
25503        .await
25504    }
25505    /// Upload media all at once.
25506    /// If the upload fails for whichever reason, all progress is lost.
25507    ///
25508    /// * *multipart*: yes
25509    /// * *max size*: 0kb
25510    /// * *valid mime types*: '*/*'
25511    pub async fn upload<RS>(
25512        self,
25513        stream: RS,
25514        mime_type: mime::Mime,
25515    ) -> common::Result<(common::Response, Object)>
25516    where
25517        RS: common::ReadSeek,
25518    {
25519        self.doit(stream, mime_type, common::UploadProtocol::Simple)
25520            .await
25521    }
25522
25523    ///
25524    /// Sets the *request* property to the given value.
25525    ///
25526    /// Even though the property as already been set when instantiating this call,
25527    /// we provide this method for API completeness.
25528    pub fn request(mut self, new_value: Object) -> ObjectInsertCall<'a, C> {
25529        self._request = new_value;
25530        self
25531    }
25532    /// Name of the bucket in which to store the new object. Overrides the provided object metadata's bucket value, if any.
25533    ///
25534    /// Sets the *bucket* path property to the given value.
25535    ///
25536    /// Even though the property as already been set when instantiating this call,
25537    /// we provide this method for API completeness.
25538    pub fn bucket(mut self, new_value: &str) -> ObjectInsertCall<'a, C> {
25539        self._bucket = new_value.to_string();
25540        self
25541    }
25542    /// The project to be billed for this request. Required for Requester Pays buckets.
25543    ///
25544    /// Sets the *user project* query property to the given value.
25545    pub fn user_project(mut self, new_value: &str) -> ObjectInsertCall<'a, C> {
25546        self._user_project = Some(new_value.to_string());
25547        self
25548    }
25549    /// Set of properties to return. Defaults to noAcl, unless the object resource specifies the acl property, when it defaults to full.
25550    ///
25551    /// Sets the *projection* query property to the given value.
25552    pub fn projection(mut self, new_value: &str) -> ObjectInsertCall<'a, C> {
25553        self._projection = Some(new_value.to_string());
25554        self
25555    }
25556    /// Apply a predefined set of access controls to this object.
25557    ///
25558    /// Sets the *predefined acl* query property to the given value.
25559    pub fn predefined_acl(mut self, new_value: &str) -> ObjectInsertCall<'a, C> {
25560        self._predefined_acl = Some(new_value.to_string());
25561        self
25562    }
25563    /// Name of the object. Required when the object metadata is not otherwise provided. Overrides the object metadata's name value, if any. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
25564    ///
25565    /// Sets the *name* query property to the given value.
25566    pub fn name(mut self, new_value: &str) -> ObjectInsertCall<'a, C> {
25567        self._name = Some(new_value.to_string());
25568        self
25569    }
25570    /// Resource name of the Cloud KMS key, of the form projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key, that will be used to encrypt the object. Overrides the object metadata's kms_key_name value, if any.
25571    ///
25572    /// Sets the *kms key name* query property to the given value.
25573    pub fn kms_key_name(mut self, new_value: &str) -> ObjectInsertCall<'a, C> {
25574        self._kms_key_name = Some(new_value.to_string());
25575        self
25576    }
25577    /// Makes the operation conditional on whether the object's current metageneration does not match the given value.
25578    ///
25579    /// Sets the *if metageneration not match* query property to the given value.
25580    pub fn if_metageneration_not_match(mut self, new_value: i64) -> ObjectInsertCall<'a, C> {
25581        self._if_metageneration_not_match = Some(new_value);
25582        self
25583    }
25584    /// Makes the operation conditional on whether the object's current metageneration matches the given value.
25585    ///
25586    /// Sets the *if metageneration match* query property to the given value.
25587    pub fn if_metageneration_match(mut self, new_value: i64) -> ObjectInsertCall<'a, C> {
25588        self._if_metageneration_match = Some(new_value);
25589        self
25590    }
25591    /// Makes the operation conditional on whether the object's current generation does not match the given value. If no live object exists, the precondition fails. Setting to 0 makes the operation succeed only if there is a live version of the object.
25592    ///
25593    /// Sets the *if generation not match* query property to the given value.
25594    pub fn if_generation_not_match(mut self, new_value: i64) -> ObjectInsertCall<'a, C> {
25595        self._if_generation_not_match = Some(new_value);
25596        self
25597    }
25598    /// Makes the operation conditional on whether the object's current generation matches the given value. Setting to 0 makes the operation succeed only if there are no live versions of the object.
25599    ///
25600    /// Sets the *if generation match* query property to the given value.
25601    pub fn if_generation_match(mut self, new_value: i64) -> ObjectInsertCall<'a, C> {
25602        self._if_generation_match = Some(new_value);
25603        self
25604    }
25605    /// If set, sets the contentEncoding property of the final object to this value. Setting this parameter is equivalent to setting the contentEncoding metadata property. This can be useful when uploading an object with uploadType=media to indicate the encoding of the content being uploaded.
25606    ///
25607    /// Sets the *content encoding* query property to the given value.
25608    pub fn content_encoding(mut self, new_value: &str) -> ObjectInsertCall<'a, C> {
25609        self._content_encoding = Some(new_value.to_string());
25610        self
25611    }
25612    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25613    /// while executing the actual API request.
25614    ///
25615    /// ````text
25616    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25617    /// ````
25618    ///
25619    /// Sets the *delegate* property to the given value.
25620    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ObjectInsertCall<'a, C> {
25621        self._delegate = Some(new_value);
25622        self
25623    }
25624
25625    /// Set any additional parameter of the query string used in the request.
25626    /// It should be used to set parameters which are not yet available through their own
25627    /// setters.
25628    ///
25629    /// Please note that this method must not be used to set any of the known parameters
25630    /// which have their own setter method. If done anyway, the request will fail.
25631    ///
25632    /// # Additional Parameters
25633    ///
25634    /// * *alt* (query-string) - Data format for the response.
25635    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25636    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
25637    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25638    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25639    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
25640    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
25641    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
25642    pub fn param<T>(mut self, name: T, value: T) -> ObjectInsertCall<'a, C>
25643    where
25644        T: AsRef<str>,
25645    {
25646        self._additional_params
25647            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25648        self
25649    }
25650
25651    /// Identifies the authorization scope for the method you are building.
25652    ///
25653    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25654    /// [`Scope::CloudPlatform`].
25655    ///
25656    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25657    /// tokens for more than one scope.
25658    ///
25659    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25660    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25661    /// sufficient, a read-write scope will do as well.
25662    pub fn add_scope<St>(mut self, scope: St) -> ObjectInsertCall<'a, C>
25663    where
25664        St: AsRef<str>,
25665    {
25666        self._scopes.insert(String::from(scope.as_ref()));
25667        self
25668    }
25669    /// Identifies the authorization scope(s) for the method you are building.
25670    ///
25671    /// See [`Self::add_scope()`] for details.
25672    pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectInsertCall<'a, C>
25673    where
25674        I: IntoIterator<Item = St>,
25675        St: AsRef<str>,
25676    {
25677        self._scopes
25678            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25679        self
25680    }
25681
25682    /// Removes all scopes, and no default scope will be used either.
25683    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25684    /// for details).
25685    pub fn clear_scopes(mut self) -> ObjectInsertCall<'a, C> {
25686        self._scopes.clear();
25687        self
25688    }
25689}
25690
25691/// Retrieves a list of objects matching the criteria.
25692///
25693/// A builder for the *list* method supported by a *object* resource.
25694/// It is not used directly, but through a [`ObjectMethods`] instance.
25695///
25696/// # Example
25697///
25698/// Instantiate a resource method builder
25699///
25700/// ```test_harness,no_run
25701/// # extern crate hyper;
25702/// # extern crate hyper_rustls;
25703/// # extern crate google_storage1 as storage1;
25704/// # async fn dox() {
25705/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25706///
25707/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25708/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
25709/// #     secret,
25710/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25711/// # ).build().await.unwrap();
25712///
25713/// # let client = hyper_util::client::legacy::Client::builder(
25714/// #     hyper_util::rt::TokioExecutor::new()
25715/// # )
25716/// # .build(
25717/// #     hyper_rustls::HttpsConnectorBuilder::new()
25718/// #         .with_native_roots()
25719/// #         .unwrap()
25720/// #         .https_or_http()
25721/// #         .enable_http1()
25722/// #         .build()
25723/// # );
25724/// # let mut hub = Storage::new(client, auth);
25725/// // You can configure optional parameters by calling the respective setters at will, and
25726/// // execute the final call using `doit()`.
25727/// // Values shown here are possibly random and not representative !
25728/// let result = hub.objects().list("bucket")
25729///              .versions(false)
25730///              .user_project("elitr")
25731///              .start_offset("consetetur")
25732///              .soft_deleted(false)
25733///              .projection("clita")
25734///              .prefix("sit")
25735///              .page_token("takimata")
25736///              .max_results(70)
25737///              .match_glob("diam")
25738///              .include_trailing_delimiter(true)
25739///              .include_folders_as_prefixes(false)
25740///              .end_offset("diam")
25741///              .delimiter("diam")
25742///              .doit().await;
25743/// # }
25744/// ```
25745pub struct ObjectListCall<'a, C>
25746where
25747    C: 'a,
25748{
25749    hub: &'a Storage<C>,
25750    _bucket: String,
25751    _versions: Option<bool>,
25752    _user_project: Option<String>,
25753    _start_offset: Option<String>,
25754    _soft_deleted: Option<bool>,
25755    _projection: Option<String>,
25756    _prefix: Option<String>,
25757    _page_token: Option<String>,
25758    _max_results: Option<u32>,
25759    _match_glob: Option<String>,
25760    _include_trailing_delimiter: Option<bool>,
25761    _include_folders_as_prefixes: Option<bool>,
25762    _end_offset: Option<String>,
25763    _delimiter: Option<String>,
25764    _delegate: Option<&'a mut dyn common::Delegate>,
25765    _additional_params: HashMap<String, String>,
25766    _scopes: BTreeSet<String>,
25767}
25768
25769impl<'a, C> common::CallBuilder for ObjectListCall<'a, C> {}
25770
25771impl<'a, C> ObjectListCall<'a, C>
25772where
25773    C: common::Connector,
25774{
25775    /// Perform the operation you have build so far.
25776    pub async fn doit(mut self) -> common::Result<(common::Response, Objects)> {
25777        use std::borrow::Cow;
25778        use std::io::{Read, Seek};
25779
25780        use common::{url::Params, ToParts};
25781        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25782
25783        let mut dd = common::DefaultDelegate;
25784        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25785        dlg.begin(common::MethodInfo {
25786            id: "storage.objects.list",
25787            http_method: hyper::Method::GET,
25788        });
25789
25790        for &field in [
25791            "alt",
25792            "bucket",
25793            "versions",
25794            "userProject",
25795            "startOffset",
25796            "softDeleted",
25797            "projection",
25798            "prefix",
25799            "pageToken",
25800            "maxResults",
25801            "matchGlob",
25802            "includeTrailingDelimiter",
25803            "includeFoldersAsPrefixes",
25804            "endOffset",
25805            "delimiter",
25806        ]
25807        .iter()
25808        {
25809            if self._additional_params.contains_key(field) {
25810                dlg.finished(false);
25811                return Err(common::Error::FieldClash(field));
25812            }
25813        }
25814
25815        let mut params = Params::with_capacity(16 + self._additional_params.len());
25816        params.push("bucket", self._bucket);
25817        if let Some(value) = self._versions.as_ref() {
25818            params.push("versions", value.to_string());
25819        }
25820        if let Some(value) = self._user_project.as_ref() {
25821            params.push("userProject", value);
25822        }
25823        if let Some(value) = self._start_offset.as_ref() {
25824            params.push("startOffset", value);
25825        }
25826        if let Some(value) = self._soft_deleted.as_ref() {
25827            params.push("softDeleted", value.to_string());
25828        }
25829        if let Some(value) = self._projection.as_ref() {
25830            params.push("projection", value);
25831        }
25832        if let Some(value) = self._prefix.as_ref() {
25833            params.push("prefix", value);
25834        }
25835        if let Some(value) = self._page_token.as_ref() {
25836            params.push("pageToken", value);
25837        }
25838        if let Some(value) = self._max_results.as_ref() {
25839            params.push("maxResults", value.to_string());
25840        }
25841        if let Some(value) = self._match_glob.as_ref() {
25842            params.push("matchGlob", value);
25843        }
25844        if let Some(value) = self._include_trailing_delimiter.as_ref() {
25845            params.push("includeTrailingDelimiter", value.to_string());
25846        }
25847        if let Some(value) = self._include_folders_as_prefixes.as_ref() {
25848            params.push("includeFoldersAsPrefixes", value.to_string());
25849        }
25850        if let Some(value) = self._end_offset.as_ref() {
25851            params.push("endOffset", value);
25852        }
25853        if let Some(value) = self._delimiter.as_ref() {
25854            params.push("delimiter", value);
25855        }
25856
25857        params.extend(self._additional_params.iter());
25858
25859        params.push("alt", "json");
25860        let mut url = self.hub._base_url.clone() + "b/{bucket}/o";
25861        if self._scopes.is_empty() {
25862            self._scopes
25863                .insert(Scope::CloudPlatform.as_ref().to_string());
25864        }
25865
25866        #[allow(clippy::single_element_loop)]
25867        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
25868            url = params.uri_replacement(url, param_name, find_this, false);
25869        }
25870        {
25871            let to_remove = ["bucket"];
25872            params.remove_params(&to_remove);
25873        }
25874
25875        let url = params.parse_with_url(&url);
25876
25877        loop {
25878            let token = match self
25879                .hub
25880                .auth
25881                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25882                .await
25883            {
25884                Ok(token) => token,
25885                Err(e) => match dlg.token(e) {
25886                    Ok(token) => token,
25887                    Err(e) => {
25888                        dlg.finished(false);
25889                        return Err(common::Error::MissingToken(e));
25890                    }
25891                },
25892            };
25893            let mut req_result = {
25894                let client = &self.hub.client;
25895                dlg.pre_request();
25896                let mut req_builder = hyper::Request::builder()
25897                    .method(hyper::Method::GET)
25898                    .uri(url.as_str())
25899                    .header(USER_AGENT, self.hub._user_agent.clone());
25900
25901                if let Some(token) = token.as_ref() {
25902                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25903                }
25904
25905                let request = req_builder
25906                    .header(CONTENT_LENGTH, 0_u64)
25907                    .body(common::to_body::<String>(None));
25908
25909                client.request(request.unwrap()).await
25910            };
25911
25912            match req_result {
25913                Err(err) => {
25914                    if let common::Retry::After(d) = dlg.http_error(&err) {
25915                        sleep(d).await;
25916                        continue;
25917                    }
25918                    dlg.finished(false);
25919                    return Err(common::Error::HttpError(err));
25920                }
25921                Ok(res) => {
25922                    let (mut parts, body) = res.into_parts();
25923                    let mut body = common::Body::new(body);
25924                    if !parts.status.is_success() {
25925                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25926                        let error = serde_json::from_str(&common::to_string(&bytes));
25927                        let response = common::to_response(parts, bytes.into());
25928
25929                        if let common::Retry::After(d) =
25930                            dlg.http_failure(&response, error.as_ref().ok())
25931                        {
25932                            sleep(d).await;
25933                            continue;
25934                        }
25935
25936                        dlg.finished(false);
25937
25938                        return Err(match error {
25939                            Ok(value) => common::Error::BadRequest(value),
25940                            _ => common::Error::Failure(response),
25941                        });
25942                    }
25943                    let response = {
25944                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25945                        let encoded = common::to_string(&bytes);
25946                        match serde_json::from_str(&encoded) {
25947                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25948                            Err(error) => {
25949                                dlg.response_json_decode_error(&encoded, &error);
25950                                return Err(common::Error::JsonDecodeError(
25951                                    encoded.to_string(),
25952                                    error,
25953                                ));
25954                            }
25955                        }
25956                    };
25957
25958                    dlg.finished(true);
25959                    return Ok(response);
25960                }
25961            }
25962        }
25963    }
25964
25965    /// Name of the bucket in which to look for objects.
25966    ///
25967    /// Sets the *bucket* path property to the given value.
25968    ///
25969    /// Even though the property as already been set when instantiating this call,
25970    /// we provide this method for API completeness.
25971    pub fn bucket(mut self, new_value: &str) -> ObjectListCall<'a, C> {
25972        self._bucket = new_value.to_string();
25973        self
25974    }
25975    /// If true, lists all versions of an object as distinct results. The default is false. For more information, see Object Versioning.
25976    ///
25977    /// Sets the *versions* query property to the given value.
25978    pub fn versions(mut self, new_value: bool) -> ObjectListCall<'a, C> {
25979        self._versions = Some(new_value);
25980        self
25981    }
25982    /// The project to be billed for this request. Required for Requester Pays buckets.
25983    ///
25984    /// Sets the *user project* query property to the given value.
25985    pub fn user_project(mut self, new_value: &str) -> ObjectListCall<'a, C> {
25986        self._user_project = Some(new_value.to_string());
25987        self
25988    }
25989    /// Filter results to objects whose names are lexicographically equal to or after startOffset. If endOffset is also set, the objects listed will have names between startOffset (inclusive) and endOffset (exclusive).
25990    ///
25991    /// Sets the *start offset* query property to the given value.
25992    pub fn start_offset(mut self, new_value: &str) -> ObjectListCall<'a, C> {
25993        self._start_offset = Some(new_value.to_string());
25994        self
25995    }
25996    /// If true, only soft-deleted object versions will be listed. The default is false. For more information, see Soft Delete.
25997    ///
25998    /// Sets the *soft deleted* query property to the given value.
25999    pub fn soft_deleted(mut self, new_value: bool) -> ObjectListCall<'a, C> {
26000        self._soft_deleted = Some(new_value);
26001        self
26002    }
26003    /// Set of properties to return. Defaults to noAcl.
26004    ///
26005    /// Sets the *projection* query property to the given value.
26006    pub fn projection(mut self, new_value: &str) -> ObjectListCall<'a, C> {
26007        self._projection = Some(new_value.to_string());
26008        self
26009    }
26010    /// Filter results to objects whose names begin with this prefix.
26011    ///
26012    /// Sets the *prefix* query property to the given value.
26013    pub fn prefix(mut self, new_value: &str) -> ObjectListCall<'a, C> {
26014        self._prefix = Some(new_value.to_string());
26015        self
26016    }
26017    /// A previously-returned page token representing part of the larger set of results to view.
26018    ///
26019    /// Sets the *page token* query property to the given value.
26020    pub fn page_token(mut self, new_value: &str) -> ObjectListCall<'a, C> {
26021        self._page_token = Some(new_value.to_string());
26022        self
26023    }
26024    /// Maximum number of items plus prefixes to return in a single page of responses. As duplicate prefixes are omitted, fewer total results may be returned than requested. The service will use this parameter or 1,000 items, whichever is smaller.
26025    ///
26026    /// Sets the *max results* query property to the given value.
26027    pub fn max_results(mut self, new_value: u32) -> ObjectListCall<'a, C> {
26028        self._max_results = Some(new_value);
26029        self
26030    }
26031    /// Filter results to objects and prefixes that match this glob pattern.
26032    ///
26033    /// Sets the *match glob* query property to the given value.
26034    pub fn match_glob(mut self, new_value: &str) -> ObjectListCall<'a, C> {
26035        self._match_glob = Some(new_value.to_string());
26036        self
26037    }
26038    /// If true, objects that end in exactly one instance of delimiter will have their metadata included in items in addition to prefixes.
26039    ///
26040    /// Sets the *include trailing delimiter* query property to the given value.
26041    pub fn include_trailing_delimiter(mut self, new_value: bool) -> ObjectListCall<'a, C> {
26042        self._include_trailing_delimiter = Some(new_value);
26043        self
26044    }
26045    /// Only applicable if delimiter is set to '/'. If true, will also include folders and managed folders (besides objects) in the returned prefixes.
26046    ///
26047    /// Sets the *include folders as prefixes* query property to the given value.
26048    pub fn include_folders_as_prefixes(mut self, new_value: bool) -> ObjectListCall<'a, C> {
26049        self._include_folders_as_prefixes = Some(new_value);
26050        self
26051    }
26052    /// Filter results to objects whose names are lexicographically before endOffset. If startOffset is also set, the objects listed will have names between startOffset (inclusive) and endOffset (exclusive).
26053    ///
26054    /// Sets the *end offset* query property to the given value.
26055    pub fn end_offset(mut self, new_value: &str) -> ObjectListCall<'a, C> {
26056        self._end_offset = Some(new_value.to_string());
26057        self
26058    }
26059    /// Returns results in a directory-like mode. items will contain only objects whose names, aside from the prefix, do not contain delimiter. Objects whose names, aside from the prefix, contain delimiter will have their name, truncated after the delimiter, returned in prefixes. Duplicate prefixes are omitted.
26060    ///
26061    /// Sets the *delimiter* query property to the given value.
26062    pub fn delimiter(mut self, new_value: &str) -> ObjectListCall<'a, C> {
26063        self._delimiter = Some(new_value.to_string());
26064        self
26065    }
26066    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26067    /// while executing the actual API request.
26068    ///
26069    /// ````text
26070    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26071    /// ````
26072    ///
26073    /// Sets the *delegate* property to the given value.
26074    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ObjectListCall<'a, C> {
26075        self._delegate = Some(new_value);
26076        self
26077    }
26078
26079    /// Set any additional parameter of the query string used in the request.
26080    /// It should be used to set parameters which are not yet available through their own
26081    /// setters.
26082    ///
26083    /// Please note that this method must not be used to set any of the known parameters
26084    /// which have their own setter method. If done anyway, the request will fail.
26085    ///
26086    /// # Additional Parameters
26087    ///
26088    /// * *alt* (query-string) - Data format for the response.
26089    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26090    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
26091    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26092    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26093    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
26094    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
26095    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
26096    pub fn param<T>(mut self, name: T, value: T) -> ObjectListCall<'a, C>
26097    where
26098        T: AsRef<str>,
26099    {
26100        self._additional_params
26101            .insert(name.as_ref().to_string(), value.as_ref().to_string());
26102        self
26103    }
26104
26105    /// Identifies the authorization scope for the method you are building.
26106    ///
26107    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26108    /// [`Scope::CloudPlatform`].
26109    ///
26110    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26111    /// tokens for more than one scope.
26112    ///
26113    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26114    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26115    /// sufficient, a read-write scope will do as well.
26116    pub fn add_scope<St>(mut self, scope: St) -> ObjectListCall<'a, C>
26117    where
26118        St: AsRef<str>,
26119    {
26120        self._scopes.insert(String::from(scope.as_ref()));
26121        self
26122    }
26123    /// Identifies the authorization scope(s) for the method you are building.
26124    ///
26125    /// See [`Self::add_scope()`] for details.
26126    pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectListCall<'a, C>
26127    where
26128        I: IntoIterator<Item = St>,
26129        St: AsRef<str>,
26130    {
26131        self._scopes
26132            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26133        self
26134    }
26135
26136    /// Removes all scopes, and no default scope will be used either.
26137    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26138    /// for details).
26139    pub fn clear_scopes(mut self) -> ObjectListCall<'a, C> {
26140        self._scopes.clear();
26141        self
26142    }
26143}
26144
26145/// Patches an object's metadata.
26146///
26147/// A builder for the *patch* method supported by a *object* resource.
26148/// It is not used directly, but through a [`ObjectMethods`] instance.
26149///
26150/// # Example
26151///
26152/// Instantiate a resource method builder
26153///
26154/// ```test_harness,no_run
26155/// # extern crate hyper;
26156/// # extern crate hyper_rustls;
26157/// # extern crate google_storage1 as storage1;
26158/// use storage1::api::Object;
26159/// # async fn dox() {
26160/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26161///
26162/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26163/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
26164/// #     secret,
26165/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26166/// # ).build().await.unwrap();
26167///
26168/// # let client = hyper_util::client::legacy::Client::builder(
26169/// #     hyper_util::rt::TokioExecutor::new()
26170/// # )
26171/// # .build(
26172/// #     hyper_rustls::HttpsConnectorBuilder::new()
26173/// #         .with_native_roots()
26174/// #         .unwrap()
26175/// #         .https_or_http()
26176/// #         .enable_http1()
26177/// #         .build()
26178/// # );
26179/// # let mut hub = Storage::new(client, auth);
26180/// // As the method needs a request, you would usually fill it with the desired information
26181/// // into the respective structure. Some of the parts shown here might not be applicable !
26182/// // Values shown here are possibly random and not representative !
26183/// let mut req = Object::default();
26184///
26185/// // You can configure optional parameters by calling the respective setters at will, and
26186/// // execute the final call using `doit()`.
26187/// // Values shown here are possibly random and not representative !
26188/// let result = hub.objects().patch(req, "bucket", "object")
26189///              .user_project("ea")
26190///              .projection("dolore")
26191///              .predefined_acl("ipsum")
26192///              .override_unlocked_retention(true)
26193///              .if_metageneration_not_match(-27)
26194///              .if_metageneration_match(-53)
26195///              .if_generation_not_match(-98)
26196///              .if_generation_match(-101)
26197///              .generation(-15)
26198///              .doit().await;
26199/// # }
26200/// ```
26201pub struct ObjectPatchCall<'a, C>
26202where
26203    C: 'a,
26204{
26205    hub: &'a Storage<C>,
26206    _request: Object,
26207    _bucket: String,
26208    _object: String,
26209    _user_project: Option<String>,
26210    _projection: Option<String>,
26211    _predefined_acl: Option<String>,
26212    _override_unlocked_retention: Option<bool>,
26213    _if_metageneration_not_match: Option<i64>,
26214    _if_metageneration_match: Option<i64>,
26215    _if_generation_not_match: Option<i64>,
26216    _if_generation_match: Option<i64>,
26217    _generation: Option<i64>,
26218    _delegate: Option<&'a mut dyn common::Delegate>,
26219    _additional_params: HashMap<String, String>,
26220    _scopes: BTreeSet<String>,
26221}
26222
26223impl<'a, C> common::CallBuilder for ObjectPatchCall<'a, C> {}
26224
26225impl<'a, C> ObjectPatchCall<'a, C>
26226where
26227    C: common::Connector,
26228{
26229    /// Perform the operation you have build so far.
26230    pub async fn doit(mut self) -> common::Result<(common::Response, Object)> {
26231        use std::borrow::Cow;
26232        use std::io::{Read, Seek};
26233
26234        use common::{url::Params, ToParts};
26235        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26236
26237        let mut dd = common::DefaultDelegate;
26238        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26239        dlg.begin(common::MethodInfo {
26240            id: "storage.objects.patch",
26241            http_method: hyper::Method::PATCH,
26242        });
26243
26244        for &field in [
26245            "alt",
26246            "bucket",
26247            "object",
26248            "userProject",
26249            "projection",
26250            "predefinedAcl",
26251            "overrideUnlockedRetention",
26252            "ifMetagenerationNotMatch",
26253            "ifMetagenerationMatch",
26254            "ifGenerationNotMatch",
26255            "ifGenerationMatch",
26256            "generation",
26257        ]
26258        .iter()
26259        {
26260            if self._additional_params.contains_key(field) {
26261                dlg.finished(false);
26262                return Err(common::Error::FieldClash(field));
26263            }
26264        }
26265
26266        let mut params = Params::with_capacity(14 + self._additional_params.len());
26267        params.push("bucket", self._bucket);
26268        params.push("object", self._object);
26269        if let Some(value) = self._user_project.as_ref() {
26270            params.push("userProject", value);
26271        }
26272        if let Some(value) = self._projection.as_ref() {
26273            params.push("projection", value);
26274        }
26275        if let Some(value) = self._predefined_acl.as_ref() {
26276            params.push("predefinedAcl", value);
26277        }
26278        if let Some(value) = self._override_unlocked_retention.as_ref() {
26279            params.push("overrideUnlockedRetention", value.to_string());
26280        }
26281        if let Some(value) = self._if_metageneration_not_match.as_ref() {
26282            params.push("ifMetagenerationNotMatch", value.to_string());
26283        }
26284        if let Some(value) = self._if_metageneration_match.as_ref() {
26285            params.push("ifMetagenerationMatch", value.to_string());
26286        }
26287        if let Some(value) = self._if_generation_not_match.as_ref() {
26288            params.push("ifGenerationNotMatch", value.to_string());
26289        }
26290        if let Some(value) = self._if_generation_match.as_ref() {
26291            params.push("ifGenerationMatch", value.to_string());
26292        }
26293        if let Some(value) = self._generation.as_ref() {
26294            params.push("generation", value.to_string());
26295        }
26296
26297        params.extend(self._additional_params.iter());
26298
26299        params.push("alt", "json");
26300        let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}";
26301        if self._scopes.is_empty() {
26302            self._scopes
26303                .insert(Scope::CloudPlatform.as_ref().to_string());
26304        }
26305
26306        #[allow(clippy::single_element_loop)]
26307        for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object")].iter() {
26308            url = params.uri_replacement(url, param_name, find_this, false);
26309        }
26310        {
26311            let to_remove = ["object", "bucket"];
26312            params.remove_params(&to_remove);
26313        }
26314
26315        let url = params.parse_with_url(&url);
26316
26317        let mut json_mime_type = mime::APPLICATION_JSON;
26318        let mut request_value_reader = {
26319            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
26320            common::remove_json_null_values(&mut value);
26321            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
26322            serde_json::to_writer(&mut dst, &value).unwrap();
26323            dst
26324        };
26325        let request_size = request_value_reader
26326            .seek(std::io::SeekFrom::End(0))
26327            .unwrap();
26328        request_value_reader
26329            .seek(std::io::SeekFrom::Start(0))
26330            .unwrap();
26331
26332        loop {
26333            let token = match self
26334                .hub
26335                .auth
26336                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26337                .await
26338            {
26339                Ok(token) => token,
26340                Err(e) => match dlg.token(e) {
26341                    Ok(token) => token,
26342                    Err(e) => {
26343                        dlg.finished(false);
26344                        return Err(common::Error::MissingToken(e));
26345                    }
26346                },
26347            };
26348            request_value_reader
26349                .seek(std::io::SeekFrom::Start(0))
26350                .unwrap();
26351            let mut req_result = {
26352                let client = &self.hub.client;
26353                dlg.pre_request();
26354                let mut req_builder = hyper::Request::builder()
26355                    .method(hyper::Method::PATCH)
26356                    .uri(url.as_str())
26357                    .header(USER_AGENT, self.hub._user_agent.clone());
26358
26359                if let Some(token) = token.as_ref() {
26360                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26361                }
26362
26363                let request = req_builder
26364                    .header(CONTENT_TYPE, json_mime_type.to_string())
26365                    .header(CONTENT_LENGTH, request_size as u64)
26366                    .body(common::to_body(
26367                        request_value_reader.get_ref().clone().into(),
26368                    ));
26369
26370                client.request(request.unwrap()).await
26371            };
26372
26373            match req_result {
26374                Err(err) => {
26375                    if let common::Retry::After(d) = dlg.http_error(&err) {
26376                        sleep(d).await;
26377                        continue;
26378                    }
26379                    dlg.finished(false);
26380                    return Err(common::Error::HttpError(err));
26381                }
26382                Ok(res) => {
26383                    let (mut parts, body) = res.into_parts();
26384                    let mut body = common::Body::new(body);
26385                    if !parts.status.is_success() {
26386                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26387                        let error = serde_json::from_str(&common::to_string(&bytes));
26388                        let response = common::to_response(parts, bytes.into());
26389
26390                        if let common::Retry::After(d) =
26391                            dlg.http_failure(&response, error.as_ref().ok())
26392                        {
26393                            sleep(d).await;
26394                            continue;
26395                        }
26396
26397                        dlg.finished(false);
26398
26399                        return Err(match error {
26400                            Ok(value) => common::Error::BadRequest(value),
26401                            _ => common::Error::Failure(response),
26402                        });
26403                    }
26404                    let response = {
26405                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26406                        let encoded = common::to_string(&bytes);
26407                        match serde_json::from_str(&encoded) {
26408                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26409                            Err(error) => {
26410                                dlg.response_json_decode_error(&encoded, &error);
26411                                return Err(common::Error::JsonDecodeError(
26412                                    encoded.to_string(),
26413                                    error,
26414                                ));
26415                            }
26416                        }
26417                    };
26418
26419                    dlg.finished(true);
26420                    return Ok(response);
26421                }
26422            }
26423        }
26424    }
26425
26426    ///
26427    /// Sets the *request* property to the given value.
26428    ///
26429    /// Even though the property as already been set when instantiating this call,
26430    /// we provide this method for API completeness.
26431    pub fn request(mut self, new_value: Object) -> ObjectPatchCall<'a, C> {
26432        self._request = new_value;
26433        self
26434    }
26435    /// Name of the bucket in which the object resides.
26436    ///
26437    /// Sets the *bucket* path property to the given value.
26438    ///
26439    /// Even though the property as already been set when instantiating this call,
26440    /// we provide this method for API completeness.
26441    pub fn bucket(mut self, new_value: &str) -> ObjectPatchCall<'a, C> {
26442        self._bucket = new_value.to_string();
26443        self
26444    }
26445    /// Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
26446    ///
26447    /// Sets the *object* path property to the given value.
26448    ///
26449    /// Even though the property as already been set when instantiating this call,
26450    /// we provide this method for API completeness.
26451    pub fn object(mut self, new_value: &str) -> ObjectPatchCall<'a, C> {
26452        self._object = new_value.to_string();
26453        self
26454    }
26455    /// The project to be billed for this request, for Requester Pays buckets.
26456    ///
26457    /// Sets the *user project* query property to the given value.
26458    pub fn user_project(mut self, new_value: &str) -> ObjectPatchCall<'a, C> {
26459        self._user_project = Some(new_value.to_string());
26460        self
26461    }
26462    /// Set of properties to return. Defaults to full.
26463    ///
26464    /// Sets the *projection* query property to the given value.
26465    pub fn projection(mut self, new_value: &str) -> ObjectPatchCall<'a, C> {
26466        self._projection = Some(new_value.to_string());
26467        self
26468    }
26469    /// Apply a predefined set of access controls to this object.
26470    ///
26471    /// Sets the *predefined acl* query property to the given value.
26472    pub fn predefined_acl(mut self, new_value: &str) -> ObjectPatchCall<'a, C> {
26473        self._predefined_acl = Some(new_value.to_string());
26474        self
26475    }
26476    /// Must be true to remove the retention configuration, reduce its unlocked retention period, or change its mode from unlocked to locked.
26477    ///
26478    /// Sets the *override unlocked retention* query property to the given value.
26479    pub fn override_unlocked_retention(mut self, new_value: bool) -> ObjectPatchCall<'a, C> {
26480        self._override_unlocked_retention = Some(new_value);
26481        self
26482    }
26483    /// Makes the operation conditional on whether the object's current metageneration does not match the given value.
26484    ///
26485    /// Sets the *if metageneration not match* query property to the given value.
26486    pub fn if_metageneration_not_match(mut self, new_value: i64) -> ObjectPatchCall<'a, C> {
26487        self._if_metageneration_not_match = Some(new_value);
26488        self
26489    }
26490    /// Makes the operation conditional on whether the object's current metageneration matches the given value.
26491    ///
26492    /// Sets the *if metageneration match* query property to the given value.
26493    pub fn if_metageneration_match(mut self, new_value: i64) -> ObjectPatchCall<'a, C> {
26494        self._if_metageneration_match = Some(new_value);
26495        self
26496    }
26497    /// Makes the operation conditional on whether the object's current generation does not match the given value. If no live object exists, the precondition fails. Setting to 0 makes the operation succeed only if there is a live version of the object.
26498    ///
26499    /// Sets the *if generation not match* query property to the given value.
26500    pub fn if_generation_not_match(mut self, new_value: i64) -> ObjectPatchCall<'a, C> {
26501        self._if_generation_not_match = Some(new_value);
26502        self
26503    }
26504    /// Makes the operation conditional on whether the object's current generation matches the given value. Setting to 0 makes the operation succeed only if there are no live versions of the object.
26505    ///
26506    /// Sets the *if generation match* query property to the given value.
26507    pub fn if_generation_match(mut self, new_value: i64) -> ObjectPatchCall<'a, C> {
26508        self._if_generation_match = Some(new_value);
26509        self
26510    }
26511    /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
26512    ///
26513    /// Sets the *generation* query property to the given value.
26514    pub fn generation(mut self, new_value: i64) -> ObjectPatchCall<'a, C> {
26515        self._generation = Some(new_value);
26516        self
26517    }
26518    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26519    /// while executing the actual API request.
26520    ///
26521    /// ````text
26522    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26523    /// ````
26524    ///
26525    /// Sets the *delegate* property to the given value.
26526    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ObjectPatchCall<'a, C> {
26527        self._delegate = Some(new_value);
26528        self
26529    }
26530
26531    /// Set any additional parameter of the query string used in the request.
26532    /// It should be used to set parameters which are not yet available through their own
26533    /// setters.
26534    ///
26535    /// Please note that this method must not be used to set any of the known parameters
26536    /// which have their own setter method. If done anyway, the request will fail.
26537    ///
26538    /// # Additional Parameters
26539    ///
26540    /// * *alt* (query-string) - Data format for the response.
26541    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26542    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
26543    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26544    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26545    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
26546    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
26547    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
26548    pub fn param<T>(mut self, name: T, value: T) -> ObjectPatchCall<'a, C>
26549    where
26550        T: AsRef<str>,
26551    {
26552        self._additional_params
26553            .insert(name.as_ref().to_string(), value.as_ref().to_string());
26554        self
26555    }
26556
26557    /// Identifies the authorization scope for the method you are building.
26558    ///
26559    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26560    /// [`Scope::CloudPlatform`].
26561    ///
26562    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26563    /// tokens for more than one scope.
26564    ///
26565    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26566    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26567    /// sufficient, a read-write scope will do as well.
26568    pub fn add_scope<St>(mut self, scope: St) -> ObjectPatchCall<'a, C>
26569    where
26570        St: AsRef<str>,
26571    {
26572        self._scopes.insert(String::from(scope.as_ref()));
26573        self
26574    }
26575    /// Identifies the authorization scope(s) for the method you are building.
26576    ///
26577    /// See [`Self::add_scope()`] for details.
26578    pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectPatchCall<'a, C>
26579    where
26580        I: IntoIterator<Item = St>,
26581        St: AsRef<str>,
26582    {
26583        self._scopes
26584            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26585        self
26586    }
26587
26588    /// Removes all scopes, and no default scope will be used either.
26589    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26590    /// for details).
26591    pub fn clear_scopes(mut self) -> ObjectPatchCall<'a, C> {
26592        self._scopes.clear();
26593        self
26594    }
26595}
26596
26597/// Restores a soft-deleted object.
26598///
26599/// A builder for the *restore* method supported by a *object* resource.
26600/// It is not used directly, but through a [`ObjectMethods`] instance.
26601///
26602/// # Example
26603///
26604/// Instantiate a resource method builder
26605///
26606/// ```test_harness,no_run
26607/// # extern crate hyper;
26608/// # extern crate hyper_rustls;
26609/// # extern crate google_storage1 as storage1;
26610/// # async fn dox() {
26611/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26612///
26613/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26614/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
26615/// #     secret,
26616/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26617/// # ).build().await.unwrap();
26618///
26619/// # let client = hyper_util::client::legacy::Client::builder(
26620/// #     hyper_util::rt::TokioExecutor::new()
26621/// # )
26622/// # .build(
26623/// #     hyper_rustls::HttpsConnectorBuilder::new()
26624/// #         .with_native_roots()
26625/// #         .unwrap()
26626/// #         .https_or_http()
26627/// #         .enable_http1()
26628/// #         .build()
26629/// # );
26630/// # let mut hub = Storage::new(client, auth);
26631/// // You can configure optional parameters by calling the respective setters at will, and
26632/// // execute the final call using `doit()`.
26633/// // Values shown here are possibly random and not representative !
26634/// let result = hub.objects().restore("bucket", "object", -32)
26635///              .user_project("erat")
26636///              .projection("ut")
26637///              .if_metageneration_not_match(-18)
26638///              .if_metageneration_match(-51)
26639///              .if_generation_not_match(-66)
26640///              .if_generation_match(-35)
26641///              .copy_source_acl(true)
26642///              .doit().await;
26643/// # }
26644/// ```
26645pub struct ObjectRestoreCall<'a, C>
26646where
26647    C: 'a,
26648{
26649    hub: &'a Storage<C>,
26650    _bucket: String,
26651    _object: String,
26652    _generation: i64,
26653    _user_project: Option<String>,
26654    _projection: Option<String>,
26655    _if_metageneration_not_match: Option<i64>,
26656    _if_metageneration_match: Option<i64>,
26657    _if_generation_not_match: Option<i64>,
26658    _if_generation_match: Option<i64>,
26659    _copy_source_acl: Option<bool>,
26660    _delegate: Option<&'a mut dyn common::Delegate>,
26661    _additional_params: HashMap<String, String>,
26662    _scopes: BTreeSet<String>,
26663}
26664
26665impl<'a, C> common::CallBuilder for ObjectRestoreCall<'a, C> {}
26666
26667impl<'a, C> ObjectRestoreCall<'a, C>
26668where
26669    C: common::Connector,
26670{
26671    /// Perform the operation you have build so far.
26672    pub async fn doit(mut self) -> common::Result<(common::Response, Object)> {
26673        use std::borrow::Cow;
26674        use std::io::{Read, Seek};
26675
26676        use common::{url::Params, ToParts};
26677        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26678
26679        let mut dd = common::DefaultDelegate;
26680        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26681        dlg.begin(common::MethodInfo {
26682            id: "storage.objects.restore",
26683            http_method: hyper::Method::POST,
26684        });
26685
26686        for &field in [
26687            "alt",
26688            "bucket",
26689            "object",
26690            "generation",
26691            "userProject",
26692            "projection",
26693            "ifMetagenerationNotMatch",
26694            "ifMetagenerationMatch",
26695            "ifGenerationNotMatch",
26696            "ifGenerationMatch",
26697            "copySourceAcl",
26698        ]
26699        .iter()
26700        {
26701            if self._additional_params.contains_key(field) {
26702                dlg.finished(false);
26703                return Err(common::Error::FieldClash(field));
26704            }
26705        }
26706
26707        let mut params = Params::with_capacity(12 + self._additional_params.len());
26708        params.push("bucket", self._bucket);
26709        params.push("object", self._object);
26710        params.push("generation", self._generation.to_string());
26711        if let Some(value) = self._user_project.as_ref() {
26712            params.push("userProject", value);
26713        }
26714        if let Some(value) = self._projection.as_ref() {
26715            params.push("projection", value);
26716        }
26717        if let Some(value) = self._if_metageneration_not_match.as_ref() {
26718            params.push("ifMetagenerationNotMatch", value.to_string());
26719        }
26720        if let Some(value) = self._if_metageneration_match.as_ref() {
26721            params.push("ifMetagenerationMatch", value.to_string());
26722        }
26723        if let Some(value) = self._if_generation_not_match.as_ref() {
26724            params.push("ifGenerationNotMatch", value.to_string());
26725        }
26726        if let Some(value) = self._if_generation_match.as_ref() {
26727            params.push("ifGenerationMatch", value.to_string());
26728        }
26729        if let Some(value) = self._copy_source_acl.as_ref() {
26730            params.push("copySourceAcl", value.to_string());
26731        }
26732
26733        params.extend(self._additional_params.iter());
26734
26735        params.push("alt", "json");
26736        let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}/restore";
26737        if self._scopes.is_empty() {
26738            self._scopes
26739                .insert(Scope::CloudPlatform.as_ref().to_string());
26740        }
26741
26742        #[allow(clippy::single_element_loop)]
26743        for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object")].iter() {
26744            url = params.uri_replacement(url, param_name, find_this, false);
26745        }
26746        {
26747            let to_remove = ["object", "bucket"];
26748            params.remove_params(&to_remove);
26749        }
26750
26751        let url = params.parse_with_url(&url);
26752
26753        loop {
26754            let token = match self
26755                .hub
26756                .auth
26757                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26758                .await
26759            {
26760                Ok(token) => token,
26761                Err(e) => match dlg.token(e) {
26762                    Ok(token) => token,
26763                    Err(e) => {
26764                        dlg.finished(false);
26765                        return Err(common::Error::MissingToken(e));
26766                    }
26767                },
26768            };
26769            let mut req_result = {
26770                let client = &self.hub.client;
26771                dlg.pre_request();
26772                let mut req_builder = hyper::Request::builder()
26773                    .method(hyper::Method::POST)
26774                    .uri(url.as_str())
26775                    .header(USER_AGENT, self.hub._user_agent.clone());
26776
26777                if let Some(token) = token.as_ref() {
26778                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26779                }
26780
26781                let request = req_builder
26782                    .header(CONTENT_LENGTH, 0_u64)
26783                    .body(common::to_body::<String>(None));
26784
26785                client.request(request.unwrap()).await
26786            };
26787
26788            match req_result {
26789                Err(err) => {
26790                    if let common::Retry::After(d) = dlg.http_error(&err) {
26791                        sleep(d).await;
26792                        continue;
26793                    }
26794                    dlg.finished(false);
26795                    return Err(common::Error::HttpError(err));
26796                }
26797                Ok(res) => {
26798                    let (mut parts, body) = res.into_parts();
26799                    let mut body = common::Body::new(body);
26800                    if !parts.status.is_success() {
26801                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26802                        let error = serde_json::from_str(&common::to_string(&bytes));
26803                        let response = common::to_response(parts, bytes.into());
26804
26805                        if let common::Retry::After(d) =
26806                            dlg.http_failure(&response, error.as_ref().ok())
26807                        {
26808                            sleep(d).await;
26809                            continue;
26810                        }
26811
26812                        dlg.finished(false);
26813
26814                        return Err(match error {
26815                            Ok(value) => common::Error::BadRequest(value),
26816                            _ => common::Error::Failure(response),
26817                        });
26818                    }
26819                    let response = {
26820                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26821                        let encoded = common::to_string(&bytes);
26822                        match serde_json::from_str(&encoded) {
26823                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26824                            Err(error) => {
26825                                dlg.response_json_decode_error(&encoded, &error);
26826                                return Err(common::Error::JsonDecodeError(
26827                                    encoded.to_string(),
26828                                    error,
26829                                ));
26830                            }
26831                        }
26832                    };
26833
26834                    dlg.finished(true);
26835                    return Ok(response);
26836                }
26837            }
26838        }
26839    }
26840
26841    /// Name of the bucket in which the object resides.
26842    ///
26843    /// Sets the *bucket* path property to the given value.
26844    ///
26845    /// Even though the property as already been set when instantiating this call,
26846    /// we provide this method for API completeness.
26847    pub fn bucket(mut self, new_value: &str) -> ObjectRestoreCall<'a, C> {
26848        self._bucket = new_value.to_string();
26849        self
26850    }
26851    /// Name of the object. For information about how to URL encode object names to be path safe, see Encoding URI Path Parts.
26852    ///
26853    /// Sets the *object* path property to the given value.
26854    ///
26855    /// Even though the property as already been set when instantiating this call,
26856    /// we provide this method for API completeness.
26857    pub fn object(mut self, new_value: &str) -> ObjectRestoreCall<'a, C> {
26858        self._object = new_value.to_string();
26859        self
26860    }
26861    /// Selects a specific revision of this object.
26862    ///
26863    /// Sets the *generation* query property to the given value.
26864    ///
26865    /// Even though the property as already been set when instantiating this call,
26866    /// we provide this method for API completeness.
26867    pub fn generation(mut self, new_value: i64) -> ObjectRestoreCall<'a, C> {
26868        self._generation = new_value;
26869        self
26870    }
26871    /// The project to be billed for this request. Required for Requester Pays buckets.
26872    ///
26873    /// Sets the *user project* query property to the given value.
26874    pub fn user_project(mut self, new_value: &str) -> ObjectRestoreCall<'a, C> {
26875        self._user_project = Some(new_value.to_string());
26876        self
26877    }
26878    /// Set of properties to return. Defaults to full.
26879    ///
26880    /// Sets the *projection* query property to the given value.
26881    pub fn projection(mut self, new_value: &str) -> ObjectRestoreCall<'a, C> {
26882        self._projection = Some(new_value.to_string());
26883        self
26884    }
26885    /// Makes the operation conditional on whether none of the object's live metagenerations match the given value.
26886    ///
26887    /// Sets the *if metageneration not match* query property to the given value.
26888    pub fn if_metageneration_not_match(mut self, new_value: i64) -> ObjectRestoreCall<'a, C> {
26889        self._if_metageneration_not_match = Some(new_value);
26890        self
26891    }
26892    /// Makes the operation conditional on whether the object's one live metageneration matches the given value.
26893    ///
26894    /// Sets the *if metageneration match* query property to the given value.
26895    pub fn if_metageneration_match(mut self, new_value: i64) -> ObjectRestoreCall<'a, C> {
26896        self._if_metageneration_match = Some(new_value);
26897        self
26898    }
26899    /// Makes the operation conditional on whether none of the object's live generations match the given value. If no live object exists, the precondition fails. Setting to 0 makes the operation succeed only if there is a live version of the object.
26900    ///
26901    /// Sets the *if generation not match* query property to the given value.
26902    pub fn if_generation_not_match(mut self, new_value: i64) -> ObjectRestoreCall<'a, C> {
26903        self._if_generation_not_match = Some(new_value);
26904        self
26905    }
26906    /// Makes the operation conditional on whether the object's one live generation matches the given value. Setting to 0 makes the operation succeed only if there are no live versions of the object.
26907    ///
26908    /// Sets the *if generation match* query property to the given value.
26909    pub fn if_generation_match(mut self, new_value: i64) -> ObjectRestoreCall<'a, C> {
26910        self._if_generation_match = Some(new_value);
26911        self
26912    }
26913    /// If true, copies the source object's ACL; otherwise, uses the bucket's default object ACL. The default is false.
26914    ///
26915    /// Sets the *copy source acl* query property to the given value.
26916    pub fn copy_source_acl(mut self, new_value: bool) -> ObjectRestoreCall<'a, C> {
26917        self._copy_source_acl = Some(new_value);
26918        self
26919    }
26920    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26921    /// while executing the actual API request.
26922    ///
26923    /// ````text
26924    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26925    /// ````
26926    ///
26927    /// Sets the *delegate* property to the given value.
26928    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ObjectRestoreCall<'a, C> {
26929        self._delegate = Some(new_value);
26930        self
26931    }
26932
26933    /// Set any additional parameter of the query string used in the request.
26934    /// It should be used to set parameters which are not yet available through their own
26935    /// setters.
26936    ///
26937    /// Please note that this method must not be used to set any of the known parameters
26938    /// which have their own setter method. If done anyway, the request will fail.
26939    ///
26940    /// # Additional Parameters
26941    ///
26942    /// * *alt* (query-string) - Data format for the response.
26943    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26944    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
26945    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26946    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26947    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
26948    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
26949    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
26950    pub fn param<T>(mut self, name: T, value: T) -> ObjectRestoreCall<'a, C>
26951    where
26952        T: AsRef<str>,
26953    {
26954        self._additional_params
26955            .insert(name.as_ref().to_string(), value.as_ref().to_string());
26956        self
26957    }
26958
26959    /// Identifies the authorization scope for the method you are building.
26960    ///
26961    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26962    /// [`Scope::CloudPlatform`].
26963    ///
26964    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26965    /// tokens for more than one scope.
26966    ///
26967    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26968    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26969    /// sufficient, a read-write scope will do as well.
26970    pub fn add_scope<St>(mut self, scope: St) -> ObjectRestoreCall<'a, C>
26971    where
26972        St: AsRef<str>,
26973    {
26974        self._scopes.insert(String::from(scope.as_ref()));
26975        self
26976    }
26977    /// Identifies the authorization scope(s) for the method you are building.
26978    ///
26979    /// See [`Self::add_scope()`] for details.
26980    pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectRestoreCall<'a, C>
26981    where
26982        I: IntoIterator<Item = St>,
26983        St: AsRef<str>,
26984    {
26985        self._scopes
26986            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26987        self
26988    }
26989
26990    /// Removes all scopes, and no default scope will be used either.
26991    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26992    /// for details).
26993    pub fn clear_scopes(mut self) -> ObjectRestoreCall<'a, C> {
26994        self._scopes.clear();
26995        self
26996    }
26997}
26998
26999/// Rewrites a source object to a destination object. Optionally overrides metadata.
27000///
27001/// A builder for the *rewrite* method supported by a *object* resource.
27002/// It is not used directly, but through a [`ObjectMethods`] instance.
27003///
27004/// # Example
27005///
27006/// Instantiate a resource method builder
27007///
27008/// ```test_harness,no_run
27009/// # extern crate hyper;
27010/// # extern crate hyper_rustls;
27011/// # extern crate google_storage1 as storage1;
27012/// use storage1::api::Object;
27013/// # async fn dox() {
27014/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27015///
27016/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27017/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
27018/// #     secret,
27019/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27020/// # ).build().await.unwrap();
27021///
27022/// # let client = hyper_util::client::legacy::Client::builder(
27023/// #     hyper_util::rt::TokioExecutor::new()
27024/// # )
27025/// # .build(
27026/// #     hyper_rustls::HttpsConnectorBuilder::new()
27027/// #         .with_native_roots()
27028/// #         .unwrap()
27029/// #         .https_or_http()
27030/// #         .enable_http1()
27031/// #         .build()
27032/// # );
27033/// # let mut hub = Storage::new(client, auth);
27034/// // As the method needs a request, you would usually fill it with the desired information
27035/// // into the respective structure. Some of the parts shown here might not be applicable !
27036/// // Values shown here are possibly random and not representative !
27037/// let mut req = Object::default();
27038///
27039/// // You can configure optional parameters by calling the respective setters at will, and
27040/// // execute the final call using `doit()`.
27041/// // Values shown here are possibly random and not representative !
27042/// let result = hub.objects().rewrite(req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject")
27043///              .user_project("kasd")
27044///              .source_generation(-39)
27045///              .rewrite_token("dolor")
27046///              .projection("amet")
27047///              .max_bytes_rewritten_per_call(-3)
27048///              .if_source_metageneration_not_match(-16)
27049///              .if_source_metageneration_match(-60)
27050///              .if_source_generation_not_match(-100)
27051///              .if_source_generation_match(-5)
27052///              .if_metageneration_not_match(-24)
27053///              .if_metageneration_match(-94)
27054///              .if_generation_not_match(-90)
27055///              .if_generation_match(-4)
27056///              .destination_predefined_acl("sadipscing")
27057///              .destination_kms_key_name("dolor")
27058///              .doit().await;
27059/// # }
27060/// ```
27061pub struct ObjectRewriteCall<'a, C>
27062where
27063    C: 'a,
27064{
27065    hub: &'a Storage<C>,
27066    _request: Object,
27067    _source_bucket: String,
27068    _source_object: String,
27069    _destination_bucket: String,
27070    _destination_object: String,
27071    _user_project: Option<String>,
27072    _source_generation: Option<i64>,
27073    _rewrite_token: Option<String>,
27074    _projection: Option<String>,
27075    _max_bytes_rewritten_per_call: Option<i64>,
27076    _if_source_metageneration_not_match: Option<i64>,
27077    _if_source_metageneration_match: Option<i64>,
27078    _if_source_generation_not_match: Option<i64>,
27079    _if_source_generation_match: Option<i64>,
27080    _if_metageneration_not_match: Option<i64>,
27081    _if_metageneration_match: Option<i64>,
27082    _if_generation_not_match: Option<i64>,
27083    _if_generation_match: Option<i64>,
27084    _destination_predefined_acl: Option<String>,
27085    _destination_kms_key_name: Option<String>,
27086    _delegate: Option<&'a mut dyn common::Delegate>,
27087    _additional_params: HashMap<String, String>,
27088    _scopes: BTreeSet<String>,
27089}
27090
27091impl<'a, C> common::CallBuilder for ObjectRewriteCall<'a, C> {}
27092
27093impl<'a, C> ObjectRewriteCall<'a, C>
27094where
27095    C: common::Connector,
27096{
27097    /// Perform the operation you have build so far.
27098    pub async fn doit(mut self) -> common::Result<(common::Response, RewriteResponse)> {
27099        use std::borrow::Cow;
27100        use std::io::{Read, Seek};
27101
27102        use common::{url::Params, ToParts};
27103        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27104
27105        let mut dd = common::DefaultDelegate;
27106        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27107        dlg.begin(common::MethodInfo {
27108            id: "storage.objects.rewrite",
27109            http_method: hyper::Method::POST,
27110        });
27111
27112        for &field in [
27113            "alt",
27114            "sourceBucket",
27115            "sourceObject",
27116            "destinationBucket",
27117            "destinationObject",
27118            "userProject",
27119            "sourceGeneration",
27120            "rewriteToken",
27121            "projection",
27122            "maxBytesRewrittenPerCall",
27123            "ifSourceMetagenerationNotMatch",
27124            "ifSourceMetagenerationMatch",
27125            "ifSourceGenerationNotMatch",
27126            "ifSourceGenerationMatch",
27127            "ifMetagenerationNotMatch",
27128            "ifMetagenerationMatch",
27129            "ifGenerationNotMatch",
27130            "ifGenerationMatch",
27131            "destinationPredefinedAcl",
27132            "destinationKmsKeyName",
27133        ]
27134        .iter()
27135        {
27136            if self._additional_params.contains_key(field) {
27137                dlg.finished(false);
27138                return Err(common::Error::FieldClash(field));
27139            }
27140        }
27141
27142        let mut params = Params::with_capacity(22 + self._additional_params.len());
27143        params.push("sourceBucket", self._source_bucket);
27144        params.push("sourceObject", self._source_object);
27145        params.push("destinationBucket", self._destination_bucket);
27146        params.push("destinationObject", self._destination_object);
27147        if let Some(value) = self._user_project.as_ref() {
27148            params.push("userProject", value);
27149        }
27150        if let Some(value) = self._source_generation.as_ref() {
27151            params.push("sourceGeneration", value.to_string());
27152        }
27153        if let Some(value) = self._rewrite_token.as_ref() {
27154            params.push("rewriteToken", value);
27155        }
27156        if let Some(value) = self._projection.as_ref() {
27157            params.push("projection", value);
27158        }
27159        if let Some(value) = self._max_bytes_rewritten_per_call.as_ref() {
27160            params.push("maxBytesRewrittenPerCall", value.to_string());
27161        }
27162        if let Some(value) = self._if_source_metageneration_not_match.as_ref() {
27163            params.push("ifSourceMetagenerationNotMatch", value.to_string());
27164        }
27165        if let Some(value) = self._if_source_metageneration_match.as_ref() {
27166            params.push("ifSourceMetagenerationMatch", value.to_string());
27167        }
27168        if let Some(value) = self._if_source_generation_not_match.as_ref() {
27169            params.push("ifSourceGenerationNotMatch", value.to_string());
27170        }
27171        if let Some(value) = self._if_source_generation_match.as_ref() {
27172            params.push("ifSourceGenerationMatch", value.to_string());
27173        }
27174        if let Some(value) = self._if_metageneration_not_match.as_ref() {
27175            params.push("ifMetagenerationNotMatch", value.to_string());
27176        }
27177        if let Some(value) = self._if_metageneration_match.as_ref() {
27178            params.push("ifMetagenerationMatch", value.to_string());
27179        }
27180        if let Some(value) = self._if_generation_not_match.as_ref() {
27181            params.push("ifGenerationNotMatch", value.to_string());
27182        }
27183        if let Some(value) = self._if_generation_match.as_ref() {
27184            params.push("ifGenerationMatch", value.to_string());
27185        }
27186        if let Some(value) = self._destination_predefined_acl.as_ref() {
27187            params.push("destinationPredefinedAcl", value);
27188        }
27189        if let Some(value) = self._destination_kms_key_name.as_ref() {
27190            params.push("destinationKmsKeyName", value);
27191        }
27192
27193        params.extend(self._additional_params.iter());
27194
27195        params.push("alt", "json");
27196        let mut url = self.hub._base_url.clone() + "b/{sourceBucket}/o/{sourceObject}/rewriteTo/b/{destinationBucket}/o/{destinationObject}";
27197        if self._scopes.is_empty() {
27198            self._scopes
27199                .insert(Scope::CloudPlatform.as_ref().to_string());
27200        }
27201
27202        #[allow(clippy::single_element_loop)]
27203        for &(find_this, param_name) in [
27204            ("{sourceBucket}", "sourceBucket"),
27205            ("{sourceObject}", "sourceObject"),
27206            ("{destinationBucket}", "destinationBucket"),
27207            ("{destinationObject}", "destinationObject"),
27208        ]
27209        .iter()
27210        {
27211            url = params.uri_replacement(url, param_name, find_this, false);
27212        }
27213        {
27214            let to_remove = [
27215                "destinationObject",
27216                "destinationBucket",
27217                "sourceObject",
27218                "sourceBucket",
27219            ];
27220            params.remove_params(&to_remove);
27221        }
27222
27223        let url = params.parse_with_url(&url);
27224
27225        let mut json_mime_type = mime::APPLICATION_JSON;
27226        let mut request_value_reader = {
27227            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
27228            common::remove_json_null_values(&mut value);
27229            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
27230            serde_json::to_writer(&mut dst, &value).unwrap();
27231            dst
27232        };
27233        let request_size = request_value_reader
27234            .seek(std::io::SeekFrom::End(0))
27235            .unwrap();
27236        request_value_reader
27237            .seek(std::io::SeekFrom::Start(0))
27238            .unwrap();
27239
27240        loop {
27241            let token = match self
27242                .hub
27243                .auth
27244                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27245                .await
27246            {
27247                Ok(token) => token,
27248                Err(e) => match dlg.token(e) {
27249                    Ok(token) => token,
27250                    Err(e) => {
27251                        dlg.finished(false);
27252                        return Err(common::Error::MissingToken(e));
27253                    }
27254                },
27255            };
27256            request_value_reader
27257                .seek(std::io::SeekFrom::Start(0))
27258                .unwrap();
27259            let mut req_result = {
27260                let client = &self.hub.client;
27261                dlg.pre_request();
27262                let mut req_builder = hyper::Request::builder()
27263                    .method(hyper::Method::POST)
27264                    .uri(url.as_str())
27265                    .header(USER_AGENT, self.hub._user_agent.clone());
27266
27267                if let Some(token) = token.as_ref() {
27268                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27269                }
27270
27271                let request = req_builder
27272                    .header(CONTENT_TYPE, json_mime_type.to_string())
27273                    .header(CONTENT_LENGTH, request_size as u64)
27274                    .body(common::to_body(
27275                        request_value_reader.get_ref().clone().into(),
27276                    ));
27277
27278                client.request(request.unwrap()).await
27279            };
27280
27281            match req_result {
27282                Err(err) => {
27283                    if let common::Retry::After(d) = dlg.http_error(&err) {
27284                        sleep(d).await;
27285                        continue;
27286                    }
27287                    dlg.finished(false);
27288                    return Err(common::Error::HttpError(err));
27289                }
27290                Ok(res) => {
27291                    let (mut parts, body) = res.into_parts();
27292                    let mut body = common::Body::new(body);
27293                    if !parts.status.is_success() {
27294                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27295                        let error = serde_json::from_str(&common::to_string(&bytes));
27296                        let response = common::to_response(parts, bytes.into());
27297
27298                        if let common::Retry::After(d) =
27299                            dlg.http_failure(&response, error.as_ref().ok())
27300                        {
27301                            sleep(d).await;
27302                            continue;
27303                        }
27304
27305                        dlg.finished(false);
27306
27307                        return Err(match error {
27308                            Ok(value) => common::Error::BadRequest(value),
27309                            _ => common::Error::Failure(response),
27310                        });
27311                    }
27312                    let response = {
27313                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27314                        let encoded = common::to_string(&bytes);
27315                        match serde_json::from_str(&encoded) {
27316                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27317                            Err(error) => {
27318                                dlg.response_json_decode_error(&encoded, &error);
27319                                return Err(common::Error::JsonDecodeError(
27320                                    encoded.to_string(),
27321                                    error,
27322                                ));
27323                            }
27324                        }
27325                    };
27326
27327                    dlg.finished(true);
27328                    return Ok(response);
27329                }
27330            }
27331        }
27332    }
27333
27334    ///
27335    /// Sets the *request* property to the given value.
27336    ///
27337    /// Even though the property as already been set when instantiating this call,
27338    /// we provide this method for API completeness.
27339    pub fn request(mut self, new_value: Object) -> ObjectRewriteCall<'a, C> {
27340        self._request = new_value;
27341        self
27342    }
27343    /// Name of the bucket in which to find the source object.
27344    ///
27345    /// Sets the *source bucket* path property to the given value.
27346    ///
27347    /// Even though the property as already been set when instantiating this call,
27348    /// we provide this method for API completeness.
27349    pub fn source_bucket(mut self, new_value: &str) -> ObjectRewriteCall<'a, C> {
27350        self._source_bucket = new_value.to_string();
27351        self
27352    }
27353    /// Name of the source object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
27354    ///
27355    /// Sets the *source object* path property to the given value.
27356    ///
27357    /// Even though the property as already been set when instantiating this call,
27358    /// we provide this method for API completeness.
27359    pub fn source_object(mut self, new_value: &str) -> ObjectRewriteCall<'a, C> {
27360        self._source_object = new_value.to_string();
27361        self
27362    }
27363    /// Name of the bucket in which to store the new object. Overrides the provided object metadata's bucket value, if any.
27364    ///
27365    /// Sets the *destination bucket* path property to the given value.
27366    ///
27367    /// Even though the property as already been set when instantiating this call,
27368    /// we provide this method for API completeness.
27369    pub fn destination_bucket(mut self, new_value: &str) -> ObjectRewriteCall<'a, C> {
27370        self._destination_bucket = new_value.to_string();
27371        self
27372    }
27373    /// Name of the new object. Required when the object metadata is not otherwise provided. Overrides the object metadata's name value, if any. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
27374    ///
27375    /// Sets the *destination object* path property to the given value.
27376    ///
27377    /// Even though the property as already been set when instantiating this call,
27378    /// we provide this method for API completeness.
27379    pub fn destination_object(mut self, new_value: &str) -> ObjectRewriteCall<'a, C> {
27380        self._destination_object = new_value.to_string();
27381        self
27382    }
27383    /// The project to be billed for this request. Required for Requester Pays buckets.
27384    ///
27385    /// Sets the *user project* query property to the given value.
27386    pub fn user_project(mut self, new_value: &str) -> ObjectRewriteCall<'a, C> {
27387        self._user_project = Some(new_value.to_string());
27388        self
27389    }
27390    /// If present, selects a specific revision of the source object (as opposed to the latest version, the default).
27391    ///
27392    /// Sets the *source generation* query property to the given value.
27393    pub fn source_generation(mut self, new_value: i64) -> ObjectRewriteCall<'a, C> {
27394        self._source_generation = Some(new_value);
27395        self
27396    }
27397    /// Include this field (from the previous rewrite response) on each rewrite request after the first one, until the rewrite response 'done' flag is true. Calls that provide a rewriteToken can omit all other request fields, but if included those fields must match the values provided in the first rewrite request.
27398    ///
27399    /// Sets the *rewrite token* query property to the given value.
27400    pub fn rewrite_token(mut self, new_value: &str) -> ObjectRewriteCall<'a, C> {
27401        self._rewrite_token = Some(new_value.to_string());
27402        self
27403    }
27404    /// Set of properties to return. Defaults to noAcl, unless the object resource specifies the acl property, when it defaults to full.
27405    ///
27406    /// Sets the *projection* query property to the given value.
27407    pub fn projection(mut self, new_value: &str) -> ObjectRewriteCall<'a, C> {
27408        self._projection = Some(new_value.to_string());
27409        self
27410    }
27411    /// The maximum number of bytes that will be rewritten per rewrite request. Most callers shouldn't need to specify this parameter - it is primarily in place to support testing. If specified the value must be an integral multiple of 1 MiB (1048576). Also, this only applies to requests where the source and destination span locations and/or storage classes. Finally, this value must not change across rewrite calls else you'll get an error that the rewriteToken is invalid.
27412    ///
27413    /// Sets the *max bytes rewritten per call* query property to the given value.
27414    pub fn max_bytes_rewritten_per_call(mut self, new_value: i64) -> ObjectRewriteCall<'a, C> {
27415        self._max_bytes_rewritten_per_call = Some(new_value);
27416        self
27417    }
27418    /// Makes the operation conditional on whether the source object's current metageneration does not match the given value.
27419    ///
27420    /// Sets the *if source metageneration not match* query property to the given value.
27421    pub fn if_source_metageneration_not_match(
27422        mut self,
27423        new_value: i64,
27424    ) -> ObjectRewriteCall<'a, C> {
27425        self._if_source_metageneration_not_match = Some(new_value);
27426        self
27427    }
27428    /// Makes the operation conditional on whether the source object's current metageneration matches the given value.
27429    ///
27430    /// Sets the *if source metageneration match* query property to the given value.
27431    pub fn if_source_metageneration_match(mut self, new_value: i64) -> ObjectRewriteCall<'a, C> {
27432        self._if_source_metageneration_match = Some(new_value);
27433        self
27434    }
27435    /// Makes the operation conditional on whether the source object's current generation does not match the given value.
27436    ///
27437    /// Sets the *if source generation not match* query property to the given value.
27438    pub fn if_source_generation_not_match(mut self, new_value: i64) -> ObjectRewriteCall<'a, C> {
27439        self._if_source_generation_not_match = Some(new_value);
27440        self
27441    }
27442    /// Makes the operation conditional on whether the source object's current generation matches the given value.
27443    ///
27444    /// Sets the *if source generation match* query property to the given value.
27445    pub fn if_source_generation_match(mut self, new_value: i64) -> ObjectRewriteCall<'a, C> {
27446        self._if_source_generation_match = Some(new_value);
27447        self
27448    }
27449    /// Makes the operation conditional on whether the destination object's current metageneration does not match the given value.
27450    ///
27451    /// Sets the *if metageneration not match* query property to the given value.
27452    pub fn if_metageneration_not_match(mut self, new_value: i64) -> ObjectRewriteCall<'a, C> {
27453        self._if_metageneration_not_match = Some(new_value);
27454        self
27455    }
27456    /// Makes the operation conditional on whether the destination object's current metageneration matches the given value.
27457    ///
27458    /// Sets the *if metageneration match* query property to the given value.
27459    pub fn if_metageneration_match(mut self, new_value: i64) -> ObjectRewriteCall<'a, C> {
27460        self._if_metageneration_match = Some(new_value);
27461        self
27462    }
27463    /// Makes the operation conditional on whether the object's current generation does not match the given value. If no live object exists, the precondition fails. Setting to 0 makes the operation succeed only if there is a live version of the object.
27464    ///
27465    /// Sets the *if generation not match* query property to the given value.
27466    pub fn if_generation_not_match(mut self, new_value: i64) -> ObjectRewriteCall<'a, C> {
27467        self._if_generation_not_match = Some(new_value);
27468        self
27469    }
27470    /// Makes the operation conditional on whether the object's current generation matches the given value. Setting to 0 makes the operation succeed only if there are no live versions of the object.
27471    ///
27472    /// Sets the *if generation match* query property to the given value.
27473    pub fn if_generation_match(mut self, new_value: i64) -> ObjectRewriteCall<'a, C> {
27474        self._if_generation_match = Some(new_value);
27475        self
27476    }
27477    /// Apply a predefined set of access controls to the destination object.
27478    ///
27479    /// Sets the *destination predefined acl* query property to the given value.
27480    pub fn destination_predefined_acl(mut self, new_value: &str) -> ObjectRewriteCall<'a, C> {
27481        self._destination_predefined_acl = Some(new_value.to_string());
27482        self
27483    }
27484    /// Resource name of the Cloud KMS key, of the form projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key, that will be used to encrypt the object. Overrides the object metadata's kms_key_name value, if any.
27485    ///
27486    /// Sets the *destination kms key name* query property to the given value.
27487    pub fn destination_kms_key_name(mut self, new_value: &str) -> ObjectRewriteCall<'a, C> {
27488        self._destination_kms_key_name = Some(new_value.to_string());
27489        self
27490    }
27491    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27492    /// while executing the actual API request.
27493    ///
27494    /// ````text
27495    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
27496    /// ````
27497    ///
27498    /// Sets the *delegate* property to the given value.
27499    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ObjectRewriteCall<'a, C> {
27500        self._delegate = Some(new_value);
27501        self
27502    }
27503
27504    /// Set any additional parameter of the query string used in the request.
27505    /// It should be used to set parameters which are not yet available through their own
27506    /// setters.
27507    ///
27508    /// Please note that this method must not be used to set any of the known parameters
27509    /// which have their own setter method. If done anyway, the request will fail.
27510    ///
27511    /// # Additional Parameters
27512    ///
27513    /// * *alt* (query-string) - Data format for the response.
27514    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27515    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
27516    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27517    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27518    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
27519    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
27520    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
27521    pub fn param<T>(mut self, name: T, value: T) -> ObjectRewriteCall<'a, C>
27522    where
27523        T: AsRef<str>,
27524    {
27525        self._additional_params
27526            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27527        self
27528    }
27529
27530    /// Identifies the authorization scope for the method you are building.
27531    ///
27532    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27533    /// [`Scope::CloudPlatform`].
27534    ///
27535    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27536    /// tokens for more than one scope.
27537    ///
27538    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27539    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27540    /// sufficient, a read-write scope will do as well.
27541    pub fn add_scope<St>(mut self, scope: St) -> ObjectRewriteCall<'a, C>
27542    where
27543        St: AsRef<str>,
27544    {
27545        self._scopes.insert(String::from(scope.as_ref()));
27546        self
27547    }
27548    /// Identifies the authorization scope(s) for the method you are building.
27549    ///
27550    /// See [`Self::add_scope()`] for details.
27551    pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectRewriteCall<'a, C>
27552    where
27553        I: IntoIterator<Item = St>,
27554        St: AsRef<str>,
27555    {
27556        self._scopes
27557            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27558        self
27559    }
27560
27561    /// Removes all scopes, and no default scope will be used either.
27562    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27563    /// for details).
27564    pub fn clear_scopes(mut self) -> ObjectRewriteCall<'a, C> {
27565        self._scopes.clear();
27566        self
27567    }
27568}
27569
27570/// Updates an IAM policy for the specified object.
27571///
27572/// A builder for the *setIamPolicy* method supported by a *object* resource.
27573/// It is not used directly, but through a [`ObjectMethods`] instance.
27574///
27575/// # Example
27576///
27577/// Instantiate a resource method builder
27578///
27579/// ```test_harness,no_run
27580/// # extern crate hyper;
27581/// # extern crate hyper_rustls;
27582/// # extern crate google_storage1 as storage1;
27583/// use storage1::api::Policy;
27584/// # async fn dox() {
27585/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27586///
27587/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27588/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
27589/// #     secret,
27590/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27591/// # ).build().await.unwrap();
27592///
27593/// # let client = hyper_util::client::legacy::Client::builder(
27594/// #     hyper_util::rt::TokioExecutor::new()
27595/// # )
27596/// # .build(
27597/// #     hyper_rustls::HttpsConnectorBuilder::new()
27598/// #         .with_native_roots()
27599/// #         .unwrap()
27600/// #         .https_or_http()
27601/// #         .enable_http1()
27602/// #         .build()
27603/// # );
27604/// # let mut hub = Storage::new(client, auth);
27605/// // As the method needs a request, you would usually fill it with the desired information
27606/// // into the respective structure. Some of the parts shown here might not be applicable !
27607/// // Values shown here are possibly random and not representative !
27608/// let mut req = Policy::default();
27609///
27610/// // You can configure optional parameters by calling the respective setters at will, and
27611/// // execute the final call using `doit()`.
27612/// // Values shown here are possibly random and not representative !
27613/// let result = hub.objects().set_iam_policy(req, "bucket", "object")
27614///              .user_project("et")
27615///              .generation(-48)
27616///              .doit().await;
27617/// # }
27618/// ```
27619pub struct ObjectSetIamPolicyCall<'a, C>
27620where
27621    C: 'a,
27622{
27623    hub: &'a Storage<C>,
27624    _request: Policy,
27625    _bucket: String,
27626    _object: String,
27627    _user_project: Option<String>,
27628    _generation: Option<i64>,
27629    _delegate: Option<&'a mut dyn common::Delegate>,
27630    _additional_params: HashMap<String, String>,
27631    _scopes: BTreeSet<String>,
27632}
27633
27634impl<'a, C> common::CallBuilder for ObjectSetIamPolicyCall<'a, C> {}
27635
27636impl<'a, C> ObjectSetIamPolicyCall<'a, C>
27637where
27638    C: common::Connector,
27639{
27640    /// Perform the operation you have build so far.
27641    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
27642        use std::borrow::Cow;
27643        use std::io::{Read, Seek};
27644
27645        use common::{url::Params, ToParts};
27646        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27647
27648        let mut dd = common::DefaultDelegate;
27649        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27650        dlg.begin(common::MethodInfo {
27651            id: "storage.objects.setIamPolicy",
27652            http_method: hyper::Method::PUT,
27653        });
27654
27655        for &field in ["alt", "bucket", "object", "userProject", "generation"].iter() {
27656            if self._additional_params.contains_key(field) {
27657                dlg.finished(false);
27658                return Err(common::Error::FieldClash(field));
27659            }
27660        }
27661
27662        let mut params = Params::with_capacity(7 + self._additional_params.len());
27663        params.push("bucket", self._bucket);
27664        params.push("object", self._object);
27665        if let Some(value) = self._user_project.as_ref() {
27666            params.push("userProject", value);
27667        }
27668        if let Some(value) = self._generation.as_ref() {
27669            params.push("generation", value.to_string());
27670        }
27671
27672        params.extend(self._additional_params.iter());
27673
27674        params.push("alt", "json");
27675        let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}/iam";
27676        if self._scopes.is_empty() {
27677            self._scopes
27678                .insert(Scope::CloudPlatform.as_ref().to_string());
27679        }
27680
27681        #[allow(clippy::single_element_loop)]
27682        for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object")].iter() {
27683            url = params.uri_replacement(url, param_name, find_this, false);
27684        }
27685        {
27686            let to_remove = ["object", "bucket"];
27687            params.remove_params(&to_remove);
27688        }
27689
27690        let url = params.parse_with_url(&url);
27691
27692        let mut json_mime_type = mime::APPLICATION_JSON;
27693        let mut request_value_reader = {
27694            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
27695            common::remove_json_null_values(&mut value);
27696            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
27697            serde_json::to_writer(&mut dst, &value).unwrap();
27698            dst
27699        };
27700        let request_size = request_value_reader
27701            .seek(std::io::SeekFrom::End(0))
27702            .unwrap();
27703        request_value_reader
27704            .seek(std::io::SeekFrom::Start(0))
27705            .unwrap();
27706
27707        loop {
27708            let token = match self
27709                .hub
27710                .auth
27711                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27712                .await
27713            {
27714                Ok(token) => token,
27715                Err(e) => match dlg.token(e) {
27716                    Ok(token) => token,
27717                    Err(e) => {
27718                        dlg.finished(false);
27719                        return Err(common::Error::MissingToken(e));
27720                    }
27721                },
27722            };
27723            request_value_reader
27724                .seek(std::io::SeekFrom::Start(0))
27725                .unwrap();
27726            let mut req_result = {
27727                let client = &self.hub.client;
27728                dlg.pre_request();
27729                let mut req_builder = hyper::Request::builder()
27730                    .method(hyper::Method::PUT)
27731                    .uri(url.as_str())
27732                    .header(USER_AGENT, self.hub._user_agent.clone());
27733
27734                if let Some(token) = token.as_ref() {
27735                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27736                }
27737
27738                let request = req_builder
27739                    .header(CONTENT_TYPE, json_mime_type.to_string())
27740                    .header(CONTENT_LENGTH, request_size as u64)
27741                    .body(common::to_body(
27742                        request_value_reader.get_ref().clone().into(),
27743                    ));
27744
27745                client.request(request.unwrap()).await
27746            };
27747
27748            match req_result {
27749                Err(err) => {
27750                    if let common::Retry::After(d) = dlg.http_error(&err) {
27751                        sleep(d).await;
27752                        continue;
27753                    }
27754                    dlg.finished(false);
27755                    return Err(common::Error::HttpError(err));
27756                }
27757                Ok(res) => {
27758                    let (mut parts, body) = res.into_parts();
27759                    let mut body = common::Body::new(body);
27760                    if !parts.status.is_success() {
27761                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27762                        let error = serde_json::from_str(&common::to_string(&bytes));
27763                        let response = common::to_response(parts, bytes.into());
27764
27765                        if let common::Retry::After(d) =
27766                            dlg.http_failure(&response, error.as_ref().ok())
27767                        {
27768                            sleep(d).await;
27769                            continue;
27770                        }
27771
27772                        dlg.finished(false);
27773
27774                        return Err(match error {
27775                            Ok(value) => common::Error::BadRequest(value),
27776                            _ => common::Error::Failure(response),
27777                        });
27778                    }
27779                    let response = {
27780                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27781                        let encoded = common::to_string(&bytes);
27782                        match serde_json::from_str(&encoded) {
27783                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27784                            Err(error) => {
27785                                dlg.response_json_decode_error(&encoded, &error);
27786                                return Err(common::Error::JsonDecodeError(
27787                                    encoded.to_string(),
27788                                    error,
27789                                ));
27790                            }
27791                        }
27792                    };
27793
27794                    dlg.finished(true);
27795                    return Ok(response);
27796                }
27797            }
27798        }
27799    }
27800
27801    ///
27802    /// Sets the *request* property to the given value.
27803    ///
27804    /// Even though the property as already been set when instantiating this call,
27805    /// we provide this method for API completeness.
27806    pub fn request(mut self, new_value: Policy) -> ObjectSetIamPolicyCall<'a, C> {
27807        self._request = new_value;
27808        self
27809    }
27810    /// Name of the bucket in which the object resides.
27811    ///
27812    /// Sets the *bucket* path property to the given value.
27813    ///
27814    /// Even though the property as already been set when instantiating this call,
27815    /// we provide this method for API completeness.
27816    pub fn bucket(mut self, new_value: &str) -> ObjectSetIamPolicyCall<'a, C> {
27817        self._bucket = new_value.to_string();
27818        self
27819    }
27820    /// Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
27821    ///
27822    /// Sets the *object* path property to the given value.
27823    ///
27824    /// Even though the property as already been set when instantiating this call,
27825    /// we provide this method for API completeness.
27826    pub fn object(mut self, new_value: &str) -> ObjectSetIamPolicyCall<'a, C> {
27827        self._object = new_value.to_string();
27828        self
27829    }
27830    /// The project to be billed for this request. Required for Requester Pays buckets.
27831    ///
27832    /// Sets the *user project* query property to the given value.
27833    pub fn user_project(mut self, new_value: &str) -> ObjectSetIamPolicyCall<'a, C> {
27834        self._user_project = Some(new_value.to_string());
27835        self
27836    }
27837    /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
27838    ///
27839    /// Sets the *generation* query property to the given value.
27840    pub fn generation(mut self, new_value: i64) -> ObjectSetIamPolicyCall<'a, C> {
27841        self._generation = Some(new_value);
27842        self
27843    }
27844    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27845    /// while executing the actual API request.
27846    ///
27847    /// ````text
27848    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
27849    /// ````
27850    ///
27851    /// Sets the *delegate* property to the given value.
27852    pub fn delegate(
27853        mut self,
27854        new_value: &'a mut dyn common::Delegate,
27855    ) -> ObjectSetIamPolicyCall<'a, C> {
27856        self._delegate = Some(new_value);
27857        self
27858    }
27859
27860    /// Set any additional parameter of the query string used in the request.
27861    /// It should be used to set parameters which are not yet available through their own
27862    /// setters.
27863    ///
27864    /// Please note that this method must not be used to set any of the known parameters
27865    /// which have their own setter method. If done anyway, the request will fail.
27866    ///
27867    /// # Additional Parameters
27868    ///
27869    /// * *alt* (query-string) - Data format for the response.
27870    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27871    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
27872    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27873    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27874    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
27875    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
27876    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
27877    pub fn param<T>(mut self, name: T, value: T) -> ObjectSetIamPolicyCall<'a, C>
27878    where
27879        T: AsRef<str>,
27880    {
27881        self._additional_params
27882            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27883        self
27884    }
27885
27886    /// Identifies the authorization scope for the method you are building.
27887    ///
27888    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27889    /// [`Scope::CloudPlatform`].
27890    ///
27891    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27892    /// tokens for more than one scope.
27893    ///
27894    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27895    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27896    /// sufficient, a read-write scope will do as well.
27897    pub fn add_scope<St>(mut self, scope: St) -> ObjectSetIamPolicyCall<'a, C>
27898    where
27899        St: AsRef<str>,
27900    {
27901        self._scopes.insert(String::from(scope.as_ref()));
27902        self
27903    }
27904    /// Identifies the authorization scope(s) for the method you are building.
27905    ///
27906    /// See [`Self::add_scope()`] for details.
27907    pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectSetIamPolicyCall<'a, C>
27908    where
27909        I: IntoIterator<Item = St>,
27910        St: AsRef<str>,
27911    {
27912        self._scopes
27913            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27914        self
27915    }
27916
27917    /// Removes all scopes, and no default scope will be used either.
27918    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27919    /// for details).
27920    pub fn clear_scopes(mut self) -> ObjectSetIamPolicyCall<'a, C> {
27921        self._scopes.clear();
27922        self
27923    }
27924}
27925
27926/// Tests a set of permissions on the given object to see which, if any, are held by the caller.
27927///
27928/// A builder for the *testIamPermissions* method supported by a *object* resource.
27929/// It is not used directly, but through a [`ObjectMethods`] instance.
27930///
27931/// # Example
27932///
27933/// Instantiate a resource method builder
27934///
27935/// ```test_harness,no_run
27936/// # extern crate hyper;
27937/// # extern crate hyper_rustls;
27938/// # extern crate google_storage1 as storage1;
27939/// # async fn dox() {
27940/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27941///
27942/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27943/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
27944/// #     secret,
27945/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27946/// # ).build().await.unwrap();
27947///
27948/// # let client = hyper_util::client::legacy::Client::builder(
27949/// #     hyper_util::rt::TokioExecutor::new()
27950/// # )
27951/// # .build(
27952/// #     hyper_rustls::HttpsConnectorBuilder::new()
27953/// #         .with_native_roots()
27954/// #         .unwrap()
27955/// #         .https_or_http()
27956/// #         .enable_http1()
27957/// #         .build()
27958/// # );
27959/// # let mut hub = Storage::new(client, auth);
27960/// // You can configure optional parameters by calling the respective setters at will, and
27961/// // execute the final call using `doit()`.
27962/// // Values shown here are possibly random and not representative !
27963/// let result = hub.objects().test_iam_permissions("bucket", "object", &vec!["diam".into()])
27964///              .user_project("ipsum")
27965///              .generation(-38)
27966///              .doit().await;
27967/// # }
27968/// ```
27969pub struct ObjectTestIamPermissionCall<'a, C>
27970where
27971    C: 'a,
27972{
27973    hub: &'a Storage<C>,
27974    _bucket: String,
27975    _object: String,
27976    _permissions: Vec<String>,
27977    _user_project: Option<String>,
27978    _generation: Option<i64>,
27979    _delegate: Option<&'a mut dyn common::Delegate>,
27980    _additional_params: HashMap<String, String>,
27981    _scopes: BTreeSet<String>,
27982}
27983
27984impl<'a, C> common::CallBuilder for ObjectTestIamPermissionCall<'a, C> {}
27985
27986impl<'a, C> ObjectTestIamPermissionCall<'a, C>
27987where
27988    C: common::Connector,
27989{
27990    /// Perform the operation you have build so far.
27991    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
27992        use std::borrow::Cow;
27993        use std::io::{Read, Seek};
27994
27995        use common::{url::Params, ToParts};
27996        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27997
27998        let mut dd = common::DefaultDelegate;
27999        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28000        dlg.begin(common::MethodInfo {
28001            id: "storage.objects.testIamPermissions",
28002            http_method: hyper::Method::GET,
28003        });
28004
28005        for &field in [
28006            "alt",
28007            "bucket",
28008            "object",
28009            "permissions",
28010            "userProject",
28011            "generation",
28012        ]
28013        .iter()
28014        {
28015            if self._additional_params.contains_key(field) {
28016                dlg.finished(false);
28017                return Err(common::Error::FieldClash(field));
28018            }
28019        }
28020
28021        let mut params = Params::with_capacity(7 + self._additional_params.len());
28022        params.push("bucket", self._bucket);
28023        params.push("object", self._object);
28024        if !self._permissions.is_empty() {
28025            for f in self._permissions.iter() {
28026                params.push("permissions", f);
28027            }
28028        }
28029        if let Some(value) = self._user_project.as_ref() {
28030            params.push("userProject", value);
28031        }
28032        if let Some(value) = self._generation.as_ref() {
28033            params.push("generation", value.to_string());
28034        }
28035
28036        params.extend(self._additional_params.iter());
28037
28038        params.push("alt", "json");
28039        let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}/iam/testPermissions";
28040        if self._scopes.is_empty() {
28041            self._scopes
28042                .insert(Scope::CloudPlatform.as_ref().to_string());
28043        }
28044
28045        #[allow(clippy::single_element_loop)]
28046        for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object")].iter() {
28047            url = params.uri_replacement(url, param_name, find_this, false);
28048        }
28049        {
28050            let to_remove = ["object", "bucket"];
28051            params.remove_params(&to_remove);
28052        }
28053
28054        let url = params.parse_with_url(&url);
28055
28056        loop {
28057            let token = match self
28058                .hub
28059                .auth
28060                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28061                .await
28062            {
28063                Ok(token) => token,
28064                Err(e) => match dlg.token(e) {
28065                    Ok(token) => token,
28066                    Err(e) => {
28067                        dlg.finished(false);
28068                        return Err(common::Error::MissingToken(e));
28069                    }
28070                },
28071            };
28072            let mut req_result = {
28073                let client = &self.hub.client;
28074                dlg.pre_request();
28075                let mut req_builder = hyper::Request::builder()
28076                    .method(hyper::Method::GET)
28077                    .uri(url.as_str())
28078                    .header(USER_AGENT, self.hub._user_agent.clone());
28079
28080                if let Some(token) = token.as_ref() {
28081                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28082                }
28083
28084                let request = req_builder
28085                    .header(CONTENT_LENGTH, 0_u64)
28086                    .body(common::to_body::<String>(None));
28087
28088                client.request(request.unwrap()).await
28089            };
28090
28091            match req_result {
28092                Err(err) => {
28093                    if let common::Retry::After(d) = dlg.http_error(&err) {
28094                        sleep(d).await;
28095                        continue;
28096                    }
28097                    dlg.finished(false);
28098                    return Err(common::Error::HttpError(err));
28099                }
28100                Ok(res) => {
28101                    let (mut parts, body) = res.into_parts();
28102                    let mut body = common::Body::new(body);
28103                    if !parts.status.is_success() {
28104                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28105                        let error = serde_json::from_str(&common::to_string(&bytes));
28106                        let response = common::to_response(parts, bytes.into());
28107
28108                        if let common::Retry::After(d) =
28109                            dlg.http_failure(&response, error.as_ref().ok())
28110                        {
28111                            sleep(d).await;
28112                            continue;
28113                        }
28114
28115                        dlg.finished(false);
28116
28117                        return Err(match error {
28118                            Ok(value) => common::Error::BadRequest(value),
28119                            _ => common::Error::Failure(response),
28120                        });
28121                    }
28122                    let response = {
28123                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28124                        let encoded = common::to_string(&bytes);
28125                        match serde_json::from_str(&encoded) {
28126                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28127                            Err(error) => {
28128                                dlg.response_json_decode_error(&encoded, &error);
28129                                return Err(common::Error::JsonDecodeError(
28130                                    encoded.to_string(),
28131                                    error,
28132                                ));
28133                            }
28134                        }
28135                    };
28136
28137                    dlg.finished(true);
28138                    return Ok(response);
28139                }
28140            }
28141        }
28142    }
28143
28144    /// Name of the bucket in which the object resides.
28145    ///
28146    /// Sets the *bucket* path property to the given value.
28147    ///
28148    /// Even though the property as already been set when instantiating this call,
28149    /// we provide this method for API completeness.
28150    pub fn bucket(mut self, new_value: &str) -> ObjectTestIamPermissionCall<'a, C> {
28151        self._bucket = new_value.to_string();
28152        self
28153    }
28154    /// Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
28155    ///
28156    /// Sets the *object* path property to the given value.
28157    ///
28158    /// Even though the property as already been set when instantiating this call,
28159    /// we provide this method for API completeness.
28160    pub fn object(mut self, new_value: &str) -> ObjectTestIamPermissionCall<'a, C> {
28161        self._object = new_value.to_string();
28162        self
28163    }
28164    /// Permissions to test.
28165    ///
28166    /// Append the given value to the *permissions* query property.
28167    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
28168    ///
28169    /// Even though the property as already been set when instantiating this call,
28170    /// we provide this method for API completeness.
28171    pub fn add_permissions(mut self, new_value: &str) -> ObjectTestIamPermissionCall<'a, C> {
28172        self._permissions.push(new_value.to_string());
28173        self
28174    }
28175    /// The project to be billed for this request. Required for Requester Pays buckets.
28176    ///
28177    /// Sets the *user project* query property to the given value.
28178    pub fn user_project(mut self, new_value: &str) -> ObjectTestIamPermissionCall<'a, C> {
28179        self._user_project = Some(new_value.to_string());
28180        self
28181    }
28182    /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
28183    ///
28184    /// Sets the *generation* query property to the given value.
28185    pub fn generation(mut self, new_value: i64) -> ObjectTestIamPermissionCall<'a, C> {
28186        self._generation = Some(new_value);
28187        self
28188    }
28189    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28190    /// while executing the actual API request.
28191    ///
28192    /// ````text
28193    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
28194    /// ````
28195    ///
28196    /// Sets the *delegate* property to the given value.
28197    pub fn delegate(
28198        mut self,
28199        new_value: &'a mut dyn common::Delegate,
28200    ) -> ObjectTestIamPermissionCall<'a, C> {
28201        self._delegate = Some(new_value);
28202        self
28203    }
28204
28205    /// Set any additional parameter of the query string used in the request.
28206    /// It should be used to set parameters which are not yet available through their own
28207    /// setters.
28208    ///
28209    /// Please note that this method must not be used to set any of the known parameters
28210    /// which have their own setter method. If done anyway, the request will fail.
28211    ///
28212    /// # Additional Parameters
28213    ///
28214    /// * *alt* (query-string) - Data format for the response.
28215    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28216    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
28217    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28218    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28219    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
28220    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
28221    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
28222    pub fn param<T>(mut self, name: T, value: T) -> ObjectTestIamPermissionCall<'a, C>
28223    where
28224        T: AsRef<str>,
28225    {
28226        self._additional_params
28227            .insert(name.as_ref().to_string(), value.as_ref().to_string());
28228        self
28229    }
28230
28231    /// Identifies the authorization scope for the method you are building.
28232    ///
28233    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28234    /// [`Scope::CloudPlatform`].
28235    ///
28236    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28237    /// tokens for more than one scope.
28238    ///
28239    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28240    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28241    /// sufficient, a read-write scope will do as well.
28242    pub fn add_scope<St>(mut self, scope: St) -> ObjectTestIamPermissionCall<'a, C>
28243    where
28244        St: AsRef<str>,
28245    {
28246        self._scopes.insert(String::from(scope.as_ref()));
28247        self
28248    }
28249    /// Identifies the authorization scope(s) for the method you are building.
28250    ///
28251    /// See [`Self::add_scope()`] for details.
28252    pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectTestIamPermissionCall<'a, C>
28253    where
28254        I: IntoIterator<Item = St>,
28255        St: AsRef<str>,
28256    {
28257        self._scopes
28258            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28259        self
28260    }
28261
28262    /// Removes all scopes, and no default scope will be used either.
28263    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28264    /// for details).
28265    pub fn clear_scopes(mut self) -> ObjectTestIamPermissionCall<'a, C> {
28266        self._scopes.clear();
28267        self
28268    }
28269}
28270
28271/// Updates an object's metadata.
28272///
28273/// A builder for the *update* method supported by a *object* resource.
28274/// It is not used directly, but through a [`ObjectMethods`] instance.
28275///
28276/// # Example
28277///
28278/// Instantiate a resource method builder
28279///
28280/// ```test_harness,no_run
28281/// # extern crate hyper;
28282/// # extern crate hyper_rustls;
28283/// # extern crate google_storage1 as storage1;
28284/// use storage1::api::Object;
28285/// # async fn dox() {
28286/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28287///
28288/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28289/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
28290/// #     secret,
28291/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28292/// # ).build().await.unwrap();
28293///
28294/// # let client = hyper_util::client::legacy::Client::builder(
28295/// #     hyper_util::rt::TokioExecutor::new()
28296/// # )
28297/// # .build(
28298/// #     hyper_rustls::HttpsConnectorBuilder::new()
28299/// #         .with_native_roots()
28300/// #         .unwrap()
28301/// #         .https_or_http()
28302/// #         .enable_http1()
28303/// #         .build()
28304/// # );
28305/// # let mut hub = Storage::new(client, auth);
28306/// // As the method needs a request, you would usually fill it with the desired information
28307/// // into the respective structure. Some of the parts shown here might not be applicable !
28308/// // Values shown here are possibly random and not representative !
28309/// let mut req = Object::default();
28310///
28311/// // You can configure optional parameters by calling the respective setters at will, and
28312/// // execute the final call using `doit()`.
28313/// // Values shown here are possibly random and not representative !
28314/// let result = hub.objects().update(req, "bucket", "object")
28315///              .user_project("At")
28316///              .projection("diam")
28317///              .predefined_acl("amet")
28318///              .override_unlocked_retention(false)
28319///              .if_metageneration_not_match(-90)
28320///              .if_metageneration_match(-31)
28321///              .if_generation_not_match(-20)
28322///              .if_generation_match(-35)
28323///              .generation(-1)
28324///              .doit().await;
28325/// # }
28326/// ```
28327pub struct ObjectUpdateCall<'a, C>
28328where
28329    C: 'a,
28330{
28331    hub: &'a Storage<C>,
28332    _request: Object,
28333    _bucket: String,
28334    _object: String,
28335    _user_project: Option<String>,
28336    _projection: Option<String>,
28337    _predefined_acl: Option<String>,
28338    _override_unlocked_retention: Option<bool>,
28339    _if_metageneration_not_match: Option<i64>,
28340    _if_metageneration_match: Option<i64>,
28341    _if_generation_not_match: Option<i64>,
28342    _if_generation_match: Option<i64>,
28343    _generation: Option<i64>,
28344    _delegate: Option<&'a mut dyn common::Delegate>,
28345    _additional_params: HashMap<String, String>,
28346    _scopes: BTreeSet<String>,
28347}
28348
28349impl<'a, C> common::CallBuilder for ObjectUpdateCall<'a, C> {}
28350
28351impl<'a, C> ObjectUpdateCall<'a, C>
28352where
28353    C: common::Connector,
28354{
28355    /// Perform the operation you have build so far.
28356    pub async fn doit(mut self) -> common::Result<(common::Response, Object)> {
28357        use std::borrow::Cow;
28358        use std::io::{Read, Seek};
28359
28360        use common::{url::Params, ToParts};
28361        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28362
28363        let mut dd = common::DefaultDelegate;
28364        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28365        dlg.begin(common::MethodInfo {
28366            id: "storage.objects.update",
28367            http_method: hyper::Method::PUT,
28368        });
28369
28370        for &field in [
28371            "alt",
28372            "bucket",
28373            "object",
28374            "userProject",
28375            "projection",
28376            "predefinedAcl",
28377            "overrideUnlockedRetention",
28378            "ifMetagenerationNotMatch",
28379            "ifMetagenerationMatch",
28380            "ifGenerationNotMatch",
28381            "ifGenerationMatch",
28382            "generation",
28383        ]
28384        .iter()
28385        {
28386            if self._additional_params.contains_key(field) {
28387                dlg.finished(false);
28388                return Err(common::Error::FieldClash(field));
28389            }
28390        }
28391
28392        let mut params = Params::with_capacity(14 + self._additional_params.len());
28393        params.push("bucket", self._bucket);
28394        params.push("object", self._object);
28395        if let Some(value) = self._user_project.as_ref() {
28396            params.push("userProject", value);
28397        }
28398        if let Some(value) = self._projection.as_ref() {
28399            params.push("projection", value);
28400        }
28401        if let Some(value) = self._predefined_acl.as_ref() {
28402            params.push("predefinedAcl", value);
28403        }
28404        if let Some(value) = self._override_unlocked_retention.as_ref() {
28405            params.push("overrideUnlockedRetention", value.to_string());
28406        }
28407        if let Some(value) = self._if_metageneration_not_match.as_ref() {
28408            params.push("ifMetagenerationNotMatch", value.to_string());
28409        }
28410        if let Some(value) = self._if_metageneration_match.as_ref() {
28411            params.push("ifMetagenerationMatch", value.to_string());
28412        }
28413        if let Some(value) = self._if_generation_not_match.as_ref() {
28414            params.push("ifGenerationNotMatch", value.to_string());
28415        }
28416        if let Some(value) = self._if_generation_match.as_ref() {
28417            params.push("ifGenerationMatch", value.to_string());
28418        }
28419        if let Some(value) = self._generation.as_ref() {
28420            params.push("generation", value.to_string());
28421        }
28422
28423        params.extend(self._additional_params.iter());
28424
28425        params.push("alt", "json");
28426        let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}";
28427        if self._scopes.is_empty() {
28428            self._scopes
28429                .insert(Scope::CloudPlatform.as_ref().to_string());
28430        }
28431
28432        #[allow(clippy::single_element_loop)]
28433        for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object")].iter() {
28434            url = params.uri_replacement(url, param_name, find_this, false);
28435        }
28436        {
28437            let to_remove = ["object", "bucket"];
28438            params.remove_params(&to_remove);
28439        }
28440
28441        let url = params.parse_with_url(&url);
28442
28443        let mut json_mime_type = mime::APPLICATION_JSON;
28444        let mut request_value_reader = {
28445            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
28446            common::remove_json_null_values(&mut value);
28447            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
28448            serde_json::to_writer(&mut dst, &value).unwrap();
28449            dst
28450        };
28451        let request_size = request_value_reader
28452            .seek(std::io::SeekFrom::End(0))
28453            .unwrap();
28454        request_value_reader
28455            .seek(std::io::SeekFrom::Start(0))
28456            .unwrap();
28457
28458        loop {
28459            let token = match self
28460                .hub
28461                .auth
28462                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28463                .await
28464            {
28465                Ok(token) => token,
28466                Err(e) => match dlg.token(e) {
28467                    Ok(token) => token,
28468                    Err(e) => {
28469                        dlg.finished(false);
28470                        return Err(common::Error::MissingToken(e));
28471                    }
28472                },
28473            };
28474            request_value_reader
28475                .seek(std::io::SeekFrom::Start(0))
28476                .unwrap();
28477            let mut req_result = {
28478                let client = &self.hub.client;
28479                dlg.pre_request();
28480                let mut req_builder = hyper::Request::builder()
28481                    .method(hyper::Method::PUT)
28482                    .uri(url.as_str())
28483                    .header(USER_AGENT, self.hub._user_agent.clone());
28484
28485                if let Some(token) = token.as_ref() {
28486                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28487                }
28488
28489                let request = req_builder
28490                    .header(CONTENT_TYPE, json_mime_type.to_string())
28491                    .header(CONTENT_LENGTH, request_size as u64)
28492                    .body(common::to_body(
28493                        request_value_reader.get_ref().clone().into(),
28494                    ));
28495
28496                client.request(request.unwrap()).await
28497            };
28498
28499            match req_result {
28500                Err(err) => {
28501                    if let common::Retry::After(d) = dlg.http_error(&err) {
28502                        sleep(d).await;
28503                        continue;
28504                    }
28505                    dlg.finished(false);
28506                    return Err(common::Error::HttpError(err));
28507                }
28508                Ok(res) => {
28509                    let (mut parts, body) = res.into_parts();
28510                    let mut body = common::Body::new(body);
28511                    if !parts.status.is_success() {
28512                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28513                        let error = serde_json::from_str(&common::to_string(&bytes));
28514                        let response = common::to_response(parts, bytes.into());
28515
28516                        if let common::Retry::After(d) =
28517                            dlg.http_failure(&response, error.as_ref().ok())
28518                        {
28519                            sleep(d).await;
28520                            continue;
28521                        }
28522
28523                        dlg.finished(false);
28524
28525                        return Err(match error {
28526                            Ok(value) => common::Error::BadRequest(value),
28527                            _ => common::Error::Failure(response),
28528                        });
28529                    }
28530                    let response = {
28531                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28532                        let encoded = common::to_string(&bytes);
28533                        match serde_json::from_str(&encoded) {
28534                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28535                            Err(error) => {
28536                                dlg.response_json_decode_error(&encoded, &error);
28537                                return Err(common::Error::JsonDecodeError(
28538                                    encoded.to_string(),
28539                                    error,
28540                                ));
28541                            }
28542                        }
28543                    };
28544
28545                    dlg.finished(true);
28546                    return Ok(response);
28547                }
28548            }
28549        }
28550    }
28551
28552    ///
28553    /// Sets the *request* property to the given value.
28554    ///
28555    /// Even though the property as already been set when instantiating this call,
28556    /// we provide this method for API completeness.
28557    pub fn request(mut self, new_value: Object) -> ObjectUpdateCall<'a, C> {
28558        self._request = new_value;
28559        self
28560    }
28561    /// Name of the bucket in which the object resides.
28562    ///
28563    /// Sets the *bucket* path property to the given value.
28564    ///
28565    /// Even though the property as already been set when instantiating this call,
28566    /// we provide this method for API completeness.
28567    pub fn bucket(mut self, new_value: &str) -> ObjectUpdateCall<'a, C> {
28568        self._bucket = new_value.to_string();
28569        self
28570    }
28571    /// Name of the object. For information about how to URL encode object names to be path safe, see [Encoding URI Path Parts](https://cloud.google.com/storage/docs/request-endpoints#encoding).
28572    ///
28573    /// Sets the *object* path property to the given value.
28574    ///
28575    /// Even though the property as already been set when instantiating this call,
28576    /// we provide this method for API completeness.
28577    pub fn object(mut self, new_value: &str) -> ObjectUpdateCall<'a, C> {
28578        self._object = new_value.to_string();
28579        self
28580    }
28581    /// The project to be billed for this request. Required for Requester Pays buckets.
28582    ///
28583    /// Sets the *user project* query property to the given value.
28584    pub fn user_project(mut self, new_value: &str) -> ObjectUpdateCall<'a, C> {
28585        self._user_project = Some(new_value.to_string());
28586        self
28587    }
28588    /// Set of properties to return. Defaults to full.
28589    ///
28590    /// Sets the *projection* query property to the given value.
28591    pub fn projection(mut self, new_value: &str) -> ObjectUpdateCall<'a, C> {
28592        self._projection = Some(new_value.to_string());
28593        self
28594    }
28595    /// Apply a predefined set of access controls to this object.
28596    ///
28597    /// Sets the *predefined acl* query property to the given value.
28598    pub fn predefined_acl(mut self, new_value: &str) -> ObjectUpdateCall<'a, C> {
28599        self._predefined_acl = Some(new_value.to_string());
28600        self
28601    }
28602    /// Must be true to remove the retention configuration, reduce its unlocked retention period, or change its mode from unlocked to locked.
28603    ///
28604    /// Sets the *override unlocked retention* query property to the given value.
28605    pub fn override_unlocked_retention(mut self, new_value: bool) -> ObjectUpdateCall<'a, C> {
28606        self._override_unlocked_retention = Some(new_value);
28607        self
28608    }
28609    /// Makes the operation conditional on whether the object's current metageneration does not match the given value.
28610    ///
28611    /// Sets the *if metageneration not match* query property to the given value.
28612    pub fn if_metageneration_not_match(mut self, new_value: i64) -> ObjectUpdateCall<'a, C> {
28613        self._if_metageneration_not_match = Some(new_value);
28614        self
28615    }
28616    /// Makes the operation conditional on whether the object's current metageneration matches the given value.
28617    ///
28618    /// Sets the *if metageneration match* query property to the given value.
28619    pub fn if_metageneration_match(mut self, new_value: i64) -> ObjectUpdateCall<'a, C> {
28620        self._if_metageneration_match = Some(new_value);
28621        self
28622    }
28623    /// Makes the operation conditional on whether the object's current generation does not match the given value. If no live object exists, the precondition fails. Setting to 0 makes the operation succeed only if there is a live version of the object.
28624    ///
28625    /// Sets the *if generation not match* query property to the given value.
28626    pub fn if_generation_not_match(mut self, new_value: i64) -> ObjectUpdateCall<'a, C> {
28627        self._if_generation_not_match = Some(new_value);
28628        self
28629    }
28630    /// Makes the operation conditional on whether the object's current generation matches the given value. Setting to 0 makes the operation succeed only if there are no live versions of the object.
28631    ///
28632    /// Sets the *if generation match* query property to the given value.
28633    pub fn if_generation_match(mut self, new_value: i64) -> ObjectUpdateCall<'a, C> {
28634        self._if_generation_match = Some(new_value);
28635        self
28636    }
28637    /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
28638    ///
28639    /// Sets the *generation* query property to the given value.
28640    pub fn generation(mut self, new_value: i64) -> ObjectUpdateCall<'a, C> {
28641        self._generation = Some(new_value);
28642        self
28643    }
28644    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28645    /// while executing the actual API request.
28646    ///
28647    /// ````text
28648    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
28649    /// ````
28650    ///
28651    /// Sets the *delegate* property to the given value.
28652    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ObjectUpdateCall<'a, C> {
28653        self._delegate = Some(new_value);
28654        self
28655    }
28656
28657    /// Set any additional parameter of the query string used in the request.
28658    /// It should be used to set parameters which are not yet available through their own
28659    /// setters.
28660    ///
28661    /// Please note that this method must not be used to set any of the known parameters
28662    /// which have their own setter method. If done anyway, the request will fail.
28663    ///
28664    /// # Additional Parameters
28665    ///
28666    /// * *alt* (query-string) - Data format for the response.
28667    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28668    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
28669    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28670    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28671    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
28672    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
28673    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
28674    pub fn param<T>(mut self, name: T, value: T) -> ObjectUpdateCall<'a, C>
28675    where
28676        T: AsRef<str>,
28677    {
28678        self._additional_params
28679            .insert(name.as_ref().to_string(), value.as_ref().to_string());
28680        self
28681    }
28682
28683    /// Identifies the authorization scope for the method you are building.
28684    ///
28685    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28686    /// [`Scope::CloudPlatform`].
28687    ///
28688    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28689    /// tokens for more than one scope.
28690    ///
28691    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28692    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28693    /// sufficient, a read-write scope will do as well.
28694    pub fn add_scope<St>(mut self, scope: St) -> ObjectUpdateCall<'a, C>
28695    where
28696        St: AsRef<str>,
28697    {
28698        self._scopes.insert(String::from(scope.as_ref()));
28699        self
28700    }
28701    /// Identifies the authorization scope(s) for the method you are building.
28702    ///
28703    /// See [`Self::add_scope()`] for details.
28704    pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectUpdateCall<'a, C>
28705    where
28706        I: IntoIterator<Item = St>,
28707        St: AsRef<str>,
28708    {
28709        self._scopes
28710            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28711        self
28712    }
28713
28714    /// Removes all scopes, and no default scope will be used either.
28715    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28716    /// for details).
28717    pub fn clear_scopes(mut self) -> ObjectUpdateCall<'a, C> {
28718        self._scopes.clear();
28719        self
28720    }
28721}
28722
28723/// Watch for changes on all objects in a bucket.
28724///
28725/// A builder for the *watchAll* method supported by a *object* resource.
28726/// It is not used directly, but through a [`ObjectMethods`] instance.
28727///
28728/// # Example
28729///
28730/// Instantiate a resource method builder
28731///
28732/// ```test_harness,no_run
28733/// # extern crate hyper;
28734/// # extern crate hyper_rustls;
28735/// # extern crate google_storage1 as storage1;
28736/// use storage1::api::Channel;
28737/// # async fn dox() {
28738/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28739///
28740/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28741/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
28742/// #     secret,
28743/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28744/// # ).build().await.unwrap();
28745///
28746/// # let client = hyper_util::client::legacy::Client::builder(
28747/// #     hyper_util::rt::TokioExecutor::new()
28748/// # )
28749/// # .build(
28750/// #     hyper_rustls::HttpsConnectorBuilder::new()
28751/// #         .with_native_roots()
28752/// #         .unwrap()
28753/// #         .https_or_http()
28754/// #         .enable_http1()
28755/// #         .build()
28756/// # );
28757/// # let mut hub = Storage::new(client, auth);
28758/// // As the method needs a request, you would usually fill it with the desired information
28759/// // into the respective structure. Some of the parts shown here might not be applicable !
28760/// // Values shown here are possibly random and not representative !
28761/// let mut req = Channel::default();
28762///
28763/// // You can configure optional parameters by calling the respective setters at will, and
28764/// // execute the final call using `doit()`.
28765/// // Values shown here are possibly random and not representative !
28766/// let result = hub.objects().watch_all(req, "bucket")
28767///              .versions(true)
28768///              .user_project("accusam")
28769///              .start_offset("et")
28770///              .projection("nonumy")
28771///              .prefix("accusam")
28772///              .page_token("ut")
28773///              .max_results(23)
28774///              .include_trailing_delimiter(true)
28775///              .end_offset("dolor")
28776///              .delimiter("amet")
28777///              .doit().await;
28778/// # }
28779/// ```
28780pub struct ObjectWatchAllCall<'a, C>
28781where
28782    C: 'a,
28783{
28784    hub: &'a Storage<C>,
28785    _request: Channel,
28786    _bucket: String,
28787    _versions: Option<bool>,
28788    _user_project: Option<String>,
28789    _start_offset: Option<String>,
28790    _projection: Option<String>,
28791    _prefix: Option<String>,
28792    _page_token: Option<String>,
28793    _max_results: Option<u32>,
28794    _include_trailing_delimiter: Option<bool>,
28795    _end_offset: Option<String>,
28796    _delimiter: Option<String>,
28797    _delegate: Option<&'a mut dyn common::Delegate>,
28798    _additional_params: HashMap<String, String>,
28799    _scopes: BTreeSet<String>,
28800}
28801
28802impl<'a, C> common::CallBuilder for ObjectWatchAllCall<'a, C> {}
28803
28804impl<'a, C> ObjectWatchAllCall<'a, C>
28805where
28806    C: common::Connector,
28807{
28808    /// Perform the operation you have build so far.
28809    pub async fn doit(mut self) -> common::Result<(common::Response, Channel)> {
28810        use std::borrow::Cow;
28811        use std::io::{Read, Seek};
28812
28813        use common::{url::Params, ToParts};
28814        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28815
28816        let mut dd = common::DefaultDelegate;
28817        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28818        dlg.begin(common::MethodInfo {
28819            id: "storage.objects.watchAll",
28820            http_method: hyper::Method::POST,
28821        });
28822
28823        for &field in [
28824            "alt",
28825            "bucket",
28826            "versions",
28827            "userProject",
28828            "startOffset",
28829            "projection",
28830            "prefix",
28831            "pageToken",
28832            "maxResults",
28833            "includeTrailingDelimiter",
28834            "endOffset",
28835            "delimiter",
28836        ]
28837        .iter()
28838        {
28839            if self._additional_params.contains_key(field) {
28840                dlg.finished(false);
28841                return Err(common::Error::FieldClash(field));
28842            }
28843        }
28844
28845        let mut params = Params::with_capacity(14 + self._additional_params.len());
28846        params.push("bucket", self._bucket);
28847        if let Some(value) = self._versions.as_ref() {
28848            params.push("versions", value.to_string());
28849        }
28850        if let Some(value) = self._user_project.as_ref() {
28851            params.push("userProject", value);
28852        }
28853        if let Some(value) = self._start_offset.as_ref() {
28854            params.push("startOffset", value);
28855        }
28856        if let Some(value) = self._projection.as_ref() {
28857            params.push("projection", value);
28858        }
28859        if let Some(value) = self._prefix.as_ref() {
28860            params.push("prefix", value);
28861        }
28862        if let Some(value) = self._page_token.as_ref() {
28863            params.push("pageToken", value);
28864        }
28865        if let Some(value) = self._max_results.as_ref() {
28866            params.push("maxResults", value.to_string());
28867        }
28868        if let Some(value) = self._include_trailing_delimiter.as_ref() {
28869            params.push("includeTrailingDelimiter", value.to_string());
28870        }
28871        if let Some(value) = self._end_offset.as_ref() {
28872            params.push("endOffset", value);
28873        }
28874        if let Some(value) = self._delimiter.as_ref() {
28875            params.push("delimiter", value);
28876        }
28877
28878        params.extend(self._additional_params.iter());
28879
28880        params.push("alt", "json");
28881        let mut url = self.hub._base_url.clone() + "b/{bucket}/o/watch";
28882        if self._scopes.is_empty() {
28883            self._scopes
28884                .insert(Scope::CloudPlatform.as_ref().to_string());
28885        }
28886
28887        #[allow(clippy::single_element_loop)]
28888        for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
28889            url = params.uri_replacement(url, param_name, find_this, false);
28890        }
28891        {
28892            let to_remove = ["bucket"];
28893            params.remove_params(&to_remove);
28894        }
28895
28896        let url = params.parse_with_url(&url);
28897
28898        let mut json_mime_type = mime::APPLICATION_JSON;
28899        let mut request_value_reader = {
28900            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
28901            common::remove_json_null_values(&mut value);
28902            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
28903            serde_json::to_writer(&mut dst, &value).unwrap();
28904            dst
28905        };
28906        let request_size = request_value_reader
28907            .seek(std::io::SeekFrom::End(0))
28908            .unwrap();
28909        request_value_reader
28910            .seek(std::io::SeekFrom::Start(0))
28911            .unwrap();
28912
28913        loop {
28914            let token = match self
28915                .hub
28916                .auth
28917                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28918                .await
28919            {
28920                Ok(token) => token,
28921                Err(e) => match dlg.token(e) {
28922                    Ok(token) => token,
28923                    Err(e) => {
28924                        dlg.finished(false);
28925                        return Err(common::Error::MissingToken(e));
28926                    }
28927                },
28928            };
28929            request_value_reader
28930                .seek(std::io::SeekFrom::Start(0))
28931                .unwrap();
28932            let mut req_result = {
28933                let client = &self.hub.client;
28934                dlg.pre_request();
28935                let mut req_builder = hyper::Request::builder()
28936                    .method(hyper::Method::POST)
28937                    .uri(url.as_str())
28938                    .header(USER_AGENT, self.hub._user_agent.clone());
28939
28940                if let Some(token) = token.as_ref() {
28941                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28942                }
28943
28944                let request = req_builder
28945                    .header(CONTENT_TYPE, json_mime_type.to_string())
28946                    .header(CONTENT_LENGTH, request_size as u64)
28947                    .body(common::to_body(
28948                        request_value_reader.get_ref().clone().into(),
28949                    ));
28950
28951                client.request(request.unwrap()).await
28952            };
28953
28954            match req_result {
28955                Err(err) => {
28956                    if let common::Retry::After(d) = dlg.http_error(&err) {
28957                        sleep(d).await;
28958                        continue;
28959                    }
28960                    dlg.finished(false);
28961                    return Err(common::Error::HttpError(err));
28962                }
28963                Ok(res) => {
28964                    let (mut parts, body) = res.into_parts();
28965                    let mut body = common::Body::new(body);
28966                    if !parts.status.is_success() {
28967                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28968                        let error = serde_json::from_str(&common::to_string(&bytes));
28969                        let response = common::to_response(parts, bytes.into());
28970
28971                        if let common::Retry::After(d) =
28972                            dlg.http_failure(&response, error.as_ref().ok())
28973                        {
28974                            sleep(d).await;
28975                            continue;
28976                        }
28977
28978                        dlg.finished(false);
28979
28980                        return Err(match error {
28981                            Ok(value) => common::Error::BadRequest(value),
28982                            _ => common::Error::Failure(response),
28983                        });
28984                    }
28985                    let response = {
28986                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28987                        let encoded = common::to_string(&bytes);
28988                        match serde_json::from_str(&encoded) {
28989                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28990                            Err(error) => {
28991                                dlg.response_json_decode_error(&encoded, &error);
28992                                return Err(common::Error::JsonDecodeError(
28993                                    encoded.to_string(),
28994                                    error,
28995                                ));
28996                            }
28997                        }
28998                    };
28999
29000                    dlg.finished(true);
29001                    return Ok(response);
29002                }
29003            }
29004        }
29005    }
29006
29007    ///
29008    /// Sets the *request* property to the given value.
29009    ///
29010    /// Even though the property as already been set when instantiating this call,
29011    /// we provide this method for API completeness.
29012    pub fn request(mut self, new_value: Channel) -> ObjectWatchAllCall<'a, C> {
29013        self._request = new_value;
29014        self
29015    }
29016    /// Name of the bucket in which to look for objects.
29017    ///
29018    /// Sets the *bucket* path property to the given value.
29019    ///
29020    /// Even though the property as already been set when instantiating this call,
29021    /// we provide this method for API completeness.
29022    pub fn bucket(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C> {
29023        self._bucket = new_value.to_string();
29024        self
29025    }
29026    /// If true, lists all versions of an object as distinct results. The default is false. For more information, see Object Versioning.
29027    ///
29028    /// Sets the *versions* query property to the given value.
29029    pub fn versions(mut self, new_value: bool) -> ObjectWatchAllCall<'a, C> {
29030        self._versions = Some(new_value);
29031        self
29032    }
29033    /// The project to be billed for this request. Required for Requester Pays buckets.
29034    ///
29035    /// Sets the *user project* query property to the given value.
29036    pub fn user_project(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C> {
29037        self._user_project = Some(new_value.to_string());
29038        self
29039    }
29040    /// Filter results to objects whose names are lexicographically equal to or after startOffset. If endOffset is also set, the objects listed will have names between startOffset (inclusive) and endOffset (exclusive).
29041    ///
29042    /// Sets the *start offset* query property to the given value.
29043    pub fn start_offset(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C> {
29044        self._start_offset = Some(new_value.to_string());
29045        self
29046    }
29047    /// Set of properties to return. Defaults to noAcl.
29048    ///
29049    /// Sets the *projection* query property to the given value.
29050    pub fn projection(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C> {
29051        self._projection = Some(new_value.to_string());
29052        self
29053    }
29054    /// Filter results to objects whose names begin with this prefix.
29055    ///
29056    /// Sets the *prefix* query property to the given value.
29057    pub fn prefix(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C> {
29058        self._prefix = Some(new_value.to_string());
29059        self
29060    }
29061    /// A previously-returned page token representing part of the larger set of results to view.
29062    ///
29063    /// Sets the *page token* query property to the given value.
29064    pub fn page_token(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C> {
29065        self._page_token = Some(new_value.to_string());
29066        self
29067    }
29068    /// Maximum number of items plus prefixes to return in a single page of responses. As duplicate prefixes are omitted, fewer total results may be returned than requested. The service will use this parameter or 1,000 items, whichever is smaller.
29069    ///
29070    /// Sets the *max results* query property to the given value.
29071    pub fn max_results(mut self, new_value: u32) -> ObjectWatchAllCall<'a, C> {
29072        self._max_results = Some(new_value);
29073        self
29074    }
29075    /// If true, objects that end in exactly one instance of delimiter will have their metadata included in items in addition to prefixes.
29076    ///
29077    /// Sets the *include trailing delimiter* query property to the given value.
29078    pub fn include_trailing_delimiter(mut self, new_value: bool) -> ObjectWatchAllCall<'a, C> {
29079        self._include_trailing_delimiter = Some(new_value);
29080        self
29081    }
29082    /// Filter results to objects whose names are lexicographically before endOffset. If startOffset is also set, the objects listed will have names between startOffset (inclusive) and endOffset (exclusive).
29083    ///
29084    /// Sets the *end offset* query property to the given value.
29085    pub fn end_offset(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C> {
29086        self._end_offset = Some(new_value.to_string());
29087        self
29088    }
29089    /// Returns results in a directory-like mode. items will contain only objects whose names, aside from the prefix, do not contain delimiter. Objects whose names, aside from the prefix, contain delimiter will have their name, truncated after the delimiter, returned in prefixes. Duplicate prefixes are omitted.
29090    ///
29091    /// Sets the *delimiter* query property to the given value.
29092    pub fn delimiter(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C> {
29093        self._delimiter = Some(new_value.to_string());
29094        self
29095    }
29096    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29097    /// while executing the actual API request.
29098    ///
29099    /// ````text
29100    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
29101    /// ````
29102    ///
29103    /// Sets the *delegate* property to the given value.
29104    pub fn delegate(
29105        mut self,
29106        new_value: &'a mut dyn common::Delegate,
29107    ) -> ObjectWatchAllCall<'a, C> {
29108        self._delegate = Some(new_value);
29109        self
29110    }
29111
29112    /// Set any additional parameter of the query string used in the request.
29113    /// It should be used to set parameters which are not yet available through their own
29114    /// setters.
29115    ///
29116    /// Please note that this method must not be used to set any of the known parameters
29117    /// which have their own setter method. If done anyway, the request will fail.
29118    ///
29119    /// # Additional Parameters
29120    ///
29121    /// * *alt* (query-string) - Data format for the response.
29122    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29123    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
29124    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29125    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29126    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
29127    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
29128    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
29129    pub fn param<T>(mut self, name: T, value: T) -> ObjectWatchAllCall<'a, C>
29130    where
29131        T: AsRef<str>,
29132    {
29133        self._additional_params
29134            .insert(name.as_ref().to_string(), value.as_ref().to_string());
29135        self
29136    }
29137
29138    /// Identifies the authorization scope for the method you are building.
29139    ///
29140    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29141    /// [`Scope::CloudPlatform`].
29142    ///
29143    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29144    /// tokens for more than one scope.
29145    ///
29146    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29147    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29148    /// sufficient, a read-write scope will do as well.
29149    pub fn add_scope<St>(mut self, scope: St) -> ObjectWatchAllCall<'a, C>
29150    where
29151        St: AsRef<str>,
29152    {
29153        self._scopes.insert(String::from(scope.as_ref()));
29154        self
29155    }
29156    /// Identifies the authorization scope(s) for the method you are building.
29157    ///
29158    /// See [`Self::add_scope()`] for details.
29159    pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectWatchAllCall<'a, C>
29160    where
29161        I: IntoIterator<Item = St>,
29162        St: AsRef<str>,
29163    {
29164        self._scopes
29165            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29166        self
29167    }
29168
29169    /// Removes all scopes, and no default scope will be used either.
29170    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29171    /// for details).
29172    pub fn clear_scopes(mut self) -> ObjectWatchAllCall<'a, C> {
29173        self._scopes.clear();
29174        self
29175    }
29176}
29177
29178/// Creates a new HMAC key for the specified service account.
29179///
29180/// A builder for the *hmacKeys.create* method supported by a *project* resource.
29181/// It is not used directly, but through a [`ProjectMethods`] instance.
29182///
29183/// # Example
29184///
29185/// Instantiate a resource method builder
29186///
29187/// ```test_harness,no_run
29188/// # extern crate hyper;
29189/// # extern crate hyper_rustls;
29190/// # extern crate google_storage1 as storage1;
29191/// # async fn dox() {
29192/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29193///
29194/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29195/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
29196/// #     secret,
29197/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29198/// # ).build().await.unwrap();
29199///
29200/// # let client = hyper_util::client::legacy::Client::builder(
29201/// #     hyper_util::rt::TokioExecutor::new()
29202/// # )
29203/// # .build(
29204/// #     hyper_rustls::HttpsConnectorBuilder::new()
29205/// #         .with_native_roots()
29206/// #         .unwrap()
29207/// #         .https_or_http()
29208/// #         .enable_http1()
29209/// #         .build()
29210/// # );
29211/// # let mut hub = Storage::new(client, auth);
29212/// // You can configure optional parameters by calling the respective setters at will, and
29213/// // execute the final call using `doit()`.
29214/// // Values shown here are possibly random and not representative !
29215/// let result = hub.projects().hmac_keys_create("projectId", "serviceAccountEmail")
29216///              .user_project("ipsum")
29217///              .doit().await;
29218/// # }
29219/// ```
29220pub struct ProjectHmacKeyCreateCall<'a, C>
29221where
29222    C: 'a,
29223{
29224    hub: &'a Storage<C>,
29225    _project_id: String,
29226    _service_account_email: String,
29227    _user_project: Option<String>,
29228    _delegate: Option<&'a mut dyn common::Delegate>,
29229    _additional_params: HashMap<String, String>,
29230    _scopes: BTreeSet<String>,
29231}
29232
29233impl<'a, C> common::CallBuilder for ProjectHmacKeyCreateCall<'a, C> {}
29234
29235impl<'a, C> ProjectHmacKeyCreateCall<'a, C>
29236where
29237    C: common::Connector,
29238{
29239    /// Perform the operation you have build so far.
29240    pub async fn doit(mut self) -> common::Result<(common::Response, HmacKey)> {
29241        use std::borrow::Cow;
29242        use std::io::{Read, Seek};
29243
29244        use common::{url::Params, ToParts};
29245        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29246
29247        let mut dd = common::DefaultDelegate;
29248        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29249        dlg.begin(common::MethodInfo {
29250            id: "storage.projects.hmacKeys.create",
29251            http_method: hyper::Method::POST,
29252        });
29253
29254        for &field in ["alt", "projectId", "serviceAccountEmail", "userProject"].iter() {
29255            if self._additional_params.contains_key(field) {
29256                dlg.finished(false);
29257                return Err(common::Error::FieldClash(field));
29258            }
29259        }
29260
29261        let mut params = Params::with_capacity(5 + self._additional_params.len());
29262        params.push("projectId", self._project_id);
29263        params.push("serviceAccountEmail", self._service_account_email);
29264        if let Some(value) = self._user_project.as_ref() {
29265            params.push("userProject", value);
29266        }
29267
29268        params.extend(self._additional_params.iter());
29269
29270        params.push("alt", "json");
29271        let mut url = self.hub._base_url.clone() + "projects/{projectId}/hmacKeys";
29272        if self._scopes.is_empty() {
29273            self._scopes
29274                .insert(Scope::CloudPlatform.as_ref().to_string());
29275        }
29276
29277        #[allow(clippy::single_element_loop)]
29278        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
29279            url = params.uri_replacement(url, param_name, find_this, false);
29280        }
29281        {
29282            let to_remove = ["projectId"];
29283            params.remove_params(&to_remove);
29284        }
29285
29286        let url = params.parse_with_url(&url);
29287
29288        loop {
29289            let token = match self
29290                .hub
29291                .auth
29292                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29293                .await
29294            {
29295                Ok(token) => token,
29296                Err(e) => match dlg.token(e) {
29297                    Ok(token) => token,
29298                    Err(e) => {
29299                        dlg.finished(false);
29300                        return Err(common::Error::MissingToken(e));
29301                    }
29302                },
29303            };
29304            let mut req_result = {
29305                let client = &self.hub.client;
29306                dlg.pre_request();
29307                let mut req_builder = hyper::Request::builder()
29308                    .method(hyper::Method::POST)
29309                    .uri(url.as_str())
29310                    .header(USER_AGENT, self.hub._user_agent.clone());
29311
29312                if let Some(token) = token.as_ref() {
29313                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29314                }
29315
29316                let request = req_builder
29317                    .header(CONTENT_LENGTH, 0_u64)
29318                    .body(common::to_body::<String>(None));
29319
29320                client.request(request.unwrap()).await
29321            };
29322
29323            match req_result {
29324                Err(err) => {
29325                    if let common::Retry::After(d) = dlg.http_error(&err) {
29326                        sleep(d).await;
29327                        continue;
29328                    }
29329                    dlg.finished(false);
29330                    return Err(common::Error::HttpError(err));
29331                }
29332                Ok(res) => {
29333                    let (mut parts, body) = res.into_parts();
29334                    let mut body = common::Body::new(body);
29335                    if !parts.status.is_success() {
29336                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29337                        let error = serde_json::from_str(&common::to_string(&bytes));
29338                        let response = common::to_response(parts, bytes.into());
29339
29340                        if let common::Retry::After(d) =
29341                            dlg.http_failure(&response, error.as_ref().ok())
29342                        {
29343                            sleep(d).await;
29344                            continue;
29345                        }
29346
29347                        dlg.finished(false);
29348
29349                        return Err(match error {
29350                            Ok(value) => common::Error::BadRequest(value),
29351                            _ => common::Error::Failure(response),
29352                        });
29353                    }
29354                    let response = {
29355                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29356                        let encoded = common::to_string(&bytes);
29357                        match serde_json::from_str(&encoded) {
29358                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29359                            Err(error) => {
29360                                dlg.response_json_decode_error(&encoded, &error);
29361                                return Err(common::Error::JsonDecodeError(
29362                                    encoded.to_string(),
29363                                    error,
29364                                ));
29365                            }
29366                        }
29367                    };
29368
29369                    dlg.finished(true);
29370                    return Ok(response);
29371                }
29372            }
29373        }
29374    }
29375
29376    /// Project ID owning the service account.
29377    ///
29378    /// Sets the *project id* path property to the given value.
29379    ///
29380    /// Even though the property as already been set when instantiating this call,
29381    /// we provide this method for API completeness.
29382    pub fn project_id(mut self, new_value: &str) -> ProjectHmacKeyCreateCall<'a, C> {
29383        self._project_id = new_value.to_string();
29384        self
29385    }
29386    /// Email address of the service account.
29387    ///
29388    /// Sets the *service account email* query property to the given value.
29389    ///
29390    /// Even though the property as already been set when instantiating this call,
29391    /// we provide this method for API completeness.
29392    pub fn service_account_email(mut self, new_value: &str) -> ProjectHmacKeyCreateCall<'a, C> {
29393        self._service_account_email = new_value.to_string();
29394        self
29395    }
29396    /// The project to be billed for this request.
29397    ///
29398    /// Sets the *user project* query property to the given value.
29399    pub fn user_project(mut self, new_value: &str) -> ProjectHmacKeyCreateCall<'a, C> {
29400        self._user_project = Some(new_value.to_string());
29401        self
29402    }
29403    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29404    /// while executing the actual API request.
29405    ///
29406    /// ````text
29407    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
29408    /// ````
29409    ///
29410    /// Sets the *delegate* property to the given value.
29411    pub fn delegate(
29412        mut self,
29413        new_value: &'a mut dyn common::Delegate,
29414    ) -> ProjectHmacKeyCreateCall<'a, C> {
29415        self._delegate = Some(new_value);
29416        self
29417    }
29418
29419    /// Set any additional parameter of the query string used in the request.
29420    /// It should be used to set parameters which are not yet available through their own
29421    /// setters.
29422    ///
29423    /// Please note that this method must not be used to set any of the known parameters
29424    /// which have their own setter method. If done anyway, the request will fail.
29425    ///
29426    /// # Additional Parameters
29427    ///
29428    /// * *alt* (query-string) - Data format for the response.
29429    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29430    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
29431    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29432    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29433    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
29434    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
29435    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
29436    pub fn param<T>(mut self, name: T, value: T) -> ProjectHmacKeyCreateCall<'a, C>
29437    where
29438        T: AsRef<str>,
29439    {
29440        self._additional_params
29441            .insert(name.as_ref().to_string(), value.as_ref().to_string());
29442        self
29443    }
29444
29445    /// Identifies the authorization scope for the method you are building.
29446    ///
29447    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29448    /// [`Scope::CloudPlatform`].
29449    ///
29450    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29451    /// tokens for more than one scope.
29452    ///
29453    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29454    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29455    /// sufficient, a read-write scope will do as well.
29456    pub fn add_scope<St>(mut self, scope: St) -> ProjectHmacKeyCreateCall<'a, C>
29457    where
29458        St: AsRef<str>,
29459    {
29460        self._scopes.insert(String::from(scope.as_ref()));
29461        self
29462    }
29463    /// Identifies the authorization scope(s) for the method you are building.
29464    ///
29465    /// See [`Self::add_scope()`] for details.
29466    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectHmacKeyCreateCall<'a, C>
29467    where
29468        I: IntoIterator<Item = St>,
29469        St: AsRef<str>,
29470    {
29471        self._scopes
29472            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29473        self
29474    }
29475
29476    /// Removes all scopes, and no default scope will be used either.
29477    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29478    /// for details).
29479    pub fn clear_scopes(mut self) -> ProjectHmacKeyCreateCall<'a, C> {
29480        self._scopes.clear();
29481        self
29482    }
29483}
29484
29485/// Deletes an HMAC key.
29486///
29487/// A builder for the *hmacKeys.delete* method supported by a *project* resource.
29488/// It is not used directly, but through a [`ProjectMethods`] instance.
29489///
29490/// # Example
29491///
29492/// Instantiate a resource method builder
29493///
29494/// ```test_harness,no_run
29495/// # extern crate hyper;
29496/// # extern crate hyper_rustls;
29497/// # extern crate google_storage1 as storage1;
29498/// # async fn dox() {
29499/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29500///
29501/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29502/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
29503/// #     secret,
29504/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29505/// # ).build().await.unwrap();
29506///
29507/// # let client = hyper_util::client::legacy::Client::builder(
29508/// #     hyper_util::rt::TokioExecutor::new()
29509/// # )
29510/// # .build(
29511/// #     hyper_rustls::HttpsConnectorBuilder::new()
29512/// #         .with_native_roots()
29513/// #         .unwrap()
29514/// #         .https_or_http()
29515/// #         .enable_http1()
29516/// #         .build()
29517/// # );
29518/// # let mut hub = Storage::new(client, auth);
29519/// // You can configure optional parameters by calling the respective setters at will, and
29520/// // execute the final call using `doit()`.
29521/// // Values shown here are possibly random and not representative !
29522/// let result = hub.projects().hmac_keys_delete("projectId", "accessId")
29523///              .user_project("sea")
29524///              .doit().await;
29525/// # }
29526/// ```
29527pub struct ProjectHmacKeyDeleteCall<'a, C>
29528where
29529    C: 'a,
29530{
29531    hub: &'a Storage<C>,
29532    _project_id: String,
29533    _access_id: String,
29534    _user_project: Option<String>,
29535    _delegate: Option<&'a mut dyn common::Delegate>,
29536    _additional_params: HashMap<String, String>,
29537    _scopes: BTreeSet<String>,
29538}
29539
29540impl<'a, C> common::CallBuilder for ProjectHmacKeyDeleteCall<'a, C> {}
29541
29542impl<'a, C> ProjectHmacKeyDeleteCall<'a, C>
29543where
29544    C: common::Connector,
29545{
29546    /// Perform the operation you have build so far.
29547    pub async fn doit(mut self) -> common::Result<common::Response> {
29548        use std::borrow::Cow;
29549        use std::io::{Read, Seek};
29550
29551        use common::{url::Params, ToParts};
29552        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29553
29554        let mut dd = common::DefaultDelegate;
29555        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29556        dlg.begin(common::MethodInfo {
29557            id: "storage.projects.hmacKeys.delete",
29558            http_method: hyper::Method::DELETE,
29559        });
29560
29561        for &field in ["projectId", "accessId", "userProject"].iter() {
29562            if self._additional_params.contains_key(field) {
29563                dlg.finished(false);
29564                return Err(common::Error::FieldClash(field));
29565            }
29566        }
29567
29568        let mut params = Params::with_capacity(4 + self._additional_params.len());
29569        params.push("projectId", self._project_id);
29570        params.push("accessId", self._access_id);
29571        if let Some(value) = self._user_project.as_ref() {
29572            params.push("userProject", value);
29573        }
29574
29575        params.extend(self._additional_params.iter());
29576
29577        let mut url = self.hub._base_url.clone() + "projects/{projectId}/hmacKeys/{accessId}";
29578        if self._scopes.is_empty() {
29579            self._scopes
29580                .insert(Scope::CloudPlatform.as_ref().to_string());
29581        }
29582
29583        #[allow(clippy::single_element_loop)]
29584        for &(find_this, param_name) in
29585            [("{projectId}", "projectId"), ("{accessId}", "accessId")].iter()
29586        {
29587            url = params.uri_replacement(url, param_name, find_this, false);
29588        }
29589        {
29590            let to_remove = ["accessId", "projectId"];
29591            params.remove_params(&to_remove);
29592        }
29593
29594        let url = params.parse_with_url(&url);
29595
29596        loop {
29597            let token = match self
29598                .hub
29599                .auth
29600                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29601                .await
29602            {
29603                Ok(token) => token,
29604                Err(e) => match dlg.token(e) {
29605                    Ok(token) => token,
29606                    Err(e) => {
29607                        dlg.finished(false);
29608                        return Err(common::Error::MissingToken(e));
29609                    }
29610                },
29611            };
29612            let mut req_result = {
29613                let client = &self.hub.client;
29614                dlg.pre_request();
29615                let mut req_builder = hyper::Request::builder()
29616                    .method(hyper::Method::DELETE)
29617                    .uri(url.as_str())
29618                    .header(USER_AGENT, self.hub._user_agent.clone());
29619
29620                if let Some(token) = token.as_ref() {
29621                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29622                }
29623
29624                let request = req_builder
29625                    .header(CONTENT_LENGTH, 0_u64)
29626                    .body(common::to_body::<String>(None));
29627
29628                client.request(request.unwrap()).await
29629            };
29630
29631            match req_result {
29632                Err(err) => {
29633                    if let common::Retry::After(d) = dlg.http_error(&err) {
29634                        sleep(d).await;
29635                        continue;
29636                    }
29637                    dlg.finished(false);
29638                    return Err(common::Error::HttpError(err));
29639                }
29640                Ok(res) => {
29641                    let (mut parts, body) = res.into_parts();
29642                    let mut body = common::Body::new(body);
29643                    if !parts.status.is_success() {
29644                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29645                        let error = serde_json::from_str(&common::to_string(&bytes));
29646                        let response = common::to_response(parts, bytes.into());
29647
29648                        if let common::Retry::After(d) =
29649                            dlg.http_failure(&response, error.as_ref().ok())
29650                        {
29651                            sleep(d).await;
29652                            continue;
29653                        }
29654
29655                        dlg.finished(false);
29656
29657                        return Err(match error {
29658                            Ok(value) => common::Error::BadRequest(value),
29659                            _ => common::Error::Failure(response),
29660                        });
29661                    }
29662                    let response = common::Response::from_parts(parts, body);
29663
29664                    dlg.finished(true);
29665                    return Ok(response);
29666                }
29667            }
29668        }
29669    }
29670
29671    /// Project ID owning the requested key
29672    ///
29673    /// Sets the *project id* path property to the given value.
29674    ///
29675    /// Even though the property as already been set when instantiating this call,
29676    /// we provide this method for API completeness.
29677    pub fn project_id(mut self, new_value: &str) -> ProjectHmacKeyDeleteCall<'a, C> {
29678        self._project_id = new_value.to_string();
29679        self
29680    }
29681    /// Name of the HMAC key to be deleted.
29682    ///
29683    /// Sets the *access id* path property to the given value.
29684    ///
29685    /// Even though the property as already been set when instantiating this call,
29686    /// we provide this method for API completeness.
29687    pub fn access_id(mut self, new_value: &str) -> ProjectHmacKeyDeleteCall<'a, C> {
29688        self._access_id = new_value.to_string();
29689        self
29690    }
29691    /// The project to be billed for this request.
29692    ///
29693    /// Sets the *user project* query property to the given value.
29694    pub fn user_project(mut self, new_value: &str) -> ProjectHmacKeyDeleteCall<'a, C> {
29695        self._user_project = Some(new_value.to_string());
29696        self
29697    }
29698    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29699    /// while executing the actual API request.
29700    ///
29701    /// ````text
29702    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
29703    /// ````
29704    ///
29705    /// Sets the *delegate* property to the given value.
29706    pub fn delegate(
29707        mut self,
29708        new_value: &'a mut dyn common::Delegate,
29709    ) -> ProjectHmacKeyDeleteCall<'a, C> {
29710        self._delegate = Some(new_value);
29711        self
29712    }
29713
29714    /// Set any additional parameter of the query string used in the request.
29715    /// It should be used to set parameters which are not yet available through their own
29716    /// setters.
29717    ///
29718    /// Please note that this method must not be used to set any of the known parameters
29719    /// which have their own setter method. If done anyway, the request will fail.
29720    ///
29721    /// # Additional Parameters
29722    ///
29723    /// * *alt* (query-string) - Data format for the response.
29724    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29725    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
29726    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29727    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29728    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
29729    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
29730    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
29731    pub fn param<T>(mut self, name: T, value: T) -> ProjectHmacKeyDeleteCall<'a, C>
29732    where
29733        T: AsRef<str>,
29734    {
29735        self._additional_params
29736            .insert(name.as_ref().to_string(), value.as_ref().to_string());
29737        self
29738    }
29739
29740    /// Identifies the authorization scope for the method you are building.
29741    ///
29742    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29743    /// [`Scope::CloudPlatform`].
29744    ///
29745    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29746    /// tokens for more than one scope.
29747    ///
29748    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29749    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29750    /// sufficient, a read-write scope will do as well.
29751    pub fn add_scope<St>(mut self, scope: St) -> ProjectHmacKeyDeleteCall<'a, C>
29752    where
29753        St: AsRef<str>,
29754    {
29755        self._scopes.insert(String::from(scope.as_ref()));
29756        self
29757    }
29758    /// Identifies the authorization scope(s) for the method you are building.
29759    ///
29760    /// See [`Self::add_scope()`] for details.
29761    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectHmacKeyDeleteCall<'a, C>
29762    where
29763        I: IntoIterator<Item = St>,
29764        St: AsRef<str>,
29765    {
29766        self._scopes
29767            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29768        self
29769    }
29770
29771    /// Removes all scopes, and no default scope will be used either.
29772    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29773    /// for details).
29774    pub fn clear_scopes(mut self) -> ProjectHmacKeyDeleteCall<'a, C> {
29775        self._scopes.clear();
29776        self
29777    }
29778}
29779
29780/// Retrieves an HMAC key's metadata
29781///
29782/// A builder for the *hmacKeys.get* method supported by a *project* resource.
29783/// It is not used directly, but through a [`ProjectMethods`] instance.
29784///
29785/// # Example
29786///
29787/// Instantiate a resource method builder
29788///
29789/// ```test_harness,no_run
29790/// # extern crate hyper;
29791/// # extern crate hyper_rustls;
29792/// # extern crate google_storage1 as storage1;
29793/// # async fn dox() {
29794/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29795///
29796/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29797/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
29798/// #     secret,
29799/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29800/// # ).build().await.unwrap();
29801///
29802/// # let client = hyper_util::client::legacy::Client::builder(
29803/// #     hyper_util::rt::TokioExecutor::new()
29804/// # )
29805/// # .build(
29806/// #     hyper_rustls::HttpsConnectorBuilder::new()
29807/// #         .with_native_roots()
29808/// #         .unwrap()
29809/// #         .https_or_http()
29810/// #         .enable_http1()
29811/// #         .build()
29812/// # );
29813/// # let mut hub = Storage::new(client, auth);
29814/// // You can configure optional parameters by calling the respective setters at will, and
29815/// // execute the final call using `doit()`.
29816/// // Values shown here are possibly random and not representative !
29817/// let result = hub.projects().hmac_keys_get("projectId", "accessId")
29818///              .user_project("Stet")
29819///              .doit().await;
29820/// # }
29821/// ```
29822pub struct ProjectHmacKeyGetCall<'a, C>
29823where
29824    C: 'a,
29825{
29826    hub: &'a Storage<C>,
29827    _project_id: String,
29828    _access_id: String,
29829    _user_project: Option<String>,
29830    _delegate: Option<&'a mut dyn common::Delegate>,
29831    _additional_params: HashMap<String, String>,
29832    _scopes: BTreeSet<String>,
29833}
29834
29835impl<'a, C> common::CallBuilder for ProjectHmacKeyGetCall<'a, C> {}
29836
29837impl<'a, C> ProjectHmacKeyGetCall<'a, C>
29838where
29839    C: common::Connector,
29840{
29841    /// Perform the operation you have build so far.
29842    pub async fn doit(mut self) -> common::Result<(common::Response, HmacKeyMetadata)> {
29843        use std::borrow::Cow;
29844        use std::io::{Read, Seek};
29845
29846        use common::{url::Params, ToParts};
29847        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29848
29849        let mut dd = common::DefaultDelegate;
29850        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29851        dlg.begin(common::MethodInfo {
29852            id: "storage.projects.hmacKeys.get",
29853            http_method: hyper::Method::GET,
29854        });
29855
29856        for &field in ["alt", "projectId", "accessId", "userProject"].iter() {
29857            if self._additional_params.contains_key(field) {
29858                dlg.finished(false);
29859                return Err(common::Error::FieldClash(field));
29860            }
29861        }
29862
29863        let mut params = Params::with_capacity(5 + self._additional_params.len());
29864        params.push("projectId", self._project_id);
29865        params.push("accessId", self._access_id);
29866        if let Some(value) = self._user_project.as_ref() {
29867            params.push("userProject", value);
29868        }
29869
29870        params.extend(self._additional_params.iter());
29871
29872        params.push("alt", "json");
29873        let mut url = self.hub._base_url.clone() + "projects/{projectId}/hmacKeys/{accessId}";
29874        if self._scopes.is_empty() {
29875            self._scopes
29876                .insert(Scope::CloudPlatform.as_ref().to_string());
29877        }
29878
29879        #[allow(clippy::single_element_loop)]
29880        for &(find_this, param_name) in
29881            [("{projectId}", "projectId"), ("{accessId}", "accessId")].iter()
29882        {
29883            url = params.uri_replacement(url, param_name, find_this, false);
29884        }
29885        {
29886            let to_remove = ["accessId", "projectId"];
29887            params.remove_params(&to_remove);
29888        }
29889
29890        let url = params.parse_with_url(&url);
29891
29892        loop {
29893            let token = match self
29894                .hub
29895                .auth
29896                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29897                .await
29898            {
29899                Ok(token) => token,
29900                Err(e) => match dlg.token(e) {
29901                    Ok(token) => token,
29902                    Err(e) => {
29903                        dlg.finished(false);
29904                        return Err(common::Error::MissingToken(e));
29905                    }
29906                },
29907            };
29908            let mut req_result = {
29909                let client = &self.hub.client;
29910                dlg.pre_request();
29911                let mut req_builder = hyper::Request::builder()
29912                    .method(hyper::Method::GET)
29913                    .uri(url.as_str())
29914                    .header(USER_AGENT, self.hub._user_agent.clone());
29915
29916                if let Some(token) = token.as_ref() {
29917                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29918                }
29919
29920                let request = req_builder
29921                    .header(CONTENT_LENGTH, 0_u64)
29922                    .body(common::to_body::<String>(None));
29923
29924                client.request(request.unwrap()).await
29925            };
29926
29927            match req_result {
29928                Err(err) => {
29929                    if let common::Retry::After(d) = dlg.http_error(&err) {
29930                        sleep(d).await;
29931                        continue;
29932                    }
29933                    dlg.finished(false);
29934                    return Err(common::Error::HttpError(err));
29935                }
29936                Ok(res) => {
29937                    let (mut parts, body) = res.into_parts();
29938                    let mut body = common::Body::new(body);
29939                    if !parts.status.is_success() {
29940                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29941                        let error = serde_json::from_str(&common::to_string(&bytes));
29942                        let response = common::to_response(parts, bytes.into());
29943
29944                        if let common::Retry::After(d) =
29945                            dlg.http_failure(&response, error.as_ref().ok())
29946                        {
29947                            sleep(d).await;
29948                            continue;
29949                        }
29950
29951                        dlg.finished(false);
29952
29953                        return Err(match error {
29954                            Ok(value) => common::Error::BadRequest(value),
29955                            _ => common::Error::Failure(response),
29956                        });
29957                    }
29958                    let response = {
29959                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29960                        let encoded = common::to_string(&bytes);
29961                        match serde_json::from_str(&encoded) {
29962                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29963                            Err(error) => {
29964                                dlg.response_json_decode_error(&encoded, &error);
29965                                return Err(common::Error::JsonDecodeError(
29966                                    encoded.to_string(),
29967                                    error,
29968                                ));
29969                            }
29970                        }
29971                    };
29972
29973                    dlg.finished(true);
29974                    return Ok(response);
29975                }
29976            }
29977        }
29978    }
29979
29980    /// Project ID owning the service account of the requested key.
29981    ///
29982    /// Sets the *project id* path property to the given value.
29983    ///
29984    /// Even though the property as already been set when instantiating this call,
29985    /// we provide this method for API completeness.
29986    pub fn project_id(mut self, new_value: &str) -> ProjectHmacKeyGetCall<'a, C> {
29987        self._project_id = new_value.to_string();
29988        self
29989    }
29990    /// Name of the HMAC key.
29991    ///
29992    /// Sets the *access id* path property to the given value.
29993    ///
29994    /// Even though the property as already been set when instantiating this call,
29995    /// we provide this method for API completeness.
29996    pub fn access_id(mut self, new_value: &str) -> ProjectHmacKeyGetCall<'a, C> {
29997        self._access_id = new_value.to_string();
29998        self
29999    }
30000    /// The project to be billed for this request.
30001    ///
30002    /// Sets the *user project* query property to the given value.
30003    pub fn user_project(mut self, new_value: &str) -> ProjectHmacKeyGetCall<'a, C> {
30004        self._user_project = Some(new_value.to_string());
30005        self
30006    }
30007    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30008    /// while executing the actual API request.
30009    ///
30010    /// ````text
30011    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
30012    /// ````
30013    ///
30014    /// Sets the *delegate* property to the given value.
30015    pub fn delegate(
30016        mut self,
30017        new_value: &'a mut dyn common::Delegate,
30018    ) -> ProjectHmacKeyGetCall<'a, C> {
30019        self._delegate = Some(new_value);
30020        self
30021    }
30022
30023    /// Set any additional parameter of the query string used in the request.
30024    /// It should be used to set parameters which are not yet available through their own
30025    /// setters.
30026    ///
30027    /// Please note that this method must not be used to set any of the known parameters
30028    /// which have their own setter method. If done anyway, the request will fail.
30029    ///
30030    /// # Additional Parameters
30031    ///
30032    /// * *alt* (query-string) - Data format for the response.
30033    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30034    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
30035    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30036    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30037    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
30038    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
30039    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
30040    pub fn param<T>(mut self, name: T, value: T) -> ProjectHmacKeyGetCall<'a, C>
30041    where
30042        T: AsRef<str>,
30043    {
30044        self._additional_params
30045            .insert(name.as_ref().to_string(), value.as_ref().to_string());
30046        self
30047    }
30048
30049    /// Identifies the authorization scope for the method you are building.
30050    ///
30051    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30052    /// [`Scope::CloudPlatform`].
30053    ///
30054    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30055    /// tokens for more than one scope.
30056    ///
30057    /// Usually there is more than one suitable scope to authorize an operation, some of which may
30058    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30059    /// sufficient, a read-write scope will do as well.
30060    pub fn add_scope<St>(mut self, scope: St) -> ProjectHmacKeyGetCall<'a, C>
30061    where
30062        St: AsRef<str>,
30063    {
30064        self._scopes.insert(String::from(scope.as_ref()));
30065        self
30066    }
30067    /// Identifies the authorization scope(s) for the method you are building.
30068    ///
30069    /// See [`Self::add_scope()`] for details.
30070    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectHmacKeyGetCall<'a, C>
30071    where
30072        I: IntoIterator<Item = St>,
30073        St: AsRef<str>,
30074    {
30075        self._scopes
30076            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30077        self
30078    }
30079
30080    /// Removes all scopes, and no default scope will be used either.
30081    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30082    /// for details).
30083    pub fn clear_scopes(mut self) -> ProjectHmacKeyGetCall<'a, C> {
30084        self._scopes.clear();
30085        self
30086    }
30087}
30088
30089/// Retrieves a list of HMAC keys matching the criteria.
30090///
30091/// A builder for the *hmacKeys.list* method supported by a *project* resource.
30092/// It is not used directly, but through a [`ProjectMethods`] instance.
30093///
30094/// # Example
30095///
30096/// Instantiate a resource method builder
30097///
30098/// ```test_harness,no_run
30099/// # extern crate hyper;
30100/// # extern crate hyper_rustls;
30101/// # extern crate google_storage1 as storage1;
30102/// # async fn dox() {
30103/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30104///
30105/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30106/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
30107/// #     secret,
30108/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30109/// # ).build().await.unwrap();
30110///
30111/// # let client = hyper_util::client::legacy::Client::builder(
30112/// #     hyper_util::rt::TokioExecutor::new()
30113/// # )
30114/// # .build(
30115/// #     hyper_rustls::HttpsConnectorBuilder::new()
30116/// #         .with_native_roots()
30117/// #         .unwrap()
30118/// #         .https_or_http()
30119/// #         .enable_http1()
30120/// #         .build()
30121/// # );
30122/// # let mut hub = Storage::new(client, auth);
30123/// // You can configure optional parameters by calling the respective setters at will, and
30124/// // execute the final call using `doit()`.
30125/// // Values shown here are possibly random and not representative !
30126/// let result = hub.projects().hmac_keys_list("projectId")
30127///              .user_project("no")
30128///              .show_deleted_keys(true)
30129///              .service_account_email("ipsum")
30130///              .page_token("sea")
30131///              .max_results(3)
30132///              .doit().await;
30133/// # }
30134/// ```
30135pub struct ProjectHmacKeyListCall<'a, C>
30136where
30137    C: 'a,
30138{
30139    hub: &'a Storage<C>,
30140    _project_id: String,
30141    _user_project: Option<String>,
30142    _show_deleted_keys: Option<bool>,
30143    _service_account_email: Option<String>,
30144    _page_token: Option<String>,
30145    _max_results: Option<u32>,
30146    _delegate: Option<&'a mut dyn common::Delegate>,
30147    _additional_params: HashMap<String, String>,
30148    _scopes: BTreeSet<String>,
30149}
30150
30151impl<'a, C> common::CallBuilder for ProjectHmacKeyListCall<'a, C> {}
30152
30153impl<'a, C> ProjectHmacKeyListCall<'a, C>
30154where
30155    C: common::Connector,
30156{
30157    /// Perform the operation you have build so far.
30158    pub async fn doit(mut self) -> common::Result<(common::Response, HmacKeysMetadata)> {
30159        use std::borrow::Cow;
30160        use std::io::{Read, Seek};
30161
30162        use common::{url::Params, ToParts};
30163        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30164
30165        let mut dd = common::DefaultDelegate;
30166        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30167        dlg.begin(common::MethodInfo {
30168            id: "storage.projects.hmacKeys.list",
30169            http_method: hyper::Method::GET,
30170        });
30171
30172        for &field in [
30173            "alt",
30174            "projectId",
30175            "userProject",
30176            "showDeletedKeys",
30177            "serviceAccountEmail",
30178            "pageToken",
30179            "maxResults",
30180        ]
30181        .iter()
30182        {
30183            if self._additional_params.contains_key(field) {
30184                dlg.finished(false);
30185                return Err(common::Error::FieldClash(field));
30186            }
30187        }
30188
30189        let mut params = Params::with_capacity(8 + self._additional_params.len());
30190        params.push("projectId", self._project_id);
30191        if let Some(value) = self._user_project.as_ref() {
30192            params.push("userProject", value);
30193        }
30194        if let Some(value) = self._show_deleted_keys.as_ref() {
30195            params.push("showDeletedKeys", value.to_string());
30196        }
30197        if let Some(value) = self._service_account_email.as_ref() {
30198            params.push("serviceAccountEmail", value);
30199        }
30200        if let Some(value) = self._page_token.as_ref() {
30201            params.push("pageToken", value);
30202        }
30203        if let Some(value) = self._max_results.as_ref() {
30204            params.push("maxResults", value.to_string());
30205        }
30206
30207        params.extend(self._additional_params.iter());
30208
30209        params.push("alt", "json");
30210        let mut url = self.hub._base_url.clone() + "projects/{projectId}/hmacKeys";
30211        if self._scopes.is_empty() {
30212            self._scopes
30213                .insert(Scope::CloudPlatform.as_ref().to_string());
30214        }
30215
30216        #[allow(clippy::single_element_loop)]
30217        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
30218            url = params.uri_replacement(url, param_name, find_this, false);
30219        }
30220        {
30221            let to_remove = ["projectId"];
30222            params.remove_params(&to_remove);
30223        }
30224
30225        let url = params.parse_with_url(&url);
30226
30227        loop {
30228            let token = match self
30229                .hub
30230                .auth
30231                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30232                .await
30233            {
30234                Ok(token) => token,
30235                Err(e) => match dlg.token(e) {
30236                    Ok(token) => token,
30237                    Err(e) => {
30238                        dlg.finished(false);
30239                        return Err(common::Error::MissingToken(e));
30240                    }
30241                },
30242            };
30243            let mut req_result = {
30244                let client = &self.hub.client;
30245                dlg.pre_request();
30246                let mut req_builder = hyper::Request::builder()
30247                    .method(hyper::Method::GET)
30248                    .uri(url.as_str())
30249                    .header(USER_AGENT, self.hub._user_agent.clone());
30250
30251                if let Some(token) = token.as_ref() {
30252                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30253                }
30254
30255                let request = req_builder
30256                    .header(CONTENT_LENGTH, 0_u64)
30257                    .body(common::to_body::<String>(None));
30258
30259                client.request(request.unwrap()).await
30260            };
30261
30262            match req_result {
30263                Err(err) => {
30264                    if let common::Retry::After(d) = dlg.http_error(&err) {
30265                        sleep(d).await;
30266                        continue;
30267                    }
30268                    dlg.finished(false);
30269                    return Err(common::Error::HttpError(err));
30270                }
30271                Ok(res) => {
30272                    let (mut parts, body) = res.into_parts();
30273                    let mut body = common::Body::new(body);
30274                    if !parts.status.is_success() {
30275                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30276                        let error = serde_json::from_str(&common::to_string(&bytes));
30277                        let response = common::to_response(parts, bytes.into());
30278
30279                        if let common::Retry::After(d) =
30280                            dlg.http_failure(&response, error.as_ref().ok())
30281                        {
30282                            sleep(d).await;
30283                            continue;
30284                        }
30285
30286                        dlg.finished(false);
30287
30288                        return Err(match error {
30289                            Ok(value) => common::Error::BadRequest(value),
30290                            _ => common::Error::Failure(response),
30291                        });
30292                    }
30293                    let response = {
30294                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30295                        let encoded = common::to_string(&bytes);
30296                        match serde_json::from_str(&encoded) {
30297                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30298                            Err(error) => {
30299                                dlg.response_json_decode_error(&encoded, &error);
30300                                return Err(common::Error::JsonDecodeError(
30301                                    encoded.to_string(),
30302                                    error,
30303                                ));
30304                            }
30305                        }
30306                    };
30307
30308                    dlg.finished(true);
30309                    return Ok(response);
30310                }
30311            }
30312        }
30313    }
30314
30315    /// Name of the project in which to look for HMAC keys.
30316    ///
30317    /// Sets the *project id* path property to the given value.
30318    ///
30319    /// Even though the property as already been set when instantiating this call,
30320    /// we provide this method for API completeness.
30321    pub fn project_id(mut self, new_value: &str) -> ProjectHmacKeyListCall<'a, C> {
30322        self._project_id = new_value.to_string();
30323        self
30324    }
30325    /// The project to be billed for this request.
30326    ///
30327    /// Sets the *user project* query property to the given value.
30328    pub fn user_project(mut self, new_value: &str) -> ProjectHmacKeyListCall<'a, C> {
30329        self._user_project = Some(new_value.to_string());
30330        self
30331    }
30332    /// Whether or not to show keys in the DELETED state.
30333    ///
30334    /// Sets the *show deleted keys* query property to the given value.
30335    pub fn show_deleted_keys(mut self, new_value: bool) -> ProjectHmacKeyListCall<'a, C> {
30336        self._show_deleted_keys = Some(new_value);
30337        self
30338    }
30339    /// If present, only keys for the given service account are returned.
30340    ///
30341    /// Sets the *service account email* query property to the given value.
30342    pub fn service_account_email(mut self, new_value: &str) -> ProjectHmacKeyListCall<'a, C> {
30343        self._service_account_email = Some(new_value.to_string());
30344        self
30345    }
30346    /// A previously-returned page token representing part of the larger set of results to view.
30347    ///
30348    /// Sets the *page token* query property to the given value.
30349    pub fn page_token(mut self, new_value: &str) -> ProjectHmacKeyListCall<'a, C> {
30350        self._page_token = Some(new_value.to_string());
30351        self
30352    }
30353    /// Maximum number of items to return in a single page of responses. The service uses this parameter or 250 items, whichever is smaller. The max number of items per page will also be limited by the number of distinct service accounts in the response. If the number of service accounts in a single response is too high, the page will truncated and a next page token will be returned.
30354    ///
30355    /// Sets the *max results* query property to the given value.
30356    pub fn max_results(mut self, new_value: u32) -> ProjectHmacKeyListCall<'a, C> {
30357        self._max_results = Some(new_value);
30358        self
30359    }
30360    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30361    /// while executing the actual API request.
30362    ///
30363    /// ````text
30364    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
30365    /// ````
30366    ///
30367    /// Sets the *delegate* property to the given value.
30368    pub fn delegate(
30369        mut self,
30370        new_value: &'a mut dyn common::Delegate,
30371    ) -> ProjectHmacKeyListCall<'a, C> {
30372        self._delegate = Some(new_value);
30373        self
30374    }
30375
30376    /// Set any additional parameter of the query string used in the request.
30377    /// It should be used to set parameters which are not yet available through their own
30378    /// setters.
30379    ///
30380    /// Please note that this method must not be used to set any of the known parameters
30381    /// which have their own setter method. If done anyway, the request will fail.
30382    ///
30383    /// # Additional Parameters
30384    ///
30385    /// * *alt* (query-string) - Data format for the response.
30386    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30387    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
30388    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30389    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30390    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
30391    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
30392    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
30393    pub fn param<T>(mut self, name: T, value: T) -> ProjectHmacKeyListCall<'a, C>
30394    where
30395        T: AsRef<str>,
30396    {
30397        self._additional_params
30398            .insert(name.as_ref().to_string(), value.as_ref().to_string());
30399        self
30400    }
30401
30402    /// Identifies the authorization scope for the method you are building.
30403    ///
30404    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30405    /// [`Scope::CloudPlatform`].
30406    ///
30407    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30408    /// tokens for more than one scope.
30409    ///
30410    /// Usually there is more than one suitable scope to authorize an operation, some of which may
30411    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30412    /// sufficient, a read-write scope will do as well.
30413    pub fn add_scope<St>(mut self, scope: St) -> ProjectHmacKeyListCall<'a, C>
30414    where
30415        St: AsRef<str>,
30416    {
30417        self._scopes.insert(String::from(scope.as_ref()));
30418        self
30419    }
30420    /// Identifies the authorization scope(s) for the method you are building.
30421    ///
30422    /// See [`Self::add_scope()`] for details.
30423    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectHmacKeyListCall<'a, C>
30424    where
30425        I: IntoIterator<Item = St>,
30426        St: AsRef<str>,
30427    {
30428        self._scopes
30429            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30430        self
30431    }
30432
30433    /// Removes all scopes, and no default scope will be used either.
30434    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30435    /// for details).
30436    pub fn clear_scopes(mut self) -> ProjectHmacKeyListCall<'a, C> {
30437        self._scopes.clear();
30438        self
30439    }
30440}
30441
30442/// Updates the state of an HMAC key. See the HMAC Key resource descriptor for valid states.
30443///
30444/// A builder for the *hmacKeys.update* method supported by a *project* resource.
30445/// It is not used directly, but through a [`ProjectMethods`] instance.
30446///
30447/// # Example
30448///
30449/// Instantiate a resource method builder
30450///
30451/// ```test_harness,no_run
30452/// # extern crate hyper;
30453/// # extern crate hyper_rustls;
30454/// # extern crate google_storage1 as storage1;
30455/// use storage1::api::HmacKeyMetadata;
30456/// # async fn dox() {
30457/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30458///
30459/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30460/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
30461/// #     secret,
30462/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30463/// # ).build().await.unwrap();
30464///
30465/// # let client = hyper_util::client::legacy::Client::builder(
30466/// #     hyper_util::rt::TokioExecutor::new()
30467/// # )
30468/// # .build(
30469/// #     hyper_rustls::HttpsConnectorBuilder::new()
30470/// #         .with_native_roots()
30471/// #         .unwrap()
30472/// #         .https_or_http()
30473/// #         .enable_http1()
30474/// #         .build()
30475/// # );
30476/// # let mut hub = Storage::new(client, auth);
30477/// // As the method needs a request, you would usually fill it with the desired information
30478/// // into the respective structure. Some of the parts shown here might not be applicable !
30479/// // Values shown here are possibly random and not representative !
30480/// let mut req = HmacKeyMetadata::default();
30481///
30482/// // You can configure optional parameters by calling the respective setters at will, and
30483/// // execute the final call using `doit()`.
30484/// // Values shown here are possibly random and not representative !
30485/// let result = hub.projects().hmac_keys_update(req, "projectId", "accessId")
30486///              .user_project("At")
30487///              .doit().await;
30488/// # }
30489/// ```
30490pub struct ProjectHmacKeyUpdateCall<'a, C>
30491where
30492    C: 'a,
30493{
30494    hub: &'a Storage<C>,
30495    _request: HmacKeyMetadata,
30496    _project_id: String,
30497    _access_id: String,
30498    _user_project: Option<String>,
30499    _delegate: Option<&'a mut dyn common::Delegate>,
30500    _additional_params: HashMap<String, String>,
30501    _scopes: BTreeSet<String>,
30502}
30503
30504impl<'a, C> common::CallBuilder for ProjectHmacKeyUpdateCall<'a, C> {}
30505
30506impl<'a, C> ProjectHmacKeyUpdateCall<'a, C>
30507where
30508    C: common::Connector,
30509{
30510    /// Perform the operation you have build so far.
30511    pub async fn doit(mut self) -> common::Result<(common::Response, HmacKeyMetadata)> {
30512        use std::borrow::Cow;
30513        use std::io::{Read, Seek};
30514
30515        use common::{url::Params, ToParts};
30516        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30517
30518        let mut dd = common::DefaultDelegate;
30519        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30520        dlg.begin(common::MethodInfo {
30521            id: "storage.projects.hmacKeys.update",
30522            http_method: hyper::Method::PUT,
30523        });
30524
30525        for &field in ["alt", "projectId", "accessId", "userProject"].iter() {
30526            if self._additional_params.contains_key(field) {
30527                dlg.finished(false);
30528                return Err(common::Error::FieldClash(field));
30529            }
30530        }
30531
30532        let mut params = Params::with_capacity(6 + self._additional_params.len());
30533        params.push("projectId", self._project_id);
30534        params.push("accessId", self._access_id);
30535        if let Some(value) = self._user_project.as_ref() {
30536            params.push("userProject", value);
30537        }
30538
30539        params.extend(self._additional_params.iter());
30540
30541        params.push("alt", "json");
30542        let mut url = self.hub._base_url.clone() + "projects/{projectId}/hmacKeys/{accessId}";
30543        if self._scopes.is_empty() {
30544            self._scopes
30545                .insert(Scope::CloudPlatform.as_ref().to_string());
30546        }
30547
30548        #[allow(clippy::single_element_loop)]
30549        for &(find_this, param_name) in
30550            [("{projectId}", "projectId"), ("{accessId}", "accessId")].iter()
30551        {
30552            url = params.uri_replacement(url, param_name, find_this, false);
30553        }
30554        {
30555            let to_remove = ["accessId", "projectId"];
30556            params.remove_params(&to_remove);
30557        }
30558
30559        let url = params.parse_with_url(&url);
30560
30561        let mut json_mime_type = mime::APPLICATION_JSON;
30562        let mut request_value_reader = {
30563            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
30564            common::remove_json_null_values(&mut value);
30565            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
30566            serde_json::to_writer(&mut dst, &value).unwrap();
30567            dst
30568        };
30569        let request_size = request_value_reader
30570            .seek(std::io::SeekFrom::End(0))
30571            .unwrap();
30572        request_value_reader
30573            .seek(std::io::SeekFrom::Start(0))
30574            .unwrap();
30575
30576        loop {
30577            let token = match self
30578                .hub
30579                .auth
30580                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30581                .await
30582            {
30583                Ok(token) => token,
30584                Err(e) => match dlg.token(e) {
30585                    Ok(token) => token,
30586                    Err(e) => {
30587                        dlg.finished(false);
30588                        return Err(common::Error::MissingToken(e));
30589                    }
30590                },
30591            };
30592            request_value_reader
30593                .seek(std::io::SeekFrom::Start(0))
30594                .unwrap();
30595            let mut req_result = {
30596                let client = &self.hub.client;
30597                dlg.pre_request();
30598                let mut req_builder = hyper::Request::builder()
30599                    .method(hyper::Method::PUT)
30600                    .uri(url.as_str())
30601                    .header(USER_AGENT, self.hub._user_agent.clone());
30602
30603                if let Some(token) = token.as_ref() {
30604                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30605                }
30606
30607                let request = req_builder
30608                    .header(CONTENT_TYPE, json_mime_type.to_string())
30609                    .header(CONTENT_LENGTH, request_size as u64)
30610                    .body(common::to_body(
30611                        request_value_reader.get_ref().clone().into(),
30612                    ));
30613
30614                client.request(request.unwrap()).await
30615            };
30616
30617            match req_result {
30618                Err(err) => {
30619                    if let common::Retry::After(d) = dlg.http_error(&err) {
30620                        sleep(d).await;
30621                        continue;
30622                    }
30623                    dlg.finished(false);
30624                    return Err(common::Error::HttpError(err));
30625                }
30626                Ok(res) => {
30627                    let (mut parts, body) = res.into_parts();
30628                    let mut body = common::Body::new(body);
30629                    if !parts.status.is_success() {
30630                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30631                        let error = serde_json::from_str(&common::to_string(&bytes));
30632                        let response = common::to_response(parts, bytes.into());
30633
30634                        if let common::Retry::After(d) =
30635                            dlg.http_failure(&response, error.as_ref().ok())
30636                        {
30637                            sleep(d).await;
30638                            continue;
30639                        }
30640
30641                        dlg.finished(false);
30642
30643                        return Err(match error {
30644                            Ok(value) => common::Error::BadRequest(value),
30645                            _ => common::Error::Failure(response),
30646                        });
30647                    }
30648                    let response = {
30649                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30650                        let encoded = common::to_string(&bytes);
30651                        match serde_json::from_str(&encoded) {
30652                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30653                            Err(error) => {
30654                                dlg.response_json_decode_error(&encoded, &error);
30655                                return Err(common::Error::JsonDecodeError(
30656                                    encoded.to_string(),
30657                                    error,
30658                                ));
30659                            }
30660                        }
30661                    };
30662
30663                    dlg.finished(true);
30664                    return Ok(response);
30665                }
30666            }
30667        }
30668    }
30669
30670    ///
30671    /// Sets the *request* property to the given value.
30672    ///
30673    /// Even though the property as already been set when instantiating this call,
30674    /// we provide this method for API completeness.
30675    pub fn request(mut self, new_value: HmacKeyMetadata) -> ProjectHmacKeyUpdateCall<'a, C> {
30676        self._request = new_value;
30677        self
30678    }
30679    /// Project ID owning the service account of the updated key.
30680    ///
30681    /// Sets the *project id* path property to the given value.
30682    ///
30683    /// Even though the property as already been set when instantiating this call,
30684    /// we provide this method for API completeness.
30685    pub fn project_id(mut self, new_value: &str) -> ProjectHmacKeyUpdateCall<'a, C> {
30686        self._project_id = new_value.to_string();
30687        self
30688    }
30689    /// Name of the HMAC key being updated.
30690    ///
30691    /// Sets the *access id* path property to the given value.
30692    ///
30693    /// Even though the property as already been set when instantiating this call,
30694    /// we provide this method for API completeness.
30695    pub fn access_id(mut self, new_value: &str) -> ProjectHmacKeyUpdateCall<'a, C> {
30696        self._access_id = new_value.to_string();
30697        self
30698    }
30699    /// The project to be billed for this request.
30700    ///
30701    /// Sets the *user project* query property to the given value.
30702    pub fn user_project(mut self, new_value: &str) -> ProjectHmacKeyUpdateCall<'a, C> {
30703        self._user_project = Some(new_value.to_string());
30704        self
30705    }
30706    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30707    /// while executing the actual API request.
30708    ///
30709    /// ````text
30710    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
30711    /// ````
30712    ///
30713    /// Sets the *delegate* property to the given value.
30714    pub fn delegate(
30715        mut self,
30716        new_value: &'a mut dyn common::Delegate,
30717    ) -> ProjectHmacKeyUpdateCall<'a, C> {
30718        self._delegate = Some(new_value);
30719        self
30720    }
30721
30722    /// Set any additional parameter of the query string used in the request.
30723    /// It should be used to set parameters which are not yet available through their own
30724    /// setters.
30725    ///
30726    /// Please note that this method must not be used to set any of the known parameters
30727    /// which have their own setter method. If done anyway, the request will fail.
30728    ///
30729    /// # Additional Parameters
30730    ///
30731    /// * *alt* (query-string) - Data format for the response.
30732    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30733    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
30734    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30735    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30736    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
30737    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
30738    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
30739    pub fn param<T>(mut self, name: T, value: T) -> ProjectHmacKeyUpdateCall<'a, C>
30740    where
30741        T: AsRef<str>,
30742    {
30743        self._additional_params
30744            .insert(name.as_ref().to_string(), value.as_ref().to_string());
30745        self
30746    }
30747
30748    /// Identifies the authorization scope for the method you are building.
30749    ///
30750    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30751    /// [`Scope::CloudPlatform`].
30752    ///
30753    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30754    /// tokens for more than one scope.
30755    ///
30756    /// Usually there is more than one suitable scope to authorize an operation, some of which may
30757    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30758    /// sufficient, a read-write scope will do as well.
30759    pub fn add_scope<St>(mut self, scope: St) -> ProjectHmacKeyUpdateCall<'a, C>
30760    where
30761        St: AsRef<str>,
30762    {
30763        self._scopes.insert(String::from(scope.as_ref()));
30764        self
30765    }
30766    /// Identifies the authorization scope(s) for the method you are building.
30767    ///
30768    /// See [`Self::add_scope()`] for details.
30769    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectHmacKeyUpdateCall<'a, C>
30770    where
30771        I: IntoIterator<Item = St>,
30772        St: AsRef<str>,
30773    {
30774        self._scopes
30775            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30776        self
30777    }
30778
30779    /// Removes all scopes, and no default scope will be used either.
30780    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30781    /// for details).
30782    pub fn clear_scopes(mut self) -> ProjectHmacKeyUpdateCall<'a, C> {
30783        self._scopes.clear();
30784        self
30785    }
30786}
30787
30788/// Get the email address of this project's Google Cloud Storage service account.
30789///
30790/// A builder for the *serviceAccount.get* method supported by a *project* resource.
30791/// It is not used directly, but through a [`ProjectMethods`] instance.
30792///
30793/// # Example
30794///
30795/// Instantiate a resource method builder
30796///
30797/// ```test_harness,no_run
30798/// # extern crate hyper;
30799/// # extern crate hyper_rustls;
30800/// # extern crate google_storage1 as storage1;
30801/// # async fn dox() {
30802/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30803///
30804/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30805/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
30806/// #     secret,
30807/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30808/// # ).build().await.unwrap();
30809///
30810/// # let client = hyper_util::client::legacy::Client::builder(
30811/// #     hyper_util::rt::TokioExecutor::new()
30812/// # )
30813/// # .build(
30814/// #     hyper_rustls::HttpsConnectorBuilder::new()
30815/// #         .with_native_roots()
30816/// #         .unwrap()
30817/// #         .https_or_http()
30818/// #         .enable_http1()
30819/// #         .build()
30820/// # );
30821/// # let mut hub = Storage::new(client, auth);
30822/// // You can configure optional parameters by calling the respective setters at will, and
30823/// // execute the final call using `doit()`.
30824/// // Values shown here are possibly random and not representative !
30825/// let result = hub.projects().service_account_get("projectId")
30826///              .user_project("takimata")
30827///              .doit().await;
30828/// # }
30829/// ```
30830pub struct ProjectServiceAccountGetCall<'a, C>
30831where
30832    C: 'a,
30833{
30834    hub: &'a Storage<C>,
30835    _project_id: String,
30836    _user_project: Option<String>,
30837    _delegate: Option<&'a mut dyn common::Delegate>,
30838    _additional_params: HashMap<String, String>,
30839    _scopes: BTreeSet<String>,
30840}
30841
30842impl<'a, C> common::CallBuilder for ProjectServiceAccountGetCall<'a, C> {}
30843
30844impl<'a, C> ProjectServiceAccountGetCall<'a, C>
30845where
30846    C: common::Connector,
30847{
30848    /// Perform the operation you have build so far.
30849    pub async fn doit(mut self) -> common::Result<(common::Response, ServiceAccount)> {
30850        use std::borrow::Cow;
30851        use std::io::{Read, Seek};
30852
30853        use common::{url::Params, ToParts};
30854        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30855
30856        let mut dd = common::DefaultDelegate;
30857        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30858        dlg.begin(common::MethodInfo {
30859            id: "storage.projects.serviceAccount.get",
30860            http_method: hyper::Method::GET,
30861        });
30862
30863        for &field in ["alt", "projectId", "userProject"].iter() {
30864            if self._additional_params.contains_key(field) {
30865                dlg.finished(false);
30866                return Err(common::Error::FieldClash(field));
30867            }
30868        }
30869
30870        let mut params = Params::with_capacity(4 + self._additional_params.len());
30871        params.push("projectId", self._project_id);
30872        if let Some(value) = self._user_project.as_ref() {
30873            params.push("userProject", value);
30874        }
30875
30876        params.extend(self._additional_params.iter());
30877
30878        params.push("alt", "json");
30879        let mut url = self.hub._base_url.clone() + "projects/{projectId}/serviceAccount";
30880        if self._scopes.is_empty() {
30881            self._scopes
30882                .insert(Scope::CloudPlatform.as_ref().to_string());
30883        }
30884
30885        #[allow(clippy::single_element_loop)]
30886        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
30887            url = params.uri_replacement(url, param_name, find_this, false);
30888        }
30889        {
30890            let to_remove = ["projectId"];
30891            params.remove_params(&to_remove);
30892        }
30893
30894        let url = params.parse_with_url(&url);
30895
30896        loop {
30897            let token = match self
30898                .hub
30899                .auth
30900                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30901                .await
30902            {
30903                Ok(token) => token,
30904                Err(e) => match dlg.token(e) {
30905                    Ok(token) => token,
30906                    Err(e) => {
30907                        dlg.finished(false);
30908                        return Err(common::Error::MissingToken(e));
30909                    }
30910                },
30911            };
30912            let mut req_result = {
30913                let client = &self.hub.client;
30914                dlg.pre_request();
30915                let mut req_builder = hyper::Request::builder()
30916                    .method(hyper::Method::GET)
30917                    .uri(url.as_str())
30918                    .header(USER_AGENT, self.hub._user_agent.clone());
30919
30920                if let Some(token) = token.as_ref() {
30921                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30922                }
30923
30924                let request = req_builder
30925                    .header(CONTENT_LENGTH, 0_u64)
30926                    .body(common::to_body::<String>(None));
30927
30928                client.request(request.unwrap()).await
30929            };
30930
30931            match req_result {
30932                Err(err) => {
30933                    if let common::Retry::After(d) = dlg.http_error(&err) {
30934                        sleep(d).await;
30935                        continue;
30936                    }
30937                    dlg.finished(false);
30938                    return Err(common::Error::HttpError(err));
30939                }
30940                Ok(res) => {
30941                    let (mut parts, body) = res.into_parts();
30942                    let mut body = common::Body::new(body);
30943                    if !parts.status.is_success() {
30944                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30945                        let error = serde_json::from_str(&common::to_string(&bytes));
30946                        let response = common::to_response(parts, bytes.into());
30947
30948                        if let common::Retry::After(d) =
30949                            dlg.http_failure(&response, error.as_ref().ok())
30950                        {
30951                            sleep(d).await;
30952                            continue;
30953                        }
30954
30955                        dlg.finished(false);
30956
30957                        return Err(match error {
30958                            Ok(value) => common::Error::BadRequest(value),
30959                            _ => common::Error::Failure(response),
30960                        });
30961                    }
30962                    let response = {
30963                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30964                        let encoded = common::to_string(&bytes);
30965                        match serde_json::from_str(&encoded) {
30966                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30967                            Err(error) => {
30968                                dlg.response_json_decode_error(&encoded, &error);
30969                                return Err(common::Error::JsonDecodeError(
30970                                    encoded.to_string(),
30971                                    error,
30972                                ));
30973                            }
30974                        }
30975                    };
30976
30977                    dlg.finished(true);
30978                    return Ok(response);
30979                }
30980            }
30981        }
30982    }
30983
30984    /// Project ID
30985    ///
30986    /// Sets the *project id* path property to the given value.
30987    ///
30988    /// Even though the property as already been set when instantiating this call,
30989    /// we provide this method for API completeness.
30990    pub fn project_id(mut self, new_value: &str) -> ProjectServiceAccountGetCall<'a, C> {
30991        self._project_id = new_value.to_string();
30992        self
30993    }
30994    /// The project to be billed for this request.
30995    ///
30996    /// Sets the *user project* query property to the given value.
30997    pub fn user_project(mut self, new_value: &str) -> ProjectServiceAccountGetCall<'a, C> {
30998        self._user_project = Some(new_value.to_string());
30999        self
31000    }
31001    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31002    /// while executing the actual API request.
31003    ///
31004    /// ````text
31005    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
31006    /// ````
31007    ///
31008    /// Sets the *delegate* property to the given value.
31009    pub fn delegate(
31010        mut self,
31011        new_value: &'a mut dyn common::Delegate,
31012    ) -> ProjectServiceAccountGetCall<'a, C> {
31013        self._delegate = Some(new_value);
31014        self
31015    }
31016
31017    /// Set any additional parameter of the query string used in the request.
31018    /// It should be used to set parameters which are not yet available through their own
31019    /// setters.
31020    ///
31021    /// Please note that this method must not be used to set any of the known parameters
31022    /// which have their own setter method. If done anyway, the request will fail.
31023    ///
31024    /// # Additional Parameters
31025    ///
31026    /// * *alt* (query-string) - Data format for the response.
31027    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31028    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
31029    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31030    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31031    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
31032    /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
31033    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
31034    pub fn param<T>(mut self, name: T, value: T) -> ProjectServiceAccountGetCall<'a, C>
31035    where
31036        T: AsRef<str>,
31037    {
31038        self._additional_params
31039            .insert(name.as_ref().to_string(), value.as_ref().to_string());
31040        self
31041    }
31042
31043    /// Identifies the authorization scope for the method you are building.
31044    ///
31045    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31046    /// [`Scope::CloudPlatform`].
31047    ///
31048    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31049    /// tokens for more than one scope.
31050    ///
31051    /// Usually there is more than one suitable scope to authorize an operation, some of which may
31052    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31053    /// sufficient, a read-write scope will do as well.
31054    pub fn add_scope<St>(mut self, scope: St) -> ProjectServiceAccountGetCall<'a, C>
31055    where
31056        St: AsRef<str>,
31057    {
31058        self._scopes.insert(String::from(scope.as_ref()));
31059        self
31060    }
31061    /// Identifies the authorization scope(s) for the method you are building.
31062    ///
31063    /// See [`Self::add_scope()`] for details.
31064    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectServiceAccountGetCall<'a, C>
31065    where
31066        I: IntoIterator<Item = St>,
31067        St: AsRef<str>,
31068    {
31069        self._scopes
31070            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31071        self
31072    }
31073
31074    /// Removes all scopes, and no default scope will be used either.
31075    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31076    /// for details).
31077    pub fn clear_scopes(mut self) -> ProjectServiceAccountGetCall<'a, C> {
31078        self._scopes.clear();
31079        self
31080    }
31081}