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::{Result, Error};
70/// # async fn dox() {
71/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
72///
73/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
74/// // `client_secret`, among other things.
75/// let secret: yup_oauth2::ApplicationSecret = Default::default();
76/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
77/// // unless you replace `None` with the desired Flow.
78/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
79/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
80/// // retrieve them from storage.
81/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
82/// .with_native_roots()
83/// .unwrap()
84/// .https_only()
85/// .enable_http2()
86/// .build();
87///
88/// let executor = hyper_util::rt::TokioExecutor::new();
89/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
90/// secret,
91/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
92/// yup_oauth2::client::CustomHyperClientBuilder::from(
93/// hyper_util::client::legacy::Client::builder(executor).build(connector),
94/// ),
95/// ).build().await.unwrap();
96///
97/// let client = hyper_util::client::legacy::Client::builder(
98/// hyper_util::rt::TokioExecutor::new()
99/// )
100/// .build(
101/// hyper_rustls::HttpsConnectorBuilder::new()
102/// .with_native_roots()
103/// .unwrap()
104/// .https_or_http()
105/// .enable_http2()
106/// .build()
107/// );
108/// let mut hub = Storage::new(client, auth);
109/// // You can configure optional parameters by calling the respective setters at will, and
110/// // execute the final call using `doit()`.
111/// // Values shown here are possibly random and not representative !
112/// let result = hub.buckets().list("project")
113/// .user_project("duo")
114/// .soft_deleted(true)
115/// .return_partial_success(false)
116/// .projection("ut")
117/// .prefix("gubergren")
118/// .page_token("rebum.")
119/// .max_results(44)
120/// .doit().await;
121///
122/// match result {
123/// Err(e) => match e {
124/// // The Error enum provides details about what exactly happened.
125/// // You can also just use its `Debug`, `Display` or `Error` traits
126/// Error::HttpError(_)
127/// |Error::Io(_)
128/// |Error::MissingAPIKey
129/// |Error::MissingToken(_)
130/// |Error::Cancelled
131/// |Error::UploadSizeLimitExceeded(_, _)
132/// |Error::Failure(_)
133/// |Error::BadRequest(_)
134/// |Error::FieldClash(_)
135/// |Error::JsonDecodeError(_, _) => println!("{}", e),
136/// },
137/// Ok(res) => println!("Success: {:?}", res),
138/// }
139/// # }
140/// ```
141#[derive(Clone)]
142pub struct Storage<C> {
143 pub client: common::Client<C>,
144 pub auth: Box<dyn common::GetToken>,
145 _user_agent: String,
146 _base_url: String,
147 _root_url: String,
148}
149
150impl<C> common::Hub for Storage<C> {}
151
152impl<'a, C> Storage<C> {
153 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Storage<C> {
154 Storage {
155 client,
156 auth: Box::new(auth),
157 _user_agent: "google-api-rust-client/7.0.0".to_string(),
158 _base_url: "https://storage.googleapis.com/storage/v1/".to_string(),
159 _root_url: "https://storage.googleapis.com/".to_string(),
160 }
161 }
162
163 pub fn anywhere_caches(&'a self) -> AnywhereCachMethods<'a, C> {
164 AnywhereCachMethods { hub: self }
165 }
166 pub fn bucket_access_controls(&'a self) -> BucketAccessControlMethods<'a, C> {
167 BucketAccessControlMethods { hub: self }
168 }
169 pub fn buckets(&'a self) -> BucketMethods<'a, C> {
170 BucketMethods { hub: self }
171 }
172 pub fn channels(&'a self) -> ChannelMethods<'a, C> {
173 ChannelMethods { hub: self }
174 }
175 pub fn default_object_access_controls(&'a self) -> DefaultObjectAccessControlMethods<'a, C> {
176 DefaultObjectAccessControlMethods { hub: self }
177 }
178 pub fn folders(&'a self) -> FolderMethods<'a, C> {
179 FolderMethods { hub: self }
180 }
181 pub fn managed_folders(&'a self) -> ManagedFolderMethods<'a, C> {
182 ManagedFolderMethods { hub: self }
183 }
184 pub fn notifications(&'a self) -> NotificationMethods<'a, C> {
185 NotificationMethods { hub: self }
186 }
187 pub fn object_access_controls(&'a self) -> ObjectAccessControlMethods<'a, C> {
188 ObjectAccessControlMethods { hub: self }
189 }
190 pub fn objects(&'a self) -> ObjectMethods<'a, C> {
191 ObjectMethods { hub: self }
192 }
193 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
194 ProjectMethods { hub: self }
195 }
196
197 /// Set the user-agent header field to use in all requests to the server.
198 /// It defaults to `google-api-rust-client/7.0.0`.
199 ///
200 /// Returns the previously set user-agent.
201 pub fn user_agent(&mut self, agent_name: String) -> String {
202 std::mem::replace(&mut self._user_agent, agent_name)
203 }
204
205 /// Set the base url to use in all requests to the server.
206 /// It defaults to `https://storage.googleapis.com/storage/v1/`.
207 ///
208 /// Returns the previously set base url.
209 pub fn base_url(&mut self, new_base_url: String) -> String {
210 std::mem::replace(&mut self._base_url, new_base_url)
211 }
212
213 /// Set the root url to use in all requests to the server.
214 /// It defaults to `https://storage.googleapis.com/`.
215 ///
216 /// Returns the previously set root url.
217 pub fn root_url(&mut self, new_root_url: String) -> String {
218 std::mem::replace(&mut self._root_url, new_root_url)
219 }
220}
221
222// ############
223// SCHEMAS ###
224// ##########
225/// An AdvanceRelocateBucketOperation request.
226///
227/// # Activities
228///
229/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
230/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
231///
232/// * [operations advance relocate bucket buckets](BucketOperationAdvanceRelocateBucketCall) (request)
233#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
234#[serde_with::serde_as]
235#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
236pub struct AdvanceRelocateBucketOperationRequest {
237 /// Specifies the time when the relocation will revert to the sync stage if the relocation hasn't succeeded.
238 #[serde(rename = "expireTime")]
239 pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
240 /// Specifies the duration after which the relocation will revert to the sync stage if the relocation hasn't succeeded. Optional, if not supplied, a default value of 12h will be used.
241 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
242 pub ttl: Option<chrono::Duration>,
243}
244
245impl common::RequestValue for AdvanceRelocateBucketOperationRequest {}
246
247/// An Anywhere Cache instance.
248///
249/// # Activities
250///
251/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
252/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
253///
254/// * [disable anywhere caches](AnywhereCachDisableCall) (response)
255/// * [get anywhere caches](AnywhereCachGetCall) (response)
256/// * [insert anywhere caches](AnywhereCachInsertCall) (request)
257/// * [list anywhere caches](AnywhereCachListCall) (none)
258/// * [pause anywhere caches](AnywhereCachPauseCall) (response)
259/// * [resume anywhere caches](AnywhereCachResumeCall) (response)
260/// * [update anywhere caches](AnywhereCachUpdateCall) (request)
261#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
262#[serde_with::serde_as]
263#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
264pub struct AnywhereCache {
265 /// The cache-level entry admission policy.
266 #[serde(rename = "admissionPolicy")]
267 pub admission_policy: Option<String>,
268 /// The ID of the Anywhere cache instance.
269 #[serde(rename = "anywhereCacheId")]
270 pub anywhere_cache_id: Option<String>,
271 /// The name of the bucket containing this cache instance.
272 pub bucket: Option<String>,
273 /// The creation time of the cache instance in RFC 3339 format.
274 #[serde(rename = "createTime")]
275 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
276 /// The ID of the resource, including the project number, bucket name and anywhere cache ID.
277 pub id: Option<String>,
278 /// The kind of item this is. For Anywhere Cache, this is always storage#anywhereCache.
279 pub kind: Option<String>,
280 /// True if the cache instance has an active Update long-running operation.
281 #[serde(rename = "pendingUpdate")]
282 pub pending_update: Option<bool>,
283 /// The link to this cache instance.
284 #[serde(rename = "selfLink")]
285 pub self_link: Option<String>,
286 /// The current state of the cache instance.
287 pub state: Option<String>,
288 /// The TTL of all cache entries in whole seconds. e.g., "7200s".
289 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
290 pub ttl: Option<chrono::Duration>,
291 /// The modification time of the cache instance metadata in RFC 3339 format.
292 #[serde(rename = "updateTime")]
293 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
294 /// The zone in which the cache instance is running. For example, us-central1-a.
295 pub zone: Option<String>,
296}
297
298impl common::RequestValue for AnywhereCache {}
299impl common::Resource for AnywhereCache {}
300impl common::ResponseResult for AnywhereCache {}
301
302/// A list of Anywhere Caches.
303///
304/// # Activities
305///
306/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
307/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
308///
309/// * [list anywhere caches](AnywhereCachListCall) (response)
310#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
311#[serde_with::serde_as]
312#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
313pub struct AnywhereCaches {
314 /// The list of items.
315 pub items: Option<Vec<AnywhereCache>>,
316 /// The kind of item this is. For lists of Anywhere Caches, this is always storage#anywhereCaches.
317 pub kind: Option<String>,
318 /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results.
319 #[serde(rename = "nextPageToken")]
320 pub next_page_token: Option<String>,
321}
322
323impl common::ResponseResult for AnywhereCaches {}
324
325/// A bucket.
326///
327/// # Activities
328///
329/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
330/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
331///
332/// * [delete buckets](BucketDeleteCall) (none)
333/// * [get buckets](BucketGetCall) (response)
334/// * [get iam policy buckets](BucketGetIamPolicyCall) (none)
335/// * [get storage layout buckets](BucketGetStorageLayoutCall) (none)
336/// * [insert buckets](BucketInsertCall) (request|response)
337/// * [list buckets](BucketListCall) (none)
338/// * [lock retention policy buckets](BucketLockRetentionPolicyCall) (response)
339/// * [patch buckets](BucketPatchCall) (request|response)
340/// * [relocate buckets](BucketRelocateCall) (none)
341/// * [restore buckets](BucketRestoreCall) (response)
342/// * [set iam policy buckets](BucketSetIamPolicyCall) (none)
343/// * [test iam permissions buckets](BucketTestIamPermissionCall) (none)
344/// * [update buckets](BucketUpdateCall) (request|response)
345/// * [operations advance relocate bucket buckets](BucketOperationAdvanceRelocateBucketCall) (none)
346/// * [operations cancel buckets](BucketOperationCancelCall) (none)
347/// * [operations get buckets](BucketOperationGetCall) (none)
348/// * [operations list buckets](BucketOperationListCall) (none)
349#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
350#[serde_with::serde_as]
351#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
352pub struct Bucket {
353 /// Access controls on the bucket.
354 pub acl: Option<Vec<BucketAccessControl>>,
355 /// The bucket's Autoclass configuration.
356 pub autoclass: Option<BucketAutoclass>,
357 /// The bucket's billing configuration.
358 pub billing: Option<BucketBilling>,
359 /// The bucket's Cross-Origin Resource Sharing (CORS) configuration.
360 pub cors: Option<Vec<BucketCors>>,
361 /// The bucket's custom placement configuration for Custom Dual Regions.
362 #[serde(rename = "customPlacementConfig")]
363 pub custom_placement_config: Option<BucketCustomPlacementConfig>,
364 /// 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.
365 #[serde(rename = "defaultEventBasedHold")]
366 pub default_event_based_hold: Option<bool>,
367 /// Default access controls to apply to new objects when no ACL is provided.
368 #[serde(rename = "defaultObjectAcl")]
369 pub default_object_acl: Option<Vec<ObjectAccessControl>>,
370 /// Encryption configuration for a bucket.
371 pub encryption: Option<BucketEncryption>,
372 /// HTTP 1.1 Entity tag for the bucket.
373 pub etag: Option<String>,
374 /// The generation of this bucket.
375 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
376 pub generation: Option<i64>,
377 /// The hard delete time of the bucket in RFC 3339 format.
378 #[serde(rename = "hardDeleteTime")]
379 pub hard_delete_time: Option<chrono::DateTime<chrono::offset::Utc>>,
380 /// The bucket's hierarchical namespace configuration.
381 #[serde(rename = "hierarchicalNamespace")]
382 pub hierarchical_namespace: Option<BucketHierarchicalNamespace>,
383 /// The bucket's IAM configuration.
384 #[serde(rename = "iamConfiguration")]
385 pub iam_configuration: Option<BucketIamConfiguration>,
386 /// The ID of the bucket. For buckets, the id and name properties are the same.
387 pub id: Option<String>,
388 /// The bucket's IP filter configuration. Specifies the network sources that are allowed to access the operations on the bucket, as well as its underlying objects. Only enforced when the mode is set to 'Enabled'.
389 #[serde(rename = "ipFilter")]
390 pub ip_filter: Option<BucketIpFilter>,
391 /// The kind of item this is. For buckets, this is always storage#bucket.
392 pub kind: Option<String>,
393 /// User-provided labels, in key/value pairs.
394 pub labels: Option<HashMap<String, String>>,
395 /// The bucket's lifecycle configuration. See [Lifecycle Management](https://cloud.google.com/storage/docs/lifecycle) for more information.
396 pub lifecycle: Option<BucketLifecycle>,
397 /// 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](https://cloud.google.com/storage/docs/locations) for the authoritative list.
398 pub location: Option<String>,
399 /// The type of the bucket location.
400 #[serde(rename = "locationType")]
401 pub location_type: Option<String>,
402 /// The bucket's logging configuration, which defines the destination bucket and optional name prefix for the current bucket's logs.
403 pub logging: Option<BucketLogging>,
404 /// The metadata generation of this bucket.
405 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
406 pub metageneration: Option<i64>,
407 /// The name of the bucket.
408 pub name: Option<String>,
409 /// The bucket's object retention config.
410 #[serde(rename = "objectRetention")]
411 pub object_retention: Option<BucketObjectRetention>,
412 /// The owner of the bucket. This is always the project team's owner group.
413 pub owner: Option<BucketOwner>,
414 /// The project number of the project the bucket belongs to.
415 #[serde(rename = "projectNumber")]
416 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
417 pub project_number: Option<u64>,
418 /// 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.
419 #[serde(rename = "retentionPolicy")]
420 pub retention_policy: Option<BucketRetentionPolicy>,
421 /// The Recovery Point Objective (RPO) of this bucket. Set to ASYNC_TURBO to turn on Turbo Replication on a bucket.
422 pub rpo: Option<String>,
423 /// Reserved for future use.
424 #[serde(rename = "satisfiesPZI")]
425 pub satisfies_pzi: Option<bool>,
426 /// Reserved for future use.
427 #[serde(rename = "satisfiesPZS")]
428 pub satisfies_pzs: Option<bool>,
429 /// The URI of this bucket.
430 #[serde(rename = "selfLink")]
431 pub self_link: Option<String>,
432 /// The bucket's soft delete policy, which defines the period of time that soft-deleted objects will be retained, and cannot be permanently deleted.
433 #[serde(rename = "softDeletePolicy")]
434 pub soft_delete_policy: Option<BucketSoftDeletePolicy>,
435 /// The soft delete time of the bucket in RFC 3339 format.
436 #[serde(rename = "softDeleteTime")]
437 pub soft_delete_time: Option<chrono::DateTime<chrono::offset::Utc>>,
438 /// 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](https://cloud.google.com/storage/docs/storage-classes).
439 #[serde(rename = "storageClass")]
440 pub storage_class: Option<String>,
441 /// The creation time of the bucket in RFC 3339 format.
442 #[serde(rename = "timeCreated")]
443 pub time_created: Option<chrono::DateTime<chrono::offset::Utc>>,
444 /// The modification time of the bucket in RFC 3339 format.
445 pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
446 /// The bucket's versioning configuration.
447 pub versioning: Option<BucketVersioning>,
448 /// The bucket's website configuration, controlling how the service behaves when accessing bucket contents as a web site. See the [Static Website Examples](https://cloud.google.com/storage/docs/static-website) for more information.
449 pub website: Option<BucketWebsite>,
450}
451
452impl common::RequestValue for Bucket {}
453impl common::Resource for Bucket {}
454impl common::ResponseResult for Bucket {}
455
456/// An access-control entry.
457///
458/// # Activities
459///
460/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
461/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
462///
463/// * [delete bucket access controls](BucketAccessControlDeleteCall) (none)
464/// * [get bucket access controls](BucketAccessControlGetCall) (response)
465/// * [insert bucket access controls](BucketAccessControlInsertCall) (request|response)
466/// * [list bucket access controls](BucketAccessControlListCall) (none)
467/// * [patch bucket access controls](BucketAccessControlPatchCall) (request|response)
468/// * [update bucket access controls](BucketAccessControlUpdateCall) (request|response)
469#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
470#[serde_with::serde_as]
471#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
472pub struct BucketAccessControl {
473 /// The name of the bucket.
474 pub bucket: Option<String>,
475 /// The domain associated with the entity, if any.
476 pub domain: Option<String>,
477 /// The email address associated with the entity, if any.
478 pub email: Option<String>,
479 /// The entity holding the permission, in one of the following forms:
480 /// - user-userId
481 /// - user-email
482 /// - group-groupId
483 /// - group-email
484 /// - domain-domain
485 /// - project-team-projectId
486 /// - allUsers
487 /// - allAuthenticatedUsers Examples:
488 /// - The user liz@example.com would be user-liz@example.com.
489 /// - The group example@googlegroups.com would be group-example@googlegroups.com.
490 /// - To refer to all members of the Google Apps for Business domain example.com, the entity would be domain-example.com.
491 pub entity: Option<String>,
492 /// The ID for the entity, if any.
493 #[serde(rename = "entityId")]
494 pub entity_id: Option<String>,
495 /// HTTP 1.1 Entity tag for the access-control entry.
496 pub etag: Option<String>,
497 /// The ID of the access-control entry.
498 pub id: Option<String>,
499 /// The kind of item this is. For bucket access control entries, this is always storage#bucketAccessControl.
500 pub kind: Option<String>,
501 /// The project team associated with the entity, if any.
502 #[serde(rename = "projectTeam")]
503 pub project_team: Option<BucketAccessControlProjectTeam>,
504 /// The access permission for the entity.
505 pub role: Option<String>,
506 /// The link to this access-control entry.
507 #[serde(rename = "selfLink")]
508 pub self_link: Option<String>,
509}
510
511impl common::RequestValue for BucketAccessControl {}
512impl common::Resource for BucketAccessControl {}
513impl common::ResponseResult for BucketAccessControl {}
514
515/// An access-control list.
516///
517/// # Activities
518///
519/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
520/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
521///
522/// * [list bucket access controls](BucketAccessControlListCall) (response)
523#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
524#[serde_with::serde_as]
525#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
526pub struct BucketAccessControls {
527 /// The list of items.
528 pub items: Option<Vec<BucketAccessControl>>,
529 /// The kind of item this is. For lists of bucket access control entries, this is always storage#bucketAccessControls.
530 pub kind: Option<String>,
531}
532
533impl common::ResponseResult for BucketAccessControls {}
534
535/// The storage layout configuration of a bucket.
536///
537/// # Activities
538///
539/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
540/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
541///
542/// * [get storage layout buckets](BucketGetStorageLayoutCall) (response)
543#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
544#[serde_with::serde_as]
545#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
546pub struct BucketStorageLayout {
547 /// The name of the bucket.
548 pub bucket: Option<String>,
549 /// The bucket's custom placement configuration for Custom Dual Regions.
550 #[serde(rename = "customPlacementConfig")]
551 pub custom_placement_config: Option<BucketStorageLayoutCustomPlacementConfig>,
552 /// The bucket's hierarchical namespace configuration.
553 #[serde(rename = "hierarchicalNamespace")]
554 pub hierarchical_namespace: Option<BucketStorageLayoutHierarchicalNamespace>,
555 /// The kind of item this is. For storage layout, this is always storage#storageLayout.
556 pub kind: Option<String>,
557 /// The location of the bucket.
558 pub location: Option<String>,
559 /// The type of the bucket location.
560 #[serde(rename = "locationType")]
561 pub location_type: Option<String>,
562}
563
564impl common::ResponseResult for BucketStorageLayout {}
565
566/// A list of buckets.
567///
568/// # Activities
569///
570/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
571/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
572///
573/// * [list buckets](BucketListCall) (response)
574#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
575#[serde_with::serde_as]
576#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
577pub struct Buckets {
578 /// The list of items.
579 pub items: Option<Vec<Bucket>>,
580 /// The kind of item this is. For lists of buckets, this is always storage#buckets.
581 pub kind: Option<String>,
582 /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results.
583 #[serde(rename = "nextPageToken")]
584 pub next_page_token: Option<String>,
585 /// The list of bucket resource names that could not be reached during the listing operation.
586 pub unreachable: Option<Vec<String>>,
587}
588
589impl common::ResponseResult for Buckets {}
590
591/// A bulk restore objects request.
592///
593/// # Activities
594///
595/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
596/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
597///
598/// * [bulk restore objects](ObjectBulkRestoreCall) (request)
599#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
600#[serde_with::serde_as]
601#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
602pub struct BulkRestoreObjectsRequest {
603 /// 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.
604 #[serde(rename = "allowOverwrite")]
605 pub allow_overwrite: Option<bool>,
606 /// If true, copies the source object's ACL; otherwise, uses the bucket's default object ACL. The default is false.
607 #[serde(rename = "copySourceAcl")]
608 pub copy_source_acl: Option<bool>,
609 /// Restores only the objects that were created after this time.
610 #[serde(rename = "createdAfterTime")]
611 pub created_after_time: Option<chrono::DateTime<chrono::offset::Utc>>,
612 /// Restores only the objects that were created before this time.
613 #[serde(rename = "createdBeforeTime")]
614 pub created_before_time: Option<chrono::DateTime<chrono::offset::Utc>>,
615 /// 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.
616 #[serde(rename = "matchGlobs")]
617 pub match_globs: Option<Vec<String>>,
618 /// Restores only the objects that were soft-deleted after this time.
619 #[serde(rename = "softDeletedAfterTime")]
620 pub soft_deleted_after_time: Option<chrono::DateTime<chrono::offset::Utc>>,
621 /// Restores only the objects that were soft-deleted before this time.
622 #[serde(rename = "softDeletedBeforeTime")]
623 pub soft_deleted_before_time: Option<chrono::DateTime<chrono::offset::Utc>>,
624}
625
626impl common::RequestValue for BulkRestoreObjectsRequest {}
627
628/// An notification channel used to watch for resource changes.
629///
630/// # Activities
631///
632/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
633/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
634///
635/// * [stop channels](ChannelStopCall) (request)
636/// * [watch all objects](ObjectWatchAllCall) (request|response)
637#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
638#[serde_with::serde_as]
639#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
640pub struct Channel {
641 /// The address where notifications are delivered for this channel.
642 pub address: Option<String>,
643 /// Date and time of notification channel expiration, expressed as a Unix timestamp, in milliseconds. Optional.
644 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
645 pub expiration: Option<i64>,
646 /// A UUID or similar unique string that identifies this channel.
647 pub id: Option<String>,
648 /// Identifies this as a notification channel used to watch for changes to a resource, which is "api#channel".
649 pub kind: Option<String>,
650 /// Additional parameters controlling delivery channel behavior. Optional.
651 pub params: Option<HashMap<String, String>>,
652 /// A Boolean value to indicate whether payload is wanted. Optional.
653 pub payload: Option<bool>,
654 /// An opaque ID that identifies the resource being watched on this channel. Stable across different API versions.
655 #[serde(rename = "resourceId")]
656 pub resource_id: Option<String>,
657 /// A version-specific identifier for the watched resource.
658 #[serde(rename = "resourceUri")]
659 pub resource_uri: Option<String>,
660 /// An arbitrary string delivered to the target address with each notification delivered over this channel. Optional.
661 pub token: Option<String>,
662 /// The type of delivery mechanism used for this channel.
663 #[serde(rename = "type")]
664 pub type_: Option<String>,
665}
666
667impl common::RequestValue for Channel {}
668impl common::Resource for Channel {}
669impl common::ResponseResult for Channel {}
670
671/// A Compose request.
672///
673/// # Activities
674///
675/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
676/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
677///
678/// * [compose objects](ObjectComposeCall) (request)
679#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
680#[serde_with::serde_as]
681#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
682pub struct ComposeRequest {
683 /// If true, the source objects will be deleted.
684 #[serde(rename = "deleteSourceObjects")]
685 pub delete_source_objects: Option<bool>,
686 /// Properties of the resulting object.
687 pub destination: Option<Object>,
688 /// The kind of item this is.
689 pub kind: Option<String>,
690 /// The list of source objects that will be concatenated into a single object.
691 #[serde(rename = "sourceObjects")]
692 pub source_objects: Option<Vec<ComposeRequestSourceObjects>>,
693}
694
695impl common::RequestValue for ComposeRequest {}
696
697/// Represents an expression text. Example: title: "User account presence" description: "Determines whether the request has a user account" expression: "size(request.user) > 0"
698///
699/// This type is not used in any activity, and only used as *part* of another schema.
700///
701#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
702#[serde_with::serde_as]
703#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
704pub struct Expr {
705 /// An optional description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
706 pub description: Option<String>,
707 /// 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.
708 pub expression: Option<String>,
709 /// An optional string indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
710 pub location: Option<String>,
711 /// 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.
712 pub title: Option<String>,
713}
714
715impl common::Part for Expr {}
716
717/// A folder. Only available in buckets with hierarchical namespace enabled.
718///
719/// # Activities
720///
721/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
722/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
723///
724/// * [delete folders](FolderDeleteCall) (none)
725/// * [get folders](FolderGetCall) (response)
726/// * [insert folders](FolderInsertCall) (request|response)
727/// * [list folders](FolderListCall) (none)
728/// * [rename folders](FolderRenameCall) (none)
729#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
730#[serde_with::serde_as]
731#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
732pub struct Folder {
733 /// The name of the bucket containing this folder.
734 pub bucket: Option<String>,
735 /// The creation time of the folder in RFC 3339 format.
736 #[serde(rename = "createTime")]
737 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
738 /// The ID of the folder, including the bucket name, folder name.
739 pub id: Option<String>,
740 /// The kind of item this is. For folders, this is always storage#folder.
741 pub kind: Option<String>,
742 /// The version of the metadata for this folder. Used for preconditions and for detecting changes in metadata.
743 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
744 pub metageneration: Option<i64>,
745 /// The name of the folder. Required if not specified by URL parameter.
746 pub name: Option<String>,
747 /// Only present if the folder is part of an ongoing rename folder operation. Contains information which can be used to query the operation status.
748 #[serde(rename = "pendingRenameInfo")]
749 pub pending_rename_info: Option<FolderPendingRenameInfo>,
750 /// The link to this folder.
751 #[serde(rename = "selfLink")]
752 pub self_link: Option<String>,
753 /// The modification time of the folder metadata in RFC 3339 format.
754 #[serde(rename = "updateTime")]
755 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
756}
757
758impl common::RequestValue for Folder {}
759impl common::Resource for Folder {}
760impl common::ResponseResult for Folder {}
761
762/// A list of folders.
763///
764/// # Activities
765///
766/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
767/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
768///
769/// * [list folders](FolderListCall) (response)
770#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
771#[serde_with::serde_as]
772#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
773pub struct Folders {
774 /// The list of items.
775 pub items: Option<Vec<Folder>>,
776 /// The kind of item this is. For lists of folders, this is always storage#folders.
777 pub kind: Option<String>,
778 /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results.
779 #[serde(rename = "nextPageToken")]
780 pub next_page_token: Option<String>,
781}
782
783impl common::ResponseResult for Folders {}
784
785/// The response message for storage.buckets.operations.list.
786///
787/// # Activities
788///
789/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
790/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
791///
792/// * [operations list buckets](BucketOperationListCall) (response)
793#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
794#[serde_with::serde_as]
795#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
796pub struct GoogleLongrunningListOperationsResponse {
797 /// The kind of item this is. For lists of operations, this is always storage#operations.
798 pub kind: Option<String>,
799 /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results.
800 #[serde(rename = "nextPageToken")]
801 pub next_page_token: Option<String>,
802 /// A list of operations that matches the specified filter in the request.
803 pub operations: Option<Vec<GoogleLongrunningOperation>>,
804}
805
806impl common::ResponseResult for GoogleLongrunningListOperationsResponse {}
807
808/// This resource represents a long-running operation that is the result of a network API call.
809///
810/// # Activities
811///
812/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
813/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
814///
815/// * [insert anywhere caches](AnywhereCachInsertCall) (response)
816/// * [update anywhere caches](AnywhereCachUpdateCall) (response)
817/// * [relocate buckets](BucketRelocateCall) (response)
818/// * [rename folders](FolderRenameCall) (response)
819/// * [bulk restore objects](ObjectBulkRestoreCall) (response)
820/// * [operations get buckets](BucketOperationGetCall) (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 GoogleLongrunningOperation {
825 /// 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.
826 pub done: Option<bool>,
827 /// The error result of the operation in case of failure or cancellation.
828 pub error: Option<GoogleRpcStatus>,
829 /// The kind of item this is. For operations, this is always storage#operation.
830 pub kind: Option<String>,
831 /// 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.
832 pub metadata: Option<HashMap<String, serde_json::Value>>,
833 /// 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}".
834 pub name: Option<String>,
835 /// 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".
836 pub response: Option<HashMap<String, serde_json::Value>>,
837 /// The link to this long running operation.
838 #[serde(rename = "selfLink")]
839 pub self_link: Option<String>,
840}
841
842impl common::ResponseResult for GoogleLongrunningOperation {}
843
844/// 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).
845///
846/// This type is not used in any activity, and only used as *part* of another schema.
847///
848#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
849#[serde_with::serde_as]
850#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
851pub struct GoogleRpcStatus {
852 /// The status code, which should be an enum value of google.rpc.Code.
853 pub code: Option<i32>,
854 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
855 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
856 /// A developer-facing error message, which should be in English.
857 pub message: Option<String>,
858}
859
860impl common::Part for GoogleRpcStatus {}
861
862/// JSON template to produce a JSON-style HMAC Key resource for Create responses.
863///
864/// # Activities
865///
866/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
867/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
868///
869/// * [hmac keys create projects](ProjectHmacKeyCreateCall) (response)
870#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
871#[serde_with::serde_as]
872#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
873pub struct HmacKey {
874 /// The kind of item this is. For HMAC keys, this is always storage#hmacKey.
875 pub kind: Option<String>,
876 /// Key metadata.
877 pub metadata: Option<HmacKeyMetadata>,
878 /// HMAC secret key material.
879 pub secret: Option<String>,
880}
881
882impl common::ResponseResult for HmacKey {}
883
884/// JSON template to produce a JSON-style HMAC Key metadata resource.
885///
886/// # Activities
887///
888/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
889/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
890///
891/// * [hmac keys get projects](ProjectHmacKeyGetCall) (response)
892/// * [hmac keys update projects](ProjectHmacKeyUpdateCall) (request|response)
893#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
894#[serde_with::serde_as]
895#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
896pub struct HmacKeyMetadata {
897 /// The ID of the HMAC Key.
898 #[serde(rename = "accessId")]
899 pub access_id: Option<String>,
900 /// HTTP 1.1 Entity tag for the HMAC key.
901 pub etag: Option<String>,
902 /// The ID of the HMAC key, including the Project ID and the Access ID.
903 pub id: Option<String>,
904 /// The kind of item this is. For HMAC Key metadata, this is always storage#hmacKeyMetadata.
905 pub kind: Option<String>,
906 /// Project ID owning the service account to which the key authenticates.
907 #[serde(rename = "projectId")]
908 pub project_id: Option<String>,
909 /// The link to this resource.
910 #[serde(rename = "selfLink")]
911 pub self_link: Option<String>,
912 /// The email address of the key's associated service account.
913 #[serde(rename = "serviceAccountEmail")]
914 pub service_account_email: Option<String>,
915 /// The state of the key. Can be one of ACTIVE, INACTIVE, or DELETED.
916 pub state: Option<String>,
917 /// The creation time of the HMAC key in RFC 3339 format.
918 #[serde(rename = "timeCreated")]
919 pub time_created: Option<chrono::DateTime<chrono::offset::Utc>>,
920 /// The last modification time of the HMAC key metadata in RFC 3339 format.
921 pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
922}
923
924impl common::RequestValue for HmacKeyMetadata {}
925impl common::ResponseResult for HmacKeyMetadata {}
926
927/// A list of hmacKeys.
928///
929/// # Activities
930///
931/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
932/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
933///
934/// * [hmac keys list projects](ProjectHmacKeyListCall) (response)
935#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
936#[serde_with::serde_as]
937#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
938pub struct HmacKeysMetadata {
939 /// The list of items.
940 pub items: Option<Vec<HmacKeyMetadata>>,
941 /// The kind of item this is. For lists of hmacKeys, this is always storage#hmacKeysMetadata.
942 pub kind: Option<String>,
943 /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results.
944 #[serde(rename = "nextPageToken")]
945 pub next_page_token: Option<String>,
946}
947
948impl common::ResponseResult for HmacKeysMetadata {}
949
950/// A managed folder.
951///
952/// # Activities
953///
954/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
955/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
956///
957/// * [delete managed folders](ManagedFolderDeleteCall) (none)
958/// * [get managed folders](ManagedFolderGetCall) (response)
959/// * [get iam policy managed folders](ManagedFolderGetIamPolicyCall) (none)
960/// * [insert managed folders](ManagedFolderInsertCall) (request|response)
961/// * [list managed folders](ManagedFolderListCall) (none)
962/// * [set iam policy managed folders](ManagedFolderSetIamPolicyCall) (none)
963/// * [test iam permissions managed folders](ManagedFolderTestIamPermissionCall) (none)
964#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
965#[serde_with::serde_as]
966#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
967pub struct ManagedFolder {
968 /// The name of the bucket containing this managed folder.
969 pub bucket: Option<String>,
970 /// The creation time of the managed folder in RFC 3339 format.
971 #[serde(rename = "createTime")]
972 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
973 /// The ID of the managed folder, including the bucket name and managed folder name.
974 pub id: Option<String>,
975 /// The kind of item this is. For managed folders, this is always storage#managedFolder.
976 pub kind: Option<String>,
977 /// The version of the metadata for this managed folder. Used for preconditions and for detecting changes in metadata.
978 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
979 pub metageneration: Option<i64>,
980 /// The name of the managed folder. Required if not specified by URL parameter.
981 pub name: Option<String>,
982 /// The link to this managed folder.
983 #[serde(rename = "selfLink")]
984 pub self_link: Option<String>,
985 /// The last update time of the managed folder metadata in RFC 3339 format.
986 #[serde(rename = "updateTime")]
987 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
988}
989
990impl common::RequestValue for ManagedFolder {}
991impl common::Resource for ManagedFolder {}
992impl common::ResponseResult for ManagedFolder {}
993
994/// A list of managed folders.
995///
996/// # Activities
997///
998/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
999/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1000///
1001/// * [list managed folders](ManagedFolderListCall) (response)
1002#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1003#[serde_with::serde_as]
1004#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1005pub struct ManagedFolders {
1006 /// The list of items.
1007 pub items: Option<Vec<ManagedFolder>>,
1008 /// The kind of item this is. For lists of managed folders, this is always storage#managedFolders.
1009 pub kind: Option<String>,
1010 /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results.
1011 #[serde(rename = "nextPageToken")]
1012 pub next_page_token: Option<String>,
1013}
1014
1015impl common::ResponseResult for ManagedFolders {}
1016
1017/// A subscription to receive Google PubSub notifications.
1018///
1019/// # Activities
1020///
1021/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1022/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1023///
1024/// * [delete notifications](NotificationDeleteCall) (none)
1025/// * [get notifications](NotificationGetCall) (response)
1026/// * [insert notifications](NotificationInsertCall) (request|response)
1027/// * [list notifications](NotificationListCall) (none)
1028#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1029#[serde_with::serde_as]
1030#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1031pub struct Notification {
1032 /// An optional list of additional attributes to attach to each Cloud PubSub message published for this notification subscription.
1033 pub custom_attributes: Option<HashMap<String, String>>,
1034 /// HTTP 1.1 Entity tag for this subscription notification.
1035 pub etag: Option<String>,
1036 /// If present, only send notifications about listed event types. If empty, sent notifications for all event types.
1037 pub event_types: Option<Vec<String>>,
1038 /// The ID of the notification.
1039 pub id: Option<String>,
1040 /// The kind of item this is. For notifications, this is always storage#notification.
1041 pub kind: Option<String>,
1042 /// If present, only apply this notification configuration to object names that begin with this prefix.
1043 pub object_name_prefix: Option<String>,
1044 /// The desired content of the Payload.
1045 pub payload_format: Option<String>,
1046 /// The canonical URL of this notification.
1047 #[serde(rename = "selfLink")]
1048 pub self_link: Option<String>,
1049 /// The Cloud PubSub topic to which this subscription publishes. Formatted as: '//pubsub.googleapis.com/projects/{project-identifier}/topics/{my-topic}'
1050 pub topic: Option<String>,
1051}
1052
1053impl common::RequestValue for Notification {}
1054impl common::Resource for Notification {}
1055impl common::ResponseResult for Notification {}
1056
1057/// A list of notification subscriptions.
1058///
1059/// # Activities
1060///
1061/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1062/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1063///
1064/// * [list notifications](NotificationListCall) (response)
1065#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1066#[serde_with::serde_as]
1067#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1068pub struct Notifications {
1069 /// The list of items.
1070 pub items: Option<Vec<Notification>>,
1071 /// The kind of item this is. For lists of notifications, this is always storage#notifications.
1072 pub kind: Option<String>,
1073}
1074
1075impl common::ResponseResult for Notifications {}
1076
1077/// An object.
1078///
1079/// # Activities
1080///
1081/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1082/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1083///
1084/// * [bulk restore objects](ObjectBulkRestoreCall) (none)
1085/// * [compose objects](ObjectComposeCall) (response)
1086/// * [copy objects](ObjectCopyCall) (request|response)
1087/// * [delete objects](ObjectDeleteCall) (none)
1088/// * [get objects](ObjectGetCall) (response)
1089/// * [get iam policy objects](ObjectGetIamPolicyCall) (none)
1090/// * [insert objects](ObjectInsertCall) (request|response)
1091/// * [list objects](ObjectListCall) (none)
1092/// * [move objects](ObjectMoveCall) (response)
1093/// * [patch objects](ObjectPatchCall) (request|response)
1094/// * [restore objects](ObjectRestoreCall) (response)
1095/// * [rewrite objects](ObjectRewriteCall) (request)
1096/// * [set iam policy objects](ObjectSetIamPolicyCall) (none)
1097/// * [test iam permissions objects](ObjectTestIamPermissionCall) (none)
1098/// * [update objects](ObjectUpdateCall) (request|response)
1099/// * [watch all objects](ObjectWatchAllCall) (none)
1100#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1101#[serde_with::serde_as]
1102#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1103pub struct Object {
1104 /// Access controls on the object.
1105 pub acl: Option<Vec<ObjectAccessControl>>,
1106 /// The name of the bucket containing this object.
1107 pub bucket: Option<String>,
1108 /// 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.
1109 #[serde(rename = "cacheControl")]
1110 pub cache_control: Option<String>,
1111 /// Number of underlying components that make up this object. Components are accumulated by compose operations.
1112 #[serde(rename = "componentCount")]
1113 pub component_count: Option<i32>,
1114 /// Content-Disposition of the object data.
1115 #[serde(rename = "contentDisposition")]
1116 pub content_disposition: Option<String>,
1117 /// Content-Encoding of the object data.
1118 #[serde(rename = "contentEncoding")]
1119 pub content_encoding: Option<String>,
1120 /// Content-Language of the object data.
1121 #[serde(rename = "contentLanguage")]
1122 pub content_language: Option<String>,
1123 /// Content-Type of the object data. If an object is stored without a Content-Type, it is served as application/octet-stream.
1124 #[serde(rename = "contentType")]
1125 pub content_type: Option<String>,
1126 /// User-defined or system-defined object contexts. Each object context is a key-payload pair, where the key provides the identification and the payload holds the associated value and additional metadata.
1127 pub contexts: Option<ObjectContexts>,
1128 /// 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 [Data Validation and Change Detection](https://cloud.google.com/storage/docs/data-validation).
1129 pub crc32c: Option<String>,
1130 /// A timestamp in RFC 3339 format specified by the user for an object.
1131 #[serde(rename = "customTime")]
1132 pub custom_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1133 /// Metadata of customer-supplied encryption key, if the object is encrypted by such a key.
1134 #[serde(rename = "customerEncryption")]
1135 pub customer_encryption: Option<ObjectCustomerEncryption>,
1136 /// HTTP 1.1 Entity tag for the object.
1137 pub etag: Option<String>,
1138 /// 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.
1139 #[serde(rename = "eventBasedHold")]
1140 pub event_based_hold: Option<bool>,
1141 /// The content generation of this object. Used for object versioning.
1142 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1143 pub generation: Option<i64>,
1144 /// 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.
1145 #[serde(rename = "hardDeleteTime")]
1146 pub hard_delete_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1147 /// The ID of the object, including the bucket name, object name, and generation number.
1148 pub id: Option<String>,
1149 /// The kind of item this is. For objects, this is always storage#object.
1150 pub kind: Option<String>,
1151 /// Not currently supported. Specifying the parameter causes the request to fail with status code 400 - Bad Request.
1152 #[serde(rename = "kmsKeyName")]
1153 pub kms_key_name: Option<String>,
1154 /// MD5 hash of the data; encoded using base64. For more information about using the MD5 hash, see [Data Validation and Change Detection](https://cloud.google.com/storage/docs/data-validation).
1155 #[serde(rename = "md5Hash")]
1156 pub md5_hash: Option<String>,
1157 /// Media download link.
1158 #[serde(rename = "mediaLink")]
1159 pub media_link: Option<String>,
1160 /// User-provided metadata, in key/value pairs.
1161 pub metadata: Option<HashMap<String, String>>,
1162 /// 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.
1163 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1164 pub metageneration: Option<i64>,
1165 /// The name of the object. Required if not specified by URL parameter.
1166 pub name: Option<String>,
1167 /// The owner of the object. This will always be the uploader of the object.
1168 pub owner: Option<ObjectOwner>,
1169 /// Restore token used to differentiate deleted objects with the same name and generation. This field is only returned for deleted objects in hierarchical namespace buckets.
1170 #[serde(rename = "restoreToken")]
1171 pub restore_token: Option<String>,
1172 /// A collection of object level retention parameters.
1173 pub retention: Option<ObjectRetention>,
1174 /// 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).
1175 #[serde(rename = "retentionExpirationTime")]
1176 pub retention_expiration_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1177 /// The link to this object.
1178 #[serde(rename = "selfLink")]
1179 pub self_link: Option<String>,
1180 /// Content-Length of the data in bytes.
1181 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1182 pub size: Option<u64>,
1183 /// The time at which the object became soft-deleted in RFC 3339 format.
1184 #[serde(rename = "softDeleteTime")]
1185 pub soft_delete_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1186 /// Storage class of the object.
1187 #[serde(rename = "storageClass")]
1188 pub storage_class: Option<String>,
1189 /// 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.
1190 #[serde(rename = "temporaryHold")]
1191 pub temporary_hold: Option<bool>,
1192 /// The creation time of the object in RFC 3339 format.
1193 #[serde(rename = "timeCreated")]
1194 pub time_created: Option<chrono::DateTime<chrono::offset::Utc>>,
1195 /// 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.
1196 #[serde(rename = "timeDeleted")]
1197 pub time_deleted: Option<chrono::DateTime<chrono::offset::Utc>>,
1198 /// The time when the object was finalized.
1199 #[serde(rename = "timeFinalized")]
1200 pub time_finalized: Option<chrono::DateTime<chrono::offset::Utc>>,
1201 /// The time at which the object's storage class was last changed. When the object is initially created, it will be set to timeCreated.
1202 #[serde(rename = "timeStorageClassUpdated")]
1203 pub time_storage_class_updated: Option<chrono::DateTime<chrono::offset::Utc>>,
1204 /// 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.
1205 pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
1206}
1207
1208impl common::RequestValue for Object {}
1209impl common::Resource for Object {}
1210impl common::ResponseResult for Object {}
1211
1212/// An access-control entry.
1213///
1214/// # Activities
1215///
1216/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1217/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1218///
1219/// * [get default object access controls](DefaultObjectAccessControlGetCall) (response)
1220/// * [insert default object access controls](DefaultObjectAccessControlInsertCall) (request|response)
1221/// * [patch default object access controls](DefaultObjectAccessControlPatchCall) (request|response)
1222/// * [update default object access controls](DefaultObjectAccessControlUpdateCall) (request|response)
1223/// * [delete object access controls](ObjectAccessControlDeleteCall) (none)
1224/// * [get object access controls](ObjectAccessControlGetCall) (response)
1225/// * [insert object access controls](ObjectAccessControlInsertCall) (request|response)
1226/// * [list object access controls](ObjectAccessControlListCall) (none)
1227/// * [patch object access controls](ObjectAccessControlPatchCall) (request|response)
1228/// * [update object access controls](ObjectAccessControlUpdateCall) (request|response)
1229#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1230#[serde_with::serde_as]
1231#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1232pub struct ObjectAccessControl {
1233 /// The name of the bucket.
1234 pub bucket: Option<String>,
1235 /// The domain associated with the entity, if any.
1236 pub domain: Option<String>,
1237 /// The email address associated with the entity, if any.
1238 pub email: Option<String>,
1239 /// The entity holding the permission, in one of the following forms:
1240 /// - user-userId
1241 /// - user-email
1242 /// - group-groupId
1243 /// - group-email
1244 /// - domain-domain
1245 /// - project-team-projectId
1246 /// - allUsers
1247 /// - allAuthenticatedUsers Examples:
1248 /// - The user liz@example.com would be user-liz@example.com.
1249 /// - The group example@googlegroups.com would be group-example@googlegroups.com.
1250 /// - To refer to all members of the Google Apps for Business domain example.com, the entity would be domain-example.com.
1251 pub entity: Option<String>,
1252 /// The ID for the entity, if any.
1253 #[serde(rename = "entityId")]
1254 pub entity_id: Option<String>,
1255 /// HTTP 1.1 Entity tag for the access-control entry.
1256 pub etag: Option<String>,
1257 /// The content generation of the object, if applied to an object.
1258 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1259 pub generation: Option<i64>,
1260 /// The ID of the access-control entry.
1261 pub id: Option<String>,
1262 /// The kind of item this is. For object access control entries, this is always storage#objectAccessControl.
1263 pub kind: Option<String>,
1264 /// The name of the object, if applied to an object.
1265 pub object: Option<String>,
1266 /// The project team associated with the entity, if any.
1267 #[serde(rename = "projectTeam")]
1268 pub project_team: Option<ObjectAccessControlProjectTeam>,
1269 /// The access permission for the entity.
1270 pub role: Option<String>,
1271 /// The link to this access-control entry.
1272 #[serde(rename = "selfLink")]
1273 pub self_link: Option<String>,
1274}
1275
1276impl common::RequestValue for ObjectAccessControl {}
1277impl common::Resource for ObjectAccessControl {}
1278impl common::ResponseResult for ObjectAccessControl {}
1279
1280/// An access-control list.
1281///
1282/// # Activities
1283///
1284/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1285/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1286///
1287/// * [list default object access controls](DefaultObjectAccessControlListCall) (response)
1288/// * [list object access controls](ObjectAccessControlListCall) (response)
1289#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1290#[serde_with::serde_as]
1291#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1292pub struct ObjectAccessControls {
1293 /// The list of items.
1294 pub items: Option<Vec<ObjectAccessControl>>,
1295 /// The kind of item this is. For lists of object access control entries, this is always storage#objectAccessControls.
1296 pub kind: Option<String>,
1297}
1298
1299impl common::ResponseResult for ObjectAccessControls {}
1300
1301/// The payload of a single user-defined object context.
1302///
1303/// This type is not used in any activity, and only used as *part* of another schema.
1304///
1305#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1306#[serde_with::serde_as]
1307#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1308pub struct ObjectCustomContextPayload {
1309 /// The time at which the object context was created in RFC 3339 format.
1310 #[serde(rename = "createTime")]
1311 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1312 /// The time at which the object context was last updated in RFC 3339 format.
1313 #[serde(rename = "updateTime")]
1314 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1315 /// The value of the object context.
1316 pub value: Option<String>,
1317}
1318
1319impl common::Part for ObjectCustomContextPayload {}
1320
1321/// A list of objects.
1322///
1323/// # Activities
1324///
1325/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1326/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1327///
1328/// * [list objects](ObjectListCall) (response)
1329#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1330#[serde_with::serde_as]
1331#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1332pub struct Objects {
1333 /// The list of items.
1334 pub items: Option<Vec<Object>>,
1335 /// The kind of item this is. For lists of objects, this is always storage#objects.
1336 pub kind: Option<String>,
1337 /// The continuation token, used to page through large result sets. Provide this value in a subsequent request to return the next page of results.
1338 #[serde(rename = "nextPageToken")]
1339 pub next_page_token: Option<String>,
1340 /// The list of prefixes of objects matching-but-not-listed up to and including the requested delimiter.
1341 pub prefixes: Option<Vec<String>>,
1342}
1343
1344impl common::ResponseResult for Objects {}
1345
1346/// A bucket/object/managedFolder IAM policy.
1347///
1348/// # Activities
1349///
1350/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1351/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1352///
1353/// * [get iam policy buckets](BucketGetIamPolicyCall) (response)
1354/// * [set iam policy buckets](BucketSetIamPolicyCall) (request|response)
1355/// * [get iam policy managed folders](ManagedFolderGetIamPolicyCall) (response)
1356/// * [set iam policy managed folders](ManagedFolderSetIamPolicyCall) (request|response)
1357/// * [get iam policy objects](ObjectGetIamPolicyCall) (response)
1358/// * [set iam policy objects](ObjectSetIamPolicyCall) (request|response)
1359#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1360#[serde_with::serde_as]
1361#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1362pub struct Policy {
1363 /// An association between a role, which comes with a set of permissions, and members who may assume that role.
1364 pub bindings: Option<Vec<PolicyBindings>>,
1365 /// HTTP 1.1 Entity tag for the policy.
1366 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1367 pub etag: Option<Vec<u8>>,
1368 /// The kind of item this is. For policies, this is always storage#policy. This field is ignored on input.
1369 pub kind: Option<String>,
1370 /// 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.
1371 #[serde(rename = "resourceId")]
1372 pub resource_id: Option<String>,
1373 /// The IAM policy format version.
1374 pub version: Option<i32>,
1375}
1376
1377impl common::RequestValue for Policy {}
1378impl common::ResponseResult for Policy {}
1379
1380/// A Relocate Bucket request.
1381///
1382/// # Activities
1383///
1384/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1385/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1386///
1387/// * [relocate buckets](BucketRelocateCall) (request)
1388#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1389#[serde_with::serde_as]
1390#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1391pub struct RelocateBucketRequest {
1392 /// The bucket's new custom placement configuration if relocating to a Custom Dual Region.
1393 #[serde(rename = "destinationCustomPlacementConfig")]
1394 pub destination_custom_placement_config:
1395 Option<RelocateBucketRequestDestinationCustomPlacementConfig>,
1396 /// The new location the bucket will be relocated to.
1397 #[serde(rename = "destinationLocation")]
1398 pub destination_location: Option<String>,
1399 /// If true, validate the operation, but do not actually relocate the bucket.
1400 #[serde(rename = "validateOnly")]
1401 pub validate_only: Option<bool>,
1402}
1403
1404impl common::RequestValue for RelocateBucketRequest {}
1405
1406/// A rewrite response.
1407///
1408/// # Activities
1409///
1410/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1411/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1412///
1413/// * [rewrite objects](ObjectRewriteCall) (response)
1414#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1415#[serde_with::serde_as]
1416#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1417pub struct RewriteResponse {
1418 /// true if the copy is finished; otherwise, false if the copy is in progress. This property is always present in the response.
1419 pub done: Option<bool>,
1420 /// The kind of item this is.
1421 pub kind: Option<String>,
1422 /// The total size of the object being copied in bytes. This property is always present in the response.
1423 #[serde(rename = "objectSize")]
1424 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1425 pub object_size: Option<i64>,
1426 /// A resource containing the metadata for the copied-to object. This property is present in the response only when copying completes.
1427 pub resource: Option<Object>,
1428 /// 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.
1429 #[serde(rename = "rewriteToken")]
1430 pub rewrite_token: Option<String>,
1431 /// 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.
1432 #[serde(rename = "totalBytesRewritten")]
1433 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1434 pub total_bytes_rewritten: Option<i64>,
1435}
1436
1437impl common::ResponseResult for RewriteResponse {}
1438
1439/// A subscription to receive Google PubSub notifications.
1440///
1441/// # Activities
1442///
1443/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1444/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1445///
1446/// * [service account get projects](ProjectServiceAccountGetCall) (response)
1447#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1448#[serde_with::serde_as]
1449#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1450pub struct ServiceAccount {
1451 /// The ID of the notification.
1452 pub email_address: Option<String>,
1453 /// The kind of item this is. For notifications, this is always storage#notification.
1454 pub kind: Option<String>,
1455}
1456
1457impl common::ResponseResult for ServiceAccount {}
1458
1459/// A storage.(buckets|objects|managedFolders).testIamPermissions response.
1460///
1461/// # Activities
1462///
1463/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1464/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1465///
1466/// * [test iam permissions buckets](BucketTestIamPermissionCall) (response)
1467/// * [test iam permissions managed folders](ManagedFolderTestIamPermissionCall) (response)
1468/// * [test iam permissions objects](ObjectTestIamPermissionCall) (response)
1469#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1470#[serde_with::serde_as]
1471#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1472pub struct TestIamPermissionsResponse {
1473 /// The kind of item this is.
1474 pub kind: Option<String>,
1475 /// 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:
1476 /// - storage.buckets.delete - Delete bucket.
1477 /// - storage.buckets.get - Read bucket metadata.
1478 /// - storage.buckets.getIamPolicy - Read bucket IAM policy.
1479 /// - storage.buckets.create - Create bucket.
1480 /// - storage.buckets.list - List buckets.
1481 /// - storage.buckets.setIamPolicy - Update bucket IAM policy.
1482 /// - storage.buckets.update - Update bucket metadata.
1483 /// - storage.objects.delete - Delete object.
1484 /// - storage.objects.get - Read object data and metadata.
1485 /// - storage.objects.getIamPolicy - Read object IAM policy.
1486 /// - storage.objects.create - Create object.
1487 /// - storage.objects.list - List objects.
1488 /// - storage.objects.setIamPolicy - Update object IAM policy.
1489 /// - storage.objects.update - Update object metadata.
1490 /// - storage.managedFolders.delete - Delete managed folder.
1491 /// - storage.managedFolders.get - Read managed folder metadata.
1492 /// - storage.managedFolders.getIamPolicy - Read managed folder IAM policy.
1493 /// - storage.managedFolders.create - Create managed folder.
1494 /// - storage.managedFolders.list - List managed folders.
1495 /// - storage.managedFolders.setIamPolicy - Update managed folder IAM policy.
1496 pub permissions: Option<Vec<String>>,
1497}
1498
1499impl common::ResponseResult for TestIamPermissionsResponse {}
1500
1501/// The bucket's Autoclass configuration.
1502///
1503/// This type is not used in any activity, and only used as *part* of another schema.
1504///
1505#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1506#[serde_with::serde_as]
1507#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1508pub struct BucketAutoclass {
1509 /// Whether or not Autoclass is enabled on this bucket
1510 pub enabled: Option<bool>,
1511 /// 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.
1512 #[serde(rename = "terminalStorageClass")]
1513 pub terminal_storage_class: Option<String>,
1514 /// A date and time in RFC 3339 format representing the time of the most recent update to "terminalStorageClass".
1515 #[serde(rename = "terminalStorageClassUpdateTime")]
1516 pub terminal_storage_class_update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1517 /// A date and time in RFC 3339 format representing the instant at which "enabled" was last toggled.
1518 #[serde(rename = "toggleTime")]
1519 pub toggle_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1520}
1521
1522impl common::NestedType for BucketAutoclass {}
1523impl common::Part for BucketAutoclass {}
1524
1525/// The bucket's billing configuration.
1526///
1527/// This type is not used in any activity, and only used as *part* of another schema.
1528///
1529#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1530#[serde_with::serde_as]
1531#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1532pub struct BucketBilling {
1533 /// When set to true, Requester Pays is enabled for this bucket.
1534 #[serde(rename = "requesterPays")]
1535 pub requester_pays: Option<bool>,
1536}
1537
1538impl common::NestedType for BucketBilling {}
1539impl common::Part for BucketBilling {}
1540
1541/// The bucket's Cross-Origin Resource Sharing (CORS) configuration.
1542///
1543/// This type is not used in any activity, and only used as *part* of another schema.
1544///
1545#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1546#[serde_with::serde_as]
1547#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1548pub struct BucketCors {
1549 /// The value, in seconds, to return in the Access-Control-Max-Age header used in preflight responses.
1550 #[serde(rename = "maxAgeSeconds")]
1551 pub max_age_seconds: Option<i32>,
1552 /// 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".
1553 pub method: Option<Vec<String>>,
1554 /// The list of Origins eligible to receive CORS response headers. Note: "*" is permitted in the list of origins, and means "any Origin".
1555 pub origin: Option<Vec<String>>,
1556 /// The list of HTTP headers other than the simple response headers to give permission for the user-agent to share across domains.
1557 #[serde(rename = "responseHeader")]
1558 pub response_header: Option<Vec<String>>,
1559}
1560
1561impl common::NestedType for BucketCors {}
1562impl common::Part for BucketCors {}
1563
1564/// The bucket's custom placement configuration for Custom Dual Regions.
1565///
1566/// This type is not used in any activity, and only used as *part* of another schema.
1567///
1568#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1569#[serde_with::serde_as]
1570#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1571pub struct BucketCustomPlacementConfig {
1572 /// The list of regional locations in which data is placed.
1573 #[serde(rename = "dataLocations")]
1574 pub data_locations: Option<Vec<String>>,
1575}
1576
1577impl common::NestedType for BucketCustomPlacementConfig {}
1578impl common::Part for BucketCustomPlacementConfig {}
1579
1580/// Encryption configuration for a bucket.
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 BucketEncryption {
1588 /// If set, the new objects created in this bucket must comply with this enforcement config. Changing this has no effect on existing objects; it applies to new objects only. If omitted, the new objects are allowed to be encrypted with Customer Managed Encryption type by default.
1589 #[serde(rename = "customerManagedEncryptionEnforcementConfig")]
1590 pub customer_managed_encryption_enforcement_config:
1591 Option<BucketEncryptionCustomerManagedEncryptionEnforcementConfig>,
1592 /// If set, the new objects created in this bucket must comply with this enforcement config. Changing this has no effect on existing objects; it applies to new objects only. If omitted, the new objects are allowed to be encrypted with Customer Supplied Encryption type by default.
1593 #[serde(rename = "customerSuppliedEncryptionEnforcementConfig")]
1594 pub customer_supplied_encryption_enforcement_config:
1595 Option<BucketEncryptionCustomerSuppliedEncryptionEnforcementConfig>,
1596 /// A Cloud KMS key that will be used to encrypt objects inserted into this bucket, if no encryption method is specified.
1597 #[serde(rename = "defaultKmsKeyName")]
1598 pub default_kms_key_name: Option<String>,
1599 /// If set, the new objects created in this bucket must comply with this enforcement config. Changing this has no effect on existing objects; it applies to new objects only. If omitted, the new objects are allowed to be encrypted with Google Managed Encryption type by default.
1600 #[serde(rename = "googleManagedEncryptionEnforcementConfig")]
1601 pub google_managed_encryption_enforcement_config:
1602 Option<BucketEncryptionGoogleManagedEncryptionEnforcementConfig>,
1603}
1604
1605impl common::NestedType for BucketEncryption {}
1606impl common::Part for BucketEncryption {}
1607
1608/// If set, the new objects created in this bucket must comply with this enforcement config. Changing this has no effect on existing objects; it applies to new objects only. If omitted, the new objects are allowed to be encrypted with Customer Managed Encryption type by default.
1609///
1610/// This type is not used in any activity, and only used as *part* of another schema.
1611///
1612#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1613#[serde_with::serde_as]
1614#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1615pub struct BucketEncryptionCustomerManagedEncryptionEnforcementConfig {
1616 /// Server-determined value that indicates the time from which configuration was enforced and effective. This value is in RFC 3339 format.
1617 #[serde(rename = "effectiveTime")]
1618 pub effective_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1619 /// Restriction mode for Customer-Managed Encryption Keys. Defaults to NotRestricted.
1620 #[serde(rename = "restrictionMode")]
1621 pub restriction_mode: Option<String>,
1622}
1623
1624impl common::NestedType for BucketEncryptionCustomerManagedEncryptionEnforcementConfig {}
1625impl common::Part for BucketEncryptionCustomerManagedEncryptionEnforcementConfig {}
1626
1627/// If set, the new objects created in this bucket must comply with this enforcement config. Changing this has no effect on existing objects; it applies to new objects only. If omitted, the new objects are allowed to be encrypted with Customer Supplied Encryption type by default.
1628///
1629/// This type is not used in any activity, and only used as *part* of another schema.
1630///
1631#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1632#[serde_with::serde_as]
1633#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1634pub struct BucketEncryptionCustomerSuppliedEncryptionEnforcementConfig {
1635 /// Server-determined value that indicates the time from which configuration was enforced and effective. This value is in RFC 3339 format.
1636 #[serde(rename = "effectiveTime")]
1637 pub effective_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1638 /// Restriction mode for Customer-Supplied Encryption Keys. Defaults to NotRestricted.
1639 #[serde(rename = "restrictionMode")]
1640 pub restriction_mode: Option<String>,
1641}
1642
1643impl common::NestedType for BucketEncryptionCustomerSuppliedEncryptionEnforcementConfig {}
1644impl common::Part for BucketEncryptionCustomerSuppliedEncryptionEnforcementConfig {}
1645
1646/// If set, the new objects created in this bucket must comply with this enforcement config. Changing this has no effect on existing objects; it applies to new objects only. If omitted, the new objects are allowed to be encrypted with Google Managed Encryption type by default.
1647///
1648/// This type is not used in any activity, and only used as *part* of another schema.
1649///
1650#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1651#[serde_with::serde_as]
1652#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1653pub struct BucketEncryptionGoogleManagedEncryptionEnforcementConfig {
1654 /// Server-determined value that indicates the time from which configuration was enforced and effective. This value is in RFC 3339 format.
1655 #[serde(rename = "effectiveTime")]
1656 pub effective_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1657 /// Restriction mode for Google-Managed Encryption Keys. Defaults to NotRestricted.
1658 #[serde(rename = "restrictionMode")]
1659 pub restriction_mode: Option<String>,
1660}
1661
1662impl common::NestedType for BucketEncryptionGoogleManagedEncryptionEnforcementConfig {}
1663impl common::Part for BucketEncryptionGoogleManagedEncryptionEnforcementConfig {}
1664
1665/// The bucket's hierarchical namespace configuration.
1666///
1667/// This type is not used in any activity, and only used as *part* of another schema.
1668///
1669#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1670#[serde_with::serde_as]
1671#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1672pub struct BucketHierarchicalNamespace {
1673 /// When set to true, hierarchical namespace is enabled for this bucket.
1674 pub enabled: Option<bool>,
1675}
1676
1677impl common::NestedType for BucketHierarchicalNamespace {}
1678impl common::Part for BucketHierarchicalNamespace {}
1679
1680/// The bucket's IAM configuration.
1681///
1682/// This type is not used in any activity, and only used as *part* of another schema.
1683///
1684#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1685#[serde_with::serde_as]
1686#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1687pub struct BucketIamConfiguration {
1688 /// 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.
1689 #[serde(rename = "bucketPolicyOnly")]
1690 pub bucket_policy_only: Option<BucketIamConfigurationBucketPolicyOnly>,
1691 /// The bucket's Public Access Prevention configuration. Currently, 'inherited' and 'enforced' are supported.
1692 #[serde(rename = "publicAccessPrevention")]
1693 pub public_access_prevention: Option<String>,
1694 /// The bucket's uniform bucket-level access configuration.
1695 #[serde(rename = "uniformBucketLevelAccess")]
1696 pub uniform_bucket_level_access: Option<BucketIamConfigurationUniformBucketLevelAccess>,
1697}
1698
1699impl common::NestedType for BucketIamConfiguration {}
1700impl common::Part for BucketIamConfiguration {}
1701
1702/// 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.
1703///
1704/// This type is not used in any activity, and only used as *part* of another schema.
1705///
1706#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1707#[serde_with::serde_as]
1708#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1709pub struct BucketIamConfigurationBucketPolicyOnly {
1710 /// If set, access is controlled only by bucket-level or above IAM policies.
1711 pub enabled: Option<bool>,
1712 /// 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.
1713 #[serde(rename = "lockedTime")]
1714 pub locked_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1715}
1716
1717impl common::NestedType for BucketIamConfigurationBucketPolicyOnly {}
1718impl common::Part for BucketIamConfigurationBucketPolicyOnly {}
1719
1720/// The bucket's uniform bucket-level access configuration.
1721///
1722/// This type is not used in any activity, and only used as *part* of another schema.
1723///
1724#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1725#[serde_with::serde_as]
1726#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1727pub struct BucketIamConfigurationUniformBucketLevelAccess {
1728 /// If set, access is controlled only by bucket-level or above IAM policies.
1729 pub enabled: Option<bool>,
1730 /// 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.
1731 #[serde(rename = "lockedTime")]
1732 pub locked_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1733}
1734
1735impl common::NestedType for BucketIamConfigurationUniformBucketLevelAccess {}
1736impl common::Part for BucketIamConfigurationUniformBucketLevelAccess {}
1737
1738/// The bucket's IP filter configuration. Specifies the network sources that are allowed to access the operations on the bucket, as well as its underlying objects. Only enforced when the mode is set to 'Enabled'.
1739///
1740/// This type is not used in any activity, and only used as *part* of another schema.
1741///
1742#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1743#[serde_with::serde_as]
1744#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1745pub struct BucketIpFilter {
1746 /// Whether to allow all service agents to access the bucket regardless of the IP filter configuration.
1747 #[serde(rename = "allowAllServiceAgentAccess")]
1748 pub allow_all_service_agent_access: Option<bool>,
1749 /// Whether to allow cross-org VPCs in the bucket's IP filter configuration.
1750 #[serde(rename = "allowCrossOrgVpcs")]
1751 pub allow_cross_org_vpcs: Option<bool>,
1752 /// The mode of the IP filter. Valid values are 'Enabled' and 'Disabled'.
1753 pub mode: Option<String>,
1754 /// The public network source of the bucket's IP filter.
1755 #[serde(rename = "publicNetworkSource")]
1756 pub public_network_source: Option<BucketIpFilterPublicNetworkSource>,
1757 /// The list of [VPC network](https://cloud.google.com/vpc/docs/vpc) sources of the bucket's IP filter.
1758 #[serde(rename = "vpcNetworkSources")]
1759 pub vpc_network_sources: Option<Vec<BucketIpFilterVpcNetworkSources>>,
1760}
1761
1762impl common::NestedType for BucketIpFilter {}
1763impl common::Part for BucketIpFilter {}
1764
1765/// The public network source of the bucket's IP filter.
1766///
1767/// This type is not used in any activity, and only used as *part* of another schema.
1768///
1769#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1770#[serde_with::serde_as]
1771#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1772pub struct BucketIpFilterPublicNetworkSource {
1773 /// The list of public IPv4, IPv6 cidr ranges that are allowed to access the bucket.
1774 #[serde(rename = "allowedIpCidrRanges")]
1775 pub allowed_ip_cidr_ranges: Option<Vec<String>>,
1776}
1777
1778impl common::NestedType for BucketIpFilterPublicNetworkSource {}
1779impl common::Part for BucketIpFilterPublicNetworkSource {}
1780
1781/// The list of [VPC network](https://cloud.google.com/vpc/docs/vpc) sources of the bucket's IP filter.
1782///
1783/// This type is not used in any activity, and only used as *part* of another schema.
1784///
1785#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1786#[serde_with::serde_as]
1787#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1788pub struct BucketIpFilterVpcNetworkSources {
1789 /// The list of IPv4, IPv6 cidr ranges subnetworks that are allowed to access the bucket.
1790 #[serde(rename = "allowedIpCidrRanges")]
1791 pub allowed_ip_cidr_ranges: Option<Vec<String>>,
1792 /// Name of the network. Format: projects/{PROJECT_ID}/global/networks/{NETWORK_NAME}
1793 pub network: Option<String>,
1794}
1795
1796impl common::NestedType for BucketIpFilterVpcNetworkSources {}
1797impl common::Part for BucketIpFilterVpcNetworkSources {}
1798
1799/// The bucket's lifecycle configuration. See [Lifecycle Management](https://cloud.google.com/storage/docs/lifecycle) for more information.
1800///
1801/// This type is not used in any activity, and only used as *part* of another schema.
1802///
1803#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1804#[serde_with::serde_as]
1805#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1806pub struct BucketLifecycle {
1807 /// A lifecycle management rule, which is made of an action to take and the condition(s) under which the action will be taken.
1808 pub rule: Option<Vec<BucketLifecycleRule>>,
1809}
1810
1811impl common::NestedType for BucketLifecycle {}
1812impl common::Part for BucketLifecycle {}
1813
1814/// A lifecycle management rule, which is made of an action to take and the condition(s) under which the action will be taken.
1815///
1816/// This type is not used in any activity, and only used as *part* of another schema.
1817///
1818#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1819#[serde_with::serde_as]
1820#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1821pub struct BucketLifecycleRule {
1822 /// The action to take.
1823 pub action: Option<BucketLifecycleRuleAction>,
1824 /// The condition(s) under which the action will be taken.
1825 pub condition: Option<BucketLifecycleRuleCondition>,
1826}
1827
1828impl common::NestedType for BucketLifecycleRule {}
1829impl common::Part for BucketLifecycleRule {}
1830
1831/// The action to take.
1832///
1833/// This type is not used in any activity, and only used as *part* of another schema.
1834///
1835#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1836#[serde_with::serde_as]
1837#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1838pub struct BucketLifecycleRuleAction {
1839 /// Target storage class. Required iff the type of the action is SetStorageClass.
1840 #[serde(rename = "storageClass")]
1841 pub storage_class: Option<String>,
1842 /// Type of the action. Currently, only Delete, SetStorageClass, and AbortIncompleteMultipartUpload are supported.
1843 #[serde(rename = "type")]
1844 pub type_: Option<String>,
1845}
1846
1847impl common::NestedType for BucketLifecycleRuleAction {}
1848impl common::Part for BucketLifecycleRuleAction {}
1849
1850/// The condition(s) under which the action will be taken.
1851///
1852/// This type is not used in any activity, and only used as *part* of another schema.
1853///
1854#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1855#[serde_with::serde_as]
1856#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1857pub struct BucketLifecycleRuleCondition {
1858 /// Age of an object (in days). This condition is satisfied when an object reaches the specified age.
1859 pub age: Option<i32>,
1860 /// 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.
1861 #[serde(rename = "createdBefore")]
1862 pub created_before: Option<chrono::NaiveDate>,
1863 /// 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.
1864 #[serde(rename = "customTimeBefore")]
1865 pub custom_time_before: Option<chrono::NaiveDate>,
1866 /// 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.
1867 #[serde(rename = "daysSinceCustomTime")]
1868 pub days_since_custom_time: Option<i32>,
1869 /// 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.
1870 #[serde(rename = "daysSinceNoncurrentTime")]
1871 pub days_since_noncurrent_time: Option<i32>,
1872 /// Relevant only for versioned objects. If the value is true, this condition matches live objects; if the value is false, it matches archived objects.
1873 #[serde(rename = "isLive")]
1874 pub is_live: Option<bool>,
1875 /// 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.
1876 #[serde(rename = "matchesPattern")]
1877 pub matches_pattern: Option<String>,
1878 /// 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.
1879 #[serde(rename = "matchesPrefix")]
1880 pub matches_prefix: Option<Vec<String>>,
1881 /// 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.
1882 #[serde(rename = "matchesStorageClass")]
1883 pub matches_storage_class: Option<Vec<String>>,
1884 /// 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.
1885 #[serde(rename = "matchesSuffix")]
1886 pub matches_suffix: Option<Vec<String>>,
1887 /// 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.
1888 #[serde(rename = "noncurrentTimeBefore")]
1889 pub noncurrent_time_before: Option<chrono::NaiveDate>,
1890 /// 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.
1891 #[serde(rename = "numNewerVersions")]
1892 pub num_newer_versions: Option<i32>,
1893}
1894
1895impl common::NestedType for BucketLifecycleRuleCondition {}
1896impl common::Part for BucketLifecycleRuleCondition {}
1897
1898/// The bucket's logging configuration, which defines the destination bucket and optional name prefix for the current bucket's logs.
1899///
1900/// This type is not used in any activity, and only used as *part* of another schema.
1901///
1902#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1903#[serde_with::serde_as]
1904#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1905pub struct BucketLogging {
1906 /// The destination bucket where the current bucket's logs should be placed.
1907 #[serde(rename = "logBucket")]
1908 pub log_bucket: Option<String>,
1909 /// A prefix for log object names.
1910 #[serde(rename = "logObjectPrefix")]
1911 pub log_object_prefix: Option<String>,
1912}
1913
1914impl common::NestedType for BucketLogging {}
1915impl common::Part for BucketLogging {}
1916
1917/// The bucket's object retention config.
1918///
1919/// This type is not used in any activity, and only used as *part* of another schema.
1920///
1921#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1922#[serde_with::serde_as]
1923#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1924pub struct BucketObjectRetention {
1925 /// The bucket's object retention mode. Can be Enabled.
1926 pub mode: Option<String>,
1927}
1928
1929impl common::NestedType for BucketObjectRetention {}
1930impl common::Part for BucketObjectRetention {}
1931
1932/// The owner of the bucket. This is always the project team's owner group.
1933///
1934/// This type is not used in any activity, and only used as *part* of another schema.
1935///
1936#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1937#[serde_with::serde_as]
1938#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1939pub struct BucketOwner {
1940 /// The entity, in the form project-owner-projectId.
1941 pub entity: Option<String>,
1942 /// The ID for the entity.
1943 #[serde(rename = "entityId")]
1944 pub entity_id: Option<String>,
1945}
1946
1947impl common::NestedType for BucketOwner {}
1948impl common::Part for BucketOwner {}
1949
1950/// 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.
1951///
1952/// This type is not used in any activity, and only used as *part* of another schema.
1953///
1954#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1955#[serde_with::serde_as]
1956#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1957pub struct BucketRetentionPolicy {
1958 /// Server-determined value that indicates the time from which policy was enforced and effective. This value is in RFC 3339 format.
1959 #[serde(rename = "effectiveTime")]
1960 pub effective_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1961 /// Once locked, an object retention policy cannot be modified.
1962 #[serde(rename = "isLocked")]
1963 pub is_locked: Option<bool>,
1964 /// 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.
1965 #[serde(rename = "retentionPeriod")]
1966 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1967 pub retention_period: Option<i64>,
1968}
1969
1970impl common::NestedType for BucketRetentionPolicy {}
1971impl common::Part for BucketRetentionPolicy {}
1972
1973/// The bucket's soft delete policy, which defines the period of time that soft-deleted objects will be retained, and cannot be permanently deleted.
1974///
1975/// This type is not used in any activity, and only used as *part* of another schema.
1976///
1977#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1978#[serde_with::serde_as]
1979#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1980pub struct BucketSoftDeletePolicy {
1981 /// 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.
1982 #[serde(rename = "effectiveTime")]
1983 pub effective_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1984 /// The duration in seconds that soft-deleted objects in the bucket will be retained and cannot be permanently deleted.
1985 #[serde(rename = "retentionDurationSeconds")]
1986 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1987 pub retention_duration_seconds: Option<i64>,
1988}
1989
1990impl common::NestedType for BucketSoftDeletePolicy {}
1991impl common::Part for BucketSoftDeletePolicy {}
1992
1993/// The bucket's versioning configuration.
1994///
1995/// This type is not used in any activity, and only used as *part* of another schema.
1996///
1997#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1998#[serde_with::serde_as]
1999#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2000pub struct BucketVersioning {
2001 /// While set to true, versioning is fully enabled for this bucket.
2002 pub enabled: Option<bool>,
2003}
2004
2005impl common::NestedType for BucketVersioning {}
2006impl common::Part for BucketVersioning {}
2007
2008/// The bucket's website configuration, controlling how the service behaves when accessing bucket contents as a web site. See the [Static Website Examples](https://cloud.google.com/storage/docs/static-website) for more information.
2009///
2010/// This type is not used in any activity, and only used as *part* of another schema.
2011///
2012#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2013#[serde_with::serde_as]
2014#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2015pub struct BucketWebsite {
2016 /// 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.
2017 #[serde(rename = "mainPageSuffix")]
2018 pub main_page_suffix: Option<String>,
2019 /// 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.
2020 #[serde(rename = "notFoundPage")]
2021 pub not_found_page: Option<String>,
2022}
2023
2024impl common::NestedType for BucketWebsite {}
2025impl common::Part for BucketWebsite {}
2026
2027/// The project team associated with the entity, if any.
2028///
2029/// This type is not used in any activity, and only used as *part* of another schema.
2030///
2031#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2032#[serde_with::serde_as]
2033#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2034pub struct BucketAccessControlProjectTeam {
2035 /// The project number.
2036 #[serde(rename = "projectNumber")]
2037 pub project_number: Option<String>,
2038 /// The team.
2039 pub team: Option<String>,
2040}
2041
2042impl common::NestedType for BucketAccessControlProjectTeam {}
2043impl common::Part for BucketAccessControlProjectTeam {}
2044
2045/// The bucket's custom placement configuration for Custom Dual Regions.
2046///
2047/// This type is not used in any activity, and only used as *part* of another schema.
2048///
2049#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2050#[serde_with::serde_as]
2051#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2052pub struct BucketStorageLayoutCustomPlacementConfig {
2053 /// The list of regional locations in which data is placed.
2054 #[serde(rename = "dataLocations")]
2055 pub data_locations: Option<Vec<String>>,
2056}
2057
2058impl common::NestedType for BucketStorageLayoutCustomPlacementConfig {}
2059impl common::Part for BucketStorageLayoutCustomPlacementConfig {}
2060
2061/// The bucket's hierarchical namespace configuration.
2062///
2063/// This type is not used in any activity, and only used as *part* of another schema.
2064///
2065#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2066#[serde_with::serde_as]
2067#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2068pub struct BucketStorageLayoutHierarchicalNamespace {
2069 /// When set to true, hierarchical namespace is enabled for this bucket.
2070 pub enabled: Option<bool>,
2071}
2072
2073impl common::NestedType for BucketStorageLayoutHierarchicalNamespace {}
2074impl common::Part for BucketStorageLayoutHierarchicalNamespace {}
2075
2076/// The list of source objects that will be concatenated into a single object.
2077///
2078/// This type is not used in any activity, and only used as *part* of another schema.
2079///
2080#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2081#[serde_with::serde_as]
2082#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2083pub struct ComposeRequestSourceObjects {
2084 /// The generation of this object to use as the source.
2085 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2086 pub generation: Option<i64>,
2087 /// The source object's name. All source objects must reside in the same bucket.
2088 pub name: Option<String>,
2089 /// Conditions that must be met for this operation to execute.
2090 #[serde(rename = "objectPreconditions")]
2091 pub object_preconditions: Option<ComposeRequestSourceObjectsObjectPreconditions>,
2092}
2093
2094impl common::NestedType for ComposeRequestSourceObjects {}
2095impl common::Part for ComposeRequestSourceObjects {}
2096
2097/// Conditions that must be met for this operation to execute.
2098///
2099/// This type is not used in any activity, and only used as *part* of another schema.
2100///
2101#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2102#[serde_with::serde_as]
2103#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2104pub struct ComposeRequestSourceObjectsObjectPreconditions {
2105 /// 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.
2106 #[serde(rename = "ifGenerationMatch")]
2107 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2108 pub if_generation_match: Option<i64>,
2109}
2110
2111impl common::NestedType for ComposeRequestSourceObjectsObjectPreconditions {}
2112impl common::Part for ComposeRequestSourceObjectsObjectPreconditions {}
2113
2114/// Only present if the folder is part of an ongoing rename folder operation. Contains information which can be used to query the operation status.
2115///
2116/// This type is not used in any activity, and only used as *part* of another schema.
2117///
2118#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2119#[serde_with::serde_as]
2120#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2121pub struct FolderPendingRenameInfo {
2122 /// The ID of the rename folder operation.
2123 #[serde(rename = "operationId")]
2124 pub operation_id: Option<String>,
2125}
2126
2127impl common::NestedType for FolderPendingRenameInfo {}
2128impl common::Part for FolderPendingRenameInfo {}
2129
2130/// User-defined or system-defined object contexts. Each object context is a key-payload pair, where the key provides the identification and the payload holds the associated value and additional metadata.
2131///
2132/// This type is not used in any activity, and only used as *part* of another schema.
2133///
2134#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2135#[serde_with::serde_as]
2136#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2137pub struct ObjectContexts {
2138 /// User-defined object contexts.
2139 pub custom: Option<HashMap<String, ObjectCustomContextPayload>>,
2140}
2141
2142impl common::NestedType for ObjectContexts {}
2143impl common::Part for ObjectContexts {}
2144
2145/// Metadata of customer-supplied encryption key, if the object is encrypted by such a key.
2146///
2147/// This type is not used in any activity, and only used as *part* of another schema.
2148///
2149#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2150#[serde_with::serde_as]
2151#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2152pub struct ObjectCustomerEncryption {
2153 /// The encryption algorithm.
2154 #[serde(rename = "encryptionAlgorithm")]
2155 pub encryption_algorithm: Option<String>,
2156 /// SHA256 hash value of the encryption key.
2157 #[serde(rename = "keySha256")]
2158 pub key_sha256: Option<String>,
2159}
2160
2161impl common::NestedType for ObjectCustomerEncryption {}
2162impl common::Part for ObjectCustomerEncryption {}
2163
2164/// The owner of the object. This will always be the uploader of the object.
2165///
2166/// This type is not used in any activity, and only used as *part* of another schema.
2167///
2168#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2169#[serde_with::serde_as]
2170#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2171pub struct ObjectOwner {
2172 /// The entity, in the form user-userId.
2173 pub entity: Option<String>,
2174 /// The ID for the entity.
2175 #[serde(rename = "entityId")]
2176 pub entity_id: Option<String>,
2177}
2178
2179impl common::NestedType for ObjectOwner {}
2180impl common::Part for ObjectOwner {}
2181
2182/// A collection of object level retention parameters.
2183///
2184/// This type is not used in any activity, and only used as *part* of another schema.
2185///
2186#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2187#[serde_with::serde_as]
2188#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2189pub struct ObjectRetention {
2190 /// The bucket's object retention mode, can only be Unlocked or Locked.
2191 pub mode: Option<String>,
2192 /// A time in RFC 3339 format until which object retention protects this object.
2193 #[serde(rename = "retainUntilTime")]
2194 pub retain_until_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2195}
2196
2197impl common::NestedType for ObjectRetention {}
2198impl common::Part for ObjectRetention {}
2199
2200/// The project team associated with the entity, if any.
2201///
2202/// This type is not used in any activity, and only used as *part* of another schema.
2203///
2204#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2205#[serde_with::serde_as]
2206#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2207pub struct ObjectAccessControlProjectTeam {
2208 /// The project number.
2209 #[serde(rename = "projectNumber")]
2210 pub project_number: Option<String>,
2211 /// The team.
2212 pub team: Option<String>,
2213}
2214
2215impl common::NestedType for ObjectAccessControlProjectTeam {}
2216impl common::Part for ObjectAccessControlProjectTeam {}
2217
2218/// An association between a role, which comes with a set of permissions, and members who may assume that role.
2219///
2220/// This type is not used in any activity, and only used as *part* of another schema.
2221///
2222#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2223#[serde_with::serde_as]
2224#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2225pub struct PolicyBindings {
2226 /// 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.
2227 pub condition: Option<Expr>,
2228 /// A collection of identifiers for members who may assume the provided role. Recognized identifiers are as follows:
2229 /// - allUsers - A special identifier that represents anyone on the internet; with or without a Google account.
2230 /// - allAuthenticatedUsers - A special identifier that represents anyone who is authenticated with a Google account or a service account.
2231 /// - user:emailid - An email address that represents a specific account. For example, user:alice@gmail.com or user:joe@example.com.
2232 /// - serviceAccount:emailid - An email address that represents a service account. For example, serviceAccount:my-other-app@appspot.gserviceaccount.com .
2233 /// - group:emailid - An email address that represents a Google group. For example, group:admins@example.com.
2234 /// - domain:domain - A Google Apps domain name that represents all the users of that domain. For example, domain:google.com or domain:example.com.
2235 /// - projectOwner:projectid - Owners of the given project. For example, projectOwner:my-example-project
2236 /// - projectEditor:projectid - Editors of the given project. For example, projectEditor:my-example-project
2237 /// - projectViewer:projectid - Viewers of the given project. For example, projectViewer:my-example-project
2238 pub members: Option<Vec<String>>,
2239 /// 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.
2240 /// The new IAM roles are:
2241 /// - roles/storage.admin - Full control of Google Cloud Storage resources.
2242 /// - roles/storage.objectViewer - Read-Only access to Google Cloud Storage objects.
2243 /// - roles/storage.objectCreator - Access to create objects in Google Cloud Storage.
2244 /// - roles/storage.objectAdmin - Full control of Google Cloud Storage objects. The legacy IAM roles are:
2245 /// - roles/storage.legacyObjectReader - Read-only access to objects without listing. Equivalent to an ACL entry on an object with the READER role.
2246 /// - roles/storage.legacyObjectOwner - Read/write access to existing objects without listing. Equivalent to an ACL entry on an object with the OWNER role.
2247 /// - roles/storage.legacyBucketReader - Read access to buckets with object listing. Equivalent to an ACL entry on a bucket with the READER role.
2248 /// - roles/storage.legacyBucketWriter - Read access to buckets with object listing/creation/deletion. Equivalent to an ACL entry on a bucket with the WRITER role.
2249 /// - 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.
2250 pub role: Option<String>,
2251}
2252
2253impl common::NestedType for PolicyBindings {}
2254impl common::Part for PolicyBindings {}
2255
2256/// The bucket's new custom placement configuration if relocating to a Custom Dual Region.
2257///
2258/// This type is not used in any activity, and only used as *part* of another schema.
2259///
2260#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2261#[serde_with::serde_as]
2262#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2263pub struct RelocateBucketRequestDestinationCustomPlacementConfig {
2264 /// The list of regional locations in which data is placed.
2265 #[serde(rename = "dataLocations")]
2266 pub data_locations: Option<Vec<String>>,
2267}
2268
2269impl common::NestedType for RelocateBucketRequestDestinationCustomPlacementConfig {}
2270impl common::Part for RelocateBucketRequestDestinationCustomPlacementConfig {}
2271
2272// ###################
2273// MethodBuilders ###
2274// #################
2275
2276/// A builder providing access to all methods supported on *anywhereCach* resources.
2277/// It is not used directly, but through the [`Storage`] hub.
2278///
2279/// # Example
2280///
2281/// Instantiate a resource builder
2282///
2283/// ```test_harness,no_run
2284/// extern crate hyper;
2285/// extern crate hyper_rustls;
2286/// extern crate google_storage1 as storage1;
2287///
2288/// # async fn dox() {
2289/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2290///
2291/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2292/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2293/// .with_native_roots()
2294/// .unwrap()
2295/// .https_only()
2296/// .enable_http2()
2297/// .build();
2298///
2299/// let executor = hyper_util::rt::TokioExecutor::new();
2300/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2301/// secret,
2302/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2303/// yup_oauth2::client::CustomHyperClientBuilder::from(
2304/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2305/// ),
2306/// ).build().await.unwrap();
2307///
2308/// let client = hyper_util::client::legacy::Client::builder(
2309/// hyper_util::rt::TokioExecutor::new()
2310/// )
2311/// .build(
2312/// hyper_rustls::HttpsConnectorBuilder::new()
2313/// .with_native_roots()
2314/// .unwrap()
2315/// .https_or_http()
2316/// .enable_http2()
2317/// .build()
2318/// );
2319/// let mut hub = Storage::new(client, auth);
2320/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2321/// // like `disable(...)`, `get(...)`, `insert(...)`, `list(...)`, `pause(...)`, `resume(...)` and `update(...)`
2322/// // to build up your call.
2323/// let rb = hub.anywhere_caches();
2324/// # }
2325/// ```
2326pub struct AnywhereCachMethods<'a, C>
2327where
2328 C: 'a,
2329{
2330 hub: &'a Storage<C>,
2331}
2332
2333impl<'a, C> common::MethodsBuilder for AnywhereCachMethods<'a, C> {}
2334
2335impl<'a, C> AnywhereCachMethods<'a, C> {
2336 /// Create a builder to help you perform the following task:
2337 ///
2338 /// Disables an Anywhere Cache instance.
2339 ///
2340 /// # Arguments
2341 ///
2342 /// * `bucket` - Name of the parent bucket.
2343 /// * `anywhereCacheId` - The ID of requested Anywhere Cache instance.
2344 pub fn disable(&self, bucket: &str, anywhere_cache_id: &str) -> AnywhereCachDisableCall<'a, C> {
2345 AnywhereCachDisableCall {
2346 hub: self.hub,
2347 _bucket: bucket.to_string(),
2348 _anywhere_cache_id: anywhere_cache_id.to_string(),
2349 _delegate: Default::default(),
2350 _additional_params: Default::default(),
2351 _scopes: Default::default(),
2352 }
2353 }
2354
2355 /// Create a builder to help you perform the following task:
2356 ///
2357 /// Returns the metadata of an Anywhere Cache instance.
2358 ///
2359 /// # Arguments
2360 ///
2361 /// * `bucket` - Name of the parent bucket.
2362 /// * `anywhereCacheId` - The ID of requested Anywhere Cache instance.
2363 pub fn get(&self, bucket: &str, anywhere_cache_id: &str) -> AnywhereCachGetCall<'a, C> {
2364 AnywhereCachGetCall {
2365 hub: self.hub,
2366 _bucket: bucket.to_string(),
2367 _anywhere_cache_id: anywhere_cache_id.to_string(),
2368 _delegate: Default::default(),
2369 _additional_params: Default::default(),
2370 _scopes: Default::default(),
2371 }
2372 }
2373
2374 /// Create a builder to help you perform the following task:
2375 ///
2376 /// Creates an Anywhere Cache instance.
2377 ///
2378 /// # Arguments
2379 ///
2380 /// * `request` - No description provided.
2381 /// * `bucket` - Name of the parent bucket.
2382 pub fn insert(&self, request: AnywhereCache, bucket: &str) -> AnywhereCachInsertCall<'a, C> {
2383 AnywhereCachInsertCall {
2384 hub: self.hub,
2385 _request: request,
2386 _bucket: bucket.to_string(),
2387 _delegate: Default::default(),
2388 _additional_params: Default::default(),
2389 _scopes: Default::default(),
2390 }
2391 }
2392
2393 /// Create a builder to help you perform the following task:
2394 ///
2395 /// Returns a list of Anywhere Cache instances of the bucket matching the criteria.
2396 ///
2397 /// # Arguments
2398 ///
2399 /// * `bucket` - Name of the parent bucket.
2400 pub fn list(&self, bucket: &str) -> AnywhereCachListCall<'a, C> {
2401 AnywhereCachListCall {
2402 hub: self.hub,
2403 _bucket: bucket.to_string(),
2404 _page_token: Default::default(),
2405 _page_size: Default::default(),
2406 _delegate: Default::default(),
2407 _additional_params: Default::default(),
2408 _scopes: Default::default(),
2409 }
2410 }
2411
2412 /// Create a builder to help you perform the following task:
2413 ///
2414 /// Pauses an Anywhere Cache instance.
2415 ///
2416 /// # Arguments
2417 ///
2418 /// * `bucket` - Name of the parent bucket.
2419 /// * `anywhereCacheId` - The ID of requested Anywhere Cache instance.
2420 pub fn pause(&self, bucket: &str, anywhere_cache_id: &str) -> AnywhereCachPauseCall<'a, C> {
2421 AnywhereCachPauseCall {
2422 hub: self.hub,
2423 _bucket: bucket.to_string(),
2424 _anywhere_cache_id: anywhere_cache_id.to_string(),
2425 _delegate: Default::default(),
2426 _additional_params: Default::default(),
2427 _scopes: Default::default(),
2428 }
2429 }
2430
2431 /// Create a builder to help you perform the following task:
2432 ///
2433 /// Resumes a paused or disabled Anywhere Cache instance.
2434 ///
2435 /// # Arguments
2436 ///
2437 /// * `bucket` - Name of the parent bucket.
2438 /// * `anywhereCacheId` - The ID of requested Anywhere Cache instance.
2439 pub fn resume(&self, bucket: &str, anywhere_cache_id: &str) -> AnywhereCachResumeCall<'a, C> {
2440 AnywhereCachResumeCall {
2441 hub: self.hub,
2442 _bucket: bucket.to_string(),
2443 _anywhere_cache_id: anywhere_cache_id.to_string(),
2444 _delegate: Default::default(),
2445 _additional_params: Default::default(),
2446 _scopes: Default::default(),
2447 }
2448 }
2449
2450 /// Create a builder to help you perform the following task:
2451 ///
2452 /// Updates the config(ttl and admissionPolicy) of an Anywhere Cache instance.
2453 ///
2454 /// # Arguments
2455 ///
2456 /// * `request` - No description provided.
2457 /// * `bucket` - Name of the parent bucket.
2458 /// * `anywhereCacheId` - The ID of requested Anywhere Cache instance.
2459 pub fn update(
2460 &self,
2461 request: AnywhereCache,
2462 bucket: &str,
2463 anywhere_cache_id: &str,
2464 ) -> AnywhereCachUpdateCall<'a, C> {
2465 AnywhereCachUpdateCall {
2466 hub: self.hub,
2467 _request: request,
2468 _bucket: bucket.to_string(),
2469 _anywhere_cache_id: anywhere_cache_id.to_string(),
2470 _delegate: Default::default(),
2471 _additional_params: Default::default(),
2472 _scopes: Default::default(),
2473 }
2474 }
2475}
2476
2477/// A builder providing access to all methods supported on *bucketAccessControl* resources.
2478/// It is not used directly, but through the [`Storage`] hub.
2479///
2480/// # Example
2481///
2482/// Instantiate a resource builder
2483///
2484/// ```test_harness,no_run
2485/// extern crate hyper;
2486/// extern crate hyper_rustls;
2487/// extern crate google_storage1 as storage1;
2488///
2489/// # async fn dox() {
2490/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2491///
2492/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2493/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2494/// .with_native_roots()
2495/// .unwrap()
2496/// .https_only()
2497/// .enable_http2()
2498/// .build();
2499///
2500/// let executor = hyper_util::rt::TokioExecutor::new();
2501/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2502/// secret,
2503/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2504/// yup_oauth2::client::CustomHyperClientBuilder::from(
2505/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2506/// ),
2507/// ).build().await.unwrap();
2508///
2509/// let client = hyper_util::client::legacy::Client::builder(
2510/// hyper_util::rt::TokioExecutor::new()
2511/// )
2512/// .build(
2513/// hyper_rustls::HttpsConnectorBuilder::new()
2514/// .with_native_roots()
2515/// .unwrap()
2516/// .https_or_http()
2517/// .enable_http2()
2518/// .build()
2519/// );
2520/// let mut hub = Storage::new(client, auth);
2521/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2522/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
2523/// // to build up your call.
2524/// let rb = hub.bucket_access_controls();
2525/// # }
2526/// ```
2527pub struct BucketAccessControlMethods<'a, C>
2528where
2529 C: 'a,
2530{
2531 hub: &'a Storage<C>,
2532}
2533
2534impl<'a, C> common::MethodsBuilder for BucketAccessControlMethods<'a, C> {}
2535
2536impl<'a, C> BucketAccessControlMethods<'a, C> {
2537 /// Create a builder to help you perform the following task:
2538 ///
2539 /// Permanently deletes the ACL entry for the specified entity on the specified bucket.
2540 ///
2541 /// # Arguments
2542 ///
2543 /// * `bucket` - Name of a bucket.
2544 /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
2545 pub fn delete(&self, bucket: &str, entity: &str) -> BucketAccessControlDeleteCall<'a, C> {
2546 BucketAccessControlDeleteCall {
2547 hub: self.hub,
2548 _bucket: bucket.to_string(),
2549 _entity: entity.to_string(),
2550 _user_project: Default::default(),
2551 _delegate: Default::default(),
2552 _additional_params: Default::default(),
2553 _scopes: Default::default(),
2554 }
2555 }
2556
2557 /// Create a builder to help you perform the following task:
2558 ///
2559 /// Returns the ACL entry for the specified entity on the specified bucket.
2560 ///
2561 /// # Arguments
2562 ///
2563 /// * `bucket` - Name of a bucket.
2564 /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
2565 pub fn get(&self, bucket: &str, entity: &str) -> BucketAccessControlGetCall<'a, C> {
2566 BucketAccessControlGetCall {
2567 hub: self.hub,
2568 _bucket: bucket.to_string(),
2569 _entity: entity.to_string(),
2570 _user_project: Default::default(),
2571 _delegate: Default::default(),
2572 _additional_params: Default::default(),
2573 _scopes: Default::default(),
2574 }
2575 }
2576
2577 /// Create a builder to help you perform the following task:
2578 ///
2579 /// Creates a new ACL entry on the specified bucket.
2580 ///
2581 /// # Arguments
2582 ///
2583 /// * `request` - No description provided.
2584 /// * `bucket` - Name of a bucket.
2585 pub fn insert(
2586 &self,
2587 request: BucketAccessControl,
2588 bucket: &str,
2589 ) -> BucketAccessControlInsertCall<'a, C> {
2590 BucketAccessControlInsertCall {
2591 hub: self.hub,
2592 _request: request,
2593 _bucket: bucket.to_string(),
2594 _user_project: Default::default(),
2595 _delegate: Default::default(),
2596 _additional_params: Default::default(),
2597 _scopes: Default::default(),
2598 }
2599 }
2600
2601 /// Create a builder to help you perform the following task:
2602 ///
2603 /// Retrieves ACL entries on the specified bucket.
2604 ///
2605 /// # Arguments
2606 ///
2607 /// * `bucket` - Name of a bucket.
2608 pub fn list(&self, bucket: &str) -> BucketAccessControlListCall<'a, C> {
2609 BucketAccessControlListCall {
2610 hub: self.hub,
2611 _bucket: bucket.to_string(),
2612 _user_project: Default::default(),
2613 _delegate: Default::default(),
2614 _additional_params: Default::default(),
2615 _scopes: Default::default(),
2616 }
2617 }
2618
2619 /// Create a builder to help you perform the following task:
2620 ///
2621 /// Patches an ACL entry on the specified bucket.
2622 ///
2623 /// # Arguments
2624 ///
2625 /// * `request` - No description provided.
2626 /// * `bucket` - Name of a bucket.
2627 /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
2628 pub fn patch(
2629 &self,
2630 request: BucketAccessControl,
2631 bucket: &str,
2632 entity: &str,
2633 ) -> BucketAccessControlPatchCall<'a, C> {
2634 BucketAccessControlPatchCall {
2635 hub: self.hub,
2636 _request: request,
2637 _bucket: bucket.to_string(),
2638 _entity: entity.to_string(),
2639 _user_project: Default::default(),
2640 _delegate: Default::default(),
2641 _additional_params: Default::default(),
2642 _scopes: Default::default(),
2643 }
2644 }
2645
2646 /// Create a builder to help you perform the following task:
2647 ///
2648 /// Updates an ACL entry on the specified bucket.
2649 ///
2650 /// # Arguments
2651 ///
2652 /// * `request` - No description provided.
2653 /// * `bucket` - Name of a bucket.
2654 /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
2655 pub fn update(
2656 &self,
2657 request: BucketAccessControl,
2658 bucket: &str,
2659 entity: &str,
2660 ) -> BucketAccessControlUpdateCall<'a, C> {
2661 BucketAccessControlUpdateCall {
2662 hub: self.hub,
2663 _request: request,
2664 _bucket: bucket.to_string(),
2665 _entity: entity.to_string(),
2666 _user_project: Default::default(),
2667 _delegate: Default::default(),
2668 _additional_params: Default::default(),
2669 _scopes: Default::default(),
2670 }
2671 }
2672}
2673
2674/// A builder providing access to all methods supported on *bucket* resources.
2675/// It is not used directly, but through the [`Storage`] hub.
2676///
2677/// # Example
2678///
2679/// Instantiate a resource builder
2680///
2681/// ```test_harness,no_run
2682/// extern crate hyper;
2683/// extern crate hyper_rustls;
2684/// extern crate google_storage1 as storage1;
2685///
2686/// # async fn dox() {
2687/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2688///
2689/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2690/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2691/// .with_native_roots()
2692/// .unwrap()
2693/// .https_only()
2694/// .enable_http2()
2695/// .build();
2696///
2697/// let executor = hyper_util::rt::TokioExecutor::new();
2698/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2699/// secret,
2700/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2701/// yup_oauth2::client::CustomHyperClientBuilder::from(
2702/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2703/// ),
2704/// ).build().await.unwrap();
2705///
2706/// let client = hyper_util::client::legacy::Client::builder(
2707/// hyper_util::rt::TokioExecutor::new()
2708/// )
2709/// .build(
2710/// hyper_rustls::HttpsConnectorBuilder::new()
2711/// .with_native_roots()
2712/// .unwrap()
2713/// .https_or_http()
2714/// .enable_http2()
2715/// .build()
2716/// );
2717/// let mut hub = Storage::new(client, auth);
2718/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2719/// // like `delete(...)`, `get(...)`, `get_iam_policy(...)`, `get_storage_layout(...)`, `insert(...)`, `list(...)`, `lock_retention_policy(...)`, `operations_advance_relocate_bucket(...)`, `operations_cancel(...)`, `operations_get(...)`, `operations_list(...)`, `patch(...)`, `relocate(...)`, `restore(...)`, `set_iam_policy(...)`, `test_iam_permissions(...)` and `update(...)`
2720/// // to build up your call.
2721/// let rb = hub.buckets();
2722/// # }
2723/// ```
2724pub struct BucketMethods<'a, C>
2725where
2726 C: 'a,
2727{
2728 hub: &'a Storage<C>,
2729}
2730
2731impl<'a, C> common::MethodsBuilder for BucketMethods<'a, C> {}
2732
2733impl<'a, C> BucketMethods<'a, C> {
2734 /// Create a builder to help you perform the following task:
2735 ///
2736 /// Deletes an empty bucket. Deletions are permanent unless soft delete is enabled on the bucket.
2737 ///
2738 /// # Arguments
2739 ///
2740 /// * `bucket` - Name of a bucket.
2741 pub fn delete(&self, bucket: &str) -> BucketDeleteCall<'a, C> {
2742 BucketDeleteCall {
2743 hub: self.hub,
2744 _bucket: bucket.to_string(),
2745 _user_project: Default::default(),
2746 _if_metageneration_not_match: Default::default(),
2747 _if_metageneration_match: Default::default(),
2748 _delegate: Default::default(),
2749 _additional_params: Default::default(),
2750 _scopes: Default::default(),
2751 }
2752 }
2753
2754 /// Create a builder to help you perform the following task:
2755 ///
2756 /// Returns metadata for the specified bucket.
2757 ///
2758 /// # Arguments
2759 ///
2760 /// * `bucket` - Name of a bucket.
2761 pub fn get(&self, bucket: &str) -> BucketGetCall<'a, C> {
2762 BucketGetCall {
2763 hub: self.hub,
2764 _bucket: bucket.to_string(),
2765 _user_project: Default::default(),
2766 _soft_deleted: Default::default(),
2767 _projection: Default::default(),
2768 _if_metageneration_not_match: Default::default(),
2769 _if_metageneration_match: Default::default(),
2770 _generation: Default::default(),
2771 _delegate: Default::default(),
2772 _additional_params: Default::default(),
2773 _scopes: Default::default(),
2774 }
2775 }
2776
2777 /// Create a builder to help you perform the following task:
2778 ///
2779 /// Returns an IAM policy for the specified bucket.
2780 ///
2781 /// # Arguments
2782 ///
2783 /// * `bucket` - Name of a bucket.
2784 pub fn get_iam_policy(&self, bucket: &str) -> BucketGetIamPolicyCall<'a, C> {
2785 BucketGetIamPolicyCall {
2786 hub: self.hub,
2787 _bucket: bucket.to_string(),
2788 _user_project: Default::default(),
2789 _options_requested_policy_version: Default::default(),
2790 _delegate: Default::default(),
2791 _additional_params: Default::default(),
2792 _scopes: Default::default(),
2793 }
2794 }
2795
2796 /// Create a builder to help you perform the following task:
2797 ///
2798 /// Returns the storage layout configuration for the specified bucket. Note that this operation requires storage.objects.list permission.
2799 ///
2800 /// # Arguments
2801 ///
2802 /// * `bucket` - Name of a bucket.
2803 pub fn get_storage_layout(&self, bucket: &str) -> BucketGetStorageLayoutCall<'a, C> {
2804 BucketGetStorageLayoutCall {
2805 hub: self.hub,
2806 _bucket: bucket.to_string(),
2807 _prefix: Default::default(),
2808 _delegate: Default::default(),
2809 _additional_params: Default::default(),
2810 _scopes: Default::default(),
2811 }
2812 }
2813
2814 /// Create a builder to help you perform the following task:
2815 ///
2816 /// Creates a new bucket.
2817 ///
2818 /// # Arguments
2819 ///
2820 /// * `request` - No description provided.
2821 /// * `project` - A valid API project identifier.
2822 pub fn insert(&self, request: Bucket, project: &str) -> BucketInsertCall<'a, C> {
2823 BucketInsertCall {
2824 hub: self.hub,
2825 _request: request,
2826 _project: project.to_string(),
2827 _user_project: Default::default(),
2828 _projection: Default::default(),
2829 _predefined_default_object_acl: Default::default(),
2830 _predefined_acl: Default::default(),
2831 _enable_object_retention: Default::default(),
2832 _delegate: Default::default(),
2833 _additional_params: Default::default(),
2834 _scopes: Default::default(),
2835 }
2836 }
2837
2838 /// Create a builder to help you perform the following task:
2839 ///
2840 /// Retrieves a list of buckets for a given project.
2841 ///
2842 /// # Arguments
2843 ///
2844 /// * `project` - A valid API project identifier.
2845 pub fn list(&self, project: &str) -> BucketListCall<'a, C> {
2846 BucketListCall {
2847 hub: self.hub,
2848 _project: project.to_string(),
2849 _user_project: Default::default(),
2850 _soft_deleted: Default::default(),
2851 _return_partial_success: Default::default(),
2852 _projection: Default::default(),
2853 _prefix: Default::default(),
2854 _page_token: Default::default(),
2855 _max_results: Default::default(),
2856 _delegate: Default::default(),
2857 _additional_params: Default::default(),
2858 _scopes: Default::default(),
2859 }
2860 }
2861
2862 /// Create a builder to help you perform the following task:
2863 ///
2864 /// Locks retention policy on a bucket.
2865 ///
2866 /// # Arguments
2867 ///
2868 /// * `bucket` - Name of a bucket.
2869 /// * `ifMetagenerationMatch` - Makes the operation conditional on whether bucket's current metageneration matches the given value.
2870 pub fn lock_retention_policy(
2871 &self,
2872 bucket: &str,
2873 if_metageneration_match: i64,
2874 ) -> BucketLockRetentionPolicyCall<'a, C> {
2875 BucketLockRetentionPolicyCall {
2876 hub: self.hub,
2877 _bucket: bucket.to_string(),
2878 _if_metageneration_match: if_metageneration_match,
2879 _user_project: Default::default(),
2880 _delegate: Default::default(),
2881 _additional_params: Default::default(),
2882 _scopes: Default::default(),
2883 }
2884 }
2885
2886 /// Create a builder to help you perform the following task:
2887 ///
2888 /// Patches a bucket. Changes to the bucket will be readable immediately after writing, but configuration changes may take time to propagate.
2889 ///
2890 /// # Arguments
2891 ///
2892 /// * `request` - No description provided.
2893 /// * `bucket` - Name of a bucket.
2894 pub fn patch(&self, request: Bucket, bucket: &str) -> BucketPatchCall<'a, C> {
2895 BucketPatchCall {
2896 hub: self.hub,
2897 _request: request,
2898 _bucket: bucket.to_string(),
2899 _user_project: Default::default(),
2900 _projection: Default::default(),
2901 _predefined_default_object_acl: Default::default(),
2902 _predefined_acl: Default::default(),
2903 _if_metageneration_not_match: Default::default(),
2904 _if_metageneration_match: Default::default(),
2905 _delegate: Default::default(),
2906 _additional_params: Default::default(),
2907 _scopes: Default::default(),
2908 }
2909 }
2910
2911 /// Create a builder to help you perform the following task:
2912 ///
2913 /// Initiates a long-running Relocate Bucket operation on the specified bucket.
2914 ///
2915 /// # Arguments
2916 ///
2917 /// * `request` - No description provided.
2918 /// * `bucket` - Name of the bucket to be moved.
2919 pub fn relocate(
2920 &self,
2921 request: RelocateBucketRequest,
2922 bucket: &str,
2923 ) -> BucketRelocateCall<'a, C> {
2924 BucketRelocateCall {
2925 hub: self.hub,
2926 _request: request,
2927 _bucket: bucket.to_string(),
2928 _delegate: Default::default(),
2929 _additional_params: Default::default(),
2930 _scopes: Default::default(),
2931 }
2932 }
2933
2934 /// Create a builder to help you perform the following task:
2935 ///
2936 /// Restores a soft-deleted bucket.
2937 ///
2938 /// # Arguments
2939 ///
2940 /// * `bucket` - Name of a bucket.
2941 /// * `generation` - Generation of a bucket.
2942 pub fn restore(&self, bucket: &str, generation: i64) -> BucketRestoreCall<'a, C> {
2943 BucketRestoreCall {
2944 hub: self.hub,
2945 _bucket: bucket.to_string(),
2946 _generation: generation,
2947 _user_project: Default::default(),
2948 _projection: Default::default(),
2949 _delegate: Default::default(),
2950 _additional_params: Default::default(),
2951 _scopes: Default::default(),
2952 }
2953 }
2954
2955 /// Create a builder to help you perform the following task:
2956 ///
2957 /// Updates an IAM policy for the specified bucket.
2958 ///
2959 /// # Arguments
2960 ///
2961 /// * `request` - No description provided.
2962 /// * `bucket` - Name of a bucket.
2963 pub fn set_iam_policy(&self, request: Policy, bucket: &str) -> BucketSetIamPolicyCall<'a, C> {
2964 BucketSetIamPolicyCall {
2965 hub: self.hub,
2966 _request: request,
2967 _bucket: bucket.to_string(),
2968 _user_project: Default::default(),
2969 _delegate: Default::default(),
2970 _additional_params: Default::default(),
2971 _scopes: Default::default(),
2972 }
2973 }
2974
2975 /// Create a builder to help you perform the following task:
2976 ///
2977 /// Tests a set of permissions on the given bucket to see which, if any, are held by the caller.
2978 ///
2979 /// # Arguments
2980 ///
2981 /// * `bucket` - Name of a bucket.
2982 /// * `permissions` - Permissions to test.
2983 pub fn test_iam_permissions(
2984 &self,
2985 bucket: &str,
2986 permissions: &Vec<String>,
2987 ) -> BucketTestIamPermissionCall<'a, C> {
2988 BucketTestIamPermissionCall {
2989 hub: self.hub,
2990 _bucket: bucket.to_string(),
2991 _permissions: permissions.clone(),
2992 _user_project: Default::default(),
2993 _delegate: Default::default(),
2994 _additional_params: Default::default(),
2995 _scopes: Default::default(),
2996 }
2997 }
2998
2999 /// Create a builder to help you perform the following task:
3000 ///
3001 /// Updates a bucket. Changes to the bucket will be readable immediately after writing, but configuration changes may take time to propagate.
3002 ///
3003 /// # Arguments
3004 ///
3005 /// * `request` - No description provided.
3006 /// * `bucket` - Name of a bucket.
3007 pub fn update(&self, request: Bucket, bucket: &str) -> BucketUpdateCall<'a, C> {
3008 BucketUpdateCall {
3009 hub: self.hub,
3010 _request: request,
3011 _bucket: bucket.to_string(),
3012 _user_project: Default::default(),
3013 _projection: Default::default(),
3014 _predefined_default_object_acl: Default::default(),
3015 _predefined_acl: Default::default(),
3016 _if_metageneration_not_match: Default::default(),
3017 _if_metageneration_match: Default::default(),
3018 _delegate: Default::default(),
3019 _additional_params: Default::default(),
3020 _scopes: Default::default(),
3021 }
3022 }
3023
3024 /// Create a builder to help you perform the following task:
3025 ///
3026 /// Starts asynchronous advancement of the relocate bucket operation in the case of required write downtime, to allow it to lock the bucket at the source location, and proceed with the bucket location swap. The server makes a best effort to advance the relocate bucket operation, but success is not guaranteed.
3027 ///
3028 /// # Arguments
3029 ///
3030 /// * `request` - No description provided.
3031 /// * `bucket` - Name of the bucket to advance the relocate for.
3032 /// * `operationId` - ID of the operation resource.
3033 pub fn operations_advance_relocate_bucket(
3034 &self,
3035 request: AdvanceRelocateBucketOperationRequest,
3036 bucket: &str,
3037 operation_id: &str,
3038 ) -> BucketOperationAdvanceRelocateBucketCall<'a, C> {
3039 BucketOperationAdvanceRelocateBucketCall {
3040 hub: self.hub,
3041 _request: request,
3042 _bucket: bucket.to_string(),
3043 _operation_id: operation_id.to_string(),
3044 _delegate: Default::default(),
3045 _additional_params: Default::default(),
3046 _scopes: Default::default(),
3047 }
3048 }
3049
3050 /// Create a builder to help you perform the following task:
3051 ///
3052 /// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed.
3053 ///
3054 /// # Arguments
3055 ///
3056 /// * `bucket` - The parent bucket of the operation resource.
3057 /// * `operationId` - The ID of the operation resource.
3058 pub fn operations_cancel(
3059 &self,
3060 bucket: &str,
3061 operation_id: &str,
3062 ) -> BucketOperationCancelCall<'a, C> {
3063 BucketOperationCancelCall {
3064 hub: self.hub,
3065 _bucket: bucket.to_string(),
3066 _operation_id: operation_id.to_string(),
3067 _delegate: Default::default(),
3068 _additional_params: Default::default(),
3069 _scopes: Default::default(),
3070 }
3071 }
3072
3073 /// Create a builder to help you perform the following task:
3074 ///
3075 /// Gets the latest state of a long-running operation.
3076 ///
3077 /// # Arguments
3078 ///
3079 /// * `bucket` - The parent bucket of the operation resource.
3080 /// * `operationId` - The ID of the operation resource.
3081 pub fn operations_get(
3082 &self,
3083 bucket: &str,
3084 operation_id: &str,
3085 ) -> BucketOperationGetCall<'a, C> {
3086 BucketOperationGetCall {
3087 hub: self.hub,
3088 _bucket: bucket.to_string(),
3089 _operation_id: operation_id.to_string(),
3090 _delegate: Default::default(),
3091 _additional_params: Default::default(),
3092 _scopes: Default::default(),
3093 }
3094 }
3095
3096 /// Create a builder to help you perform the following task:
3097 ///
3098 /// Lists operations that match the specified filter in the request.
3099 ///
3100 /// # Arguments
3101 ///
3102 /// * `bucket` - Name of the bucket in which to look for operations.
3103 pub fn operations_list(&self, bucket: &str) -> BucketOperationListCall<'a, C> {
3104 BucketOperationListCall {
3105 hub: self.hub,
3106 _bucket: bucket.to_string(),
3107 _page_token: Default::default(),
3108 _page_size: Default::default(),
3109 _filter: Default::default(),
3110 _delegate: Default::default(),
3111 _additional_params: Default::default(),
3112 _scopes: Default::default(),
3113 }
3114 }
3115}
3116
3117/// A builder providing access to all methods supported on *channel* resources.
3118/// It is not used directly, but through the [`Storage`] hub.
3119///
3120/// # Example
3121///
3122/// Instantiate a resource builder
3123///
3124/// ```test_harness,no_run
3125/// extern crate hyper;
3126/// extern crate hyper_rustls;
3127/// extern crate google_storage1 as storage1;
3128///
3129/// # async fn dox() {
3130/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3131///
3132/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3133/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3134/// .with_native_roots()
3135/// .unwrap()
3136/// .https_only()
3137/// .enable_http2()
3138/// .build();
3139///
3140/// let executor = hyper_util::rt::TokioExecutor::new();
3141/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3142/// secret,
3143/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3144/// yup_oauth2::client::CustomHyperClientBuilder::from(
3145/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3146/// ),
3147/// ).build().await.unwrap();
3148///
3149/// let client = hyper_util::client::legacy::Client::builder(
3150/// hyper_util::rt::TokioExecutor::new()
3151/// )
3152/// .build(
3153/// hyper_rustls::HttpsConnectorBuilder::new()
3154/// .with_native_roots()
3155/// .unwrap()
3156/// .https_or_http()
3157/// .enable_http2()
3158/// .build()
3159/// );
3160/// let mut hub = Storage::new(client, auth);
3161/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3162/// // like `stop(...)`
3163/// // to build up your call.
3164/// let rb = hub.channels();
3165/// # }
3166/// ```
3167pub struct ChannelMethods<'a, C>
3168where
3169 C: 'a,
3170{
3171 hub: &'a Storage<C>,
3172}
3173
3174impl<'a, C> common::MethodsBuilder for ChannelMethods<'a, C> {}
3175
3176impl<'a, C> ChannelMethods<'a, C> {
3177 /// Create a builder to help you perform the following task:
3178 ///
3179 /// Stop watching resources through this channel
3180 ///
3181 /// # Arguments
3182 ///
3183 /// * `request` - No description provided.
3184 pub fn stop(&self, request: Channel) -> ChannelStopCall<'a, C> {
3185 ChannelStopCall {
3186 hub: self.hub,
3187 _request: request,
3188 _delegate: Default::default(),
3189 _additional_params: Default::default(),
3190 _scopes: Default::default(),
3191 }
3192 }
3193}
3194
3195/// A builder providing access to all methods supported on *defaultObjectAccessControl* resources.
3196/// It is not used directly, but through the [`Storage`] hub.
3197///
3198/// # Example
3199///
3200/// Instantiate a resource builder
3201///
3202/// ```test_harness,no_run
3203/// extern crate hyper;
3204/// extern crate hyper_rustls;
3205/// extern crate google_storage1 as storage1;
3206///
3207/// # async fn dox() {
3208/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3209///
3210/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3211/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3212/// .with_native_roots()
3213/// .unwrap()
3214/// .https_only()
3215/// .enable_http2()
3216/// .build();
3217///
3218/// let executor = hyper_util::rt::TokioExecutor::new();
3219/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3220/// secret,
3221/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3222/// yup_oauth2::client::CustomHyperClientBuilder::from(
3223/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3224/// ),
3225/// ).build().await.unwrap();
3226///
3227/// let client = hyper_util::client::legacy::Client::builder(
3228/// hyper_util::rt::TokioExecutor::new()
3229/// )
3230/// .build(
3231/// hyper_rustls::HttpsConnectorBuilder::new()
3232/// .with_native_roots()
3233/// .unwrap()
3234/// .https_or_http()
3235/// .enable_http2()
3236/// .build()
3237/// );
3238/// let mut hub = Storage::new(client, auth);
3239/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3240/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
3241/// // to build up your call.
3242/// let rb = hub.default_object_access_controls();
3243/// # }
3244/// ```
3245pub struct DefaultObjectAccessControlMethods<'a, C>
3246where
3247 C: 'a,
3248{
3249 hub: &'a Storage<C>,
3250}
3251
3252impl<'a, C> common::MethodsBuilder for DefaultObjectAccessControlMethods<'a, C> {}
3253
3254impl<'a, C> DefaultObjectAccessControlMethods<'a, C> {
3255 /// Create a builder to help you perform the following task:
3256 ///
3257 /// Permanently deletes the default object ACL entry for the specified entity on the specified bucket.
3258 ///
3259 /// # Arguments
3260 ///
3261 /// * `bucket` - Name of a bucket.
3262 /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
3263 pub fn delete(
3264 &self,
3265 bucket: &str,
3266 entity: &str,
3267 ) -> DefaultObjectAccessControlDeleteCall<'a, C> {
3268 DefaultObjectAccessControlDeleteCall {
3269 hub: self.hub,
3270 _bucket: bucket.to_string(),
3271 _entity: entity.to_string(),
3272 _user_project: Default::default(),
3273 _delegate: Default::default(),
3274 _additional_params: Default::default(),
3275 _scopes: Default::default(),
3276 }
3277 }
3278
3279 /// Create a builder to help you perform the following task:
3280 ///
3281 /// Returns the default object ACL entry for the specified entity on the specified bucket.
3282 ///
3283 /// # Arguments
3284 ///
3285 /// * `bucket` - Name of a bucket.
3286 /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
3287 pub fn get(&self, bucket: &str, entity: &str) -> DefaultObjectAccessControlGetCall<'a, C> {
3288 DefaultObjectAccessControlGetCall {
3289 hub: self.hub,
3290 _bucket: bucket.to_string(),
3291 _entity: entity.to_string(),
3292 _user_project: Default::default(),
3293 _delegate: Default::default(),
3294 _additional_params: Default::default(),
3295 _scopes: Default::default(),
3296 }
3297 }
3298
3299 /// Create a builder to help you perform the following task:
3300 ///
3301 /// Creates a new default object ACL entry on the specified bucket.
3302 ///
3303 /// # Arguments
3304 ///
3305 /// * `request` - No description provided.
3306 /// * `bucket` - Name of a bucket.
3307 pub fn insert(
3308 &self,
3309 request: ObjectAccessControl,
3310 bucket: &str,
3311 ) -> DefaultObjectAccessControlInsertCall<'a, C> {
3312 DefaultObjectAccessControlInsertCall {
3313 hub: self.hub,
3314 _request: request,
3315 _bucket: bucket.to_string(),
3316 _user_project: 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 /// Retrieves default object ACL entries on the specified bucket.
3326 ///
3327 /// # Arguments
3328 ///
3329 /// * `bucket` - Name of a bucket.
3330 pub fn list(&self, bucket: &str) -> DefaultObjectAccessControlListCall<'a, C> {
3331 DefaultObjectAccessControlListCall {
3332 hub: self.hub,
3333 _bucket: bucket.to_string(),
3334 _user_project: Default::default(),
3335 _if_metageneration_not_match: Default::default(),
3336 _if_metageneration_match: Default::default(),
3337 _delegate: Default::default(),
3338 _additional_params: Default::default(),
3339 _scopes: Default::default(),
3340 }
3341 }
3342
3343 /// Create a builder to help you perform the following task:
3344 ///
3345 /// Patches a default object ACL entry on the specified bucket.
3346 ///
3347 /// # Arguments
3348 ///
3349 /// * `request` - No description provided.
3350 /// * `bucket` - Name of a bucket.
3351 /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
3352 pub fn patch(
3353 &self,
3354 request: ObjectAccessControl,
3355 bucket: &str,
3356 entity: &str,
3357 ) -> DefaultObjectAccessControlPatchCall<'a, C> {
3358 DefaultObjectAccessControlPatchCall {
3359 hub: self.hub,
3360 _request: request,
3361 _bucket: bucket.to_string(),
3362 _entity: entity.to_string(),
3363 _user_project: Default::default(),
3364 _delegate: Default::default(),
3365 _additional_params: Default::default(),
3366 _scopes: Default::default(),
3367 }
3368 }
3369
3370 /// Create a builder to help you perform the following task:
3371 ///
3372 /// Updates a default object ACL entry on the specified bucket.
3373 ///
3374 /// # Arguments
3375 ///
3376 /// * `request` - No description provided.
3377 /// * `bucket` - Name of a bucket.
3378 /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
3379 pub fn update(
3380 &self,
3381 request: ObjectAccessControl,
3382 bucket: &str,
3383 entity: &str,
3384 ) -> DefaultObjectAccessControlUpdateCall<'a, C> {
3385 DefaultObjectAccessControlUpdateCall {
3386 hub: self.hub,
3387 _request: request,
3388 _bucket: bucket.to_string(),
3389 _entity: entity.to_string(),
3390 _user_project: Default::default(),
3391 _delegate: Default::default(),
3392 _additional_params: Default::default(),
3393 _scopes: Default::default(),
3394 }
3395 }
3396}
3397
3398/// A builder providing access to all methods supported on *folder* resources.
3399/// It is not used directly, but through the [`Storage`] hub.
3400///
3401/// # Example
3402///
3403/// Instantiate a resource builder
3404///
3405/// ```test_harness,no_run
3406/// extern crate hyper;
3407/// extern crate hyper_rustls;
3408/// extern crate google_storage1 as storage1;
3409///
3410/// # async fn dox() {
3411/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3412///
3413/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3414/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3415/// .with_native_roots()
3416/// .unwrap()
3417/// .https_only()
3418/// .enable_http2()
3419/// .build();
3420///
3421/// let executor = hyper_util::rt::TokioExecutor::new();
3422/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3423/// secret,
3424/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3425/// yup_oauth2::client::CustomHyperClientBuilder::from(
3426/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3427/// ),
3428/// ).build().await.unwrap();
3429///
3430/// let client = hyper_util::client::legacy::Client::builder(
3431/// hyper_util::rt::TokioExecutor::new()
3432/// )
3433/// .build(
3434/// hyper_rustls::HttpsConnectorBuilder::new()
3435/// .with_native_roots()
3436/// .unwrap()
3437/// .https_or_http()
3438/// .enable_http2()
3439/// .build()
3440/// );
3441/// let mut hub = Storage::new(client, auth);
3442/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3443/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)` and `rename(...)`
3444/// // to build up your call.
3445/// let rb = hub.folders();
3446/// # }
3447/// ```
3448pub struct FolderMethods<'a, C>
3449where
3450 C: 'a,
3451{
3452 hub: &'a Storage<C>,
3453}
3454
3455impl<'a, C> common::MethodsBuilder for FolderMethods<'a, C> {}
3456
3457impl<'a, C> FolderMethods<'a, C> {
3458 /// Create a builder to help you perform the following task:
3459 ///
3460 /// Permanently deletes a folder. Only applicable to buckets with hierarchical namespace enabled.
3461 ///
3462 /// # Arguments
3463 ///
3464 /// * `bucket` - Name of the bucket in which the folder resides.
3465 /// * `folder` - Name of a folder.
3466 pub fn delete(&self, bucket: &str, folder: &str) -> FolderDeleteCall<'a, C> {
3467 FolderDeleteCall {
3468 hub: self.hub,
3469 _bucket: bucket.to_string(),
3470 _folder: folder.to_string(),
3471 _if_metageneration_not_match: Default::default(),
3472 _if_metageneration_match: Default::default(),
3473 _delegate: Default::default(),
3474 _additional_params: Default::default(),
3475 _scopes: Default::default(),
3476 }
3477 }
3478
3479 /// Create a builder to help you perform the following task:
3480 ///
3481 /// Returns metadata for the specified folder. Only applicable to buckets with hierarchical namespace enabled.
3482 ///
3483 /// # Arguments
3484 ///
3485 /// * `bucket` - Name of the bucket in which the folder resides.
3486 /// * `folder` - Name of a folder.
3487 pub fn get(&self, bucket: &str, folder: &str) -> FolderGetCall<'a, C> {
3488 FolderGetCall {
3489 hub: self.hub,
3490 _bucket: bucket.to_string(),
3491 _folder: folder.to_string(),
3492 _if_metageneration_not_match: Default::default(),
3493 _if_metageneration_match: Default::default(),
3494 _delegate: Default::default(),
3495 _additional_params: Default::default(),
3496 _scopes: Default::default(),
3497 }
3498 }
3499
3500 /// Create a builder to help you perform the following task:
3501 ///
3502 /// Creates a new folder. Only applicable to buckets with hierarchical namespace enabled.
3503 ///
3504 /// # Arguments
3505 ///
3506 /// * `request` - No description provided.
3507 /// * `bucket` - Name of the bucket in which the folder resides.
3508 pub fn insert(&self, request: Folder, bucket: &str) -> FolderInsertCall<'a, C> {
3509 FolderInsertCall {
3510 hub: self.hub,
3511 _request: request,
3512 _bucket: bucket.to_string(),
3513 _recursive: Default::default(),
3514 _delegate: Default::default(),
3515 _additional_params: Default::default(),
3516 _scopes: Default::default(),
3517 }
3518 }
3519
3520 /// Create a builder to help you perform the following task:
3521 ///
3522 /// Retrieves a list of folders matching the criteria. Only applicable to buckets with hierarchical namespace enabled.
3523 ///
3524 /// # Arguments
3525 ///
3526 /// * `bucket` - Name of the bucket in which to look for folders.
3527 pub fn list(&self, bucket: &str) -> FolderListCall<'a, C> {
3528 FolderListCall {
3529 hub: self.hub,
3530 _bucket: bucket.to_string(),
3531 _start_offset: Default::default(),
3532 _prefix: Default::default(),
3533 _page_token: Default::default(),
3534 _page_size: Default::default(),
3535 _end_offset: Default::default(),
3536 _delimiter: Default::default(),
3537 _delegate: Default::default(),
3538 _additional_params: Default::default(),
3539 _scopes: Default::default(),
3540 }
3541 }
3542
3543 /// Create a builder to help you perform the following task:
3544 ///
3545 /// Renames a source folder to a destination folder. Only applicable to buckets with hierarchical namespace enabled.
3546 ///
3547 /// # Arguments
3548 ///
3549 /// * `bucket` - Name of the bucket in which the folders are in.
3550 /// * `sourceFolder` - Name of the source folder.
3551 /// * `destinationFolder` - Name of the destination folder.
3552 pub fn rename(
3553 &self,
3554 bucket: &str,
3555 source_folder: &str,
3556 destination_folder: &str,
3557 ) -> FolderRenameCall<'a, C> {
3558 FolderRenameCall {
3559 hub: self.hub,
3560 _bucket: bucket.to_string(),
3561 _source_folder: source_folder.to_string(),
3562 _destination_folder: destination_folder.to_string(),
3563 _if_source_metageneration_not_match: Default::default(),
3564 _if_source_metageneration_match: Default::default(),
3565 _delegate: Default::default(),
3566 _additional_params: Default::default(),
3567 _scopes: Default::default(),
3568 }
3569 }
3570}
3571
3572/// A builder providing access to all methods supported on *managedFolder* resources.
3573/// It is not used directly, but through the [`Storage`] hub.
3574///
3575/// # Example
3576///
3577/// Instantiate a resource builder
3578///
3579/// ```test_harness,no_run
3580/// extern crate hyper;
3581/// extern crate hyper_rustls;
3582/// extern crate google_storage1 as storage1;
3583///
3584/// # async fn dox() {
3585/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3586///
3587/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3588/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3589/// .with_native_roots()
3590/// .unwrap()
3591/// .https_only()
3592/// .enable_http2()
3593/// .build();
3594///
3595/// let executor = hyper_util::rt::TokioExecutor::new();
3596/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3597/// secret,
3598/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3599/// yup_oauth2::client::CustomHyperClientBuilder::from(
3600/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3601/// ),
3602/// ).build().await.unwrap();
3603///
3604/// let client = hyper_util::client::legacy::Client::builder(
3605/// hyper_util::rt::TokioExecutor::new()
3606/// )
3607/// .build(
3608/// hyper_rustls::HttpsConnectorBuilder::new()
3609/// .with_native_roots()
3610/// .unwrap()
3611/// .https_or_http()
3612/// .enable_http2()
3613/// .build()
3614/// );
3615/// let mut hub = Storage::new(client, auth);
3616/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3617/// // like `delete(...)`, `get(...)`, `get_iam_policy(...)`, `insert(...)`, `list(...)`, `set_iam_policy(...)` and `test_iam_permissions(...)`
3618/// // to build up your call.
3619/// let rb = hub.managed_folders();
3620/// # }
3621/// ```
3622pub struct ManagedFolderMethods<'a, C>
3623where
3624 C: 'a,
3625{
3626 hub: &'a Storage<C>,
3627}
3628
3629impl<'a, C> common::MethodsBuilder for ManagedFolderMethods<'a, C> {}
3630
3631impl<'a, C> ManagedFolderMethods<'a, C> {
3632 /// Create a builder to help you perform the following task:
3633 ///
3634 /// Permanently deletes a managed folder.
3635 ///
3636 /// # Arguments
3637 ///
3638 /// * `bucket` - Name of the bucket containing the managed folder.
3639 /// * `managedFolder` - The managed folder name/path.
3640 pub fn delete(&self, bucket: &str, managed_folder: &str) -> ManagedFolderDeleteCall<'a, C> {
3641 ManagedFolderDeleteCall {
3642 hub: self.hub,
3643 _bucket: bucket.to_string(),
3644 _managed_folder: managed_folder.to_string(),
3645 _if_metageneration_not_match: Default::default(),
3646 _if_metageneration_match: Default::default(),
3647 _allow_non_empty: Default::default(),
3648 _delegate: Default::default(),
3649 _additional_params: Default::default(),
3650 _scopes: Default::default(),
3651 }
3652 }
3653
3654 /// Create a builder to help you perform the following task:
3655 ///
3656 /// Returns metadata of the specified managed folder.
3657 ///
3658 /// # Arguments
3659 ///
3660 /// * `bucket` - Name of the bucket containing the managed folder.
3661 /// * `managedFolder` - The managed folder name/path.
3662 pub fn get(&self, bucket: &str, managed_folder: &str) -> ManagedFolderGetCall<'a, C> {
3663 ManagedFolderGetCall {
3664 hub: self.hub,
3665 _bucket: bucket.to_string(),
3666 _managed_folder: managed_folder.to_string(),
3667 _if_metageneration_not_match: Default::default(),
3668 _if_metageneration_match: Default::default(),
3669 _delegate: Default::default(),
3670 _additional_params: Default::default(),
3671 _scopes: Default::default(),
3672 }
3673 }
3674
3675 /// Create a builder to help you perform the following task:
3676 ///
3677 /// Returns an IAM policy for the specified managed folder.
3678 ///
3679 /// # Arguments
3680 ///
3681 /// * `bucket` - Name of the bucket containing the managed folder.
3682 /// * `managedFolder` - The managed folder name/path.
3683 pub fn get_iam_policy(
3684 &self,
3685 bucket: &str,
3686 managed_folder: &str,
3687 ) -> ManagedFolderGetIamPolicyCall<'a, C> {
3688 ManagedFolderGetIamPolicyCall {
3689 hub: self.hub,
3690 _bucket: bucket.to_string(),
3691 _managed_folder: managed_folder.to_string(),
3692 _user_project: Default::default(),
3693 _options_requested_policy_version: Default::default(),
3694 _delegate: Default::default(),
3695 _additional_params: Default::default(),
3696 _scopes: Default::default(),
3697 }
3698 }
3699
3700 /// Create a builder to help you perform the following task:
3701 ///
3702 /// Creates a new managed folder.
3703 ///
3704 /// # Arguments
3705 ///
3706 /// * `request` - No description provided.
3707 /// * `bucket` - Name of the bucket containing the managed folder.
3708 pub fn insert(&self, request: ManagedFolder, bucket: &str) -> ManagedFolderInsertCall<'a, C> {
3709 ManagedFolderInsertCall {
3710 hub: self.hub,
3711 _request: request,
3712 _bucket: bucket.to_string(),
3713 _delegate: Default::default(),
3714 _additional_params: Default::default(),
3715 _scopes: Default::default(),
3716 }
3717 }
3718
3719 /// Create a builder to help you perform the following task:
3720 ///
3721 /// Lists managed folders in the given bucket.
3722 ///
3723 /// # Arguments
3724 ///
3725 /// * `bucket` - Name of the bucket containing the managed folder.
3726 pub fn list(&self, bucket: &str) -> ManagedFolderListCall<'a, C> {
3727 ManagedFolderListCall {
3728 hub: self.hub,
3729 _bucket: bucket.to_string(),
3730 _prefix: Default::default(),
3731 _page_token: Default::default(),
3732 _page_size: Default::default(),
3733 _delegate: Default::default(),
3734 _additional_params: Default::default(),
3735 _scopes: Default::default(),
3736 }
3737 }
3738
3739 /// Create a builder to help you perform the following task:
3740 ///
3741 /// Updates an IAM policy for the specified managed folder.
3742 ///
3743 /// # Arguments
3744 ///
3745 /// * `request` - No description provided.
3746 /// * `bucket` - Name of the bucket containing the managed folder.
3747 /// * `managedFolder` - The managed folder name/path.
3748 pub fn set_iam_policy(
3749 &self,
3750 request: Policy,
3751 bucket: &str,
3752 managed_folder: &str,
3753 ) -> ManagedFolderSetIamPolicyCall<'a, C> {
3754 ManagedFolderSetIamPolicyCall {
3755 hub: self.hub,
3756 _request: request,
3757 _bucket: bucket.to_string(),
3758 _managed_folder: managed_folder.to_string(),
3759 _user_project: Default::default(),
3760 _delegate: Default::default(),
3761 _additional_params: Default::default(),
3762 _scopes: Default::default(),
3763 }
3764 }
3765
3766 /// Create a builder to help you perform the following task:
3767 ///
3768 /// Tests a set of permissions on the given managed folder to see which, if any, are held by the caller.
3769 ///
3770 /// # Arguments
3771 ///
3772 /// * `bucket` - Name of the bucket containing the managed folder.
3773 /// * `managedFolder` - The managed folder name/path.
3774 /// * `permissions` - Permissions to test.
3775 pub fn test_iam_permissions(
3776 &self,
3777 bucket: &str,
3778 managed_folder: &str,
3779 permissions: &Vec<String>,
3780 ) -> ManagedFolderTestIamPermissionCall<'a, C> {
3781 ManagedFolderTestIamPermissionCall {
3782 hub: self.hub,
3783 _bucket: bucket.to_string(),
3784 _managed_folder: managed_folder.to_string(),
3785 _permissions: permissions.clone(),
3786 _user_project: Default::default(),
3787 _delegate: Default::default(),
3788 _additional_params: Default::default(),
3789 _scopes: Default::default(),
3790 }
3791 }
3792}
3793
3794/// A builder providing access to all methods supported on *notification* resources.
3795/// It is not used directly, but through the [`Storage`] hub.
3796///
3797/// # Example
3798///
3799/// Instantiate a resource builder
3800///
3801/// ```test_harness,no_run
3802/// extern crate hyper;
3803/// extern crate hyper_rustls;
3804/// extern crate google_storage1 as storage1;
3805///
3806/// # async fn dox() {
3807/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3808///
3809/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3810/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3811/// .with_native_roots()
3812/// .unwrap()
3813/// .https_only()
3814/// .enable_http2()
3815/// .build();
3816///
3817/// let executor = hyper_util::rt::TokioExecutor::new();
3818/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3819/// secret,
3820/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3821/// yup_oauth2::client::CustomHyperClientBuilder::from(
3822/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3823/// ),
3824/// ).build().await.unwrap();
3825///
3826/// let client = hyper_util::client::legacy::Client::builder(
3827/// hyper_util::rt::TokioExecutor::new()
3828/// )
3829/// .build(
3830/// hyper_rustls::HttpsConnectorBuilder::new()
3831/// .with_native_roots()
3832/// .unwrap()
3833/// .https_or_http()
3834/// .enable_http2()
3835/// .build()
3836/// );
3837/// let mut hub = Storage::new(client, auth);
3838/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3839/// // like `delete(...)`, `get(...)`, `insert(...)` and `list(...)`
3840/// // to build up your call.
3841/// let rb = hub.notifications();
3842/// # }
3843/// ```
3844pub struct NotificationMethods<'a, C>
3845where
3846 C: 'a,
3847{
3848 hub: &'a Storage<C>,
3849}
3850
3851impl<'a, C> common::MethodsBuilder for NotificationMethods<'a, C> {}
3852
3853impl<'a, C> NotificationMethods<'a, C> {
3854 /// Create a builder to help you perform the following task:
3855 ///
3856 /// Permanently deletes a notification subscription.
3857 ///
3858 /// # Arguments
3859 ///
3860 /// * `bucket` - The parent bucket of the notification.
3861 /// * `notification` - ID of the notification to delete.
3862 pub fn delete(&self, bucket: &str, notification: &str) -> NotificationDeleteCall<'a, C> {
3863 NotificationDeleteCall {
3864 hub: self.hub,
3865 _bucket: bucket.to_string(),
3866 _notification: notification.to_string(),
3867 _user_project: Default::default(),
3868 _delegate: Default::default(),
3869 _additional_params: Default::default(),
3870 _scopes: Default::default(),
3871 }
3872 }
3873
3874 /// Create a builder to help you perform the following task:
3875 ///
3876 /// View a notification configuration.
3877 ///
3878 /// # Arguments
3879 ///
3880 /// * `bucket` - The parent bucket of the notification.
3881 /// * `notification` - Notification ID
3882 pub fn get(&self, bucket: &str, notification: &str) -> NotificationGetCall<'a, C> {
3883 NotificationGetCall {
3884 hub: self.hub,
3885 _bucket: bucket.to_string(),
3886 _notification: notification.to_string(),
3887 _user_project: Default::default(),
3888 _delegate: Default::default(),
3889 _additional_params: Default::default(),
3890 _scopes: Default::default(),
3891 }
3892 }
3893
3894 /// Create a builder to help you perform the following task:
3895 ///
3896 /// Creates a notification subscription for a given bucket.
3897 ///
3898 /// # Arguments
3899 ///
3900 /// * `request` - No description provided.
3901 /// * `bucket` - The parent bucket of the notification.
3902 pub fn insert(&self, request: Notification, bucket: &str) -> NotificationInsertCall<'a, C> {
3903 NotificationInsertCall {
3904 hub: self.hub,
3905 _request: request,
3906 _bucket: bucket.to_string(),
3907 _user_project: Default::default(),
3908 _delegate: Default::default(),
3909 _additional_params: Default::default(),
3910 _scopes: Default::default(),
3911 }
3912 }
3913
3914 /// Create a builder to help you perform the following task:
3915 ///
3916 /// Retrieves a list of notification subscriptions for a given bucket.
3917 ///
3918 /// # Arguments
3919 ///
3920 /// * `bucket` - Name of a Google Cloud Storage bucket.
3921 pub fn list(&self, bucket: &str) -> NotificationListCall<'a, C> {
3922 NotificationListCall {
3923 hub: self.hub,
3924 _bucket: bucket.to_string(),
3925 _user_project: Default::default(),
3926 _delegate: Default::default(),
3927 _additional_params: Default::default(),
3928 _scopes: Default::default(),
3929 }
3930 }
3931}
3932
3933/// A builder providing access to all methods supported on *objectAccessControl* resources.
3934/// It is not used directly, but through the [`Storage`] hub.
3935///
3936/// # Example
3937///
3938/// Instantiate a resource builder
3939///
3940/// ```test_harness,no_run
3941/// extern crate hyper;
3942/// extern crate hyper_rustls;
3943/// extern crate google_storage1 as storage1;
3944///
3945/// # async fn dox() {
3946/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3947///
3948/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3949/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3950/// .with_native_roots()
3951/// .unwrap()
3952/// .https_only()
3953/// .enable_http2()
3954/// .build();
3955///
3956/// let executor = hyper_util::rt::TokioExecutor::new();
3957/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3958/// secret,
3959/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3960/// yup_oauth2::client::CustomHyperClientBuilder::from(
3961/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3962/// ),
3963/// ).build().await.unwrap();
3964///
3965/// let client = hyper_util::client::legacy::Client::builder(
3966/// hyper_util::rt::TokioExecutor::new()
3967/// )
3968/// .build(
3969/// hyper_rustls::HttpsConnectorBuilder::new()
3970/// .with_native_roots()
3971/// .unwrap()
3972/// .https_or_http()
3973/// .enable_http2()
3974/// .build()
3975/// );
3976/// let mut hub = Storage::new(client, auth);
3977/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3978/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
3979/// // to build up your call.
3980/// let rb = hub.object_access_controls();
3981/// # }
3982/// ```
3983pub struct ObjectAccessControlMethods<'a, C>
3984where
3985 C: 'a,
3986{
3987 hub: &'a Storage<C>,
3988}
3989
3990impl<'a, C> common::MethodsBuilder for ObjectAccessControlMethods<'a, C> {}
3991
3992impl<'a, C> ObjectAccessControlMethods<'a, C> {
3993 /// Create a builder to help you perform the following task:
3994 ///
3995 /// Permanently deletes the ACL entry for the specified entity on the specified object.
3996 ///
3997 /// # Arguments
3998 ///
3999 /// * `bucket` - Name of a bucket.
4000 /// * `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).
4001 /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
4002 pub fn delete(
4003 &self,
4004 bucket: &str,
4005 object: &str,
4006 entity: &str,
4007 ) -> ObjectAccessControlDeleteCall<'a, C> {
4008 ObjectAccessControlDeleteCall {
4009 hub: self.hub,
4010 _bucket: bucket.to_string(),
4011 _object: object.to_string(),
4012 _entity: entity.to_string(),
4013 _user_project: Default::default(),
4014 _generation: Default::default(),
4015 _delegate: Default::default(),
4016 _additional_params: Default::default(),
4017 _scopes: Default::default(),
4018 }
4019 }
4020
4021 /// Create a builder to help you perform the following task:
4022 ///
4023 /// Returns the ACL entry for the specified entity on the specified object.
4024 ///
4025 /// # Arguments
4026 ///
4027 /// * `bucket` - Name of a bucket.
4028 /// * `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).
4029 /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
4030 pub fn get(
4031 &self,
4032 bucket: &str,
4033 object: &str,
4034 entity: &str,
4035 ) -> ObjectAccessControlGetCall<'a, C> {
4036 ObjectAccessControlGetCall {
4037 hub: self.hub,
4038 _bucket: bucket.to_string(),
4039 _object: object.to_string(),
4040 _entity: entity.to_string(),
4041 _user_project: Default::default(),
4042 _generation: Default::default(),
4043 _delegate: Default::default(),
4044 _additional_params: Default::default(),
4045 _scopes: Default::default(),
4046 }
4047 }
4048
4049 /// Create a builder to help you perform the following task:
4050 ///
4051 /// Creates a new ACL entry on the specified object.
4052 ///
4053 /// # Arguments
4054 ///
4055 /// * `request` - No description provided.
4056 /// * `bucket` - Name of a bucket.
4057 /// * `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).
4058 pub fn insert(
4059 &self,
4060 request: ObjectAccessControl,
4061 bucket: &str,
4062 object: &str,
4063 ) -> ObjectAccessControlInsertCall<'a, C> {
4064 ObjectAccessControlInsertCall {
4065 hub: self.hub,
4066 _request: request,
4067 _bucket: bucket.to_string(),
4068 _object: object.to_string(),
4069 _user_project: Default::default(),
4070 _generation: Default::default(),
4071 _delegate: Default::default(),
4072 _additional_params: Default::default(),
4073 _scopes: Default::default(),
4074 }
4075 }
4076
4077 /// Create a builder to help you perform the following task:
4078 ///
4079 /// Retrieves ACL entries on the specified object.
4080 ///
4081 /// # Arguments
4082 ///
4083 /// * `bucket` - Name of a bucket.
4084 /// * `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).
4085 pub fn list(&self, bucket: &str, object: &str) -> ObjectAccessControlListCall<'a, C> {
4086 ObjectAccessControlListCall {
4087 hub: self.hub,
4088 _bucket: bucket.to_string(),
4089 _object: object.to_string(),
4090 _user_project: Default::default(),
4091 _generation: Default::default(),
4092 _delegate: Default::default(),
4093 _additional_params: Default::default(),
4094 _scopes: Default::default(),
4095 }
4096 }
4097
4098 /// Create a builder to help you perform the following task:
4099 ///
4100 /// Patches an ACL entry on the specified object.
4101 ///
4102 /// # Arguments
4103 ///
4104 /// * `request` - No description provided.
4105 /// * `bucket` - Name of a bucket.
4106 /// * `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).
4107 /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
4108 pub fn patch(
4109 &self,
4110 request: ObjectAccessControl,
4111 bucket: &str,
4112 object: &str,
4113 entity: &str,
4114 ) -> ObjectAccessControlPatchCall<'a, C> {
4115 ObjectAccessControlPatchCall {
4116 hub: self.hub,
4117 _request: request,
4118 _bucket: bucket.to_string(),
4119 _object: object.to_string(),
4120 _entity: entity.to_string(),
4121 _user_project: Default::default(),
4122 _generation: Default::default(),
4123 _delegate: Default::default(),
4124 _additional_params: Default::default(),
4125 _scopes: Default::default(),
4126 }
4127 }
4128
4129 /// Create a builder to help you perform the following task:
4130 ///
4131 /// Updates an ACL entry on the specified object.
4132 ///
4133 /// # Arguments
4134 ///
4135 /// * `request` - No description provided.
4136 /// * `bucket` - Name of a bucket.
4137 /// * `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).
4138 /// * `entity` - The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
4139 pub fn update(
4140 &self,
4141 request: ObjectAccessControl,
4142 bucket: &str,
4143 object: &str,
4144 entity: &str,
4145 ) -> ObjectAccessControlUpdateCall<'a, C> {
4146 ObjectAccessControlUpdateCall {
4147 hub: self.hub,
4148 _request: request,
4149 _bucket: bucket.to_string(),
4150 _object: object.to_string(),
4151 _entity: entity.to_string(),
4152 _user_project: Default::default(),
4153 _generation: Default::default(),
4154 _delegate: Default::default(),
4155 _additional_params: Default::default(),
4156 _scopes: Default::default(),
4157 }
4158 }
4159}
4160
4161/// A builder providing access to all methods supported on *object* resources.
4162/// It is not used directly, but through the [`Storage`] hub.
4163///
4164/// # Example
4165///
4166/// Instantiate a resource builder
4167///
4168/// ```test_harness,no_run
4169/// extern crate hyper;
4170/// extern crate hyper_rustls;
4171/// extern crate google_storage1 as storage1;
4172///
4173/// # async fn dox() {
4174/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4175///
4176/// let secret: yup_oauth2::ApplicationSecret = Default::default();
4177/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
4178/// .with_native_roots()
4179/// .unwrap()
4180/// .https_only()
4181/// .enable_http2()
4182/// .build();
4183///
4184/// let executor = hyper_util::rt::TokioExecutor::new();
4185/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4186/// secret,
4187/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4188/// yup_oauth2::client::CustomHyperClientBuilder::from(
4189/// hyper_util::client::legacy::Client::builder(executor).build(connector),
4190/// ),
4191/// ).build().await.unwrap();
4192///
4193/// let client = hyper_util::client::legacy::Client::builder(
4194/// hyper_util::rt::TokioExecutor::new()
4195/// )
4196/// .build(
4197/// hyper_rustls::HttpsConnectorBuilder::new()
4198/// .with_native_roots()
4199/// .unwrap()
4200/// .https_or_http()
4201/// .enable_http2()
4202/// .build()
4203/// );
4204/// let mut hub = Storage::new(client, auth);
4205/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4206/// // like `bulk_restore(...)`, `compose(...)`, `copy(...)`, `delete(...)`, `get(...)`, `get_iam_policy(...)`, `insert(...)`, `list(...)`, `move_(...)`, `patch(...)`, `restore(...)`, `rewrite(...)`, `set_iam_policy(...)`, `test_iam_permissions(...)`, `update(...)` and `watch_all(...)`
4207/// // to build up your call.
4208/// let rb = hub.objects();
4209/// # }
4210/// ```
4211pub struct ObjectMethods<'a, C>
4212where
4213 C: 'a,
4214{
4215 hub: &'a Storage<C>,
4216}
4217
4218impl<'a, C> common::MethodsBuilder for ObjectMethods<'a, C> {}
4219
4220impl<'a, C> ObjectMethods<'a, C> {
4221 /// Create a builder to help you perform the following task:
4222 ///
4223 /// Initiates a long-running bulk restore operation on the specified bucket.
4224 ///
4225 /// # Arguments
4226 ///
4227 /// * `request` - No description provided.
4228 /// * `bucket` - Name of the bucket in which the object resides.
4229 pub fn bulk_restore(
4230 &self,
4231 request: BulkRestoreObjectsRequest,
4232 bucket: &str,
4233 ) -> ObjectBulkRestoreCall<'a, C> {
4234 ObjectBulkRestoreCall {
4235 hub: self.hub,
4236 _request: request,
4237 _bucket: bucket.to_string(),
4238 _delegate: Default::default(),
4239 _additional_params: Default::default(),
4240 _scopes: Default::default(),
4241 }
4242 }
4243
4244 /// Create a builder to help you perform the following task:
4245 ///
4246 /// Concatenates a list of existing objects into a new object in the same bucket.
4247 ///
4248 /// # Arguments
4249 ///
4250 /// * `request` - No description provided.
4251 /// * `destinationBucket` - Name of the bucket containing the source objects. The destination object is stored in this bucket.
4252 /// * `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).
4253 pub fn compose(
4254 &self,
4255 request: ComposeRequest,
4256 destination_bucket: &str,
4257 destination_object: &str,
4258 ) -> ObjectComposeCall<'a, C> {
4259 ObjectComposeCall {
4260 hub: self.hub,
4261 _request: request,
4262 _destination_bucket: destination_bucket.to_string(),
4263 _destination_object: destination_object.to_string(),
4264 _user_project: Default::default(),
4265 _kms_key_name: Default::default(),
4266 _if_metageneration_match: Default::default(),
4267 _if_generation_match: Default::default(),
4268 _destination_predefined_acl: Default::default(),
4269 _delegate: Default::default(),
4270 _additional_params: Default::default(),
4271 _scopes: Default::default(),
4272 }
4273 }
4274
4275 /// Create a builder to help you perform the following task:
4276 ///
4277 /// Copies a source object to a destination object. Optionally overrides metadata.
4278 ///
4279 /// # Arguments
4280 ///
4281 /// * `request` - No description provided.
4282 /// * `sourceBucket` - Name of the bucket in which to find the source object.
4283 /// * `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).
4284 /// * `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).
4285 /// * `destinationObject` - Name of the new object. Required when the object metadata is not otherwise provided. Overrides the object metadata's name value, if any.
4286 pub fn copy(
4287 &self,
4288 request: Object,
4289 source_bucket: &str,
4290 source_object: &str,
4291 destination_bucket: &str,
4292 destination_object: &str,
4293 ) -> ObjectCopyCall<'a, C> {
4294 ObjectCopyCall {
4295 hub: self.hub,
4296 _request: request,
4297 _source_bucket: source_bucket.to_string(),
4298 _source_object: source_object.to_string(),
4299 _destination_bucket: destination_bucket.to_string(),
4300 _destination_object: destination_object.to_string(),
4301 _user_project: Default::default(),
4302 _source_generation: Default::default(),
4303 _projection: Default::default(),
4304 _if_source_metageneration_not_match: Default::default(),
4305 _if_source_metageneration_match: Default::default(),
4306 _if_source_generation_not_match: Default::default(),
4307 _if_source_generation_match: Default::default(),
4308 _if_metageneration_not_match: Default::default(),
4309 _if_metageneration_match: Default::default(),
4310 _if_generation_not_match: Default::default(),
4311 _if_generation_match: Default::default(),
4312 _destination_predefined_acl: Default::default(),
4313 _destination_kms_key_name: Default::default(),
4314 _delegate: Default::default(),
4315 _additional_params: Default::default(),
4316 _scopes: Default::default(),
4317 }
4318 }
4319
4320 /// Create a builder to help you perform the following task:
4321 ///
4322 /// Deletes an object and its metadata. Deletions are permanent if versioning is not enabled for the bucket, or if the generation parameter is used.
4323 ///
4324 /// # Arguments
4325 ///
4326 /// * `bucket` - Name of the bucket in which the object resides.
4327 /// * `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).
4328 pub fn delete(&self, bucket: &str, object: &str) -> ObjectDeleteCall<'a, C> {
4329 ObjectDeleteCall {
4330 hub: self.hub,
4331 _bucket: bucket.to_string(),
4332 _object: object.to_string(),
4333 _user_project: Default::default(),
4334 _if_metageneration_not_match: Default::default(),
4335 _if_metageneration_match: Default::default(),
4336 _if_generation_not_match: Default::default(),
4337 _if_generation_match: Default::default(),
4338 _generation: Default::default(),
4339 _delegate: Default::default(),
4340 _additional_params: Default::default(),
4341 _scopes: Default::default(),
4342 }
4343 }
4344
4345 /// Create a builder to help you perform the following task:
4346 ///
4347 /// Retrieves an object or its metadata.
4348 ///
4349 /// # Arguments
4350 ///
4351 /// * `bucket` - Name of the bucket in which the object resides.
4352 /// * `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).
4353 pub fn get(&self, bucket: &str, object: &str) -> ObjectGetCall<'a, C> {
4354 ObjectGetCall {
4355 hub: self.hub,
4356 _bucket: bucket.to_string(),
4357 _object: object.to_string(),
4358 _user_project: Default::default(),
4359 _soft_deleted: Default::default(),
4360 _restore_token: Default::default(),
4361 _projection: Default::default(),
4362 _if_metageneration_not_match: Default::default(),
4363 _if_metageneration_match: Default::default(),
4364 _if_generation_not_match: Default::default(),
4365 _if_generation_match: Default::default(),
4366 _generation: Default::default(),
4367 _delegate: Default::default(),
4368 _additional_params: Default::default(),
4369 _scopes: Default::default(),
4370 }
4371 }
4372
4373 /// Create a builder to help you perform the following task:
4374 ///
4375 /// Returns an IAM policy for the specified object.
4376 ///
4377 /// # Arguments
4378 ///
4379 /// * `bucket` - Name of the bucket in which the object resides.
4380 /// * `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).
4381 pub fn get_iam_policy(&self, bucket: &str, object: &str) -> ObjectGetIamPolicyCall<'a, C> {
4382 ObjectGetIamPolicyCall {
4383 hub: self.hub,
4384 _bucket: bucket.to_string(),
4385 _object: object.to_string(),
4386 _user_project: Default::default(),
4387 _generation: Default::default(),
4388 _delegate: Default::default(),
4389 _additional_params: Default::default(),
4390 _scopes: Default::default(),
4391 }
4392 }
4393
4394 /// Create a builder to help you perform the following task:
4395 ///
4396 /// Stores a new object and metadata.
4397 ///
4398 /// # Arguments
4399 ///
4400 /// * `request` - No description provided.
4401 /// * `bucket` - Name of the bucket in which to store the new object. Overrides the provided object metadata's bucket value, if any.
4402 pub fn insert(&self, request: Object, bucket: &str) -> ObjectInsertCall<'a, C> {
4403 ObjectInsertCall {
4404 hub: self.hub,
4405 _request: request,
4406 _bucket: bucket.to_string(),
4407 _user_project: Default::default(),
4408 _projection: Default::default(),
4409 _predefined_acl: Default::default(),
4410 _name: Default::default(),
4411 _kms_key_name: Default::default(),
4412 _if_metageneration_not_match: Default::default(),
4413 _if_metageneration_match: Default::default(),
4414 _if_generation_not_match: Default::default(),
4415 _if_generation_match: Default::default(),
4416 _content_encoding: Default::default(),
4417 _delegate: Default::default(),
4418 _additional_params: Default::default(),
4419 _scopes: Default::default(),
4420 }
4421 }
4422
4423 /// Create a builder to help you perform the following task:
4424 ///
4425 /// Retrieves a list of objects matching the criteria.
4426 ///
4427 /// # Arguments
4428 ///
4429 /// * `bucket` - Name of the bucket in which to look for objects.
4430 pub fn list(&self, bucket: &str) -> ObjectListCall<'a, C> {
4431 ObjectListCall {
4432 hub: self.hub,
4433 _bucket: bucket.to_string(),
4434 _versions: Default::default(),
4435 _user_project: Default::default(),
4436 _start_offset: Default::default(),
4437 _soft_deleted: Default::default(),
4438 _projection: Default::default(),
4439 _prefix: Default::default(),
4440 _page_token: Default::default(),
4441 _max_results: Default::default(),
4442 _match_glob: Default::default(),
4443 _include_trailing_delimiter: Default::default(),
4444 _include_folders_as_prefixes: Default::default(),
4445 _filter: Default::default(),
4446 _end_offset: Default::default(),
4447 _delimiter: Default::default(),
4448 _delegate: Default::default(),
4449 _additional_params: Default::default(),
4450 _scopes: Default::default(),
4451 }
4452 }
4453
4454 /// Create a builder to help you perform the following task:
4455 ///
4456 /// Moves the source object to the destination object in the same bucket.
4457 ///
4458 /// # Arguments
4459 ///
4460 /// * `bucket` - Name of the bucket in which the object resides.
4461 /// * `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).
4462 /// * `destinationObject` - Name of the destination 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).
4463 pub fn move_(
4464 &self,
4465 bucket: &str,
4466 source_object: &str,
4467 destination_object: &str,
4468 ) -> ObjectMoveCall<'a, C> {
4469 ObjectMoveCall {
4470 hub: self.hub,
4471 _bucket: bucket.to_string(),
4472 _source_object: source_object.to_string(),
4473 _destination_object: destination_object.to_string(),
4474 _user_project: Default::default(),
4475 _projection: Default::default(),
4476 _if_source_metageneration_not_match: Default::default(),
4477 _if_source_metageneration_match: Default::default(),
4478 _if_source_generation_not_match: Default::default(),
4479 _if_source_generation_match: Default::default(),
4480 _if_metageneration_not_match: Default::default(),
4481 _if_metageneration_match: Default::default(),
4482 _if_generation_not_match: Default::default(),
4483 _if_generation_match: Default::default(),
4484 _delegate: Default::default(),
4485 _additional_params: Default::default(),
4486 _scopes: Default::default(),
4487 }
4488 }
4489
4490 /// Create a builder to help you perform the following task:
4491 ///
4492 /// Patches an object's metadata.
4493 ///
4494 /// # Arguments
4495 ///
4496 /// * `request` - No description provided.
4497 /// * `bucket` - Name of the bucket in which the object resides.
4498 /// * `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).
4499 pub fn patch(&self, request: Object, bucket: &str, object: &str) -> ObjectPatchCall<'a, C> {
4500 ObjectPatchCall {
4501 hub: self.hub,
4502 _request: request,
4503 _bucket: bucket.to_string(),
4504 _object: object.to_string(),
4505 _user_project: Default::default(),
4506 _projection: Default::default(),
4507 _predefined_acl: Default::default(),
4508 _override_unlocked_retention: Default::default(),
4509 _if_metageneration_not_match: Default::default(),
4510 _if_metageneration_match: Default::default(),
4511 _if_generation_not_match: Default::default(),
4512 _if_generation_match: Default::default(),
4513 _generation: Default::default(),
4514 _delegate: Default::default(),
4515 _additional_params: Default::default(),
4516 _scopes: Default::default(),
4517 }
4518 }
4519
4520 /// Create a builder to help you perform the following task:
4521 ///
4522 /// Restores a soft-deleted object.
4523 ///
4524 /// # Arguments
4525 ///
4526 /// * `bucket` - Name of the bucket in which the object resides.
4527 /// * `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).
4528 /// * `generation` - Selects a specific revision of this object.
4529 pub fn restore(&self, bucket: &str, object: &str, generation: i64) -> ObjectRestoreCall<'a, C> {
4530 ObjectRestoreCall {
4531 hub: self.hub,
4532 _bucket: bucket.to_string(),
4533 _object: object.to_string(),
4534 _generation: generation,
4535 _user_project: Default::default(),
4536 _restore_token: Default::default(),
4537 _projection: Default::default(),
4538 _if_metageneration_not_match: Default::default(),
4539 _if_metageneration_match: Default::default(),
4540 _if_generation_not_match: Default::default(),
4541 _if_generation_match: Default::default(),
4542 _copy_source_acl: Default::default(),
4543 _delegate: Default::default(),
4544 _additional_params: Default::default(),
4545 _scopes: Default::default(),
4546 }
4547 }
4548
4549 /// Create a builder to help you perform the following task:
4550 ///
4551 /// Rewrites a source object to a destination object. Optionally overrides metadata.
4552 ///
4553 /// # Arguments
4554 ///
4555 /// * `request` - No description provided.
4556 /// * `sourceBucket` - Name of the bucket in which to find the source object.
4557 /// * `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).
4558 /// * `destinationBucket` - Name of the bucket in which to store the new object. Overrides the provided object metadata's bucket value, if any.
4559 /// * `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).
4560 pub fn rewrite(
4561 &self,
4562 request: Object,
4563 source_bucket: &str,
4564 source_object: &str,
4565 destination_bucket: &str,
4566 destination_object: &str,
4567 ) -> ObjectRewriteCall<'a, C> {
4568 ObjectRewriteCall {
4569 hub: self.hub,
4570 _request: request,
4571 _source_bucket: source_bucket.to_string(),
4572 _source_object: source_object.to_string(),
4573 _destination_bucket: destination_bucket.to_string(),
4574 _destination_object: destination_object.to_string(),
4575 _user_project: Default::default(),
4576 _source_generation: Default::default(),
4577 _rewrite_token: Default::default(),
4578 _projection: Default::default(),
4579 _max_bytes_rewritten_per_call: Default::default(),
4580 _if_source_metageneration_not_match: Default::default(),
4581 _if_source_metageneration_match: Default::default(),
4582 _if_source_generation_not_match: Default::default(),
4583 _if_source_generation_match: Default::default(),
4584 _if_metageneration_not_match: Default::default(),
4585 _if_metageneration_match: Default::default(),
4586 _if_generation_not_match: Default::default(),
4587 _if_generation_match: Default::default(),
4588 _destination_predefined_acl: Default::default(),
4589 _destination_kms_key_name: Default::default(),
4590 _delegate: Default::default(),
4591 _additional_params: Default::default(),
4592 _scopes: Default::default(),
4593 }
4594 }
4595
4596 /// Create a builder to help you perform the following task:
4597 ///
4598 /// Updates an IAM policy for the specified object.
4599 ///
4600 /// # Arguments
4601 ///
4602 /// * `request` - No description provided.
4603 /// * `bucket` - Name of the bucket in which the object resides.
4604 /// * `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).
4605 pub fn set_iam_policy(
4606 &self,
4607 request: Policy,
4608 bucket: &str,
4609 object: &str,
4610 ) -> ObjectSetIamPolicyCall<'a, C> {
4611 ObjectSetIamPolicyCall {
4612 hub: self.hub,
4613 _request: request,
4614 _bucket: bucket.to_string(),
4615 _object: object.to_string(),
4616 _user_project: Default::default(),
4617 _generation: Default::default(),
4618 _delegate: Default::default(),
4619 _additional_params: Default::default(),
4620 _scopes: Default::default(),
4621 }
4622 }
4623
4624 /// Create a builder to help you perform the following task:
4625 ///
4626 /// Tests a set of permissions on the given object to see which, if any, are held by the caller.
4627 ///
4628 /// # Arguments
4629 ///
4630 /// * `bucket` - Name of the bucket in which the object resides.
4631 /// * `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).
4632 /// * `permissions` - Permissions to test.
4633 pub fn test_iam_permissions(
4634 &self,
4635 bucket: &str,
4636 object: &str,
4637 permissions: &Vec<String>,
4638 ) -> ObjectTestIamPermissionCall<'a, C> {
4639 ObjectTestIamPermissionCall {
4640 hub: self.hub,
4641 _bucket: bucket.to_string(),
4642 _object: object.to_string(),
4643 _permissions: permissions.clone(),
4644 _user_project: Default::default(),
4645 _generation: Default::default(),
4646 _delegate: Default::default(),
4647 _additional_params: Default::default(),
4648 _scopes: Default::default(),
4649 }
4650 }
4651
4652 /// Create a builder to help you perform the following task:
4653 ///
4654 /// Updates an object's metadata.
4655 ///
4656 /// # Arguments
4657 ///
4658 /// * `request` - No description provided.
4659 /// * `bucket` - Name of the bucket in which the object resides.
4660 /// * `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).
4661 pub fn update(&self, request: Object, bucket: &str, object: &str) -> ObjectUpdateCall<'a, C> {
4662 ObjectUpdateCall {
4663 hub: self.hub,
4664 _request: request,
4665 _bucket: bucket.to_string(),
4666 _object: object.to_string(),
4667 _user_project: Default::default(),
4668 _projection: Default::default(),
4669 _predefined_acl: Default::default(),
4670 _override_unlocked_retention: Default::default(),
4671 _if_metageneration_not_match: Default::default(),
4672 _if_metageneration_match: Default::default(),
4673 _if_generation_not_match: Default::default(),
4674 _if_generation_match: Default::default(),
4675 _generation: Default::default(),
4676 _delegate: Default::default(),
4677 _additional_params: Default::default(),
4678 _scopes: Default::default(),
4679 }
4680 }
4681
4682 /// Create a builder to help you perform the following task:
4683 ///
4684 /// Watch for changes on all objects in a bucket.
4685 ///
4686 /// # Arguments
4687 ///
4688 /// * `request` - No description provided.
4689 /// * `bucket` - Name of the bucket in which to look for objects.
4690 pub fn watch_all(&self, request: Channel, bucket: &str) -> ObjectWatchAllCall<'a, C> {
4691 ObjectWatchAllCall {
4692 hub: self.hub,
4693 _request: request,
4694 _bucket: bucket.to_string(),
4695 _versions: Default::default(),
4696 _user_project: Default::default(),
4697 _start_offset: Default::default(),
4698 _projection: Default::default(),
4699 _prefix: Default::default(),
4700 _page_token: Default::default(),
4701 _max_results: Default::default(),
4702 _include_trailing_delimiter: Default::default(),
4703 _end_offset: Default::default(),
4704 _delimiter: Default::default(),
4705 _delegate: Default::default(),
4706 _additional_params: Default::default(),
4707 _scopes: Default::default(),
4708 }
4709 }
4710}
4711
4712/// A builder providing access to all methods supported on *project* resources.
4713/// It is not used directly, but through the [`Storage`] hub.
4714///
4715/// # Example
4716///
4717/// Instantiate a resource builder
4718///
4719/// ```test_harness,no_run
4720/// extern crate hyper;
4721/// extern crate hyper_rustls;
4722/// extern crate google_storage1 as storage1;
4723///
4724/// # async fn dox() {
4725/// use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4726///
4727/// let secret: yup_oauth2::ApplicationSecret = Default::default();
4728/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
4729/// .with_native_roots()
4730/// .unwrap()
4731/// .https_only()
4732/// .enable_http2()
4733/// .build();
4734///
4735/// let executor = hyper_util::rt::TokioExecutor::new();
4736/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4737/// secret,
4738/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4739/// yup_oauth2::client::CustomHyperClientBuilder::from(
4740/// hyper_util::client::legacy::Client::builder(executor).build(connector),
4741/// ),
4742/// ).build().await.unwrap();
4743///
4744/// let client = hyper_util::client::legacy::Client::builder(
4745/// hyper_util::rt::TokioExecutor::new()
4746/// )
4747/// .build(
4748/// hyper_rustls::HttpsConnectorBuilder::new()
4749/// .with_native_roots()
4750/// .unwrap()
4751/// .https_or_http()
4752/// .enable_http2()
4753/// .build()
4754/// );
4755/// let mut hub = Storage::new(client, auth);
4756/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4757/// // like `hmac_keys_create(...)`, `hmac_keys_delete(...)`, `hmac_keys_get(...)`, `hmac_keys_list(...)`, `hmac_keys_update(...)` and `service_account_get(...)`
4758/// // to build up your call.
4759/// let rb = hub.projects();
4760/// # }
4761/// ```
4762pub struct ProjectMethods<'a, C>
4763where
4764 C: 'a,
4765{
4766 hub: &'a Storage<C>,
4767}
4768
4769impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
4770
4771impl<'a, C> ProjectMethods<'a, C> {
4772 /// Create a builder to help you perform the following task:
4773 ///
4774 /// Creates a new HMAC key for the specified service account.
4775 ///
4776 /// # Arguments
4777 ///
4778 /// * `projectId` - Project ID owning the service account.
4779 /// * `serviceAccountEmail` - Email address of the service account.
4780 pub fn hmac_keys_create(
4781 &self,
4782 project_id: &str,
4783 service_account_email: &str,
4784 ) -> ProjectHmacKeyCreateCall<'a, C> {
4785 ProjectHmacKeyCreateCall {
4786 hub: self.hub,
4787 _project_id: project_id.to_string(),
4788 _service_account_email: service_account_email.to_string(),
4789 _user_project: Default::default(),
4790 _delegate: Default::default(),
4791 _additional_params: Default::default(),
4792 _scopes: Default::default(),
4793 }
4794 }
4795
4796 /// Create a builder to help you perform the following task:
4797 ///
4798 /// Deletes an HMAC key.
4799 ///
4800 /// # Arguments
4801 ///
4802 /// * `projectId` - Project ID owning the requested key
4803 /// * `accessId` - Name of the HMAC key to be deleted.
4804 pub fn hmac_keys_delete(
4805 &self,
4806 project_id: &str,
4807 access_id: &str,
4808 ) -> ProjectHmacKeyDeleteCall<'a, C> {
4809 ProjectHmacKeyDeleteCall {
4810 hub: self.hub,
4811 _project_id: project_id.to_string(),
4812 _access_id: access_id.to_string(),
4813 _user_project: Default::default(),
4814 _delegate: Default::default(),
4815 _additional_params: Default::default(),
4816 _scopes: Default::default(),
4817 }
4818 }
4819
4820 /// Create a builder to help you perform the following task:
4821 ///
4822 /// Retrieves an HMAC key's metadata
4823 ///
4824 /// # Arguments
4825 ///
4826 /// * `projectId` - Project ID owning the service account of the requested key.
4827 /// * `accessId` - Name of the HMAC key.
4828 pub fn hmac_keys_get(&self, project_id: &str, access_id: &str) -> ProjectHmacKeyGetCall<'a, C> {
4829 ProjectHmacKeyGetCall {
4830 hub: self.hub,
4831 _project_id: project_id.to_string(),
4832 _access_id: access_id.to_string(),
4833 _user_project: Default::default(),
4834 _delegate: Default::default(),
4835 _additional_params: Default::default(),
4836 _scopes: Default::default(),
4837 }
4838 }
4839
4840 /// Create a builder to help you perform the following task:
4841 ///
4842 /// Retrieves a list of HMAC keys matching the criteria.
4843 ///
4844 /// # Arguments
4845 ///
4846 /// * `projectId` - Name of the project in which to look for HMAC keys.
4847 pub fn hmac_keys_list(&self, project_id: &str) -> ProjectHmacKeyListCall<'a, C> {
4848 ProjectHmacKeyListCall {
4849 hub: self.hub,
4850 _project_id: project_id.to_string(),
4851 _user_project: Default::default(),
4852 _show_deleted_keys: Default::default(),
4853 _service_account_email: Default::default(),
4854 _page_token: Default::default(),
4855 _max_results: Default::default(),
4856 _delegate: Default::default(),
4857 _additional_params: Default::default(),
4858 _scopes: Default::default(),
4859 }
4860 }
4861
4862 /// Create a builder to help you perform the following task:
4863 ///
4864 /// Updates the state of an HMAC key. See the [HMAC Key resource descriptor](https://cloud.google.com/storage/docs/json_api/v1/projects/hmacKeys/update#request-body) for valid states.
4865 ///
4866 /// # Arguments
4867 ///
4868 /// * `request` - No description provided.
4869 /// * `projectId` - Project ID owning the service account of the updated key.
4870 /// * `accessId` - Name of the HMAC key being updated.
4871 pub fn hmac_keys_update(
4872 &self,
4873 request: HmacKeyMetadata,
4874 project_id: &str,
4875 access_id: &str,
4876 ) -> ProjectHmacKeyUpdateCall<'a, C> {
4877 ProjectHmacKeyUpdateCall {
4878 hub: self.hub,
4879 _request: request,
4880 _project_id: project_id.to_string(),
4881 _access_id: access_id.to_string(),
4882 _user_project: Default::default(),
4883 _delegate: Default::default(),
4884 _additional_params: Default::default(),
4885 _scopes: Default::default(),
4886 }
4887 }
4888
4889 /// Create a builder to help you perform the following task:
4890 ///
4891 /// Get the email address of this project's Google Cloud Storage service account.
4892 ///
4893 /// # Arguments
4894 ///
4895 /// * `projectId` - Project ID
4896 pub fn service_account_get(&self, project_id: &str) -> ProjectServiceAccountGetCall<'a, C> {
4897 ProjectServiceAccountGetCall {
4898 hub: self.hub,
4899 _project_id: project_id.to_string(),
4900 _user_project: Default::default(),
4901 _delegate: Default::default(),
4902 _additional_params: Default::default(),
4903 _scopes: Default::default(),
4904 }
4905 }
4906}
4907
4908// ###################
4909// CallBuilders ###
4910// #################
4911
4912/// Disables an Anywhere Cache instance.
4913///
4914/// A builder for the *disable* method supported by a *anywhereCach* resource.
4915/// It is not used directly, but through a [`AnywhereCachMethods`] instance.
4916///
4917/// # Example
4918///
4919/// Instantiate a resource method builder
4920///
4921/// ```test_harness,no_run
4922/// # extern crate hyper;
4923/// # extern crate hyper_rustls;
4924/// # extern crate google_storage1 as storage1;
4925/// # async fn dox() {
4926/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4927///
4928/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4929/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4930/// # .with_native_roots()
4931/// # .unwrap()
4932/// # .https_only()
4933/// # .enable_http2()
4934/// # .build();
4935///
4936/// # let executor = hyper_util::rt::TokioExecutor::new();
4937/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4938/// # secret,
4939/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4940/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4941/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4942/// # ),
4943/// # ).build().await.unwrap();
4944///
4945/// # let client = hyper_util::client::legacy::Client::builder(
4946/// # hyper_util::rt::TokioExecutor::new()
4947/// # )
4948/// # .build(
4949/// # hyper_rustls::HttpsConnectorBuilder::new()
4950/// # .with_native_roots()
4951/// # .unwrap()
4952/// # .https_or_http()
4953/// # .enable_http2()
4954/// # .build()
4955/// # );
4956/// # let mut hub = Storage::new(client, auth);
4957/// // You can configure optional parameters by calling the respective setters at will, and
4958/// // execute the final call using `doit()`.
4959/// // Values shown here are possibly random and not representative !
4960/// let result = hub.anywhere_caches().disable("bucket", "anywhereCacheId")
4961/// .doit().await;
4962/// # }
4963/// ```
4964pub struct AnywhereCachDisableCall<'a, C>
4965where
4966 C: 'a,
4967{
4968 hub: &'a Storage<C>,
4969 _bucket: String,
4970 _anywhere_cache_id: String,
4971 _delegate: Option<&'a mut dyn common::Delegate>,
4972 _additional_params: HashMap<String, String>,
4973 _scopes: BTreeSet<String>,
4974}
4975
4976impl<'a, C> common::CallBuilder for AnywhereCachDisableCall<'a, C> {}
4977
4978impl<'a, C> AnywhereCachDisableCall<'a, C>
4979where
4980 C: common::Connector,
4981{
4982 /// Perform the operation you have build so far.
4983 pub async fn doit(mut self) -> common::Result<(common::Response, AnywhereCache)> {
4984 use std::borrow::Cow;
4985 use std::io::{Read, Seek};
4986
4987 use common::{url::Params, ToParts};
4988 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4989
4990 let mut dd = common::DefaultDelegate;
4991 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4992 dlg.begin(common::MethodInfo {
4993 id: "storage.anywhereCaches.disable",
4994 http_method: hyper::Method::POST,
4995 });
4996
4997 for &field in ["alt", "bucket", "anywhereCacheId"].iter() {
4998 if self._additional_params.contains_key(field) {
4999 dlg.finished(false);
5000 return Err(common::Error::FieldClash(field));
5001 }
5002 }
5003
5004 let mut params = Params::with_capacity(4 + self._additional_params.len());
5005 params.push("bucket", self._bucket);
5006 params.push("anywhereCacheId", self._anywhere_cache_id);
5007
5008 params.extend(self._additional_params.iter());
5009
5010 params.push("alt", "json");
5011 let mut url =
5012 self.hub._base_url.clone() + "b/{bucket}/anywhereCaches/{anywhereCacheId}/disable";
5013 if self._scopes.is_empty() {
5014 self._scopes
5015 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
5016 }
5017
5018 #[allow(clippy::single_element_loop)]
5019 for &(find_this, param_name) in [
5020 ("{bucket}", "bucket"),
5021 ("{anywhereCacheId}", "anywhereCacheId"),
5022 ]
5023 .iter()
5024 {
5025 url = params.uri_replacement(url, param_name, find_this, false);
5026 }
5027 {
5028 let to_remove = ["anywhereCacheId", "bucket"];
5029 params.remove_params(&to_remove);
5030 }
5031
5032 let url = params.parse_with_url(&url);
5033
5034 loop {
5035 let token = match self
5036 .hub
5037 .auth
5038 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5039 .await
5040 {
5041 Ok(token) => token,
5042 Err(e) => match dlg.token(e) {
5043 Ok(token) => token,
5044 Err(e) => {
5045 dlg.finished(false);
5046 return Err(common::Error::MissingToken(e));
5047 }
5048 },
5049 };
5050 let mut req_result = {
5051 let client = &self.hub.client;
5052 dlg.pre_request();
5053 let mut req_builder = hyper::Request::builder()
5054 .method(hyper::Method::POST)
5055 .uri(url.as_str())
5056 .header(USER_AGENT, self.hub._user_agent.clone());
5057
5058 if let Some(token) = token.as_ref() {
5059 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5060 }
5061
5062 let request = req_builder
5063 .header(CONTENT_LENGTH, 0_u64)
5064 .body(common::to_body::<String>(None));
5065
5066 client.request(request.unwrap()).await
5067 };
5068
5069 match req_result {
5070 Err(err) => {
5071 if let common::Retry::After(d) = dlg.http_error(&err) {
5072 sleep(d).await;
5073 continue;
5074 }
5075 dlg.finished(false);
5076 return Err(common::Error::HttpError(err));
5077 }
5078 Ok(res) => {
5079 let (mut parts, body) = res.into_parts();
5080 let mut body = common::Body::new(body);
5081 if !parts.status.is_success() {
5082 let bytes = common::to_bytes(body).await.unwrap_or_default();
5083 let error = serde_json::from_str(&common::to_string(&bytes));
5084 let response = common::to_response(parts, bytes.into());
5085
5086 if let common::Retry::After(d) =
5087 dlg.http_failure(&response, error.as_ref().ok())
5088 {
5089 sleep(d).await;
5090 continue;
5091 }
5092
5093 dlg.finished(false);
5094
5095 return Err(match error {
5096 Ok(value) => common::Error::BadRequest(value),
5097 _ => common::Error::Failure(response),
5098 });
5099 }
5100 let response = {
5101 let bytes = common::to_bytes(body).await.unwrap_or_default();
5102 let encoded = common::to_string(&bytes);
5103 match serde_json::from_str(&encoded) {
5104 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5105 Err(error) => {
5106 dlg.response_json_decode_error(&encoded, &error);
5107 return Err(common::Error::JsonDecodeError(
5108 encoded.to_string(),
5109 error,
5110 ));
5111 }
5112 }
5113 };
5114
5115 dlg.finished(true);
5116 return Ok(response);
5117 }
5118 }
5119 }
5120 }
5121
5122 /// Name of the parent bucket.
5123 ///
5124 /// Sets the *bucket* path property to the given value.
5125 ///
5126 /// Even though the property as already been set when instantiating this call,
5127 /// we provide this method for API completeness.
5128 pub fn bucket(mut self, new_value: &str) -> AnywhereCachDisableCall<'a, C> {
5129 self._bucket = new_value.to_string();
5130 self
5131 }
5132 /// The ID of requested Anywhere Cache instance.
5133 ///
5134 /// Sets the *anywhere cache id* path property to the given value.
5135 ///
5136 /// Even though the property as already been set when instantiating this call,
5137 /// we provide this method for API completeness.
5138 pub fn anywhere_cache_id(mut self, new_value: &str) -> AnywhereCachDisableCall<'a, C> {
5139 self._anywhere_cache_id = new_value.to_string();
5140 self
5141 }
5142 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5143 /// while executing the actual API request.
5144 ///
5145 /// ````text
5146 /// It should be used to handle progress information, and to implement a certain level of resilience.
5147 /// ````
5148 ///
5149 /// Sets the *delegate* property to the given value.
5150 pub fn delegate(
5151 mut self,
5152 new_value: &'a mut dyn common::Delegate,
5153 ) -> AnywhereCachDisableCall<'a, C> {
5154 self._delegate = Some(new_value);
5155 self
5156 }
5157
5158 /// Set any additional parameter of the query string used in the request.
5159 /// It should be used to set parameters which are not yet available through their own
5160 /// setters.
5161 ///
5162 /// Please note that this method must not be used to set any of the known parameters
5163 /// which have their own setter method. If done anyway, the request will fail.
5164 ///
5165 /// # Additional Parameters
5166 ///
5167 /// * *alt* (query-string) - Data format for the response.
5168 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5169 /// * *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.
5170 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5171 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5172 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5173 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
5174 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5175 pub fn param<T>(mut self, name: T, value: T) -> AnywhereCachDisableCall<'a, C>
5176 where
5177 T: AsRef<str>,
5178 {
5179 self._additional_params
5180 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5181 self
5182 }
5183
5184 /// Identifies the authorization scope for the method you are building.
5185 ///
5186 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5187 /// [`Scope::DevstorageReadWrite`].
5188 ///
5189 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5190 /// tokens for more than one scope.
5191 ///
5192 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5193 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5194 /// sufficient, a read-write scope will do as well.
5195 pub fn add_scope<St>(mut self, scope: St) -> AnywhereCachDisableCall<'a, C>
5196 where
5197 St: AsRef<str>,
5198 {
5199 self._scopes.insert(String::from(scope.as_ref()));
5200 self
5201 }
5202 /// Identifies the authorization scope(s) for the method you are building.
5203 ///
5204 /// See [`Self::add_scope()`] for details.
5205 pub fn add_scopes<I, St>(mut self, scopes: I) -> AnywhereCachDisableCall<'a, C>
5206 where
5207 I: IntoIterator<Item = St>,
5208 St: AsRef<str>,
5209 {
5210 self._scopes
5211 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5212 self
5213 }
5214
5215 /// Removes all scopes, and no default scope will be used either.
5216 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5217 /// for details).
5218 pub fn clear_scopes(mut self) -> AnywhereCachDisableCall<'a, C> {
5219 self._scopes.clear();
5220 self
5221 }
5222}
5223
5224/// Returns the metadata of an Anywhere Cache instance.
5225///
5226/// A builder for the *get* method supported by a *anywhereCach* resource.
5227/// It is not used directly, but through a [`AnywhereCachMethods`] instance.
5228///
5229/// # Example
5230///
5231/// Instantiate a resource method builder
5232///
5233/// ```test_harness,no_run
5234/// # extern crate hyper;
5235/// # extern crate hyper_rustls;
5236/// # extern crate google_storage1 as storage1;
5237/// # async fn dox() {
5238/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5239///
5240/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5241/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5242/// # .with_native_roots()
5243/// # .unwrap()
5244/// # .https_only()
5245/// # .enable_http2()
5246/// # .build();
5247///
5248/// # let executor = hyper_util::rt::TokioExecutor::new();
5249/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5250/// # secret,
5251/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5252/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5253/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5254/// # ),
5255/// # ).build().await.unwrap();
5256///
5257/// # let client = hyper_util::client::legacy::Client::builder(
5258/// # hyper_util::rt::TokioExecutor::new()
5259/// # )
5260/// # .build(
5261/// # hyper_rustls::HttpsConnectorBuilder::new()
5262/// # .with_native_roots()
5263/// # .unwrap()
5264/// # .https_or_http()
5265/// # .enable_http2()
5266/// # .build()
5267/// # );
5268/// # let mut hub = Storage::new(client, auth);
5269/// // You can configure optional parameters by calling the respective setters at will, and
5270/// // execute the final call using `doit()`.
5271/// // Values shown here are possibly random and not representative !
5272/// let result = hub.anywhere_caches().get("bucket", "anywhereCacheId")
5273/// .doit().await;
5274/// # }
5275/// ```
5276pub struct AnywhereCachGetCall<'a, C>
5277where
5278 C: 'a,
5279{
5280 hub: &'a Storage<C>,
5281 _bucket: String,
5282 _anywhere_cache_id: String,
5283 _delegate: Option<&'a mut dyn common::Delegate>,
5284 _additional_params: HashMap<String, String>,
5285 _scopes: BTreeSet<String>,
5286}
5287
5288impl<'a, C> common::CallBuilder for AnywhereCachGetCall<'a, C> {}
5289
5290impl<'a, C> AnywhereCachGetCall<'a, C>
5291where
5292 C: common::Connector,
5293{
5294 /// Perform the operation you have build so far.
5295 pub async fn doit(mut self) -> common::Result<(common::Response, AnywhereCache)> {
5296 use std::borrow::Cow;
5297 use std::io::{Read, Seek};
5298
5299 use common::{url::Params, ToParts};
5300 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5301
5302 let mut dd = common::DefaultDelegate;
5303 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5304 dlg.begin(common::MethodInfo {
5305 id: "storage.anywhereCaches.get",
5306 http_method: hyper::Method::GET,
5307 });
5308
5309 for &field in ["alt", "bucket", "anywhereCacheId"].iter() {
5310 if self._additional_params.contains_key(field) {
5311 dlg.finished(false);
5312 return Err(common::Error::FieldClash(field));
5313 }
5314 }
5315
5316 let mut params = Params::with_capacity(4 + self._additional_params.len());
5317 params.push("bucket", self._bucket);
5318 params.push("anywhereCacheId", self._anywhere_cache_id);
5319
5320 params.extend(self._additional_params.iter());
5321
5322 params.push("alt", "json");
5323 let mut url = self.hub._base_url.clone() + "b/{bucket}/anywhereCaches/{anywhereCacheId}";
5324 if self._scopes.is_empty() {
5325 self._scopes
5326 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
5327 }
5328
5329 #[allow(clippy::single_element_loop)]
5330 for &(find_this, param_name) in [
5331 ("{bucket}", "bucket"),
5332 ("{anywhereCacheId}", "anywhereCacheId"),
5333 ]
5334 .iter()
5335 {
5336 url = params.uri_replacement(url, param_name, find_this, false);
5337 }
5338 {
5339 let to_remove = ["anywhereCacheId", "bucket"];
5340 params.remove_params(&to_remove);
5341 }
5342
5343 let url = params.parse_with_url(&url);
5344
5345 loop {
5346 let token = match self
5347 .hub
5348 .auth
5349 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5350 .await
5351 {
5352 Ok(token) => token,
5353 Err(e) => match dlg.token(e) {
5354 Ok(token) => token,
5355 Err(e) => {
5356 dlg.finished(false);
5357 return Err(common::Error::MissingToken(e));
5358 }
5359 },
5360 };
5361 let mut req_result = {
5362 let client = &self.hub.client;
5363 dlg.pre_request();
5364 let mut req_builder = hyper::Request::builder()
5365 .method(hyper::Method::GET)
5366 .uri(url.as_str())
5367 .header(USER_AGENT, self.hub._user_agent.clone());
5368
5369 if let Some(token) = token.as_ref() {
5370 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5371 }
5372
5373 let request = req_builder
5374 .header(CONTENT_LENGTH, 0_u64)
5375 .body(common::to_body::<String>(None));
5376
5377 client.request(request.unwrap()).await
5378 };
5379
5380 match req_result {
5381 Err(err) => {
5382 if let common::Retry::After(d) = dlg.http_error(&err) {
5383 sleep(d).await;
5384 continue;
5385 }
5386 dlg.finished(false);
5387 return Err(common::Error::HttpError(err));
5388 }
5389 Ok(res) => {
5390 let (mut parts, body) = res.into_parts();
5391 let mut body = common::Body::new(body);
5392 if !parts.status.is_success() {
5393 let bytes = common::to_bytes(body).await.unwrap_or_default();
5394 let error = serde_json::from_str(&common::to_string(&bytes));
5395 let response = common::to_response(parts, bytes.into());
5396
5397 if let common::Retry::After(d) =
5398 dlg.http_failure(&response, error.as_ref().ok())
5399 {
5400 sleep(d).await;
5401 continue;
5402 }
5403
5404 dlg.finished(false);
5405
5406 return Err(match error {
5407 Ok(value) => common::Error::BadRequest(value),
5408 _ => common::Error::Failure(response),
5409 });
5410 }
5411 let response = {
5412 let bytes = common::to_bytes(body).await.unwrap_or_default();
5413 let encoded = common::to_string(&bytes);
5414 match serde_json::from_str(&encoded) {
5415 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5416 Err(error) => {
5417 dlg.response_json_decode_error(&encoded, &error);
5418 return Err(common::Error::JsonDecodeError(
5419 encoded.to_string(),
5420 error,
5421 ));
5422 }
5423 }
5424 };
5425
5426 dlg.finished(true);
5427 return Ok(response);
5428 }
5429 }
5430 }
5431 }
5432
5433 /// Name of the parent bucket.
5434 ///
5435 /// Sets the *bucket* path property to the given value.
5436 ///
5437 /// Even though the property as already been set when instantiating this call,
5438 /// we provide this method for API completeness.
5439 pub fn bucket(mut self, new_value: &str) -> AnywhereCachGetCall<'a, C> {
5440 self._bucket = new_value.to_string();
5441 self
5442 }
5443 /// The ID of requested Anywhere Cache instance.
5444 ///
5445 /// Sets the *anywhere cache id* path property to the given value.
5446 ///
5447 /// Even though the property as already been set when instantiating this call,
5448 /// we provide this method for API completeness.
5449 pub fn anywhere_cache_id(mut self, new_value: &str) -> AnywhereCachGetCall<'a, C> {
5450 self._anywhere_cache_id = new_value.to_string();
5451 self
5452 }
5453 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5454 /// while executing the actual API request.
5455 ///
5456 /// ````text
5457 /// It should be used to handle progress information, and to implement a certain level of resilience.
5458 /// ````
5459 ///
5460 /// Sets the *delegate* property to the given value.
5461 pub fn delegate(
5462 mut self,
5463 new_value: &'a mut dyn common::Delegate,
5464 ) -> AnywhereCachGetCall<'a, C> {
5465 self._delegate = Some(new_value);
5466 self
5467 }
5468
5469 /// Set any additional parameter of the query string used in the request.
5470 /// It should be used to set parameters which are not yet available through their own
5471 /// setters.
5472 ///
5473 /// Please note that this method must not be used to set any of the known parameters
5474 /// which have their own setter method. If done anyway, the request will fail.
5475 ///
5476 /// # Additional Parameters
5477 ///
5478 /// * *alt* (query-string) - Data format for the response.
5479 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5480 /// * *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.
5481 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5482 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5483 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5484 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
5485 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5486 pub fn param<T>(mut self, name: T, value: T) -> AnywhereCachGetCall<'a, C>
5487 where
5488 T: AsRef<str>,
5489 {
5490 self._additional_params
5491 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5492 self
5493 }
5494
5495 /// Identifies the authorization scope for the method you are building.
5496 ///
5497 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5498 /// [`Scope::DevstorageReadOnly`].
5499 ///
5500 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5501 /// tokens for more than one scope.
5502 ///
5503 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5504 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5505 /// sufficient, a read-write scope will do as well.
5506 pub fn add_scope<St>(mut self, scope: St) -> AnywhereCachGetCall<'a, C>
5507 where
5508 St: AsRef<str>,
5509 {
5510 self._scopes.insert(String::from(scope.as_ref()));
5511 self
5512 }
5513 /// Identifies the authorization scope(s) for the method you are building.
5514 ///
5515 /// See [`Self::add_scope()`] for details.
5516 pub fn add_scopes<I, St>(mut self, scopes: I) -> AnywhereCachGetCall<'a, C>
5517 where
5518 I: IntoIterator<Item = St>,
5519 St: AsRef<str>,
5520 {
5521 self._scopes
5522 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5523 self
5524 }
5525
5526 /// Removes all scopes, and no default scope will be used either.
5527 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5528 /// for details).
5529 pub fn clear_scopes(mut self) -> AnywhereCachGetCall<'a, C> {
5530 self._scopes.clear();
5531 self
5532 }
5533}
5534
5535/// Creates an Anywhere Cache instance.
5536///
5537/// A builder for the *insert* method supported by a *anywhereCach* resource.
5538/// It is not used directly, but through a [`AnywhereCachMethods`] instance.
5539///
5540/// # Example
5541///
5542/// Instantiate a resource method builder
5543///
5544/// ```test_harness,no_run
5545/// # extern crate hyper;
5546/// # extern crate hyper_rustls;
5547/// # extern crate google_storage1 as storage1;
5548/// use storage1::api::AnywhereCache;
5549/// # async fn dox() {
5550/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5551///
5552/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5553/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5554/// # .with_native_roots()
5555/// # .unwrap()
5556/// # .https_only()
5557/// # .enable_http2()
5558/// # .build();
5559///
5560/// # let executor = hyper_util::rt::TokioExecutor::new();
5561/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5562/// # secret,
5563/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5564/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5565/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5566/// # ),
5567/// # ).build().await.unwrap();
5568///
5569/// # let client = hyper_util::client::legacy::Client::builder(
5570/// # hyper_util::rt::TokioExecutor::new()
5571/// # )
5572/// # .build(
5573/// # hyper_rustls::HttpsConnectorBuilder::new()
5574/// # .with_native_roots()
5575/// # .unwrap()
5576/// # .https_or_http()
5577/// # .enable_http2()
5578/// # .build()
5579/// # );
5580/// # let mut hub = Storage::new(client, auth);
5581/// // As the method needs a request, you would usually fill it with the desired information
5582/// // into the respective structure. Some of the parts shown here might not be applicable !
5583/// // Values shown here are possibly random and not representative !
5584/// let mut req = AnywhereCache::default();
5585///
5586/// // You can configure optional parameters by calling the respective setters at will, and
5587/// // execute the final call using `doit()`.
5588/// // Values shown here are possibly random and not representative !
5589/// let result = hub.anywhere_caches().insert(req, "bucket")
5590/// .doit().await;
5591/// # }
5592/// ```
5593pub struct AnywhereCachInsertCall<'a, C>
5594where
5595 C: 'a,
5596{
5597 hub: &'a Storage<C>,
5598 _request: AnywhereCache,
5599 _bucket: String,
5600 _delegate: Option<&'a mut dyn common::Delegate>,
5601 _additional_params: HashMap<String, String>,
5602 _scopes: BTreeSet<String>,
5603}
5604
5605impl<'a, C> common::CallBuilder for AnywhereCachInsertCall<'a, C> {}
5606
5607impl<'a, C> AnywhereCachInsertCall<'a, C>
5608where
5609 C: common::Connector,
5610{
5611 /// Perform the operation you have build so far.
5612 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
5613 use std::borrow::Cow;
5614 use std::io::{Read, Seek};
5615
5616 use common::{url::Params, ToParts};
5617 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5618
5619 let mut dd = common::DefaultDelegate;
5620 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5621 dlg.begin(common::MethodInfo {
5622 id: "storage.anywhereCaches.insert",
5623 http_method: hyper::Method::POST,
5624 });
5625
5626 for &field in ["alt", "bucket"].iter() {
5627 if self._additional_params.contains_key(field) {
5628 dlg.finished(false);
5629 return Err(common::Error::FieldClash(field));
5630 }
5631 }
5632
5633 let mut params = Params::with_capacity(4 + self._additional_params.len());
5634 params.push("bucket", self._bucket);
5635
5636 params.extend(self._additional_params.iter());
5637
5638 params.push("alt", "json");
5639 let mut url = self.hub._base_url.clone() + "b/{bucket}/anywhereCaches";
5640 if self._scopes.is_empty() {
5641 self._scopes
5642 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
5643 }
5644
5645 #[allow(clippy::single_element_loop)]
5646 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
5647 url = params.uri_replacement(url, param_name, find_this, false);
5648 }
5649 {
5650 let to_remove = ["bucket"];
5651 params.remove_params(&to_remove);
5652 }
5653
5654 let url = params.parse_with_url(&url);
5655
5656 let mut json_mime_type = mime::APPLICATION_JSON;
5657 let mut request_value_reader = {
5658 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5659 common::remove_json_null_values(&mut value);
5660 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5661 serde_json::to_writer(&mut dst, &value).unwrap();
5662 dst
5663 };
5664 let request_size = request_value_reader
5665 .seek(std::io::SeekFrom::End(0))
5666 .unwrap();
5667 request_value_reader
5668 .seek(std::io::SeekFrom::Start(0))
5669 .unwrap();
5670
5671 loop {
5672 let token = match self
5673 .hub
5674 .auth
5675 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5676 .await
5677 {
5678 Ok(token) => token,
5679 Err(e) => match dlg.token(e) {
5680 Ok(token) => token,
5681 Err(e) => {
5682 dlg.finished(false);
5683 return Err(common::Error::MissingToken(e));
5684 }
5685 },
5686 };
5687 request_value_reader
5688 .seek(std::io::SeekFrom::Start(0))
5689 .unwrap();
5690 let mut req_result = {
5691 let client = &self.hub.client;
5692 dlg.pre_request();
5693 let mut req_builder = hyper::Request::builder()
5694 .method(hyper::Method::POST)
5695 .uri(url.as_str())
5696 .header(USER_AGENT, self.hub._user_agent.clone());
5697
5698 if let Some(token) = token.as_ref() {
5699 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5700 }
5701
5702 let request = req_builder
5703 .header(CONTENT_TYPE, json_mime_type.to_string())
5704 .header(CONTENT_LENGTH, request_size as u64)
5705 .body(common::to_body(
5706 request_value_reader.get_ref().clone().into(),
5707 ));
5708
5709 client.request(request.unwrap()).await
5710 };
5711
5712 match req_result {
5713 Err(err) => {
5714 if let common::Retry::After(d) = dlg.http_error(&err) {
5715 sleep(d).await;
5716 continue;
5717 }
5718 dlg.finished(false);
5719 return Err(common::Error::HttpError(err));
5720 }
5721 Ok(res) => {
5722 let (mut parts, body) = res.into_parts();
5723 let mut body = common::Body::new(body);
5724 if !parts.status.is_success() {
5725 let bytes = common::to_bytes(body).await.unwrap_or_default();
5726 let error = serde_json::from_str(&common::to_string(&bytes));
5727 let response = common::to_response(parts, bytes.into());
5728
5729 if let common::Retry::After(d) =
5730 dlg.http_failure(&response, error.as_ref().ok())
5731 {
5732 sleep(d).await;
5733 continue;
5734 }
5735
5736 dlg.finished(false);
5737
5738 return Err(match error {
5739 Ok(value) => common::Error::BadRequest(value),
5740 _ => common::Error::Failure(response),
5741 });
5742 }
5743 let response = {
5744 let bytes = common::to_bytes(body).await.unwrap_or_default();
5745 let encoded = common::to_string(&bytes);
5746 match serde_json::from_str(&encoded) {
5747 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5748 Err(error) => {
5749 dlg.response_json_decode_error(&encoded, &error);
5750 return Err(common::Error::JsonDecodeError(
5751 encoded.to_string(),
5752 error,
5753 ));
5754 }
5755 }
5756 };
5757
5758 dlg.finished(true);
5759 return Ok(response);
5760 }
5761 }
5762 }
5763 }
5764
5765 ///
5766 /// Sets the *request* property to the given value.
5767 ///
5768 /// Even though the property as already been set when instantiating this call,
5769 /// we provide this method for API completeness.
5770 pub fn request(mut self, new_value: AnywhereCache) -> AnywhereCachInsertCall<'a, C> {
5771 self._request = new_value;
5772 self
5773 }
5774 /// Name of the parent bucket.
5775 ///
5776 /// Sets the *bucket* path property to the given value.
5777 ///
5778 /// Even though the property as already been set when instantiating this call,
5779 /// we provide this method for API completeness.
5780 pub fn bucket(mut self, new_value: &str) -> AnywhereCachInsertCall<'a, C> {
5781 self._bucket = new_value.to_string();
5782 self
5783 }
5784 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5785 /// while executing the actual API request.
5786 ///
5787 /// ````text
5788 /// It should be used to handle progress information, and to implement a certain level of resilience.
5789 /// ````
5790 ///
5791 /// Sets the *delegate* property to the given value.
5792 pub fn delegate(
5793 mut self,
5794 new_value: &'a mut dyn common::Delegate,
5795 ) -> AnywhereCachInsertCall<'a, C> {
5796 self._delegate = Some(new_value);
5797 self
5798 }
5799
5800 /// Set any additional parameter of the query string used in the request.
5801 /// It should be used to set parameters which are not yet available through their own
5802 /// setters.
5803 ///
5804 /// Please note that this method must not be used to set any of the known parameters
5805 /// which have their own setter method. If done anyway, the request will fail.
5806 ///
5807 /// # Additional Parameters
5808 ///
5809 /// * *alt* (query-string) - Data format for the response.
5810 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5811 /// * *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.
5812 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5813 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5814 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5815 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
5816 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5817 pub fn param<T>(mut self, name: T, value: T) -> AnywhereCachInsertCall<'a, C>
5818 where
5819 T: AsRef<str>,
5820 {
5821 self._additional_params
5822 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5823 self
5824 }
5825
5826 /// Identifies the authorization scope for the method you are building.
5827 ///
5828 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5829 /// [`Scope::DevstorageReadWrite`].
5830 ///
5831 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5832 /// tokens for more than one scope.
5833 ///
5834 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5835 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5836 /// sufficient, a read-write scope will do as well.
5837 pub fn add_scope<St>(mut self, scope: St) -> AnywhereCachInsertCall<'a, C>
5838 where
5839 St: AsRef<str>,
5840 {
5841 self._scopes.insert(String::from(scope.as_ref()));
5842 self
5843 }
5844 /// Identifies the authorization scope(s) for the method you are building.
5845 ///
5846 /// See [`Self::add_scope()`] for details.
5847 pub fn add_scopes<I, St>(mut self, scopes: I) -> AnywhereCachInsertCall<'a, C>
5848 where
5849 I: IntoIterator<Item = St>,
5850 St: AsRef<str>,
5851 {
5852 self._scopes
5853 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5854 self
5855 }
5856
5857 /// Removes all scopes, and no default scope will be used either.
5858 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5859 /// for details).
5860 pub fn clear_scopes(mut self) -> AnywhereCachInsertCall<'a, C> {
5861 self._scopes.clear();
5862 self
5863 }
5864}
5865
5866/// Returns a list of Anywhere Cache instances of the bucket matching the criteria.
5867///
5868/// A builder for the *list* method supported by a *anywhereCach* resource.
5869/// It is not used directly, but through a [`AnywhereCachMethods`] instance.
5870///
5871/// # Example
5872///
5873/// Instantiate a resource method builder
5874///
5875/// ```test_harness,no_run
5876/// # extern crate hyper;
5877/// # extern crate hyper_rustls;
5878/// # extern crate google_storage1 as storage1;
5879/// # async fn dox() {
5880/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5881///
5882/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5883/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5884/// # .with_native_roots()
5885/// # .unwrap()
5886/// # .https_only()
5887/// # .enable_http2()
5888/// # .build();
5889///
5890/// # let executor = hyper_util::rt::TokioExecutor::new();
5891/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5892/// # secret,
5893/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5894/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5895/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5896/// # ),
5897/// # ).build().await.unwrap();
5898///
5899/// # let client = hyper_util::client::legacy::Client::builder(
5900/// # hyper_util::rt::TokioExecutor::new()
5901/// # )
5902/// # .build(
5903/// # hyper_rustls::HttpsConnectorBuilder::new()
5904/// # .with_native_roots()
5905/// # .unwrap()
5906/// # .https_or_http()
5907/// # .enable_http2()
5908/// # .build()
5909/// # );
5910/// # let mut hub = Storage::new(client, auth);
5911/// // You can configure optional parameters by calling the respective setters at will, and
5912/// // execute the final call using `doit()`.
5913/// // Values shown here are possibly random and not representative !
5914/// let result = hub.anywhere_caches().list("bucket")
5915/// .page_token("Lorem")
5916/// .page_size(-25)
5917/// .doit().await;
5918/// # }
5919/// ```
5920pub struct AnywhereCachListCall<'a, C>
5921where
5922 C: 'a,
5923{
5924 hub: &'a Storage<C>,
5925 _bucket: String,
5926 _page_token: Option<String>,
5927 _page_size: Option<i32>,
5928 _delegate: Option<&'a mut dyn common::Delegate>,
5929 _additional_params: HashMap<String, String>,
5930 _scopes: BTreeSet<String>,
5931}
5932
5933impl<'a, C> common::CallBuilder for AnywhereCachListCall<'a, C> {}
5934
5935impl<'a, C> AnywhereCachListCall<'a, C>
5936where
5937 C: common::Connector,
5938{
5939 /// Perform the operation you have build so far.
5940 pub async fn doit(mut self) -> common::Result<(common::Response, AnywhereCaches)> {
5941 use std::borrow::Cow;
5942 use std::io::{Read, Seek};
5943
5944 use common::{url::Params, ToParts};
5945 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5946
5947 let mut dd = common::DefaultDelegate;
5948 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5949 dlg.begin(common::MethodInfo {
5950 id: "storage.anywhereCaches.list",
5951 http_method: hyper::Method::GET,
5952 });
5953
5954 for &field in ["alt", "bucket", "pageToken", "pageSize"].iter() {
5955 if self._additional_params.contains_key(field) {
5956 dlg.finished(false);
5957 return Err(common::Error::FieldClash(field));
5958 }
5959 }
5960
5961 let mut params = Params::with_capacity(5 + self._additional_params.len());
5962 params.push("bucket", self._bucket);
5963 if let Some(value) = self._page_token.as_ref() {
5964 params.push("pageToken", value);
5965 }
5966 if let Some(value) = self._page_size.as_ref() {
5967 params.push("pageSize", value.to_string());
5968 }
5969
5970 params.extend(self._additional_params.iter());
5971
5972 params.push("alt", "json");
5973 let mut url = self.hub._base_url.clone() + "b/{bucket}/anywhereCaches";
5974 if self._scopes.is_empty() {
5975 self._scopes
5976 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
5977 }
5978
5979 #[allow(clippy::single_element_loop)]
5980 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
5981 url = params.uri_replacement(url, param_name, find_this, false);
5982 }
5983 {
5984 let to_remove = ["bucket"];
5985 params.remove_params(&to_remove);
5986 }
5987
5988 let url = params.parse_with_url(&url);
5989
5990 loop {
5991 let token = match self
5992 .hub
5993 .auth
5994 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5995 .await
5996 {
5997 Ok(token) => token,
5998 Err(e) => match dlg.token(e) {
5999 Ok(token) => token,
6000 Err(e) => {
6001 dlg.finished(false);
6002 return Err(common::Error::MissingToken(e));
6003 }
6004 },
6005 };
6006 let mut req_result = {
6007 let client = &self.hub.client;
6008 dlg.pre_request();
6009 let mut req_builder = hyper::Request::builder()
6010 .method(hyper::Method::GET)
6011 .uri(url.as_str())
6012 .header(USER_AGENT, self.hub._user_agent.clone());
6013
6014 if let Some(token) = token.as_ref() {
6015 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6016 }
6017
6018 let request = req_builder
6019 .header(CONTENT_LENGTH, 0_u64)
6020 .body(common::to_body::<String>(None));
6021
6022 client.request(request.unwrap()).await
6023 };
6024
6025 match req_result {
6026 Err(err) => {
6027 if let common::Retry::After(d) = dlg.http_error(&err) {
6028 sleep(d).await;
6029 continue;
6030 }
6031 dlg.finished(false);
6032 return Err(common::Error::HttpError(err));
6033 }
6034 Ok(res) => {
6035 let (mut parts, body) = res.into_parts();
6036 let mut body = common::Body::new(body);
6037 if !parts.status.is_success() {
6038 let bytes = common::to_bytes(body).await.unwrap_or_default();
6039 let error = serde_json::from_str(&common::to_string(&bytes));
6040 let response = common::to_response(parts, bytes.into());
6041
6042 if let common::Retry::After(d) =
6043 dlg.http_failure(&response, error.as_ref().ok())
6044 {
6045 sleep(d).await;
6046 continue;
6047 }
6048
6049 dlg.finished(false);
6050
6051 return Err(match error {
6052 Ok(value) => common::Error::BadRequest(value),
6053 _ => common::Error::Failure(response),
6054 });
6055 }
6056 let response = {
6057 let bytes = common::to_bytes(body).await.unwrap_or_default();
6058 let encoded = common::to_string(&bytes);
6059 match serde_json::from_str(&encoded) {
6060 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6061 Err(error) => {
6062 dlg.response_json_decode_error(&encoded, &error);
6063 return Err(common::Error::JsonDecodeError(
6064 encoded.to_string(),
6065 error,
6066 ));
6067 }
6068 }
6069 };
6070
6071 dlg.finished(true);
6072 return Ok(response);
6073 }
6074 }
6075 }
6076 }
6077
6078 /// Name of the parent bucket.
6079 ///
6080 /// Sets the *bucket* path property to the given value.
6081 ///
6082 /// Even though the property as already been set when instantiating this call,
6083 /// we provide this method for API completeness.
6084 pub fn bucket(mut self, new_value: &str) -> AnywhereCachListCall<'a, C> {
6085 self._bucket = new_value.to_string();
6086 self
6087 }
6088 /// A previously-returned page token representing part of the larger set of results to view.
6089 ///
6090 /// Sets the *page token* query property to the given value.
6091 pub fn page_token(mut self, new_value: &str) -> AnywhereCachListCall<'a, C> {
6092 self._page_token = Some(new_value.to_string());
6093 self
6094 }
6095 /// Maximum number of items to return in a single page of responses. Maximum 1000.
6096 ///
6097 /// Sets the *page size* query property to the given value.
6098 pub fn page_size(mut self, new_value: i32) -> AnywhereCachListCall<'a, C> {
6099 self._page_size = Some(new_value);
6100 self
6101 }
6102 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6103 /// while executing the actual API request.
6104 ///
6105 /// ````text
6106 /// It should be used to handle progress information, and to implement a certain level of resilience.
6107 /// ````
6108 ///
6109 /// Sets the *delegate* property to the given value.
6110 pub fn delegate(
6111 mut self,
6112 new_value: &'a mut dyn common::Delegate,
6113 ) -> AnywhereCachListCall<'a, C> {
6114 self._delegate = Some(new_value);
6115 self
6116 }
6117
6118 /// Set any additional parameter of the query string used in the request.
6119 /// It should be used to set parameters which are not yet available through their own
6120 /// setters.
6121 ///
6122 /// Please note that this method must not be used to set any of the known parameters
6123 /// which have their own setter method. If done anyway, the request will fail.
6124 ///
6125 /// # Additional Parameters
6126 ///
6127 /// * *alt* (query-string) - Data format for the response.
6128 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6129 /// * *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.
6130 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6131 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6132 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6133 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
6134 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6135 pub fn param<T>(mut self, name: T, value: T) -> AnywhereCachListCall<'a, C>
6136 where
6137 T: AsRef<str>,
6138 {
6139 self._additional_params
6140 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6141 self
6142 }
6143
6144 /// Identifies the authorization scope for the method you are building.
6145 ///
6146 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6147 /// [`Scope::DevstorageReadOnly`].
6148 ///
6149 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6150 /// tokens for more than one scope.
6151 ///
6152 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6153 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6154 /// sufficient, a read-write scope will do as well.
6155 pub fn add_scope<St>(mut self, scope: St) -> AnywhereCachListCall<'a, C>
6156 where
6157 St: AsRef<str>,
6158 {
6159 self._scopes.insert(String::from(scope.as_ref()));
6160 self
6161 }
6162 /// Identifies the authorization scope(s) for the method you are building.
6163 ///
6164 /// See [`Self::add_scope()`] for details.
6165 pub fn add_scopes<I, St>(mut self, scopes: I) -> AnywhereCachListCall<'a, C>
6166 where
6167 I: IntoIterator<Item = St>,
6168 St: AsRef<str>,
6169 {
6170 self._scopes
6171 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6172 self
6173 }
6174
6175 /// Removes all scopes, and no default scope will be used either.
6176 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6177 /// for details).
6178 pub fn clear_scopes(mut self) -> AnywhereCachListCall<'a, C> {
6179 self._scopes.clear();
6180 self
6181 }
6182}
6183
6184/// Pauses an Anywhere Cache instance.
6185///
6186/// A builder for the *pause* method supported by a *anywhereCach* resource.
6187/// It is not used directly, but through a [`AnywhereCachMethods`] instance.
6188///
6189/// # Example
6190///
6191/// Instantiate a resource method builder
6192///
6193/// ```test_harness,no_run
6194/// # extern crate hyper;
6195/// # extern crate hyper_rustls;
6196/// # extern crate google_storage1 as storage1;
6197/// # async fn dox() {
6198/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6199///
6200/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6201/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6202/// # .with_native_roots()
6203/// # .unwrap()
6204/// # .https_only()
6205/// # .enable_http2()
6206/// # .build();
6207///
6208/// # let executor = hyper_util::rt::TokioExecutor::new();
6209/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6210/// # secret,
6211/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6212/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6213/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6214/// # ),
6215/// # ).build().await.unwrap();
6216///
6217/// # let client = hyper_util::client::legacy::Client::builder(
6218/// # hyper_util::rt::TokioExecutor::new()
6219/// # )
6220/// # .build(
6221/// # hyper_rustls::HttpsConnectorBuilder::new()
6222/// # .with_native_roots()
6223/// # .unwrap()
6224/// # .https_or_http()
6225/// # .enable_http2()
6226/// # .build()
6227/// # );
6228/// # let mut hub = Storage::new(client, auth);
6229/// // You can configure optional parameters by calling the respective setters at will, and
6230/// // execute the final call using `doit()`.
6231/// // Values shown here are possibly random and not representative !
6232/// let result = hub.anywhere_caches().pause("bucket", "anywhereCacheId")
6233/// .doit().await;
6234/// # }
6235/// ```
6236pub struct AnywhereCachPauseCall<'a, C>
6237where
6238 C: 'a,
6239{
6240 hub: &'a Storage<C>,
6241 _bucket: String,
6242 _anywhere_cache_id: String,
6243 _delegate: Option<&'a mut dyn common::Delegate>,
6244 _additional_params: HashMap<String, String>,
6245 _scopes: BTreeSet<String>,
6246}
6247
6248impl<'a, C> common::CallBuilder for AnywhereCachPauseCall<'a, C> {}
6249
6250impl<'a, C> AnywhereCachPauseCall<'a, C>
6251where
6252 C: common::Connector,
6253{
6254 /// Perform the operation you have build so far.
6255 pub async fn doit(mut self) -> common::Result<(common::Response, AnywhereCache)> {
6256 use std::borrow::Cow;
6257 use std::io::{Read, Seek};
6258
6259 use common::{url::Params, ToParts};
6260 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6261
6262 let mut dd = common::DefaultDelegate;
6263 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6264 dlg.begin(common::MethodInfo {
6265 id: "storage.anywhereCaches.pause",
6266 http_method: hyper::Method::POST,
6267 });
6268
6269 for &field in ["alt", "bucket", "anywhereCacheId"].iter() {
6270 if self._additional_params.contains_key(field) {
6271 dlg.finished(false);
6272 return Err(common::Error::FieldClash(field));
6273 }
6274 }
6275
6276 let mut params = Params::with_capacity(4 + self._additional_params.len());
6277 params.push("bucket", self._bucket);
6278 params.push("anywhereCacheId", self._anywhere_cache_id);
6279
6280 params.extend(self._additional_params.iter());
6281
6282 params.push("alt", "json");
6283 let mut url =
6284 self.hub._base_url.clone() + "b/{bucket}/anywhereCaches/{anywhereCacheId}/pause";
6285 if self._scopes.is_empty() {
6286 self._scopes
6287 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
6288 }
6289
6290 #[allow(clippy::single_element_loop)]
6291 for &(find_this, param_name) in [
6292 ("{bucket}", "bucket"),
6293 ("{anywhereCacheId}", "anywhereCacheId"),
6294 ]
6295 .iter()
6296 {
6297 url = params.uri_replacement(url, param_name, find_this, false);
6298 }
6299 {
6300 let to_remove = ["anywhereCacheId", "bucket"];
6301 params.remove_params(&to_remove);
6302 }
6303
6304 let url = params.parse_with_url(&url);
6305
6306 loop {
6307 let token = match self
6308 .hub
6309 .auth
6310 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6311 .await
6312 {
6313 Ok(token) => token,
6314 Err(e) => match dlg.token(e) {
6315 Ok(token) => token,
6316 Err(e) => {
6317 dlg.finished(false);
6318 return Err(common::Error::MissingToken(e));
6319 }
6320 },
6321 };
6322 let mut req_result = {
6323 let client = &self.hub.client;
6324 dlg.pre_request();
6325 let mut req_builder = hyper::Request::builder()
6326 .method(hyper::Method::POST)
6327 .uri(url.as_str())
6328 .header(USER_AGENT, self.hub._user_agent.clone());
6329
6330 if let Some(token) = token.as_ref() {
6331 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6332 }
6333
6334 let request = req_builder
6335 .header(CONTENT_LENGTH, 0_u64)
6336 .body(common::to_body::<String>(None));
6337
6338 client.request(request.unwrap()).await
6339 };
6340
6341 match req_result {
6342 Err(err) => {
6343 if let common::Retry::After(d) = dlg.http_error(&err) {
6344 sleep(d).await;
6345 continue;
6346 }
6347 dlg.finished(false);
6348 return Err(common::Error::HttpError(err));
6349 }
6350 Ok(res) => {
6351 let (mut parts, body) = res.into_parts();
6352 let mut body = common::Body::new(body);
6353 if !parts.status.is_success() {
6354 let bytes = common::to_bytes(body).await.unwrap_or_default();
6355 let error = serde_json::from_str(&common::to_string(&bytes));
6356 let response = common::to_response(parts, bytes.into());
6357
6358 if let common::Retry::After(d) =
6359 dlg.http_failure(&response, error.as_ref().ok())
6360 {
6361 sleep(d).await;
6362 continue;
6363 }
6364
6365 dlg.finished(false);
6366
6367 return Err(match error {
6368 Ok(value) => common::Error::BadRequest(value),
6369 _ => common::Error::Failure(response),
6370 });
6371 }
6372 let response = {
6373 let bytes = common::to_bytes(body).await.unwrap_or_default();
6374 let encoded = common::to_string(&bytes);
6375 match serde_json::from_str(&encoded) {
6376 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6377 Err(error) => {
6378 dlg.response_json_decode_error(&encoded, &error);
6379 return Err(common::Error::JsonDecodeError(
6380 encoded.to_string(),
6381 error,
6382 ));
6383 }
6384 }
6385 };
6386
6387 dlg.finished(true);
6388 return Ok(response);
6389 }
6390 }
6391 }
6392 }
6393
6394 /// Name of the parent bucket.
6395 ///
6396 /// Sets the *bucket* path property to the given value.
6397 ///
6398 /// Even though the property as already been set when instantiating this call,
6399 /// we provide this method for API completeness.
6400 pub fn bucket(mut self, new_value: &str) -> AnywhereCachPauseCall<'a, C> {
6401 self._bucket = new_value.to_string();
6402 self
6403 }
6404 /// The ID of requested Anywhere Cache instance.
6405 ///
6406 /// Sets the *anywhere cache id* path property to the given value.
6407 ///
6408 /// Even though the property as already been set when instantiating this call,
6409 /// we provide this method for API completeness.
6410 pub fn anywhere_cache_id(mut self, new_value: &str) -> AnywhereCachPauseCall<'a, C> {
6411 self._anywhere_cache_id = new_value.to_string();
6412 self
6413 }
6414 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6415 /// while executing the actual API request.
6416 ///
6417 /// ````text
6418 /// It should be used to handle progress information, and to implement a certain level of resilience.
6419 /// ````
6420 ///
6421 /// Sets the *delegate* property to the given value.
6422 pub fn delegate(
6423 mut self,
6424 new_value: &'a mut dyn common::Delegate,
6425 ) -> AnywhereCachPauseCall<'a, C> {
6426 self._delegate = Some(new_value);
6427 self
6428 }
6429
6430 /// Set any additional parameter of the query string used in the request.
6431 /// It should be used to set parameters which are not yet available through their own
6432 /// setters.
6433 ///
6434 /// Please note that this method must not be used to set any of the known parameters
6435 /// which have their own setter method. If done anyway, the request will fail.
6436 ///
6437 /// # Additional Parameters
6438 ///
6439 /// * *alt* (query-string) - Data format for the response.
6440 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6441 /// * *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.
6442 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6443 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6444 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6445 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
6446 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6447 pub fn param<T>(mut self, name: T, value: T) -> AnywhereCachPauseCall<'a, C>
6448 where
6449 T: AsRef<str>,
6450 {
6451 self._additional_params
6452 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6453 self
6454 }
6455
6456 /// Identifies the authorization scope for the method you are building.
6457 ///
6458 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6459 /// [`Scope::DevstorageReadWrite`].
6460 ///
6461 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6462 /// tokens for more than one scope.
6463 ///
6464 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6465 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6466 /// sufficient, a read-write scope will do as well.
6467 pub fn add_scope<St>(mut self, scope: St) -> AnywhereCachPauseCall<'a, C>
6468 where
6469 St: AsRef<str>,
6470 {
6471 self._scopes.insert(String::from(scope.as_ref()));
6472 self
6473 }
6474 /// Identifies the authorization scope(s) for the method you are building.
6475 ///
6476 /// See [`Self::add_scope()`] for details.
6477 pub fn add_scopes<I, St>(mut self, scopes: I) -> AnywhereCachPauseCall<'a, C>
6478 where
6479 I: IntoIterator<Item = St>,
6480 St: AsRef<str>,
6481 {
6482 self._scopes
6483 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6484 self
6485 }
6486
6487 /// Removes all scopes, and no default scope will be used either.
6488 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6489 /// for details).
6490 pub fn clear_scopes(mut self) -> AnywhereCachPauseCall<'a, C> {
6491 self._scopes.clear();
6492 self
6493 }
6494}
6495
6496/// Resumes a paused or disabled Anywhere Cache instance.
6497///
6498/// A builder for the *resume* method supported by a *anywhereCach* resource.
6499/// It is not used directly, but through a [`AnywhereCachMethods`] instance.
6500///
6501/// # Example
6502///
6503/// Instantiate a resource method builder
6504///
6505/// ```test_harness,no_run
6506/// # extern crate hyper;
6507/// # extern crate hyper_rustls;
6508/// # extern crate google_storage1 as storage1;
6509/// # async fn dox() {
6510/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6511///
6512/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6513/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6514/// # .with_native_roots()
6515/// # .unwrap()
6516/// # .https_only()
6517/// # .enable_http2()
6518/// # .build();
6519///
6520/// # let executor = hyper_util::rt::TokioExecutor::new();
6521/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6522/// # secret,
6523/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6524/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6525/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6526/// # ),
6527/// # ).build().await.unwrap();
6528///
6529/// # let client = hyper_util::client::legacy::Client::builder(
6530/// # hyper_util::rt::TokioExecutor::new()
6531/// # )
6532/// # .build(
6533/// # hyper_rustls::HttpsConnectorBuilder::new()
6534/// # .with_native_roots()
6535/// # .unwrap()
6536/// # .https_or_http()
6537/// # .enable_http2()
6538/// # .build()
6539/// # );
6540/// # let mut hub = Storage::new(client, auth);
6541/// // You can configure optional parameters by calling the respective setters at will, and
6542/// // execute the final call using `doit()`.
6543/// // Values shown here are possibly random and not representative !
6544/// let result = hub.anywhere_caches().resume("bucket", "anywhereCacheId")
6545/// .doit().await;
6546/// # }
6547/// ```
6548pub struct AnywhereCachResumeCall<'a, C>
6549where
6550 C: 'a,
6551{
6552 hub: &'a Storage<C>,
6553 _bucket: String,
6554 _anywhere_cache_id: String,
6555 _delegate: Option<&'a mut dyn common::Delegate>,
6556 _additional_params: HashMap<String, String>,
6557 _scopes: BTreeSet<String>,
6558}
6559
6560impl<'a, C> common::CallBuilder for AnywhereCachResumeCall<'a, C> {}
6561
6562impl<'a, C> AnywhereCachResumeCall<'a, C>
6563where
6564 C: common::Connector,
6565{
6566 /// Perform the operation you have build so far.
6567 pub async fn doit(mut self) -> common::Result<(common::Response, AnywhereCache)> {
6568 use std::borrow::Cow;
6569 use std::io::{Read, Seek};
6570
6571 use common::{url::Params, ToParts};
6572 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6573
6574 let mut dd = common::DefaultDelegate;
6575 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6576 dlg.begin(common::MethodInfo {
6577 id: "storage.anywhereCaches.resume",
6578 http_method: hyper::Method::POST,
6579 });
6580
6581 for &field in ["alt", "bucket", "anywhereCacheId"].iter() {
6582 if self._additional_params.contains_key(field) {
6583 dlg.finished(false);
6584 return Err(common::Error::FieldClash(field));
6585 }
6586 }
6587
6588 let mut params = Params::with_capacity(4 + self._additional_params.len());
6589 params.push("bucket", self._bucket);
6590 params.push("anywhereCacheId", self._anywhere_cache_id);
6591
6592 params.extend(self._additional_params.iter());
6593
6594 params.push("alt", "json");
6595 let mut url =
6596 self.hub._base_url.clone() + "b/{bucket}/anywhereCaches/{anywhereCacheId}/resume";
6597 if self._scopes.is_empty() {
6598 self._scopes
6599 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
6600 }
6601
6602 #[allow(clippy::single_element_loop)]
6603 for &(find_this, param_name) in [
6604 ("{bucket}", "bucket"),
6605 ("{anywhereCacheId}", "anywhereCacheId"),
6606 ]
6607 .iter()
6608 {
6609 url = params.uri_replacement(url, param_name, find_this, false);
6610 }
6611 {
6612 let to_remove = ["anywhereCacheId", "bucket"];
6613 params.remove_params(&to_remove);
6614 }
6615
6616 let url = params.parse_with_url(&url);
6617
6618 loop {
6619 let token = match self
6620 .hub
6621 .auth
6622 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6623 .await
6624 {
6625 Ok(token) => token,
6626 Err(e) => match dlg.token(e) {
6627 Ok(token) => token,
6628 Err(e) => {
6629 dlg.finished(false);
6630 return Err(common::Error::MissingToken(e));
6631 }
6632 },
6633 };
6634 let mut req_result = {
6635 let client = &self.hub.client;
6636 dlg.pre_request();
6637 let mut req_builder = hyper::Request::builder()
6638 .method(hyper::Method::POST)
6639 .uri(url.as_str())
6640 .header(USER_AGENT, self.hub._user_agent.clone());
6641
6642 if let Some(token) = token.as_ref() {
6643 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6644 }
6645
6646 let request = req_builder
6647 .header(CONTENT_LENGTH, 0_u64)
6648 .body(common::to_body::<String>(None));
6649
6650 client.request(request.unwrap()).await
6651 };
6652
6653 match req_result {
6654 Err(err) => {
6655 if let common::Retry::After(d) = dlg.http_error(&err) {
6656 sleep(d).await;
6657 continue;
6658 }
6659 dlg.finished(false);
6660 return Err(common::Error::HttpError(err));
6661 }
6662 Ok(res) => {
6663 let (mut parts, body) = res.into_parts();
6664 let mut body = common::Body::new(body);
6665 if !parts.status.is_success() {
6666 let bytes = common::to_bytes(body).await.unwrap_or_default();
6667 let error = serde_json::from_str(&common::to_string(&bytes));
6668 let response = common::to_response(parts, bytes.into());
6669
6670 if let common::Retry::After(d) =
6671 dlg.http_failure(&response, error.as_ref().ok())
6672 {
6673 sleep(d).await;
6674 continue;
6675 }
6676
6677 dlg.finished(false);
6678
6679 return Err(match error {
6680 Ok(value) => common::Error::BadRequest(value),
6681 _ => common::Error::Failure(response),
6682 });
6683 }
6684 let response = {
6685 let bytes = common::to_bytes(body).await.unwrap_or_default();
6686 let encoded = common::to_string(&bytes);
6687 match serde_json::from_str(&encoded) {
6688 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6689 Err(error) => {
6690 dlg.response_json_decode_error(&encoded, &error);
6691 return Err(common::Error::JsonDecodeError(
6692 encoded.to_string(),
6693 error,
6694 ));
6695 }
6696 }
6697 };
6698
6699 dlg.finished(true);
6700 return Ok(response);
6701 }
6702 }
6703 }
6704 }
6705
6706 /// Name of the parent bucket.
6707 ///
6708 /// Sets the *bucket* path property to the given value.
6709 ///
6710 /// Even though the property as already been set when instantiating this call,
6711 /// we provide this method for API completeness.
6712 pub fn bucket(mut self, new_value: &str) -> AnywhereCachResumeCall<'a, C> {
6713 self._bucket = new_value.to_string();
6714 self
6715 }
6716 /// The ID of requested Anywhere Cache instance.
6717 ///
6718 /// Sets the *anywhere cache id* path property to the given value.
6719 ///
6720 /// Even though the property as already been set when instantiating this call,
6721 /// we provide this method for API completeness.
6722 pub fn anywhere_cache_id(mut self, new_value: &str) -> AnywhereCachResumeCall<'a, C> {
6723 self._anywhere_cache_id = new_value.to_string();
6724 self
6725 }
6726 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6727 /// while executing the actual API request.
6728 ///
6729 /// ````text
6730 /// It should be used to handle progress information, and to implement a certain level of resilience.
6731 /// ````
6732 ///
6733 /// Sets the *delegate* property to the given value.
6734 pub fn delegate(
6735 mut self,
6736 new_value: &'a mut dyn common::Delegate,
6737 ) -> AnywhereCachResumeCall<'a, C> {
6738 self._delegate = Some(new_value);
6739 self
6740 }
6741
6742 /// Set any additional parameter of the query string used in the request.
6743 /// It should be used to set parameters which are not yet available through their own
6744 /// setters.
6745 ///
6746 /// Please note that this method must not be used to set any of the known parameters
6747 /// which have their own setter method. If done anyway, the request will fail.
6748 ///
6749 /// # Additional Parameters
6750 ///
6751 /// * *alt* (query-string) - Data format for the response.
6752 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6753 /// * *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.
6754 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6755 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6756 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6757 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
6758 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6759 pub fn param<T>(mut self, name: T, value: T) -> AnywhereCachResumeCall<'a, C>
6760 where
6761 T: AsRef<str>,
6762 {
6763 self._additional_params
6764 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6765 self
6766 }
6767
6768 /// Identifies the authorization scope for the method you are building.
6769 ///
6770 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6771 /// [`Scope::DevstorageReadWrite`].
6772 ///
6773 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6774 /// tokens for more than one scope.
6775 ///
6776 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6777 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6778 /// sufficient, a read-write scope will do as well.
6779 pub fn add_scope<St>(mut self, scope: St) -> AnywhereCachResumeCall<'a, C>
6780 where
6781 St: AsRef<str>,
6782 {
6783 self._scopes.insert(String::from(scope.as_ref()));
6784 self
6785 }
6786 /// Identifies the authorization scope(s) for the method you are building.
6787 ///
6788 /// See [`Self::add_scope()`] for details.
6789 pub fn add_scopes<I, St>(mut self, scopes: I) -> AnywhereCachResumeCall<'a, C>
6790 where
6791 I: IntoIterator<Item = St>,
6792 St: AsRef<str>,
6793 {
6794 self._scopes
6795 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6796 self
6797 }
6798
6799 /// Removes all scopes, and no default scope will be used either.
6800 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6801 /// for details).
6802 pub fn clear_scopes(mut self) -> AnywhereCachResumeCall<'a, C> {
6803 self._scopes.clear();
6804 self
6805 }
6806}
6807
6808/// Updates the config(ttl and admissionPolicy) of an Anywhere Cache instance.
6809///
6810/// A builder for the *update* method supported by a *anywhereCach* resource.
6811/// It is not used directly, but through a [`AnywhereCachMethods`] instance.
6812///
6813/// # Example
6814///
6815/// Instantiate a resource method builder
6816///
6817/// ```test_harness,no_run
6818/// # extern crate hyper;
6819/// # extern crate hyper_rustls;
6820/// # extern crate google_storage1 as storage1;
6821/// use storage1::api::AnywhereCache;
6822/// # async fn dox() {
6823/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6824///
6825/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6826/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6827/// # .with_native_roots()
6828/// # .unwrap()
6829/// # .https_only()
6830/// # .enable_http2()
6831/// # .build();
6832///
6833/// # let executor = hyper_util::rt::TokioExecutor::new();
6834/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6835/// # secret,
6836/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6837/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6838/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6839/// # ),
6840/// # ).build().await.unwrap();
6841///
6842/// # let client = hyper_util::client::legacy::Client::builder(
6843/// # hyper_util::rt::TokioExecutor::new()
6844/// # )
6845/// # .build(
6846/// # hyper_rustls::HttpsConnectorBuilder::new()
6847/// # .with_native_roots()
6848/// # .unwrap()
6849/// # .https_or_http()
6850/// # .enable_http2()
6851/// # .build()
6852/// # );
6853/// # let mut hub = Storage::new(client, auth);
6854/// // As the method needs a request, you would usually fill it with the desired information
6855/// // into the respective structure. Some of the parts shown here might not be applicable !
6856/// // Values shown here are possibly random and not representative !
6857/// let mut req = AnywhereCache::default();
6858///
6859/// // You can configure optional parameters by calling the respective setters at will, and
6860/// // execute the final call using `doit()`.
6861/// // Values shown here are possibly random and not representative !
6862/// let result = hub.anywhere_caches().update(req, "bucket", "anywhereCacheId")
6863/// .doit().await;
6864/// # }
6865/// ```
6866pub struct AnywhereCachUpdateCall<'a, C>
6867where
6868 C: 'a,
6869{
6870 hub: &'a Storage<C>,
6871 _request: AnywhereCache,
6872 _bucket: String,
6873 _anywhere_cache_id: String,
6874 _delegate: Option<&'a mut dyn common::Delegate>,
6875 _additional_params: HashMap<String, String>,
6876 _scopes: BTreeSet<String>,
6877}
6878
6879impl<'a, C> common::CallBuilder for AnywhereCachUpdateCall<'a, C> {}
6880
6881impl<'a, C> AnywhereCachUpdateCall<'a, C>
6882where
6883 C: common::Connector,
6884{
6885 /// Perform the operation you have build so far.
6886 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
6887 use std::borrow::Cow;
6888 use std::io::{Read, Seek};
6889
6890 use common::{url::Params, ToParts};
6891 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6892
6893 let mut dd = common::DefaultDelegate;
6894 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6895 dlg.begin(common::MethodInfo {
6896 id: "storage.anywhereCaches.update",
6897 http_method: hyper::Method::PATCH,
6898 });
6899
6900 for &field in ["alt", "bucket", "anywhereCacheId"].iter() {
6901 if self._additional_params.contains_key(field) {
6902 dlg.finished(false);
6903 return Err(common::Error::FieldClash(field));
6904 }
6905 }
6906
6907 let mut params = Params::with_capacity(5 + self._additional_params.len());
6908 params.push("bucket", self._bucket);
6909 params.push("anywhereCacheId", self._anywhere_cache_id);
6910
6911 params.extend(self._additional_params.iter());
6912
6913 params.push("alt", "json");
6914 let mut url = self.hub._base_url.clone() + "b/{bucket}/anywhereCaches/{anywhereCacheId}";
6915 if self._scopes.is_empty() {
6916 self._scopes
6917 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
6918 }
6919
6920 #[allow(clippy::single_element_loop)]
6921 for &(find_this, param_name) in [
6922 ("{bucket}", "bucket"),
6923 ("{anywhereCacheId}", "anywhereCacheId"),
6924 ]
6925 .iter()
6926 {
6927 url = params.uri_replacement(url, param_name, find_this, false);
6928 }
6929 {
6930 let to_remove = ["anywhereCacheId", "bucket"];
6931 params.remove_params(&to_remove);
6932 }
6933
6934 let url = params.parse_with_url(&url);
6935
6936 let mut json_mime_type = mime::APPLICATION_JSON;
6937 let mut request_value_reader = {
6938 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6939 common::remove_json_null_values(&mut value);
6940 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6941 serde_json::to_writer(&mut dst, &value).unwrap();
6942 dst
6943 };
6944 let request_size = request_value_reader
6945 .seek(std::io::SeekFrom::End(0))
6946 .unwrap();
6947 request_value_reader
6948 .seek(std::io::SeekFrom::Start(0))
6949 .unwrap();
6950
6951 loop {
6952 let token = match self
6953 .hub
6954 .auth
6955 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6956 .await
6957 {
6958 Ok(token) => token,
6959 Err(e) => match dlg.token(e) {
6960 Ok(token) => token,
6961 Err(e) => {
6962 dlg.finished(false);
6963 return Err(common::Error::MissingToken(e));
6964 }
6965 },
6966 };
6967 request_value_reader
6968 .seek(std::io::SeekFrom::Start(0))
6969 .unwrap();
6970 let mut req_result = {
6971 let client = &self.hub.client;
6972 dlg.pre_request();
6973 let mut req_builder = hyper::Request::builder()
6974 .method(hyper::Method::PATCH)
6975 .uri(url.as_str())
6976 .header(USER_AGENT, self.hub._user_agent.clone());
6977
6978 if let Some(token) = token.as_ref() {
6979 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6980 }
6981
6982 let request = req_builder
6983 .header(CONTENT_TYPE, json_mime_type.to_string())
6984 .header(CONTENT_LENGTH, request_size as u64)
6985 .body(common::to_body(
6986 request_value_reader.get_ref().clone().into(),
6987 ));
6988
6989 client.request(request.unwrap()).await
6990 };
6991
6992 match req_result {
6993 Err(err) => {
6994 if let common::Retry::After(d) = dlg.http_error(&err) {
6995 sleep(d).await;
6996 continue;
6997 }
6998 dlg.finished(false);
6999 return Err(common::Error::HttpError(err));
7000 }
7001 Ok(res) => {
7002 let (mut parts, body) = res.into_parts();
7003 let mut body = common::Body::new(body);
7004 if !parts.status.is_success() {
7005 let bytes = common::to_bytes(body).await.unwrap_or_default();
7006 let error = serde_json::from_str(&common::to_string(&bytes));
7007 let response = common::to_response(parts, bytes.into());
7008
7009 if let common::Retry::After(d) =
7010 dlg.http_failure(&response, error.as_ref().ok())
7011 {
7012 sleep(d).await;
7013 continue;
7014 }
7015
7016 dlg.finished(false);
7017
7018 return Err(match error {
7019 Ok(value) => common::Error::BadRequest(value),
7020 _ => common::Error::Failure(response),
7021 });
7022 }
7023 let response = {
7024 let bytes = common::to_bytes(body).await.unwrap_or_default();
7025 let encoded = common::to_string(&bytes);
7026 match serde_json::from_str(&encoded) {
7027 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7028 Err(error) => {
7029 dlg.response_json_decode_error(&encoded, &error);
7030 return Err(common::Error::JsonDecodeError(
7031 encoded.to_string(),
7032 error,
7033 ));
7034 }
7035 }
7036 };
7037
7038 dlg.finished(true);
7039 return Ok(response);
7040 }
7041 }
7042 }
7043 }
7044
7045 ///
7046 /// Sets the *request* property to the given value.
7047 ///
7048 /// Even though the property as already been set when instantiating this call,
7049 /// we provide this method for API completeness.
7050 pub fn request(mut self, new_value: AnywhereCache) -> AnywhereCachUpdateCall<'a, C> {
7051 self._request = new_value;
7052 self
7053 }
7054 /// Name of the parent bucket.
7055 ///
7056 /// Sets the *bucket* path property to the given value.
7057 ///
7058 /// Even though the property as already been set when instantiating this call,
7059 /// we provide this method for API completeness.
7060 pub fn bucket(mut self, new_value: &str) -> AnywhereCachUpdateCall<'a, C> {
7061 self._bucket = new_value.to_string();
7062 self
7063 }
7064 /// The ID of requested Anywhere Cache instance.
7065 ///
7066 /// Sets the *anywhere cache id* path property to the given value.
7067 ///
7068 /// Even though the property as already been set when instantiating this call,
7069 /// we provide this method for API completeness.
7070 pub fn anywhere_cache_id(mut self, new_value: &str) -> AnywhereCachUpdateCall<'a, C> {
7071 self._anywhere_cache_id = new_value.to_string();
7072 self
7073 }
7074 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7075 /// while executing the actual API request.
7076 ///
7077 /// ````text
7078 /// It should be used to handle progress information, and to implement a certain level of resilience.
7079 /// ````
7080 ///
7081 /// Sets the *delegate* property to the given value.
7082 pub fn delegate(
7083 mut self,
7084 new_value: &'a mut dyn common::Delegate,
7085 ) -> AnywhereCachUpdateCall<'a, C> {
7086 self._delegate = Some(new_value);
7087 self
7088 }
7089
7090 /// Set any additional parameter of the query string used in the request.
7091 /// It should be used to set parameters which are not yet available through their own
7092 /// setters.
7093 ///
7094 /// Please note that this method must not be used to set any of the known parameters
7095 /// which have their own setter method. If done anyway, the request will fail.
7096 ///
7097 /// # Additional Parameters
7098 ///
7099 /// * *alt* (query-string) - Data format for the response.
7100 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7101 /// * *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.
7102 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7103 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7104 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7105 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
7106 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7107 pub fn param<T>(mut self, name: T, value: T) -> AnywhereCachUpdateCall<'a, C>
7108 where
7109 T: AsRef<str>,
7110 {
7111 self._additional_params
7112 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7113 self
7114 }
7115
7116 /// Identifies the authorization scope for the method you are building.
7117 ///
7118 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7119 /// [`Scope::DevstorageReadWrite`].
7120 ///
7121 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7122 /// tokens for more than one scope.
7123 ///
7124 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7125 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7126 /// sufficient, a read-write scope will do as well.
7127 pub fn add_scope<St>(mut self, scope: St) -> AnywhereCachUpdateCall<'a, C>
7128 where
7129 St: AsRef<str>,
7130 {
7131 self._scopes.insert(String::from(scope.as_ref()));
7132 self
7133 }
7134 /// Identifies the authorization scope(s) for the method you are building.
7135 ///
7136 /// See [`Self::add_scope()`] for details.
7137 pub fn add_scopes<I, St>(mut self, scopes: I) -> AnywhereCachUpdateCall<'a, C>
7138 where
7139 I: IntoIterator<Item = St>,
7140 St: AsRef<str>,
7141 {
7142 self._scopes
7143 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7144 self
7145 }
7146
7147 /// Removes all scopes, and no default scope will be used either.
7148 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7149 /// for details).
7150 pub fn clear_scopes(mut self) -> AnywhereCachUpdateCall<'a, C> {
7151 self._scopes.clear();
7152 self
7153 }
7154}
7155
7156/// Permanently deletes the ACL entry for the specified entity on the specified bucket.
7157///
7158/// A builder for the *delete* method supported by a *bucketAccessControl* resource.
7159/// It is not used directly, but through a [`BucketAccessControlMethods`] instance.
7160///
7161/// # Example
7162///
7163/// Instantiate a resource method builder
7164///
7165/// ```test_harness,no_run
7166/// # extern crate hyper;
7167/// # extern crate hyper_rustls;
7168/// # extern crate google_storage1 as storage1;
7169/// # async fn dox() {
7170/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7171///
7172/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7173/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7174/// # .with_native_roots()
7175/// # .unwrap()
7176/// # .https_only()
7177/// # .enable_http2()
7178/// # .build();
7179///
7180/// # let executor = hyper_util::rt::TokioExecutor::new();
7181/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7182/// # secret,
7183/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7184/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7185/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7186/// # ),
7187/// # ).build().await.unwrap();
7188///
7189/// # let client = hyper_util::client::legacy::Client::builder(
7190/// # hyper_util::rt::TokioExecutor::new()
7191/// # )
7192/// # .build(
7193/// # hyper_rustls::HttpsConnectorBuilder::new()
7194/// # .with_native_roots()
7195/// # .unwrap()
7196/// # .https_or_http()
7197/// # .enable_http2()
7198/// # .build()
7199/// # );
7200/// # let mut hub = Storage::new(client, auth);
7201/// // You can configure optional parameters by calling the respective setters at will, and
7202/// // execute the final call using `doit()`.
7203/// // Values shown here are possibly random and not representative !
7204/// let result = hub.bucket_access_controls().delete("bucket", "entity")
7205/// .user_project("sed")
7206/// .doit().await;
7207/// # }
7208/// ```
7209pub struct BucketAccessControlDeleteCall<'a, C>
7210where
7211 C: 'a,
7212{
7213 hub: &'a Storage<C>,
7214 _bucket: String,
7215 _entity: String,
7216 _user_project: Option<String>,
7217 _delegate: Option<&'a mut dyn common::Delegate>,
7218 _additional_params: HashMap<String, String>,
7219 _scopes: BTreeSet<String>,
7220}
7221
7222impl<'a, C> common::CallBuilder for BucketAccessControlDeleteCall<'a, C> {}
7223
7224impl<'a, C> BucketAccessControlDeleteCall<'a, C>
7225where
7226 C: common::Connector,
7227{
7228 /// Perform the operation you have build so far.
7229 pub async fn doit(mut self) -> common::Result<common::Response> {
7230 use std::borrow::Cow;
7231 use std::io::{Read, Seek};
7232
7233 use common::{url::Params, ToParts};
7234 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7235
7236 let mut dd = common::DefaultDelegate;
7237 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7238 dlg.begin(common::MethodInfo {
7239 id: "storage.bucketAccessControls.delete",
7240 http_method: hyper::Method::DELETE,
7241 });
7242
7243 for &field in ["bucket", "entity", "userProject"].iter() {
7244 if self._additional_params.contains_key(field) {
7245 dlg.finished(false);
7246 return Err(common::Error::FieldClash(field));
7247 }
7248 }
7249
7250 let mut params = Params::with_capacity(4 + self._additional_params.len());
7251 params.push("bucket", self._bucket);
7252 params.push("entity", self._entity);
7253 if let Some(value) = self._user_project.as_ref() {
7254 params.push("userProject", value);
7255 }
7256
7257 params.extend(self._additional_params.iter());
7258
7259 let mut url = self.hub._base_url.clone() + "b/{bucket}/acl/{entity}";
7260 if self._scopes.is_empty() {
7261 self._scopes
7262 .insert(Scope::DevstorageFullControl.as_ref().to_string());
7263 }
7264
7265 #[allow(clippy::single_element_loop)]
7266 for &(find_this, param_name) in [("{bucket}", "bucket"), ("{entity}", "entity")].iter() {
7267 url = params.uri_replacement(url, param_name, find_this, false);
7268 }
7269 {
7270 let to_remove = ["entity", "bucket"];
7271 params.remove_params(&to_remove);
7272 }
7273
7274 let url = params.parse_with_url(&url);
7275
7276 loop {
7277 let token = match self
7278 .hub
7279 .auth
7280 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7281 .await
7282 {
7283 Ok(token) => token,
7284 Err(e) => match dlg.token(e) {
7285 Ok(token) => token,
7286 Err(e) => {
7287 dlg.finished(false);
7288 return Err(common::Error::MissingToken(e));
7289 }
7290 },
7291 };
7292 let mut req_result = {
7293 let client = &self.hub.client;
7294 dlg.pre_request();
7295 let mut req_builder = hyper::Request::builder()
7296 .method(hyper::Method::DELETE)
7297 .uri(url.as_str())
7298 .header(USER_AGENT, self.hub._user_agent.clone());
7299
7300 if let Some(token) = token.as_ref() {
7301 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7302 }
7303
7304 let request = req_builder
7305 .header(CONTENT_LENGTH, 0_u64)
7306 .body(common::to_body::<String>(None));
7307
7308 client.request(request.unwrap()).await
7309 };
7310
7311 match req_result {
7312 Err(err) => {
7313 if let common::Retry::After(d) = dlg.http_error(&err) {
7314 sleep(d).await;
7315 continue;
7316 }
7317 dlg.finished(false);
7318 return Err(common::Error::HttpError(err));
7319 }
7320 Ok(res) => {
7321 let (mut parts, body) = res.into_parts();
7322 let mut body = common::Body::new(body);
7323 if !parts.status.is_success() {
7324 let bytes = common::to_bytes(body).await.unwrap_or_default();
7325 let error = serde_json::from_str(&common::to_string(&bytes));
7326 let response = common::to_response(parts, bytes.into());
7327
7328 if let common::Retry::After(d) =
7329 dlg.http_failure(&response, error.as_ref().ok())
7330 {
7331 sleep(d).await;
7332 continue;
7333 }
7334
7335 dlg.finished(false);
7336
7337 return Err(match error {
7338 Ok(value) => common::Error::BadRequest(value),
7339 _ => common::Error::Failure(response),
7340 });
7341 }
7342 let response = common::Response::from_parts(parts, body);
7343
7344 dlg.finished(true);
7345 return Ok(response);
7346 }
7347 }
7348 }
7349 }
7350
7351 /// Name of a bucket.
7352 ///
7353 /// Sets the *bucket* path property to the given value.
7354 ///
7355 /// Even though the property as already been set when instantiating this call,
7356 /// we provide this method for API completeness.
7357 pub fn bucket(mut self, new_value: &str) -> BucketAccessControlDeleteCall<'a, C> {
7358 self._bucket = new_value.to_string();
7359 self
7360 }
7361 /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
7362 ///
7363 /// Sets the *entity* path property to the given value.
7364 ///
7365 /// Even though the property as already been set when instantiating this call,
7366 /// we provide this method for API completeness.
7367 pub fn entity(mut self, new_value: &str) -> BucketAccessControlDeleteCall<'a, C> {
7368 self._entity = new_value.to_string();
7369 self
7370 }
7371 /// The project to be billed for this request. Required for Requester Pays buckets.
7372 ///
7373 /// Sets the *user project* query property to the given value.
7374 pub fn user_project(mut self, new_value: &str) -> BucketAccessControlDeleteCall<'a, C> {
7375 self._user_project = Some(new_value.to_string());
7376 self
7377 }
7378 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7379 /// while executing the actual API request.
7380 ///
7381 /// ````text
7382 /// It should be used to handle progress information, and to implement a certain level of resilience.
7383 /// ````
7384 ///
7385 /// Sets the *delegate* property to the given value.
7386 pub fn delegate(
7387 mut self,
7388 new_value: &'a mut dyn common::Delegate,
7389 ) -> BucketAccessControlDeleteCall<'a, C> {
7390 self._delegate = Some(new_value);
7391 self
7392 }
7393
7394 /// Set any additional parameter of the query string used in the request.
7395 /// It should be used to set parameters which are not yet available through their own
7396 /// setters.
7397 ///
7398 /// Please note that this method must not be used to set any of the known parameters
7399 /// which have their own setter method. If done anyway, the request will fail.
7400 ///
7401 /// # Additional Parameters
7402 ///
7403 /// * *alt* (query-string) - Data format for the response.
7404 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7405 /// * *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.
7406 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7407 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7408 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7409 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
7410 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7411 pub fn param<T>(mut self, name: T, value: T) -> BucketAccessControlDeleteCall<'a, C>
7412 where
7413 T: AsRef<str>,
7414 {
7415 self._additional_params
7416 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7417 self
7418 }
7419
7420 /// Identifies the authorization scope for the method you are building.
7421 ///
7422 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7423 /// [`Scope::DevstorageFullControl`].
7424 ///
7425 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7426 /// tokens for more than one scope.
7427 ///
7428 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7429 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7430 /// sufficient, a read-write scope will do as well.
7431 pub fn add_scope<St>(mut self, scope: St) -> BucketAccessControlDeleteCall<'a, C>
7432 where
7433 St: AsRef<str>,
7434 {
7435 self._scopes.insert(String::from(scope.as_ref()));
7436 self
7437 }
7438 /// Identifies the authorization scope(s) for the method you are building.
7439 ///
7440 /// See [`Self::add_scope()`] for details.
7441 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketAccessControlDeleteCall<'a, C>
7442 where
7443 I: IntoIterator<Item = St>,
7444 St: AsRef<str>,
7445 {
7446 self._scopes
7447 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7448 self
7449 }
7450
7451 /// Removes all scopes, and no default scope will be used either.
7452 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7453 /// for details).
7454 pub fn clear_scopes(mut self) -> BucketAccessControlDeleteCall<'a, C> {
7455 self._scopes.clear();
7456 self
7457 }
7458}
7459
7460/// Returns the ACL entry for the specified entity on the specified bucket.
7461///
7462/// A builder for the *get* method supported by a *bucketAccessControl* resource.
7463/// It is not used directly, but through a [`BucketAccessControlMethods`] instance.
7464///
7465/// # Example
7466///
7467/// Instantiate a resource method builder
7468///
7469/// ```test_harness,no_run
7470/// # extern crate hyper;
7471/// # extern crate hyper_rustls;
7472/// # extern crate google_storage1 as storage1;
7473/// # async fn dox() {
7474/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7475///
7476/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7477/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7478/// # .with_native_roots()
7479/// # .unwrap()
7480/// # .https_only()
7481/// # .enable_http2()
7482/// # .build();
7483///
7484/// # let executor = hyper_util::rt::TokioExecutor::new();
7485/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7486/// # secret,
7487/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7488/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7489/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7490/// # ),
7491/// # ).build().await.unwrap();
7492///
7493/// # let client = hyper_util::client::legacy::Client::builder(
7494/// # hyper_util::rt::TokioExecutor::new()
7495/// # )
7496/// # .build(
7497/// # hyper_rustls::HttpsConnectorBuilder::new()
7498/// # .with_native_roots()
7499/// # .unwrap()
7500/// # .https_or_http()
7501/// # .enable_http2()
7502/// # .build()
7503/// # );
7504/// # let mut hub = Storage::new(client, auth);
7505/// // You can configure optional parameters by calling the respective setters at will, and
7506/// // execute the final call using `doit()`.
7507/// // Values shown here are possibly random and not representative !
7508/// let result = hub.bucket_access_controls().get("bucket", "entity")
7509/// .user_project("vero")
7510/// .doit().await;
7511/// # }
7512/// ```
7513pub struct BucketAccessControlGetCall<'a, C>
7514where
7515 C: 'a,
7516{
7517 hub: &'a Storage<C>,
7518 _bucket: String,
7519 _entity: String,
7520 _user_project: Option<String>,
7521 _delegate: Option<&'a mut dyn common::Delegate>,
7522 _additional_params: HashMap<String, String>,
7523 _scopes: BTreeSet<String>,
7524}
7525
7526impl<'a, C> common::CallBuilder for BucketAccessControlGetCall<'a, C> {}
7527
7528impl<'a, C> BucketAccessControlGetCall<'a, C>
7529where
7530 C: common::Connector,
7531{
7532 /// Perform the operation you have build so far.
7533 pub async fn doit(mut self) -> common::Result<(common::Response, BucketAccessControl)> {
7534 use std::borrow::Cow;
7535 use std::io::{Read, Seek};
7536
7537 use common::{url::Params, ToParts};
7538 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7539
7540 let mut dd = common::DefaultDelegate;
7541 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7542 dlg.begin(common::MethodInfo {
7543 id: "storage.bucketAccessControls.get",
7544 http_method: hyper::Method::GET,
7545 });
7546
7547 for &field in ["alt", "bucket", "entity", "userProject"].iter() {
7548 if self._additional_params.contains_key(field) {
7549 dlg.finished(false);
7550 return Err(common::Error::FieldClash(field));
7551 }
7552 }
7553
7554 let mut params = Params::with_capacity(5 + self._additional_params.len());
7555 params.push("bucket", self._bucket);
7556 params.push("entity", self._entity);
7557 if let Some(value) = self._user_project.as_ref() {
7558 params.push("userProject", value);
7559 }
7560
7561 params.extend(self._additional_params.iter());
7562
7563 params.push("alt", "json");
7564 let mut url = self.hub._base_url.clone() + "b/{bucket}/acl/{entity}";
7565 if self._scopes.is_empty() {
7566 self._scopes
7567 .insert(Scope::DevstorageFullControl.as_ref().to_string());
7568 }
7569
7570 #[allow(clippy::single_element_loop)]
7571 for &(find_this, param_name) in [("{bucket}", "bucket"), ("{entity}", "entity")].iter() {
7572 url = params.uri_replacement(url, param_name, find_this, false);
7573 }
7574 {
7575 let to_remove = ["entity", "bucket"];
7576 params.remove_params(&to_remove);
7577 }
7578
7579 let url = params.parse_with_url(&url);
7580
7581 loop {
7582 let token = match self
7583 .hub
7584 .auth
7585 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7586 .await
7587 {
7588 Ok(token) => token,
7589 Err(e) => match dlg.token(e) {
7590 Ok(token) => token,
7591 Err(e) => {
7592 dlg.finished(false);
7593 return Err(common::Error::MissingToken(e));
7594 }
7595 },
7596 };
7597 let mut req_result = {
7598 let client = &self.hub.client;
7599 dlg.pre_request();
7600 let mut req_builder = hyper::Request::builder()
7601 .method(hyper::Method::GET)
7602 .uri(url.as_str())
7603 .header(USER_AGENT, self.hub._user_agent.clone());
7604
7605 if let Some(token) = token.as_ref() {
7606 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7607 }
7608
7609 let request = req_builder
7610 .header(CONTENT_LENGTH, 0_u64)
7611 .body(common::to_body::<String>(None));
7612
7613 client.request(request.unwrap()).await
7614 };
7615
7616 match req_result {
7617 Err(err) => {
7618 if let common::Retry::After(d) = dlg.http_error(&err) {
7619 sleep(d).await;
7620 continue;
7621 }
7622 dlg.finished(false);
7623 return Err(common::Error::HttpError(err));
7624 }
7625 Ok(res) => {
7626 let (mut parts, body) = res.into_parts();
7627 let mut body = common::Body::new(body);
7628 if !parts.status.is_success() {
7629 let bytes = common::to_bytes(body).await.unwrap_or_default();
7630 let error = serde_json::from_str(&common::to_string(&bytes));
7631 let response = common::to_response(parts, bytes.into());
7632
7633 if let common::Retry::After(d) =
7634 dlg.http_failure(&response, error.as_ref().ok())
7635 {
7636 sleep(d).await;
7637 continue;
7638 }
7639
7640 dlg.finished(false);
7641
7642 return Err(match error {
7643 Ok(value) => common::Error::BadRequest(value),
7644 _ => common::Error::Failure(response),
7645 });
7646 }
7647 let response = {
7648 let bytes = common::to_bytes(body).await.unwrap_or_default();
7649 let encoded = common::to_string(&bytes);
7650 match serde_json::from_str(&encoded) {
7651 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7652 Err(error) => {
7653 dlg.response_json_decode_error(&encoded, &error);
7654 return Err(common::Error::JsonDecodeError(
7655 encoded.to_string(),
7656 error,
7657 ));
7658 }
7659 }
7660 };
7661
7662 dlg.finished(true);
7663 return Ok(response);
7664 }
7665 }
7666 }
7667 }
7668
7669 /// Name of a bucket.
7670 ///
7671 /// Sets the *bucket* path property to the given value.
7672 ///
7673 /// Even though the property as already been set when instantiating this call,
7674 /// we provide this method for API completeness.
7675 pub fn bucket(mut self, new_value: &str) -> BucketAccessControlGetCall<'a, C> {
7676 self._bucket = new_value.to_string();
7677 self
7678 }
7679 /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
7680 ///
7681 /// Sets the *entity* path property to the given value.
7682 ///
7683 /// Even though the property as already been set when instantiating this call,
7684 /// we provide this method for API completeness.
7685 pub fn entity(mut self, new_value: &str) -> BucketAccessControlGetCall<'a, C> {
7686 self._entity = new_value.to_string();
7687 self
7688 }
7689 /// The project to be billed for this request. Required for Requester Pays buckets.
7690 ///
7691 /// Sets the *user project* query property to the given value.
7692 pub fn user_project(mut self, new_value: &str) -> BucketAccessControlGetCall<'a, C> {
7693 self._user_project = Some(new_value.to_string());
7694 self
7695 }
7696 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7697 /// while executing the actual API request.
7698 ///
7699 /// ````text
7700 /// It should be used to handle progress information, and to implement a certain level of resilience.
7701 /// ````
7702 ///
7703 /// Sets the *delegate* property to the given value.
7704 pub fn delegate(
7705 mut self,
7706 new_value: &'a mut dyn common::Delegate,
7707 ) -> BucketAccessControlGetCall<'a, C> {
7708 self._delegate = Some(new_value);
7709 self
7710 }
7711
7712 /// Set any additional parameter of the query string used in the request.
7713 /// It should be used to set parameters which are not yet available through their own
7714 /// setters.
7715 ///
7716 /// Please note that this method must not be used to set any of the known parameters
7717 /// which have their own setter method. If done anyway, the request will fail.
7718 ///
7719 /// # Additional Parameters
7720 ///
7721 /// * *alt* (query-string) - Data format for the response.
7722 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7723 /// * *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.
7724 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7725 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7726 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7727 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
7728 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7729 pub fn param<T>(mut self, name: T, value: T) -> BucketAccessControlGetCall<'a, C>
7730 where
7731 T: AsRef<str>,
7732 {
7733 self._additional_params
7734 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7735 self
7736 }
7737
7738 /// Identifies the authorization scope for the method you are building.
7739 ///
7740 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7741 /// [`Scope::DevstorageFullControl`].
7742 ///
7743 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7744 /// tokens for more than one scope.
7745 ///
7746 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7747 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7748 /// sufficient, a read-write scope will do as well.
7749 pub fn add_scope<St>(mut self, scope: St) -> BucketAccessControlGetCall<'a, C>
7750 where
7751 St: AsRef<str>,
7752 {
7753 self._scopes.insert(String::from(scope.as_ref()));
7754 self
7755 }
7756 /// Identifies the authorization scope(s) for the method you are building.
7757 ///
7758 /// See [`Self::add_scope()`] for details.
7759 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketAccessControlGetCall<'a, C>
7760 where
7761 I: IntoIterator<Item = St>,
7762 St: AsRef<str>,
7763 {
7764 self._scopes
7765 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7766 self
7767 }
7768
7769 /// Removes all scopes, and no default scope will be used either.
7770 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7771 /// for details).
7772 pub fn clear_scopes(mut self) -> BucketAccessControlGetCall<'a, C> {
7773 self._scopes.clear();
7774 self
7775 }
7776}
7777
7778/// Creates a new ACL entry on the specified bucket.
7779///
7780/// A builder for the *insert* method supported by a *bucketAccessControl* resource.
7781/// It is not used directly, but through a [`BucketAccessControlMethods`] instance.
7782///
7783/// # Example
7784///
7785/// Instantiate a resource method builder
7786///
7787/// ```test_harness,no_run
7788/// # extern crate hyper;
7789/// # extern crate hyper_rustls;
7790/// # extern crate google_storage1 as storage1;
7791/// use storage1::api::BucketAccessControl;
7792/// # async fn dox() {
7793/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7794///
7795/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7796/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7797/// # .with_native_roots()
7798/// # .unwrap()
7799/// # .https_only()
7800/// # .enable_http2()
7801/// # .build();
7802///
7803/// # let executor = hyper_util::rt::TokioExecutor::new();
7804/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7805/// # secret,
7806/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7807/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7808/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7809/// # ),
7810/// # ).build().await.unwrap();
7811///
7812/// # let client = hyper_util::client::legacy::Client::builder(
7813/// # hyper_util::rt::TokioExecutor::new()
7814/// # )
7815/// # .build(
7816/// # hyper_rustls::HttpsConnectorBuilder::new()
7817/// # .with_native_roots()
7818/// # .unwrap()
7819/// # .https_or_http()
7820/// # .enable_http2()
7821/// # .build()
7822/// # );
7823/// # let mut hub = Storage::new(client, auth);
7824/// // As the method needs a request, you would usually fill it with the desired information
7825/// // into the respective structure. Some of the parts shown here might not be applicable !
7826/// // Values shown here are possibly random and not representative !
7827/// let mut req = BucketAccessControl::default();
7828///
7829/// // You can configure optional parameters by calling the respective setters at will, and
7830/// // execute the final call using `doit()`.
7831/// // Values shown here are possibly random and not representative !
7832/// let result = hub.bucket_access_controls().insert(req, "bucket")
7833/// .user_project("sed")
7834/// .doit().await;
7835/// # }
7836/// ```
7837pub struct BucketAccessControlInsertCall<'a, C>
7838where
7839 C: 'a,
7840{
7841 hub: &'a Storage<C>,
7842 _request: BucketAccessControl,
7843 _bucket: String,
7844 _user_project: Option<String>,
7845 _delegate: Option<&'a mut dyn common::Delegate>,
7846 _additional_params: HashMap<String, String>,
7847 _scopes: BTreeSet<String>,
7848}
7849
7850impl<'a, C> common::CallBuilder for BucketAccessControlInsertCall<'a, C> {}
7851
7852impl<'a, C> BucketAccessControlInsertCall<'a, C>
7853where
7854 C: common::Connector,
7855{
7856 /// Perform the operation you have build so far.
7857 pub async fn doit(mut self) -> common::Result<(common::Response, BucketAccessControl)> {
7858 use std::borrow::Cow;
7859 use std::io::{Read, Seek};
7860
7861 use common::{url::Params, ToParts};
7862 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7863
7864 let mut dd = common::DefaultDelegate;
7865 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7866 dlg.begin(common::MethodInfo {
7867 id: "storage.bucketAccessControls.insert",
7868 http_method: hyper::Method::POST,
7869 });
7870
7871 for &field in ["alt", "bucket", "userProject"].iter() {
7872 if self._additional_params.contains_key(field) {
7873 dlg.finished(false);
7874 return Err(common::Error::FieldClash(field));
7875 }
7876 }
7877
7878 let mut params = Params::with_capacity(5 + self._additional_params.len());
7879 params.push("bucket", self._bucket);
7880 if let Some(value) = self._user_project.as_ref() {
7881 params.push("userProject", value);
7882 }
7883
7884 params.extend(self._additional_params.iter());
7885
7886 params.push("alt", "json");
7887 let mut url = self.hub._base_url.clone() + "b/{bucket}/acl";
7888 if self._scopes.is_empty() {
7889 self._scopes
7890 .insert(Scope::DevstorageFullControl.as_ref().to_string());
7891 }
7892
7893 #[allow(clippy::single_element_loop)]
7894 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
7895 url = params.uri_replacement(url, param_name, find_this, false);
7896 }
7897 {
7898 let to_remove = ["bucket"];
7899 params.remove_params(&to_remove);
7900 }
7901
7902 let url = params.parse_with_url(&url);
7903
7904 let mut json_mime_type = mime::APPLICATION_JSON;
7905 let mut request_value_reader = {
7906 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7907 common::remove_json_null_values(&mut value);
7908 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7909 serde_json::to_writer(&mut dst, &value).unwrap();
7910 dst
7911 };
7912 let request_size = request_value_reader
7913 .seek(std::io::SeekFrom::End(0))
7914 .unwrap();
7915 request_value_reader
7916 .seek(std::io::SeekFrom::Start(0))
7917 .unwrap();
7918
7919 loop {
7920 let token = match self
7921 .hub
7922 .auth
7923 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7924 .await
7925 {
7926 Ok(token) => token,
7927 Err(e) => match dlg.token(e) {
7928 Ok(token) => token,
7929 Err(e) => {
7930 dlg.finished(false);
7931 return Err(common::Error::MissingToken(e));
7932 }
7933 },
7934 };
7935 request_value_reader
7936 .seek(std::io::SeekFrom::Start(0))
7937 .unwrap();
7938 let mut req_result = {
7939 let client = &self.hub.client;
7940 dlg.pre_request();
7941 let mut req_builder = hyper::Request::builder()
7942 .method(hyper::Method::POST)
7943 .uri(url.as_str())
7944 .header(USER_AGENT, self.hub._user_agent.clone());
7945
7946 if let Some(token) = token.as_ref() {
7947 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7948 }
7949
7950 let request = req_builder
7951 .header(CONTENT_TYPE, json_mime_type.to_string())
7952 .header(CONTENT_LENGTH, request_size as u64)
7953 .body(common::to_body(
7954 request_value_reader.get_ref().clone().into(),
7955 ));
7956
7957 client.request(request.unwrap()).await
7958 };
7959
7960 match req_result {
7961 Err(err) => {
7962 if let common::Retry::After(d) = dlg.http_error(&err) {
7963 sleep(d).await;
7964 continue;
7965 }
7966 dlg.finished(false);
7967 return Err(common::Error::HttpError(err));
7968 }
7969 Ok(res) => {
7970 let (mut parts, body) = res.into_parts();
7971 let mut body = common::Body::new(body);
7972 if !parts.status.is_success() {
7973 let bytes = common::to_bytes(body).await.unwrap_or_default();
7974 let error = serde_json::from_str(&common::to_string(&bytes));
7975 let response = common::to_response(parts, bytes.into());
7976
7977 if let common::Retry::After(d) =
7978 dlg.http_failure(&response, error.as_ref().ok())
7979 {
7980 sleep(d).await;
7981 continue;
7982 }
7983
7984 dlg.finished(false);
7985
7986 return Err(match error {
7987 Ok(value) => common::Error::BadRequest(value),
7988 _ => common::Error::Failure(response),
7989 });
7990 }
7991 let response = {
7992 let bytes = common::to_bytes(body).await.unwrap_or_default();
7993 let encoded = common::to_string(&bytes);
7994 match serde_json::from_str(&encoded) {
7995 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7996 Err(error) => {
7997 dlg.response_json_decode_error(&encoded, &error);
7998 return Err(common::Error::JsonDecodeError(
7999 encoded.to_string(),
8000 error,
8001 ));
8002 }
8003 }
8004 };
8005
8006 dlg.finished(true);
8007 return Ok(response);
8008 }
8009 }
8010 }
8011 }
8012
8013 ///
8014 /// Sets the *request* property to the given value.
8015 ///
8016 /// Even though the property as already been set when instantiating this call,
8017 /// we provide this method for API completeness.
8018 pub fn request(
8019 mut self,
8020 new_value: BucketAccessControl,
8021 ) -> BucketAccessControlInsertCall<'a, C> {
8022 self._request = new_value;
8023 self
8024 }
8025 /// Name of a bucket.
8026 ///
8027 /// Sets the *bucket* path property to the given value.
8028 ///
8029 /// Even though the property as already been set when instantiating this call,
8030 /// we provide this method for API completeness.
8031 pub fn bucket(mut self, new_value: &str) -> BucketAccessControlInsertCall<'a, C> {
8032 self._bucket = new_value.to_string();
8033 self
8034 }
8035 /// The project to be billed for this request. Required for Requester Pays buckets.
8036 ///
8037 /// Sets the *user project* query property to the given value.
8038 pub fn user_project(mut self, new_value: &str) -> BucketAccessControlInsertCall<'a, C> {
8039 self._user_project = Some(new_value.to_string());
8040 self
8041 }
8042 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8043 /// while executing the actual API request.
8044 ///
8045 /// ````text
8046 /// It should be used to handle progress information, and to implement a certain level of resilience.
8047 /// ````
8048 ///
8049 /// Sets the *delegate* property to the given value.
8050 pub fn delegate(
8051 mut self,
8052 new_value: &'a mut dyn common::Delegate,
8053 ) -> BucketAccessControlInsertCall<'a, C> {
8054 self._delegate = Some(new_value);
8055 self
8056 }
8057
8058 /// Set any additional parameter of the query string used in the request.
8059 /// It should be used to set parameters which are not yet available through their own
8060 /// setters.
8061 ///
8062 /// Please note that this method must not be used to set any of the known parameters
8063 /// which have their own setter method. If done anyway, the request will fail.
8064 ///
8065 /// # Additional Parameters
8066 ///
8067 /// * *alt* (query-string) - Data format for the response.
8068 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8069 /// * *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.
8070 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8071 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8072 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8073 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
8074 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8075 pub fn param<T>(mut self, name: T, value: T) -> BucketAccessControlInsertCall<'a, C>
8076 where
8077 T: AsRef<str>,
8078 {
8079 self._additional_params
8080 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8081 self
8082 }
8083
8084 /// Identifies the authorization scope for the method you are building.
8085 ///
8086 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8087 /// [`Scope::DevstorageFullControl`].
8088 ///
8089 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8090 /// tokens for more than one scope.
8091 ///
8092 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8093 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8094 /// sufficient, a read-write scope will do as well.
8095 pub fn add_scope<St>(mut self, scope: St) -> BucketAccessControlInsertCall<'a, C>
8096 where
8097 St: AsRef<str>,
8098 {
8099 self._scopes.insert(String::from(scope.as_ref()));
8100 self
8101 }
8102 /// Identifies the authorization scope(s) for the method you are building.
8103 ///
8104 /// See [`Self::add_scope()`] for details.
8105 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketAccessControlInsertCall<'a, C>
8106 where
8107 I: IntoIterator<Item = St>,
8108 St: AsRef<str>,
8109 {
8110 self._scopes
8111 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8112 self
8113 }
8114
8115 /// Removes all scopes, and no default scope will be used either.
8116 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8117 /// for details).
8118 pub fn clear_scopes(mut self) -> BucketAccessControlInsertCall<'a, C> {
8119 self._scopes.clear();
8120 self
8121 }
8122}
8123
8124/// Retrieves ACL entries on the specified bucket.
8125///
8126/// A builder for the *list* method supported by a *bucketAccessControl* resource.
8127/// It is not used directly, but through a [`BucketAccessControlMethods`] instance.
8128///
8129/// # Example
8130///
8131/// Instantiate a resource method builder
8132///
8133/// ```test_harness,no_run
8134/// # extern crate hyper;
8135/// # extern crate hyper_rustls;
8136/// # extern crate google_storage1 as storage1;
8137/// # async fn dox() {
8138/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8139///
8140/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8141/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8142/// # .with_native_roots()
8143/// # .unwrap()
8144/// # .https_only()
8145/// # .enable_http2()
8146/// # .build();
8147///
8148/// # let executor = hyper_util::rt::TokioExecutor::new();
8149/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8150/// # secret,
8151/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8152/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8153/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8154/// # ),
8155/// # ).build().await.unwrap();
8156///
8157/// # let client = hyper_util::client::legacy::Client::builder(
8158/// # hyper_util::rt::TokioExecutor::new()
8159/// # )
8160/// # .build(
8161/// # hyper_rustls::HttpsConnectorBuilder::new()
8162/// # .with_native_roots()
8163/// # .unwrap()
8164/// # .https_or_http()
8165/// # .enable_http2()
8166/// # .build()
8167/// # );
8168/// # let mut hub = Storage::new(client, auth);
8169/// // You can configure optional parameters by calling the respective setters at will, and
8170/// // execute the final call using `doit()`.
8171/// // Values shown here are possibly random and not representative !
8172/// let result = hub.bucket_access_controls().list("bucket")
8173/// .user_project("dolore")
8174/// .doit().await;
8175/// # }
8176/// ```
8177pub struct BucketAccessControlListCall<'a, C>
8178where
8179 C: 'a,
8180{
8181 hub: &'a Storage<C>,
8182 _bucket: String,
8183 _user_project: Option<String>,
8184 _delegate: Option<&'a mut dyn common::Delegate>,
8185 _additional_params: HashMap<String, String>,
8186 _scopes: BTreeSet<String>,
8187}
8188
8189impl<'a, C> common::CallBuilder for BucketAccessControlListCall<'a, C> {}
8190
8191impl<'a, C> BucketAccessControlListCall<'a, C>
8192where
8193 C: common::Connector,
8194{
8195 /// Perform the operation you have build so far.
8196 pub async fn doit(mut self) -> common::Result<(common::Response, BucketAccessControls)> {
8197 use std::borrow::Cow;
8198 use std::io::{Read, Seek};
8199
8200 use common::{url::Params, ToParts};
8201 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8202
8203 let mut dd = common::DefaultDelegate;
8204 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8205 dlg.begin(common::MethodInfo {
8206 id: "storage.bucketAccessControls.list",
8207 http_method: hyper::Method::GET,
8208 });
8209
8210 for &field in ["alt", "bucket", "userProject"].iter() {
8211 if self._additional_params.contains_key(field) {
8212 dlg.finished(false);
8213 return Err(common::Error::FieldClash(field));
8214 }
8215 }
8216
8217 let mut params = Params::with_capacity(4 + self._additional_params.len());
8218 params.push("bucket", self._bucket);
8219 if let Some(value) = self._user_project.as_ref() {
8220 params.push("userProject", value);
8221 }
8222
8223 params.extend(self._additional_params.iter());
8224
8225 params.push("alt", "json");
8226 let mut url = self.hub._base_url.clone() + "b/{bucket}/acl";
8227 if self._scopes.is_empty() {
8228 self._scopes
8229 .insert(Scope::DevstorageFullControl.as_ref().to_string());
8230 }
8231
8232 #[allow(clippy::single_element_loop)]
8233 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
8234 url = params.uri_replacement(url, param_name, find_this, false);
8235 }
8236 {
8237 let to_remove = ["bucket"];
8238 params.remove_params(&to_remove);
8239 }
8240
8241 let url = params.parse_with_url(&url);
8242
8243 loop {
8244 let token = match self
8245 .hub
8246 .auth
8247 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8248 .await
8249 {
8250 Ok(token) => token,
8251 Err(e) => match dlg.token(e) {
8252 Ok(token) => token,
8253 Err(e) => {
8254 dlg.finished(false);
8255 return Err(common::Error::MissingToken(e));
8256 }
8257 },
8258 };
8259 let mut req_result = {
8260 let client = &self.hub.client;
8261 dlg.pre_request();
8262 let mut req_builder = hyper::Request::builder()
8263 .method(hyper::Method::GET)
8264 .uri(url.as_str())
8265 .header(USER_AGENT, self.hub._user_agent.clone());
8266
8267 if let Some(token) = token.as_ref() {
8268 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8269 }
8270
8271 let request = req_builder
8272 .header(CONTENT_LENGTH, 0_u64)
8273 .body(common::to_body::<String>(None));
8274
8275 client.request(request.unwrap()).await
8276 };
8277
8278 match req_result {
8279 Err(err) => {
8280 if let common::Retry::After(d) = dlg.http_error(&err) {
8281 sleep(d).await;
8282 continue;
8283 }
8284 dlg.finished(false);
8285 return Err(common::Error::HttpError(err));
8286 }
8287 Ok(res) => {
8288 let (mut parts, body) = res.into_parts();
8289 let mut body = common::Body::new(body);
8290 if !parts.status.is_success() {
8291 let bytes = common::to_bytes(body).await.unwrap_or_default();
8292 let error = serde_json::from_str(&common::to_string(&bytes));
8293 let response = common::to_response(parts, bytes.into());
8294
8295 if let common::Retry::After(d) =
8296 dlg.http_failure(&response, error.as_ref().ok())
8297 {
8298 sleep(d).await;
8299 continue;
8300 }
8301
8302 dlg.finished(false);
8303
8304 return Err(match error {
8305 Ok(value) => common::Error::BadRequest(value),
8306 _ => common::Error::Failure(response),
8307 });
8308 }
8309 let response = {
8310 let bytes = common::to_bytes(body).await.unwrap_or_default();
8311 let encoded = common::to_string(&bytes);
8312 match serde_json::from_str(&encoded) {
8313 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8314 Err(error) => {
8315 dlg.response_json_decode_error(&encoded, &error);
8316 return Err(common::Error::JsonDecodeError(
8317 encoded.to_string(),
8318 error,
8319 ));
8320 }
8321 }
8322 };
8323
8324 dlg.finished(true);
8325 return Ok(response);
8326 }
8327 }
8328 }
8329 }
8330
8331 /// Name of a bucket.
8332 ///
8333 /// Sets the *bucket* path property to the given value.
8334 ///
8335 /// Even though the property as already been set when instantiating this call,
8336 /// we provide this method for API completeness.
8337 pub fn bucket(mut self, new_value: &str) -> BucketAccessControlListCall<'a, C> {
8338 self._bucket = new_value.to_string();
8339 self
8340 }
8341 /// The project to be billed for this request. Required for Requester Pays buckets.
8342 ///
8343 /// Sets the *user project* query property to the given value.
8344 pub fn user_project(mut self, new_value: &str) -> BucketAccessControlListCall<'a, C> {
8345 self._user_project = Some(new_value.to_string());
8346 self
8347 }
8348 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8349 /// while executing the actual API request.
8350 ///
8351 /// ````text
8352 /// It should be used to handle progress information, and to implement a certain level of resilience.
8353 /// ````
8354 ///
8355 /// Sets the *delegate* property to the given value.
8356 pub fn delegate(
8357 mut self,
8358 new_value: &'a mut dyn common::Delegate,
8359 ) -> BucketAccessControlListCall<'a, C> {
8360 self._delegate = Some(new_value);
8361 self
8362 }
8363
8364 /// Set any additional parameter of the query string used in the request.
8365 /// It should be used to set parameters which are not yet available through their own
8366 /// setters.
8367 ///
8368 /// Please note that this method must not be used to set any of the known parameters
8369 /// which have their own setter method. If done anyway, the request will fail.
8370 ///
8371 /// # Additional Parameters
8372 ///
8373 /// * *alt* (query-string) - Data format for the response.
8374 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8375 /// * *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.
8376 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8377 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8378 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8379 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
8380 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8381 pub fn param<T>(mut self, name: T, value: T) -> BucketAccessControlListCall<'a, C>
8382 where
8383 T: AsRef<str>,
8384 {
8385 self._additional_params
8386 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8387 self
8388 }
8389
8390 /// Identifies the authorization scope for the method you are building.
8391 ///
8392 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8393 /// [`Scope::DevstorageFullControl`].
8394 ///
8395 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8396 /// tokens for more than one scope.
8397 ///
8398 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8399 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8400 /// sufficient, a read-write scope will do as well.
8401 pub fn add_scope<St>(mut self, scope: St) -> BucketAccessControlListCall<'a, C>
8402 where
8403 St: AsRef<str>,
8404 {
8405 self._scopes.insert(String::from(scope.as_ref()));
8406 self
8407 }
8408 /// Identifies the authorization scope(s) for the method you are building.
8409 ///
8410 /// See [`Self::add_scope()`] for details.
8411 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketAccessControlListCall<'a, C>
8412 where
8413 I: IntoIterator<Item = St>,
8414 St: AsRef<str>,
8415 {
8416 self._scopes
8417 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8418 self
8419 }
8420
8421 /// Removes all scopes, and no default scope will be used either.
8422 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8423 /// for details).
8424 pub fn clear_scopes(mut self) -> BucketAccessControlListCall<'a, C> {
8425 self._scopes.clear();
8426 self
8427 }
8428}
8429
8430/// Patches an ACL entry on the specified bucket.
8431///
8432/// A builder for the *patch* method supported by a *bucketAccessControl* resource.
8433/// It is not used directly, but through a [`BucketAccessControlMethods`] instance.
8434///
8435/// # Example
8436///
8437/// Instantiate a resource method builder
8438///
8439/// ```test_harness,no_run
8440/// # extern crate hyper;
8441/// # extern crate hyper_rustls;
8442/// # extern crate google_storage1 as storage1;
8443/// use storage1::api::BucketAccessControl;
8444/// # async fn dox() {
8445/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8446///
8447/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8448/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8449/// # .with_native_roots()
8450/// # .unwrap()
8451/// # .https_only()
8452/// # .enable_http2()
8453/// # .build();
8454///
8455/// # let executor = hyper_util::rt::TokioExecutor::new();
8456/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8457/// # secret,
8458/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8459/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8460/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8461/// # ),
8462/// # ).build().await.unwrap();
8463///
8464/// # let client = hyper_util::client::legacy::Client::builder(
8465/// # hyper_util::rt::TokioExecutor::new()
8466/// # )
8467/// # .build(
8468/// # hyper_rustls::HttpsConnectorBuilder::new()
8469/// # .with_native_roots()
8470/// # .unwrap()
8471/// # .https_or_http()
8472/// # .enable_http2()
8473/// # .build()
8474/// # );
8475/// # let mut hub = Storage::new(client, auth);
8476/// // As the method needs a request, you would usually fill it with the desired information
8477/// // into the respective structure. Some of the parts shown here might not be applicable !
8478/// // Values shown here are possibly random and not representative !
8479/// let mut req = BucketAccessControl::default();
8480///
8481/// // You can configure optional parameters by calling the respective setters at will, and
8482/// // execute the final call using `doit()`.
8483/// // Values shown here are possibly random and not representative !
8484/// let result = hub.bucket_access_controls().patch(req, "bucket", "entity")
8485/// .user_project("amet.")
8486/// .doit().await;
8487/// # }
8488/// ```
8489pub struct BucketAccessControlPatchCall<'a, C>
8490where
8491 C: 'a,
8492{
8493 hub: &'a Storage<C>,
8494 _request: BucketAccessControl,
8495 _bucket: String,
8496 _entity: String,
8497 _user_project: Option<String>,
8498 _delegate: Option<&'a mut dyn common::Delegate>,
8499 _additional_params: HashMap<String, String>,
8500 _scopes: BTreeSet<String>,
8501}
8502
8503impl<'a, C> common::CallBuilder for BucketAccessControlPatchCall<'a, C> {}
8504
8505impl<'a, C> BucketAccessControlPatchCall<'a, C>
8506where
8507 C: common::Connector,
8508{
8509 /// Perform the operation you have build so far.
8510 pub async fn doit(mut self) -> common::Result<(common::Response, BucketAccessControl)> {
8511 use std::borrow::Cow;
8512 use std::io::{Read, Seek};
8513
8514 use common::{url::Params, ToParts};
8515 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8516
8517 let mut dd = common::DefaultDelegate;
8518 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8519 dlg.begin(common::MethodInfo {
8520 id: "storage.bucketAccessControls.patch",
8521 http_method: hyper::Method::PATCH,
8522 });
8523
8524 for &field in ["alt", "bucket", "entity", "userProject"].iter() {
8525 if self._additional_params.contains_key(field) {
8526 dlg.finished(false);
8527 return Err(common::Error::FieldClash(field));
8528 }
8529 }
8530
8531 let mut params = Params::with_capacity(6 + self._additional_params.len());
8532 params.push("bucket", self._bucket);
8533 params.push("entity", self._entity);
8534 if let Some(value) = self._user_project.as_ref() {
8535 params.push("userProject", value);
8536 }
8537
8538 params.extend(self._additional_params.iter());
8539
8540 params.push("alt", "json");
8541 let mut url = self.hub._base_url.clone() + "b/{bucket}/acl/{entity}";
8542 if self._scopes.is_empty() {
8543 self._scopes
8544 .insert(Scope::DevstorageFullControl.as_ref().to_string());
8545 }
8546
8547 #[allow(clippy::single_element_loop)]
8548 for &(find_this, param_name) in [("{bucket}", "bucket"), ("{entity}", "entity")].iter() {
8549 url = params.uri_replacement(url, param_name, find_this, false);
8550 }
8551 {
8552 let to_remove = ["entity", "bucket"];
8553 params.remove_params(&to_remove);
8554 }
8555
8556 let url = params.parse_with_url(&url);
8557
8558 let mut json_mime_type = mime::APPLICATION_JSON;
8559 let mut request_value_reader = {
8560 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8561 common::remove_json_null_values(&mut value);
8562 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8563 serde_json::to_writer(&mut dst, &value).unwrap();
8564 dst
8565 };
8566 let request_size = request_value_reader
8567 .seek(std::io::SeekFrom::End(0))
8568 .unwrap();
8569 request_value_reader
8570 .seek(std::io::SeekFrom::Start(0))
8571 .unwrap();
8572
8573 loop {
8574 let token = match self
8575 .hub
8576 .auth
8577 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8578 .await
8579 {
8580 Ok(token) => token,
8581 Err(e) => match dlg.token(e) {
8582 Ok(token) => token,
8583 Err(e) => {
8584 dlg.finished(false);
8585 return Err(common::Error::MissingToken(e));
8586 }
8587 },
8588 };
8589 request_value_reader
8590 .seek(std::io::SeekFrom::Start(0))
8591 .unwrap();
8592 let mut req_result = {
8593 let client = &self.hub.client;
8594 dlg.pre_request();
8595 let mut req_builder = hyper::Request::builder()
8596 .method(hyper::Method::PATCH)
8597 .uri(url.as_str())
8598 .header(USER_AGENT, self.hub._user_agent.clone());
8599
8600 if let Some(token) = token.as_ref() {
8601 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8602 }
8603
8604 let request = req_builder
8605 .header(CONTENT_TYPE, json_mime_type.to_string())
8606 .header(CONTENT_LENGTH, request_size as u64)
8607 .body(common::to_body(
8608 request_value_reader.get_ref().clone().into(),
8609 ));
8610
8611 client.request(request.unwrap()).await
8612 };
8613
8614 match req_result {
8615 Err(err) => {
8616 if let common::Retry::After(d) = dlg.http_error(&err) {
8617 sleep(d).await;
8618 continue;
8619 }
8620 dlg.finished(false);
8621 return Err(common::Error::HttpError(err));
8622 }
8623 Ok(res) => {
8624 let (mut parts, body) = res.into_parts();
8625 let mut body = common::Body::new(body);
8626 if !parts.status.is_success() {
8627 let bytes = common::to_bytes(body).await.unwrap_or_default();
8628 let error = serde_json::from_str(&common::to_string(&bytes));
8629 let response = common::to_response(parts, bytes.into());
8630
8631 if let common::Retry::After(d) =
8632 dlg.http_failure(&response, error.as_ref().ok())
8633 {
8634 sleep(d).await;
8635 continue;
8636 }
8637
8638 dlg.finished(false);
8639
8640 return Err(match error {
8641 Ok(value) => common::Error::BadRequest(value),
8642 _ => common::Error::Failure(response),
8643 });
8644 }
8645 let response = {
8646 let bytes = common::to_bytes(body).await.unwrap_or_default();
8647 let encoded = common::to_string(&bytes);
8648 match serde_json::from_str(&encoded) {
8649 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8650 Err(error) => {
8651 dlg.response_json_decode_error(&encoded, &error);
8652 return Err(common::Error::JsonDecodeError(
8653 encoded.to_string(),
8654 error,
8655 ));
8656 }
8657 }
8658 };
8659
8660 dlg.finished(true);
8661 return Ok(response);
8662 }
8663 }
8664 }
8665 }
8666
8667 ///
8668 /// Sets the *request* property to the given value.
8669 ///
8670 /// Even though the property as already been set when instantiating this call,
8671 /// we provide this method for API completeness.
8672 pub fn request(
8673 mut self,
8674 new_value: BucketAccessControl,
8675 ) -> BucketAccessControlPatchCall<'a, C> {
8676 self._request = new_value;
8677 self
8678 }
8679 /// Name of a bucket.
8680 ///
8681 /// Sets the *bucket* path property to the given value.
8682 ///
8683 /// Even though the property as already been set when instantiating this call,
8684 /// we provide this method for API completeness.
8685 pub fn bucket(mut self, new_value: &str) -> BucketAccessControlPatchCall<'a, C> {
8686 self._bucket = new_value.to_string();
8687 self
8688 }
8689 /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
8690 ///
8691 /// Sets the *entity* path property to the given value.
8692 ///
8693 /// Even though the property as already been set when instantiating this call,
8694 /// we provide this method for API completeness.
8695 pub fn entity(mut self, new_value: &str) -> BucketAccessControlPatchCall<'a, C> {
8696 self._entity = new_value.to_string();
8697 self
8698 }
8699 /// The project to be billed for this request. Required for Requester Pays buckets.
8700 ///
8701 /// Sets the *user project* query property to the given value.
8702 pub fn user_project(mut self, new_value: &str) -> BucketAccessControlPatchCall<'a, C> {
8703 self._user_project = Some(new_value.to_string());
8704 self
8705 }
8706 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8707 /// while executing the actual API request.
8708 ///
8709 /// ````text
8710 /// It should be used to handle progress information, and to implement a certain level of resilience.
8711 /// ````
8712 ///
8713 /// Sets the *delegate* property to the given value.
8714 pub fn delegate(
8715 mut self,
8716 new_value: &'a mut dyn common::Delegate,
8717 ) -> BucketAccessControlPatchCall<'a, C> {
8718 self._delegate = Some(new_value);
8719 self
8720 }
8721
8722 /// Set any additional parameter of the query string used in the request.
8723 /// It should be used to set parameters which are not yet available through their own
8724 /// setters.
8725 ///
8726 /// Please note that this method must not be used to set any of the known parameters
8727 /// which have their own setter method. If done anyway, the request will fail.
8728 ///
8729 /// # Additional Parameters
8730 ///
8731 /// * *alt* (query-string) - Data format for the response.
8732 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8733 /// * *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.
8734 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8735 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8736 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8737 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
8738 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8739 pub fn param<T>(mut self, name: T, value: T) -> BucketAccessControlPatchCall<'a, C>
8740 where
8741 T: AsRef<str>,
8742 {
8743 self._additional_params
8744 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8745 self
8746 }
8747
8748 /// Identifies the authorization scope for the method you are building.
8749 ///
8750 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8751 /// [`Scope::DevstorageFullControl`].
8752 ///
8753 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8754 /// tokens for more than one scope.
8755 ///
8756 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8757 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8758 /// sufficient, a read-write scope will do as well.
8759 pub fn add_scope<St>(mut self, scope: St) -> BucketAccessControlPatchCall<'a, C>
8760 where
8761 St: AsRef<str>,
8762 {
8763 self._scopes.insert(String::from(scope.as_ref()));
8764 self
8765 }
8766 /// Identifies the authorization scope(s) for the method you are building.
8767 ///
8768 /// See [`Self::add_scope()`] for details.
8769 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketAccessControlPatchCall<'a, C>
8770 where
8771 I: IntoIterator<Item = St>,
8772 St: AsRef<str>,
8773 {
8774 self._scopes
8775 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8776 self
8777 }
8778
8779 /// Removes all scopes, and no default scope will be used either.
8780 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8781 /// for details).
8782 pub fn clear_scopes(mut self) -> BucketAccessControlPatchCall<'a, C> {
8783 self._scopes.clear();
8784 self
8785 }
8786}
8787
8788/// Updates an ACL entry on the specified bucket.
8789///
8790/// A builder for the *update* method supported by a *bucketAccessControl* resource.
8791/// It is not used directly, but through a [`BucketAccessControlMethods`] instance.
8792///
8793/// # Example
8794///
8795/// Instantiate a resource method builder
8796///
8797/// ```test_harness,no_run
8798/// # extern crate hyper;
8799/// # extern crate hyper_rustls;
8800/// # extern crate google_storage1 as storage1;
8801/// use storage1::api::BucketAccessControl;
8802/// # async fn dox() {
8803/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8804///
8805/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8806/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8807/// # .with_native_roots()
8808/// # .unwrap()
8809/// # .https_only()
8810/// # .enable_http2()
8811/// # .build();
8812///
8813/// # let executor = hyper_util::rt::TokioExecutor::new();
8814/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8815/// # secret,
8816/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8817/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8818/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8819/// # ),
8820/// # ).build().await.unwrap();
8821///
8822/// # let client = hyper_util::client::legacy::Client::builder(
8823/// # hyper_util::rt::TokioExecutor::new()
8824/// # )
8825/// # .build(
8826/// # hyper_rustls::HttpsConnectorBuilder::new()
8827/// # .with_native_roots()
8828/// # .unwrap()
8829/// # .https_or_http()
8830/// # .enable_http2()
8831/// # .build()
8832/// # );
8833/// # let mut hub = Storage::new(client, auth);
8834/// // As the method needs a request, you would usually fill it with the desired information
8835/// // into the respective structure. Some of the parts shown here might not be applicable !
8836/// // Values shown here are possibly random and not representative !
8837/// let mut req = BucketAccessControl::default();
8838///
8839/// // You can configure optional parameters by calling the respective setters at will, and
8840/// // execute the final call using `doit()`.
8841/// // Values shown here are possibly random and not representative !
8842/// let result = hub.bucket_access_controls().update(req, "bucket", "entity")
8843/// .user_project("dolor")
8844/// .doit().await;
8845/// # }
8846/// ```
8847pub struct BucketAccessControlUpdateCall<'a, C>
8848where
8849 C: 'a,
8850{
8851 hub: &'a Storage<C>,
8852 _request: BucketAccessControl,
8853 _bucket: String,
8854 _entity: String,
8855 _user_project: Option<String>,
8856 _delegate: Option<&'a mut dyn common::Delegate>,
8857 _additional_params: HashMap<String, String>,
8858 _scopes: BTreeSet<String>,
8859}
8860
8861impl<'a, C> common::CallBuilder for BucketAccessControlUpdateCall<'a, C> {}
8862
8863impl<'a, C> BucketAccessControlUpdateCall<'a, C>
8864where
8865 C: common::Connector,
8866{
8867 /// Perform the operation you have build so far.
8868 pub async fn doit(mut self) -> common::Result<(common::Response, BucketAccessControl)> {
8869 use std::borrow::Cow;
8870 use std::io::{Read, Seek};
8871
8872 use common::{url::Params, ToParts};
8873 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8874
8875 let mut dd = common::DefaultDelegate;
8876 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8877 dlg.begin(common::MethodInfo {
8878 id: "storage.bucketAccessControls.update",
8879 http_method: hyper::Method::PUT,
8880 });
8881
8882 for &field in ["alt", "bucket", "entity", "userProject"].iter() {
8883 if self._additional_params.contains_key(field) {
8884 dlg.finished(false);
8885 return Err(common::Error::FieldClash(field));
8886 }
8887 }
8888
8889 let mut params = Params::with_capacity(6 + self._additional_params.len());
8890 params.push("bucket", self._bucket);
8891 params.push("entity", self._entity);
8892 if let Some(value) = self._user_project.as_ref() {
8893 params.push("userProject", value);
8894 }
8895
8896 params.extend(self._additional_params.iter());
8897
8898 params.push("alt", "json");
8899 let mut url = self.hub._base_url.clone() + "b/{bucket}/acl/{entity}";
8900 if self._scopes.is_empty() {
8901 self._scopes
8902 .insert(Scope::DevstorageFullControl.as_ref().to_string());
8903 }
8904
8905 #[allow(clippy::single_element_loop)]
8906 for &(find_this, param_name) in [("{bucket}", "bucket"), ("{entity}", "entity")].iter() {
8907 url = params.uri_replacement(url, param_name, find_this, false);
8908 }
8909 {
8910 let to_remove = ["entity", "bucket"];
8911 params.remove_params(&to_remove);
8912 }
8913
8914 let url = params.parse_with_url(&url);
8915
8916 let mut json_mime_type = mime::APPLICATION_JSON;
8917 let mut request_value_reader = {
8918 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8919 common::remove_json_null_values(&mut value);
8920 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8921 serde_json::to_writer(&mut dst, &value).unwrap();
8922 dst
8923 };
8924 let request_size = request_value_reader
8925 .seek(std::io::SeekFrom::End(0))
8926 .unwrap();
8927 request_value_reader
8928 .seek(std::io::SeekFrom::Start(0))
8929 .unwrap();
8930
8931 loop {
8932 let token = match self
8933 .hub
8934 .auth
8935 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8936 .await
8937 {
8938 Ok(token) => token,
8939 Err(e) => match dlg.token(e) {
8940 Ok(token) => token,
8941 Err(e) => {
8942 dlg.finished(false);
8943 return Err(common::Error::MissingToken(e));
8944 }
8945 },
8946 };
8947 request_value_reader
8948 .seek(std::io::SeekFrom::Start(0))
8949 .unwrap();
8950 let mut req_result = {
8951 let client = &self.hub.client;
8952 dlg.pre_request();
8953 let mut req_builder = hyper::Request::builder()
8954 .method(hyper::Method::PUT)
8955 .uri(url.as_str())
8956 .header(USER_AGENT, self.hub._user_agent.clone());
8957
8958 if let Some(token) = token.as_ref() {
8959 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8960 }
8961
8962 let request = req_builder
8963 .header(CONTENT_TYPE, json_mime_type.to_string())
8964 .header(CONTENT_LENGTH, request_size as u64)
8965 .body(common::to_body(
8966 request_value_reader.get_ref().clone().into(),
8967 ));
8968
8969 client.request(request.unwrap()).await
8970 };
8971
8972 match req_result {
8973 Err(err) => {
8974 if let common::Retry::After(d) = dlg.http_error(&err) {
8975 sleep(d).await;
8976 continue;
8977 }
8978 dlg.finished(false);
8979 return Err(common::Error::HttpError(err));
8980 }
8981 Ok(res) => {
8982 let (mut parts, body) = res.into_parts();
8983 let mut body = common::Body::new(body);
8984 if !parts.status.is_success() {
8985 let bytes = common::to_bytes(body).await.unwrap_or_default();
8986 let error = serde_json::from_str(&common::to_string(&bytes));
8987 let response = common::to_response(parts, bytes.into());
8988
8989 if let common::Retry::After(d) =
8990 dlg.http_failure(&response, error.as_ref().ok())
8991 {
8992 sleep(d).await;
8993 continue;
8994 }
8995
8996 dlg.finished(false);
8997
8998 return Err(match error {
8999 Ok(value) => common::Error::BadRequest(value),
9000 _ => common::Error::Failure(response),
9001 });
9002 }
9003 let response = {
9004 let bytes = common::to_bytes(body).await.unwrap_or_default();
9005 let encoded = common::to_string(&bytes);
9006 match serde_json::from_str(&encoded) {
9007 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9008 Err(error) => {
9009 dlg.response_json_decode_error(&encoded, &error);
9010 return Err(common::Error::JsonDecodeError(
9011 encoded.to_string(),
9012 error,
9013 ));
9014 }
9015 }
9016 };
9017
9018 dlg.finished(true);
9019 return Ok(response);
9020 }
9021 }
9022 }
9023 }
9024
9025 ///
9026 /// Sets the *request* property to the given value.
9027 ///
9028 /// Even though the property as already been set when instantiating this call,
9029 /// we provide this method for API completeness.
9030 pub fn request(
9031 mut self,
9032 new_value: BucketAccessControl,
9033 ) -> BucketAccessControlUpdateCall<'a, C> {
9034 self._request = new_value;
9035 self
9036 }
9037 /// Name of a bucket.
9038 ///
9039 /// Sets the *bucket* path property to the given value.
9040 ///
9041 /// Even though the property as already been set when instantiating this call,
9042 /// we provide this method for API completeness.
9043 pub fn bucket(mut self, new_value: &str) -> BucketAccessControlUpdateCall<'a, C> {
9044 self._bucket = new_value.to_string();
9045 self
9046 }
9047 /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
9048 ///
9049 /// Sets the *entity* path property to the given value.
9050 ///
9051 /// Even though the property as already been set when instantiating this call,
9052 /// we provide this method for API completeness.
9053 pub fn entity(mut self, new_value: &str) -> BucketAccessControlUpdateCall<'a, C> {
9054 self._entity = new_value.to_string();
9055 self
9056 }
9057 /// The project to be billed for this request. Required for Requester Pays buckets.
9058 ///
9059 /// Sets the *user project* query property to the given value.
9060 pub fn user_project(mut self, new_value: &str) -> BucketAccessControlUpdateCall<'a, C> {
9061 self._user_project = Some(new_value.to_string());
9062 self
9063 }
9064 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9065 /// while executing the actual API request.
9066 ///
9067 /// ````text
9068 /// It should be used to handle progress information, and to implement a certain level of resilience.
9069 /// ````
9070 ///
9071 /// Sets the *delegate* property to the given value.
9072 pub fn delegate(
9073 mut self,
9074 new_value: &'a mut dyn common::Delegate,
9075 ) -> BucketAccessControlUpdateCall<'a, C> {
9076 self._delegate = Some(new_value);
9077 self
9078 }
9079
9080 /// Set any additional parameter of the query string used in the request.
9081 /// It should be used to set parameters which are not yet available through their own
9082 /// setters.
9083 ///
9084 /// Please note that this method must not be used to set any of the known parameters
9085 /// which have their own setter method. If done anyway, the request will fail.
9086 ///
9087 /// # Additional Parameters
9088 ///
9089 /// * *alt* (query-string) - Data format for the response.
9090 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9091 /// * *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.
9092 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9093 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9094 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9095 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
9096 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9097 pub fn param<T>(mut self, name: T, value: T) -> BucketAccessControlUpdateCall<'a, C>
9098 where
9099 T: AsRef<str>,
9100 {
9101 self._additional_params
9102 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9103 self
9104 }
9105
9106 /// Identifies the authorization scope for the method you are building.
9107 ///
9108 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9109 /// [`Scope::DevstorageFullControl`].
9110 ///
9111 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9112 /// tokens for more than one scope.
9113 ///
9114 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9115 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9116 /// sufficient, a read-write scope will do as well.
9117 pub fn add_scope<St>(mut self, scope: St) -> BucketAccessControlUpdateCall<'a, C>
9118 where
9119 St: AsRef<str>,
9120 {
9121 self._scopes.insert(String::from(scope.as_ref()));
9122 self
9123 }
9124 /// Identifies the authorization scope(s) for the method you are building.
9125 ///
9126 /// See [`Self::add_scope()`] for details.
9127 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketAccessControlUpdateCall<'a, C>
9128 where
9129 I: IntoIterator<Item = St>,
9130 St: AsRef<str>,
9131 {
9132 self._scopes
9133 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9134 self
9135 }
9136
9137 /// Removes all scopes, and no default scope will be used either.
9138 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9139 /// for details).
9140 pub fn clear_scopes(mut self) -> BucketAccessControlUpdateCall<'a, C> {
9141 self._scopes.clear();
9142 self
9143 }
9144}
9145
9146/// Deletes an empty bucket. Deletions are permanent unless soft delete is enabled on the bucket.
9147///
9148/// A builder for the *delete* method supported by a *bucket* resource.
9149/// It is not used directly, but through a [`BucketMethods`] instance.
9150///
9151/// # Example
9152///
9153/// Instantiate a resource method builder
9154///
9155/// ```test_harness,no_run
9156/// # extern crate hyper;
9157/// # extern crate hyper_rustls;
9158/// # extern crate google_storage1 as storage1;
9159/// # async fn dox() {
9160/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9161///
9162/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9163/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9164/// # .with_native_roots()
9165/// # .unwrap()
9166/// # .https_only()
9167/// # .enable_http2()
9168/// # .build();
9169///
9170/// # let executor = hyper_util::rt::TokioExecutor::new();
9171/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9172/// # secret,
9173/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9174/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9175/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9176/// # ),
9177/// # ).build().await.unwrap();
9178///
9179/// # let client = hyper_util::client::legacy::Client::builder(
9180/// # hyper_util::rt::TokioExecutor::new()
9181/// # )
9182/// # .build(
9183/// # hyper_rustls::HttpsConnectorBuilder::new()
9184/// # .with_native_roots()
9185/// # .unwrap()
9186/// # .https_or_http()
9187/// # .enable_http2()
9188/// # .build()
9189/// # );
9190/// # let mut hub = Storage::new(client, auth);
9191/// // You can configure optional parameters by calling the respective setters at will, and
9192/// // execute the final call using `doit()`.
9193/// // Values shown here are possibly random and not representative !
9194/// let result = hub.buckets().delete("bucket")
9195/// .user_project("et")
9196/// .if_metageneration_not_match(-95)
9197/// .if_metageneration_match(-15)
9198/// .doit().await;
9199/// # }
9200/// ```
9201pub struct BucketDeleteCall<'a, C>
9202where
9203 C: 'a,
9204{
9205 hub: &'a Storage<C>,
9206 _bucket: String,
9207 _user_project: Option<String>,
9208 _if_metageneration_not_match: Option<i64>,
9209 _if_metageneration_match: Option<i64>,
9210 _delegate: Option<&'a mut dyn common::Delegate>,
9211 _additional_params: HashMap<String, String>,
9212 _scopes: BTreeSet<String>,
9213}
9214
9215impl<'a, C> common::CallBuilder for BucketDeleteCall<'a, C> {}
9216
9217impl<'a, C> BucketDeleteCall<'a, C>
9218where
9219 C: common::Connector,
9220{
9221 /// Perform the operation you have build so far.
9222 pub async fn doit(mut self) -> common::Result<common::Response> {
9223 use std::borrow::Cow;
9224 use std::io::{Read, Seek};
9225
9226 use common::{url::Params, ToParts};
9227 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9228
9229 let mut dd = common::DefaultDelegate;
9230 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9231 dlg.begin(common::MethodInfo {
9232 id: "storage.buckets.delete",
9233 http_method: hyper::Method::DELETE,
9234 });
9235
9236 for &field in [
9237 "bucket",
9238 "userProject",
9239 "ifMetagenerationNotMatch",
9240 "ifMetagenerationMatch",
9241 ]
9242 .iter()
9243 {
9244 if self._additional_params.contains_key(field) {
9245 dlg.finished(false);
9246 return Err(common::Error::FieldClash(field));
9247 }
9248 }
9249
9250 let mut params = Params::with_capacity(5 + self._additional_params.len());
9251 params.push("bucket", self._bucket);
9252 if let Some(value) = self._user_project.as_ref() {
9253 params.push("userProject", value);
9254 }
9255 if let Some(value) = self._if_metageneration_not_match.as_ref() {
9256 params.push("ifMetagenerationNotMatch", value.to_string());
9257 }
9258 if let Some(value) = self._if_metageneration_match.as_ref() {
9259 params.push("ifMetagenerationMatch", value.to_string());
9260 }
9261
9262 params.extend(self._additional_params.iter());
9263
9264 let mut url = self.hub._base_url.clone() + "b/{bucket}";
9265 if self._scopes.is_empty() {
9266 self._scopes
9267 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
9268 }
9269
9270 #[allow(clippy::single_element_loop)]
9271 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
9272 url = params.uri_replacement(url, param_name, find_this, false);
9273 }
9274 {
9275 let to_remove = ["bucket"];
9276 params.remove_params(&to_remove);
9277 }
9278
9279 let url = params.parse_with_url(&url);
9280
9281 loop {
9282 let token = match self
9283 .hub
9284 .auth
9285 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9286 .await
9287 {
9288 Ok(token) => token,
9289 Err(e) => match dlg.token(e) {
9290 Ok(token) => token,
9291 Err(e) => {
9292 dlg.finished(false);
9293 return Err(common::Error::MissingToken(e));
9294 }
9295 },
9296 };
9297 let mut req_result = {
9298 let client = &self.hub.client;
9299 dlg.pre_request();
9300 let mut req_builder = hyper::Request::builder()
9301 .method(hyper::Method::DELETE)
9302 .uri(url.as_str())
9303 .header(USER_AGENT, self.hub._user_agent.clone());
9304
9305 if let Some(token) = token.as_ref() {
9306 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9307 }
9308
9309 let request = req_builder
9310 .header(CONTENT_LENGTH, 0_u64)
9311 .body(common::to_body::<String>(None));
9312
9313 client.request(request.unwrap()).await
9314 };
9315
9316 match req_result {
9317 Err(err) => {
9318 if let common::Retry::After(d) = dlg.http_error(&err) {
9319 sleep(d).await;
9320 continue;
9321 }
9322 dlg.finished(false);
9323 return Err(common::Error::HttpError(err));
9324 }
9325 Ok(res) => {
9326 let (mut parts, body) = res.into_parts();
9327 let mut body = common::Body::new(body);
9328 if !parts.status.is_success() {
9329 let bytes = common::to_bytes(body).await.unwrap_or_default();
9330 let error = serde_json::from_str(&common::to_string(&bytes));
9331 let response = common::to_response(parts, bytes.into());
9332
9333 if let common::Retry::After(d) =
9334 dlg.http_failure(&response, error.as_ref().ok())
9335 {
9336 sleep(d).await;
9337 continue;
9338 }
9339
9340 dlg.finished(false);
9341
9342 return Err(match error {
9343 Ok(value) => common::Error::BadRequest(value),
9344 _ => common::Error::Failure(response),
9345 });
9346 }
9347 let response = common::Response::from_parts(parts, body);
9348
9349 dlg.finished(true);
9350 return Ok(response);
9351 }
9352 }
9353 }
9354 }
9355
9356 /// Name of a bucket.
9357 ///
9358 /// Sets the *bucket* path property to the given value.
9359 ///
9360 /// Even though the property as already been set when instantiating this call,
9361 /// we provide this method for API completeness.
9362 pub fn bucket(mut self, new_value: &str) -> BucketDeleteCall<'a, C> {
9363 self._bucket = new_value.to_string();
9364 self
9365 }
9366 /// The project to be billed for this request. Required for Requester Pays buckets.
9367 ///
9368 /// Sets the *user project* query property to the given value.
9369 pub fn user_project(mut self, new_value: &str) -> BucketDeleteCall<'a, C> {
9370 self._user_project = Some(new_value.to_string());
9371 self
9372 }
9373 /// If set, only deletes the bucket if its metageneration does not match this value.
9374 ///
9375 /// Sets the *if metageneration not match* query property to the given value.
9376 pub fn if_metageneration_not_match(mut self, new_value: i64) -> BucketDeleteCall<'a, C> {
9377 self._if_metageneration_not_match = Some(new_value);
9378 self
9379 }
9380 /// If set, only deletes the bucket if its metageneration matches this value.
9381 ///
9382 /// Sets the *if metageneration match* query property to the given value.
9383 pub fn if_metageneration_match(mut self, new_value: i64) -> BucketDeleteCall<'a, C> {
9384 self._if_metageneration_match = Some(new_value);
9385 self
9386 }
9387 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9388 /// while executing the actual API request.
9389 ///
9390 /// ````text
9391 /// It should be used to handle progress information, and to implement a certain level of resilience.
9392 /// ````
9393 ///
9394 /// Sets the *delegate* property to the given value.
9395 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> BucketDeleteCall<'a, C> {
9396 self._delegate = Some(new_value);
9397 self
9398 }
9399
9400 /// Set any additional parameter of the query string used in the request.
9401 /// It should be used to set parameters which are not yet available through their own
9402 /// setters.
9403 ///
9404 /// Please note that this method must not be used to set any of the known parameters
9405 /// which have their own setter method. If done anyway, the request will fail.
9406 ///
9407 /// # Additional Parameters
9408 ///
9409 /// * *alt* (query-string) - Data format for the response.
9410 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9411 /// * *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.
9412 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9413 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9414 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9415 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
9416 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9417 pub fn param<T>(mut self, name: T, value: T) -> BucketDeleteCall<'a, C>
9418 where
9419 T: AsRef<str>,
9420 {
9421 self._additional_params
9422 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9423 self
9424 }
9425
9426 /// Identifies the authorization scope for the method you are building.
9427 ///
9428 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9429 /// [`Scope::DevstorageReadWrite`].
9430 ///
9431 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9432 /// tokens for more than one scope.
9433 ///
9434 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9435 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9436 /// sufficient, a read-write scope will do as well.
9437 pub fn add_scope<St>(mut self, scope: St) -> BucketDeleteCall<'a, C>
9438 where
9439 St: AsRef<str>,
9440 {
9441 self._scopes.insert(String::from(scope.as_ref()));
9442 self
9443 }
9444 /// Identifies the authorization scope(s) for the method you are building.
9445 ///
9446 /// See [`Self::add_scope()`] for details.
9447 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketDeleteCall<'a, C>
9448 where
9449 I: IntoIterator<Item = St>,
9450 St: AsRef<str>,
9451 {
9452 self._scopes
9453 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9454 self
9455 }
9456
9457 /// Removes all scopes, and no default scope will be used either.
9458 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9459 /// for details).
9460 pub fn clear_scopes(mut self) -> BucketDeleteCall<'a, C> {
9461 self._scopes.clear();
9462 self
9463 }
9464}
9465
9466/// Returns metadata for the specified bucket.
9467///
9468/// A builder for the *get* method supported by a *bucket* resource.
9469/// It is not used directly, but through a [`BucketMethods`] instance.
9470///
9471/// # Example
9472///
9473/// Instantiate a resource method builder
9474///
9475/// ```test_harness,no_run
9476/// # extern crate hyper;
9477/// # extern crate hyper_rustls;
9478/// # extern crate google_storage1 as storage1;
9479/// # async fn dox() {
9480/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9481///
9482/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9483/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9484/// # .with_native_roots()
9485/// # .unwrap()
9486/// # .https_only()
9487/// # .enable_http2()
9488/// # .build();
9489///
9490/// # let executor = hyper_util::rt::TokioExecutor::new();
9491/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9492/// # secret,
9493/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9494/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9495/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9496/// # ),
9497/// # ).build().await.unwrap();
9498///
9499/// # let client = hyper_util::client::legacy::Client::builder(
9500/// # hyper_util::rt::TokioExecutor::new()
9501/// # )
9502/// # .build(
9503/// # hyper_rustls::HttpsConnectorBuilder::new()
9504/// # .with_native_roots()
9505/// # .unwrap()
9506/// # .https_or_http()
9507/// # .enable_http2()
9508/// # .build()
9509/// # );
9510/// # let mut hub = Storage::new(client, auth);
9511/// // You can configure optional parameters by calling the respective setters at will, and
9512/// // execute the final call using `doit()`.
9513/// // Values shown here are possibly random and not representative !
9514/// let result = hub.buckets().get("bucket")
9515/// .user_project("duo")
9516/// .soft_deleted(false)
9517/// .projection("vero")
9518/// .if_metageneration_not_match(-88)
9519/// .if_metageneration_match(-65)
9520/// .generation(-76)
9521/// .doit().await;
9522/// # }
9523/// ```
9524pub struct BucketGetCall<'a, C>
9525where
9526 C: 'a,
9527{
9528 hub: &'a Storage<C>,
9529 _bucket: String,
9530 _user_project: Option<String>,
9531 _soft_deleted: Option<bool>,
9532 _projection: Option<String>,
9533 _if_metageneration_not_match: Option<i64>,
9534 _if_metageneration_match: Option<i64>,
9535 _generation: Option<i64>,
9536 _delegate: Option<&'a mut dyn common::Delegate>,
9537 _additional_params: HashMap<String, String>,
9538 _scopes: BTreeSet<String>,
9539}
9540
9541impl<'a, C> common::CallBuilder for BucketGetCall<'a, C> {}
9542
9543impl<'a, C> BucketGetCall<'a, C>
9544where
9545 C: common::Connector,
9546{
9547 /// Perform the operation you have build so far.
9548 pub async fn doit(mut self) -> common::Result<(common::Response, Bucket)> {
9549 use std::borrow::Cow;
9550 use std::io::{Read, Seek};
9551
9552 use common::{url::Params, ToParts};
9553 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9554
9555 let mut dd = common::DefaultDelegate;
9556 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9557 dlg.begin(common::MethodInfo {
9558 id: "storage.buckets.get",
9559 http_method: hyper::Method::GET,
9560 });
9561
9562 for &field in [
9563 "alt",
9564 "bucket",
9565 "userProject",
9566 "softDeleted",
9567 "projection",
9568 "ifMetagenerationNotMatch",
9569 "ifMetagenerationMatch",
9570 "generation",
9571 ]
9572 .iter()
9573 {
9574 if self._additional_params.contains_key(field) {
9575 dlg.finished(false);
9576 return Err(common::Error::FieldClash(field));
9577 }
9578 }
9579
9580 let mut params = Params::with_capacity(9 + self._additional_params.len());
9581 params.push("bucket", self._bucket);
9582 if let Some(value) = self._user_project.as_ref() {
9583 params.push("userProject", value);
9584 }
9585 if let Some(value) = self._soft_deleted.as_ref() {
9586 params.push("softDeleted", value.to_string());
9587 }
9588 if let Some(value) = self._projection.as_ref() {
9589 params.push("projection", value);
9590 }
9591 if let Some(value) = self._if_metageneration_not_match.as_ref() {
9592 params.push("ifMetagenerationNotMatch", value.to_string());
9593 }
9594 if let Some(value) = self._if_metageneration_match.as_ref() {
9595 params.push("ifMetagenerationMatch", value.to_string());
9596 }
9597 if let Some(value) = self._generation.as_ref() {
9598 params.push("generation", value.to_string());
9599 }
9600
9601 params.extend(self._additional_params.iter());
9602
9603 params.push("alt", "json");
9604 let mut url = self.hub._base_url.clone() + "b/{bucket}";
9605 if self._scopes.is_empty() {
9606 self._scopes
9607 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
9608 }
9609
9610 #[allow(clippy::single_element_loop)]
9611 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
9612 url = params.uri_replacement(url, param_name, find_this, false);
9613 }
9614 {
9615 let to_remove = ["bucket"];
9616 params.remove_params(&to_remove);
9617 }
9618
9619 let url = params.parse_with_url(&url);
9620
9621 loop {
9622 let token = match self
9623 .hub
9624 .auth
9625 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9626 .await
9627 {
9628 Ok(token) => token,
9629 Err(e) => match dlg.token(e) {
9630 Ok(token) => token,
9631 Err(e) => {
9632 dlg.finished(false);
9633 return Err(common::Error::MissingToken(e));
9634 }
9635 },
9636 };
9637 let mut req_result = {
9638 let client = &self.hub.client;
9639 dlg.pre_request();
9640 let mut req_builder = hyper::Request::builder()
9641 .method(hyper::Method::GET)
9642 .uri(url.as_str())
9643 .header(USER_AGENT, self.hub._user_agent.clone());
9644
9645 if let Some(token) = token.as_ref() {
9646 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9647 }
9648
9649 let request = req_builder
9650 .header(CONTENT_LENGTH, 0_u64)
9651 .body(common::to_body::<String>(None));
9652
9653 client.request(request.unwrap()).await
9654 };
9655
9656 match req_result {
9657 Err(err) => {
9658 if let common::Retry::After(d) = dlg.http_error(&err) {
9659 sleep(d).await;
9660 continue;
9661 }
9662 dlg.finished(false);
9663 return Err(common::Error::HttpError(err));
9664 }
9665 Ok(res) => {
9666 let (mut parts, body) = res.into_parts();
9667 let mut body = common::Body::new(body);
9668 if !parts.status.is_success() {
9669 let bytes = common::to_bytes(body).await.unwrap_or_default();
9670 let error = serde_json::from_str(&common::to_string(&bytes));
9671 let response = common::to_response(parts, bytes.into());
9672
9673 if let common::Retry::After(d) =
9674 dlg.http_failure(&response, error.as_ref().ok())
9675 {
9676 sleep(d).await;
9677 continue;
9678 }
9679
9680 dlg.finished(false);
9681
9682 return Err(match error {
9683 Ok(value) => common::Error::BadRequest(value),
9684 _ => common::Error::Failure(response),
9685 });
9686 }
9687 let response = {
9688 let bytes = common::to_bytes(body).await.unwrap_or_default();
9689 let encoded = common::to_string(&bytes);
9690 match serde_json::from_str(&encoded) {
9691 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9692 Err(error) => {
9693 dlg.response_json_decode_error(&encoded, &error);
9694 return Err(common::Error::JsonDecodeError(
9695 encoded.to_string(),
9696 error,
9697 ));
9698 }
9699 }
9700 };
9701
9702 dlg.finished(true);
9703 return Ok(response);
9704 }
9705 }
9706 }
9707 }
9708
9709 /// Name of a bucket.
9710 ///
9711 /// Sets the *bucket* path property to the given value.
9712 ///
9713 /// Even though the property as already been set when instantiating this call,
9714 /// we provide this method for API completeness.
9715 pub fn bucket(mut self, new_value: &str) -> BucketGetCall<'a, C> {
9716 self._bucket = new_value.to_string();
9717 self
9718 }
9719 /// The project to be billed for this request. Required for Requester Pays buckets.
9720 ///
9721 /// Sets the *user project* query property to the given value.
9722 pub fn user_project(mut self, new_value: &str) -> BucketGetCall<'a, C> {
9723 self._user_project = Some(new_value.to_string());
9724 self
9725 }
9726 /// If true, return the soft-deleted version of this bucket. The default is false. For more information, see [Soft Delete](https://cloud.google.com/storage/docs/soft-delete).
9727 ///
9728 /// Sets the *soft deleted* query property to the given value.
9729 pub fn soft_deleted(mut self, new_value: bool) -> BucketGetCall<'a, C> {
9730 self._soft_deleted = Some(new_value);
9731 self
9732 }
9733 /// Set of properties to return. Defaults to noAcl.
9734 ///
9735 /// Sets the *projection* query property to the given value.
9736 pub fn projection(mut self, new_value: &str) -> BucketGetCall<'a, C> {
9737 self._projection = Some(new_value.to_string());
9738 self
9739 }
9740 /// Makes the return of the bucket metadata conditional on whether the bucket's current metageneration does not match the given value.
9741 ///
9742 /// Sets the *if metageneration not match* query property to the given value.
9743 pub fn if_metageneration_not_match(mut self, new_value: i64) -> BucketGetCall<'a, C> {
9744 self._if_metageneration_not_match = Some(new_value);
9745 self
9746 }
9747 /// Makes the return of the bucket metadata conditional on whether the bucket's current metageneration matches the given value.
9748 ///
9749 /// Sets the *if metageneration match* query property to the given value.
9750 pub fn if_metageneration_match(mut self, new_value: i64) -> BucketGetCall<'a, C> {
9751 self._if_metageneration_match = Some(new_value);
9752 self
9753 }
9754 /// If present, specifies the generation of the bucket. This is required if softDeleted is true.
9755 ///
9756 /// Sets the *generation* query property to the given value.
9757 pub fn generation(mut self, new_value: i64) -> BucketGetCall<'a, C> {
9758 self._generation = Some(new_value);
9759 self
9760 }
9761 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9762 /// while executing the actual API request.
9763 ///
9764 /// ````text
9765 /// It should be used to handle progress information, and to implement a certain level of resilience.
9766 /// ````
9767 ///
9768 /// Sets the *delegate* property to the given value.
9769 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> BucketGetCall<'a, C> {
9770 self._delegate = Some(new_value);
9771 self
9772 }
9773
9774 /// Set any additional parameter of the query string used in the request.
9775 /// It should be used to set parameters which are not yet available through their own
9776 /// setters.
9777 ///
9778 /// Please note that this method must not be used to set any of the known parameters
9779 /// which have their own setter method. If done anyway, the request will fail.
9780 ///
9781 /// # Additional Parameters
9782 ///
9783 /// * *alt* (query-string) - Data format for the response.
9784 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9785 /// * *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.
9786 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9787 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9788 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9789 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
9790 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9791 pub fn param<T>(mut self, name: T, value: T) -> BucketGetCall<'a, C>
9792 where
9793 T: AsRef<str>,
9794 {
9795 self._additional_params
9796 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9797 self
9798 }
9799
9800 /// Identifies the authorization scope for the method you are building.
9801 ///
9802 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9803 /// [`Scope::DevstorageReadOnly`].
9804 ///
9805 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9806 /// tokens for more than one scope.
9807 ///
9808 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9809 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9810 /// sufficient, a read-write scope will do as well.
9811 pub fn add_scope<St>(mut self, scope: St) -> BucketGetCall<'a, C>
9812 where
9813 St: AsRef<str>,
9814 {
9815 self._scopes.insert(String::from(scope.as_ref()));
9816 self
9817 }
9818 /// Identifies the authorization scope(s) for the method you are building.
9819 ///
9820 /// See [`Self::add_scope()`] for details.
9821 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketGetCall<'a, C>
9822 where
9823 I: IntoIterator<Item = St>,
9824 St: AsRef<str>,
9825 {
9826 self._scopes
9827 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9828 self
9829 }
9830
9831 /// Removes all scopes, and no default scope will be used either.
9832 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9833 /// for details).
9834 pub fn clear_scopes(mut self) -> BucketGetCall<'a, C> {
9835 self._scopes.clear();
9836 self
9837 }
9838}
9839
9840/// Returns an IAM policy for the specified bucket.
9841///
9842/// A builder for the *getIamPolicy* method supported by a *bucket* resource.
9843/// It is not used directly, but through a [`BucketMethods`] instance.
9844///
9845/// # Example
9846///
9847/// Instantiate a resource method builder
9848///
9849/// ```test_harness,no_run
9850/// # extern crate hyper;
9851/// # extern crate hyper_rustls;
9852/// # extern crate google_storage1 as storage1;
9853/// # async fn dox() {
9854/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9855///
9856/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9857/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9858/// # .with_native_roots()
9859/// # .unwrap()
9860/// # .https_only()
9861/// # .enable_http2()
9862/// # .build();
9863///
9864/// # let executor = hyper_util::rt::TokioExecutor::new();
9865/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9866/// # secret,
9867/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9868/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9869/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9870/// # ),
9871/// # ).build().await.unwrap();
9872///
9873/// # let client = hyper_util::client::legacy::Client::builder(
9874/// # hyper_util::rt::TokioExecutor::new()
9875/// # )
9876/// # .build(
9877/// # hyper_rustls::HttpsConnectorBuilder::new()
9878/// # .with_native_roots()
9879/// # .unwrap()
9880/// # .https_or_http()
9881/// # .enable_http2()
9882/// # .build()
9883/// # );
9884/// # let mut hub = Storage::new(client, auth);
9885/// // You can configure optional parameters by calling the respective setters at will, and
9886/// // execute the final call using `doit()`.
9887/// // Values shown here are possibly random and not representative !
9888/// let result = hub.buckets().get_iam_policy("bucket")
9889/// .user_project("Lorem")
9890/// .options_requested_policy_version(-29)
9891/// .doit().await;
9892/// # }
9893/// ```
9894pub struct BucketGetIamPolicyCall<'a, C>
9895where
9896 C: 'a,
9897{
9898 hub: &'a Storage<C>,
9899 _bucket: String,
9900 _user_project: Option<String>,
9901 _options_requested_policy_version: Option<i32>,
9902 _delegate: Option<&'a mut dyn common::Delegate>,
9903 _additional_params: HashMap<String, String>,
9904 _scopes: BTreeSet<String>,
9905}
9906
9907impl<'a, C> common::CallBuilder for BucketGetIamPolicyCall<'a, C> {}
9908
9909impl<'a, C> BucketGetIamPolicyCall<'a, C>
9910where
9911 C: common::Connector,
9912{
9913 /// Perform the operation you have build so far.
9914 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
9915 use std::borrow::Cow;
9916 use std::io::{Read, Seek};
9917
9918 use common::{url::Params, ToParts};
9919 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9920
9921 let mut dd = common::DefaultDelegate;
9922 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9923 dlg.begin(common::MethodInfo {
9924 id: "storage.buckets.getIamPolicy",
9925 http_method: hyper::Method::GET,
9926 });
9927
9928 for &field in [
9929 "alt",
9930 "bucket",
9931 "userProject",
9932 "optionsRequestedPolicyVersion",
9933 ]
9934 .iter()
9935 {
9936 if self._additional_params.contains_key(field) {
9937 dlg.finished(false);
9938 return Err(common::Error::FieldClash(field));
9939 }
9940 }
9941
9942 let mut params = Params::with_capacity(5 + self._additional_params.len());
9943 params.push("bucket", self._bucket);
9944 if let Some(value) = self._user_project.as_ref() {
9945 params.push("userProject", value);
9946 }
9947 if let Some(value) = self._options_requested_policy_version.as_ref() {
9948 params.push("optionsRequestedPolicyVersion", value.to_string());
9949 }
9950
9951 params.extend(self._additional_params.iter());
9952
9953 params.push("alt", "json");
9954 let mut url = self.hub._base_url.clone() + "b/{bucket}/iam";
9955 if self._scopes.is_empty() {
9956 self._scopes
9957 .insert(Scope::DevstorageFullControl.as_ref().to_string());
9958 }
9959
9960 #[allow(clippy::single_element_loop)]
9961 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
9962 url = params.uri_replacement(url, param_name, find_this, false);
9963 }
9964 {
9965 let to_remove = ["bucket"];
9966 params.remove_params(&to_remove);
9967 }
9968
9969 let url = params.parse_with_url(&url);
9970
9971 loop {
9972 let token = match self
9973 .hub
9974 .auth
9975 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9976 .await
9977 {
9978 Ok(token) => token,
9979 Err(e) => match dlg.token(e) {
9980 Ok(token) => token,
9981 Err(e) => {
9982 dlg.finished(false);
9983 return Err(common::Error::MissingToken(e));
9984 }
9985 },
9986 };
9987 let mut req_result = {
9988 let client = &self.hub.client;
9989 dlg.pre_request();
9990 let mut req_builder = hyper::Request::builder()
9991 .method(hyper::Method::GET)
9992 .uri(url.as_str())
9993 .header(USER_AGENT, self.hub._user_agent.clone());
9994
9995 if let Some(token) = token.as_ref() {
9996 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9997 }
9998
9999 let request = req_builder
10000 .header(CONTENT_LENGTH, 0_u64)
10001 .body(common::to_body::<String>(None));
10002
10003 client.request(request.unwrap()).await
10004 };
10005
10006 match req_result {
10007 Err(err) => {
10008 if let common::Retry::After(d) = dlg.http_error(&err) {
10009 sleep(d).await;
10010 continue;
10011 }
10012 dlg.finished(false);
10013 return Err(common::Error::HttpError(err));
10014 }
10015 Ok(res) => {
10016 let (mut parts, body) = res.into_parts();
10017 let mut body = common::Body::new(body);
10018 if !parts.status.is_success() {
10019 let bytes = common::to_bytes(body).await.unwrap_or_default();
10020 let error = serde_json::from_str(&common::to_string(&bytes));
10021 let response = common::to_response(parts, bytes.into());
10022
10023 if let common::Retry::After(d) =
10024 dlg.http_failure(&response, error.as_ref().ok())
10025 {
10026 sleep(d).await;
10027 continue;
10028 }
10029
10030 dlg.finished(false);
10031
10032 return Err(match error {
10033 Ok(value) => common::Error::BadRequest(value),
10034 _ => common::Error::Failure(response),
10035 });
10036 }
10037 let response = {
10038 let bytes = common::to_bytes(body).await.unwrap_or_default();
10039 let encoded = common::to_string(&bytes);
10040 match serde_json::from_str(&encoded) {
10041 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10042 Err(error) => {
10043 dlg.response_json_decode_error(&encoded, &error);
10044 return Err(common::Error::JsonDecodeError(
10045 encoded.to_string(),
10046 error,
10047 ));
10048 }
10049 }
10050 };
10051
10052 dlg.finished(true);
10053 return Ok(response);
10054 }
10055 }
10056 }
10057 }
10058
10059 /// Name of a bucket.
10060 ///
10061 /// Sets the *bucket* path property to the given value.
10062 ///
10063 /// Even though the property as already been set when instantiating this call,
10064 /// we provide this method for API completeness.
10065 pub fn bucket(mut self, new_value: &str) -> BucketGetIamPolicyCall<'a, C> {
10066 self._bucket = new_value.to_string();
10067 self
10068 }
10069 /// The project to be billed for this request. Required for Requester Pays buckets.
10070 ///
10071 /// Sets the *user project* query property to the given value.
10072 pub fn user_project(mut self, new_value: &str) -> BucketGetIamPolicyCall<'a, C> {
10073 self._user_project = Some(new_value.to_string());
10074 self
10075 }
10076 /// 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.
10077 ///
10078 /// Sets the *options requested policy version* query property to the given value.
10079 pub fn options_requested_policy_version(
10080 mut self,
10081 new_value: i32,
10082 ) -> BucketGetIamPolicyCall<'a, C> {
10083 self._options_requested_policy_version = Some(new_value);
10084 self
10085 }
10086 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10087 /// while executing the actual API request.
10088 ///
10089 /// ````text
10090 /// It should be used to handle progress information, and to implement a certain level of resilience.
10091 /// ````
10092 ///
10093 /// Sets the *delegate* property to the given value.
10094 pub fn delegate(
10095 mut self,
10096 new_value: &'a mut dyn common::Delegate,
10097 ) -> BucketGetIamPolicyCall<'a, C> {
10098 self._delegate = Some(new_value);
10099 self
10100 }
10101
10102 /// Set any additional parameter of the query string used in the request.
10103 /// It should be used to set parameters which are not yet available through their own
10104 /// setters.
10105 ///
10106 /// Please note that this method must not be used to set any of the known parameters
10107 /// which have their own setter method. If done anyway, the request will fail.
10108 ///
10109 /// # Additional Parameters
10110 ///
10111 /// * *alt* (query-string) - Data format for the response.
10112 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10113 /// * *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.
10114 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10115 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10116 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10117 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
10118 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10119 pub fn param<T>(mut self, name: T, value: T) -> BucketGetIamPolicyCall<'a, C>
10120 where
10121 T: AsRef<str>,
10122 {
10123 self._additional_params
10124 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10125 self
10126 }
10127
10128 /// Identifies the authorization scope for the method you are building.
10129 ///
10130 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10131 /// [`Scope::DevstorageFullControl`].
10132 ///
10133 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10134 /// tokens for more than one scope.
10135 ///
10136 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10137 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10138 /// sufficient, a read-write scope will do as well.
10139 pub fn add_scope<St>(mut self, scope: St) -> BucketGetIamPolicyCall<'a, C>
10140 where
10141 St: AsRef<str>,
10142 {
10143 self._scopes.insert(String::from(scope.as_ref()));
10144 self
10145 }
10146 /// Identifies the authorization scope(s) for the method you are building.
10147 ///
10148 /// See [`Self::add_scope()`] for details.
10149 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketGetIamPolicyCall<'a, C>
10150 where
10151 I: IntoIterator<Item = St>,
10152 St: AsRef<str>,
10153 {
10154 self._scopes
10155 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10156 self
10157 }
10158
10159 /// Removes all scopes, and no default scope will be used either.
10160 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10161 /// for details).
10162 pub fn clear_scopes(mut self) -> BucketGetIamPolicyCall<'a, C> {
10163 self._scopes.clear();
10164 self
10165 }
10166}
10167
10168/// Returns the storage layout configuration for the specified bucket. Note that this operation requires storage.objects.list permission.
10169///
10170/// A builder for the *getStorageLayout* method supported by a *bucket* resource.
10171/// It is not used directly, but through a [`BucketMethods`] instance.
10172///
10173/// # Example
10174///
10175/// Instantiate a resource method builder
10176///
10177/// ```test_harness,no_run
10178/// # extern crate hyper;
10179/// # extern crate hyper_rustls;
10180/// # extern crate google_storage1 as storage1;
10181/// # async fn dox() {
10182/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10183///
10184/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10185/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10186/// # .with_native_roots()
10187/// # .unwrap()
10188/// # .https_only()
10189/// # .enable_http2()
10190/// # .build();
10191///
10192/// # let executor = hyper_util::rt::TokioExecutor::new();
10193/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10194/// # secret,
10195/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10196/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10197/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10198/// # ),
10199/// # ).build().await.unwrap();
10200///
10201/// # let client = hyper_util::client::legacy::Client::builder(
10202/// # hyper_util::rt::TokioExecutor::new()
10203/// # )
10204/// # .build(
10205/// # hyper_rustls::HttpsConnectorBuilder::new()
10206/// # .with_native_roots()
10207/// # .unwrap()
10208/// # .https_or_http()
10209/// # .enable_http2()
10210/// # .build()
10211/// # );
10212/// # let mut hub = Storage::new(client, auth);
10213/// // You can configure optional parameters by calling the respective setters at will, and
10214/// // execute the final call using `doit()`.
10215/// // Values shown here are possibly random and not representative !
10216/// let result = hub.buckets().get_storage_layout("bucket")
10217/// .prefix("ipsum")
10218/// .doit().await;
10219/// # }
10220/// ```
10221pub struct BucketGetStorageLayoutCall<'a, C>
10222where
10223 C: 'a,
10224{
10225 hub: &'a Storage<C>,
10226 _bucket: String,
10227 _prefix: Option<String>,
10228 _delegate: Option<&'a mut dyn common::Delegate>,
10229 _additional_params: HashMap<String, String>,
10230 _scopes: BTreeSet<String>,
10231}
10232
10233impl<'a, C> common::CallBuilder for BucketGetStorageLayoutCall<'a, C> {}
10234
10235impl<'a, C> BucketGetStorageLayoutCall<'a, C>
10236where
10237 C: common::Connector,
10238{
10239 /// Perform the operation you have build so far.
10240 pub async fn doit(mut self) -> common::Result<(common::Response, BucketStorageLayout)> {
10241 use std::borrow::Cow;
10242 use std::io::{Read, Seek};
10243
10244 use common::{url::Params, ToParts};
10245 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10246
10247 let mut dd = common::DefaultDelegate;
10248 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10249 dlg.begin(common::MethodInfo {
10250 id: "storage.buckets.getStorageLayout",
10251 http_method: hyper::Method::GET,
10252 });
10253
10254 for &field in ["alt", "bucket", "prefix"].iter() {
10255 if self._additional_params.contains_key(field) {
10256 dlg.finished(false);
10257 return Err(common::Error::FieldClash(field));
10258 }
10259 }
10260
10261 let mut params = Params::with_capacity(4 + self._additional_params.len());
10262 params.push("bucket", self._bucket);
10263 if let Some(value) = self._prefix.as_ref() {
10264 params.push("prefix", value);
10265 }
10266
10267 params.extend(self._additional_params.iter());
10268
10269 params.push("alt", "json");
10270 let mut url = self.hub._base_url.clone() + "b/{bucket}/storageLayout";
10271 if self._scopes.is_empty() {
10272 self._scopes
10273 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
10274 }
10275
10276 #[allow(clippy::single_element_loop)]
10277 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
10278 url = params.uri_replacement(url, param_name, find_this, false);
10279 }
10280 {
10281 let to_remove = ["bucket"];
10282 params.remove_params(&to_remove);
10283 }
10284
10285 let url = params.parse_with_url(&url);
10286
10287 loop {
10288 let token = match self
10289 .hub
10290 .auth
10291 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10292 .await
10293 {
10294 Ok(token) => token,
10295 Err(e) => match dlg.token(e) {
10296 Ok(token) => token,
10297 Err(e) => {
10298 dlg.finished(false);
10299 return Err(common::Error::MissingToken(e));
10300 }
10301 },
10302 };
10303 let mut req_result = {
10304 let client = &self.hub.client;
10305 dlg.pre_request();
10306 let mut req_builder = hyper::Request::builder()
10307 .method(hyper::Method::GET)
10308 .uri(url.as_str())
10309 .header(USER_AGENT, self.hub._user_agent.clone());
10310
10311 if let Some(token) = token.as_ref() {
10312 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10313 }
10314
10315 let request = req_builder
10316 .header(CONTENT_LENGTH, 0_u64)
10317 .body(common::to_body::<String>(None));
10318
10319 client.request(request.unwrap()).await
10320 };
10321
10322 match req_result {
10323 Err(err) => {
10324 if let common::Retry::After(d) = dlg.http_error(&err) {
10325 sleep(d).await;
10326 continue;
10327 }
10328 dlg.finished(false);
10329 return Err(common::Error::HttpError(err));
10330 }
10331 Ok(res) => {
10332 let (mut parts, body) = res.into_parts();
10333 let mut body = common::Body::new(body);
10334 if !parts.status.is_success() {
10335 let bytes = common::to_bytes(body).await.unwrap_or_default();
10336 let error = serde_json::from_str(&common::to_string(&bytes));
10337 let response = common::to_response(parts, bytes.into());
10338
10339 if let common::Retry::After(d) =
10340 dlg.http_failure(&response, error.as_ref().ok())
10341 {
10342 sleep(d).await;
10343 continue;
10344 }
10345
10346 dlg.finished(false);
10347
10348 return Err(match error {
10349 Ok(value) => common::Error::BadRequest(value),
10350 _ => common::Error::Failure(response),
10351 });
10352 }
10353 let response = {
10354 let bytes = common::to_bytes(body).await.unwrap_or_default();
10355 let encoded = common::to_string(&bytes);
10356 match serde_json::from_str(&encoded) {
10357 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10358 Err(error) => {
10359 dlg.response_json_decode_error(&encoded, &error);
10360 return Err(common::Error::JsonDecodeError(
10361 encoded.to_string(),
10362 error,
10363 ));
10364 }
10365 }
10366 };
10367
10368 dlg.finished(true);
10369 return Ok(response);
10370 }
10371 }
10372 }
10373 }
10374
10375 /// Name of a bucket.
10376 ///
10377 /// Sets the *bucket* path property to the given value.
10378 ///
10379 /// Even though the property as already been set when instantiating this call,
10380 /// we provide this method for API completeness.
10381 pub fn bucket(mut self, new_value: &str) -> BucketGetStorageLayoutCall<'a, C> {
10382 self._bucket = new_value.to_string();
10383 self
10384 }
10385 /// An optional prefix used for permission check. It is useful when the caller only has storage.objects.list permission under a specific prefix.
10386 ///
10387 /// Sets the *prefix* query property to the given value.
10388 pub fn prefix(mut self, new_value: &str) -> BucketGetStorageLayoutCall<'a, C> {
10389 self._prefix = Some(new_value.to_string());
10390 self
10391 }
10392 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10393 /// while executing the actual API request.
10394 ///
10395 /// ````text
10396 /// It should be used to handle progress information, and to implement a certain level of resilience.
10397 /// ````
10398 ///
10399 /// Sets the *delegate* property to the given value.
10400 pub fn delegate(
10401 mut self,
10402 new_value: &'a mut dyn common::Delegate,
10403 ) -> BucketGetStorageLayoutCall<'a, C> {
10404 self._delegate = Some(new_value);
10405 self
10406 }
10407
10408 /// Set any additional parameter of the query string used in the request.
10409 /// It should be used to set parameters which are not yet available through their own
10410 /// setters.
10411 ///
10412 /// Please note that this method must not be used to set any of the known parameters
10413 /// which have their own setter method. If done anyway, the request will fail.
10414 ///
10415 /// # Additional Parameters
10416 ///
10417 /// * *alt* (query-string) - Data format for the response.
10418 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10419 /// * *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.
10420 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10421 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10422 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10423 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
10424 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10425 pub fn param<T>(mut self, name: T, value: T) -> BucketGetStorageLayoutCall<'a, C>
10426 where
10427 T: AsRef<str>,
10428 {
10429 self._additional_params
10430 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10431 self
10432 }
10433
10434 /// Identifies the authorization scope for the method you are building.
10435 ///
10436 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10437 /// [`Scope::DevstorageReadOnly`].
10438 ///
10439 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10440 /// tokens for more than one scope.
10441 ///
10442 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10443 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10444 /// sufficient, a read-write scope will do as well.
10445 pub fn add_scope<St>(mut self, scope: St) -> BucketGetStorageLayoutCall<'a, C>
10446 where
10447 St: AsRef<str>,
10448 {
10449 self._scopes.insert(String::from(scope.as_ref()));
10450 self
10451 }
10452 /// Identifies the authorization scope(s) for the method you are building.
10453 ///
10454 /// See [`Self::add_scope()`] for details.
10455 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketGetStorageLayoutCall<'a, C>
10456 where
10457 I: IntoIterator<Item = St>,
10458 St: AsRef<str>,
10459 {
10460 self._scopes
10461 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10462 self
10463 }
10464
10465 /// Removes all scopes, and no default scope will be used either.
10466 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10467 /// for details).
10468 pub fn clear_scopes(mut self) -> BucketGetStorageLayoutCall<'a, C> {
10469 self._scopes.clear();
10470 self
10471 }
10472}
10473
10474/// Creates a new bucket.
10475///
10476/// A builder for the *insert* method supported by a *bucket* resource.
10477/// It is not used directly, but through a [`BucketMethods`] instance.
10478///
10479/// # Example
10480///
10481/// Instantiate a resource method builder
10482///
10483/// ```test_harness,no_run
10484/// # extern crate hyper;
10485/// # extern crate hyper_rustls;
10486/// # extern crate google_storage1 as storage1;
10487/// use storage1::api::Bucket;
10488/// # async fn dox() {
10489/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10490///
10491/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10492/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10493/// # .with_native_roots()
10494/// # .unwrap()
10495/// # .https_only()
10496/// # .enable_http2()
10497/// # .build();
10498///
10499/// # let executor = hyper_util::rt::TokioExecutor::new();
10500/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10501/// # secret,
10502/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10503/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10504/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10505/// # ),
10506/// # ).build().await.unwrap();
10507///
10508/// # let client = hyper_util::client::legacy::Client::builder(
10509/// # hyper_util::rt::TokioExecutor::new()
10510/// # )
10511/// # .build(
10512/// # hyper_rustls::HttpsConnectorBuilder::new()
10513/// # .with_native_roots()
10514/// # .unwrap()
10515/// # .https_or_http()
10516/// # .enable_http2()
10517/// # .build()
10518/// # );
10519/// # let mut hub = Storage::new(client, auth);
10520/// // As the method needs a request, you would usually fill it with the desired information
10521/// // into the respective structure. Some of the parts shown here might not be applicable !
10522/// // Values shown here are possibly random and not representative !
10523/// let mut req = Bucket::default();
10524///
10525/// // You can configure optional parameters by calling the respective setters at will, and
10526/// // execute the final call using `doit()`.
10527/// // Values shown here are possibly random and not representative !
10528/// let result = hub.buckets().insert(req, "project")
10529/// .user_project("takimata")
10530/// .projection("consetetur")
10531/// .predefined_default_object_acl("voluptua.")
10532/// .predefined_acl("et")
10533/// .enable_object_retention(false)
10534/// .doit().await;
10535/// # }
10536/// ```
10537pub struct BucketInsertCall<'a, C>
10538where
10539 C: 'a,
10540{
10541 hub: &'a Storage<C>,
10542 _request: Bucket,
10543 _project: String,
10544 _user_project: Option<String>,
10545 _projection: Option<String>,
10546 _predefined_default_object_acl: Option<String>,
10547 _predefined_acl: Option<String>,
10548 _enable_object_retention: Option<bool>,
10549 _delegate: Option<&'a mut dyn common::Delegate>,
10550 _additional_params: HashMap<String, String>,
10551 _scopes: BTreeSet<String>,
10552}
10553
10554impl<'a, C> common::CallBuilder for BucketInsertCall<'a, C> {}
10555
10556impl<'a, C> BucketInsertCall<'a, C>
10557where
10558 C: common::Connector,
10559{
10560 /// Perform the operation you have build so far.
10561 pub async fn doit(mut self) -> common::Result<(common::Response, Bucket)> {
10562 use std::borrow::Cow;
10563 use std::io::{Read, Seek};
10564
10565 use common::{url::Params, ToParts};
10566 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10567
10568 let mut dd = common::DefaultDelegate;
10569 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10570 dlg.begin(common::MethodInfo {
10571 id: "storage.buckets.insert",
10572 http_method: hyper::Method::POST,
10573 });
10574
10575 for &field in [
10576 "alt",
10577 "project",
10578 "userProject",
10579 "projection",
10580 "predefinedDefaultObjectAcl",
10581 "predefinedAcl",
10582 "enableObjectRetention",
10583 ]
10584 .iter()
10585 {
10586 if self._additional_params.contains_key(field) {
10587 dlg.finished(false);
10588 return Err(common::Error::FieldClash(field));
10589 }
10590 }
10591
10592 let mut params = Params::with_capacity(9 + self._additional_params.len());
10593 params.push("project", self._project);
10594 if let Some(value) = self._user_project.as_ref() {
10595 params.push("userProject", value);
10596 }
10597 if let Some(value) = self._projection.as_ref() {
10598 params.push("projection", value);
10599 }
10600 if let Some(value) = self._predefined_default_object_acl.as_ref() {
10601 params.push("predefinedDefaultObjectAcl", value);
10602 }
10603 if let Some(value) = self._predefined_acl.as_ref() {
10604 params.push("predefinedAcl", value);
10605 }
10606 if let Some(value) = self._enable_object_retention.as_ref() {
10607 params.push("enableObjectRetention", value.to_string());
10608 }
10609
10610 params.extend(self._additional_params.iter());
10611
10612 params.push("alt", "json");
10613 let mut url = self.hub._base_url.clone() + "b";
10614 if self._scopes.is_empty() {
10615 self._scopes
10616 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
10617 }
10618
10619 let url = params.parse_with_url(&url);
10620
10621 let mut json_mime_type = mime::APPLICATION_JSON;
10622 let mut request_value_reader = {
10623 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10624 common::remove_json_null_values(&mut value);
10625 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10626 serde_json::to_writer(&mut dst, &value).unwrap();
10627 dst
10628 };
10629 let request_size = request_value_reader
10630 .seek(std::io::SeekFrom::End(0))
10631 .unwrap();
10632 request_value_reader
10633 .seek(std::io::SeekFrom::Start(0))
10634 .unwrap();
10635
10636 loop {
10637 let token = match self
10638 .hub
10639 .auth
10640 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10641 .await
10642 {
10643 Ok(token) => token,
10644 Err(e) => match dlg.token(e) {
10645 Ok(token) => token,
10646 Err(e) => {
10647 dlg.finished(false);
10648 return Err(common::Error::MissingToken(e));
10649 }
10650 },
10651 };
10652 request_value_reader
10653 .seek(std::io::SeekFrom::Start(0))
10654 .unwrap();
10655 let mut req_result = {
10656 let client = &self.hub.client;
10657 dlg.pre_request();
10658 let mut req_builder = hyper::Request::builder()
10659 .method(hyper::Method::POST)
10660 .uri(url.as_str())
10661 .header(USER_AGENT, self.hub._user_agent.clone());
10662
10663 if let Some(token) = token.as_ref() {
10664 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10665 }
10666
10667 let request = req_builder
10668 .header(CONTENT_TYPE, json_mime_type.to_string())
10669 .header(CONTENT_LENGTH, request_size as u64)
10670 .body(common::to_body(
10671 request_value_reader.get_ref().clone().into(),
10672 ));
10673
10674 client.request(request.unwrap()).await
10675 };
10676
10677 match req_result {
10678 Err(err) => {
10679 if let common::Retry::After(d) = dlg.http_error(&err) {
10680 sleep(d).await;
10681 continue;
10682 }
10683 dlg.finished(false);
10684 return Err(common::Error::HttpError(err));
10685 }
10686 Ok(res) => {
10687 let (mut parts, body) = res.into_parts();
10688 let mut body = common::Body::new(body);
10689 if !parts.status.is_success() {
10690 let bytes = common::to_bytes(body).await.unwrap_or_default();
10691 let error = serde_json::from_str(&common::to_string(&bytes));
10692 let response = common::to_response(parts, bytes.into());
10693
10694 if let common::Retry::After(d) =
10695 dlg.http_failure(&response, error.as_ref().ok())
10696 {
10697 sleep(d).await;
10698 continue;
10699 }
10700
10701 dlg.finished(false);
10702
10703 return Err(match error {
10704 Ok(value) => common::Error::BadRequest(value),
10705 _ => common::Error::Failure(response),
10706 });
10707 }
10708 let response = {
10709 let bytes = common::to_bytes(body).await.unwrap_or_default();
10710 let encoded = common::to_string(&bytes);
10711 match serde_json::from_str(&encoded) {
10712 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10713 Err(error) => {
10714 dlg.response_json_decode_error(&encoded, &error);
10715 return Err(common::Error::JsonDecodeError(
10716 encoded.to_string(),
10717 error,
10718 ));
10719 }
10720 }
10721 };
10722
10723 dlg.finished(true);
10724 return Ok(response);
10725 }
10726 }
10727 }
10728 }
10729
10730 ///
10731 /// Sets the *request* property to the given value.
10732 ///
10733 /// Even though the property as already been set when instantiating this call,
10734 /// we provide this method for API completeness.
10735 pub fn request(mut self, new_value: Bucket) -> BucketInsertCall<'a, C> {
10736 self._request = new_value;
10737 self
10738 }
10739 /// A valid API project identifier.
10740 ///
10741 /// Sets the *project* query property to the given value.
10742 ///
10743 /// Even though the property as already been set when instantiating this call,
10744 /// we provide this method for API completeness.
10745 pub fn project(mut self, new_value: &str) -> BucketInsertCall<'a, C> {
10746 self._project = new_value.to_string();
10747 self
10748 }
10749 /// The project to be billed for this request.
10750 ///
10751 /// Sets the *user project* query property to the given value.
10752 pub fn user_project(mut self, new_value: &str) -> BucketInsertCall<'a, C> {
10753 self._user_project = Some(new_value.to_string());
10754 self
10755 }
10756 /// Set of properties to return. Defaults to noAcl, unless the bucket resource specifies acl or defaultObjectAcl properties, when it defaults to full.
10757 ///
10758 /// Sets the *projection* query property to the given value.
10759 pub fn projection(mut self, new_value: &str) -> BucketInsertCall<'a, C> {
10760 self._projection = Some(new_value.to_string());
10761 self
10762 }
10763 /// Apply a predefined set of default object access controls to this bucket.
10764 ///
10765 /// Sets the *predefined default object acl* query property to the given value.
10766 pub fn predefined_default_object_acl(mut self, new_value: &str) -> BucketInsertCall<'a, C> {
10767 self._predefined_default_object_acl = Some(new_value.to_string());
10768 self
10769 }
10770 /// Apply a predefined set of access controls to this bucket.
10771 ///
10772 /// Sets the *predefined acl* query property to the given value.
10773 pub fn predefined_acl(mut self, new_value: &str) -> BucketInsertCall<'a, C> {
10774 self._predefined_acl = Some(new_value.to_string());
10775 self
10776 }
10777 /// When set to true, object retention is enabled for this bucket.
10778 ///
10779 /// Sets the *enable object retention* query property to the given value.
10780 pub fn enable_object_retention(mut self, new_value: bool) -> BucketInsertCall<'a, C> {
10781 self._enable_object_retention = Some(new_value);
10782 self
10783 }
10784 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10785 /// while executing the actual API request.
10786 ///
10787 /// ````text
10788 /// It should be used to handle progress information, and to implement a certain level of resilience.
10789 /// ````
10790 ///
10791 /// Sets the *delegate* property to the given value.
10792 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> BucketInsertCall<'a, C> {
10793 self._delegate = Some(new_value);
10794 self
10795 }
10796
10797 /// Set any additional parameter of the query string used in the request.
10798 /// It should be used to set parameters which are not yet available through their own
10799 /// setters.
10800 ///
10801 /// Please note that this method must not be used to set any of the known parameters
10802 /// which have their own setter method. If done anyway, the request will fail.
10803 ///
10804 /// # Additional Parameters
10805 ///
10806 /// * *alt* (query-string) - Data format for the response.
10807 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10808 /// * *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.
10809 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10810 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10811 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10812 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
10813 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10814 pub fn param<T>(mut self, name: T, value: T) -> BucketInsertCall<'a, C>
10815 where
10816 T: AsRef<str>,
10817 {
10818 self._additional_params
10819 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10820 self
10821 }
10822
10823 /// Identifies the authorization scope for the method you are building.
10824 ///
10825 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10826 /// [`Scope::DevstorageReadWrite`].
10827 ///
10828 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10829 /// tokens for more than one scope.
10830 ///
10831 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10832 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10833 /// sufficient, a read-write scope will do as well.
10834 pub fn add_scope<St>(mut self, scope: St) -> BucketInsertCall<'a, C>
10835 where
10836 St: AsRef<str>,
10837 {
10838 self._scopes.insert(String::from(scope.as_ref()));
10839 self
10840 }
10841 /// Identifies the authorization scope(s) for the method you are building.
10842 ///
10843 /// See [`Self::add_scope()`] for details.
10844 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketInsertCall<'a, C>
10845 where
10846 I: IntoIterator<Item = St>,
10847 St: AsRef<str>,
10848 {
10849 self._scopes
10850 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10851 self
10852 }
10853
10854 /// Removes all scopes, and no default scope will be used either.
10855 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10856 /// for details).
10857 pub fn clear_scopes(mut self) -> BucketInsertCall<'a, C> {
10858 self._scopes.clear();
10859 self
10860 }
10861}
10862
10863/// Retrieves a list of buckets for a given project.
10864///
10865/// A builder for the *list* method supported by a *bucket* resource.
10866/// It is not used directly, but through a [`BucketMethods`] instance.
10867///
10868/// # Example
10869///
10870/// Instantiate a resource method builder
10871///
10872/// ```test_harness,no_run
10873/// # extern crate hyper;
10874/// # extern crate hyper_rustls;
10875/// # extern crate google_storage1 as storage1;
10876/// # async fn dox() {
10877/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10878///
10879/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10880/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10881/// # .with_native_roots()
10882/// # .unwrap()
10883/// # .https_only()
10884/// # .enable_http2()
10885/// # .build();
10886///
10887/// # let executor = hyper_util::rt::TokioExecutor::new();
10888/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10889/// # secret,
10890/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10891/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10892/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10893/// # ),
10894/// # ).build().await.unwrap();
10895///
10896/// # let client = hyper_util::client::legacy::Client::builder(
10897/// # hyper_util::rt::TokioExecutor::new()
10898/// # )
10899/// # .build(
10900/// # hyper_rustls::HttpsConnectorBuilder::new()
10901/// # .with_native_roots()
10902/// # .unwrap()
10903/// # .https_or_http()
10904/// # .enable_http2()
10905/// # .build()
10906/// # );
10907/// # let mut hub = Storage::new(client, auth);
10908/// // You can configure optional parameters by calling the respective setters at will, and
10909/// // execute the final call using `doit()`.
10910/// // Values shown here are possibly random and not representative !
10911/// let result = hub.buckets().list("project")
10912/// .user_project("sed")
10913/// .soft_deleted(true)
10914/// .return_partial_success(false)
10915/// .projection("accusam")
10916/// .prefix("voluptua.")
10917/// .page_token("dolore")
10918/// .max_results(67)
10919/// .doit().await;
10920/// # }
10921/// ```
10922pub struct BucketListCall<'a, C>
10923where
10924 C: 'a,
10925{
10926 hub: &'a Storage<C>,
10927 _project: String,
10928 _user_project: Option<String>,
10929 _soft_deleted: Option<bool>,
10930 _return_partial_success: Option<bool>,
10931 _projection: Option<String>,
10932 _prefix: Option<String>,
10933 _page_token: Option<String>,
10934 _max_results: Option<u32>,
10935 _delegate: Option<&'a mut dyn common::Delegate>,
10936 _additional_params: HashMap<String, String>,
10937 _scopes: BTreeSet<String>,
10938}
10939
10940impl<'a, C> common::CallBuilder for BucketListCall<'a, C> {}
10941
10942impl<'a, C> BucketListCall<'a, C>
10943where
10944 C: common::Connector,
10945{
10946 /// Perform the operation you have build so far.
10947 pub async fn doit(mut self) -> common::Result<(common::Response, Buckets)> {
10948 use std::borrow::Cow;
10949 use std::io::{Read, Seek};
10950
10951 use common::{url::Params, ToParts};
10952 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10953
10954 let mut dd = common::DefaultDelegate;
10955 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10956 dlg.begin(common::MethodInfo {
10957 id: "storage.buckets.list",
10958 http_method: hyper::Method::GET,
10959 });
10960
10961 for &field in [
10962 "alt",
10963 "project",
10964 "userProject",
10965 "softDeleted",
10966 "returnPartialSuccess",
10967 "projection",
10968 "prefix",
10969 "pageToken",
10970 "maxResults",
10971 ]
10972 .iter()
10973 {
10974 if self._additional_params.contains_key(field) {
10975 dlg.finished(false);
10976 return Err(common::Error::FieldClash(field));
10977 }
10978 }
10979
10980 let mut params = Params::with_capacity(10 + self._additional_params.len());
10981 params.push("project", self._project);
10982 if let Some(value) = self._user_project.as_ref() {
10983 params.push("userProject", value);
10984 }
10985 if let Some(value) = self._soft_deleted.as_ref() {
10986 params.push("softDeleted", value.to_string());
10987 }
10988 if let Some(value) = self._return_partial_success.as_ref() {
10989 params.push("returnPartialSuccess", value.to_string());
10990 }
10991 if let Some(value) = self._projection.as_ref() {
10992 params.push("projection", value);
10993 }
10994 if let Some(value) = self._prefix.as_ref() {
10995 params.push("prefix", value);
10996 }
10997 if let Some(value) = self._page_token.as_ref() {
10998 params.push("pageToken", value);
10999 }
11000 if let Some(value) = self._max_results.as_ref() {
11001 params.push("maxResults", value.to_string());
11002 }
11003
11004 params.extend(self._additional_params.iter());
11005
11006 params.push("alt", "json");
11007 let mut url = self.hub._base_url.clone() + "b";
11008 if self._scopes.is_empty() {
11009 self._scopes
11010 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
11011 }
11012
11013 let url = params.parse_with_url(&url);
11014
11015 loop {
11016 let token = match self
11017 .hub
11018 .auth
11019 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11020 .await
11021 {
11022 Ok(token) => token,
11023 Err(e) => match dlg.token(e) {
11024 Ok(token) => token,
11025 Err(e) => {
11026 dlg.finished(false);
11027 return Err(common::Error::MissingToken(e));
11028 }
11029 },
11030 };
11031 let mut req_result = {
11032 let client = &self.hub.client;
11033 dlg.pre_request();
11034 let mut req_builder = hyper::Request::builder()
11035 .method(hyper::Method::GET)
11036 .uri(url.as_str())
11037 .header(USER_AGENT, self.hub._user_agent.clone());
11038
11039 if let Some(token) = token.as_ref() {
11040 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11041 }
11042
11043 let request = req_builder
11044 .header(CONTENT_LENGTH, 0_u64)
11045 .body(common::to_body::<String>(None));
11046
11047 client.request(request.unwrap()).await
11048 };
11049
11050 match req_result {
11051 Err(err) => {
11052 if let common::Retry::After(d) = dlg.http_error(&err) {
11053 sleep(d).await;
11054 continue;
11055 }
11056 dlg.finished(false);
11057 return Err(common::Error::HttpError(err));
11058 }
11059 Ok(res) => {
11060 let (mut parts, body) = res.into_parts();
11061 let mut body = common::Body::new(body);
11062 if !parts.status.is_success() {
11063 let bytes = common::to_bytes(body).await.unwrap_or_default();
11064 let error = serde_json::from_str(&common::to_string(&bytes));
11065 let response = common::to_response(parts, bytes.into());
11066
11067 if let common::Retry::After(d) =
11068 dlg.http_failure(&response, error.as_ref().ok())
11069 {
11070 sleep(d).await;
11071 continue;
11072 }
11073
11074 dlg.finished(false);
11075
11076 return Err(match error {
11077 Ok(value) => common::Error::BadRequest(value),
11078 _ => common::Error::Failure(response),
11079 });
11080 }
11081 let response = {
11082 let bytes = common::to_bytes(body).await.unwrap_or_default();
11083 let encoded = common::to_string(&bytes);
11084 match serde_json::from_str(&encoded) {
11085 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11086 Err(error) => {
11087 dlg.response_json_decode_error(&encoded, &error);
11088 return Err(common::Error::JsonDecodeError(
11089 encoded.to_string(),
11090 error,
11091 ));
11092 }
11093 }
11094 };
11095
11096 dlg.finished(true);
11097 return Ok(response);
11098 }
11099 }
11100 }
11101 }
11102
11103 /// A valid API project identifier.
11104 ///
11105 /// Sets the *project* query property to the given value.
11106 ///
11107 /// Even though the property as already been set when instantiating this call,
11108 /// we provide this method for API completeness.
11109 pub fn project(mut self, new_value: &str) -> BucketListCall<'a, C> {
11110 self._project = new_value.to_string();
11111 self
11112 }
11113 /// The project to be billed for this request.
11114 ///
11115 /// Sets the *user project* query property to the given value.
11116 pub fn user_project(mut self, new_value: &str) -> BucketListCall<'a, C> {
11117 self._user_project = Some(new_value.to_string());
11118 self
11119 }
11120 /// If true, only soft-deleted bucket versions will be returned. The default is false. For more information, see [Soft Delete](https://cloud.google.com/storage/docs/soft-delete).
11121 ///
11122 /// Sets the *soft deleted* query property to the given value.
11123 pub fn soft_deleted(mut self, new_value: bool) -> BucketListCall<'a, C> {
11124 self._soft_deleted = Some(new_value);
11125 self
11126 }
11127 /// If true, return a list of bucket resource names for buckets that are in unreachable locations.
11128 ///
11129 /// Sets the *return partial success* query property to the given value.
11130 pub fn return_partial_success(mut self, new_value: bool) -> BucketListCall<'a, C> {
11131 self._return_partial_success = Some(new_value);
11132 self
11133 }
11134 /// Set of properties to return. Defaults to noAcl.
11135 ///
11136 /// Sets the *projection* query property to the given value.
11137 pub fn projection(mut self, new_value: &str) -> BucketListCall<'a, C> {
11138 self._projection = Some(new_value.to_string());
11139 self
11140 }
11141 /// Filter results to buckets whose names begin with this prefix.
11142 ///
11143 /// Sets the *prefix* query property to the given value.
11144 pub fn prefix(mut self, new_value: &str) -> BucketListCall<'a, C> {
11145 self._prefix = Some(new_value.to_string());
11146 self
11147 }
11148 /// A previously-returned page token representing part of the larger set of results to view.
11149 ///
11150 /// Sets the *page token* query property to the given value.
11151 pub fn page_token(mut self, new_value: &str) -> BucketListCall<'a, C> {
11152 self._page_token = Some(new_value.to_string());
11153 self
11154 }
11155 /// Maximum number of buckets to return in a single response. The service will use this parameter or 1,000 items, whichever is smaller.
11156 ///
11157 /// Sets the *max results* query property to the given value.
11158 pub fn max_results(mut self, new_value: u32) -> BucketListCall<'a, C> {
11159 self._max_results = Some(new_value);
11160 self
11161 }
11162 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11163 /// while executing the actual API request.
11164 ///
11165 /// ````text
11166 /// It should be used to handle progress information, and to implement a certain level of resilience.
11167 /// ````
11168 ///
11169 /// Sets the *delegate* property to the given value.
11170 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> BucketListCall<'a, C> {
11171 self._delegate = Some(new_value);
11172 self
11173 }
11174
11175 /// Set any additional parameter of the query string used in the request.
11176 /// It should be used to set parameters which are not yet available through their own
11177 /// setters.
11178 ///
11179 /// Please note that this method must not be used to set any of the known parameters
11180 /// which have their own setter method. If done anyway, the request will fail.
11181 ///
11182 /// # Additional Parameters
11183 ///
11184 /// * *alt* (query-string) - Data format for the response.
11185 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11186 /// * *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.
11187 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11188 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11189 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11190 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
11191 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11192 pub fn param<T>(mut self, name: T, value: T) -> BucketListCall<'a, C>
11193 where
11194 T: AsRef<str>,
11195 {
11196 self._additional_params
11197 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11198 self
11199 }
11200
11201 /// Identifies the authorization scope for the method you are building.
11202 ///
11203 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11204 /// [`Scope::DevstorageReadOnly`].
11205 ///
11206 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11207 /// tokens for more than one scope.
11208 ///
11209 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11210 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11211 /// sufficient, a read-write scope will do as well.
11212 pub fn add_scope<St>(mut self, scope: St) -> BucketListCall<'a, C>
11213 where
11214 St: AsRef<str>,
11215 {
11216 self._scopes.insert(String::from(scope.as_ref()));
11217 self
11218 }
11219 /// Identifies the authorization scope(s) for the method you are building.
11220 ///
11221 /// See [`Self::add_scope()`] for details.
11222 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketListCall<'a, C>
11223 where
11224 I: IntoIterator<Item = St>,
11225 St: AsRef<str>,
11226 {
11227 self._scopes
11228 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11229 self
11230 }
11231
11232 /// Removes all scopes, and no default scope will be used either.
11233 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11234 /// for details).
11235 pub fn clear_scopes(mut self) -> BucketListCall<'a, C> {
11236 self._scopes.clear();
11237 self
11238 }
11239}
11240
11241/// Locks retention policy on a bucket.
11242///
11243/// A builder for the *lockRetentionPolicy* method supported by a *bucket* resource.
11244/// It is not used directly, but through a [`BucketMethods`] instance.
11245///
11246/// # Example
11247///
11248/// Instantiate a resource method builder
11249///
11250/// ```test_harness,no_run
11251/// # extern crate hyper;
11252/// # extern crate hyper_rustls;
11253/// # extern crate google_storage1 as storage1;
11254/// # async fn dox() {
11255/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11256///
11257/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11258/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11259/// # .with_native_roots()
11260/// # .unwrap()
11261/// # .https_only()
11262/// # .enable_http2()
11263/// # .build();
11264///
11265/// # let executor = hyper_util::rt::TokioExecutor::new();
11266/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11267/// # secret,
11268/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11269/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11270/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11271/// # ),
11272/// # ).build().await.unwrap();
11273///
11274/// # let client = hyper_util::client::legacy::Client::builder(
11275/// # hyper_util::rt::TokioExecutor::new()
11276/// # )
11277/// # .build(
11278/// # hyper_rustls::HttpsConnectorBuilder::new()
11279/// # .with_native_roots()
11280/// # .unwrap()
11281/// # .https_or_http()
11282/// # .enable_http2()
11283/// # .build()
11284/// # );
11285/// # let mut hub = Storage::new(client, auth);
11286/// // You can configure optional parameters by calling the respective setters at will, and
11287/// // execute the final call using `doit()`.
11288/// // Values shown here are possibly random and not representative !
11289/// let result = hub.buckets().lock_retention_policy("bucket", -78)
11290/// .user_project("amet.")
11291/// .doit().await;
11292/// # }
11293/// ```
11294pub struct BucketLockRetentionPolicyCall<'a, C>
11295where
11296 C: 'a,
11297{
11298 hub: &'a Storage<C>,
11299 _bucket: String,
11300 _if_metageneration_match: i64,
11301 _user_project: Option<String>,
11302 _delegate: Option<&'a mut dyn common::Delegate>,
11303 _additional_params: HashMap<String, String>,
11304 _scopes: BTreeSet<String>,
11305}
11306
11307impl<'a, C> common::CallBuilder for BucketLockRetentionPolicyCall<'a, C> {}
11308
11309impl<'a, C> BucketLockRetentionPolicyCall<'a, C>
11310where
11311 C: common::Connector,
11312{
11313 /// Perform the operation you have build so far.
11314 pub async fn doit(mut self) -> common::Result<(common::Response, Bucket)> {
11315 use std::borrow::Cow;
11316 use std::io::{Read, Seek};
11317
11318 use common::{url::Params, ToParts};
11319 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11320
11321 let mut dd = common::DefaultDelegate;
11322 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11323 dlg.begin(common::MethodInfo {
11324 id: "storage.buckets.lockRetentionPolicy",
11325 http_method: hyper::Method::POST,
11326 });
11327
11328 for &field in ["alt", "bucket", "ifMetagenerationMatch", "userProject"].iter() {
11329 if self._additional_params.contains_key(field) {
11330 dlg.finished(false);
11331 return Err(common::Error::FieldClash(field));
11332 }
11333 }
11334
11335 let mut params = Params::with_capacity(5 + self._additional_params.len());
11336 params.push("bucket", self._bucket);
11337 params.push(
11338 "ifMetagenerationMatch",
11339 self._if_metageneration_match.to_string(),
11340 );
11341 if let Some(value) = self._user_project.as_ref() {
11342 params.push("userProject", value);
11343 }
11344
11345 params.extend(self._additional_params.iter());
11346
11347 params.push("alt", "json");
11348 let mut url = self.hub._base_url.clone() + "b/{bucket}/lockRetentionPolicy";
11349 if self._scopes.is_empty() {
11350 self._scopes
11351 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
11352 }
11353
11354 #[allow(clippy::single_element_loop)]
11355 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
11356 url = params.uri_replacement(url, param_name, find_this, false);
11357 }
11358 {
11359 let to_remove = ["bucket"];
11360 params.remove_params(&to_remove);
11361 }
11362
11363 let url = params.parse_with_url(&url);
11364
11365 loop {
11366 let token = match self
11367 .hub
11368 .auth
11369 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11370 .await
11371 {
11372 Ok(token) => token,
11373 Err(e) => match dlg.token(e) {
11374 Ok(token) => token,
11375 Err(e) => {
11376 dlg.finished(false);
11377 return Err(common::Error::MissingToken(e));
11378 }
11379 },
11380 };
11381 let mut req_result = {
11382 let client = &self.hub.client;
11383 dlg.pre_request();
11384 let mut req_builder = hyper::Request::builder()
11385 .method(hyper::Method::POST)
11386 .uri(url.as_str())
11387 .header(USER_AGENT, self.hub._user_agent.clone());
11388
11389 if let Some(token) = token.as_ref() {
11390 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11391 }
11392
11393 let request = req_builder
11394 .header(CONTENT_LENGTH, 0_u64)
11395 .body(common::to_body::<String>(None));
11396
11397 client.request(request.unwrap()).await
11398 };
11399
11400 match req_result {
11401 Err(err) => {
11402 if let common::Retry::After(d) = dlg.http_error(&err) {
11403 sleep(d).await;
11404 continue;
11405 }
11406 dlg.finished(false);
11407 return Err(common::Error::HttpError(err));
11408 }
11409 Ok(res) => {
11410 let (mut parts, body) = res.into_parts();
11411 let mut body = common::Body::new(body);
11412 if !parts.status.is_success() {
11413 let bytes = common::to_bytes(body).await.unwrap_or_default();
11414 let error = serde_json::from_str(&common::to_string(&bytes));
11415 let response = common::to_response(parts, bytes.into());
11416
11417 if let common::Retry::After(d) =
11418 dlg.http_failure(&response, error.as_ref().ok())
11419 {
11420 sleep(d).await;
11421 continue;
11422 }
11423
11424 dlg.finished(false);
11425
11426 return Err(match error {
11427 Ok(value) => common::Error::BadRequest(value),
11428 _ => common::Error::Failure(response),
11429 });
11430 }
11431 let response = {
11432 let bytes = common::to_bytes(body).await.unwrap_or_default();
11433 let encoded = common::to_string(&bytes);
11434 match serde_json::from_str(&encoded) {
11435 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11436 Err(error) => {
11437 dlg.response_json_decode_error(&encoded, &error);
11438 return Err(common::Error::JsonDecodeError(
11439 encoded.to_string(),
11440 error,
11441 ));
11442 }
11443 }
11444 };
11445
11446 dlg.finished(true);
11447 return Ok(response);
11448 }
11449 }
11450 }
11451 }
11452
11453 /// Name of a bucket.
11454 ///
11455 /// Sets the *bucket* path property to the given value.
11456 ///
11457 /// Even though the property as already been set when instantiating this call,
11458 /// we provide this method for API completeness.
11459 pub fn bucket(mut self, new_value: &str) -> BucketLockRetentionPolicyCall<'a, C> {
11460 self._bucket = new_value.to_string();
11461 self
11462 }
11463 /// Makes the operation conditional on whether bucket's current metageneration matches the given value.
11464 ///
11465 /// Sets the *if metageneration match* query property to the given value.
11466 ///
11467 /// Even though the property as already been set when instantiating this call,
11468 /// we provide this method for API completeness.
11469 pub fn if_metageneration_match(
11470 mut self,
11471 new_value: i64,
11472 ) -> BucketLockRetentionPolicyCall<'a, C> {
11473 self._if_metageneration_match = new_value;
11474 self
11475 }
11476 /// The project to be billed for this request. Required for Requester Pays buckets.
11477 ///
11478 /// Sets the *user project* query property to the given value.
11479 pub fn user_project(mut self, new_value: &str) -> BucketLockRetentionPolicyCall<'a, C> {
11480 self._user_project = Some(new_value.to_string());
11481 self
11482 }
11483 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11484 /// while executing the actual API request.
11485 ///
11486 /// ````text
11487 /// It should be used to handle progress information, and to implement a certain level of resilience.
11488 /// ````
11489 ///
11490 /// Sets the *delegate* property to the given value.
11491 pub fn delegate(
11492 mut self,
11493 new_value: &'a mut dyn common::Delegate,
11494 ) -> BucketLockRetentionPolicyCall<'a, C> {
11495 self._delegate = Some(new_value);
11496 self
11497 }
11498
11499 /// Set any additional parameter of the query string used in the request.
11500 /// It should be used to set parameters which are not yet available through their own
11501 /// setters.
11502 ///
11503 /// Please note that this method must not be used to set any of the known parameters
11504 /// which have their own setter method. If done anyway, the request will fail.
11505 ///
11506 /// # Additional Parameters
11507 ///
11508 /// * *alt* (query-string) - Data format for the response.
11509 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11510 /// * *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.
11511 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11512 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11513 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11514 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
11515 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11516 pub fn param<T>(mut self, name: T, value: T) -> BucketLockRetentionPolicyCall<'a, C>
11517 where
11518 T: AsRef<str>,
11519 {
11520 self._additional_params
11521 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11522 self
11523 }
11524
11525 /// Identifies the authorization scope for the method you are building.
11526 ///
11527 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11528 /// [`Scope::DevstorageReadWrite`].
11529 ///
11530 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11531 /// tokens for more than one scope.
11532 ///
11533 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11534 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11535 /// sufficient, a read-write scope will do as well.
11536 pub fn add_scope<St>(mut self, scope: St) -> BucketLockRetentionPolicyCall<'a, C>
11537 where
11538 St: AsRef<str>,
11539 {
11540 self._scopes.insert(String::from(scope.as_ref()));
11541 self
11542 }
11543 /// Identifies the authorization scope(s) for the method you are building.
11544 ///
11545 /// See [`Self::add_scope()`] for details.
11546 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketLockRetentionPolicyCall<'a, C>
11547 where
11548 I: IntoIterator<Item = St>,
11549 St: AsRef<str>,
11550 {
11551 self._scopes
11552 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11553 self
11554 }
11555
11556 /// Removes all scopes, and no default scope will be used either.
11557 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11558 /// for details).
11559 pub fn clear_scopes(mut self) -> BucketLockRetentionPolicyCall<'a, C> {
11560 self._scopes.clear();
11561 self
11562 }
11563}
11564
11565/// Patches a bucket. Changes to the bucket will be readable immediately after writing, but configuration changes may take time to propagate.
11566///
11567/// A builder for the *patch* method supported by a *bucket* resource.
11568/// It is not used directly, but through a [`BucketMethods`] instance.
11569///
11570/// # Example
11571///
11572/// Instantiate a resource method builder
11573///
11574/// ```test_harness,no_run
11575/// # extern crate hyper;
11576/// # extern crate hyper_rustls;
11577/// # extern crate google_storage1 as storage1;
11578/// use storage1::api::Bucket;
11579/// # async fn dox() {
11580/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11581///
11582/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11583/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11584/// # .with_native_roots()
11585/// # .unwrap()
11586/// # .https_only()
11587/// # .enable_http2()
11588/// # .build();
11589///
11590/// # let executor = hyper_util::rt::TokioExecutor::new();
11591/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11592/// # secret,
11593/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11594/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11595/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11596/// # ),
11597/// # ).build().await.unwrap();
11598///
11599/// # let client = hyper_util::client::legacy::Client::builder(
11600/// # hyper_util::rt::TokioExecutor::new()
11601/// # )
11602/// # .build(
11603/// # hyper_rustls::HttpsConnectorBuilder::new()
11604/// # .with_native_roots()
11605/// # .unwrap()
11606/// # .https_or_http()
11607/// # .enable_http2()
11608/// # .build()
11609/// # );
11610/// # let mut hub = Storage::new(client, auth);
11611/// // As the method needs a request, you would usually fill it with the desired information
11612/// // into the respective structure. Some of the parts shown here might not be applicable !
11613/// // Values shown here are possibly random and not representative !
11614/// let mut req = Bucket::default();
11615///
11616/// // You can configure optional parameters by calling the respective setters at will, and
11617/// // execute the final call using `doit()`.
11618/// // Values shown here are possibly random and not representative !
11619/// let result = hub.buckets().patch(req, "bucket")
11620/// .user_project("sadipscing")
11621/// .projection("Lorem")
11622/// .predefined_default_object_acl("invidunt")
11623/// .predefined_acl("no")
11624/// .if_metageneration_not_match(-7)
11625/// .if_metageneration_match(-27)
11626/// .doit().await;
11627/// # }
11628/// ```
11629pub struct BucketPatchCall<'a, C>
11630where
11631 C: 'a,
11632{
11633 hub: &'a Storage<C>,
11634 _request: Bucket,
11635 _bucket: String,
11636 _user_project: Option<String>,
11637 _projection: Option<String>,
11638 _predefined_default_object_acl: Option<String>,
11639 _predefined_acl: Option<String>,
11640 _if_metageneration_not_match: Option<i64>,
11641 _if_metageneration_match: Option<i64>,
11642 _delegate: Option<&'a mut dyn common::Delegate>,
11643 _additional_params: HashMap<String, String>,
11644 _scopes: BTreeSet<String>,
11645}
11646
11647impl<'a, C> common::CallBuilder for BucketPatchCall<'a, C> {}
11648
11649impl<'a, C> BucketPatchCall<'a, C>
11650where
11651 C: common::Connector,
11652{
11653 /// Perform the operation you have build so far.
11654 pub async fn doit(mut self) -> common::Result<(common::Response, Bucket)> {
11655 use std::borrow::Cow;
11656 use std::io::{Read, Seek};
11657
11658 use common::{url::Params, ToParts};
11659 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11660
11661 let mut dd = common::DefaultDelegate;
11662 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11663 dlg.begin(common::MethodInfo {
11664 id: "storage.buckets.patch",
11665 http_method: hyper::Method::PATCH,
11666 });
11667
11668 for &field in [
11669 "alt",
11670 "bucket",
11671 "userProject",
11672 "projection",
11673 "predefinedDefaultObjectAcl",
11674 "predefinedAcl",
11675 "ifMetagenerationNotMatch",
11676 "ifMetagenerationMatch",
11677 ]
11678 .iter()
11679 {
11680 if self._additional_params.contains_key(field) {
11681 dlg.finished(false);
11682 return Err(common::Error::FieldClash(field));
11683 }
11684 }
11685
11686 let mut params = Params::with_capacity(10 + self._additional_params.len());
11687 params.push("bucket", self._bucket);
11688 if let Some(value) = self._user_project.as_ref() {
11689 params.push("userProject", value);
11690 }
11691 if let Some(value) = self._projection.as_ref() {
11692 params.push("projection", value);
11693 }
11694 if let Some(value) = self._predefined_default_object_acl.as_ref() {
11695 params.push("predefinedDefaultObjectAcl", value);
11696 }
11697 if let Some(value) = self._predefined_acl.as_ref() {
11698 params.push("predefinedAcl", value);
11699 }
11700 if let Some(value) = self._if_metageneration_not_match.as_ref() {
11701 params.push("ifMetagenerationNotMatch", value.to_string());
11702 }
11703 if let Some(value) = self._if_metageneration_match.as_ref() {
11704 params.push("ifMetagenerationMatch", value.to_string());
11705 }
11706
11707 params.extend(self._additional_params.iter());
11708
11709 params.push("alt", "json");
11710 let mut url = self.hub._base_url.clone() + "b/{bucket}";
11711 if self._scopes.is_empty() {
11712 self._scopes
11713 .insert(Scope::DevstorageFullControl.as_ref().to_string());
11714 }
11715
11716 #[allow(clippy::single_element_loop)]
11717 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
11718 url = params.uri_replacement(url, param_name, find_this, false);
11719 }
11720 {
11721 let to_remove = ["bucket"];
11722 params.remove_params(&to_remove);
11723 }
11724
11725 let url = params.parse_with_url(&url);
11726
11727 let mut json_mime_type = mime::APPLICATION_JSON;
11728 let mut request_value_reader = {
11729 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11730 common::remove_json_null_values(&mut value);
11731 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11732 serde_json::to_writer(&mut dst, &value).unwrap();
11733 dst
11734 };
11735 let request_size = request_value_reader
11736 .seek(std::io::SeekFrom::End(0))
11737 .unwrap();
11738 request_value_reader
11739 .seek(std::io::SeekFrom::Start(0))
11740 .unwrap();
11741
11742 loop {
11743 let token = match self
11744 .hub
11745 .auth
11746 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11747 .await
11748 {
11749 Ok(token) => token,
11750 Err(e) => match dlg.token(e) {
11751 Ok(token) => token,
11752 Err(e) => {
11753 dlg.finished(false);
11754 return Err(common::Error::MissingToken(e));
11755 }
11756 },
11757 };
11758 request_value_reader
11759 .seek(std::io::SeekFrom::Start(0))
11760 .unwrap();
11761 let mut req_result = {
11762 let client = &self.hub.client;
11763 dlg.pre_request();
11764 let mut req_builder = hyper::Request::builder()
11765 .method(hyper::Method::PATCH)
11766 .uri(url.as_str())
11767 .header(USER_AGENT, self.hub._user_agent.clone());
11768
11769 if let Some(token) = token.as_ref() {
11770 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11771 }
11772
11773 let request = req_builder
11774 .header(CONTENT_TYPE, json_mime_type.to_string())
11775 .header(CONTENT_LENGTH, request_size as u64)
11776 .body(common::to_body(
11777 request_value_reader.get_ref().clone().into(),
11778 ));
11779
11780 client.request(request.unwrap()).await
11781 };
11782
11783 match req_result {
11784 Err(err) => {
11785 if let common::Retry::After(d) = dlg.http_error(&err) {
11786 sleep(d).await;
11787 continue;
11788 }
11789 dlg.finished(false);
11790 return Err(common::Error::HttpError(err));
11791 }
11792 Ok(res) => {
11793 let (mut parts, body) = res.into_parts();
11794 let mut body = common::Body::new(body);
11795 if !parts.status.is_success() {
11796 let bytes = common::to_bytes(body).await.unwrap_or_default();
11797 let error = serde_json::from_str(&common::to_string(&bytes));
11798 let response = common::to_response(parts, bytes.into());
11799
11800 if let common::Retry::After(d) =
11801 dlg.http_failure(&response, error.as_ref().ok())
11802 {
11803 sleep(d).await;
11804 continue;
11805 }
11806
11807 dlg.finished(false);
11808
11809 return Err(match error {
11810 Ok(value) => common::Error::BadRequest(value),
11811 _ => common::Error::Failure(response),
11812 });
11813 }
11814 let response = {
11815 let bytes = common::to_bytes(body).await.unwrap_or_default();
11816 let encoded = common::to_string(&bytes);
11817 match serde_json::from_str(&encoded) {
11818 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11819 Err(error) => {
11820 dlg.response_json_decode_error(&encoded, &error);
11821 return Err(common::Error::JsonDecodeError(
11822 encoded.to_string(),
11823 error,
11824 ));
11825 }
11826 }
11827 };
11828
11829 dlg.finished(true);
11830 return Ok(response);
11831 }
11832 }
11833 }
11834 }
11835
11836 ///
11837 /// Sets the *request* property to the given value.
11838 ///
11839 /// Even though the property as already been set when instantiating this call,
11840 /// we provide this method for API completeness.
11841 pub fn request(mut self, new_value: Bucket) -> BucketPatchCall<'a, C> {
11842 self._request = new_value;
11843 self
11844 }
11845 /// Name of a bucket.
11846 ///
11847 /// Sets the *bucket* path property to the given value.
11848 ///
11849 /// Even though the property as already been set when instantiating this call,
11850 /// we provide this method for API completeness.
11851 pub fn bucket(mut self, new_value: &str) -> BucketPatchCall<'a, C> {
11852 self._bucket = new_value.to_string();
11853 self
11854 }
11855 /// The project to be billed for this request. Required for Requester Pays buckets.
11856 ///
11857 /// Sets the *user project* query property to the given value.
11858 pub fn user_project(mut self, new_value: &str) -> BucketPatchCall<'a, C> {
11859 self._user_project = Some(new_value.to_string());
11860 self
11861 }
11862 /// Set of properties to return. Defaults to full.
11863 ///
11864 /// Sets the *projection* query property to the given value.
11865 pub fn projection(mut self, new_value: &str) -> BucketPatchCall<'a, C> {
11866 self._projection = Some(new_value.to_string());
11867 self
11868 }
11869 /// Apply a predefined set of default object access controls to this bucket.
11870 ///
11871 /// Sets the *predefined default object acl* query property to the given value.
11872 pub fn predefined_default_object_acl(mut self, new_value: &str) -> BucketPatchCall<'a, C> {
11873 self._predefined_default_object_acl = Some(new_value.to_string());
11874 self
11875 }
11876 /// Apply a predefined set of access controls to this bucket.
11877 ///
11878 /// Sets the *predefined acl* query property to the given value.
11879 pub fn predefined_acl(mut self, new_value: &str) -> BucketPatchCall<'a, C> {
11880 self._predefined_acl = Some(new_value.to_string());
11881 self
11882 }
11883 /// Makes the return of the bucket metadata conditional on whether the bucket's current metageneration does not match the given value.
11884 ///
11885 /// Sets the *if metageneration not match* query property to the given value.
11886 pub fn if_metageneration_not_match(mut self, new_value: i64) -> BucketPatchCall<'a, C> {
11887 self._if_metageneration_not_match = Some(new_value);
11888 self
11889 }
11890 /// Makes the return of the bucket metadata conditional on whether the bucket's current metageneration matches the given value.
11891 ///
11892 /// Sets the *if metageneration match* query property to the given value.
11893 pub fn if_metageneration_match(mut self, new_value: i64) -> BucketPatchCall<'a, C> {
11894 self._if_metageneration_match = Some(new_value);
11895 self
11896 }
11897 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11898 /// while executing the actual API request.
11899 ///
11900 /// ````text
11901 /// It should be used to handle progress information, and to implement a certain level of resilience.
11902 /// ````
11903 ///
11904 /// Sets the *delegate* property to the given value.
11905 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> BucketPatchCall<'a, C> {
11906 self._delegate = Some(new_value);
11907 self
11908 }
11909
11910 /// Set any additional parameter of the query string used in the request.
11911 /// It should be used to set parameters which are not yet available through their own
11912 /// setters.
11913 ///
11914 /// Please note that this method must not be used to set any of the known parameters
11915 /// which have their own setter method. If done anyway, the request will fail.
11916 ///
11917 /// # Additional Parameters
11918 ///
11919 /// * *alt* (query-string) - Data format for the response.
11920 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11921 /// * *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.
11922 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11923 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11924 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11925 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
11926 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11927 pub fn param<T>(mut self, name: T, value: T) -> BucketPatchCall<'a, C>
11928 where
11929 T: AsRef<str>,
11930 {
11931 self._additional_params
11932 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11933 self
11934 }
11935
11936 /// Identifies the authorization scope for the method you are building.
11937 ///
11938 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11939 /// [`Scope::DevstorageFullControl`].
11940 ///
11941 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11942 /// tokens for more than one scope.
11943 ///
11944 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11945 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11946 /// sufficient, a read-write scope will do as well.
11947 pub fn add_scope<St>(mut self, scope: St) -> BucketPatchCall<'a, C>
11948 where
11949 St: AsRef<str>,
11950 {
11951 self._scopes.insert(String::from(scope.as_ref()));
11952 self
11953 }
11954 /// Identifies the authorization scope(s) for the method you are building.
11955 ///
11956 /// See [`Self::add_scope()`] for details.
11957 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketPatchCall<'a, C>
11958 where
11959 I: IntoIterator<Item = St>,
11960 St: AsRef<str>,
11961 {
11962 self._scopes
11963 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11964 self
11965 }
11966
11967 /// Removes all scopes, and no default scope will be used either.
11968 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11969 /// for details).
11970 pub fn clear_scopes(mut self) -> BucketPatchCall<'a, C> {
11971 self._scopes.clear();
11972 self
11973 }
11974}
11975
11976/// Initiates a long-running Relocate Bucket operation on the specified bucket.
11977///
11978/// A builder for the *relocate* method supported by a *bucket* resource.
11979/// It is not used directly, but through a [`BucketMethods`] instance.
11980///
11981/// # Example
11982///
11983/// Instantiate a resource method builder
11984///
11985/// ```test_harness,no_run
11986/// # extern crate hyper;
11987/// # extern crate hyper_rustls;
11988/// # extern crate google_storage1 as storage1;
11989/// use storage1::api::RelocateBucketRequest;
11990/// # async fn dox() {
11991/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11992///
11993/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11994/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11995/// # .with_native_roots()
11996/// # .unwrap()
11997/// # .https_only()
11998/// # .enable_http2()
11999/// # .build();
12000///
12001/// # let executor = hyper_util::rt::TokioExecutor::new();
12002/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12003/// # secret,
12004/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12005/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12006/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12007/// # ),
12008/// # ).build().await.unwrap();
12009///
12010/// # let client = hyper_util::client::legacy::Client::builder(
12011/// # hyper_util::rt::TokioExecutor::new()
12012/// # )
12013/// # .build(
12014/// # hyper_rustls::HttpsConnectorBuilder::new()
12015/// # .with_native_roots()
12016/// # .unwrap()
12017/// # .https_or_http()
12018/// # .enable_http2()
12019/// # .build()
12020/// # );
12021/// # let mut hub = Storage::new(client, auth);
12022/// // As the method needs a request, you would usually fill it with the desired information
12023/// // into the respective structure. Some of the parts shown here might not be applicable !
12024/// // Values shown here are possibly random and not representative !
12025/// let mut req = RelocateBucketRequest::default();
12026///
12027/// // You can configure optional parameters by calling the respective setters at will, and
12028/// // execute the final call using `doit()`.
12029/// // Values shown here are possibly random and not representative !
12030/// let result = hub.buckets().relocate(req, "bucket")
12031/// .doit().await;
12032/// # }
12033/// ```
12034pub struct BucketRelocateCall<'a, C>
12035where
12036 C: 'a,
12037{
12038 hub: &'a Storage<C>,
12039 _request: RelocateBucketRequest,
12040 _bucket: String,
12041 _delegate: Option<&'a mut dyn common::Delegate>,
12042 _additional_params: HashMap<String, String>,
12043 _scopes: BTreeSet<String>,
12044}
12045
12046impl<'a, C> common::CallBuilder for BucketRelocateCall<'a, C> {}
12047
12048impl<'a, C> BucketRelocateCall<'a, C>
12049where
12050 C: common::Connector,
12051{
12052 /// Perform the operation you have build so far.
12053 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
12054 use std::borrow::Cow;
12055 use std::io::{Read, Seek};
12056
12057 use common::{url::Params, ToParts};
12058 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12059
12060 let mut dd = common::DefaultDelegate;
12061 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12062 dlg.begin(common::MethodInfo {
12063 id: "storage.buckets.relocate",
12064 http_method: hyper::Method::POST,
12065 });
12066
12067 for &field in ["alt", "bucket"].iter() {
12068 if self._additional_params.contains_key(field) {
12069 dlg.finished(false);
12070 return Err(common::Error::FieldClash(field));
12071 }
12072 }
12073
12074 let mut params = Params::with_capacity(4 + self._additional_params.len());
12075 params.push("bucket", self._bucket);
12076
12077 params.extend(self._additional_params.iter());
12078
12079 params.push("alt", "json");
12080 let mut url = self.hub._base_url.clone() + "b/{bucket}/relocate";
12081 if self._scopes.is_empty() {
12082 self._scopes
12083 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
12084 }
12085
12086 #[allow(clippy::single_element_loop)]
12087 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
12088 url = params.uri_replacement(url, param_name, find_this, false);
12089 }
12090 {
12091 let to_remove = ["bucket"];
12092 params.remove_params(&to_remove);
12093 }
12094
12095 let url = params.parse_with_url(&url);
12096
12097 let mut json_mime_type = mime::APPLICATION_JSON;
12098 let mut request_value_reader = {
12099 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12100 common::remove_json_null_values(&mut value);
12101 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12102 serde_json::to_writer(&mut dst, &value).unwrap();
12103 dst
12104 };
12105 let request_size = request_value_reader
12106 .seek(std::io::SeekFrom::End(0))
12107 .unwrap();
12108 request_value_reader
12109 .seek(std::io::SeekFrom::Start(0))
12110 .unwrap();
12111
12112 loop {
12113 let token = match self
12114 .hub
12115 .auth
12116 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12117 .await
12118 {
12119 Ok(token) => token,
12120 Err(e) => match dlg.token(e) {
12121 Ok(token) => token,
12122 Err(e) => {
12123 dlg.finished(false);
12124 return Err(common::Error::MissingToken(e));
12125 }
12126 },
12127 };
12128 request_value_reader
12129 .seek(std::io::SeekFrom::Start(0))
12130 .unwrap();
12131 let mut req_result = {
12132 let client = &self.hub.client;
12133 dlg.pre_request();
12134 let mut req_builder = hyper::Request::builder()
12135 .method(hyper::Method::POST)
12136 .uri(url.as_str())
12137 .header(USER_AGENT, self.hub._user_agent.clone());
12138
12139 if let Some(token) = token.as_ref() {
12140 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12141 }
12142
12143 let request = req_builder
12144 .header(CONTENT_TYPE, json_mime_type.to_string())
12145 .header(CONTENT_LENGTH, request_size as u64)
12146 .body(common::to_body(
12147 request_value_reader.get_ref().clone().into(),
12148 ));
12149
12150 client.request(request.unwrap()).await
12151 };
12152
12153 match req_result {
12154 Err(err) => {
12155 if let common::Retry::After(d) = dlg.http_error(&err) {
12156 sleep(d).await;
12157 continue;
12158 }
12159 dlg.finished(false);
12160 return Err(common::Error::HttpError(err));
12161 }
12162 Ok(res) => {
12163 let (mut parts, body) = res.into_parts();
12164 let mut body = common::Body::new(body);
12165 if !parts.status.is_success() {
12166 let bytes = common::to_bytes(body).await.unwrap_or_default();
12167 let error = serde_json::from_str(&common::to_string(&bytes));
12168 let response = common::to_response(parts, bytes.into());
12169
12170 if let common::Retry::After(d) =
12171 dlg.http_failure(&response, error.as_ref().ok())
12172 {
12173 sleep(d).await;
12174 continue;
12175 }
12176
12177 dlg.finished(false);
12178
12179 return Err(match error {
12180 Ok(value) => common::Error::BadRequest(value),
12181 _ => common::Error::Failure(response),
12182 });
12183 }
12184 let response = {
12185 let bytes = common::to_bytes(body).await.unwrap_or_default();
12186 let encoded = common::to_string(&bytes);
12187 match serde_json::from_str(&encoded) {
12188 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12189 Err(error) => {
12190 dlg.response_json_decode_error(&encoded, &error);
12191 return Err(common::Error::JsonDecodeError(
12192 encoded.to_string(),
12193 error,
12194 ));
12195 }
12196 }
12197 };
12198
12199 dlg.finished(true);
12200 return Ok(response);
12201 }
12202 }
12203 }
12204 }
12205
12206 ///
12207 /// Sets the *request* property to the given value.
12208 ///
12209 /// Even though the property as already been set when instantiating this call,
12210 /// we provide this method for API completeness.
12211 pub fn request(mut self, new_value: RelocateBucketRequest) -> BucketRelocateCall<'a, C> {
12212 self._request = new_value;
12213 self
12214 }
12215 /// Name of the bucket to be moved.
12216 ///
12217 /// Sets the *bucket* path property to the given value.
12218 ///
12219 /// Even though the property as already been set when instantiating this call,
12220 /// we provide this method for API completeness.
12221 pub fn bucket(mut self, new_value: &str) -> BucketRelocateCall<'a, C> {
12222 self._bucket = new_value.to_string();
12223 self
12224 }
12225 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12226 /// while executing the actual API request.
12227 ///
12228 /// ````text
12229 /// It should be used to handle progress information, and to implement a certain level of resilience.
12230 /// ````
12231 ///
12232 /// Sets the *delegate* property to the given value.
12233 pub fn delegate(
12234 mut self,
12235 new_value: &'a mut dyn common::Delegate,
12236 ) -> BucketRelocateCall<'a, C> {
12237 self._delegate = Some(new_value);
12238 self
12239 }
12240
12241 /// Set any additional parameter of the query string used in the request.
12242 /// It should be used to set parameters which are not yet available through their own
12243 /// setters.
12244 ///
12245 /// Please note that this method must not be used to set any of the known parameters
12246 /// which have their own setter method. If done anyway, the request will fail.
12247 ///
12248 /// # Additional Parameters
12249 ///
12250 /// * *alt* (query-string) - Data format for the response.
12251 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12252 /// * *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.
12253 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12254 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12255 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12256 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
12257 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12258 pub fn param<T>(mut self, name: T, value: T) -> BucketRelocateCall<'a, C>
12259 where
12260 T: AsRef<str>,
12261 {
12262 self._additional_params
12263 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12264 self
12265 }
12266
12267 /// Identifies the authorization scope for the method you are building.
12268 ///
12269 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12270 /// [`Scope::DevstorageReadWrite`].
12271 ///
12272 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12273 /// tokens for more than one scope.
12274 ///
12275 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12276 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12277 /// sufficient, a read-write scope will do as well.
12278 pub fn add_scope<St>(mut self, scope: St) -> BucketRelocateCall<'a, C>
12279 where
12280 St: AsRef<str>,
12281 {
12282 self._scopes.insert(String::from(scope.as_ref()));
12283 self
12284 }
12285 /// Identifies the authorization scope(s) for the method you are building.
12286 ///
12287 /// See [`Self::add_scope()`] for details.
12288 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketRelocateCall<'a, C>
12289 where
12290 I: IntoIterator<Item = St>,
12291 St: AsRef<str>,
12292 {
12293 self._scopes
12294 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12295 self
12296 }
12297
12298 /// Removes all scopes, and no default scope will be used either.
12299 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12300 /// for details).
12301 pub fn clear_scopes(mut self) -> BucketRelocateCall<'a, C> {
12302 self._scopes.clear();
12303 self
12304 }
12305}
12306
12307/// Restores a soft-deleted bucket.
12308///
12309/// A builder for the *restore* method supported by a *bucket* resource.
12310/// It is not used directly, but through a [`BucketMethods`] instance.
12311///
12312/// # Example
12313///
12314/// Instantiate a resource method builder
12315///
12316/// ```test_harness,no_run
12317/// # extern crate hyper;
12318/// # extern crate hyper_rustls;
12319/// # extern crate google_storage1 as storage1;
12320/// # async fn dox() {
12321/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12322///
12323/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12324/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12325/// # .with_native_roots()
12326/// # .unwrap()
12327/// # .https_only()
12328/// # .enable_http2()
12329/// # .build();
12330///
12331/// # let executor = hyper_util::rt::TokioExecutor::new();
12332/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12333/// # secret,
12334/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12335/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12336/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12337/// # ),
12338/// # ).build().await.unwrap();
12339///
12340/// # let client = hyper_util::client::legacy::Client::builder(
12341/// # hyper_util::rt::TokioExecutor::new()
12342/// # )
12343/// # .build(
12344/// # hyper_rustls::HttpsConnectorBuilder::new()
12345/// # .with_native_roots()
12346/// # .unwrap()
12347/// # .https_or_http()
12348/// # .enable_http2()
12349/// # .build()
12350/// # );
12351/// # let mut hub = Storage::new(client, auth);
12352/// // You can configure optional parameters by calling the respective setters at will, and
12353/// // execute the final call using `doit()`.
12354/// // Values shown here are possibly random and not representative !
12355/// let result = hub.buckets().restore("bucket", -35)
12356/// .user_project("tempor")
12357/// .projection("aliquyam")
12358/// .doit().await;
12359/// # }
12360/// ```
12361pub struct BucketRestoreCall<'a, C>
12362where
12363 C: 'a,
12364{
12365 hub: &'a Storage<C>,
12366 _bucket: String,
12367 _generation: i64,
12368 _user_project: Option<String>,
12369 _projection: Option<String>,
12370 _delegate: Option<&'a mut dyn common::Delegate>,
12371 _additional_params: HashMap<String, String>,
12372 _scopes: BTreeSet<String>,
12373}
12374
12375impl<'a, C> common::CallBuilder for BucketRestoreCall<'a, C> {}
12376
12377impl<'a, C> BucketRestoreCall<'a, C>
12378where
12379 C: common::Connector,
12380{
12381 /// Perform the operation you have build so far.
12382 pub async fn doit(mut self) -> common::Result<(common::Response, Bucket)> {
12383 use std::borrow::Cow;
12384 use std::io::{Read, Seek};
12385
12386 use common::{url::Params, ToParts};
12387 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12388
12389 let mut dd = common::DefaultDelegate;
12390 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12391 dlg.begin(common::MethodInfo {
12392 id: "storage.buckets.restore",
12393 http_method: hyper::Method::POST,
12394 });
12395
12396 for &field in ["alt", "bucket", "generation", "userProject", "projection"].iter() {
12397 if self._additional_params.contains_key(field) {
12398 dlg.finished(false);
12399 return Err(common::Error::FieldClash(field));
12400 }
12401 }
12402
12403 let mut params = Params::with_capacity(6 + self._additional_params.len());
12404 params.push("bucket", self._bucket);
12405 params.push("generation", self._generation.to_string());
12406 if let Some(value) = self._user_project.as_ref() {
12407 params.push("userProject", value);
12408 }
12409 if let Some(value) = self._projection.as_ref() {
12410 params.push("projection", value);
12411 }
12412
12413 params.extend(self._additional_params.iter());
12414
12415 params.push("alt", "json");
12416 let mut url = self.hub._base_url.clone() + "b/{bucket}/restore";
12417 if self._scopes.is_empty() {
12418 self._scopes
12419 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
12420 }
12421
12422 #[allow(clippy::single_element_loop)]
12423 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
12424 url = params.uri_replacement(url, param_name, find_this, false);
12425 }
12426 {
12427 let to_remove = ["bucket"];
12428 params.remove_params(&to_remove);
12429 }
12430
12431 let url = params.parse_with_url(&url);
12432
12433 loop {
12434 let token = match self
12435 .hub
12436 .auth
12437 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12438 .await
12439 {
12440 Ok(token) => token,
12441 Err(e) => match dlg.token(e) {
12442 Ok(token) => token,
12443 Err(e) => {
12444 dlg.finished(false);
12445 return Err(common::Error::MissingToken(e));
12446 }
12447 },
12448 };
12449 let mut req_result = {
12450 let client = &self.hub.client;
12451 dlg.pre_request();
12452 let mut req_builder = hyper::Request::builder()
12453 .method(hyper::Method::POST)
12454 .uri(url.as_str())
12455 .header(USER_AGENT, self.hub._user_agent.clone());
12456
12457 if let Some(token) = token.as_ref() {
12458 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12459 }
12460
12461 let request = req_builder
12462 .header(CONTENT_LENGTH, 0_u64)
12463 .body(common::to_body::<String>(None));
12464
12465 client.request(request.unwrap()).await
12466 };
12467
12468 match req_result {
12469 Err(err) => {
12470 if let common::Retry::After(d) = dlg.http_error(&err) {
12471 sleep(d).await;
12472 continue;
12473 }
12474 dlg.finished(false);
12475 return Err(common::Error::HttpError(err));
12476 }
12477 Ok(res) => {
12478 let (mut parts, body) = res.into_parts();
12479 let mut body = common::Body::new(body);
12480 if !parts.status.is_success() {
12481 let bytes = common::to_bytes(body).await.unwrap_or_default();
12482 let error = serde_json::from_str(&common::to_string(&bytes));
12483 let response = common::to_response(parts, bytes.into());
12484
12485 if let common::Retry::After(d) =
12486 dlg.http_failure(&response, error.as_ref().ok())
12487 {
12488 sleep(d).await;
12489 continue;
12490 }
12491
12492 dlg.finished(false);
12493
12494 return Err(match error {
12495 Ok(value) => common::Error::BadRequest(value),
12496 _ => common::Error::Failure(response),
12497 });
12498 }
12499 let response = {
12500 let bytes = common::to_bytes(body).await.unwrap_or_default();
12501 let encoded = common::to_string(&bytes);
12502 match serde_json::from_str(&encoded) {
12503 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12504 Err(error) => {
12505 dlg.response_json_decode_error(&encoded, &error);
12506 return Err(common::Error::JsonDecodeError(
12507 encoded.to_string(),
12508 error,
12509 ));
12510 }
12511 }
12512 };
12513
12514 dlg.finished(true);
12515 return Ok(response);
12516 }
12517 }
12518 }
12519 }
12520
12521 /// Name of a bucket.
12522 ///
12523 /// Sets the *bucket* path property to the given value.
12524 ///
12525 /// Even though the property as already been set when instantiating this call,
12526 /// we provide this method for API completeness.
12527 pub fn bucket(mut self, new_value: &str) -> BucketRestoreCall<'a, C> {
12528 self._bucket = new_value.to_string();
12529 self
12530 }
12531 /// Generation of a bucket.
12532 ///
12533 /// Sets the *generation* query property to the given value.
12534 ///
12535 /// Even though the property as already been set when instantiating this call,
12536 /// we provide this method for API completeness.
12537 pub fn generation(mut self, new_value: i64) -> BucketRestoreCall<'a, C> {
12538 self._generation = new_value;
12539 self
12540 }
12541 /// The project to be billed for this request. Required for Requester Pays buckets.
12542 ///
12543 /// Sets the *user project* query property to the given value.
12544 pub fn user_project(mut self, new_value: &str) -> BucketRestoreCall<'a, C> {
12545 self._user_project = Some(new_value.to_string());
12546 self
12547 }
12548 /// Set of properties to return. Defaults to full.
12549 ///
12550 /// Sets the *projection* query property to the given value.
12551 pub fn projection(mut self, new_value: &str) -> BucketRestoreCall<'a, C> {
12552 self._projection = Some(new_value.to_string());
12553 self
12554 }
12555 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12556 /// while executing the actual API request.
12557 ///
12558 /// ````text
12559 /// It should be used to handle progress information, and to implement a certain level of resilience.
12560 /// ````
12561 ///
12562 /// Sets the *delegate* property to the given value.
12563 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> BucketRestoreCall<'a, C> {
12564 self._delegate = Some(new_value);
12565 self
12566 }
12567
12568 /// Set any additional parameter of the query string used in the request.
12569 /// It should be used to set parameters which are not yet available through their own
12570 /// setters.
12571 ///
12572 /// Please note that this method must not be used to set any of the known parameters
12573 /// which have their own setter method. If done anyway, the request will fail.
12574 ///
12575 /// # Additional Parameters
12576 ///
12577 /// * *alt* (query-string) - Data format for the response.
12578 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12579 /// * *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.
12580 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12581 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12582 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12583 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
12584 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12585 pub fn param<T>(mut self, name: T, value: T) -> BucketRestoreCall<'a, C>
12586 where
12587 T: AsRef<str>,
12588 {
12589 self._additional_params
12590 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12591 self
12592 }
12593
12594 /// Identifies the authorization scope for the method you are building.
12595 ///
12596 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12597 /// [`Scope::DevstorageReadWrite`].
12598 ///
12599 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12600 /// tokens for more than one scope.
12601 ///
12602 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12603 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12604 /// sufficient, a read-write scope will do as well.
12605 pub fn add_scope<St>(mut self, scope: St) -> BucketRestoreCall<'a, C>
12606 where
12607 St: AsRef<str>,
12608 {
12609 self._scopes.insert(String::from(scope.as_ref()));
12610 self
12611 }
12612 /// Identifies the authorization scope(s) for the method you are building.
12613 ///
12614 /// See [`Self::add_scope()`] for details.
12615 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketRestoreCall<'a, C>
12616 where
12617 I: IntoIterator<Item = St>,
12618 St: AsRef<str>,
12619 {
12620 self._scopes
12621 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12622 self
12623 }
12624
12625 /// Removes all scopes, and no default scope will be used either.
12626 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12627 /// for details).
12628 pub fn clear_scopes(mut self) -> BucketRestoreCall<'a, C> {
12629 self._scopes.clear();
12630 self
12631 }
12632}
12633
12634/// Updates an IAM policy for the specified bucket.
12635///
12636/// A builder for the *setIamPolicy* method supported by a *bucket* resource.
12637/// It is not used directly, but through a [`BucketMethods`] instance.
12638///
12639/// # Example
12640///
12641/// Instantiate a resource method builder
12642///
12643/// ```test_harness,no_run
12644/// # extern crate hyper;
12645/// # extern crate hyper_rustls;
12646/// # extern crate google_storage1 as storage1;
12647/// use storage1::api::Policy;
12648/// # async fn dox() {
12649/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12650///
12651/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12652/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12653/// # .with_native_roots()
12654/// # .unwrap()
12655/// # .https_only()
12656/// # .enable_http2()
12657/// # .build();
12658///
12659/// # let executor = hyper_util::rt::TokioExecutor::new();
12660/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12661/// # secret,
12662/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12663/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12664/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12665/// # ),
12666/// # ).build().await.unwrap();
12667///
12668/// # let client = hyper_util::client::legacy::Client::builder(
12669/// # hyper_util::rt::TokioExecutor::new()
12670/// # )
12671/// # .build(
12672/// # hyper_rustls::HttpsConnectorBuilder::new()
12673/// # .with_native_roots()
12674/// # .unwrap()
12675/// # .https_or_http()
12676/// # .enable_http2()
12677/// # .build()
12678/// # );
12679/// # let mut hub = Storage::new(client, auth);
12680/// // As the method needs a request, you would usually fill it with the desired information
12681/// // into the respective structure. Some of the parts shown here might not be applicable !
12682/// // Values shown here are possibly random and not representative !
12683/// let mut req = Policy::default();
12684///
12685/// // You can configure optional parameters by calling the respective setters at will, and
12686/// // execute the final call using `doit()`.
12687/// // Values shown here are possibly random and not representative !
12688/// let result = hub.buckets().set_iam_policy(req, "bucket")
12689/// .user_project("et")
12690/// .doit().await;
12691/// # }
12692/// ```
12693pub struct BucketSetIamPolicyCall<'a, C>
12694where
12695 C: 'a,
12696{
12697 hub: &'a Storage<C>,
12698 _request: Policy,
12699 _bucket: String,
12700 _user_project: Option<String>,
12701 _delegate: Option<&'a mut dyn common::Delegate>,
12702 _additional_params: HashMap<String, String>,
12703 _scopes: BTreeSet<String>,
12704}
12705
12706impl<'a, C> common::CallBuilder for BucketSetIamPolicyCall<'a, C> {}
12707
12708impl<'a, C> BucketSetIamPolicyCall<'a, C>
12709where
12710 C: common::Connector,
12711{
12712 /// Perform the operation you have build so far.
12713 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
12714 use std::borrow::Cow;
12715 use std::io::{Read, Seek};
12716
12717 use common::{url::Params, ToParts};
12718 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12719
12720 let mut dd = common::DefaultDelegate;
12721 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12722 dlg.begin(common::MethodInfo {
12723 id: "storage.buckets.setIamPolicy",
12724 http_method: hyper::Method::PUT,
12725 });
12726
12727 for &field in ["alt", "bucket", "userProject"].iter() {
12728 if self._additional_params.contains_key(field) {
12729 dlg.finished(false);
12730 return Err(common::Error::FieldClash(field));
12731 }
12732 }
12733
12734 let mut params = Params::with_capacity(5 + self._additional_params.len());
12735 params.push("bucket", self._bucket);
12736 if let Some(value) = self._user_project.as_ref() {
12737 params.push("userProject", value);
12738 }
12739
12740 params.extend(self._additional_params.iter());
12741
12742 params.push("alt", "json");
12743 let mut url = self.hub._base_url.clone() + "b/{bucket}/iam";
12744 if self._scopes.is_empty() {
12745 self._scopes
12746 .insert(Scope::DevstorageFullControl.as_ref().to_string());
12747 }
12748
12749 #[allow(clippy::single_element_loop)]
12750 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
12751 url = params.uri_replacement(url, param_name, find_this, false);
12752 }
12753 {
12754 let to_remove = ["bucket"];
12755 params.remove_params(&to_remove);
12756 }
12757
12758 let url = params.parse_with_url(&url);
12759
12760 let mut json_mime_type = mime::APPLICATION_JSON;
12761 let mut request_value_reader = {
12762 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12763 common::remove_json_null_values(&mut value);
12764 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12765 serde_json::to_writer(&mut dst, &value).unwrap();
12766 dst
12767 };
12768 let request_size = request_value_reader
12769 .seek(std::io::SeekFrom::End(0))
12770 .unwrap();
12771 request_value_reader
12772 .seek(std::io::SeekFrom::Start(0))
12773 .unwrap();
12774
12775 loop {
12776 let token = match self
12777 .hub
12778 .auth
12779 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12780 .await
12781 {
12782 Ok(token) => token,
12783 Err(e) => match dlg.token(e) {
12784 Ok(token) => token,
12785 Err(e) => {
12786 dlg.finished(false);
12787 return Err(common::Error::MissingToken(e));
12788 }
12789 },
12790 };
12791 request_value_reader
12792 .seek(std::io::SeekFrom::Start(0))
12793 .unwrap();
12794 let mut req_result = {
12795 let client = &self.hub.client;
12796 dlg.pre_request();
12797 let mut req_builder = hyper::Request::builder()
12798 .method(hyper::Method::PUT)
12799 .uri(url.as_str())
12800 .header(USER_AGENT, self.hub._user_agent.clone());
12801
12802 if let Some(token) = token.as_ref() {
12803 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12804 }
12805
12806 let request = req_builder
12807 .header(CONTENT_TYPE, json_mime_type.to_string())
12808 .header(CONTENT_LENGTH, request_size as u64)
12809 .body(common::to_body(
12810 request_value_reader.get_ref().clone().into(),
12811 ));
12812
12813 client.request(request.unwrap()).await
12814 };
12815
12816 match req_result {
12817 Err(err) => {
12818 if let common::Retry::After(d) = dlg.http_error(&err) {
12819 sleep(d).await;
12820 continue;
12821 }
12822 dlg.finished(false);
12823 return Err(common::Error::HttpError(err));
12824 }
12825 Ok(res) => {
12826 let (mut parts, body) = res.into_parts();
12827 let mut body = common::Body::new(body);
12828 if !parts.status.is_success() {
12829 let bytes = common::to_bytes(body).await.unwrap_or_default();
12830 let error = serde_json::from_str(&common::to_string(&bytes));
12831 let response = common::to_response(parts, bytes.into());
12832
12833 if let common::Retry::After(d) =
12834 dlg.http_failure(&response, error.as_ref().ok())
12835 {
12836 sleep(d).await;
12837 continue;
12838 }
12839
12840 dlg.finished(false);
12841
12842 return Err(match error {
12843 Ok(value) => common::Error::BadRequest(value),
12844 _ => common::Error::Failure(response),
12845 });
12846 }
12847 let response = {
12848 let bytes = common::to_bytes(body).await.unwrap_or_default();
12849 let encoded = common::to_string(&bytes);
12850 match serde_json::from_str(&encoded) {
12851 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12852 Err(error) => {
12853 dlg.response_json_decode_error(&encoded, &error);
12854 return Err(common::Error::JsonDecodeError(
12855 encoded.to_string(),
12856 error,
12857 ));
12858 }
12859 }
12860 };
12861
12862 dlg.finished(true);
12863 return Ok(response);
12864 }
12865 }
12866 }
12867 }
12868
12869 ///
12870 /// Sets the *request* property to the given value.
12871 ///
12872 /// Even though the property as already been set when instantiating this call,
12873 /// we provide this method for API completeness.
12874 pub fn request(mut self, new_value: Policy) -> BucketSetIamPolicyCall<'a, C> {
12875 self._request = new_value;
12876 self
12877 }
12878 /// Name of a bucket.
12879 ///
12880 /// Sets the *bucket* path property to the given value.
12881 ///
12882 /// Even though the property as already been set when instantiating this call,
12883 /// we provide this method for API completeness.
12884 pub fn bucket(mut self, new_value: &str) -> BucketSetIamPolicyCall<'a, C> {
12885 self._bucket = new_value.to_string();
12886 self
12887 }
12888 /// The project to be billed for this request. Required for Requester Pays buckets.
12889 ///
12890 /// Sets the *user project* query property to the given value.
12891 pub fn user_project(mut self, new_value: &str) -> BucketSetIamPolicyCall<'a, C> {
12892 self._user_project = Some(new_value.to_string());
12893 self
12894 }
12895 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12896 /// while executing the actual API request.
12897 ///
12898 /// ````text
12899 /// It should be used to handle progress information, and to implement a certain level of resilience.
12900 /// ````
12901 ///
12902 /// Sets the *delegate* property to the given value.
12903 pub fn delegate(
12904 mut self,
12905 new_value: &'a mut dyn common::Delegate,
12906 ) -> BucketSetIamPolicyCall<'a, C> {
12907 self._delegate = Some(new_value);
12908 self
12909 }
12910
12911 /// Set any additional parameter of the query string used in the request.
12912 /// It should be used to set parameters which are not yet available through their own
12913 /// setters.
12914 ///
12915 /// Please note that this method must not be used to set any of the known parameters
12916 /// which have their own setter method. If done anyway, the request will fail.
12917 ///
12918 /// # Additional Parameters
12919 ///
12920 /// * *alt* (query-string) - Data format for the response.
12921 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12922 /// * *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.
12923 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12924 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12925 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12926 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
12927 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12928 pub fn param<T>(mut self, name: T, value: T) -> BucketSetIamPolicyCall<'a, C>
12929 where
12930 T: AsRef<str>,
12931 {
12932 self._additional_params
12933 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12934 self
12935 }
12936
12937 /// Identifies the authorization scope for the method you are building.
12938 ///
12939 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12940 /// [`Scope::DevstorageFullControl`].
12941 ///
12942 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12943 /// tokens for more than one scope.
12944 ///
12945 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12946 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12947 /// sufficient, a read-write scope will do as well.
12948 pub fn add_scope<St>(mut self, scope: St) -> BucketSetIamPolicyCall<'a, C>
12949 where
12950 St: AsRef<str>,
12951 {
12952 self._scopes.insert(String::from(scope.as_ref()));
12953 self
12954 }
12955 /// Identifies the authorization scope(s) for the method you are building.
12956 ///
12957 /// See [`Self::add_scope()`] for details.
12958 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketSetIamPolicyCall<'a, C>
12959 where
12960 I: IntoIterator<Item = St>,
12961 St: AsRef<str>,
12962 {
12963 self._scopes
12964 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12965 self
12966 }
12967
12968 /// Removes all scopes, and no default scope will be used either.
12969 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12970 /// for details).
12971 pub fn clear_scopes(mut self) -> BucketSetIamPolicyCall<'a, C> {
12972 self._scopes.clear();
12973 self
12974 }
12975}
12976
12977/// Tests a set of permissions on the given bucket to see which, if any, are held by the caller.
12978///
12979/// A builder for the *testIamPermissions* method supported by a *bucket* resource.
12980/// It is not used directly, but through a [`BucketMethods`] instance.
12981///
12982/// # Example
12983///
12984/// Instantiate a resource method builder
12985///
12986/// ```test_harness,no_run
12987/// # extern crate hyper;
12988/// # extern crate hyper_rustls;
12989/// # extern crate google_storage1 as storage1;
12990/// # async fn dox() {
12991/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12992///
12993/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12994/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12995/// # .with_native_roots()
12996/// # .unwrap()
12997/// # .https_only()
12998/// # .enable_http2()
12999/// # .build();
13000///
13001/// # let executor = hyper_util::rt::TokioExecutor::new();
13002/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13003/// # secret,
13004/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13005/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13006/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13007/// # ),
13008/// # ).build().await.unwrap();
13009///
13010/// # let client = hyper_util::client::legacy::Client::builder(
13011/// # hyper_util::rt::TokioExecutor::new()
13012/// # )
13013/// # .build(
13014/// # hyper_rustls::HttpsConnectorBuilder::new()
13015/// # .with_native_roots()
13016/// # .unwrap()
13017/// # .https_or_http()
13018/// # .enable_http2()
13019/// # .build()
13020/// # );
13021/// # let mut hub = Storage::new(client, auth);
13022/// // You can configure optional parameters by calling the respective setters at will, and
13023/// // execute the final call using `doit()`.
13024/// // Values shown here are possibly random and not representative !
13025/// let result = hub.buckets().test_iam_permissions("bucket", &vec!["Lorem".into()])
13026/// .user_project("est")
13027/// .doit().await;
13028/// # }
13029/// ```
13030pub struct BucketTestIamPermissionCall<'a, C>
13031where
13032 C: 'a,
13033{
13034 hub: &'a Storage<C>,
13035 _bucket: String,
13036 _permissions: Vec<String>,
13037 _user_project: Option<String>,
13038 _delegate: Option<&'a mut dyn common::Delegate>,
13039 _additional_params: HashMap<String, String>,
13040 _scopes: BTreeSet<String>,
13041}
13042
13043impl<'a, C> common::CallBuilder for BucketTestIamPermissionCall<'a, C> {}
13044
13045impl<'a, C> BucketTestIamPermissionCall<'a, C>
13046where
13047 C: common::Connector,
13048{
13049 /// Perform the operation you have build so far.
13050 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
13051 use std::borrow::Cow;
13052 use std::io::{Read, Seek};
13053
13054 use common::{url::Params, ToParts};
13055 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13056
13057 let mut dd = common::DefaultDelegate;
13058 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13059 dlg.begin(common::MethodInfo {
13060 id: "storage.buckets.testIamPermissions",
13061 http_method: hyper::Method::GET,
13062 });
13063
13064 for &field in ["alt", "bucket", "permissions", "userProject"].iter() {
13065 if self._additional_params.contains_key(field) {
13066 dlg.finished(false);
13067 return Err(common::Error::FieldClash(field));
13068 }
13069 }
13070
13071 let mut params = Params::with_capacity(5 + self._additional_params.len());
13072 params.push("bucket", self._bucket);
13073 if !self._permissions.is_empty() {
13074 for f in self._permissions.iter() {
13075 params.push("permissions", f);
13076 }
13077 }
13078 if let Some(value) = self._user_project.as_ref() {
13079 params.push("userProject", value);
13080 }
13081
13082 params.extend(self._additional_params.iter());
13083
13084 params.push("alt", "json");
13085 let mut url = self.hub._base_url.clone() + "b/{bucket}/iam/testPermissions";
13086 if self._scopes.is_empty() {
13087 self._scopes
13088 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
13089 }
13090
13091 #[allow(clippy::single_element_loop)]
13092 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
13093 url = params.uri_replacement(url, param_name, find_this, false);
13094 }
13095 {
13096 let to_remove = ["bucket"];
13097 params.remove_params(&to_remove);
13098 }
13099
13100 let url = params.parse_with_url(&url);
13101
13102 loop {
13103 let token = match self
13104 .hub
13105 .auth
13106 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13107 .await
13108 {
13109 Ok(token) => token,
13110 Err(e) => match dlg.token(e) {
13111 Ok(token) => token,
13112 Err(e) => {
13113 dlg.finished(false);
13114 return Err(common::Error::MissingToken(e));
13115 }
13116 },
13117 };
13118 let mut req_result = {
13119 let client = &self.hub.client;
13120 dlg.pre_request();
13121 let mut req_builder = hyper::Request::builder()
13122 .method(hyper::Method::GET)
13123 .uri(url.as_str())
13124 .header(USER_AGENT, self.hub._user_agent.clone());
13125
13126 if let Some(token) = token.as_ref() {
13127 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13128 }
13129
13130 let request = req_builder
13131 .header(CONTENT_LENGTH, 0_u64)
13132 .body(common::to_body::<String>(None));
13133
13134 client.request(request.unwrap()).await
13135 };
13136
13137 match req_result {
13138 Err(err) => {
13139 if let common::Retry::After(d) = dlg.http_error(&err) {
13140 sleep(d).await;
13141 continue;
13142 }
13143 dlg.finished(false);
13144 return Err(common::Error::HttpError(err));
13145 }
13146 Ok(res) => {
13147 let (mut parts, body) = res.into_parts();
13148 let mut body = common::Body::new(body);
13149 if !parts.status.is_success() {
13150 let bytes = common::to_bytes(body).await.unwrap_or_default();
13151 let error = serde_json::from_str(&common::to_string(&bytes));
13152 let response = common::to_response(parts, bytes.into());
13153
13154 if let common::Retry::After(d) =
13155 dlg.http_failure(&response, error.as_ref().ok())
13156 {
13157 sleep(d).await;
13158 continue;
13159 }
13160
13161 dlg.finished(false);
13162
13163 return Err(match error {
13164 Ok(value) => common::Error::BadRequest(value),
13165 _ => common::Error::Failure(response),
13166 });
13167 }
13168 let response = {
13169 let bytes = common::to_bytes(body).await.unwrap_or_default();
13170 let encoded = common::to_string(&bytes);
13171 match serde_json::from_str(&encoded) {
13172 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13173 Err(error) => {
13174 dlg.response_json_decode_error(&encoded, &error);
13175 return Err(common::Error::JsonDecodeError(
13176 encoded.to_string(),
13177 error,
13178 ));
13179 }
13180 }
13181 };
13182
13183 dlg.finished(true);
13184 return Ok(response);
13185 }
13186 }
13187 }
13188 }
13189
13190 /// Name of a bucket.
13191 ///
13192 /// Sets the *bucket* path property to the given value.
13193 ///
13194 /// Even though the property as already been set when instantiating this call,
13195 /// we provide this method for API completeness.
13196 pub fn bucket(mut self, new_value: &str) -> BucketTestIamPermissionCall<'a, C> {
13197 self._bucket = new_value.to_string();
13198 self
13199 }
13200 /// Permissions to test.
13201 ///
13202 /// Append the given value to the *permissions* query property.
13203 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
13204 ///
13205 /// Even though the property as already been set when instantiating this call,
13206 /// we provide this method for API completeness.
13207 pub fn add_permissions(mut self, new_value: &str) -> BucketTestIamPermissionCall<'a, C> {
13208 self._permissions.push(new_value.to_string());
13209 self
13210 }
13211 /// The project to be billed for this request. Required for Requester Pays buckets.
13212 ///
13213 /// Sets the *user project* query property to the given value.
13214 pub fn user_project(mut self, new_value: &str) -> BucketTestIamPermissionCall<'a, C> {
13215 self._user_project = Some(new_value.to_string());
13216 self
13217 }
13218 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13219 /// while executing the actual API request.
13220 ///
13221 /// ````text
13222 /// It should be used to handle progress information, and to implement a certain level of resilience.
13223 /// ````
13224 ///
13225 /// Sets the *delegate* property to the given value.
13226 pub fn delegate(
13227 mut self,
13228 new_value: &'a mut dyn common::Delegate,
13229 ) -> BucketTestIamPermissionCall<'a, C> {
13230 self._delegate = Some(new_value);
13231 self
13232 }
13233
13234 /// Set any additional parameter of the query string used in the request.
13235 /// It should be used to set parameters which are not yet available through their own
13236 /// setters.
13237 ///
13238 /// Please note that this method must not be used to set any of the known parameters
13239 /// which have their own setter method. If done anyway, the request will fail.
13240 ///
13241 /// # Additional Parameters
13242 ///
13243 /// * *alt* (query-string) - Data format for the response.
13244 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13245 /// * *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.
13246 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13247 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13248 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13249 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
13250 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13251 pub fn param<T>(mut self, name: T, value: T) -> BucketTestIamPermissionCall<'a, C>
13252 where
13253 T: AsRef<str>,
13254 {
13255 self._additional_params
13256 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13257 self
13258 }
13259
13260 /// Identifies the authorization scope for the method you are building.
13261 ///
13262 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13263 /// [`Scope::DevstorageReadOnly`].
13264 ///
13265 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13266 /// tokens for more than one scope.
13267 ///
13268 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13269 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13270 /// sufficient, a read-write scope will do as well.
13271 pub fn add_scope<St>(mut self, scope: St) -> BucketTestIamPermissionCall<'a, C>
13272 where
13273 St: AsRef<str>,
13274 {
13275 self._scopes.insert(String::from(scope.as_ref()));
13276 self
13277 }
13278 /// Identifies the authorization scope(s) for the method you are building.
13279 ///
13280 /// See [`Self::add_scope()`] for details.
13281 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketTestIamPermissionCall<'a, C>
13282 where
13283 I: IntoIterator<Item = St>,
13284 St: AsRef<str>,
13285 {
13286 self._scopes
13287 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13288 self
13289 }
13290
13291 /// Removes all scopes, and no default scope will be used either.
13292 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13293 /// for details).
13294 pub fn clear_scopes(mut self) -> BucketTestIamPermissionCall<'a, C> {
13295 self._scopes.clear();
13296 self
13297 }
13298}
13299
13300/// Updates a bucket. Changes to the bucket will be readable immediately after writing, but configuration changes may take time to propagate.
13301///
13302/// A builder for the *update* method supported by a *bucket* resource.
13303/// It is not used directly, but through a [`BucketMethods`] instance.
13304///
13305/// # Example
13306///
13307/// Instantiate a resource method builder
13308///
13309/// ```test_harness,no_run
13310/// # extern crate hyper;
13311/// # extern crate hyper_rustls;
13312/// # extern crate google_storage1 as storage1;
13313/// use storage1::api::Bucket;
13314/// # async fn dox() {
13315/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13316///
13317/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13318/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13319/// # .with_native_roots()
13320/// # .unwrap()
13321/// # .https_only()
13322/// # .enable_http2()
13323/// # .build();
13324///
13325/// # let executor = hyper_util::rt::TokioExecutor::new();
13326/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13327/// # secret,
13328/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13329/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13330/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13331/// # ),
13332/// # ).build().await.unwrap();
13333///
13334/// # let client = hyper_util::client::legacy::Client::builder(
13335/// # hyper_util::rt::TokioExecutor::new()
13336/// # )
13337/// # .build(
13338/// # hyper_rustls::HttpsConnectorBuilder::new()
13339/// # .with_native_roots()
13340/// # .unwrap()
13341/// # .https_or_http()
13342/// # .enable_http2()
13343/// # .build()
13344/// # );
13345/// # let mut hub = Storage::new(client, auth);
13346/// // As the method needs a request, you would usually fill it with the desired information
13347/// // into the respective structure. Some of the parts shown here might not be applicable !
13348/// // Values shown here are possibly random and not representative !
13349/// let mut req = Bucket::default();
13350///
13351/// // You can configure optional parameters by calling the respective setters at will, and
13352/// // execute the final call using `doit()`.
13353/// // Values shown here are possibly random and not representative !
13354/// let result = hub.buckets().update(req, "bucket")
13355/// .user_project("diam")
13356/// .projection("dolores")
13357/// .predefined_default_object_acl("dolores")
13358/// .predefined_acl("et")
13359/// .if_metageneration_not_match(-93)
13360/// .if_metageneration_match(-11)
13361/// .doit().await;
13362/// # }
13363/// ```
13364pub struct BucketUpdateCall<'a, C>
13365where
13366 C: 'a,
13367{
13368 hub: &'a Storage<C>,
13369 _request: Bucket,
13370 _bucket: String,
13371 _user_project: Option<String>,
13372 _projection: Option<String>,
13373 _predefined_default_object_acl: Option<String>,
13374 _predefined_acl: Option<String>,
13375 _if_metageneration_not_match: Option<i64>,
13376 _if_metageneration_match: Option<i64>,
13377 _delegate: Option<&'a mut dyn common::Delegate>,
13378 _additional_params: HashMap<String, String>,
13379 _scopes: BTreeSet<String>,
13380}
13381
13382impl<'a, C> common::CallBuilder for BucketUpdateCall<'a, C> {}
13383
13384impl<'a, C> BucketUpdateCall<'a, C>
13385where
13386 C: common::Connector,
13387{
13388 /// Perform the operation you have build so far.
13389 pub async fn doit(mut self) -> common::Result<(common::Response, Bucket)> {
13390 use std::borrow::Cow;
13391 use std::io::{Read, Seek};
13392
13393 use common::{url::Params, ToParts};
13394 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13395
13396 let mut dd = common::DefaultDelegate;
13397 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13398 dlg.begin(common::MethodInfo {
13399 id: "storage.buckets.update",
13400 http_method: hyper::Method::PUT,
13401 });
13402
13403 for &field in [
13404 "alt",
13405 "bucket",
13406 "userProject",
13407 "projection",
13408 "predefinedDefaultObjectAcl",
13409 "predefinedAcl",
13410 "ifMetagenerationNotMatch",
13411 "ifMetagenerationMatch",
13412 ]
13413 .iter()
13414 {
13415 if self._additional_params.contains_key(field) {
13416 dlg.finished(false);
13417 return Err(common::Error::FieldClash(field));
13418 }
13419 }
13420
13421 let mut params = Params::with_capacity(10 + self._additional_params.len());
13422 params.push("bucket", self._bucket);
13423 if let Some(value) = self._user_project.as_ref() {
13424 params.push("userProject", value);
13425 }
13426 if let Some(value) = self._projection.as_ref() {
13427 params.push("projection", value);
13428 }
13429 if let Some(value) = self._predefined_default_object_acl.as_ref() {
13430 params.push("predefinedDefaultObjectAcl", value);
13431 }
13432 if let Some(value) = self._predefined_acl.as_ref() {
13433 params.push("predefinedAcl", value);
13434 }
13435 if let Some(value) = self._if_metageneration_not_match.as_ref() {
13436 params.push("ifMetagenerationNotMatch", value.to_string());
13437 }
13438 if let Some(value) = self._if_metageneration_match.as_ref() {
13439 params.push("ifMetagenerationMatch", value.to_string());
13440 }
13441
13442 params.extend(self._additional_params.iter());
13443
13444 params.push("alt", "json");
13445 let mut url = self.hub._base_url.clone() + "b/{bucket}";
13446 if self._scopes.is_empty() {
13447 self._scopes
13448 .insert(Scope::DevstorageFullControl.as_ref().to_string());
13449 }
13450
13451 #[allow(clippy::single_element_loop)]
13452 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
13453 url = params.uri_replacement(url, param_name, find_this, false);
13454 }
13455 {
13456 let to_remove = ["bucket"];
13457 params.remove_params(&to_remove);
13458 }
13459
13460 let url = params.parse_with_url(&url);
13461
13462 let mut json_mime_type = mime::APPLICATION_JSON;
13463 let mut request_value_reader = {
13464 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13465 common::remove_json_null_values(&mut value);
13466 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13467 serde_json::to_writer(&mut dst, &value).unwrap();
13468 dst
13469 };
13470 let request_size = request_value_reader
13471 .seek(std::io::SeekFrom::End(0))
13472 .unwrap();
13473 request_value_reader
13474 .seek(std::io::SeekFrom::Start(0))
13475 .unwrap();
13476
13477 loop {
13478 let token = match self
13479 .hub
13480 .auth
13481 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13482 .await
13483 {
13484 Ok(token) => token,
13485 Err(e) => match dlg.token(e) {
13486 Ok(token) => token,
13487 Err(e) => {
13488 dlg.finished(false);
13489 return Err(common::Error::MissingToken(e));
13490 }
13491 },
13492 };
13493 request_value_reader
13494 .seek(std::io::SeekFrom::Start(0))
13495 .unwrap();
13496 let mut req_result = {
13497 let client = &self.hub.client;
13498 dlg.pre_request();
13499 let mut req_builder = hyper::Request::builder()
13500 .method(hyper::Method::PUT)
13501 .uri(url.as_str())
13502 .header(USER_AGENT, self.hub._user_agent.clone());
13503
13504 if let Some(token) = token.as_ref() {
13505 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13506 }
13507
13508 let request = req_builder
13509 .header(CONTENT_TYPE, json_mime_type.to_string())
13510 .header(CONTENT_LENGTH, request_size as u64)
13511 .body(common::to_body(
13512 request_value_reader.get_ref().clone().into(),
13513 ));
13514
13515 client.request(request.unwrap()).await
13516 };
13517
13518 match req_result {
13519 Err(err) => {
13520 if let common::Retry::After(d) = dlg.http_error(&err) {
13521 sleep(d).await;
13522 continue;
13523 }
13524 dlg.finished(false);
13525 return Err(common::Error::HttpError(err));
13526 }
13527 Ok(res) => {
13528 let (mut parts, body) = res.into_parts();
13529 let mut body = common::Body::new(body);
13530 if !parts.status.is_success() {
13531 let bytes = common::to_bytes(body).await.unwrap_or_default();
13532 let error = serde_json::from_str(&common::to_string(&bytes));
13533 let response = common::to_response(parts, bytes.into());
13534
13535 if let common::Retry::After(d) =
13536 dlg.http_failure(&response, error.as_ref().ok())
13537 {
13538 sleep(d).await;
13539 continue;
13540 }
13541
13542 dlg.finished(false);
13543
13544 return Err(match error {
13545 Ok(value) => common::Error::BadRequest(value),
13546 _ => common::Error::Failure(response),
13547 });
13548 }
13549 let response = {
13550 let bytes = common::to_bytes(body).await.unwrap_or_default();
13551 let encoded = common::to_string(&bytes);
13552 match serde_json::from_str(&encoded) {
13553 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13554 Err(error) => {
13555 dlg.response_json_decode_error(&encoded, &error);
13556 return Err(common::Error::JsonDecodeError(
13557 encoded.to_string(),
13558 error,
13559 ));
13560 }
13561 }
13562 };
13563
13564 dlg.finished(true);
13565 return Ok(response);
13566 }
13567 }
13568 }
13569 }
13570
13571 ///
13572 /// Sets the *request* property to the given value.
13573 ///
13574 /// Even though the property as already been set when instantiating this call,
13575 /// we provide this method for API completeness.
13576 pub fn request(mut self, new_value: Bucket) -> BucketUpdateCall<'a, C> {
13577 self._request = new_value;
13578 self
13579 }
13580 /// Name of a bucket.
13581 ///
13582 /// Sets the *bucket* path property to the given value.
13583 ///
13584 /// Even though the property as already been set when instantiating this call,
13585 /// we provide this method for API completeness.
13586 pub fn bucket(mut self, new_value: &str) -> BucketUpdateCall<'a, C> {
13587 self._bucket = new_value.to_string();
13588 self
13589 }
13590 /// The project to be billed for this request. Required for Requester Pays buckets.
13591 ///
13592 /// Sets the *user project* query property to the given value.
13593 pub fn user_project(mut self, new_value: &str) -> BucketUpdateCall<'a, C> {
13594 self._user_project = Some(new_value.to_string());
13595 self
13596 }
13597 /// Set of properties to return. Defaults to full.
13598 ///
13599 /// Sets the *projection* query property to the given value.
13600 pub fn projection(mut self, new_value: &str) -> BucketUpdateCall<'a, C> {
13601 self._projection = Some(new_value.to_string());
13602 self
13603 }
13604 /// Apply a predefined set of default object access controls to this bucket.
13605 ///
13606 /// Sets the *predefined default object acl* query property to the given value.
13607 pub fn predefined_default_object_acl(mut self, new_value: &str) -> BucketUpdateCall<'a, C> {
13608 self._predefined_default_object_acl = Some(new_value.to_string());
13609 self
13610 }
13611 /// Apply a predefined set of access controls to this bucket.
13612 ///
13613 /// Sets the *predefined acl* query property to the given value.
13614 pub fn predefined_acl(mut self, new_value: &str) -> BucketUpdateCall<'a, C> {
13615 self._predefined_acl = Some(new_value.to_string());
13616 self
13617 }
13618 /// Makes the return of the bucket metadata conditional on whether the bucket's current metageneration does not match the given value.
13619 ///
13620 /// Sets the *if metageneration not match* query property to the given value.
13621 pub fn if_metageneration_not_match(mut self, new_value: i64) -> BucketUpdateCall<'a, C> {
13622 self._if_metageneration_not_match = Some(new_value);
13623 self
13624 }
13625 /// Makes the return of the bucket metadata conditional on whether the bucket's current metageneration matches the given value.
13626 ///
13627 /// Sets the *if metageneration match* query property to the given value.
13628 pub fn if_metageneration_match(mut self, new_value: i64) -> BucketUpdateCall<'a, C> {
13629 self._if_metageneration_match = Some(new_value);
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(mut self, new_value: &'a mut dyn common::Delegate) -> BucketUpdateCall<'a, C> {
13641 self._delegate = Some(new_value);
13642 self
13643 }
13644
13645 /// Set any additional parameter of the query string used in the request.
13646 /// It should be used to set parameters which are not yet available through their own
13647 /// setters.
13648 ///
13649 /// Please note that this method must not be used to set any of the known parameters
13650 /// which have their own setter method. If done anyway, the request will fail.
13651 ///
13652 /// # Additional Parameters
13653 ///
13654 /// * *alt* (query-string) - Data format for the response.
13655 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13656 /// * *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.
13657 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13658 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13659 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13660 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
13661 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13662 pub fn param<T>(mut self, name: T, value: T) -> BucketUpdateCall<'a, C>
13663 where
13664 T: AsRef<str>,
13665 {
13666 self._additional_params
13667 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13668 self
13669 }
13670
13671 /// Identifies the authorization scope for the method you are building.
13672 ///
13673 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13674 /// [`Scope::DevstorageFullControl`].
13675 ///
13676 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13677 /// tokens for more than one scope.
13678 ///
13679 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13680 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13681 /// sufficient, a read-write scope will do as well.
13682 pub fn add_scope<St>(mut self, scope: St) -> BucketUpdateCall<'a, C>
13683 where
13684 St: AsRef<str>,
13685 {
13686 self._scopes.insert(String::from(scope.as_ref()));
13687 self
13688 }
13689 /// Identifies the authorization scope(s) for the method you are building.
13690 ///
13691 /// See [`Self::add_scope()`] for details.
13692 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketUpdateCall<'a, C>
13693 where
13694 I: IntoIterator<Item = St>,
13695 St: AsRef<str>,
13696 {
13697 self._scopes
13698 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13699 self
13700 }
13701
13702 /// Removes all scopes, and no default scope will be used either.
13703 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13704 /// for details).
13705 pub fn clear_scopes(mut self) -> BucketUpdateCall<'a, C> {
13706 self._scopes.clear();
13707 self
13708 }
13709}
13710
13711/// Starts asynchronous advancement of the relocate bucket operation in the case of required write downtime, to allow it to lock the bucket at the source location, and proceed with the bucket location swap. The server makes a best effort to advance the relocate bucket operation, but success is not guaranteed.
13712///
13713/// A builder for the *operations.advanceRelocateBucket* method supported by a *bucket* resource.
13714/// It is not used directly, but through a [`BucketMethods`] instance.
13715///
13716/// # Example
13717///
13718/// Instantiate a resource method builder
13719///
13720/// ```test_harness,no_run
13721/// # extern crate hyper;
13722/// # extern crate hyper_rustls;
13723/// # extern crate google_storage1 as storage1;
13724/// use storage1::api::AdvanceRelocateBucketOperationRequest;
13725/// # async fn dox() {
13726/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13727///
13728/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13729/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13730/// # .with_native_roots()
13731/// # .unwrap()
13732/// # .https_only()
13733/// # .enable_http2()
13734/// # .build();
13735///
13736/// # let executor = hyper_util::rt::TokioExecutor::new();
13737/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13738/// # secret,
13739/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13740/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13741/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13742/// # ),
13743/// # ).build().await.unwrap();
13744///
13745/// # let client = hyper_util::client::legacy::Client::builder(
13746/// # hyper_util::rt::TokioExecutor::new()
13747/// # )
13748/// # .build(
13749/// # hyper_rustls::HttpsConnectorBuilder::new()
13750/// # .with_native_roots()
13751/// # .unwrap()
13752/// # .https_or_http()
13753/// # .enable_http2()
13754/// # .build()
13755/// # );
13756/// # let mut hub = Storage::new(client, auth);
13757/// // As the method needs a request, you would usually fill it with the desired information
13758/// // into the respective structure. Some of the parts shown here might not be applicable !
13759/// // Values shown here are possibly random and not representative !
13760/// let mut req = AdvanceRelocateBucketOperationRequest::default();
13761///
13762/// // You can configure optional parameters by calling the respective setters at will, and
13763/// // execute the final call using `doit()`.
13764/// // Values shown here are possibly random and not representative !
13765/// let result = hub.buckets().operations_advance_relocate_bucket(req, "bucket", "operationId")
13766/// .doit().await;
13767/// # }
13768/// ```
13769pub struct BucketOperationAdvanceRelocateBucketCall<'a, C>
13770where
13771 C: 'a,
13772{
13773 hub: &'a Storage<C>,
13774 _request: AdvanceRelocateBucketOperationRequest,
13775 _bucket: String,
13776 _operation_id: String,
13777 _delegate: Option<&'a mut dyn common::Delegate>,
13778 _additional_params: HashMap<String, String>,
13779 _scopes: BTreeSet<String>,
13780}
13781
13782impl<'a, C> common::CallBuilder for BucketOperationAdvanceRelocateBucketCall<'a, C> {}
13783
13784impl<'a, C> BucketOperationAdvanceRelocateBucketCall<'a, C>
13785where
13786 C: common::Connector,
13787{
13788 /// Perform the operation you have build so far.
13789 pub async fn doit(mut self) -> common::Result<common::Response> {
13790 use std::borrow::Cow;
13791 use std::io::{Read, Seek};
13792
13793 use common::{url::Params, ToParts};
13794 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13795
13796 let mut dd = common::DefaultDelegate;
13797 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13798 dlg.begin(common::MethodInfo {
13799 id: "storage.buckets.operations.advanceRelocateBucket",
13800 http_method: hyper::Method::POST,
13801 });
13802
13803 for &field in ["bucket", "operationId"].iter() {
13804 if self._additional_params.contains_key(field) {
13805 dlg.finished(false);
13806 return Err(common::Error::FieldClash(field));
13807 }
13808 }
13809
13810 let mut params = Params::with_capacity(4 + self._additional_params.len());
13811 params.push("bucket", self._bucket);
13812 params.push("operationId", self._operation_id);
13813
13814 params.extend(self._additional_params.iter());
13815
13816 let mut url = self.hub._base_url.clone()
13817 + "b/{bucket}/operations/{operationId}/advanceRelocateBucket";
13818 if self._scopes.is_empty() {
13819 self._scopes
13820 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
13821 }
13822
13823 #[allow(clippy::single_element_loop)]
13824 for &(find_this, param_name) in
13825 [("{bucket}", "bucket"), ("{operationId}", "operationId")].iter()
13826 {
13827 url = params.uri_replacement(url, param_name, find_this, false);
13828 }
13829 {
13830 let to_remove = ["operationId", "bucket"];
13831 params.remove_params(&to_remove);
13832 }
13833
13834 let url = params.parse_with_url(&url);
13835
13836 let mut json_mime_type = mime::APPLICATION_JSON;
13837 let mut request_value_reader = {
13838 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13839 common::remove_json_null_values(&mut value);
13840 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13841 serde_json::to_writer(&mut dst, &value).unwrap();
13842 dst
13843 };
13844 let request_size = request_value_reader
13845 .seek(std::io::SeekFrom::End(0))
13846 .unwrap();
13847 request_value_reader
13848 .seek(std::io::SeekFrom::Start(0))
13849 .unwrap();
13850
13851 loop {
13852 let token = match self
13853 .hub
13854 .auth
13855 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13856 .await
13857 {
13858 Ok(token) => token,
13859 Err(e) => match dlg.token(e) {
13860 Ok(token) => token,
13861 Err(e) => {
13862 dlg.finished(false);
13863 return Err(common::Error::MissingToken(e));
13864 }
13865 },
13866 };
13867 request_value_reader
13868 .seek(std::io::SeekFrom::Start(0))
13869 .unwrap();
13870 let mut req_result = {
13871 let client = &self.hub.client;
13872 dlg.pre_request();
13873 let mut req_builder = hyper::Request::builder()
13874 .method(hyper::Method::POST)
13875 .uri(url.as_str())
13876 .header(USER_AGENT, self.hub._user_agent.clone());
13877
13878 if let Some(token) = token.as_ref() {
13879 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13880 }
13881
13882 let request = req_builder
13883 .header(CONTENT_TYPE, json_mime_type.to_string())
13884 .header(CONTENT_LENGTH, request_size as u64)
13885 .body(common::to_body(
13886 request_value_reader.get_ref().clone().into(),
13887 ));
13888
13889 client.request(request.unwrap()).await
13890 };
13891
13892 match req_result {
13893 Err(err) => {
13894 if let common::Retry::After(d) = dlg.http_error(&err) {
13895 sleep(d).await;
13896 continue;
13897 }
13898 dlg.finished(false);
13899 return Err(common::Error::HttpError(err));
13900 }
13901 Ok(res) => {
13902 let (mut parts, body) = res.into_parts();
13903 let mut body = common::Body::new(body);
13904 if !parts.status.is_success() {
13905 let bytes = common::to_bytes(body).await.unwrap_or_default();
13906 let error = serde_json::from_str(&common::to_string(&bytes));
13907 let response = common::to_response(parts, bytes.into());
13908
13909 if let common::Retry::After(d) =
13910 dlg.http_failure(&response, error.as_ref().ok())
13911 {
13912 sleep(d).await;
13913 continue;
13914 }
13915
13916 dlg.finished(false);
13917
13918 return Err(match error {
13919 Ok(value) => common::Error::BadRequest(value),
13920 _ => common::Error::Failure(response),
13921 });
13922 }
13923 let response = common::Response::from_parts(parts, body);
13924
13925 dlg.finished(true);
13926 return Ok(response);
13927 }
13928 }
13929 }
13930 }
13931
13932 ///
13933 /// Sets the *request* property to the given value.
13934 ///
13935 /// Even though the property as already been set when instantiating this call,
13936 /// we provide this method for API completeness.
13937 pub fn request(
13938 mut self,
13939 new_value: AdvanceRelocateBucketOperationRequest,
13940 ) -> BucketOperationAdvanceRelocateBucketCall<'a, C> {
13941 self._request = new_value;
13942 self
13943 }
13944 /// Name of the bucket to advance the relocate for.
13945 ///
13946 /// Sets the *bucket* path property to the given value.
13947 ///
13948 /// Even though the property as already been set when instantiating this call,
13949 /// we provide this method for API completeness.
13950 pub fn bucket(mut self, new_value: &str) -> BucketOperationAdvanceRelocateBucketCall<'a, C> {
13951 self._bucket = new_value.to_string();
13952 self
13953 }
13954 /// ID of the operation resource.
13955 ///
13956 /// Sets the *operation id* path property to the given value.
13957 ///
13958 /// Even though the property as already been set when instantiating this call,
13959 /// we provide this method for API completeness.
13960 pub fn operation_id(
13961 mut self,
13962 new_value: &str,
13963 ) -> BucketOperationAdvanceRelocateBucketCall<'a, C> {
13964 self._operation_id = new_value.to_string();
13965 self
13966 }
13967 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13968 /// while executing the actual API request.
13969 ///
13970 /// ````text
13971 /// It should be used to handle progress information, and to implement a certain level of resilience.
13972 /// ````
13973 ///
13974 /// Sets the *delegate* property to the given value.
13975 pub fn delegate(
13976 mut self,
13977 new_value: &'a mut dyn common::Delegate,
13978 ) -> BucketOperationAdvanceRelocateBucketCall<'a, C> {
13979 self._delegate = Some(new_value);
13980 self
13981 }
13982
13983 /// Set any additional parameter of the query string used in the request.
13984 /// It should be used to set parameters which are not yet available through their own
13985 /// setters.
13986 ///
13987 /// Please note that this method must not be used to set any of the known parameters
13988 /// which have their own setter method. If done anyway, the request will fail.
13989 ///
13990 /// # Additional Parameters
13991 ///
13992 /// * *alt* (query-string) - Data format for the response.
13993 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13994 /// * *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.
13995 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13996 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13997 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13998 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
13999 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14000 pub fn param<T>(mut self, name: T, value: T) -> BucketOperationAdvanceRelocateBucketCall<'a, C>
14001 where
14002 T: AsRef<str>,
14003 {
14004 self._additional_params
14005 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14006 self
14007 }
14008
14009 /// Identifies the authorization scope for the method you are building.
14010 ///
14011 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14012 /// [`Scope::DevstorageReadWrite`].
14013 ///
14014 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14015 /// tokens for more than one scope.
14016 ///
14017 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14018 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14019 /// sufficient, a read-write scope will do as well.
14020 pub fn add_scope<St>(mut self, scope: St) -> BucketOperationAdvanceRelocateBucketCall<'a, C>
14021 where
14022 St: AsRef<str>,
14023 {
14024 self._scopes.insert(String::from(scope.as_ref()));
14025 self
14026 }
14027 /// Identifies the authorization scope(s) for the method you are building.
14028 ///
14029 /// See [`Self::add_scope()`] for details.
14030 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketOperationAdvanceRelocateBucketCall<'a, C>
14031 where
14032 I: IntoIterator<Item = St>,
14033 St: AsRef<str>,
14034 {
14035 self._scopes
14036 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14037 self
14038 }
14039
14040 /// Removes all scopes, and no default scope will be used either.
14041 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14042 /// for details).
14043 pub fn clear_scopes(mut self) -> BucketOperationAdvanceRelocateBucketCall<'a, C> {
14044 self._scopes.clear();
14045 self
14046 }
14047}
14048
14049/// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed.
14050///
14051/// A builder for the *operations.cancel* method supported by a *bucket* resource.
14052/// It is not used directly, but through a [`BucketMethods`] instance.
14053///
14054/// # Example
14055///
14056/// Instantiate a resource method builder
14057///
14058/// ```test_harness,no_run
14059/// # extern crate hyper;
14060/// # extern crate hyper_rustls;
14061/// # extern crate google_storage1 as storage1;
14062/// # async fn dox() {
14063/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14064///
14065/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14066/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14067/// # .with_native_roots()
14068/// # .unwrap()
14069/// # .https_only()
14070/// # .enable_http2()
14071/// # .build();
14072///
14073/// # let executor = hyper_util::rt::TokioExecutor::new();
14074/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14075/// # secret,
14076/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14077/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14078/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14079/// # ),
14080/// # ).build().await.unwrap();
14081///
14082/// # let client = hyper_util::client::legacy::Client::builder(
14083/// # hyper_util::rt::TokioExecutor::new()
14084/// # )
14085/// # .build(
14086/// # hyper_rustls::HttpsConnectorBuilder::new()
14087/// # .with_native_roots()
14088/// # .unwrap()
14089/// # .https_or_http()
14090/// # .enable_http2()
14091/// # .build()
14092/// # );
14093/// # let mut hub = Storage::new(client, auth);
14094/// // You can configure optional parameters by calling the respective setters at will, and
14095/// // execute the final call using `doit()`.
14096/// // Values shown here are possibly random and not representative !
14097/// let result = hub.buckets().operations_cancel("bucket", "operationId")
14098/// .doit().await;
14099/// # }
14100/// ```
14101pub struct BucketOperationCancelCall<'a, C>
14102where
14103 C: 'a,
14104{
14105 hub: &'a Storage<C>,
14106 _bucket: String,
14107 _operation_id: String,
14108 _delegate: Option<&'a mut dyn common::Delegate>,
14109 _additional_params: HashMap<String, String>,
14110 _scopes: BTreeSet<String>,
14111}
14112
14113impl<'a, C> common::CallBuilder for BucketOperationCancelCall<'a, C> {}
14114
14115impl<'a, C> BucketOperationCancelCall<'a, C>
14116where
14117 C: common::Connector,
14118{
14119 /// Perform the operation you have build so far.
14120 pub async fn doit(mut self) -> common::Result<common::Response> {
14121 use std::borrow::Cow;
14122 use std::io::{Read, Seek};
14123
14124 use common::{url::Params, ToParts};
14125 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14126
14127 let mut dd = common::DefaultDelegate;
14128 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14129 dlg.begin(common::MethodInfo {
14130 id: "storage.buckets.operations.cancel",
14131 http_method: hyper::Method::POST,
14132 });
14133
14134 for &field in ["bucket", "operationId"].iter() {
14135 if self._additional_params.contains_key(field) {
14136 dlg.finished(false);
14137 return Err(common::Error::FieldClash(field));
14138 }
14139 }
14140
14141 let mut params = Params::with_capacity(3 + self._additional_params.len());
14142 params.push("bucket", self._bucket);
14143 params.push("operationId", self._operation_id);
14144
14145 params.extend(self._additional_params.iter());
14146
14147 let mut url = self.hub._base_url.clone() + "b/{bucket}/operations/{operationId}/cancel";
14148 if self._scopes.is_empty() {
14149 self._scopes
14150 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
14151 }
14152
14153 #[allow(clippy::single_element_loop)]
14154 for &(find_this, param_name) in
14155 [("{bucket}", "bucket"), ("{operationId}", "operationId")].iter()
14156 {
14157 url = params.uri_replacement(url, param_name, find_this, false);
14158 }
14159 {
14160 let to_remove = ["operationId", "bucket"];
14161 params.remove_params(&to_remove);
14162 }
14163
14164 let url = params.parse_with_url(&url);
14165
14166 loop {
14167 let token = match self
14168 .hub
14169 .auth
14170 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14171 .await
14172 {
14173 Ok(token) => token,
14174 Err(e) => match dlg.token(e) {
14175 Ok(token) => token,
14176 Err(e) => {
14177 dlg.finished(false);
14178 return Err(common::Error::MissingToken(e));
14179 }
14180 },
14181 };
14182 let mut req_result = {
14183 let client = &self.hub.client;
14184 dlg.pre_request();
14185 let mut req_builder = hyper::Request::builder()
14186 .method(hyper::Method::POST)
14187 .uri(url.as_str())
14188 .header(USER_AGENT, self.hub._user_agent.clone());
14189
14190 if let Some(token) = token.as_ref() {
14191 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14192 }
14193
14194 let request = req_builder
14195 .header(CONTENT_LENGTH, 0_u64)
14196 .body(common::to_body::<String>(None));
14197
14198 client.request(request.unwrap()).await
14199 };
14200
14201 match req_result {
14202 Err(err) => {
14203 if let common::Retry::After(d) = dlg.http_error(&err) {
14204 sleep(d).await;
14205 continue;
14206 }
14207 dlg.finished(false);
14208 return Err(common::Error::HttpError(err));
14209 }
14210 Ok(res) => {
14211 let (mut parts, body) = res.into_parts();
14212 let mut body = common::Body::new(body);
14213 if !parts.status.is_success() {
14214 let bytes = common::to_bytes(body).await.unwrap_or_default();
14215 let error = serde_json::from_str(&common::to_string(&bytes));
14216 let response = common::to_response(parts, bytes.into());
14217
14218 if let common::Retry::After(d) =
14219 dlg.http_failure(&response, error.as_ref().ok())
14220 {
14221 sleep(d).await;
14222 continue;
14223 }
14224
14225 dlg.finished(false);
14226
14227 return Err(match error {
14228 Ok(value) => common::Error::BadRequest(value),
14229 _ => common::Error::Failure(response),
14230 });
14231 }
14232 let response = common::Response::from_parts(parts, body);
14233
14234 dlg.finished(true);
14235 return Ok(response);
14236 }
14237 }
14238 }
14239 }
14240
14241 /// The parent bucket of the operation resource.
14242 ///
14243 /// Sets the *bucket* path property to the given value.
14244 ///
14245 /// Even though the property as already been set when instantiating this call,
14246 /// we provide this method for API completeness.
14247 pub fn bucket(mut self, new_value: &str) -> BucketOperationCancelCall<'a, C> {
14248 self._bucket = new_value.to_string();
14249 self
14250 }
14251 /// The ID of the operation resource.
14252 ///
14253 /// Sets the *operation id* path property to the given value.
14254 ///
14255 /// Even though the property as already been set when instantiating this call,
14256 /// we provide this method for API completeness.
14257 pub fn operation_id(mut self, new_value: &str) -> BucketOperationCancelCall<'a, C> {
14258 self._operation_id = new_value.to_string();
14259 self
14260 }
14261 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14262 /// while executing the actual API request.
14263 ///
14264 /// ````text
14265 /// It should be used to handle progress information, and to implement a certain level of resilience.
14266 /// ````
14267 ///
14268 /// Sets the *delegate* property to the given value.
14269 pub fn delegate(
14270 mut self,
14271 new_value: &'a mut dyn common::Delegate,
14272 ) -> BucketOperationCancelCall<'a, C> {
14273 self._delegate = Some(new_value);
14274 self
14275 }
14276
14277 /// Set any additional parameter of the query string used in the request.
14278 /// It should be used to set parameters which are not yet available through their own
14279 /// setters.
14280 ///
14281 /// Please note that this method must not be used to set any of the known parameters
14282 /// which have their own setter method. If done anyway, the request will fail.
14283 ///
14284 /// # Additional Parameters
14285 ///
14286 /// * *alt* (query-string) - Data format for the response.
14287 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14288 /// * *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.
14289 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14290 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14291 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14292 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
14293 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14294 pub fn param<T>(mut self, name: T, value: T) -> BucketOperationCancelCall<'a, C>
14295 where
14296 T: AsRef<str>,
14297 {
14298 self._additional_params
14299 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14300 self
14301 }
14302
14303 /// Identifies the authorization scope for the method you are building.
14304 ///
14305 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14306 /// [`Scope::DevstorageReadWrite`].
14307 ///
14308 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14309 /// tokens for more than one scope.
14310 ///
14311 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14312 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14313 /// sufficient, a read-write scope will do as well.
14314 pub fn add_scope<St>(mut self, scope: St) -> BucketOperationCancelCall<'a, C>
14315 where
14316 St: AsRef<str>,
14317 {
14318 self._scopes.insert(String::from(scope.as_ref()));
14319 self
14320 }
14321 /// Identifies the authorization scope(s) for the method you are building.
14322 ///
14323 /// See [`Self::add_scope()`] for details.
14324 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketOperationCancelCall<'a, C>
14325 where
14326 I: IntoIterator<Item = St>,
14327 St: AsRef<str>,
14328 {
14329 self._scopes
14330 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14331 self
14332 }
14333
14334 /// Removes all scopes, and no default scope will be used either.
14335 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14336 /// for details).
14337 pub fn clear_scopes(mut self) -> BucketOperationCancelCall<'a, C> {
14338 self._scopes.clear();
14339 self
14340 }
14341}
14342
14343/// Gets the latest state of a long-running operation.
14344///
14345/// A builder for the *operations.get* method supported by a *bucket* resource.
14346/// It is not used directly, but through a [`BucketMethods`] instance.
14347///
14348/// # Example
14349///
14350/// Instantiate a resource method builder
14351///
14352/// ```test_harness,no_run
14353/// # extern crate hyper;
14354/// # extern crate hyper_rustls;
14355/// # extern crate google_storage1 as storage1;
14356/// # async fn dox() {
14357/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14358///
14359/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14360/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14361/// # .with_native_roots()
14362/// # .unwrap()
14363/// # .https_only()
14364/// # .enable_http2()
14365/// # .build();
14366///
14367/// # let executor = hyper_util::rt::TokioExecutor::new();
14368/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14369/// # secret,
14370/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14371/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14372/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14373/// # ),
14374/// # ).build().await.unwrap();
14375///
14376/// # let client = hyper_util::client::legacy::Client::builder(
14377/// # hyper_util::rt::TokioExecutor::new()
14378/// # )
14379/// # .build(
14380/// # hyper_rustls::HttpsConnectorBuilder::new()
14381/// # .with_native_roots()
14382/// # .unwrap()
14383/// # .https_or_http()
14384/// # .enable_http2()
14385/// # .build()
14386/// # );
14387/// # let mut hub = Storage::new(client, auth);
14388/// // You can configure optional parameters by calling the respective setters at will, and
14389/// // execute the final call using `doit()`.
14390/// // Values shown here are possibly random and not representative !
14391/// let result = hub.buckets().operations_get("bucket", "operationId")
14392/// .doit().await;
14393/// # }
14394/// ```
14395pub struct BucketOperationGetCall<'a, C>
14396where
14397 C: 'a,
14398{
14399 hub: &'a Storage<C>,
14400 _bucket: String,
14401 _operation_id: String,
14402 _delegate: Option<&'a mut dyn common::Delegate>,
14403 _additional_params: HashMap<String, String>,
14404 _scopes: BTreeSet<String>,
14405}
14406
14407impl<'a, C> common::CallBuilder for BucketOperationGetCall<'a, C> {}
14408
14409impl<'a, C> BucketOperationGetCall<'a, C>
14410where
14411 C: common::Connector,
14412{
14413 /// Perform the operation you have build so far.
14414 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
14415 use std::borrow::Cow;
14416 use std::io::{Read, Seek};
14417
14418 use common::{url::Params, ToParts};
14419 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14420
14421 let mut dd = common::DefaultDelegate;
14422 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14423 dlg.begin(common::MethodInfo {
14424 id: "storage.buckets.operations.get",
14425 http_method: hyper::Method::GET,
14426 });
14427
14428 for &field in ["alt", "bucket", "operationId"].iter() {
14429 if self._additional_params.contains_key(field) {
14430 dlg.finished(false);
14431 return Err(common::Error::FieldClash(field));
14432 }
14433 }
14434
14435 let mut params = Params::with_capacity(4 + self._additional_params.len());
14436 params.push("bucket", self._bucket);
14437 params.push("operationId", self._operation_id);
14438
14439 params.extend(self._additional_params.iter());
14440
14441 params.push("alt", "json");
14442 let mut url = self.hub._base_url.clone() + "b/{bucket}/operations/{operationId}";
14443 if self._scopes.is_empty() {
14444 self._scopes
14445 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
14446 }
14447
14448 #[allow(clippy::single_element_loop)]
14449 for &(find_this, param_name) in
14450 [("{bucket}", "bucket"), ("{operationId}", "operationId")].iter()
14451 {
14452 url = params.uri_replacement(url, param_name, find_this, false);
14453 }
14454 {
14455 let to_remove = ["operationId", "bucket"];
14456 params.remove_params(&to_remove);
14457 }
14458
14459 let url = params.parse_with_url(&url);
14460
14461 loop {
14462 let token = match self
14463 .hub
14464 .auth
14465 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14466 .await
14467 {
14468 Ok(token) => token,
14469 Err(e) => match dlg.token(e) {
14470 Ok(token) => token,
14471 Err(e) => {
14472 dlg.finished(false);
14473 return Err(common::Error::MissingToken(e));
14474 }
14475 },
14476 };
14477 let mut req_result = {
14478 let client = &self.hub.client;
14479 dlg.pre_request();
14480 let mut req_builder = hyper::Request::builder()
14481 .method(hyper::Method::GET)
14482 .uri(url.as_str())
14483 .header(USER_AGENT, self.hub._user_agent.clone());
14484
14485 if let Some(token) = token.as_ref() {
14486 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14487 }
14488
14489 let request = req_builder
14490 .header(CONTENT_LENGTH, 0_u64)
14491 .body(common::to_body::<String>(None));
14492
14493 client.request(request.unwrap()).await
14494 };
14495
14496 match req_result {
14497 Err(err) => {
14498 if let common::Retry::After(d) = dlg.http_error(&err) {
14499 sleep(d).await;
14500 continue;
14501 }
14502 dlg.finished(false);
14503 return Err(common::Error::HttpError(err));
14504 }
14505 Ok(res) => {
14506 let (mut parts, body) = res.into_parts();
14507 let mut body = common::Body::new(body);
14508 if !parts.status.is_success() {
14509 let bytes = common::to_bytes(body).await.unwrap_or_default();
14510 let error = serde_json::from_str(&common::to_string(&bytes));
14511 let response = common::to_response(parts, bytes.into());
14512
14513 if let common::Retry::After(d) =
14514 dlg.http_failure(&response, error.as_ref().ok())
14515 {
14516 sleep(d).await;
14517 continue;
14518 }
14519
14520 dlg.finished(false);
14521
14522 return Err(match error {
14523 Ok(value) => common::Error::BadRequest(value),
14524 _ => common::Error::Failure(response),
14525 });
14526 }
14527 let response = {
14528 let bytes = common::to_bytes(body).await.unwrap_or_default();
14529 let encoded = common::to_string(&bytes);
14530 match serde_json::from_str(&encoded) {
14531 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14532 Err(error) => {
14533 dlg.response_json_decode_error(&encoded, &error);
14534 return Err(common::Error::JsonDecodeError(
14535 encoded.to_string(),
14536 error,
14537 ));
14538 }
14539 }
14540 };
14541
14542 dlg.finished(true);
14543 return Ok(response);
14544 }
14545 }
14546 }
14547 }
14548
14549 /// The parent bucket of the operation resource.
14550 ///
14551 /// Sets the *bucket* path property to the given value.
14552 ///
14553 /// Even though the property as already been set when instantiating this call,
14554 /// we provide this method for API completeness.
14555 pub fn bucket(mut self, new_value: &str) -> BucketOperationGetCall<'a, C> {
14556 self._bucket = new_value.to_string();
14557 self
14558 }
14559 /// The ID of the operation resource.
14560 ///
14561 /// Sets the *operation id* path property to the given value.
14562 ///
14563 /// Even though the property as already been set when instantiating this call,
14564 /// we provide this method for API completeness.
14565 pub fn operation_id(mut self, new_value: &str) -> BucketOperationGetCall<'a, C> {
14566 self._operation_id = new_value.to_string();
14567 self
14568 }
14569 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14570 /// while executing the actual API request.
14571 ///
14572 /// ````text
14573 /// It should be used to handle progress information, and to implement a certain level of resilience.
14574 /// ````
14575 ///
14576 /// Sets the *delegate* property to the given value.
14577 pub fn delegate(
14578 mut self,
14579 new_value: &'a mut dyn common::Delegate,
14580 ) -> BucketOperationGetCall<'a, C> {
14581 self._delegate = Some(new_value);
14582 self
14583 }
14584
14585 /// Set any additional parameter of the query string used in the request.
14586 /// It should be used to set parameters which are not yet available through their own
14587 /// setters.
14588 ///
14589 /// Please note that this method must not be used to set any of the known parameters
14590 /// which have their own setter method. If done anyway, the request will fail.
14591 ///
14592 /// # Additional Parameters
14593 ///
14594 /// * *alt* (query-string) - Data format for the response.
14595 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14596 /// * *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.
14597 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14598 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14599 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14600 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
14601 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14602 pub fn param<T>(mut self, name: T, value: T) -> BucketOperationGetCall<'a, C>
14603 where
14604 T: AsRef<str>,
14605 {
14606 self._additional_params
14607 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14608 self
14609 }
14610
14611 /// Identifies the authorization scope for the method you are building.
14612 ///
14613 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14614 /// [`Scope::DevstorageReadOnly`].
14615 ///
14616 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14617 /// tokens for more than one scope.
14618 ///
14619 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14620 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14621 /// sufficient, a read-write scope will do as well.
14622 pub fn add_scope<St>(mut self, scope: St) -> BucketOperationGetCall<'a, C>
14623 where
14624 St: AsRef<str>,
14625 {
14626 self._scopes.insert(String::from(scope.as_ref()));
14627 self
14628 }
14629 /// Identifies the authorization scope(s) for the method you are building.
14630 ///
14631 /// See [`Self::add_scope()`] for details.
14632 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketOperationGetCall<'a, C>
14633 where
14634 I: IntoIterator<Item = St>,
14635 St: AsRef<str>,
14636 {
14637 self._scopes
14638 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14639 self
14640 }
14641
14642 /// Removes all scopes, and no default scope will be used either.
14643 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14644 /// for details).
14645 pub fn clear_scopes(mut self) -> BucketOperationGetCall<'a, C> {
14646 self._scopes.clear();
14647 self
14648 }
14649}
14650
14651/// Lists operations that match the specified filter in the request.
14652///
14653/// A builder for the *operations.list* method supported by a *bucket* resource.
14654/// It is not used directly, but through a [`BucketMethods`] instance.
14655///
14656/// # Example
14657///
14658/// Instantiate a resource method builder
14659///
14660/// ```test_harness,no_run
14661/// # extern crate hyper;
14662/// # extern crate hyper_rustls;
14663/// # extern crate google_storage1 as storage1;
14664/// # async fn dox() {
14665/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14666///
14667/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14668/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14669/// # .with_native_roots()
14670/// # .unwrap()
14671/// # .https_only()
14672/// # .enable_http2()
14673/// # .build();
14674///
14675/// # let executor = hyper_util::rt::TokioExecutor::new();
14676/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14677/// # secret,
14678/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14679/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14680/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14681/// # ),
14682/// # ).build().await.unwrap();
14683///
14684/// # let client = hyper_util::client::legacy::Client::builder(
14685/// # hyper_util::rt::TokioExecutor::new()
14686/// # )
14687/// # .build(
14688/// # hyper_rustls::HttpsConnectorBuilder::new()
14689/// # .with_native_roots()
14690/// # .unwrap()
14691/// # .https_or_http()
14692/// # .enable_http2()
14693/// # .build()
14694/// # );
14695/// # let mut hub = Storage::new(client, auth);
14696/// // You can configure optional parameters by calling the respective setters at will, and
14697/// // execute the final call using `doit()`.
14698/// // Values shown here are possibly random and not representative !
14699/// let result = hub.buckets().operations_list("bucket")
14700/// .page_token("aliquyam")
14701/// .page_size(-69)
14702/// .filter("sadipscing")
14703/// .doit().await;
14704/// # }
14705/// ```
14706pub struct BucketOperationListCall<'a, C>
14707where
14708 C: 'a,
14709{
14710 hub: &'a Storage<C>,
14711 _bucket: String,
14712 _page_token: Option<String>,
14713 _page_size: Option<i32>,
14714 _filter: Option<String>,
14715 _delegate: Option<&'a mut dyn common::Delegate>,
14716 _additional_params: HashMap<String, String>,
14717 _scopes: BTreeSet<String>,
14718}
14719
14720impl<'a, C> common::CallBuilder for BucketOperationListCall<'a, C> {}
14721
14722impl<'a, C> BucketOperationListCall<'a, C>
14723where
14724 C: common::Connector,
14725{
14726 /// Perform the operation you have build so far.
14727 pub async fn doit(
14728 mut self,
14729 ) -> common::Result<(common::Response, GoogleLongrunningListOperationsResponse)> {
14730 use std::borrow::Cow;
14731 use std::io::{Read, Seek};
14732
14733 use common::{url::Params, ToParts};
14734 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14735
14736 let mut dd = common::DefaultDelegate;
14737 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14738 dlg.begin(common::MethodInfo {
14739 id: "storage.buckets.operations.list",
14740 http_method: hyper::Method::GET,
14741 });
14742
14743 for &field in ["alt", "bucket", "pageToken", "pageSize", "filter"].iter() {
14744 if self._additional_params.contains_key(field) {
14745 dlg.finished(false);
14746 return Err(common::Error::FieldClash(field));
14747 }
14748 }
14749
14750 let mut params = Params::with_capacity(6 + self._additional_params.len());
14751 params.push("bucket", self._bucket);
14752 if let Some(value) = self._page_token.as_ref() {
14753 params.push("pageToken", value);
14754 }
14755 if let Some(value) = self._page_size.as_ref() {
14756 params.push("pageSize", value.to_string());
14757 }
14758 if let Some(value) = self._filter.as_ref() {
14759 params.push("filter", value);
14760 }
14761
14762 params.extend(self._additional_params.iter());
14763
14764 params.push("alt", "json");
14765 let mut url = self.hub._base_url.clone() + "b/{bucket}/operations";
14766 if self._scopes.is_empty() {
14767 self._scopes
14768 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
14769 }
14770
14771 #[allow(clippy::single_element_loop)]
14772 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
14773 url = params.uri_replacement(url, param_name, find_this, false);
14774 }
14775 {
14776 let to_remove = ["bucket"];
14777 params.remove_params(&to_remove);
14778 }
14779
14780 let url = params.parse_with_url(&url);
14781
14782 loop {
14783 let token = match self
14784 .hub
14785 .auth
14786 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14787 .await
14788 {
14789 Ok(token) => token,
14790 Err(e) => match dlg.token(e) {
14791 Ok(token) => token,
14792 Err(e) => {
14793 dlg.finished(false);
14794 return Err(common::Error::MissingToken(e));
14795 }
14796 },
14797 };
14798 let mut req_result = {
14799 let client = &self.hub.client;
14800 dlg.pre_request();
14801 let mut req_builder = hyper::Request::builder()
14802 .method(hyper::Method::GET)
14803 .uri(url.as_str())
14804 .header(USER_AGENT, self.hub._user_agent.clone());
14805
14806 if let Some(token) = token.as_ref() {
14807 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14808 }
14809
14810 let request = req_builder
14811 .header(CONTENT_LENGTH, 0_u64)
14812 .body(common::to_body::<String>(None));
14813
14814 client.request(request.unwrap()).await
14815 };
14816
14817 match req_result {
14818 Err(err) => {
14819 if let common::Retry::After(d) = dlg.http_error(&err) {
14820 sleep(d).await;
14821 continue;
14822 }
14823 dlg.finished(false);
14824 return Err(common::Error::HttpError(err));
14825 }
14826 Ok(res) => {
14827 let (mut parts, body) = res.into_parts();
14828 let mut body = common::Body::new(body);
14829 if !parts.status.is_success() {
14830 let bytes = common::to_bytes(body).await.unwrap_or_default();
14831 let error = serde_json::from_str(&common::to_string(&bytes));
14832 let response = common::to_response(parts, bytes.into());
14833
14834 if let common::Retry::After(d) =
14835 dlg.http_failure(&response, error.as_ref().ok())
14836 {
14837 sleep(d).await;
14838 continue;
14839 }
14840
14841 dlg.finished(false);
14842
14843 return Err(match error {
14844 Ok(value) => common::Error::BadRequest(value),
14845 _ => common::Error::Failure(response),
14846 });
14847 }
14848 let response = {
14849 let bytes = common::to_bytes(body).await.unwrap_or_default();
14850 let encoded = common::to_string(&bytes);
14851 match serde_json::from_str(&encoded) {
14852 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14853 Err(error) => {
14854 dlg.response_json_decode_error(&encoded, &error);
14855 return Err(common::Error::JsonDecodeError(
14856 encoded.to_string(),
14857 error,
14858 ));
14859 }
14860 }
14861 };
14862
14863 dlg.finished(true);
14864 return Ok(response);
14865 }
14866 }
14867 }
14868 }
14869
14870 /// Name of the bucket in which to look for operations.
14871 ///
14872 /// Sets the *bucket* path property to the given value.
14873 ///
14874 /// Even though the property as already been set when instantiating this call,
14875 /// we provide this method for API completeness.
14876 pub fn bucket(mut self, new_value: &str) -> BucketOperationListCall<'a, C> {
14877 self._bucket = new_value.to_string();
14878 self
14879 }
14880 /// A previously-returned page token representing part of the larger set of results to view.
14881 ///
14882 /// Sets the *page token* query property to the given value.
14883 pub fn page_token(mut self, new_value: &str) -> BucketOperationListCall<'a, C> {
14884 self._page_token = Some(new_value.to_string());
14885 self
14886 }
14887 /// 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.
14888 ///
14889 /// Sets the *page size* query property to the given value.
14890 pub fn page_size(mut self, new_value: i32) -> BucketOperationListCall<'a, C> {
14891 self._page_size = Some(new_value);
14892 self
14893 }
14894 /// 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).
14895 ///
14896 /// Sets the *filter* query property to the given value.
14897 pub fn filter(mut self, new_value: &str) -> BucketOperationListCall<'a, C> {
14898 self._filter = Some(new_value.to_string());
14899 self
14900 }
14901 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14902 /// while executing the actual API request.
14903 ///
14904 /// ````text
14905 /// It should be used to handle progress information, and to implement a certain level of resilience.
14906 /// ````
14907 ///
14908 /// Sets the *delegate* property to the given value.
14909 pub fn delegate(
14910 mut self,
14911 new_value: &'a mut dyn common::Delegate,
14912 ) -> BucketOperationListCall<'a, C> {
14913 self._delegate = Some(new_value);
14914 self
14915 }
14916
14917 /// Set any additional parameter of the query string used in the request.
14918 /// It should be used to set parameters which are not yet available through their own
14919 /// setters.
14920 ///
14921 /// Please note that this method must not be used to set any of the known parameters
14922 /// which have their own setter method. If done anyway, the request will fail.
14923 ///
14924 /// # Additional Parameters
14925 ///
14926 /// * *alt* (query-string) - Data format for the response.
14927 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14928 /// * *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.
14929 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14930 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14931 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14932 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
14933 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14934 pub fn param<T>(mut self, name: T, value: T) -> BucketOperationListCall<'a, C>
14935 where
14936 T: AsRef<str>,
14937 {
14938 self._additional_params
14939 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14940 self
14941 }
14942
14943 /// Identifies the authorization scope for the method you are building.
14944 ///
14945 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14946 /// [`Scope::DevstorageReadOnly`].
14947 ///
14948 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14949 /// tokens for more than one scope.
14950 ///
14951 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14952 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14953 /// sufficient, a read-write scope will do as well.
14954 pub fn add_scope<St>(mut self, scope: St) -> BucketOperationListCall<'a, C>
14955 where
14956 St: AsRef<str>,
14957 {
14958 self._scopes.insert(String::from(scope.as_ref()));
14959 self
14960 }
14961 /// Identifies the authorization scope(s) for the method you are building.
14962 ///
14963 /// See [`Self::add_scope()`] for details.
14964 pub fn add_scopes<I, St>(mut self, scopes: I) -> BucketOperationListCall<'a, C>
14965 where
14966 I: IntoIterator<Item = St>,
14967 St: AsRef<str>,
14968 {
14969 self._scopes
14970 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14971 self
14972 }
14973
14974 /// Removes all scopes, and no default scope will be used either.
14975 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14976 /// for details).
14977 pub fn clear_scopes(mut self) -> BucketOperationListCall<'a, C> {
14978 self._scopes.clear();
14979 self
14980 }
14981}
14982
14983/// Stop watching resources through this channel
14984///
14985/// A builder for the *stop* method supported by a *channel* resource.
14986/// It is not used directly, but through a [`ChannelMethods`] instance.
14987///
14988/// # Example
14989///
14990/// Instantiate a resource method builder
14991///
14992/// ```test_harness,no_run
14993/// # extern crate hyper;
14994/// # extern crate hyper_rustls;
14995/// # extern crate google_storage1 as storage1;
14996/// use storage1::api::Channel;
14997/// # async fn dox() {
14998/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14999///
15000/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15001/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15002/// # .with_native_roots()
15003/// # .unwrap()
15004/// # .https_only()
15005/// # .enable_http2()
15006/// # .build();
15007///
15008/// # let executor = hyper_util::rt::TokioExecutor::new();
15009/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15010/// # secret,
15011/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15012/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15013/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15014/// # ),
15015/// # ).build().await.unwrap();
15016///
15017/// # let client = hyper_util::client::legacy::Client::builder(
15018/// # hyper_util::rt::TokioExecutor::new()
15019/// # )
15020/// # .build(
15021/// # hyper_rustls::HttpsConnectorBuilder::new()
15022/// # .with_native_roots()
15023/// # .unwrap()
15024/// # .https_or_http()
15025/// # .enable_http2()
15026/// # .build()
15027/// # );
15028/// # let mut hub = Storage::new(client, auth);
15029/// // As the method needs a request, you would usually fill it with the desired information
15030/// // into the respective structure. Some of the parts shown here might not be applicable !
15031/// // Values shown here are possibly random and not representative !
15032/// let mut req = Channel::default();
15033///
15034/// // You can configure optional parameters by calling the respective setters at will, and
15035/// // execute the final call using `doit()`.
15036/// // Values shown here are possibly random and not representative !
15037/// let result = hub.channels().stop(req)
15038/// .doit().await;
15039/// # }
15040/// ```
15041pub struct ChannelStopCall<'a, C>
15042where
15043 C: 'a,
15044{
15045 hub: &'a Storage<C>,
15046 _request: Channel,
15047 _delegate: Option<&'a mut dyn common::Delegate>,
15048 _additional_params: HashMap<String, String>,
15049 _scopes: BTreeSet<String>,
15050}
15051
15052impl<'a, C> common::CallBuilder for ChannelStopCall<'a, C> {}
15053
15054impl<'a, C> ChannelStopCall<'a, C>
15055where
15056 C: common::Connector,
15057{
15058 /// Perform the operation you have build so far.
15059 pub async fn doit(mut self) -> common::Result<common::Response> {
15060 use std::borrow::Cow;
15061 use std::io::{Read, Seek};
15062
15063 use common::{url::Params, ToParts};
15064 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15065
15066 let mut dd = common::DefaultDelegate;
15067 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15068 dlg.begin(common::MethodInfo {
15069 id: "storage.channels.stop",
15070 http_method: hyper::Method::POST,
15071 });
15072
15073 for &field in [].iter() {
15074 if self._additional_params.contains_key(field) {
15075 dlg.finished(false);
15076 return Err(common::Error::FieldClash(field));
15077 }
15078 }
15079
15080 let mut params = Params::with_capacity(2 + self._additional_params.len());
15081
15082 params.extend(self._additional_params.iter());
15083
15084 let mut url = self.hub._base_url.clone() + "channels/stop";
15085 if self._scopes.is_empty() {
15086 self._scopes
15087 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
15088 }
15089
15090 let url = params.parse_with_url(&url);
15091
15092 let mut json_mime_type = mime::APPLICATION_JSON;
15093 let mut request_value_reader = {
15094 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15095 common::remove_json_null_values(&mut value);
15096 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15097 serde_json::to_writer(&mut dst, &value).unwrap();
15098 dst
15099 };
15100 let request_size = request_value_reader
15101 .seek(std::io::SeekFrom::End(0))
15102 .unwrap();
15103 request_value_reader
15104 .seek(std::io::SeekFrom::Start(0))
15105 .unwrap();
15106
15107 loop {
15108 let token = match self
15109 .hub
15110 .auth
15111 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15112 .await
15113 {
15114 Ok(token) => token,
15115 Err(e) => match dlg.token(e) {
15116 Ok(token) => token,
15117 Err(e) => {
15118 dlg.finished(false);
15119 return Err(common::Error::MissingToken(e));
15120 }
15121 },
15122 };
15123 request_value_reader
15124 .seek(std::io::SeekFrom::Start(0))
15125 .unwrap();
15126 let mut req_result = {
15127 let client = &self.hub.client;
15128 dlg.pre_request();
15129 let mut req_builder = hyper::Request::builder()
15130 .method(hyper::Method::POST)
15131 .uri(url.as_str())
15132 .header(USER_AGENT, self.hub._user_agent.clone());
15133
15134 if let Some(token) = token.as_ref() {
15135 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15136 }
15137
15138 let request = req_builder
15139 .header(CONTENT_TYPE, json_mime_type.to_string())
15140 .header(CONTENT_LENGTH, request_size as u64)
15141 .body(common::to_body(
15142 request_value_reader.get_ref().clone().into(),
15143 ));
15144
15145 client.request(request.unwrap()).await
15146 };
15147
15148 match req_result {
15149 Err(err) => {
15150 if let common::Retry::After(d) = dlg.http_error(&err) {
15151 sleep(d).await;
15152 continue;
15153 }
15154 dlg.finished(false);
15155 return Err(common::Error::HttpError(err));
15156 }
15157 Ok(res) => {
15158 let (mut parts, body) = res.into_parts();
15159 let mut body = common::Body::new(body);
15160 if !parts.status.is_success() {
15161 let bytes = common::to_bytes(body).await.unwrap_or_default();
15162 let error = serde_json::from_str(&common::to_string(&bytes));
15163 let response = common::to_response(parts, bytes.into());
15164
15165 if let common::Retry::After(d) =
15166 dlg.http_failure(&response, error.as_ref().ok())
15167 {
15168 sleep(d).await;
15169 continue;
15170 }
15171
15172 dlg.finished(false);
15173
15174 return Err(match error {
15175 Ok(value) => common::Error::BadRequest(value),
15176 _ => common::Error::Failure(response),
15177 });
15178 }
15179 let response = common::Response::from_parts(parts, body);
15180
15181 dlg.finished(true);
15182 return Ok(response);
15183 }
15184 }
15185 }
15186 }
15187
15188 ///
15189 /// Sets the *request* property to the given value.
15190 ///
15191 /// Even though the property as already been set when instantiating this call,
15192 /// we provide this method for API completeness.
15193 pub fn request(mut self, new_value: Channel) -> ChannelStopCall<'a, C> {
15194 self._request = new_value;
15195 self
15196 }
15197 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15198 /// while executing the actual API request.
15199 ///
15200 /// ````text
15201 /// It should be used to handle progress information, and to implement a certain level of resilience.
15202 /// ````
15203 ///
15204 /// Sets the *delegate* property to the given value.
15205 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChannelStopCall<'a, C> {
15206 self._delegate = Some(new_value);
15207 self
15208 }
15209
15210 /// Set any additional parameter of the query string used in the request.
15211 /// It should be used to set parameters which are not yet available through their own
15212 /// setters.
15213 ///
15214 /// Please note that this method must not be used to set any of the known parameters
15215 /// which have their own setter method. If done anyway, the request will fail.
15216 ///
15217 /// # Additional Parameters
15218 ///
15219 /// * *alt* (query-string) - Data format for the response.
15220 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15221 /// * *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.
15222 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15223 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15224 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15225 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
15226 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15227 pub fn param<T>(mut self, name: T, value: T) -> ChannelStopCall<'a, C>
15228 where
15229 T: AsRef<str>,
15230 {
15231 self._additional_params
15232 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15233 self
15234 }
15235
15236 /// Identifies the authorization scope for the method you are building.
15237 ///
15238 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15239 /// [`Scope::DevstorageReadOnly`].
15240 ///
15241 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15242 /// tokens for more than one scope.
15243 ///
15244 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15245 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15246 /// sufficient, a read-write scope will do as well.
15247 pub fn add_scope<St>(mut self, scope: St) -> ChannelStopCall<'a, C>
15248 where
15249 St: AsRef<str>,
15250 {
15251 self._scopes.insert(String::from(scope.as_ref()));
15252 self
15253 }
15254 /// Identifies the authorization scope(s) for the method you are building.
15255 ///
15256 /// See [`Self::add_scope()`] for details.
15257 pub fn add_scopes<I, St>(mut self, scopes: I) -> ChannelStopCall<'a, C>
15258 where
15259 I: IntoIterator<Item = St>,
15260 St: AsRef<str>,
15261 {
15262 self._scopes
15263 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15264 self
15265 }
15266
15267 /// Removes all scopes, and no default scope will be used either.
15268 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15269 /// for details).
15270 pub fn clear_scopes(mut self) -> ChannelStopCall<'a, C> {
15271 self._scopes.clear();
15272 self
15273 }
15274}
15275
15276/// Permanently deletes the default object ACL entry for the specified entity on the specified bucket.
15277///
15278/// A builder for the *delete* method supported by a *defaultObjectAccessControl* resource.
15279/// It is not used directly, but through a [`DefaultObjectAccessControlMethods`] instance.
15280///
15281/// # Example
15282///
15283/// Instantiate a resource method builder
15284///
15285/// ```test_harness,no_run
15286/// # extern crate hyper;
15287/// # extern crate hyper_rustls;
15288/// # extern crate google_storage1 as storage1;
15289/// # async fn dox() {
15290/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15291///
15292/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15293/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15294/// # .with_native_roots()
15295/// # .unwrap()
15296/// # .https_only()
15297/// # .enable_http2()
15298/// # .build();
15299///
15300/// # let executor = hyper_util::rt::TokioExecutor::new();
15301/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15302/// # secret,
15303/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15304/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15305/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15306/// # ),
15307/// # ).build().await.unwrap();
15308///
15309/// # let client = hyper_util::client::legacy::Client::builder(
15310/// # hyper_util::rt::TokioExecutor::new()
15311/// # )
15312/// # .build(
15313/// # hyper_rustls::HttpsConnectorBuilder::new()
15314/// # .with_native_roots()
15315/// # .unwrap()
15316/// # .https_or_http()
15317/// # .enable_http2()
15318/// # .build()
15319/// # );
15320/// # let mut hub = Storage::new(client, auth);
15321/// // You can configure optional parameters by calling the respective setters at will, and
15322/// // execute the final call using `doit()`.
15323/// // Values shown here are possibly random and not representative !
15324/// let result = hub.default_object_access_controls().delete("bucket", "entity")
15325/// .user_project("amet")
15326/// .doit().await;
15327/// # }
15328/// ```
15329pub struct DefaultObjectAccessControlDeleteCall<'a, C>
15330where
15331 C: 'a,
15332{
15333 hub: &'a Storage<C>,
15334 _bucket: String,
15335 _entity: String,
15336 _user_project: Option<String>,
15337 _delegate: Option<&'a mut dyn common::Delegate>,
15338 _additional_params: HashMap<String, String>,
15339 _scopes: BTreeSet<String>,
15340}
15341
15342impl<'a, C> common::CallBuilder for DefaultObjectAccessControlDeleteCall<'a, C> {}
15343
15344impl<'a, C> DefaultObjectAccessControlDeleteCall<'a, C>
15345where
15346 C: common::Connector,
15347{
15348 /// Perform the operation you have build so far.
15349 pub async fn doit(mut self) -> common::Result<common::Response> {
15350 use std::borrow::Cow;
15351 use std::io::{Read, Seek};
15352
15353 use common::{url::Params, ToParts};
15354 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15355
15356 let mut dd = common::DefaultDelegate;
15357 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15358 dlg.begin(common::MethodInfo {
15359 id: "storage.defaultObjectAccessControls.delete",
15360 http_method: hyper::Method::DELETE,
15361 });
15362
15363 for &field in ["bucket", "entity", "userProject"].iter() {
15364 if self._additional_params.contains_key(field) {
15365 dlg.finished(false);
15366 return Err(common::Error::FieldClash(field));
15367 }
15368 }
15369
15370 let mut params = Params::with_capacity(4 + self._additional_params.len());
15371 params.push("bucket", self._bucket);
15372 params.push("entity", self._entity);
15373 if let Some(value) = self._user_project.as_ref() {
15374 params.push("userProject", value);
15375 }
15376
15377 params.extend(self._additional_params.iter());
15378
15379 let mut url = self.hub._base_url.clone() + "b/{bucket}/defaultObjectAcl/{entity}";
15380 if self._scopes.is_empty() {
15381 self._scopes
15382 .insert(Scope::DevstorageFullControl.as_ref().to_string());
15383 }
15384
15385 #[allow(clippy::single_element_loop)]
15386 for &(find_this, param_name) in [("{bucket}", "bucket"), ("{entity}", "entity")].iter() {
15387 url = params.uri_replacement(url, param_name, find_this, false);
15388 }
15389 {
15390 let to_remove = ["entity", "bucket"];
15391 params.remove_params(&to_remove);
15392 }
15393
15394 let url = params.parse_with_url(&url);
15395
15396 loop {
15397 let token = match self
15398 .hub
15399 .auth
15400 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15401 .await
15402 {
15403 Ok(token) => token,
15404 Err(e) => match dlg.token(e) {
15405 Ok(token) => token,
15406 Err(e) => {
15407 dlg.finished(false);
15408 return Err(common::Error::MissingToken(e));
15409 }
15410 },
15411 };
15412 let mut req_result = {
15413 let client = &self.hub.client;
15414 dlg.pre_request();
15415 let mut req_builder = hyper::Request::builder()
15416 .method(hyper::Method::DELETE)
15417 .uri(url.as_str())
15418 .header(USER_AGENT, self.hub._user_agent.clone());
15419
15420 if let Some(token) = token.as_ref() {
15421 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15422 }
15423
15424 let request = req_builder
15425 .header(CONTENT_LENGTH, 0_u64)
15426 .body(common::to_body::<String>(None));
15427
15428 client.request(request.unwrap()).await
15429 };
15430
15431 match req_result {
15432 Err(err) => {
15433 if let common::Retry::After(d) = dlg.http_error(&err) {
15434 sleep(d).await;
15435 continue;
15436 }
15437 dlg.finished(false);
15438 return Err(common::Error::HttpError(err));
15439 }
15440 Ok(res) => {
15441 let (mut parts, body) = res.into_parts();
15442 let mut body = common::Body::new(body);
15443 if !parts.status.is_success() {
15444 let bytes = common::to_bytes(body).await.unwrap_or_default();
15445 let error = serde_json::from_str(&common::to_string(&bytes));
15446 let response = common::to_response(parts, bytes.into());
15447
15448 if let common::Retry::After(d) =
15449 dlg.http_failure(&response, error.as_ref().ok())
15450 {
15451 sleep(d).await;
15452 continue;
15453 }
15454
15455 dlg.finished(false);
15456
15457 return Err(match error {
15458 Ok(value) => common::Error::BadRequest(value),
15459 _ => common::Error::Failure(response),
15460 });
15461 }
15462 let response = common::Response::from_parts(parts, body);
15463
15464 dlg.finished(true);
15465 return Ok(response);
15466 }
15467 }
15468 }
15469 }
15470
15471 /// Name of a bucket.
15472 ///
15473 /// Sets the *bucket* path property to the given value.
15474 ///
15475 /// Even though the property as already been set when instantiating this call,
15476 /// we provide this method for API completeness.
15477 pub fn bucket(mut self, new_value: &str) -> DefaultObjectAccessControlDeleteCall<'a, C> {
15478 self._bucket = new_value.to_string();
15479 self
15480 }
15481 /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
15482 ///
15483 /// Sets the *entity* path property to the given value.
15484 ///
15485 /// Even though the property as already been set when instantiating this call,
15486 /// we provide this method for API completeness.
15487 pub fn entity(mut self, new_value: &str) -> DefaultObjectAccessControlDeleteCall<'a, C> {
15488 self._entity = new_value.to_string();
15489 self
15490 }
15491 /// The project to be billed for this request. Required for Requester Pays buckets.
15492 ///
15493 /// Sets the *user project* query property to the given value.
15494 pub fn user_project(mut self, new_value: &str) -> DefaultObjectAccessControlDeleteCall<'a, C> {
15495 self._user_project = Some(new_value.to_string());
15496 self
15497 }
15498 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15499 /// while executing the actual API request.
15500 ///
15501 /// ````text
15502 /// It should be used to handle progress information, and to implement a certain level of resilience.
15503 /// ````
15504 ///
15505 /// Sets the *delegate* property to the given value.
15506 pub fn delegate(
15507 mut self,
15508 new_value: &'a mut dyn common::Delegate,
15509 ) -> DefaultObjectAccessControlDeleteCall<'a, C> {
15510 self._delegate = Some(new_value);
15511 self
15512 }
15513
15514 /// Set any additional parameter of the query string used in the request.
15515 /// It should be used to set parameters which are not yet available through their own
15516 /// setters.
15517 ///
15518 /// Please note that this method must not be used to set any of the known parameters
15519 /// which have their own setter method. If done anyway, the request will fail.
15520 ///
15521 /// # Additional Parameters
15522 ///
15523 /// * *alt* (query-string) - Data format for the response.
15524 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15525 /// * *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.
15526 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15527 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15528 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15529 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
15530 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15531 pub fn param<T>(mut self, name: T, value: T) -> DefaultObjectAccessControlDeleteCall<'a, C>
15532 where
15533 T: AsRef<str>,
15534 {
15535 self._additional_params
15536 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15537 self
15538 }
15539
15540 /// Identifies the authorization scope for the method you are building.
15541 ///
15542 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15543 /// [`Scope::DevstorageFullControl`].
15544 ///
15545 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15546 /// tokens for more than one scope.
15547 ///
15548 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15549 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15550 /// sufficient, a read-write scope will do as well.
15551 pub fn add_scope<St>(mut self, scope: St) -> DefaultObjectAccessControlDeleteCall<'a, C>
15552 where
15553 St: AsRef<str>,
15554 {
15555 self._scopes.insert(String::from(scope.as_ref()));
15556 self
15557 }
15558 /// Identifies the authorization scope(s) for the method you are building.
15559 ///
15560 /// See [`Self::add_scope()`] for details.
15561 pub fn add_scopes<I, St>(mut self, scopes: I) -> DefaultObjectAccessControlDeleteCall<'a, C>
15562 where
15563 I: IntoIterator<Item = St>,
15564 St: AsRef<str>,
15565 {
15566 self._scopes
15567 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15568 self
15569 }
15570
15571 /// Removes all scopes, and no default scope will be used either.
15572 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15573 /// for details).
15574 pub fn clear_scopes(mut self) -> DefaultObjectAccessControlDeleteCall<'a, C> {
15575 self._scopes.clear();
15576 self
15577 }
15578}
15579
15580/// Returns the default object ACL entry for the specified entity on the specified bucket.
15581///
15582/// A builder for the *get* method supported by a *defaultObjectAccessControl* resource.
15583/// It is not used directly, but through a [`DefaultObjectAccessControlMethods`] instance.
15584///
15585/// # Example
15586///
15587/// Instantiate a resource method builder
15588///
15589/// ```test_harness,no_run
15590/// # extern crate hyper;
15591/// # extern crate hyper_rustls;
15592/// # extern crate google_storage1 as storage1;
15593/// # async fn dox() {
15594/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15595///
15596/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15597/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15598/// # .with_native_roots()
15599/// # .unwrap()
15600/// # .https_only()
15601/// # .enable_http2()
15602/// # .build();
15603///
15604/// # let executor = hyper_util::rt::TokioExecutor::new();
15605/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15606/// # secret,
15607/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15608/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15609/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15610/// # ),
15611/// # ).build().await.unwrap();
15612///
15613/// # let client = hyper_util::client::legacy::Client::builder(
15614/// # hyper_util::rt::TokioExecutor::new()
15615/// # )
15616/// # .build(
15617/// # hyper_rustls::HttpsConnectorBuilder::new()
15618/// # .with_native_roots()
15619/// # .unwrap()
15620/// # .https_or_http()
15621/// # .enable_http2()
15622/// # .build()
15623/// # );
15624/// # let mut hub = Storage::new(client, auth);
15625/// // You can configure optional parameters by calling the respective setters at will, and
15626/// // execute the final call using `doit()`.
15627/// // Values shown here are possibly random and not representative !
15628/// let result = hub.default_object_access_controls().get("bucket", "entity")
15629/// .user_project("sea")
15630/// .doit().await;
15631/// # }
15632/// ```
15633pub struct DefaultObjectAccessControlGetCall<'a, C>
15634where
15635 C: 'a,
15636{
15637 hub: &'a Storage<C>,
15638 _bucket: String,
15639 _entity: String,
15640 _user_project: Option<String>,
15641 _delegate: Option<&'a mut dyn common::Delegate>,
15642 _additional_params: HashMap<String, String>,
15643 _scopes: BTreeSet<String>,
15644}
15645
15646impl<'a, C> common::CallBuilder for DefaultObjectAccessControlGetCall<'a, C> {}
15647
15648impl<'a, C> DefaultObjectAccessControlGetCall<'a, C>
15649where
15650 C: common::Connector,
15651{
15652 /// Perform the operation you have build so far.
15653 pub async fn doit(mut self) -> common::Result<(common::Response, ObjectAccessControl)> {
15654 use std::borrow::Cow;
15655 use std::io::{Read, Seek};
15656
15657 use common::{url::Params, ToParts};
15658 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15659
15660 let mut dd = common::DefaultDelegate;
15661 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15662 dlg.begin(common::MethodInfo {
15663 id: "storage.defaultObjectAccessControls.get",
15664 http_method: hyper::Method::GET,
15665 });
15666
15667 for &field in ["alt", "bucket", "entity", "userProject"].iter() {
15668 if self._additional_params.contains_key(field) {
15669 dlg.finished(false);
15670 return Err(common::Error::FieldClash(field));
15671 }
15672 }
15673
15674 let mut params = Params::with_capacity(5 + self._additional_params.len());
15675 params.push("bucket", self._bucket);
15676 params.push("entity", self._entity);
15677 if let Some(value) = self._user_project.as_ref() {
15678 params.push("userProject", value);
15679 }
15680
15681 params.extend(self._additional_params.iter());
15682
15683 params.push("alt", "json");
15684 let mut url = self.hub._base_url.clone() + "b/{bucket}/defaultObjectAcl/{entity}";
15685 if self._scopes.is_empty() {
15686 self._scopes
15687 .insert(Scope::DevstorageFullControl.as_ref().to_string());
15688 }
15689
15690 #[allow(clippy::single_element_loop)]
15691 for &(find_this, param_name) in [("{bucket}", "bucket"), ("{entity}", "entity")].iter() {
15692 url = params.uri_replacement(url, param_name, find_this, false);
15693 }
15694 {
15695 let to_remove = ["entity", "bucket"];
15696 params.remove_params(&to_remove);
15697 }
15698
15699 let url = params.parse_with_url(&url);
15700
15701 loop {
15702 let token = match self
15703 .hub
15704 .auth
15705 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15706 .await
15707 {
15708 Ok(token) => token,
15709 Err(e) => match dlg.token(e) {
15710 Ok(token) => token,
15711 Err(e) => {
15712 dlg.finished(false);
15713 return Err(common::Error::MissingToken(e));
15714 }
15715 },
15716 };
15717 let mut req_result = {
15718 let client = &self.hub.client;
15719 dlg.pre_request();
15720 let mut req_builder = hyper::Request::builder()
15721 .method(hyper::Method::GET)
15722 .uri(url.as_str())
15723 .header(USER_AGENT, self.hub._user_agent.clone());
15724
15725 if let Some(token) = token.as_ref() {
15726 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15727 }
15728
15729 let request = req_builder
15730 .header(CONTENT_LENGTH, 0_u64)
15731 .body(common::to_body::<String>(None));
15732
15733 client.request(request.unwrap()).await
15734 };
15735
15736 match req_result {
15737 Err(err) => {
15738 if let common::Retry::After(d) = dlg.http_error(&err) {
15739 sleep(d).await;
15740 continue;
15741 }
15742 dlg.finished(false);
15743 return Err(common::Error::HttpError(err));
15744 }
15745 Ok(res) => {
15746 let (mut parts, body) = res.into_parts();
15747 let mut body = common::Body::new(body);
15748 if !parts.status.is_success() {
15749 let bytes = common::to_bytes(body).await.unwrap_or_default();
15750 let error = serde_json::from_str(&common::to_string(&bytes));
15751 let response = common::to_response(parts, bytes.into());
15752
15753 if let common::Retry::After(d) =
15754 dlg.http_failure(&response, error.as_ref().ok())
15755 {
15756 sleep(d).await;
15757 continue;
15758 }
15759
15760 dlg.finished(false);
15761
15762 return Err(match error {
15763 Ok(value) => common::Error::BadRequest(value),
15764 _ => common::Error::Failure(response),
15765 });
15766 }
15767 let response = {
15768 let bytes = common::to_bytes(body).await.unwrap_or_default();
15769 let encoded = common::to_string(&bytes);
15770 match serde_json::from_str(&encoded) {
15771 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15772 Err(error) => {
15773 dlg.response_json_decode_error(&encoded, &error);
15774 return Err(common::Error::JsonDecodeError(
15775 encoded.to_string(),
15776 error,
15777 ));
15778 }
15779 }
15780 };
15781
15782 dlg.finished(true);
15783 return Ok(response);
15784 }
15785 }
15786 }
15787 }
15788
15789 /// Name of a bucket.
15790 ///
15791 /// Sets the *bucket* path property to the given value.
15792 ///
15793 /// Even though the property as already been set when instantiating this call,
15794 /// we provide this method for API completeness.
15795 pub fn bucket(mut self, new_value: &str) -> DefaultObjectAccessControlGetCall<'a, C> {
15796 self._bucket = new_value.to_string();
15797 self
15798 }
15799 /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
15800 ///
15801 /// Sets the *entity* path property to the given value.
15802 ///
15803 /// Even though the property as already been set when instantiating this call,
15804 /// we provide this method for API completeness.
15805 pub fn entity(mut self, new_value: &str) -> DefaultObjectAccessControlGetCall<'a, C> {
15806 self._entity = new_value.to_string();
15807 self
15808 }
15809 /// The project to be billed for this request. Required for Requester Pays buckets.
15810 ///
15811 /// Sets the *user project* query property to the given value.
15812 pub fn user_project(mut self, new_value: &str) -> DefaultObjectAccessControlGetCall<'a, C> {
15813 self._user_project = Some(new_value.to_string());
15814 self
15815 }
15816 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15817 /// while executing the actual API request.
15818 ///
15819 /// ````text
15820 /// It should be used to handle progress information, and to implement a certain level of resilience.
15821 /// ````
15822 ///
15823 /// Sets the *delegate* property to the given value.
15824 pub fn delegate(
15825 mut self,
15826 new_value: &'a mut dyn common::Delegate,
15827 ) -> DefaultObjectAccessControlGetCall<'a, C> {
15828 self._delegate = Some(new_value);
15829 self
15830 }
15831
15832 /// Set any additional parameter of the query string used in the request.
15833 /// It should be used to set parameters which are not yet available through their own
15834 /// setters.
15835 ///
15836 /// Please note that this method must not be used to set any of the known parameters
15837 /// which have their own setter method. If done anyway, the request will fail.
15838 ///
15839 /// # Additional Parameters
15840 ///
15841 /// * *alt* (query-string) - Data format for the response.
15842 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15843 /// * *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.
15844 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15845 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15846 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15847 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
15848 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15849 pub fn param<T>(mut self, name: T, value: T) -> DefaultObjectAccessControlGetCall<'a, C>
15850 where
15851 T: AsRef<str>,
15852 {
15853 self._additional_params
15854 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15855 self
15856 }
15857
15858 /// Identifies the authorization scope for the method you are building.
15859 ///
15860 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15861 /// [`Scope::DevstorageFullControl`].
15862 ///
15863 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15864 /// tokens for more than one scope.
15865 ///
15866 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15867 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15868 /// sufficient, a read-write scope will do as well.
15869 pub fn add_scope<St>(mut self, scope: St) -> DefaultObjectAccessControlGetCall<'a, C>
15870 where
15871 St: AsRef<str>,
15872 {
15873 self._scopes.insert(String::from(scope.as_ref()));
15874 self
15875 }
15876 /// Identifies the authorization scope(s) for the method you are building.
15877 ///
15878 /// See [`Self::add_scope()`] for details.
15879 pub fn add_scopes<I, St>(mut self, scopes: I) -> DefaultObjectAccessControlGetCall<'a, C>
15880 where
15881 I: IntoIterator<Item = St>,
15882 St: AsRef<str>,
15883 {
15884 self._scopes
15885 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15886 self
15887 }
15888
15889 /// Removes all scopes, and no default scope will be used either.
15890 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15891 /// for details).
15892 pub fn clear_scopes(mut self) -> DefaultObjectAccessControlGetCall<'a, C> {
15893 self._scopes.clear();
15894 self
15895 }
15896}
15897
15898/// Creates a new default object ACL entry on the specified bucket.
15899///
15900/// A builder for the *insert* method supported by a *defaultObjectAccessControl* resource.
15901/// It is not used directly, but through a [`DefaultObjectAccessControlMethods`] instance.
15902///
15903/// # Example
15904///
15905/// Instantiate a resource method builder
15906///
15907/// ```test_harness,no_run
15908/// # extern crate hyper;
15909/// # extern crate hyper_rustls;
15910/// # extern crate google_storage1 as storage1;
15911/// use storage1::api::ObjectAccessControl;
15912/// # async fn dox() {
15913/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15914///
15915/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15916/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15917/// # .with_native_roots()
15918/// # .unwrap()
15919/// # .https_only()
15920/// # .enable_http2()
15921/// # .build();
15922///
15923/// # let executor = hyper_util::rt::TokioExecutor::new();
15924/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15925/// # secret,
15926/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15927/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15928/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15929/// # ),
15930/// # ).build().await.unwrap();
15931///
15932/// # let client = hyper_util::client::legacy::Client::builder(
15933/// # hyper_util::rt::TokioExecutor::new()
15934/// # )
15935/// # .build(
15936/// # hyper_rustls::HttpsConnectorBuilder::new()
15937/// # .with_native_roots()
15938/// # .unwrap()
15939/// # .https_or_http()
15940/// # .enable_http2()
15941/// # .build()
15942/// # );
15943/// # let mut hub = Storage::new(client, auth);
15944/// // As the method needs a request, you would usually fill it with the desired information
15945/// // into the respective structure. Some of the parts shown here might not be applicable !
15946/// // Values shown here are possibly random and not representative !
15947/// let mut req = ObjectAccessControl::default();
15948///
15949/// // You can configure optional parameters by calling the respective setters at will, and
15950/// // execute the final call using `doit()`.
15951/// // Values shown here are possibly random and not representative !
15952/// let result = hub.default_object_access_controls().insert(req, "bucket")
15953/// .user_project("consetetur")
15954/// .doit().await;
15955/// # }
15956/// ```
15957pub struct DefaultObjectAccessControlInsertCall<'a, C>
15958where
15959 C: 'a,
15960{
15961 hub: &'a Storage<C>,
15962 _request: ObjectAccessControl,
15963 _bucket: String,
15964 _user_project: Option<String>,
15965 _delegate: Option<&'a mut dyn common::Delegate>,
15966 _additional_params: HashMap<String, String>,
15967 _scopes: BTreeSet<String>,
15968}
15969
15970impl<'a, C> common::CallBuilder for DefaultObjectAccessControlInsertCall<'a, C> {}
15971
15972impl<'a, C> DefaultObjectAccessControlInsertCall<'a, C>
15973where
15974 C: common::Connector,
15975{
15976 /// Perform the operation you have build so far.
15977 pub async fn doit(mut self) -> common::Result<(common::Response, ObjectAccessControl)> {
15978 use std::borrow::Cow;
15979 use std::io::{Read, Seek};
15980
15981 use common::{url::Params, ToParts};
15982 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15983
15984 let mut dd = common::DefaultDelegate;
15985 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15986 dlg.begin(common::MethodInfo {
15987 id: "storage.defaultObjectAccessControls.insert",
15988 http_method: hyper::Method::POST,
15989 });
15990
15991 for &field in ["alt", "bucket", "userProject"].iter() {
15992 if self._additional_params.contains_key(field) {
15993 dlg.finished(false);
15994 return Err(common::Error::FieldClash(field));
15995 }
15996 }
15997
15998 let mut params = Params::with_capacity(5 + self._additional_params.len());
15999 params.push("bucket", self._bucket);
16000 if let Some(value) = self._user_project.as_ref() {
16001 params.push("userProject", value);
16002 }
16003
16004 params.extend(self._additional_params.iter());
16005
16006 params.push("alt", "json");
16007 let mut url = self.hub._base_url.clone() + "b/{bucket}/defaultObjectAcl";
16008 if self._scopes.is_empty() {
16009 self._scopes
16010 .insert(Scope::DevstorageFullControl.as_ref().to_string());
16011 }
16012
16013 #[allow(clippy::single_element_loop)]
16014 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
16015 url = params.uri_replacement(url, param_name, find_this, false);
16016 }
16017 {
16018 let to_remove = ["bucket"];
16019 params.remove_params(&to_remove);
16020 }
16021
16022 let url = params.parse_with_url(&url);
16023
16024 let mut json_mime_type = mime::APPLICATION_JSON;
16025 let mut request_value_reader = {
16026 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16027 common::remove_json_null_values(&mut value);
16028 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16029 serde_json::to_writer(&mut dst, &value).unwrap();
16030 dst
16031 };
16032 let request_size = request_value_reader
16033 .seek(std::io::SeekFrom::End(0))
16034 .unwrap();
16035 request_value_reader
16036 .seek(std::io::SeekFrom::Start(0))
16037 .unwrap();
16038
16039 loop {
16040 let token = match self
16041 .hub
16042 .auth
16043 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16044 .await
16045 {
16046 Ok(token) => token,
16047 Err(e) => match dlg.token(e) {
16048 Ok(token) => token,
16049 Err(e) => {
16050 dlg.finished(false);
16051 return Err(common::Error::MissingToken(e));
16052 }
16053 },
16054 };
16055 request_value_reader
16056 .seek(std::io::SeekFrom::Start(0))
16057 .unwrap();
16058 let mut req_result = {
16059 let client = &self.hub.client;
16060 dlg.pre_request();
16061 let mut req_builder = hyper::Request::builder()
16062 .method(hyper::Method::POST)
16063 .uri(url.as_str())
16064 .header(USER_AGENT, self.hub._user_agent.clone());
16065
16066 if let Some(token) = token.as_ref() {
16067 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16068 }
16069
16070 let request = req_builder
16071 .header(CONTENT_TYPE, json_mime_type.to_string())
16072 .header(CONTENT_LENGTH, request_size as u64)
16073 .body(common::to_body(
16074 request_value_reader.get_ref().clone().into(),
16075 ));
16076
16077 client.request(request.unwrap()).await
16078 };
16079
16080 match req_result {
16081 Err(err) => {
16082 if let common::Retry::After(d) = dlg.http_error(&err) {
16083 sleep(d).await;
16084 continue;
16085 }
16086 dlg.finished(false);
16087 return Err(common::Error::HttpError(err));
16088 }
16089 Ok(res) => {
16090 let (mut parts, body) = res.into_parts();
16091 let mut body = common::Body::new(body);
16092 if !parts.status.is_success() {
16093 let bytes = common::to_bytes(body).await.unwrap_or_default();
16094 let error = serde_json::from_str(&common::to_string(&bytes));
16095 let response = common::to_response(parts, bytes.into());
16096
16097 if let common::Retry::After(d) =
16098 dlg.http_failure(&response, error.as_ref().ok())
16099 {
16100 sleep(d).await;
16101 continue;
16102 }
16103
16104 dlg.finished(false);
16105
16106 return Err(match error {
16107 Ok(value) => common::Error::BadRequest(value),
16108 _ => common::Error::Failure(response),
16109 });
16110 }
16111 let response = {
16112 let bytes = common::to_bytes(body).await.unwrap_or_default();
16113 let encoded = common::to_string(&bytes);
16114 match serde_json::from_str(&encoded) {
16115 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16116 Err(error) => {
16117 dlg.response_json_decode_error(&encoded, &error);
16118 return Err(common::Error::JsonDecodeError(
16119 encoded.to_string(),
16120 error,
16121 ));
16122 }
16123 }
16124 };
16125
16126 dlg.finished(true);
16127 return Ok(response);
16128 }
16129 }
16130 }
16131 }
16132
16133 ///
16134 /// Sets the *request* property to the given value.
16135 ///
16136 /// Even though the property as already been set when instantiating this call,
16137 /// we provide this method for API completeness.
16138 pub fn request(
16139 mut self,
16140 new_value: ObjectAccessControl,
16141 ) -> DefaultObjectAccessControlInsertCall<'a, C> {
16142 self._request = new_value;
16143 self
16144 }
16145 /// Name of a bucket.
16146 ///
16147 /// Sets the *bucket* path property to the given value.
16148 ///
16149 /// Even though the property as already been set when instantiating this call,
16150 /// we provide this method for API completeness.
16151 pub fn bucket(mut self, new_value: &str) -> DefaultObjectAccessControlInsertCall<'a, C> {
16152 self._bucket = new_value.to_string();
16153 self
16154 }
16155 /// The project to be billed for this request. Required for Requester Pays buckets.
16156 ///
16157 /// Sets the *user project* query property to the given value.
16158 pub fn user_project(mut self, new_value: &str) -> DefaultObjectAccessControlInsertCall<'a, C> {
16159 self._user_project = Some(new_value.to_string());
16160 self
16161 }
16162 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16163 /// while executing the actual API request.
16164 ///
16165 /// ````text
16166 /// It should be used to handle progress information, and to implement a certain level of resilience.
16167 /// ````
16168 ///
16169 /// Sets the *delegate* property to the given value.
16170 pub fn delegate(
16171 mut self,
16172 new_value: &'a mut dyn common::Delegate,
16173 ) -> DefaultObjectAccessControlInsertCall<'a, C> {
16174 self._delegate = Some(new_value);
16175 self
16176 }
16177
16178 /// Set any additional parameter of the query string used in the request.
16179 /// It should be used to set parameters which are not yet available through their own
16180 /// setters.
16181 ///
16182 /// Please note that this method must not be used to set any of the known parameters
16183 /// which have their own setter method. If done anyway, the request will fail.
16184 ///
16185 /// # Additional Parameters
16186 ///
16187 /// * *alt* (query-string) - Data format for the response.
16188 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16189 /// * *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.
16190 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16191 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16192 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16193 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
16194 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16195 pub fn param<T>(mut self, name: T, value: T) -> DefaultObjectAccessControlInsertCall<'a, C>
16196 where
16197 T: AsRef<str>,
16198 {
16199 self._additional_params
16200 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16201 self
16202 }
16203
16204 /// Identifies the authorization scope for the method you are building.
16205 ///
16206 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16207 /// [`Scope::DevstorageFullControl`].
16208 ///
16209 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16210 /// tokens for more than one scope.
16211 ///
16212 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16213 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16214 /// sufficient, a read-write scope will do as well.
16215 pub fn add_scope<St>(mut self, scope: St) -> DefaultObjectAccessControlInsertCall<'a, C>
16216 where
16217 St: AsRef<str>,
16218 {
16219 self._scopes.insert(String::from(scope.as_ref()));
16220 self
16221 }
16222 /// Identifies the authorization scope(s) for the method you are building.
16223 ///
16224 /// See [`Self::add_scope()`] for details.
16225 pub fn add_scopes<I, St>(mut self, scopes: I) -> DefaultObjectAccessControlInsertCall<'a, C>
16226 where
16227 I: IntoIterator<Item = St>,
16228 St: AsRef<str>,
16229 {
16230 self._scopes
16231 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16232 self
16233 }
16234
16235 /// Removes all scopes, and no default scope will be used either.
16236 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16237 /// for details).
16238 pub fn clear_scopes(mut self) -> DefaultObjectAccessControlInsertCall<'a, C> {
16239 self._scopes.clear();
16240 self
16241 }
16242}
16243
16244/// Retrieves default object ACL entries on the specified bucket.
16245///
16246/// A builder for the *list* method supported by a *defaultObjectAccessControl* resource.
16247/// It is not used directly, but through a [`DefaultObjectAccessControlMethods`] instance.
16248///
16249/// # Example
16250///
16251/// Instantiate a resource method builder
16252///
16253/// ```test_harness,no_run
16254/// # extern crate hyper;
16255/// # extern crate hyper_rustls;
16256/// # extern crate google_storage1 as storage1;
16257/// # async fn dox() {
16258/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16259///
16260/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16261/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16262/// # .with_native_roots()
16263/// # .unwrap()
16264/// # .https_only()
16265/// # .enable_http2()
16266/// # .build();
16267///
16268/// # let executor = hyper_util::rt::TokioExecutor::new();
16269/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16270/// # secret,
16271/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16272/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16273/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16274/// # ),
16275/// # ).build().await.unwrap();
16276///
16277/// # let client = hyper_util::client::legacy::Client::builder(
16278/// # hyper_util::rt::TokioExecutor::new()
16279/// # )
16280/// # .build(
16281/// # hyper_rustls::HttpsConnectorBuilder::new()
16282/// # .with_native_roots()
16283/// # .unwrap()
16284/// # .https_or_http()
16285/// # .enable_http2()
16286/// # .build()
16287/// # );
16288/// # let mut hub = Storage::new(client, auth);
16289/// // You can configure optional parameters by calling the respective setters at will, and
16290/// // execute the final call using `doit()`.
16291/// // Values shown here are possibly random and not representative !
16292/// let result = hub.default_object_access_controls().list("bucket")
16293/// .user_project("est")
16294/// .if_metageneration_not_match(-82)
16295/// .if_metageneration_match(-94)
16296/// .doit().await;
16297/// # }
16298/// ```
16299pub struct DefaultObjectAccessControlListCall<'a, C>
16300where
16301 C: 'a,
16302{
16303 hub: &'a Storage<C>,
16304 _bucket: String,
16305 _user_project: Option<String>,
16306 _if_metageneration_not_match: Option<i64>,
16307 _if_metageneration_match: Option<i64>,
16308 _delegate: Option<&'a mut dyn common::Delegate>,
16309 _additional_params: HashMap<String, String>,
16310 _scopes: BTreeSet<String>,
16311}
16312
16313impl<'a, C> common::CallBuilder for DefaultObjectAccessControlListCall<'a, C> {}
16314
16315impl<'a, C> DefaultObjectAccessControlListCall<'a, C>
16316where
16317 C: common::Connector,
16318{
16319 /// Perform the operation you have build so far.
16320 pub async fn doit(mut self) -> common::Result<(common::Response, ObjectAccessControls)> {
16321 use std::borrow::Cow;
16322 use std::io::{Read, Seek};
16323
16324 use common::{url::Params, ToParts};
16325 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16326
16327 let mut dd = common::DefaultDelegate;
16328 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16329 dlg.begin(common::MethodInfo {
16330 id: "storage.defaultObjectAccessControls.list",
16331 http_method: hyper::Method::GET,
16332 });
16333
16334 for &field in [
16335 "alt",
16336 "bucket",
16337 "userProject",
16338 "ifMetagenerationNotMatch",
16339 "ifMetagenerationMatch",
16340 ]
16341 .iter()
16342 {
16343 if self._additional_params.contains_key(field) {
16344 dlg.finished(false);
16345 return Err(common::Error::FieldClash(field));
16346 }
16347 }
16348
16349 let mut params = Params::with_capacity(6 + self._additional_params.len());
16350 params.push("bucket", self._bucket);
16351 if let Some(value) = self._user_project.as_ref() {
16352 params.push("userProject", value);
16353 }
16354 if let Some(value) = self._if_metageneration_not_match.as_ref() {
16355 params.push("ifMetagenerationNotMatch", value.to_string());
16356 }
16357 if let Some(value) = self._if_metageneration_match.as_ref() {
16358 params.push("ifMetagenerationMatch", value.to_string());
16359 }
16360
16361 params.extend(self._additional_params.iter());
16362
16363 params.push("alt", "json");
16364 let mut url = self.hub._base_url.clone() + "b/{bucket}/defaultObjectAcl";
16365 if self._scopes.is_empty() {
16366 self._scopes
16367 .insert(Scope::DevstorageFullControl.as_ref().to_string());
16368 }
16369
16370 #[allow(clippy::single_element_loop)]
16371 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
16372 url = params.uri_replacement(url, param_name, find_this, false);
16373 }
16374 {
16375 let to_remove = ["bucket"];
16376 params.remove_params(&to_remove);
16377 }
16378
16379 let url = params.parse_with_url(&url);
16380
16381 loop {
16382 let token = match self
16383 .hub
16384 .auth
16385 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16386 .await
16387 {
16388 Ok(token) => token,
16389 Err(e) => match dlg.token(e) {
16390 Ok(token) => token,
16391 Err(e) => {
16392 dlg.finished(false);
16393 return Err(common::Error::MissingToken(e));
16394 }
16395 },
16396 };
16397 let mut req_result = {
16398 let client = &self.hub.client;
16399 dlg.pre_request();
16400 let mut req_builder = hyper::Request::builder()
16401 .method(hyper::Method::GET)
16402 .uri(url.as_str())
16403 .header(USER_AGENT, self.hub._user_agent.clone());
16404
16405 if let Some(token) = token.as_ref() {
16406 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16407 }
16408
16409 let request = req_builder
16410 .header(CONTENT_LENGTH, 0_u64)
16411 .body(common::to_body::<String>(None));
16412
16413 client.request(request.unwrap()).await
16414 };
16415
16416 match req_result {
16417 Err(err) => {
16418 if let common::Retry::After(d) = dlg.http_error(&err) {
16419 sleep(d).await;
16420 continue;
16421 }
16422 dlg.finished(false);
16423 return Err(common::Error::HttpError(err));
16424 }
16425 Ok(res) => {
16426 let (mut parts, body) = res.into_parts();
16427 let mut body = common::Body::new(body);
16428 if !parts.status.is_success() {
16429 let bytes = common::to_bytes(body).await.unwrap_or_default();
16430 let error = serde_json::from_str(&common::to_string(&bytes));
16431 let response = common::to_response(parts, bytes.into());
16432
16433 if let common::Retry::After(d) =
16434 dlg.http_failure(&response, error.as_ref().ok())
16435 {
16436 sleep(d).await;
16437 continue;
16438 }
16439
16440 dlg.finished(false);
16441
16442 return Err(match error {
16443 Ok(value) => common::Error::BadRequest(value),
16444 _ => common::Error::Failure(response),
16445 });
16446 }
16447 let response = {
16448 let bytes = common::to_bytes(body).await.unwrap_or_default();
16449 let encoded = common::to_string(&bytes);
16450 match serde_json::from_str(&encoded) {
16451 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16452 Err(error) => {
16453 dlg.response_json_decode_error(&encoded, &error);
16454 return Err(common::Error::JsonDecodeError(
16455 encoded.to_string(),
16456 error,
16457 ));
16458 }
16459 }
16460 };
16461
16462 dlg.finished(true);
16463 return Ok(response);
16464 }
16465 }
16466 }
16467 }
16468
16469 /// Name of a bucket.
16470 ///
16471 /// Sets the *bucket* path property to the given value.
16472 ///
16473 /// Even though the property as already been set when instantiating this call,
16474 /// we provide this method for API completeness.
16475 pub fn bucket(mut self, new_value: &str) -> DefaultObjectAccessControlListCall<'a, C> {
16476 self._bucket = new_value.to_string();
16477 self
16478 }
16479 /// The project to be billed for this request. Required for Requester Pays buckets.
16480 ///
16481 /// Sets the *user project* query property to the given value.
16482 pub fn user_project(mut self, new_value: &str) -> DefaultObjectAccessControlListCall<'a, C> {
16483 self._user_project = Some(new_value.to_string());
16484 self
16485 }
16486 /// If present, only return default ACL listing if the bucket's current metageneration does not match the given value.
16487 ///
16488 /// Sets the *if metageneration not match* query property to the given value.
16489 pub fn if_metageneration_not_match(
16490 mut self,
16491 new_value: i64,
16492 ) -> DefaultObjectAccessControlListCall<'a, C> {
16493 self._if_metageneration_not_match = Some(new_value);
16494 self
16495 }
16496 /// If present, only return default ACL listing if the bucket's current metageneration matches this value.
16497 ///
16498 /// Sets the *if metageneration match* query property to the given value.
16499 pub fn if_metageneration_match(
16500 mut self,
16501 new_value: i64,
16502 ) -> DefaultObjectAccessControlListCall<'a, C> {
16503 self._if_metageneration_match = Some(new_value);
16504 self
16505 }
16506 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16507 /// while executing the actual API request.
16508 ///
16509 /// ````text
16510 /// It should be used to handle progress information, and to implement a certain level of resilience.
16511 /// ````
16512 ///
16513 /// Sets the *delegate* property to the given value.
16514 pub fn delegate(
16515 mut self,
16516 new_value: &'a mut dyn common::Delegate,
16517 ) -> DefaultObjectAccessControlListCall<'a, C> {
16518 self._delegate = Some(new_value);
16519 self
16520 }
16521
16522 /// Set any additional parameter of the query string used in the request.
16523 /// It should be used to set parameters which are not yet available through their own
16524 /// setters.
16525 ///
16526 /// Please note that this method must not be used to set any of the known parameters
16527 /// which have their own setter method. If done anyway, the request will fail.
16528 ///
16529 /// # Additional Parameters
16530 ///
16531 /// * *alt* (query-string) - Data format for the response.
16532 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16533 /// * *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.
16534 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16535 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16536 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16537 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
16538 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16539 pub fn param<T>(mut self, name: T, value: T) -> DefaultObjectAccessControlListCall<'a, C>
16540 where
16541 T: AsRef<str>,
16542 {
16543 self._additional_params
16544 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16545 self
16546 }
16547
16548 /// Identifies the authorization scope for the method you are building.
16549 ///
16550 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16551 /// [`Scope::DevstorageFullControl`].
16552 ///
16553 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16554 /// tokens for more than one scope.
16555 ///
16556 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16557 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16558 /// sufficient, a read-write scope will do as well.
16559 pub fn add_scope<St>(mut self, scope: St) -> DefaultObjectAccessControlListCall<'a, C>
16560 where
16561 St: AsRef<str>,
16562 {
16563 self._scopes.insert(String::from(scope.as_ref()));
16564 self
16565 }
16566 /// Identifies the authorization scope(s) for the method you are building.
16567 ///
16568 /// See [`Self::add_scope()`] for details.
16569 pub fn add_scopes<I, St>(mut self, scopes: I) -> DefaultObjectAccessControlListCall<'a, C>
16570 where
16571 I: IntoIterator<Item = St>,
16572 St: AsRef<str>,
16573 {
16574 self._scopes
16575 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16576 self
16577 }
16578
16579 /// Removes all scopes, and no default scope will be used either.
16580 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16581 /// for details).
16582 pub fn clear_scopes(mut self) -> DefaultObjectAccessControlListCall<'a, C> {
16583 self._scopes.clear();
16584 self
16585 }
16586}
16587
16588/// Patches a default object ACL entry on the specified bucket.
16589///
16590/// A builder for the *patch* method supported by a *defaultObjectAccessControl* resource.
16591/// It is not used directly, but through a [`DefaultObjectAccessControlMethods`] instance.
16592///
16593/// # Example
16594///
16595/// Instantiate a resource method builder
16596///
16597/// ```test_harness,no_run
16598/// # extern crate hyper;
16599/// # extern crate hyper_rustls;
16600/// # extern crate google_storage1 as storage1;
16601/// use storage1::api::ObjectAccessControl;
16602/// # async fn dox() {
16603/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16604///
16605/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16606/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16607/// # .with_native_roots()
16608/// # .unwrap()
16609/// # .https_only()
16610/// # .enable_http2()
16611/// # .build();
16612///
16613/// # let executor = hyper_util::rt::TokioExecutor::new();
16614/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16615/// # secret,
16616/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16617/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16618/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16619/// # ),
16620/// # ).build().await.unwrap();
16621///
16622/// # let client = hyper_util::client::legacy::Client::builder(
16623/// # hyper_util::rt::TokioExecutor::new()
16624/// # )
16625/// # .build(
16626/// # hyper_rustls::HttpsConnectorBuilder::new()
16627/// # .with_native_roots()
16628/// # .unwrap()
16629/// # .https_or_http()
16630/// # .enable_http2()
16631/// # .build()
16632/// # );
16633/// # let mut hub = Storage::new(client, auth);
16634/// // As the method needs a request, you would usually fill it with the desired information
16635/// // into the respective structure. Some of the parts shown here might not be applicable !
16636/// // Values shown here are possibly random and not representative !
16637/// let mut req = ObjectAccessControl::default();
16638///
16639/// // You can configure optional parameters by calling the respective setters at will, and
16640/// // execute the final call using `doit()`.
16641/// // Values shown here are possibly random and not representative !
16642/// let result = hub.default_object_access_controls().patch(req, "bucket", "entity")
16643/// .user_project("est")
16644/// .doit().await;
16645/// # }
16646/// ```
16647pub struct DefaultObjectAccessControlPatchCall<'a, C>
16648where
16649 C: 'a,
16650{
16651 hub: &'a Storage<C>,
16652 _request: ObjectAccessControl,
16653 _bucket: String,
16654 _entity: String,
16655 _user_project: Option<String>,
16656 _delegate: Option<&'a mut dyn common::Delegate>,
16657 _additional_params: HashMap<String, String>,
16658 _scopes: BTreeSet<String>,
16659}
16660
16661impl<'a, C> common::CallBuilder for DefaultObjectAccessControlPatchCall<'a, C> {}
16662
16663impl<'a, C> DefaultObjectAccessControlPatchCall<'a, C>
16664where
16665 C: common::Connector,
16666{
16667 /// Perform the operation you have build so far.
16668 pub async fn doit(mut self) -> common::Result<(common::Response, ObjectAccessControl)> {
16669 use std::borrow::Cow;
16670 use std::io::{Read, Seek};
16671
16672 use common::{url::Params, ToParts};
16673 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16674
16675 let mut dd = common::DefaultDelegate;
16676 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16677 dlg.begin(common::MethodInfo {
16678 id: "storage.defaultObjectAccessControls.patch",
16679 http_method: hyper::Method::PATCH,
16680 });
16681
16682 for &field in ["alt", "bucket", "entity", "userProject"].iter() {
16683 if self._additional_params.contains_key(field) {
16684 dlg.finished(false);
16685 return Err(common::Error::FieldClash(field));
16686 }
16687 }
16688
16689 let mut params = Params::with_capacity(6 + self._additional_params.len());
16690 params.push("bucket", self._bucket);
16691 params.push("entity", self._entity);
16692 if let Some(value) = self._user_project.as_ref() {
16693 params.push("userProject", value);
16694 }
16695
16696 params.extend(self._additional_params.iter());
16697
16698 params.push("alt", "json");
16699 let mut url = self.hub._base_url.clone() + "b/{bucket}/defaultObjectAcl/{entity}";
16700 if self._scopes.is_empty() {
16701 self._scopes
16702 .insert(Scope::DevstorageFullControl.as_ref().to_string());
16703 }
16704
16705 #[allow(clippy::single_element_loop)]
16706 for &(find_this, param_name) in [("{bucket}", "bucket"), ("{entity}", "entity")].iter() {
16707 url = params.uri_replacement(url, param_name, find_this, false);
16708 }
16709 {
16710 let to_remove = ["entity", "bucket"];
16711 params.remove_params(&to_remove);
16712 }
16713
16714 let url = params.parse_with_url(&url);
16715
16716 let mut json_mime_type = mime::APPLICATION_JSON;
16717 let mut request_value_reader = {
16718 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16719 common::remove_json_null_values(&mut value);
16720 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16721 serde_json::to_writer(&mut dst, &value).unwrap();
16722 dst
16723 };
16724 let request_size = request_value_reader
16725 .seek(std::io::SeekFrom::End(0))
16726 .unwrap();
16727 request_value_reader
16728 .seek(std::io::SeekFrom::Start(0))
16729 .unwrap();
16730
16731 loop {
16732 let token = match self
16733 .hub
16734 .auth
16735 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16736 .await
16737 {
16738 Ok(token) => token,
16739 Err(e) => match dlg.token(e) {
16740 Ok(token) => token,
16741 Err(e) => {
16742 dlg.finished(false);
16743 return Err(common::Error::MissingToken(e));
16744 }
16745 },
16746 };
16747 request_value_reader
16748 .seek(std::io::SeekFrom::Start(0))
16749 .unwrap();
16750 let mut req_result = {
16751 let client = &self.hub.client;
16752 dlg.pre_request();
16753 let mut req_builder = hyper::Request::builder()
16754 .method(hyper::Method::PATCH)
16755 .uri(url.as_str())
16756 .header(USER_AGENT, self.hub._user_agent.clone());
16757
16758 if let Some(token) = token.as_ref() {
16759 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16760 }
16761
16762 let request = req_builder
16763 .header(CONTENT_TYPE, json_mime_type.to_string())
16764 .header(CONTENT_LENGTH, request_size as u64)
16765 .body(common::to_body(
16766 request_value_reader.get_ref().clone().into(),
16767 ));
16768
16769 client.request(request.unwrap()).await
16770 };
16771
16772 match req_result {
16773 Err(err) => {
16774 if let common::Retry::After(d) = dlg.http_error(&err) {
16775 sleep(d).await;
16776 continue;
16777 }
16778 dlg.finished(false);
16779 return Err(common::Error::HttpError(err));
16780 }
16781 Ok(res) => {
16782 let (mut parts, body) = res.into_parts();
16783 let mut body = common::Body::new(body);
16784 if !parts.status.is_success() {
16785 let bytes = common::to_bytes(body).await.unwrap_or_default();
16786 let error = serde_json::from_str(&common::to_string(&bytes));
16787 let response = common::to_response(parts, bytes.into());
16788
16789 if let common::Retry::After(d) =
16790 dlg.http_failure(&response, error.as_ref().ok())
16791 {
16792 sleep(d).await;
16793 continue;
16794 }
16795
16796 dlg.finished(false);
16797
16798 return Err(match error {
16799 Ok(value) => common::Error::BadRequest(value),
16800 _ => common::Error::Failure(response),
16801 });
16802 }
16803 let response = {
16804 let bytes = common::to_bytes(body).await.unwrap_or_default();
16805 let encoded = common::to_string(&bytes);
16806 match serde_json::from_str(&encoded) {
16807 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16808 Err(error) => {
16809 dlg.response_json_decode_error(&encoded, &error);
16810 return Err(common::Error::JsonDecodeError(
16811 encoded.to_string(),
16812 error,
16813 ));
16814 }
16815 }
16816 };
16817
16818 dlg.finished(true);
16819 return Ok(response);
16820 }
16821 }
16822 }
16823 }
16824
16825 ///
16826 /// Sets the *request* property to the given value.
16827 ///
16828 /// Even though the property as already been set when instantiating this call,
16829 /// we provide this method for API completeness.
16830 pub fn request(
16831 mut self,
16832 new_value: ObjectAccessControl,
16833 ) -> DefaultObjectAccessControlPatchCall<'a, C> {
16834 self._request = new_value;
16835 self
16836 }
16837 /// Name of a bucket.
16838 ///
16839 /// Sets the *bucket* path property to the given value.
16840 ///
16841 /// Even though the property as already been set when instantiating this call,
16842 /// we provide this method for API completeness.
16843 pub fn bucket(mut self, new_value: &str) -> DefaultObjectAccessControlPatchCall<'a, C> {
16844 self._bucket = new_value.to_string();
16845 self
16846 }
16847 /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
16848 ///
16849 /// Sets the *entity* path property to the given value.
16850 ///
16851 /// Even though the property as already been set when instantiating this call,
16852 /// we provide this method for API completeness.
16853 pub fn entity(mut self, new_value: &str) -> DefaultObjectAccessControlPatchCall<'a, C> {
16854 self._entity = new_value.to_string();
16855 self
16856 }
16857 /// The project to be billed for this request. Required for Requester Pays buckets.
16858 ///
16859 /// Sets the *user project* query property to the given value.
16860 pub fn user_project(mut self, new_value: &str) -> DefaultObjectAccessControlPatchCall<'a, C> {
16861 self._user_project = Some(new_value.to_string());
16862 self
16863 }
16864 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16865 /// while executing the actual API request.
16866 ///
16867 /// ````text
16868 /// It should be used to handle progress information, and to implement a certain level of resilience.
16869 /// ````
16870 ///
16871 /// Sets the *delegate* property to the given value.
16872 pub fn delegate(
16873 mut self,
16874 new_value: &'a mut dyn common::Delegate,
16875 ) -> DefaultObjectAccessControlPatchCall<'a, C> {
16876 self._delegate = Some(new_value);
16877 self
16878 }
16879
16880 /// Set any additional parameter of the query string used in the request.
16881 /// It should be used to set parameters which are not yet available through their own
16882 /// setters.
16883 ///
16884 /// Please note that this method must not be used to set any of the known parameters
16885 /// which have their own setter method. If done anyway, the request will fail.
16886 ///
16887 /// # Additional Parameters
16888 ///
16889 /// * *alt* (query-string) - Data format for the response.
16890 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16891 /// * *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.
16892 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16893 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16894 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16895 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
16896 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16897 pub fn param<T>(mut self, name: T, value: T) -> DefaultObjectAccessControlPatchCall<'a, C>
16898 where
16899 T: AsRef<str>,
16900 {
16901 self._additional_params
16902 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16903 self
16904 }
16905
16906 /// Identifies the authorization scope for the method you are building.
16907 ///
16908 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16909 /// [`Scope::DevstorageFullControl`].
16910 ///
16911 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16912 /// tokens for more than one scope.
16913 ///
16914 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16915 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16916 /// sufficient, a read-write scope will do as well.
16917 pub fn add_scope<St>(mut self, scope: St) -> DefaultObjectAccessControlPatchCall<'a, C>
16918 where
16919 St: AsRef<str>,
16920 {
16921 self._scopes.insert(String::from(scope.as_ref()));
16922 self
16923 }
16924 /// Identifies the authorization scope(s) for the method you are building.
16925 ///
16926 /// See [`Self::add_scope()`] for details.
16927 pub fn add_scopes<I, St>(mut self, scopes: I) -> DefaultObjectAccessControlPatchCall<'a, C>
16928 where
16929 I: IntoIterator<Item = St>,
16930 St: AsRef<str>,
16931 {
16932 self._scopes
16933 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16934 self
16935 }
16936
16937 /// Removes all scopes, and no default scope will be used either.
16938 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16939 /// for details).
16940 pub fn clear_scopes(mut self) -> DefaultObjectAccessControlPatchCall<'a, C> {
16941 self._scopes.clear();
16942 self
16943 }
16944}
16945
16946/// Updates a default object ACL entry on the specified bucket.
16947///
16948/// A builder for the *update* method supported by a *defaultObjectAccessControl* resource.
16949/// It is not used directly, but through a [`DefaultObjectAccessControlMethods`] instance.
16950///
16951/// # Example
16952///
16953/// Instantiate a resource method builder
16954///
16955/// ```test_harness,no_run
16956/// # extern crate hyper;
16957/// # extern crate hyper_rustls;
16958/// # extern crate google_storage1 as storage1;
16959/// use storage1::api::ObjectAccessControl;
16960/// # async fn dox() {
16961/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16962///
16963/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16964/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16965/// # .with_native_roots()
16966/// # .unwrap()
16967/// # .https_only()
16968/// # .enable_http2()
16969/// # .build();
16970///
16971/// # let executor = hyper_util::rt::TokioExecutor::new();
16972/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16973/// # secret,
16974/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16975/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16976/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16977/// # ),
16978/// # ).build().await.unwrap();
16979///
16980/// # let client = hyper_util::client::legacy::Client::builder(
16981/// # hyper_util::rt::TokioExecutor::new()
16982/// # )
16983/// # .build(
16984/// # hyper_rustls::HttpsConnectorBuilder::new()
16985/// # .with_native_roots()
16986/// # .unwrap()
16987/// # .https_or_http()
16988/// # .enable_http2()
16989/// # .build()
16990/// # );
16991/// # let mut hub = Storage::new(client, auth);
16992/// // As the method needs a request, you would usually fill it with the desired information
16993/// // into the respective structure. Some of the parts shown here might not be applicable !
16994/// // Values shown here are possibly random and not representative !
16995/// let mut req = ObjectAccessControl::default();
16996///
16997/// // You can configure optional parameters by calling the respective setters at will, and
16998/// // execute the final call using `doit()`.
16999/// // Values shown here are possibly random and not representative !
17000/// let result = hub.default_object_access_controls().update(req, "bucket", "entity")
17001/// .user_project("eos")
17002/// .doit().await;
17003/// # }
17004/// ```
17005pub struct DefaultObjectAccessControlUpdateCall<'a, C>
17006where
17007 C: 'a,
17008{
17009 hub: &'a Storage<C>,
17010 _request: ObjectAccessControl,
17011 _bucket: String,
17012 _entity: String,
17013 _user_project: Option<String>,
17014 _delegate: Option<&'a mut dyn common::Delegate>,
17015 _additional_params: HashMap<String, String>,
17016 _scopes: BTreeSet<String>,
17017}
17018
17019impl<'a, C> common::CallBuilder for DefaultObjectAccessControlUpdateCall<'a, C> {}
17020
17021impl<'a, C> DefaultObjectAccessControlUpdateCall<'a, C>
17022where
17023 C: common::Connector,
17024{
17025 /// Perform the operation you have build so far.
17026 pub async fn doit(mut self) -> common::Result<(common::Response, ObjectAccessControl)> {
17027 use std::borrow::Cow;
17028 use std::io::{Read, Seek};
17029
17030 use common::{url::Params, ToParts};
17031 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17032
17033 let mut dd = common::DefaultDelegate;
17034 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17035 dlg.begin(common::MethodInfo {
17036 id: "storage.defaultObjectAccessControls.update",
17037 http_method: hyper::Method::PUT,
17038 });
17039
17040 for &field in ["alt", "bucket", "entity", "userProject"].iter() {
17041 if self._additional_params.contains_key(field) {
17042 dlg.finished(false);
17043 return Err(common::Error::FieldClash(field));
17044 }
17045 }
17046
17047 let mut params = Params::with_capacity(6 + self._additional_params.len());
17048 params.push("bucket", self._bucket);
17049 params.push("entity", self._entity);
17050 if let Some(value) = self._user_project.as_ref() {
17051 params.push("userProject", value);
17052 }
17053
17054 params.extend(self._additional_params.iter());
17055
17056 params.push("alt", "json");
17057 let mut url = self.hub._base_url.clone() + "b/{bucket}/defaultObjectAcl/{entity}";
17058 if self._scopes.is_empty() {
17059 self._scopes
17060 .insert(Scope::DevstorageFullControl.as_ref().to_string());
17061 }
17062
17063 #[allow(clippy::single_element_loop)]
17064 for &(find_this, param_name) in [("{bucket}", "bucket"), ("{entity}", "entity")].iter() {
17065 url = params.uri_replacement(url, param_name, find_this, false);
17066 }
17067 {
17068 let to_remove = ["entity", "bucket"];
17069 params.remove_params(&to_remove);
17070 }
17071
17072 let url = params.parse_with_url(&url);
17073
17074 let mut json_mime_type = mime::APPLICATION_JSON;
17075 let mut request_value_reader = {
17076 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17077 common::remove_json_null_values(&mut value);
17078 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17079 serde_json::to_writer(&mut dst, &value).unwrap();
17080 dst
17081 };
17082 let request_size = request_value_reader
17083 .seek(std::io::SeekFrom::End(0))
17084 .unwrap();
17085 request_value_reader
17086 .seek(std::io::SeekFrom::Start(0))
17087 .unwrap();
17088
17089 loop {
17090 let token = match self
17091 .hub
17092 .auth
17093 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17094 .await
17095 {
17096 Ok(token) => token,
17097 Err(e) => match dlg.token(e) {
17098 Ok(token) => token,
17099 Err(e) => {
17100 dlg.finished(false);
17101 return Err(common::Error::MissingToken(e));
17102 }
17103 },
17104 };
17105 request_value_reader
17106 .seek(std::io::SeekFrom::Start(0))
17107 .unwrap();
17108 let mut req_result = {
17109 let client = &self.hub.client;
17110 dlg.pre_request();
17111 let mut req_builder = hyper::Request::builder()
17112 .method(hyper::Method::PUT)
17113 .uri(url.as_str())
17114 .header(USER_AGENT, self.hub._user_agent.clone());
17115
17116 if let Some(token) = token.as_ref() {
17117 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17118 }
17119
17120 let request = req_builder
17121 .header(CONTENT_TYPE, json_mime_type.to_string())
17122 .header(CONTENT_LENGTH, request_size as u64)
17123 .body(common::to_body(
17124 request_value_reader.get_ref().clone().into(),
17125 ));
17126
17127 client.request(request.unwrap()).await
17128 };
17129
17130 match req_result {
17131 Err(err) => {
17132 if let common::Retry::After(d) = dlg.http_error(&err) {
17133 sleep(d).await;
17134 continue;
17135 }
17136 dlg.finished(false);
17137 return Err(common::Error::HttpError(err));
17138 }
17139 Ok(res) => {
17140 let (mut parts, body) = res.into_parts();
17141 let mut body = common::Body::new(body);
17142 if !parts.status.is_success() {
17143 let bytes = common::to_bytes(body).await.unwrap_or_default();
17144 let error = serde_json::from_str(&common::to_string(&bytes));
17145 let response = common::to_response(parts, bytes.into());
17146
17147 if let common::Retry::After(d) =
17148 dlg.http_failure(&response, error.as_ref().ok())
17149 {
17150 sleep(d).await;
17151 continue;
17152 }
17153
17154 dlg.finished(false);
17155
17156 return Err(match error {
17157 Ok(value) => common::Error::BadRequest(value),
17158 _ => common::Error::Failure(response),
17159 });
17160 }
17161 let response = {
17162 let bytes = common::to_bytes(body).await.unwrap_or_default();
17163 let encoded = common::to_string(&bytes);
17164 match serde_json::from_str(&encoded) {
17165 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17166 Err(error) => {
17167 dlg.response_json_decode_error(&encoded, &error);
17168 return Err(common::Error::JsonDecodeError(
17169 encoded.to_string(),
17170 error,
17171 ));
17172 }
17173 }
17174 };
17175
17176 dlg.finished(true);
17177 return Ok(response);
17178 }
17179 }
17180 }
17181 }
17182
17183 ///
17184 /// Sets the *request* property to the given value.
17185 ///
17186 /// Even though the property as already been set when instantiating this call,
17187 /// we provide this method for API completeness.
17188 pub fn request(
17189 mut self,
17190 new_value: ObjectAccessControl,
17191 ) -> DefaultObjectAccessControlUpdateCall<'a, C> {
17192 self._request = new_value;
17193 self
17194 }
17195 /// Name of a bucket.
17196 ///
17197 /// Sets the *bucket* path property to the given value.
17198 ///
17199 /// Even though the property as already been set when instantiating this call,
17200 /// we provide this method for API completeness.
17201 pub fn bucket(mut self, new_value: &str) -> DefaultObjectAccessControlUpdateCall<'a, C> {
17202 self._bucket = new_value.to_string();
17203 self
17204 }
17205 /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
17206 ///
17207 /// Sets the *entity* path property to the given value.
17208 ///
17209 /// Even though the property as already been set when instantiating this call,
17210 /// we provide this method for API completeness.
17211 pub fn entity(mut self, new_value: &str) -> DefaultObjectAccessControlUpdateCall<'a, C> {
17212 self._entity = new_value.to_string();
17213 self
17214 }
17215 /// The project to be billed for this request. Required for Requester Pays buckets.
17216 ///
17217 /// Sets the *user project* query property to the given value.
17218 pub fn user_project(mut self, new_value: &str) -> DefaultObjectAccessControlUpdateCall<'a, C> {
17219 self._user_project = Some(new_value.to_string());
17220 self
17221 }
17222 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17223 /// while executing the actual API request.
17224 ///
17225 /// ````text
17226 /// It should be used to handle progress information, and to implement a certain level of resilience.
17227 /// ````
17228 ///
17229 /// Sets the *delegate* property to the given value.
17230 pub fn delegate(
17231 mut self,
17232 new_value: &'a mut dyn common::Delegate,
17233 ) -> DefaultObjectAccessControlUpdateCall<'a, C> {
17234 self._delegate = Some(new_value);
17235 self
17236 }
17237
17238 /// Set any additional parameter of the query string used in the request.
17239 /// It should be used to set parameters which are not yet available through their own
17240 /// setters.
17241 ///
17242 /// Please note that this method must not be used to set any of the known parameters
17243 /// which have their own setter method. If done anyway, the request will fail.
17244 ///
17245 /// # Additional Parameters
17246 ///
17247 /// * *alt* (query-string) - Data format for the response.
17248 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17249 /// * *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.
17250 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17251 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17252 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17253 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
17254 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17255 pub fn param<T>(mut self, name: T, value: T) -> DefaultObjectAccessControlUpdateCall<'a, C>
17256 where
17257 T: AsRef<str>,
17258 {
17259 self._additional_params
17260 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17261 self
17262 }
17263
17264 /// Identifies the authorization scope for the method you are building.
17265 ///
17266 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17267 /// [`Scope::DevstorageFullControl`].
17268 ///
17269 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17270 /// tokens for more than one scope.
17271 ///
17272 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17273 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17274 /// sufficient, a read-write scope will do as well.
17275 pub fn add_scope<St>(mut self, scope: St) -> DefaultObjectAccessControlUpdateCall<'a, C>
17276 where
17277 St: AsRef<str>,
17278 {
17279 self._scopes.insert(String::from(scope.as_ref()));
17280 self
17281 }
17282 /// Identifies the authorization scope(s) for the method you are building.
17283 ///
17284 /// See [`Self::add_scope()`] for details.
17285 pub fn add_scopes<I, St>(mut self, scopes: I) -> DefaultObjectAccessControlUpdateCall<'a, C>
17286 where
17287 I: IntoIterator<Item = St>,
17288 St: AsRef<str>,
17289 {
17290 self._scopes
17291 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17292 self
17293 }
17294
17295 /// Removes all scopes, and no default scope will be used either.
17296 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17297 /// for details).
17298 pub fn clear_scopes(mut self) -> DefaultObjectAccessControlUpdateCall<'a, C> {
17299 self._scopes.clear();
17300 self
17301 }
17302}
17303
17304/// Permanently deletes a folder. Only applicable to buckets with hierarchical namespace enabled.
17305///
17306/// A builder for the *delete* method supported by a *folder* resource.
17307/// It is not used directly, but through a [`FolderMethods`] instance.
17308///
17309/// # Example
17310///
17311/// Instantiate a resource method builder
17312///
17313/// ```test_harness,no_run
17314/// # extern crate hyper;
17315/// # extern crate hyper_rustls;
17316/// # extern crate google_storage1 as storage1;
17317/// # async fn dox() {
17318/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17319///
17320/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17321/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17322/// # .with_native_roots()
17323/// # .unwrap()
17324/// # .https_only()
17325/// # .enable_http2()
17326/// # .build();
17327///
17328/// # let executor = hyper_util::rt::TokioExecutor::new();
17329/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17330/// # secret,
17331/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17332/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17333/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17334/// # ),
17335/// # ).build().await.unwrap();
17336///
17337/// # let client = hyper_util::client::legacy::Client::builder(
17338/// # hyper_util::rt::TokioExecutor::new()
17339/// # )
17340/// # .build(
17341/// # hyper_rustls::HttpsConnectorBuilder::new()
17342/// # .with_native_roots()
17343/// # .unwrap()
17344/// # .https_or_http()
17345/// # .enable_http2()
17346/// # .build()
17347/// # );
17348/// # let mut hub = Storage::new(client, auth);
17349/// // You can configure optional parameters by calling the respective setters at will, and
17350/// // execute the final call using `doit()`.
17351/// // Values shown here are possibly random and not representative !
17352/// let result = hub.folders().delete("bucket", "folder")
17353/// .if_metageneration_not_match(-15)
17354/// .if_metageneration_match(-19)
17355/// .doit().await;
17356/// # }
17357/// ```
17358pub struct FolderDeleteCall<'a, C>
17359where
17360 C: 'a,
17361{
17362 hub: &'a Storage<C>,
17363 _bucket: String,
17364 _folder: String,
17365 _if_metageneration_not_match: Option<i64>,
17366 _if_metageneration_match: Option<i64>,
17367 _delegate: Option<&'a mut dyn common::Delegate>,
17368 _additional_params: HashMap<String, String>,
17369 _scopes: BTreeSet<String>,
17370}
17371
17372impl<'a, C> common::CallBuilder for FolderDeleteCall<'a, C> {}
17373
17374impl<'a, C> FolderDeleteCall<'a, C>
17375where
17376 C: common::Connector,
17377{
17378 /// Perform the operation you have build so far.
17379 pub async fn doit(mut self) -> common::Result<common::Response> {
17380 use std::borrow::Cow;
17381 use std::io::{Read, Seek};
17382
17383 use common::{url::Params, ToParts};
17384 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17385
17386 let mut dd = common::DefaultDelegate;
17387 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17388 dlg.begin(common::MethodInfo {
17389 id: "storage.folders.delete",
17390 http_method: hyper::Method::DELETE,
17391 });
17392
17393 for &field in [
17394 "bucket",
17395 "folder",
17396 "ifMetagenerationNotMatch",
17397 "ifMetagenerationMatch",
17398 ]
17399 .iter()
17400 {
17401 if self._additional_params.contains_key(field) {
17402 dlg.finished(false);
17403 return Err(common::Error::FieldClash(field));
17404 }
17405 }
17406
17407 let mut params = Params::with_capacity(5 + self._additional_params.len());
17408 params.push("bucket", self._bucket);
17409 params.push("folder", self._folder);
17410 if let Some(value) = self._if_metageneration_not_match.as_ref() {
17411 params.push("ifMetagenerationNotMatch", value.to_string());
17412 }
17413 if let Some(value) = self._if_metageneration_match.as_ref() {
17414 params.push("ifMetagenerationMatch", value.to_string());
17415 }
17416
17417 params.extend(self._additional_params.iter());
17418
17419 let mut url = self.hub._base_url.clone() + "b/{bucket}/folders/{folder}";
17420 if self._scopes.is_empty() {
17421 self._scopes
17422 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
17423 }
17424
17425 #[allow(clippy::single_element_loop)]
17426 for &(find_this, param_name) in [("{bucket}", "bucket"), ("{folder}", "folder")].iter() {
17427 url = params.uri_replacement(url, param_name, find_this, false);
17428 }
17429 {
17430 let to_remove = ["folder", "bucket"];
17431 params.remove_params(&to_remove);
17432 }
17433
17434 let url = params.parse_with_url(&url);
17435
17436 loop {
17437 let token = match self
17438 .hub
17439 .auth
17440 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17441 .await
17442 {
17443 Ok(token) => token,
17444 Err(e) => match dlg.token(e) {
17445 Ok(token) => token,
17446 Err(e) => {
17447 dlg.finished(false);
17448 return Err(common::Error::MissingToken(e));
17449 }
17450 },
17451 };
17452 let mut req_result = {
17453 let client = &self.hub.client;
17454 dlg.pre_request();
17455 let mut req_builder = hyper::Request::builder()
17456 .method(hyper::Method::DELETE)
17457 .uri(url.as_str())
17458 .header(USER_AGENT, self.hub._user_agent.clone());
17459
17460 if let Some(token) = token.as_ref() {
17461 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17462 }
17463
17464 let request = req_builder
17465 .header(CONTENT_LENGTH, 0_u64)
17466 .body(common::to_body::<String>(None));
17467
17468 client.request(request.unwrap()).await
17469 };
17470
17471 match req_result {
17472 Err(err) => {
17473 if let common::Retry::After(d) = dlg.http_error(&err) {
17474 sleep(d).await;
17475 continue;
17476 }
17477 dlg.finished(false);
17478 return Err(common::Error::HttpError(err));
17479 }
17480 Ok(res) => {
17481 let (mut parts, body) = res.into_parts();
17482 let mut body = common::Body::new(body);
17483 if !parts.status.is_success() {
17484 let bytes = common::to_bytes(body).await.unwrap_or_default();
17485 let error = serde_json::from_str(&common::to_string(&bytes));
17486 let response = common::to_response(parts, bytes.into());
17487
17488 if let common::Retry::After(d) =
17489 dlg.http_failure(&response, error.as_ref().ok())
17490 {
17491 sleep(d).await;
17492 continue;
17493 }
17494
17495 dlg.finished(false);
17496
17497 return Err(match error {
17498 Ok(value) => common::Error::BadRequest(value),
17499 _ => common::Error::Failure(response),
17500 });
17501 }
17502 let response = common::Response::from_parts(parts, body);
17503
17504 dlg.finished(true);
17505 return Ok(response);
17506 }
17507 }
17508 }
17509 }
17510
17511 /// Name of the bucket in which the folder resides.
17512 ///
17513 /// Sets the *bucket* path property to the given value.
17514 ///
17515 /// Even though the property as already been set when instantiating this call,
17516 /// we provide this method for API completeness.
17517 pub fn bucket(mut self, new_value: &str) -> FolderDeleteCall<'a, C> {
17518 self._bucket = new_value.to_string();
17519 self
17520 }
17521 /// Name of a folder.
17522 ///
17523 /// Sets the *folder* path property to the given value.
17524 ///
17525 /// Even though the property as already been set when instantiating this call,
17526 /// we provide this method for API completeness.
17527 pub fn folder(mut self, new_value: &str) -> FolderDeleteCall<'a, C> {
17528 self._folder = new_value.to_string();
17529 self
17530 }
17531 /// If set, only deletes the folder if its metageneration does not match this value.
17532 ///
17533 /// Sets the *if metageneration not match* query property to the given value.
17534 pub fn if_metageneration_not_match(mut self, new_value: i64) -> FolderDeleteCall<'a, C> {
17535 self._if_metageneration_not_match = Some(new_value);
17536 self
17537 }
17538 /// If set, only deletes the folder if its metageneration matches this value.
17539 ///
17540 /// Sets the *if metageneration match* query property to the given value.
17541 pub fn if_metageneration_match(mut self, new_value: i64) -> FolderDeleteCall<'a, C> {
17542 self._if_metageneration_match = Some(new_value);
17543 self
17544 }
17545 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17546 /// while executing the actual API request.
17547 ///
17548 /// ````text
17549 /// It should be used to handle progress information, and to implement a certain level of resilience.
17550 /// ````
17551 ///
17552 /// Sets the *delegate* property to the given value.
17553 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FolderDeleteCall<'a, C> {
17554 self._delegate = Some(new_value);
17555 self
17556 }
17557
17558 /// Set any additional parameter of the query string used in the request.
17559 /// It should be used to set parameters which are not yet available through their own
17560 /// setters.
17561 ///
17562 /// Please note that this method must not be used to set any of the known parameters
17563 /// which have their own setter method. If done anyway, the request will fail.
17564 ///
17565 /// # Additional Parameters
17566 ///
17567 /// * *alt* (query-string) - Data format for the response.
17568 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17569 /// * *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.
17570 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17571 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17572 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17573 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
17574 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17575 pub fn param<T>(mut self, name: T, value: T) -> FolderDeleteCall<'a, C>
17576 where
17577 T: AsRef<str>,
17578 {
17579 self._additional_params
17580 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17581 self
17582 }
17583
17584 /// Identifies the authorization scope for the method you are building.
17585 ///
17586 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17587 /// [`Scope::DevstorageReadWrite`].
17588 ///
17589 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17590 /// tokens for more than one scope.
17591 ///
17592 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17593 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17594 /// sufficient, a read-write scope will do as well.
17595 pub fn add_scope<St>(mut self, scope: St) -> FolderDeleteCall<'a, C>
17596 where
17597 St: AsRef<str>,
17598 {
17599 self._scopes.insert(String::from(scope.as_ref()));
17600 self
17601 }
17602 /// Identifies the authorization scope(s) for the method you are building.
17603 ///
17604 /// See [`Self::add_scope()`] for details.
17605 pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderDeleteCall<'a, C>
17606 where
17607 I: IntoIterator<Item = St>,
17608 St: AsRef<str>,
17609 {
17610 self._scopes
17611 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17612 self
17613 }
17614
17615 /// Removes all scopes, and no default scope will be used either.
17616 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17617 /// for details).
17618 pub fn clear_scopes(mut self) -> FolderDeleteCall<'a, C> {
17619 self._scopes.clear();
17620 self
17621 }
17622}
17623
17624/// Returns metadata for the specified folder. Only applicable to buckets with hierarchical namespace enabled.
17625///
17626/// A builder for the *get* method supported by a *folder* resource.
17627/// It is not used directly, but through a [`FolderMethods`] instance.
17628///
17629/// # Example
17630///
17631/// Instantiate a resource method builder
17632///
17633/// ```test_harness,no_run
17634/// # extern crate hyper;
17635/// # extern crate hyper_rustls;
17636/// # extern crate google_storage1 as storage1;
17637/// # async fn dox() {
17638/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17639///
17640/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17641/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17642/// # .with_native_roots()
17643/// # .unwrap()
17644/// # .https_only()
17645/// # .enable_http2()
17646/// # .build();
17647///
17648/// # let executor = hyper_util::rt::TokioExecutor::new();
17649/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17650/// # secret,
17651/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17652/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17653/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17654/// # ),
17655/// # ).build().await.unwrap();
17656///
17657/// # let client = hyper_util::client::legacy::Client::builder(
17658/// # hyper_util::rt::TokioExecutor::new()
17659/// # )
17660/// # .build(
17661/// # hyper_rustls::HttpsConnectorBuilder::new()
17662/// # .with_native_roots()
17663/// # .unwrap()
17664/// # .https_or_http()
17665/// # .enable_http2()
17666/// # .build()
17667/// # );
17668/// # let mut hub = Storage::new(client, auth);
17669/// // You can configure optional parameters by calling the respective setters at will, and
17670/// // execute the final call using `doit()`.
17671/// // Values shown here are possibly random and not representative !
17672/// let result = hub.folders().get("bucket", "folder")
17673/// .if_metageneration_not_match(-10)
17674/// .if_metageneration_match(-74)
17675/// .doit().await;
17676/// # }
17677/// ```
17678pub struct FolderGetCall<'a, C>
17679where
17680 C: 'a,
17681{
17682 hub: &'a Storage<C>,
17683 _bucket: String,
17684 _folder: String,
17685 _if_metageneration_not_match: Option<i64>,
17686 _if_metageneration_match: Option<i64>,
17687 _delegate: Option<&'a mut dyn common::Delegate>,
17688 _additional_params: HashMap<String, String>,
17689 _scopes: BTreeSet<String>,
17690}
17691
17692impl<'a, C> common::CallBuilder for FolderGetCall<'a, C> {}
17693
17694impl<'a, C> FolderGetCall<'a, C>
17695where
17696 C: common::Connector,
17697{
17698 /// Perform the operation you have build so far.
17699 pub async fn doit(mut self) -> common::Result<(common::Response, Folder)> {
17700 use std::borrow::Cow;
17701 use std::io::{Read, Seek};
17702
17703 use common::{url::Params, ToParts};
17704 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17705
17706 let mut dd = common::DefaultDelegate;
17707 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17708 dlg.begin(common::MethodInfo {
17709 id: "storage.folders.get",
17710 http_method: hyper::Method::GET,
17711 });
17712
17713 for &field in [
17714 "alt",
17715 "bucket",
17716 "folder",
17717 "ifMetagenerationNotMatch",
17718 "ifMetagenerationMatch",
17719 ]
17720 .iter()
17721 {
17722 if self._additional_params.contains_key(field) {
17723 dlg.finished(false);
17724 return Err(common::Error::FieldClash(field));
17725 }
17726 }
17727
17728 let mut params = Params::with_capacity(6 + self._additional_params.len());
17729 params.push("bucket", self._bucket);
17730 params.push("folder", self._folder);
17731 if let Some(value) = self._if_metageneration_not_match.as_ref() {
17732 params.push("ifMetagenerationNotMatch", value.to_string());
17733 }
17734 if let Some(value) = self._if_metageneration_match.as_ref() {
17735 params.push("ifMetagenerationMatch", value.to_string());
17736 }
17737
17738 params.extend(self._additional_params.iter());
17739
17740 params.push("alt", "json");
17741 let mut url = self.hub._base_url.clone() + "b/{bucket}/folders/{folder}";
17742 if self._scopes.is_empty() {
17743 self._scopes
17744 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
17745 }
17746
17747 #[allow(clippy::single_element_loop)]
17748 for &(find_this, param_name) in [("{bucket}", "bucket"), ("{folder}", "folder")].iter() {
17749 url = params.uri_replacement(url, param_name, find_this, false);
17750 }
17751 {
17752 let to_remove = ["folder", "bucket"];
17753 params.remove_params(&to_remove);
17754 }
17755
17756 let url = params.parse_with_url(&url);
17757
17758 loop {
17759 let token = match self
17760 .hub
17761 .auth
17762 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17763 .await
17764 {
17765 Ok(token) => token,
17766 Err(e) => match dlg.token(e) {
17767 Ok(token) => token,
17768 Err(e) => {
17769 dlg.finished(false);
17770 return Err(common::Error::MissingToken(e));
17771 }
17772 },
17773 };
17774 let mut req_result = {
17775 let client = &self.hub.client;
17776 dlg.pre_request();
17777 let mut req_builder = hyper::Request::builder()
17778 .method(hyper::Method::GET)
17779 .uri(url.as_str())
17780 .header(USER_AGENT, self.hub._user_agent.clone());
17781
17782 if let Some(token) = token.as_ref() {
17783 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17784 }
17785
17786 let request = req_builder
17787 .header(CONTENT_LENGTH, 0_u64)
17788 .body(common::to_body::<String>(None));
17789
17790 client.request(request.unwrap()).await
17791 };
17792
17793 match req_result {
17794 Err(err) => {
17795 if let common::Retry::After(d) = dlg.http_error(&err) {
17796 sleep(d).await;
17797 continue;
17798 }
17799 dlg.finished(false);
17800 return Err(common::Error::HttpError(err));
17801 }
17802 Ok(res) => {
17803 let (mut parts, body) = res.into_parts();
17804 let mut body = common::Body::new(body);
17805 if !parts.status.is_success() {
17806 let bytes = common::to_bytes(body).await.unwrap_or_default();
17807 let error = serde_json::from_str(&common::to_string(&bytes));
17808 let response = common::to_response(parts, bytes.into());
17809
17810 if let common::Retry::After(d) =
17811 dlg.http_failure(&response, error.as_ref().ok())
17812 {
17813 sleep(d).await;
17814 continue;
17815 }
17816
17817 dlg.finished(false);
17818
17819 return Err(match error {
17820 Ok(value) => common::Error::BadRequest(value),
17821 _ => common::Error::Failure(response),
17822 });
17823 }
17824 let response = {
17825 let bytes = common::to_bytes(body).await.unwrap_or_default();
17826 let encoded = common::to_string(&bytes);
17827 match serde_json::from_str(&encoded) {
17828 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17829 Err(error) => {
17830 dlg.response_json_decode_error(&encoded, &error);
17831 return Err(common::Error::JsonDecodeError(
17832 encoded.to_string(),
17833 error,
17834 ));
17835 }
17836 }
17837 };
17838
17839 dlg.finished(true);
17840 return Ok(response);
17841 }
17842 }
17843 }
17844 }
17845
17846 /// Name of the bucket in which the folder resides.
17847 ///
17848 /// Sets the *bucket* path property to the given value.
17849 ///
17850 /// Even though the property as already been set when instantiating this call,
17851 /// we provide this method for API completeness.
17852 pub fn bucket(mut self, new_value: &str) -> FolderGetCall<'a, C> {
17853 self._bucket = new_value.to_string();
17854 self
17855 }
17856 /// Name of a folder.
17857 ///
17858 /// Sets the *folder* path property to the given value.
17859 ///
17860 /// Even though the property as already been set when instantiating this call,
17861 /// we provide this method for API completeness.
17862 pub fn folder(mut self, new_value: &str) -> FolderGetCall<'a, C> {
17863 self._folder = new_value.to_string();
17864 self
17865 }
17866 /// Makes the return of the folder metadata conditional on whether the folder's current metageneration does not match the given value.
17867 ///
17868 /// Sets the *if metageneration not match* query property to the given value.
17869 pub fn if_metageneration_not_match(mut self, new_value: i64) -> FolderGetCall<'a, C> {
17870 self._if_metageneration_not_match = Some(new_value);
17871 self
17872 }
17873 /// Makes the return of the folder metadata conditional on whether the folder's current metageneration matches the given value.
17874 ///
17875 /// Sets the *if metageneration match* query property to the given value.
17876 pub fn if_metageneration_match(mut self, new_value: i64) -> FolderGetCall<'a, C> {
17877 self._if_metageneration_match = Some(new_value);
17878 self
17879 }
17880 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17881 /// while executing the actual API request.
17882 ///
17883 /// ````text
17884 /// It should be used to handle progress information, and to implement a certain level of resilience.
17885 /// ````
17886 ///
17887 /// Sets the *delegate* property to the given value.
17888 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FolderGetCall<'a, C> {
17889 self._delegate = Some(new_value);
17890 self
17891 }
17892
17893 /// Set any additional parameter of the query string used in the request.
17894 /// It should be used to set parameters which are not yet available through their own
17895 /// setters.
17896 ///
17897 /// Please note that this method must not be used to set any of the known parameters
17898 /// which have their own setter method. If done anyway, the request will fail.
17899 ///
17900 /// # Additional Parameters
17901 ///
17902 /// * *alt* (query-string) - Data format for the response.
17903 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17904 /// * *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.
17905 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17906 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17907 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17908 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
17909 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17910 pub fn param<T>(mut self, name: T, value: T) -> FolderGetCall<'a, C>
17911 where
17912 T: AsRef<str>,
17913 {
17914 self._additional_params
17915 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17916 self
17917 }
17918
17919 /// Identifies the authorization scope for the method you are building.
17920 ///
17921 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17922 /// [`Scope::DevstorageReadOnly`].
17923 ///
17924 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17925 /// tokens for more than one scope.
17926 ///
17927 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17928 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17929 /// sufficient, a read-write scope will do as well.
17930 pub fn add_scope<St>(mut self, scope: St) -> FolderGetCall<'a, C>
17931 where
17932 St: AsRef<str>,
17933 {
17934 self._scopes.insert(String::from(scope.as_ref()));
17935 self
17936 }
17937 /// Identifies the authorization scope(s) for the method you are building.
17938 ///
17939 /// See [`Self::add_scope()`] for details.
17940 pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderGetCall<'a, C>
17941 where
17942 I: IntoIterator<Item = St>,
17943 St: AsRef<str>,
17944 {
17945 self._scopes
17946 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17947 self
17948 }
17949
17950 /// Removes all scopes, and no default scope will be used either.
17951 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17952 /// for details).
17953 pub fn clear_scopes(mut self) -> FolderGetCall<'a, C> {
17954 self._scopes.clear();
17955 self
17956 }
17957}
17958
17959/// Creates a new folder. Only applicable to buckets with hierarchical namespace enabled.
17960///
17961/// A builder for the *insert* method supported by a *folder* resource.
17962/// It is not used directly, but through a [`FolderMethods`] instance.
17963///
17964/// # Example
17965///
17966/// Instantiate a resource method builder
17967///
17968/// ```test_harness,no_run
17969/// # extern crate hyper;
17970/// # extern crate hyper_rustls;
17971/// # extern crate google_storage1 as storage1;
17972/// use storage1::api::Folder;
17973/// # async fn dox() {
17974/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17975///
17976/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17977/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17978/// # .with_native_roots()
17979/// # .unwrap()
17980/// # .https_only()
17981/// # .enable_http2()
17982/// # .build();
17983///
17984/// # let executor = hyper_util::rt::TokioExecutor::new();
17985/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17986/// # secret,
17987/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17988/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17989/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17990/// # ),
17991/// # ).build().await.unwrap();
17992///
17993/// # let client = hyper_util::client::legacy::Client::builder(
17994/// # hyper_util::rt::TokioExecutor::new()
17995/// # )
17996/// # .build(
17997/// # hyper_rustls::HttpsConnectorBuilder::new()
17998/// # .with_native_roots()
17999/// # .unwrap()
18000/// # .https_or_http()
18001/// # .enable_http2()
18002/// # .build()
18003/// # );
18004/// # let mut hub = Storage::new(client, auth);
18005/// // As the method needs a request, you would usually fill it with the desired information
18006/// // into the respective structure. Some of the parts shown here might not be applicable !
18007/// // Values shown here are possibly random and not representative !
18008/// let mut req = Folder::default();
18009///
18010/// // You can configure optional parameters by calling the respective setters at will, and
18011/// // execute the final call using `doit()`.
18012/// // Values shown here are possibly random and not representative !
18013/// let result = hub.folders().insert(req, "bucket")
18014/// .recursive(false)
18015/// .doit().await;
18016/// # }
18017/// ```
18018pub struct FolderInsertCall<'a, C>
18019where
18020 C: 'a,
18021{
18022 hub: &'a Storage<C>,
18023 _request: Folder,
18024 _bucket: String,
18025 _recursive: Option<bool>,
18026 _delegate: Option<&'a mut dyn common::Delegate>,
18027 _additional_params: HashMap<String, String>,
18028 _scopes: BTreeSet<String>,
18029}
18030
18031impl<'a, C> common::CallBuilder for FolderInsertCall<'a, C> {}
18032
18033impl<'a, C> FolderInsertCall<'a, C>
18034where
18035 C: common::Connector,
18036{
18037 /// Perform the operation you have build so far.
18038 pub async fn doit(mut self) -> common::Result<(common::Response, Folder)> {
18039 use std::borrow::Cow;
18040 use std::io::{Read, Seek};
18041
18042 use common::{url::Params, ToParts};
18043 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18044
18045 let mut dd = common::DefaultDelegate;
18046 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18047 dlg.begin(common::MethodInfo {
18048 id: "storage.folders.insert",
18049 http_method: hyper::Method::POST,
18050 });
18051
18052 for &field in ["alt", "bucket", "recursive"].iter() {
18053 if self._additional_params.contains_key(field) {
18054 dlg.finished(false);
18055 return Err(common::Error::FieldClash(field));
18056 }
18057 }
18058
18059 let mut params = Params::with_capacity(5 + self._additional_params.len());
18060 params.push("bucket", self._bucket);
18061 if let Some(value) = self._recursive.as_ref() {
18062 params.push("recursive", value.to_string());
18063 }
18064
18065 params.extend(self._additional_params.iter());
18066
18067 params.push("alt", "json");
18068 let mut url = self.hub._base_url.clone() + "b/{bucket}/folders";
18069 if self._scopes.is_empty() {
18070 self._scopes
18071 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
18072 }
18073
18074 #[allow(clippy::single_element_loop)]
18075 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
18076 url = params.uri_replacement(url, param_name, find_this, false);
18077 }
18078 {
18079 let to_remove = ["bucket"];
18080 params.remove_params(&to_remove);
18081 }
18082
18083 let url = params.parse_with_url(&url);
18084
18085 let mut json_mime_type = mime::APPLICATION_JSON;
18086 let mut request_value_reader = {
18087 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18088 common::remove_json_null_values(&mut value);
18089 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18090 serde_json::to_writer(&mut dst, &value).unwrap();
18091 dst
18092 };
18093 let request_size = request_value_reader
18094 .seek(std::io::SeekFrom::End(0))
18095 .unwrap();
18096 request_value_reader
18097 .seek(std::io::SeekFrom::Start(0))
18098 .unwrap();
18099
18100 loop {
18101 let token = match self
18102 .hub
18103 .auth
18104 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18105 .await
18106 {
18107 Ok(token) => token,
18108 Err(e) => match dlg.token(e) {
18109 Ok(token) => token,
18110 Err(e) => {
18111 dlg.finished(false);
18112 return Err(common::Error::MissingToken(e));
18113 }
18114 },
18115 };
18116 request_value_reader
18117 .seek(std::io::SeekFrom::Start(0))
18118 .unwrap();
18119 let mut req_result = {
18120 let client = &self.hub.client;
18121 dlg.pre_request();
18122 let mut req_builder = hyper::Request::builder()
18123 .method(hyper::Method::POST)
18124 .uri(url.as_str())
18125 .header(USER_AGENT, self.hub._user_agent.clone());
18126
18127 if let Some(token) = token.as_ref() {
18128 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18129 }
18130
18131 let request = req_builder
18132 .header(CONTENT_TYPE, json_mime_type.to_string())
18133 .header(CONTENT_LENGTH, request_size as u64)
18134 .body(common::to_body(
18135 request_value_reader.get_ref().clone().into(),
18136 ));
18137
18138 client.request(request.unwrap()).await
18139 };
18140
18141 match req_result {
18142 Err(err) => {
18143 if let common::Retry::After(d) = dlg.http_error(&err) {
18144 sleep(d).await;
18145 continue;
18146 }
18147 dlg.finished(false);
18148 return Err(common::Error::HttpError(err));
18149 }
18150 Ok(res) => {
18151 let (mut parts, body) = res.into_parts();
18152 let mut body = common::Body::new(body);
18153 if !parts.status.is_success() {
18154 let bytes = common::to_bytes(body).await.unwrap_or_default();
18155 let error = serde_json::from_str(&common::to_string(&bytes));
18156 let response = common::to_response(parts, bytes.into());
18157
18158 if let common::Retry::After(d) =
18159 dlg.http_failure(&response, error.as_ref().ok())
18160 {
18161 sleep(d).await;
18162 continue;
18163 }
18164
18165 dlg.finished(false);
18166
18167 return Err(match error {
18168 Ok(value) => common::Error::BadRequest(value),
18169 _ => common::Error::Failure(response),
18170 });
18171 }
18172 let response = {
18173 let bytes = common::to_bytes(body).await.unwrap_or_default();
18174 let encoded = common::to_string(&bytes);
18175 match serde_json::from_str(&encoded) {
18176 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18177 Err(error) => {
18178 dlg.response_json_decode_error(&encoded, &error);
18179 return Err(common::Error::JsonDecodeError(
18180 encoded.to_string(),
18181 error,
18182 ));
18183 }
18184 }
18185 };
18186
18187 dlg.finished(true);
18188 return Ok(response);
18189 }
18190 }
18191 }
18192 }
18193
18194 ///
18195 /// Sets the *request* property to the given value.
18196 ///
18197 /// Even though the property as already been set when instantiating this call,
18198 /// we provide this method for API completeness.
18199 pub fn request(mut self, new_value: Folder) -> FolderInsertCall<'a, C> {
18200 self._request = new_value;
18201 self
18202 }
18203 /// Name of the bucket in which the folder resides.
18204 ///
18205 /// Sets the *bucket* path property to the given value.
18206 ///
18207 /// Even though the property as already been set when instantiating this call,
18208 /// we provide this method for API completeness.
18209 pub fn bucket(mut self, new_value: &str) -> FolderInsertCall<'a, C> {
18210 self._bucket = new_value.to_string();
18211 self
18212 }
18213 /// If true, any parent folder which doesn't exist will be created automatically.
18214 ///
18215 /// Sets the *recursive* query property to the given value.
18216 pub fn recursive(mut self, new_value: bool) -> FolderInsertCall<'a, C> {
18217 self._recursive = Some(new_value);
18218 self
18219 }
18220 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18221 /// while executing the actual API request.
18222 ///
18223 /// ````text
18224 /// It should be used to handle progress information, and to implement a certain level of resilience.
18225 /// ````
18226 ///
18227 /// Sets the *delegate* property to the given value.
18228 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FolderInsertCall<'a, C> {
18229 self._delegate = Some(new_value);
18230 self
18231 }
18232
18233 /// Set any additional parameter of the query string used in the request.
18234 /// It should be used to set parameters which are not yet available through their own
18235 /// setters.
18236 ///
18237 /// Please note that this method must not be used to set any of the known parameters
18238 /// which have their own setter method. If done anyway, the request will fail.
18239 ///
18240 /// # Additional Parameters
18241 ///
18242 /// * *alt* (query-string) - Data format for the response.
18243 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18244 /// * *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.
18245 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18246 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18247 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18248 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
18249 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18250 pub fn param<T>(mut self, name: T, value: T) -> FolderInsertCall<'a, C>
18251 where
18252 T: AsRef<str>,
18253 {
18254 self._additional_params
18255 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18256 self
18257 }
18258
18259 /// Identifies the authorization scope for the method you are building.
18260 ///
18261 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18262 /// [`Scope::DevstorageReadWrite`].
18263 ///
18264 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18265 /// tokens for more than one scope.
18266 ///
18267 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18268 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18269 /// sufficient, a read-write scope will do as well.
18270 pub fn add_scope<St>(mut self, scope: St) -> FolderInsertCall<'a, C>
18271 where
18272 St: AsRef<str>,
18273 {
18274 self._scopes.insert(String::from(scope.as_ref()));
18275 self
18276 }
18277 /// Identifies the authorization scope(s) for the method you are building.
18278 ///
18279 /// See [`Self::add_scope()`] for details.
18280 pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderInsertCall<'a, C>
18281 where
18282 I: IntoIterator<Item = St>,
18283 St: AsRef<str>,
18284 {
18285 self._scopes
18286 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18287 self
18288 }
18289
18290 /// Removes all scopes, and no default scope will be used either.
18291 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18292 /// for details).
18293 pub fn clear_scopes(mut self) -> FolderInsertCall<'a, C> {
18294 self._scopes.clear();
18295 self
18296 }
18297}
18298
18299/// Retrieves a list of folders matching the criteria. Only applicable to buckets with hierarchical namespace enabled.
18300///
18301/// A builder for the *list* method supported by a *folder* resource.
18302/// It is not used directly, but through a [`FolderMethods`] instance.
18303///
18304/// # Example
18305///
18306/// Instantiate a resource method builder
18307///
18308/// ```test_harness,no_run
18309/// # extern crate hyper;
18310/// # extern crate hyper_rustls;
18311/// # extern crate google_storage1 as storage1;
18312/// # async fn dox() {
18313/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18314///
18315/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18316/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18317/// # .with_native_roots()
18318/// # .unwrap()
18319/// # .https_only()
18320/// # .enable_http2()
18321/// # .build();
18322///
18323/// # let executor = hyper_util::rt::TokioExecutor::new();
18324/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18325/// # secret,
18326/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18327/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18328/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18329/// # ),
18330/// # ).build().await.unwrap();
18331///
18332/// # let client = hyper_util::client::legacy::Client::builder(
18333/// # hyper_util::rt::TokioExecutor::new()
18334/// # )
18335/// # .build(
18336/// # hyper_rustls::HttpsConnectorBuilder::new()
18337/// # .with_native_roots()
18338/// # .unwrap()
18339/// # .https_or_http()
18340/// # .enable_http2()
18341/// # .build()
18342/// # );
18343/// # let mut hub = Storage::new(client, auth);
18344/// // You can configure optional parameters by calling the respective setters at will, and
18345/// // execute the final call using `doit()`.
18346/// // Values shown here are possibly random and not representative !
18347/// let result = hub.folders().list("bucket")
18348/// .start_offset("Lorem")
18349/// .prefix("accusam")
18350/// .page_token("amet")
18351/// .page_size(-31)
18352/// .end_offset("dolores")
18353/// .delimiter("erat")
18354/// .doit().await;
18355/// # }
18356/// ```
18357pub struct FolderListCall<'a, C>
18358where
18359 C: 'a,
18360{
18361 hub: &'a Storage<C>,
18362 _bucket: String,
18363 _start_offset: Option<String>,
18364 _prefix: Option<String>,
18365 _page_token: Option<String>,
18366 _page_size: Option<i32>,
18367 _end_offset: Option<String>,
18368 _delimiter: Option<String>,
18369 _delegate: Option<&'a mut dyn common::Delegate>,
18370 _additional_params: HashMap<String, String>,
18371 _scopes: BTreeSet<String>,
18372}
18373
18374impl<'a, C> common::CallBuilder for FolderListCall<'a, C> {}
18375
18376impl<'a, C> FolderListCall<'a, C>
18377where
18378 C: common::Connector,
18379{
18380 /// Perform the operation you have build so far.
18381 pub async fn doit(mut self) -> common::Result<(common::Response, Folders)> {
18382 use std::borrow::Cow;
18383 use std::io::{Read, Seek};
18384
18385 use common::{url::Params, ToParts};
18386 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18387
18388 let mut dd = common::DefaultDelegate;
18389 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18390 dlg.begin(common::MethodInfo {
18391 id: "storage.folders.list",
18392 http_method: hyper::Method::GET,
18393 });
18394
18395 for &field in [
18396 "alt",
18397 "bucket",
18398 "startOffset",
18399 "prefix",
18400 "pageToken",
18401 "pageSize",
18402 "endOffset",
18403 "delimiter",
18404 ]
18405 .iter()
18406 {
18407 if self._additional_params.contains_key(field) {
18408 dlg.finished(false);
18409 return Err(common::Error::FieldClash(field));
18410 }
18411 }
18412
18413 let mut params = Params::with_capacity(9 + self._additional_params.len());
18414 params.push("bucket", self._bucket);
18415 if let Some(value) = self._start_offset.as_ref() {
18416 params.push("startOffset", value);
18417 }
18418 if let Some(value) = self._prefix.as_ref() {
18419 params.push("prefix", value);
18420 }
18421 if let Some(value) = self._page_token.as_ref() {
18422 params.push("pageToken", value);
18423 }
18424 if let Some(value) = self._page_size.as_ref() {
18425 params.push("pageSize", value.to_string());
18426 }
18427 if let Some(value) = self._end_offset.as_ref() {
18428 params.push("endOffset", value);
18429 }
18430 if let Some(value) = self._delimiter.as_ref() {
18431 params.push("delimiter", value);
18432 }
18433
18434 params.extend(self._additional_params.iter());
18435
18436 params.push("alt", "json");
18437 let mut url = self.hub._base_url.clone() + "b/{bucket}/folders";
18438 if self._scopes.is_empty() {
18439 self._scopes
18440 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
18441 }
18442
18443 #[allow(clippy::single_element_loop)]
18444 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
18445 url = params.uri_replacement(url, param_name, find_this, false);
18446 }
18447 {
18448 let to_remove = ["bucket"];
18449 params.remove_params(&to_remove);
18450 }
18451
18452 let url = params.parse_with_url(&url);
18453
18454 loop {
18455 let token = match self
18456 .hub
18457 .auth
18458 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18459 .await
18460 {
18461 Ok(token) => token,
18462 Err(e) => match dlg.token(e) {
18463 Ok(token) => token,
18464 Err(e) => {
18465 dlg.finished(false);
18466 return Err(common::Error::MissingToken(e));
18467 }
18468 },
18469 };
18470 let mut req_result = {
18471 let client = &self.hub.client;
18472 dlg.pre_request();
18473 let mut req_builder = hyper::Request::builder()
18474 .method(hyper::Method::GET)
18475 .uri(url.as_str())
18476 .header(USER_AGENT, self.hub._user_agent.clone());
18477
18478 if let Some(token) = token.as_ref() {
18479 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18480 }
18481
18482 let request = req_builder
18483 .header(CONTENT_LENGTH, 0_u64)
18484 .body(common::to_body::<String>(None));
18485
18486 client.request(request.unwrap()).await
18487 };
18488
18489 match req_result {
18490 Err(err) => {
18491 if let common::Retry::After(d) = dlg.http_error(&err) {
18492 sleep(d).await;
18493 continue;
18494 }
18495 dlg.finished(false);
18496 return Err(common::Error::HttpError(err));
18497 }
18498 Ok(res) => {
18499 let (mut parts, body) = res.into_parts();
18500 let mut body = common::Body::new(body);
18501 if !parts.status.is_success() {
18502 let bytes = common::to_bytes(body).await.unwrap_or_default();
18503 let error = serde_json::from_str(&common::to_string(&bytes));
18504 let response = common::to_response(parts, bytes.into());
18505
18506 if let common::Retry::After(d) =
18507 dlg.http_failure(&response, error.as_ref().ok())
18508 {
18509 sleep(d).await;
18510 continue;
18511 }
18512
18513 dlg.finished(false);
18514
18515 return Err(match error {
18516 Ok(value) => common::Error::BadRequest(value),
18517 _ => common::Error::Failure(response),
18518 });
18519 }
18520 let response = {
18521 let bytes = common::to_bytes(body).await.unwrap_or_default();
18522 let encoded = common::to_string(&bytes);
18523 match serde_json::from_str(&encoded) {
18524 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18525 Err(error) => {
18526 dlg.response_json_decode_error(&encoded, &error);
18527 return Err(common::Error::JsonDecodeError(
18528 encoded.to_string(),
18529 error,
18530 ));
18531 }
18532 }
18533 };
18534
18535 dlg.finished(true);
18536 return Ok(response);
18537 }
18538 }
18539 }
18540 }
18541
18542 /// Name of the bucket in which to look for folders.
18543 ///
18544 /// Sets the *bucket* path property to the given value.
18545 ///
18546 /// Even though the property as already been set when instantiating this call,
18547 /// we provide this method for API completeness.
18548 pub fn bucket(mut self, new_value: &str) -> FolderListCall<'a, C> {
18549 self._bucket = new_value.to_string();
18550 self
18551 }
18552 /// 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).
18553 ///
18554 /// Sets the *start offset* query property to the given value.
18555 pub fn start_offset(mut self, new_value: &str) -> FolderListCall<'a, C> {
18556 self._start_offset = Some(new_value.to_string());
18557 self
18558 }
18559 /// Filter results to folders whose paths begin with this prefix. If set, the value must either be an empty string or end with a '/'.
18560 ///
18561 /// Sets the *prefix* query property to the given value.
18562 pub fn prefix(mut self, new_value: &str) -> FolderListCall<'a, C> {
18563 self._prefix = Some(new_value.to_string());
18564 self
18565 }
18566 /// A previously-returned page token representing part of the larger set of results to view.
18567 ///
18568 /// Sets the *page token* query property to the given value.
18569 pub fn page_token(mut self, new_value: &str) -> FolderListCall<'a, C> {
18570 self._page_token = Some(new_value.to_string());
18571 self
18572 }
18573 /// Maximum number of items to return in a single page of responses.
18574 ///
18575 /// Sets the *page size* query property to the given value.
18576 pub fn page_size(mut self, new_value: i32) -> FolderListCall<'a, C> {
18577 self._page_size = Some(new_value);
18578 self
18579 }
18580 /// 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).
18581 ///
18582 /// Sets the *end offset* query property to the given value.
18583 pub fn end_offset(mut self, new_value: &str) -> FolderListCall<'a, C> {
18584 self._end_offset = Some(new_value.to_string());
18585 self
18586 }
18587 /// 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.
18588 ///
18589 /// Sets the *delimiter* query property to the given value.
18590 pub fn delimiter(mut self, new_value: &str) -> FolderListCall<'a, C> {
18591 self._delimiter = Some(new_value.to_string());
18592 self
18593 }
18594 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18595 /// while executing the actual API request.
18596 ///
18597 /// ````text
18598 /// It should be used to handle progress information, and to implement a certain level of resilience.
18599 /// ````
18600 ///
18601 /// Sets the *delegate* property to the given value.
18602 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FolderListCall<'a, C> {
18603 self._delegate = Some(new_value);
18604 self
18605 }
18606
18607 /// Set any additional parameter of the query string used in the request.
18608 /// It should be used to set parameters which are not yet available through their own
18609 /// setters.
18610 ///
18611 /// Please note that this method must not be used to set any of the known parameters
18612 /// which have their own setter method. If done anyway, the request will fail.
18613 ///
18614 /// # Additional Parameters
18615 ///
18616 /// * *alt* (query-string) - Data format for the response.
18617 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18618 /// * *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.
18619 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18620 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18621 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18622 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
18623 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18624 pub fn param<T>(mut self, name: T, value: T) -> FolderListCall<'a, C>
18625 where
18626 T: AsRef<str>,
18627 {
18628 self._additional_params
18629 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18630 self
18631 }
18632
18633 /// Identifies the authorization scope for the method you are building.
18634 ///
18635 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18636 /// [`Scope::DevstorageReadOnly`].
18637 ///
18638 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18639 /// tokens for more than one scope.
18640 ///
18641 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18642 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18643 /// sufficient, a read-write scope will do as well.
18644 pub fn add_scope<St>(mut self, scope: St) -> FolderListCall<'a, C>
18645 where
18646 St: AsRef<str>,
18647 {
18648 self._scopes.insert(String::from(scope.as_ref()));
18649 self
18650 }
18651 /// Identifies the authorization scope(s) for the method you are building.
18652 ///
18653 /// See [`Self::add_scope()`] for details.
18654 pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderListCall<'a, C>
18655 where
18656 I: IntoIterator<Item = St>,
18657 St: AsRef<str>,
18658 {
18659 self._scopes
18660 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18661 self
18662 }
18663
18664 /// Removes all scopes, and no default scope will be used either.
18665 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18666 /// for details).
18667 pub fn clear_scopes(mut self) -> FolderListCall<'a, C> {
18668 self._scopes.clear();
18669 self
18670 }
18671}
18672
18673/// Renames a source folder to a destination folder. Only applicable to buckets with hierarchical namespace enabled.
18674///
18675/// A builder for the *rename* method supported by a *folder* resource.
18676/// It is not used directly, but through a [`FolderMethods`] instance.
18677///
18678/// # Example
18679///
18680/// Instantiate a resource method builder
18681///
18682/// ```test_harness,no_run
18683/// # extern crate hyper;
18684/// # extern crate hyper_rustls;
18685/// # extern crate google_storage1 as storage1;
18686/// # async fn dox() {
18687/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18688///
18689/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18690/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18691/// # .with_native_roots()
18692/// # .unwrap()
18693/// # .https_only()
18694/// # .enable_http2()
18695/// # .build();
18696///
18697/// # let executor = hyper_util::rt::TokioExecutor::new();
18698/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18699/// # secret,
18700/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18701/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18702/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18703/// # ),
18704/// # ).build().await.unwrap();
18705///
18706/// # let client = hyper_util::client::legacy::Client::builder(
18707/// # hyper_util::rt::TokioExecutor::new()
18708/// # )
18709/// # .build(
18710/// # hyper_rustls::HttpsConnectorBuilder::new()
18711/// # .with_native_roots()
18712/// # .unwrap()
18713/// # .https_or_http()
18714/// # .enable_http2()
18715/// # .build()
18716/// # );
18717/// # let mut hub = Storage::new(client, auth);
18718/// // You can configure optional parameters by calling the respective setters at will, and
18719/// // execute the final call using `doit()`.
18720/// // Values shown here are possibly random and not representative !
18721/// let result = hub.folders().rename("bucket", "sourceFolder", "destinationFolder")
18722/// .if_source_metageneration_not_match(-51)
18723/// .if_source_metageneration_match(-22)
18724/// .doit().await;
18725/// # }
18726/// ```
18727pub struct FolderRenameCall<'a, C>
18728where
18729 C: 'a,
18730{
18731 hub: &'a Storage<C>,
18732 _bucket: String,
18733 _source_folder: String,
18734 _destination_folder: String,
18735 _if_source_metageneration_not_match: Option<i64>,
18736 _if_source_metageneration_match: Option<i64>,
18737 _delegate: Option<&'a mut dyn common::Delegate>,
18738 _additional_params: HashMap<String, String>,
18739 _scopes: BTreeSet<String>,
18740}
18741
18742impl<'a, C> common::CallBuilder for FolderRenameCall<'a, C> {}
18743
18744impl<'a, C> FolderRenameCall<'a, C>
18745where
18746 C: common::Connector,
18747{
18748 /// Perform the operation you have build so far.
18749 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
18750 use std::borrow::Cow;
18751 use std::io::{Read, Seek};
18752
18753 use common::{url::Params, ToParts};
18754 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18755
18756 let mut dd = common::DefaultDelegate;
18757 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18758 dlg.begin(common::MethodInfo {
18759 id: "storage.folders.rename",
18760 http_method: hyper::Method::POST,
18761 });
18762
18763 for &field in [
18764 "alt",
18765 "bucket",
18766 "sourceFolder",
18767 "destinationFolder",
18768 "ifSourceMetagenerationNotMatch",
18769 "ifSourceMetagenerationMatch",
18770 ]
18771 .iter()
18772 {
18773 if self._additional_params.contains_key(field) {
18774 dlg.finished(false);
18775 return Err(common::Error::FieldClash(field));
18776 }
18777 }
18778
18779 let mut params = Params::with_capacity(7 + self._additional_params.len());
18780 params.push("bucket", self._bucket);
18781 params.push("sourceFolder", self._source_folder);
18782 params.push("destinationFolder", self._destination_folder);
18783 if let Some(value) = self._if_source_metageneration_not_match.as_ref() {
18784 params.push("ifSourceMetagenerationNotMatch", value.to_string());
18785 }
18786 if let Some(value) = self._if_source_metageneration_match.as_ref() {
18787 params.push("ifSourceMetagenerationMatch", value.to_string());
18788 }
18789
18790 params.extend(self._additional_params.iter());
18791
18792 params.push("alt", "json");
18793 let mut url = self.hub._base_url.clone()
18794 + "b/{bucket}/folders/{sourceFolder}/renameTo/folders/{destinationFolder}";
18795 if self._scopes.is_empty() {
18796 self._scopes
18797 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
18798 }
18799
18800 #[allow(clippy::single_element_loop)]
18801 for &(find_this, param_name) in [
18802 ("{bucket}", "bucket"),
18803 ("{sourceFolder}", "sourceFolder"),
18804 ("{destinationFolder}", "destinationFolder"),
18805 ]
18806 .iter()
18807 {
18808 url = params.uri_replacement(url, param_name, find_this, false);
18809 }
18810 {
18811 let to_remove = ["destinationFolder", "sourceFolder", "bucket"];
18812 params.remove_params(&to_remove);
18813 }
18814
18815 let url = params.parse_with_url(&url);
18816
18817 loop {
18818 let token = match self
18819 .hub
18820 .auth
18821 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18822 .await
18823 {
18824 Ok(token) => token,
18825 Err(e) => match dlg.token(e) {
18826 Ok(token) => token,
18827 Err(e) => {
18828 dlg.finished(false);
18829 return Err(common::Error::MissingToken(e));
18830 }
18831 },
18832 };
18833 let mut req_result = {
18834 let client = &self.hub.client;
18835 dlg.pre_request();
18836 let mut req_builder = hyper::Request::builder()
18837 .method(hyper::Method::POST)
18838 .uri(url.as_str())
18839 .header(USER_AGENT, self.hub._user_agent.clone());
18840
18841 if let Some(token) = token.as_ref() {
18842 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18843 }
18844
18845 let request = req_builder
18846 .header(CONTENT_LENGTH, 0_u64)
18847 .body(common::to_body::<String>(None));
18848
18849 client.request(request.unwrap()).await
18850 };
18851
18852 match req_result {
18853 Err(err) => {
18854 if let common::Retry::After(d) = dlg.http_error(&err) {
18855 sleep(d).await;
18856 continue;
18857 }
18858 dlg.finished(false);
18859 return Err(common::Error::HttpError(err));
18860 }
18861 Ok(res) => {
18862 let (mut parts, body) = res.into_parts();
18863 let mut body = common::Body::new(body);
18864 if !parts.status.is_success() {
18865 let bytes = common::to_bytes(body).await.unwrap_or_default();
18866 let error = serde_json::from_str(&common::to_string(&bytes));
18867 let response = common::to_response(parts, bytes.into());
18868
18869 if let common::Retry::After(d) =
18870 dlg.http_failure(&response, error.as_ref().ok())
18871 {
18872 sleep(d).await;
18873 continue;
18874 }
18875
18876 dlg.finished(false);
18877
18878 return Err(match error {
18879 Ok(value) => common::Error::BadRequest(value),
18880 _ => common::Error::Failure(response),
18881 });
18882 }
18883 let response = {
18884 let bytes = common::to_bytes(body).await.unwrap_or_default();
18885 let encoded = common::to_string(&bytes);
18886 match serde_json::from_str(&encoded) {
18887 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18888 Err(error) => {
18889 dlg.response_json_decode_error(&encoded, &error);
18890 return Err(common::Error::JsonDecodeError(
18891 encoded.to_string(),
18892 error,
18893 ));
18894 }
18895 }
18896 };
18897
18898 dlg.finished(true);
18899 return Ok(response);
18900 }
18901 }
18902 }
18903 }
18904
18905 /// Name of the bucket in which the folders are in.
18906 ///
18907 /// Sets the *bucket* path property to the given value.
18908 ///
18909 /// Even though the property as already been set when instantiating this call,
18910 /// we provide this method for API completeness.
18911 pub fn bucket(mut self, new_value: &str) -> FolderRenameCall<'a, C> {
18912 self._bucket = new_value.to_string();
18913 self
18914 }
18915 /// Name of the source folder.
18916 ///
18917 /// Sets the *source folder* path property to the given value.
18918 ///
18919 /// Even though the property as already been set when instantiating this call,
18920 /// we provide this method for API completeness.
18921 pub fn source_folder(mut self, new_value: &str) -> FolderRenameCall<'a, C> {
18922 self._source_folder = new_value.to_string();
18923 self
18924 }
18925 /// Name of the destination folder.
18926 ///
18927 /// Sets the *destination folder* path property to the given value.
18928 ///
18929 /// Even though the property as already been set when instantiating this call,
18930 /// we provide this method for API completeness.
18931 pub fn destination_folder(mut self, new_value: &str) -> FolderRenameCall<'a, C> {
18932 self._destination_folder = new_value.to_string();
18933 self
18934 }
18935 /// Makes the operation conditional on whether the source object's current metageneration does not match the given value.
18936 ///
18937 /// Sets the *if source metageneration not match* query property to the given value.
18938 pub fn if_source_metageneration_not_match(mut self, new_value: i64) -> FolderRenameCall<'a, C> {
18939 self._if_source_metageneration_not_match = Some(new_value);
18940 self
18941 }
18942 /// Makes the operation conditional on whether the source object's current metageneration matches the given value.
18943 ///
18944 /// Sets the *if source metageneration match* query property to the given value.
18945 pub fn if_source_metageneration_match(mut self, new_value: i64) -> FolderRenameCall<'a, C> {
18946 self._if_source_metageneration_match = Some(new_value);
18947 self
18948 }
18949 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18950 /// while executing the actual API request.
18951 ///
18952 /// ````text
18953 /// It should be used to handle progress information, and to implement a certain level of resilience.
18954 /// ````
18955 ///
18956 /// Sets the *delegate* property to the given value.
18957 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FolderRenameCall<'a, C> {
18958 self._delegate = Some(new_value);
18959 self
18960 }
18961
18962 /// Set any additional parameter of the query string used in the request.
18963 /// It should be used to set parameters which are not yet available through their own
18964 /// setters.
18965 ///
18966 /// Please note that this method must not be used to set any of the known parameters
18967 /// which have their own setter method. If done anyway, the request will fail.
18968 ///
18969 /// # Additional Parameters
18970 ///
18971 /// * *alt* (query-string) - Data format for the response.
18972 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18973 /// * *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.
18974 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18975 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18976 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18977 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
18978 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18979 pub fn param<T>(mut self, name: T, value: T) -> FolderRenameCall<'a, C>
18980 where
18981 T: AsRef<str>,
18982 {
18983 self._additional_params
18984 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18985 self
18986 }
18987
18988 /// Identifies the authorization scope for the method you are building.
18989 ///
18990 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18991 /// [`Scope::DevstorageReadWrite`].
18992 ///
18993 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18994 /// tokens for more than one scope.
18995 ///
18996 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18997 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18998 /// sufficient, a read-write scope will do as well.
18999 pub fn add_scope<St>(mut self, scope: St) -> FolderRenameCall<'a, C>
19000 where
19001 St: AsRef<str>,
19002 {
19003 self._scopes.insert(String::from(scope.as_ref()));
19004 self
19005 }
19006 /// Identifies the authorization scope(s) for the method you are building.
19007 ///
19008 /// See [`Self::add_scope()`] for details.
19009 pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderRenameCall<'a, C>
19010 where
19011 I: IntoIterator<Item = St>,
19012 St: AsRef<str>,
19013 {
19014 self._scopes
19015 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19016 self
19017 }
19018
19019 /// Removes all scopes, and no default scope will be used either.
19020 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19021 /// for details).
19022 pub fn clear_scopes(mut self) -> FolderRenameCall<'a, C> {
19023 self._scopes.clear();
19024 self
19025 }
19026}
19027
19028/// Permanently deletes a managed folder.
19029///
19030/// A builder for the *delete* method supported by a *managedFolder* resource.
19031/// It is not used directly, but through a [`ManagedFolderMethods`] instance.
19032///
19033/// # Example
19034///
19035/// Instantiate a resource method builder
19036///
19037/// ```test_harness,no_run
19038/// # extern crate hyper;
19039/// # extern crate hyper_rustls;
19040/// # extern crate google_storage1 as storage1;
19041/// # async fn dox() {
19042/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19043///
19044/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19045/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19046/// # .with_native_roots()
19047/// # .unwrap()
19048/// # .https_only()
19049/// # .enable_http2()
19050/// # .build();
19051///
19052/// # let executor = hyper_util::rt::TokioExecutor::new();
19053/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19054/// # secret,
19055/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19056/// # yup_oauth2::client::CustomHyperClientBuilder::from(
19057/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
19058/// # ),
19059/// # ).build().await.unwrap();
19060///
19061/// # let client = hyper_util::client::legacy::Client::builder(
19062/// # hyper_util::rt::TokioExecutor::new()
19063/// # )
19064/// # .build(
19065/// # hyper_rustls::HttpsConnectorBuilder::new()
19066/// # .with_native_roots()
19067/// # .unwrap()
19068/// # .https_or_http()
19069/// # .enable_http2()
19070/// # .build()
19071/// # );
19072/// # let mut hub = Storage::new(client, auth);
19073/// // You can configure optional parameters by calling the respective setters at will, and
19074/// // execute the final call using `doit()`.
19075/// // Values shown here are possibly random and not representative !
19076/// let result = hub.managed_folders().delete("bucket", "managedFolder")
19077/// .if_metageneration_not_match(-22)
19078/// .if_metageneration_match(-48)
19079/// .allow_non_empty(false)
19080/// .doit().await;
19081/// # }
19082/// ```
19083pub struct ManagedFolderDeleteCall<'a, C>
19084where
19085 C: 'a,
19086{
19087 hub: &'a Storage<C>,
19088 _bucket: String,
19089 _managed_folder: String,
19090 _if_metageneration_not_match: Option<i64>,
19091 _if_metageneration_match: Option<i64>,
19092 _allow_non_empty: Option<bool>,
19093 _delegate: Option<&'a mut dyn common::Delegate>,
19094 _additional_params: HashMap<String, String>,
19095 _scopes: BTreeSet<String>,
19096}
19097
19098impl<'a, C> common::CallBuilder for ManagedFolderDeleteCall<'a, C> {}
19099
19100impl<'a, C> ManagedFolderDeleteCall<'a, C>
19101where
19102 C: common::Connector,
19103{
19104 /// Perform the operation you have build so far.
19105 pub async fn doit(mut self) -> common::Result<common::Response> {
19106 use std::borrow::Cow;
19107 use std::io::{Read, Seek};
19108
19109 use common::{url::Params, ToParts};
19110 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19111
19112 let mut dd = common::DefaultDelegate;
19113 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19114 dlg.begin(common::MethodInfo {
19115 id: "storage.managedFolders.delete",
19116 http_method: hyper::Method::DELETE,
19117 });
19118
19119 for &field in [
19120 "bucket",
19121 "managedFolder",
19122 "ifMetagenerationNotMatch",
19123 "ifMetagenerationMatch",
19124 "allowNonEmpty",
19125 ]
19126 .iter()
19127 {
19128 if self._additional_params.contains_key(field) {
19129 dlg.finished(false);
19130 return Err(common::Error::FieldClash(field));
19131 }
19132 }
19133
19134 let mut params = Params::with_capacity(6 + self._additional_params.len());
19135 params.push("bucket", self._bucket);
19136 params.push("managedFolder", self._managed_folder);
19137 if let Some(value) = self._if_metageneration_not_match.as_ref() {
19138 params.push("ifMetagenerationNotMatch", value.to_string());
19139 }
19140 if let Some(value) = self._if_metageneration_match.as_ref() {
19141 params.push("ifMetagenerationMatch", value.to_string());
19142 }
19143 if let Some(value) = self._allow_non_empty.as_ref() {
19144 params.push("allowNonEmpty", value.to_string());
19145 }
19146
19147 params.extend(self._additional_params.iter());
19148
19149 let mut url = self.hub._base_url.clone() + "b/{bucket}/managedFolders/{managedFolder}";
19150 if self._scopes.is_empty() {
19151 self._scopes
19152 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
19153 }
19154
19155 #[allow(clippy::single_element_loop)]
19156 for &(find_this, param_name) in
19157 [("{bucket}", "bucket"), ("{managedFolder}", "managedFolder")].iter()
19158 {
19159 url = params.uri_replacement(url, param_name, find_this, false);
19160 }
19161 {
19162 let to_remove = ["managedFolder", "bucket"];
19163 params.remove_params(&to_remove);
19164 }
19165
19166 let url = params.parse_with_url(&url);
19167
19168 loop {
19169 let token = match self
19170 .hub
19171 .auth
19172 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19173 .await
19174 {
19175 Ok(token) => token,
19176 Err(e) => match dlg.token(e) {
19177 Ok(token) => token,
19178 Err(e) => {
19179 dlg.finished(false);
19180 return Err(common::Error::MissingToken(e));
19181 }
19182 },
19183 };
19184 let mut req_result = {
19185 let client = &self.hub.client;
19186 dlg.pre_request();
19187 let mut req_builder = hyper::Request::builder()
19188 .method(hyper::Method::DELETE)
19189 .uri(url.as_str())
19190 .header(USER_AGENT, self.hub._user_agent.clone());
19191
19192 if let Some(token) = token.as_ref() {
19193 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19194 }
19195
19196 let request = req_builder
19197 .header(CONTENT_LENGTH, 0_u64)
19198 .body(common::to_body::<String>(None));
19199
19200 client.request(request.unwrap()).await
19201 };
19202
19203 match req_result {
19204 Err(err) => {
19205 if let common::Retry::After(d) = dlg.http_error(&err) {
19206 sleep(d).await;
19207 continue;
19208 }
19209 dlg.finished(false);
19210 return Err(common::Error::HttpError(err));
19211 }
19212 Ok(res) => {
19213 let (mut parts, body) = res.into_parts();
19214 let mut body = common::Body::new(body);
19215 if !parts.status.is_success() {
19216 let bytes = common::to_bytes(body).await.unwrap_or_default();
19217 let error = serde_json::from_str(&common::to_string(&bytes));
19218 let response = common::to_response(parts, bytes.into());
19219
19220 if let common::Retry::After(d) =
19221 dlg.http_failure(&response, error.as_ref().ok())
19222 {
19223 sleep(d).await;
19224 continue;
19225 }
19226
19227 dlg.finished(false);
19228
19229 return Err(match error {
19230 Ok(value) => common::Error::BadRequest(value),
19231 _ => common::Error::Failure(response),
19232 });
19233 }
19234 let response = common::Response::from_parts(parts, body);
19235
19236 dlg.finished(true);
19237 return Ok(response);
19238 }
19239 }
19240 }
19241 }
19242
19243 /// Name of the bucket containing the managed folder.
19244 ///
19245 /// Sets the *bucket* path property to the given value.
19246 ///
19247 /// Even though the property as already been set when instantiating this call,
19248 /// we provide this method for API completeness.
19249 pub fn bucket(mut self, new_value: &str) -> ManagedFolderDeleteCall<'a, C> {
19250 self._bucket = new_value.to_string();
19251 self
19252 }
19253 /// The managed folder name/path.
19254 ///
19255 /// Sets the *managed folder* path property to the given value.
19256 ///
19257 /// Even though the property as already been set when instantiating this call,
19258 /// we provide this method for API completeness.
19259 pub fn managed_folder(mut self, new_value: &str) -> ManagedFolderDeleteCall<'a, C> {
19260 self._managed_folder = new_value.to_string();
19261 self
19262 }
19263 /// If set, only deletes the managed folder if its metageneration does not match this value.
19264 ///
19265 /// Sets the *if metageneration not match* query property to the given value.
19266 pub fn if_metageneration_not_match(mut self, new_value: i64) -> ManagedFolderDeleteCall<'a, C> {
19267 self._if_metageneration_not_match = Some(new_value);
19268 self
19269 }
19270 /// If set, only deletes the managed folder if its metageneration matches this value.
19271 ///
19272 /// Sets the *if metageneration match* query property to the given value.
19273 pub fn if_metageneration_match(mut self, new_value: i64) -> ManagedFolderDeleteCall<'a, C> {
19274 self._if_metageneration_match = Some(new_value);
19275 self
19276 }
19277 /// 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.
19278 ///
19279 /// Sets the *allow non empty* query property to the given value.
19280 pub fn allow_non_empty(mut self, new_value: bool) -> ManagedFolderDeleteCall<'a, C> {
19281 self._allow_non_empty = Some(new_value);
19282 self
19283 }
19284 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19285 /// while executing the actual API request.
19286 ///
19287 /// ````text
19288 /// It should be used to handle progress information, and to implement a certain level of resilience.
19289 /// ````
19290 ///
19291 /// Sets the *delegate* property to the given value.
19292 pub fn delegate(
19293 mut self,
19294 new_value: &'a mut dyn common::Delegate,
19295 ) -> ManagedFolderDeleteCall<'a, C> {
19296 self._delegate = Some(new_value);
19297 self
19298 }
19299
19300 /// Set any additional parameter of the query string used in the request.
19301 /// It should be used to set parameters which are not yet available through their own
19302 /// setters.
19303 ///
19304 /// Please note that this method must not be used to set any of the known parameters
19305 /// which have their own setter method. If done anyway, the request will fail.
19306 ///
19307 /// # Additional Parameters
19308 ///
19309 /// * *alt* (query-string) - Data format for the response.
19310 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19311 /// * *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.
19312 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19313 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19314 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19315 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
19316 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
19317 pub fn param<T>(mut self, name: T, value: T) -> ManagedFolderDeleteCall<'a, C>
19318 where
19319 T: AsRef<str>,
19320 {
19321 self._additional_params
19322 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19323 self
19324 }
19325
19326 /// Identifies the authorization scope for the method you are building.
19327 ///
19328 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19329 /// [`Scope::DevstorageReadWrite`].
19330 ///
19331 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19332 /// tokens for more than one scope.
19333 ///
19334 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19335 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19336 /// sufficient, a read-write scope will do as well.
19337 pub fn add_scope<St>(mut self, scope: St) -> ManagedFolderDeleteCall<'a, C>
19338 where
19339 St: AsRef<str>,
19340 {
19341 self._scopes.insert(String::from(scope.as_ref()));
19342 self
19343 }
19344 /// Identifies the authorization scope(s) for the method you are building.
19345 ///
19346 /// See [`Self::add_scope()`] for details.
19347 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedFolderDeleteCall<'a, C>
19348 where
19349 I: IntoIterator<Item = St>,
19350 St: AsRef<str>,
19351 {
19352 self._scopes
19353 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19354 self
19355 }
19356
19357 /// Removes all scopes, and no default scope will be used either.
19358 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19359 /// for details).
19360 pub fn clear_scopes(mut self) -> ManagedFolderDeleteCall<'a, C> {
19361 self._scopes.clear();
19362 self
19363 }
19364}
19365
19366/// Returns metadata of the specified managed folder.
19367///
19368/// A builder for the *get* method supported by a *managedFolder* resource.
19369/// It is not used directly, but through a [`ManagedFolderMethods`] instance.
19370///
19371/// # Example
19372///
19373/// Instantiate a resource method builder
19374///
19375/// ```test_harness,no_run
19376/// # extern crate hyper;
19377/// # extern crate hyper_rustls;
19378/// # extern crate google_storage1 as storage1;
19379/// # async fn dox() {
19380/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19381///
19382/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19383/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19384/// # .with_native_roots()
19385/// # .unwrap()
19386/// # .https_only()
19387/// # .enable_http2()
19388/// # .build();
19389///
19390/// # let executor = hyper_util::rt::TokioExecutor::new();
19391/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19392/// # secret,
19393/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19394/// # yup_oauth2::client::CustomHyperClientBuilder::from(
19395/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
19396/// # ),
19397/// # ).build().await.unwrap();
19398///
19399/// # let client = hyper_util::client::legacy::Client::builder(
19400/// # hyper_util::rt::TokioExecutor::new()
19401/// # )
19402/// # .build(
19403/// # hyper_rustls::HttpsConnectorBuilder::new()
19404/// # .with_native_roots()
19405/// # .unwrap()
19406/// # .https_or_http()
19407/// # .enable_http2()
19408/// # .build()
19409/// # );
19410/// # let mut hub = Storage::new(client, auth);
19411/// // You can configure optional parameters by calling the respective setters at will, and
19412/// // execute the final call using `doit()`.
19413/// // Values shown here are possibly random and not representative !
19414/// let result = hub.managed_folders().get("bucket", "managedFolder")
19415/// .if_metageneration_not_match(-22)
19416/// .if_metageneration_match(-12)
19417/// .doit().await;
19418/// # }
19419/// ```
19420pub struct ManagedFolderGetCall<'a, C>
19421where
19422 C: 'a,
19423{
19424 hub: &'a Storage<C>,
19425 _bucket: String,
19426 _managed_folder: String,
19427 _if_metageneration_not_match: Option<i64>,
19428 _if_metageneration_match: Option<i64>,
19429 _delegate: Option<&'a mut dyn common::Delegate>,
19430 _additional_params: HashMap<String, String>,
19431 _scopes: BTreeSet<String>,
19432}
19433
19434impl<'a, C> common::CallBuilder for ManagedFolderGetCall<'a, C> {}
19435
19436impl<'a, C> ManagedFolderGetCall<'a, C>
19437where
19438 C: common::Connector,
19439{
19440 /// Perform the operation you have build so far.
19441 pub async fn doit(mut self) -> common::Result<(common::Response, ManagedFolder)> {
19442 use std::borrow::Cow;
19443 use std::io::{Read, Seek};
19444
19445 use common::{url::Params, ToParts};
19446 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19447
19448 let mut dd = common::DefaultDelegate;
19449 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19450 dlg.begin(common::MethodInfo {
19451 id: "storage.managedFolders.get",
19452 http_method: hyper::Method::GET,
19453 });
19454
19455 for &field in [
19456 "alt",
19457 "bucket",
19458 "managedFolder",
19459 "ifMetagenerationNotMatch",
19460 "ifMetagenerationMatch",
19461 ]
19462 .iter()
19463 {
19464 if self._additional_params.contains_key(field) {
19465 dlg.finished(false);
19466 return Err(common::Error::FieldClash(field));
19467 }
19468 }
19469
19470 let mut params = Params::with_capacity(6 + self._additional_params.len());
19471 params.push("bucket", self._bucket);
19472 params.push("managedFolder", self._managed_folder);
19473 if let Some(value) = self._if_metageneration_not_match.as_ref() {
19474 params.push("ifMetagenerationNotMatch", value.to_string());
19475 }
19476 if let Some(value) = self._if_metageneration_match.as_ref() {
19477 params.push("ifMetagenerationMatch", value.to_string());
19478 }
19479
19480 params.extend(self._additional_params.iter());
19481
19482 params.push("alt", "json");
19483 let mut url = self.hub._base_url.clone() + "b/{bucket}/managedFolders/{managedFolder}";
19484 if self._scopes.is_empty() {
19485 self._scopes
19486 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
19487 }
19488
19489 #[allow(clippy::single_element_loop)]
19490 for &(find_this, param_name) in
19491 [("{bucket}", "bucket"), ("{managedFolder}", "managedFolder")].iter()
19492 {
19493 url = params.uri_replacement(url, param_name, find_this, false);
19494 }
19495 {
19496 let to_remove = ["managedFolder", "bucket"];
19497 params.remove_params(&to_remove);
19498 }
19499
19500 let url = params.parse_with_url(&url);
19501
19502 loop {
19503 let token = match self
19504 .hub
19505 .auth
19506 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19507 .await
19508 {
19509 Ok(token) => token,
19510 Err(e) => match dlg.token(e) {
19511 Ok(token) => token,
19512 Err(e) => {
19513 dlg.finished(false);
19514 return Err(common::Error::MissingToken(e));
19515 }
19516 },
19517 };
19518 let mut req_result = {
19519 let client = &self.hub.client;
19520 dlg.pre_request();
19521 let mut req_builder = hyper::Request::builder()
19522 .method(hyper::Method::GET)
19523 .uri(url.as_str())
19524 .header(USER_AGENT, self.hub._user_agent.clone());
19525
19526 if let Some(token) = token.as_ref() {
19527 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19528 }
19529
19530 let request = req_builder
19531 .header(CONTENT_LENGTH, 0_u64)
19532 .body(common::to_body::<String>(None));
19533
19534 client.request(request.unwrap()).await
19535 };
19536
19537 match req_result {
19538 Err(err) => {
19539 if let common::Retry::After(d) = dlg.http_error(&err) {
19540 sleep(d).await;
19541 continue;
19542 }
19543 dlg.finished(false);
19544 return Err(common::Error::HttpError(err));
19545 }
19546 Ok(res) => {
19547 let (mut parts, body) = res.into_parts();
19548 let mut body = common::Body::new(body);
19549 if !parts.status.is_success() {
19550 let bytes = common::to_bytes(body).await.unwrap_or_default();
19551 let error = serde_json::from_str(&common::to_string(&bytes));
19552 let response = common::to_response(parts, bytes.into());
19553
19554 if let common::Retry::After(d) =
19555 dlg.http_failure(&response, error.as_ref().ok())
19556 {
19557 sleep(d).await;
19558 continue;
19559 }
19560
19561 dlg.finished(false);
19562
19563 return Err(match error {
19564 Ok(value) => common::Error::BadRequest(value),
19565 _ => common::Error::Failure(response),
19566 });
19567 }
19568 let response = {
19569 let bytes = common::to_bytes(body).await.unwrap_or_default();
19570 let encoded = common::to_string(&bytes);
19571 match serde_json::from_str(&encoded) {
19572 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19573 Err(error) => {
19574 dlg.response_json_decode_error(&encoded, &error);
19575 return Err(common::Error::JsonDecodeError(
19576 encoded.to_string(),
19577 error,
19578 ));
19579 }
19580 }
19581 };
19582
19583 dlg.finished(true);
19584 return Ok(response);
19585 }
19586 }
19587 }
19588 }
19589
19590 /// Name of the bucket containing the managed folder.
19591 ///
19592 /// Sets the *bucket* path property to the given value.
19593 ///
19594 /// Even though the property as already been set when instantiating this call,
19595 /// we provide this method for API completeness.
19596 pub fn bucket(mut self, new_value: &str) -> ManagedFolderGetCall<'a, C> {
19597 self._bucket = new_value.to_string();
19598 self
19599 }
19600 /// The managed folder name/path.
19601 ///
19602 /// Sets the *managed folder* path property to the given value.
19603 ///
19604 /// Even though the property as already been set when instantiating this call,
19605 /// we provide this method for API completeness.
19606 pub fn managed_folder(mut self, new_value: &str) -> ManagedFolderGetCall<'a, C> {
19607 self._managed_folder = new_value.to_string();
19608 self
19609 }
19610 /// Makes the return of the managed folder metadata conditional on whether the managed folder's current metageneration does not match the given value.
19611 ///
19612 /// Sets the *if metageneration not match* query property to the given value.
19613 pub fn if_metageneration_not_match(mut self, new_value: i64) -> ManagedFolderGetCall<'a, C> {
19614 self._if_metageneration_not_match = Some(new_value);
19615 self
19616 }
19617 /// Makes the return of the managed folder metadata conditional on whether the managed folder's current metageneration matches the given value.
19618 ///
19619 /// Sets the *if metageneration match* query property to the given value.
19620 pub fn if_metageneration_match(mut self, new_value: i64) -> ManagedFolderGetCall<'a, C> {
19621 self._if_metageneration_match = Some(new_value);
19622 self
19623 }
19624 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19625 /// while executing the actual API request.
19626 ///
19627 /// ````text
19628 /// It should be used to handle progress information, and to implement a certain level of resilience.
19629 /// ````
19630 ///
19631 /// Sets the *delegate* property to the given value.
19632 pub fn delegate(
19633 mut self,
19634 new_value: &'a mut dyn common::Delegate,
19635 ) -> ManagedFolderGetCall<'a, C> {
19636 self._delegate = Some(new_value);
19637 self
19638 }
19639
19640 /// Set any additional parameter of the query string used in the request.
19641 /// It should be used to set parameters which are not yet available through their own
19642 /// setters.
19643 ///
19644 /// Please note that this method must not be used to set any of the known parameters
19645 /// which have their own setter method. If done anyway, the request will fail.
19646 ///
19647 /// # Additional Parameters
19648 ///
19649 /// * *alt* (query-string) - Data format for the response.
19650 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19651 /// * *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.
19652 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19653 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19654 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19655 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
19656 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
19657 pub fn param<T>(mut self, name: T, value: T) -> ManagedFolderGetCall<'a, C>
19658 where
19659 T: AsRef<str>,
19660 {
19661 self._additional_params
19662 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19663 self
19664 }
19665
19666 /// Identifies the authorization scope for the method you are building.
19667 ///
19668 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19669 /// [`Scope::DevstorageReadOnly`].
19670 ///
19671 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19672 /// tokens for more than one scope.
19673 ///
19674 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19675 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19676 /// sufficient, a read-write scope will do as well.
19677 pub fn add_scope<St>(mut self, scope: St) -> ManagedFolderGetCall<'a, C>
19678 where
19679 St: AsRef<str>,
19680 {
19681 self._scopes.insert(String::from(scope.as_ref()));
19682 self
19683 }
19684 /// Identifies the authorization scope(s) for the method you are building.
19685 ///
19686 /// See [`Self::add_scope()`] for details.
19687 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedFolderGetCall<'a, C>
19688 where
19689 I: IntoIterator<Item = St>,
19690 St: AsRef<str>,
19691 {
19692 self._scopes
19693 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19694 self
19695 }
19696
19697 /// Removes all scopes, and no default scope will be used either.
19698 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19699 /// for details).
19700 pub fn clear_scopes(mut self) -> ManagedFolderGetCall<'a, C> {
19701 self._scopes.clear();
19702 self
19703 }
19704}
19705
19706/// Returns an IAM policy for the specified managed folder.
19707///
19708/// A builder for the *getIamPolicy* method supported by a *managedFolder* resource.
19709/// It is not used directly, but through a [`ManagedFolderMethods`] instance.
19710///
19711/// # Example
19712///
19713/// Instantiate a resource method builder
19714///
19715/// ```test_harness,no_run
19716/// # extern crate hyper;
19717/// # extern crate hyper_rustls;
19718/// # extern crate google_storage1 as storage1;
19719/// # async fn dox() {
19720/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19721///
19722/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19723/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19724/// # .with_native_roots()
19725/// # .unwrap()
19726/// # .https_only()
19727/// # .enable_http2()
19728/// # .build();
19729///
19730/// # let executor = hyper_util::rt::TokioExecutor::new();
19731/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19732/// # secret,
19733/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19734/// # yup_oauth2::client::CustomHyperClientBuilder::from(
19735/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
19736/// # ),
19737/// # ).build().await.unwrap();
19738///
19739/// # let client = hyper_util::client::legacy::Client::builder(
19740/// # hyper_util::rt::TokioExecutor::new()
19741/// # )
19742/// # .build(
19743/// # hyper_rustls::HttpsConnectorBuilder::new()
19744/// # .with_native_roots()
19745/// # .unwrap()
19746/// # .https_or_http()
19747/// # .enable_http2()
19748/// # .build()
19749/// # );
19750/// # let mut hub = Storage::new(client, auth);
19751/// // You can configure optional parameters by calling the respective setters at will, and
19752/// // execute the final call using `doit()`.
19753/// // Values shown here are possibly random and not representative !
19754/// let result = hub.managed_folders().get_iam_policy("bucket", "managedFolder")
19755/// .user_project("consetetur")
19756/// .options_requested_policy_version(-98)
19757/// .doit().await;
19758/// # }
19759/// ```
19760pub struct ManagedFolderGetIamPolicyCall<'a, C>
19761where
19762 C: 'a,
19763{
19764 hub: &'a Storage<C>,
19765 _bucket: String,
19766 _managed_folder: String,
19767 _user_project: Option<String>,
19768 _options_requested_policy_version: Option<i32>,
19769 _delegate: Option<&'a mut dyn common::Delegate>,
19770 _additional_params: HashMap<String, String>,
19771 _scopes: BTreeSet<String>,
19772}
19773
19774impl<'a, C> common::CallBuilder for ManagedFolderGetIamPolicyCall<'a, C> {}
19775
19776impl<'a, C> ManagedFolderGetIamPolicyCall<'a, C>
19777where
19778 C: common::Connector,
19779{
19780 /// Perform the operation you have build so far.
19781 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
19782 use std::borrow::Cow;
19783 use std::io::{Read, Seek};
19784
19785 use common::{url::Params, ToParts};
19786 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19787
19788 let mut dd = common::DefaultDelegate;
19789 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19790 dlg.begin(common::MethodInfo {
19791 id: "storage.managedFolders.getIamPolicy",
19792 http_method: hyper::Method::GET,
19793 });
19794
19795 for &field in [
19796 "alt",
19797 "bucket",
19798 "managedFolder",
19799 "userProject",
19800 "optionsRequestedPolicyVersion",
19801 ]
19802 .iter()
19803 {
19804 if self._additional_params.contains_key(field) {
19805 dlg.finished(false);
19806 return Err(common::Error::FieldClash(field));
19807 }
19808 }
19809
19810 let mut params = Params::with_capacity(6 + self._additional_params.len());
19811 params.push("bucket", self._bucket);
19812 params.push("managedFolder", self._managed_folder);
19813 if let Some(value) = self._user_project.as_ref() {
19814 params.push("userProject", value);
19815 }
19816 if let Some(value) = self._options_requested_policy_version.as_ref() {
19817 params.push("optionsRequestedPolicyVersion", value.to_string());
19818 }
19819
19820 params.extend(self._additional_params.iter());
19821
19822 params.push("alt", "json");
19823 let mut url = self.hub._base_url.clone() + "b/{bucket}/managedFolders/{managedFolder}/iam";
19824 if self._scopes.is_empty() {
19825 self._scopes
19826 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
19827 }
19828
19829 #[allow(clippy::single_element_loop)]
19830 for &(find_this, param_name) in
19831 [("{bucket}", "bucket"), ("{managedFolder}", "managedFolder")].iter()
19832 {
19833 url = params.uri_replacement(url, param_name, find_this, false);
19834 }
19835 {
19836 let to_remove = ["managedFolder", "bucket"];
19837 params.remove_params(&to_remove);
19838 }
19839
19840 let url = params.parse_with_url(&url);
19841
19842 loop {
19843 let token = match self
19844 .hub
19845 .auth
19846 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19847 .await
19848 {
19849 Ok(token) => token,
19850 Err(e) => match dlg.token(e) {
19851 Ok(token) => token,
19852 Err(e) => {
19853 dlg.finished(false);
19854 return Err(common::Error::MissingToken(e));
19855 }
19856 },
19857 };
19858 let mut req_result = {
19859 let client = &self.hub.client;
19860 dlg.pre_request();
19861 let mut req_builder = hyper::Request::builder()
19862 .method(hyper::Method::GET)
19863 .uri(url.as_str())
19864 .header(USER_AGENT, self.hub._user_agent.clone());
19865
19866 if let Some(token) = token.as_ref() {
19867 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19868 }
19869
19870 let request = req_builder
19871 .header(CONTENT_LENGTH, 0_u64)
19872 .body(common::to_body::<String>(None));
19873
19874 client.request(request.unwrap()).await
19875 };
19876
19877 match req_result {
19878 Err(err) => {
19879 if let common::Retry::After(d) = dlg.http_error(&err) {
19880 sleep(d).await;
19881 continue;
19882 }
19883 dlg.finished(false);
19884 return Err(common::Error::HttpError(err));
19885 }
19886 Ok(res) => {
19887 let (mut parts, body) = res.into_parts();
19888 let mut body = common::Body::new(body);
19889 if !parts.status.is_success() {
19890 let bytes = common::to_bytes(body).await.unwrap_or_default();
19891 let error = serde_json::from_str(&common::to_string(&bytes));
19892 let response = common::to_response(parts, bytes.into());
19893
19894 if let common::Retry::After(d) =
19895 dlg.http_failure(&response, error.as_ref().ok())
19896 {
19897 sleep(d).await;
19898 continue;
19899 }
19900
19901 dlg.finished(false);
19902
19903 return Err(match error {
19904 Ok(value) => common::Error::BadRequest(value),
19905 _ => common::Error::Failure(response),
19906 });
19907 }
19908 let response = {
19909 let bytes = common::to_bytes(body).await.unwrap_or_default();
19910 let encoded = common::to_string(&bytes);
19911 match serde_json::from_str(&encoded) {
19912 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19913 Err(error) => {
19914 dlg.response_json_decode_error(&encoded, &error);
19915 return Err(common::Error::JsonDecodeError(
19916 encoded.to_string(),
19917 error,
19918 ));
19919 }
19920 }
19921 };
19922
19923 dlg.finished(true);
19924 return Ok(response);
19925 }
19926 }
19927 }
19928 }
19929
19930 /// Name of the bucket containing the managed folder.
19931 ///
19932 /// Sets the *bucket* path property to the given value.
19933 ///
19934 /// Even though the property as already been set when instantiating this call,
19935 /// we provide this method for API completeness.
19936 pub fn bucket(mut self, new_value: &str) -> ManagedFolderGetIamPolicyCall<'a, C> {
19937 self._bucket = new_value.to_string();
19938 self
19939 }
19940 /// The managed folder name/path.
19941 ///
19942 /// Sets the *managed folder* path property to the given value.
19943 ///
19944 /// Even though the property as already been set when instantiating this call,
19945 /// we provide this method for API completeness.
19946 pub fn managed_folder(mut self, new_value: &str) -> ManagedFolderGetIamPolicyCall<'a, C> {
19947 self._managed_folder = new_value.to_string();
19948 self
19949 }
19950 /// The project to be billed for this request. Required for Requester Pays buckets.
19951 ///
19952 /// Sets the *user project* query property to the given value.
19953 pub fn user_project(mut self, new_value: &str) -> ManagedFolderGetIamPolicyCall<'a, C> {
19954 self._user_project = Some(new_value.to_string());
19955 self
19956 }
19957 /// 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.
19958 ///
19959 /// Sets the *options requested policy version* query property to the given value.
19960 pub fn options_requested_policy_version(
19961 mut self,
19962 new_value: i32,
19963 ) -> ManagedFolderGetIamPolicyCall<'a, C> {
19964 self._options_requested_policy_version = Some(new_value);
19965 self
19966 }
19967 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19968 /// while executing the actual API request.
19969 ///
19970 /// ````text
19971 /// It should be used to handle progress information, and to implement a certain level of resilience.
19972 /// ````
19973 ///
19974 /// Sets the *delegate* property to the given value.
19975 pub fn delegate(
19976 mut self,
19977 new_value: &'a mut dyn common::Delegate,
19978 ) -> ManagedFolderGetIamPolicyCall<'a, C> {
19979 self._delegate = Some(new_value);
19980 self
19981 }
19982
19983 /// Set any additional parameter of the query string used in the request.
19984 /// It should be used to set parameters which are not yet available through their own
19985 /// setters.
19986 ///
19987 /// Please note that this method must not be used to set any of the known parameters
19988 /// which have their own setter method. If done anyway, the request will fail.
19989 ///
19990 /// # Additional Parameters
19991 ///
19992 /// * *alt* (query-string) - Data format for the response.
19993 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19994 /// * *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.
19995 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19996 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19997 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19998 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
19999 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
20000 pub fn param<T>(mut self, name: T, value: T) -> ManagedFolderGetIamPolicyCall<'a, C>
20001 where
20002 T: AsRef<str>,
20003 {
20004 self._additional_params
20005 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20006 self
20007 }
20008
20009 /// Identifies the authorization scope for the method you are building.
20010 ///
20011 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20012 /// [`Scope::DevstorageReadOnly`].
20013 ///
20014 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20015 /// tokens for more than one scope.
20016 ///
20017 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20018 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20019 /// sufficient, a read-write scope will do as well.
20020 pub fn add_scope<St>(mut self, scope: St) -> ManagedFolderGetIamPolicyCall<'a, C>
20021 where
20022 St: AsRef<str>,
20023 {
20024 self._scopes.insert(String::from(scope.as_ref()));
20025 self
20026 }
20027 /// Identifies the authorization scope(s) for the method you are building.
20028 ///
20029 /// See [`Self::add_scope()`] for details.
20030 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedFolderGetIamPolicyCall<'a, C>
20031 where
20032 I: IntoIterator<Item = St>,
20033 St: AsRef<str>,
20034 {
20035 self._scopes
20036 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20037 self
20038 }
20039
20040 /// Removes all scopes, and no default scope will be used either.
20041 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20042 /// for details).
20043 pub fn clear_scopes(mut self) -> ManagedFolderGetIamPolicyCall<'a, C> {
20044 self._scopes.clear();
20045 self
20046 }
20047}
20048
20049/// Creates a new managed folder.
20050///
20051/// A builder for the *insert* method supported by a *managedFolder* resource.
20052/// It is not used directly, but through a [`ManagedFolderMethods`] instance.
20053///
20054/// # Example
20055///
20056/// Instantiate a resource method builder
20057///
20058/// ```test_harness,no_run
20059/// # extern crate hyper;
20060/// # extern crate hyper_rustls;
20061/// # extern crate google_storage1 as storage1;
20062/// use storage1::api::ManagedFolder;
20063/// # async fn dox() {
20064/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20065///
20066/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20067/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20068/// # .with_native_roots()
20069/// # .unwrap()
20070/// # .https_only()
20071/// # .enable_http2()
20072/// # .build();
20073///
20074/// # let executor = hyper_util::rt::TokioExecutor::new();
20075/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20076/// # secret,
20077/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20078/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20079/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20080/// # ),
20081/// # ).build().await.unwrap();
20082///
20083/// # let client = hyper_util::client::legacy::Client::builder(
20084/// # hyper_util::rt::TokioExecutor::new()
20085/// # )
20086/// # .build(
20087/// # hyper_rustls::HttpsConnectorBuilder::new()
20088/// # .with_native_roots()
20089/// # .unwrap()
20090/// # .https_or_http()
20091/// # .enable_http2()
20092/// # .build()
20093/// # );
20094/// # let mut hub = Storage::new(client, auth);
20095/// // As the method needs a request, you would usually fill it with the desired information
20096/// // into the respective structure. Some of the parts shown here might not be applicable !
20097/// // Values shown here are possibly random and not representative !
20098/// let mut req = ManagedFolder::default();
20099///
20100/// // You can configure optional parameters by calling the respective setters at will, and
20101/// // execute the final call using `doit()`.
20102/// // Values shown here are possibly random and not representative !
20103/// let result = hub.managed_folders().insert(req, "bucket")
20104/// .doit().await;
20105/// # }
20106/// ```
20107pub struct ManagedFolderInsertCall<'a, C>
20108where
20109 C: 'a,
20110{
20111 hub: &'a Storage<C>,
20112 _request: ManagedFolder,
20113 _bucket: String,
20114 _delegate: Option<&'a mut dyn common::Delegate>,
20115 _additional_params: HashMap<String, String>,
20116 _scopes: BTreeSet<String>,
20117}
20118
20119impl<'a, C> common::CallBuilder for ManagedFolderInsertCall<'a, C> {}
20120
20121impl<'a, C> ManagedFolderInsertCall<'a, C>
20122where
20123 C: common::Connector,
20124{
20125 /// Perform the operation you have build so far.
20126 pub async fn doit(mut self) -> common::Result<(common::Response, ManagedFolder)> {
20127 use std::borrow::Cow;
20128 use std::io::{Read, Seek};
20129
20130 use common::{url::Params, ToParts};
20131 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20132
20133 let mut dd = common::DefaultDelegate;
20134 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20135 dlg.begin(common::MethodInfo {
20136 id: "storage.managedFolders.insert",
20137 http_method: hyper::Method::POST,
20138 });
20139
20140 for &field in ["alt", "bucket"].iter() {
20141 if self._additional_params.contains_key(field) {
20142 dlg.finished(false);
20143 return Err(common::Error::FieldClash(field));
20144 }
20145 }
20146
20147 let mut params = Params::with_capacity(4 + self._additional_params.len());
20148 params.push("bucket", self._bucket);
20149
20150 params.extend(self._additional_params.iter());
20151
20152 params.push("alt", "json");
20153 let mut url = self.hub._base_url.clone() + "b/{bucket}/managedFolders";
20154 if self._scopes.is_empty() {
20155 self._scopes
20156 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
20157 }
20158
20159 #[allow(clippy::single_element_loop)]
20160 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
20161 url = params.uri_replacement(url, param_name, find_this, false);
20162 }
20163 {
20164 let to_remove = ["bucket"];
20165 params.remove_params(&to_remove);
20166 }
20167
20168 let url = params.parse_with_url(&url);
20169
20170 let mut json_mime_type = mime::APPLICATION_JSON;
20171 let mut request_value_reader = {
20172 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20173 common::remove_json_null_values(&mut value);
20174 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20175 serde_json::to_writer(&mut dst, &value).unwrap();
20176 dst
20177 };
20178 let request_size = request_value_reader
20179 .seek(std::io::SeekFrom::End(0))
20180 .unwrap();
20181 request_value_reader
20182 .seek(std::io::SeekFrom::Start(0))
20183 .unwrap();
20184
20185 loop {
20186 let token = match self
20187 .hub
20188 .auth
20189 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20190 .await
20191 {
20192 Ok(token) => token,
20193 Err(e) => match dlg.token(e) {
20194 Ok(token) => token,
20195 Err(e) => {
20196 dlg.finished(false);
20197 return Err(common::Error::MissingToken(e));
20198 }
20199 },
20200 };
20201 request_value_reader
20202 .seek(std::io::SeekFrom::Start(0))
20203 .unwrap();
20204 let mut req_result = {
20205 let client = &self.hub.client;
20206 dlg.pre_request();
20207 let mut req_builder = hyper::Request::builder()
20208 .method(hyper::Method::POST)
20209 .uri(url.as_str())
20210 .header(USER_AGENT, self.hub._user_agent.clone());
20211
20212 if let Some(token) = token.as_ref() {
20213 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20214 }
20215
20216 let request = req_builder
20217 .header(CONTENT_TYPE, json_mime_type.to_string())
20218 .header(CONTENT_LENGTH, request_size as u64)
20219 .body(common::to_body(
20220 request_value_reader.get_ref().clone().into(),
20221 ));
20222
20223 client.request(request.unwrap()).await
20224 };
20225
20226 match req_result {
20227 Err(err) => {
20228 if let common::Retry::After(d) = dlg.http_error(&err) {
20229 sleep(d).await;
20230 continue;
20231 }
20232 dlg.finished(false);
20233 return Err(common::Error::HttpError(err));
20234 }
20235 Ok(res) => {
20236 let (mut parts, body) = res.into_parts();
20237 let mut body = common::Body::new(body);
20238 if !parts.status.is_success() {
20239 let bytes = common::to_bytes(body).await.unwrap_or_default();
20240 let error = serde_json::from_str(&common::to_string(&bytes));
20241 let response = common::to_response(parts, bytes.into());
20242
20243 if let common::Retry::After(d) =
20244 dlg.http_failure(&response, error.as_ref().ok())
20245 {
20246 sleep(d).await;
20247 continue;
20248 }
20249
20250 dlg.finished(false);
20251
20252 return Err(match error {
20253 Ok(value) => common::Error::BadRequest(value),
20254 _ => common::Error::Failure(response),
20255 });
20256 }
20257 let response = {
20258 let bytes = common::to_bytes(body).await.unwrap_or_default();
20259 let encoded = common::to_string(&bytes);
20260 match serde_json::from_str(&encoded) {
20261 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20262 Err(error) => {
20263 dlg.response_json_decode_error(&encoded, &error);
20264 return Err(common::Error::JsonDecodeError(
20265 encoded.to_string(),
20266 error,
20267 ));
20268 }
20269 }
20270 };
20271
20272 dlg.finished(true);
20273 return Ok(response);
20274 }
20275 }
20276 }
20277 }
20278
20279 ///
20280 /// Sets the *request* property to the given value.
20281 ///
20282 /// Even though the property as already been set when instantiating this call,
20283 /// we provide this method for API completeness.
20284 pub fn request(mut self, new_value: ManagedFolder) -> ManagedFolderInsertCall<'a, C> {
20285 self._request = new_value;
20286 self
20287 }
20288 /// Name of the bucket containing the managed folder.
20289 ///
20290 /// Sets the *bucket* path property to the given value.
20291 ///
20292 /// Even though the property as already been set when instantiating this call,
20293 /// we provide this method for API completeness.
20294 pub fn bucket(mut self, new_value: &str) -> ManagedFolderInsertCall<'a, C> {
20295 self._bucket = new_value.to_string();
20296 self
20297 }
20298 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20299 /// while executing the actual API request.
20300 ///
20301 /// ````text
20302 /// It should be used to handle progress information, and to implement a certain level of resilience.
20303 /// ````
20304 ///
20305 /// Sets the *delegate* property to the given value.
20306 pub fn delegate(
20307 mut self,
20308 new_value: &'a mut dyn common::Delegate,
20309 ) -> ManagedFolderInsertCall<'a, C> {
20310 self._delegate = Some(new_value);
20311 self
20312 }
20313
20314 /// Set any additional parameter of the query string used in the request.
20315 /// It should be used to set parameters which are not yet available through their own
20316 /// setters.
20317 ///
20318 /// Please note that this method must not be used to set any of the known parameters
20319 /// which have their own setter method. If done anyway, the request will fail.
20320 ///
20321 /// # Additional Parameters
20322 ///
20323 /// * *alt* (query-string) - Data format for the response.
20324 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20325 /// * *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.
20326 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20327 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20328 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
20329 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
20330 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
20331 pub fn param<T>(mut self, name: T, value: T) -> ManagedFolderInsertCall<'a, C>
20332 where
20333 T: AsRef<str>,
20334 {
20335 self._additional_params
20336 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20337 self
20338 }
20339
20340 /// Identifies the authorization scope for the method you are building.
20341 ///
20342 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20343 /// [`Scope::DevstorageReadWrite`].
20344 ///
20345 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20346 /// tokens for more than one scope.
20347 ///
20348 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20349 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20350 /// sufficient, a read-write scope will do as well.
20351 pub fn add_scope<St>(mut self, scope: St) -> ManagedFolderInsertCall<'a, C>
20352 where
20353 St: AsRef<str>,
20354 {
20355 self._scopes.insert(String::from(scope.as_ref()));
20356 self
20357 }
20358 /// Identifies the authorization scope(s) for the method you are building.
20359 ///
20360 /// See [`Self::add_scope()`] for details.
20361 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedFolderInsertCall<'a, C>
20362 where
20363 I: IntoIterator<Item = St>,
20364 St: AsRef<str>,
20365 {
20366 self._scopes
20367 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20368 self
20369 }
20370
20371 /// Removes all scopes, and no default scope will be used either.
20372 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20373 /// for details).
20374 pub fn clear_scopes(mut self) -> ManagedFolderInsertCall<'a, C> {
20375 self._scopes.clear();
20376 self
20377 }
20378}
20379
20380/// Lists managed folders in the given bucket.
20381///
20382/// A builder for the *list* method supported by a *managedFolder* resource.
20383/// It is not used directly, but through a [`ManagedFolderMethods`] instance.
20384///
20385/// # Example
20386///
20387/// Instantiate a resource method builder
20388///
20389/// ```test_harness,no_run
20390/// # extern crate hyper;
20391/// # extern crate hyper_rustls;
20392/// # extern crate google_storage1 as storage1;
20393/// # async fn dox() {
20394/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20395///
20396/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20397/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20398/// # .with_native_roots()
20399/// # .unwrap()
20400/// # .https_only()
20401/// # .enable_http2()
20402/// # .build();
20403///
20404/// # let executor = hyper_util::rt::TokioExecutor::new();
20405/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20406/// # secret,
20407/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20408/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20409/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20410/// # ),
20411/// # ).build().await.unwrap();
20412///
20413/// # let client = hyper_util::client::legacy::Client::builder(
20414/// # hyper_util::rt::TokioExecutor::new()
20415/// # )
20416/// # .build(
20417/// # hyper_rustls::HttpsConnectorBuilder::new()
20418/// # .with_native_roots()
20419/// # .unwrap()
20420/// # .https_or_http()
20421/// # .enable_http2()
20422/// # .build()
20423/// # );
20424/// # let mut hub = Storage::new(client, auth);
20425/// // You can configure optional parameters by calling the respective setters at will, and
20426/// // execute the final call using `doit()`.
20427/// // Values shown here are possibly random and not representative !
20428/// let result = hub.managed_folders().list("bucket")
20429/// .prefix("At")
20430/// .page_token("dolores")
20431/// .page_size(-46)
20432/// .doit().await;
20433/// # }
20434/// ```
20435pub struct ManagedFolderListCall<'a, C>
20436where
20437 C: 'a,
20438{
20439 hub: &'a Storage<C>,
20440 _bucket: String,
20441 _prefix: Option<String>,
20442 _page_token: Option<String>,
20443 _page_size: Option<i32>,
20444 _delegate: Option<&'a mut dyn common::Delegate>,
20445 _additional_params: HashMap<String, String>,
20446 _scopes: BTreeSet<String>,
20447}
20448
20449impl<'a, C> common::CallBuilder for ManagedFolderListCall<'a, C> {}
20450
20451impl<'a, C> ManagedFolderListCall<'a, C>
20452where
20453 C: common::Connector,
20454{
20455 /// Perform the operation you have build so far.
20456 pub async fn doit(mut self) -> common::Result<(common::Response, ManagedFolders)> {
20457 use std::borrow::Cow;
20458 use std::io::{Read, Seek};
20459
20460 use common::{url::Params, ToParts};
20461 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20462
20463 let mut dd = common::DefaultDelegate;
20464 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20465 dlg.begin(common::MethodInfo {
20466 id: "storage.managedFolders.list",
20467 http_method: hyper::Method::GET,
20468 });
20469
20470 for &field in ["alt", "bucket", "prefix", "pageToken", "pageSize"].iter() {
20471 if self._additional_params.contains_key(field) {
20472 dlg.finished(false);
20473 return Err(common::Error::FieldClash(field));
20474 }
20475 }
20476
20477 let mut params = Params::with_capacity(6 + self._additional_params.len());
20478 params.push("bucket", self._bucket);
20479 if let Some(value) = self._prefix.as_ref() {
20480 params.push("prefix", value);
20481 }
20482 if let Some(value) = self._page_token.as_ref() {
20483 params.push("pageToken", value);
20484 }
20485 if let Some(value) = self._page_size.as_ref() {
20486 params.push("pageSize", value.to_string());
20487 }
20488
20489 params.extend(self._additional_params.iter());
20490
20491 params.push("alt", "json");
20492 let mut url = self.hub._base_url.clone() + "b/{bucket}/managedFolders";
20493 if self._scopes.is_empty() {
20494 self._scopes
20495 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
20496 }
20497
20498 #[allow(clippy::single_element_loop)]
20499 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
20500 url = params.uri_replacement(url, param_name, find_this, false);
20501 }
20502 {
20503 let to_remove = ["bucket"];
20504 params.remove_params(&to_remove);
20505 }
20506
20507 let url = params.parse_with_url(&url);
20508
20509 loop {
20510 let token = match self
20511 .hub
20512 .auth
20513 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20514 .await
20515 {
20516 Ok(token) => token,
20517 Err(e) => match dlg.token(e) {
20518 Ok(token) => token,
20519 Err(e) => {
20520 dlg.finished(false);
20521 return Err(common::Error::MissingToken(e));
20522 }
20523 },
20524 };
20525 let mut req_result = {
20526 let client = &self.hub.client;
20527 dlg.pre_request();
20528 let mut req_builder = hyper::Request::builder()
20529 .method(hyper::Method::GET)
20530 .uri(url.as_str())
20531 .header(USER_AGENT, self.hub._user_agent.clone());
20532
20533 if let Some(token) = token.as_ref() {
20534 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20535 }
20536
20537 let request = req_builder
20538 .header(CONTENT_LENGTH, 0_u64)
20539 .body(common::to_body::<String>(None));
20540
20541 client.request(request.unwrap()).await
20542 };
20543
20544 match req_result {
20545 Err(err) => {
20546 if let common::Retry::After(d) = dlg.http_error(&err) {
20547 sleep(d).await;
20548 continue;
20549 }
20550 dlg.finished(false);
20551 return Err(common::Error::HttpError(err));
20552 }
20553 Ok(res) => {
20554 let (mut parts, body) = res.into_parts();
20555 let mut body = common::Body::new(body);
20556 if !parts.status.is_success() {
20557 let bytes = common::to_bytes(body).await.unwrap_or_default();
20558 let error = serde_json::from_str(&common::to_string(&bytes));
20559 let response = common::to_response(parts, bytes.into());
20560
20561 if let common::Retry::After(d) =
20562 dlg.http_failure(&response, error.as_ref().ok())
20563 {
20564 sleep(d).await;
20565 continue;
20566 }
20567
20568 dlg.finished(false);
20569
20570 return Err(match error {
20571 Ok(value) => common::Error::BadRequest(value),
20572 _ => common::Error::Failure(response),
20573 });
20574 }
20575 let response = {
20576 let bytes = common::to_bytes(body).await.unwrap_or_default();
20577 let encoded = common::to_string(&bytes);
20578 match serde_json::from_str(&encoded) {
20579 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20580 Err(error) => {
20581 dlg.response_json_decode_error(&encoded, &error);
20582 return Err(common::Error::JsonDecodeError(
20583 encoded.to_string(),
20584 error,
20585 ));
20586 }
20587 }
20588 };
20589
20590 dlg.finished(true);
20591 return Ok(response);
20592 }
20593 }
20594 }
20595 }
20596
20597 /// Name of the bucket containing the managed folder.
20598 ///
20599 /// Sets the *bucket* path property to the given value.
20600 ///
20601 /// Even though the property as already been set when instantiating this call,
20602 /// we provide this method for API completeness.
20603 pub fn bucket(mut self, new_value: &str) -> ManagedFolderListCall<'a, C> {
20604 self._bucket = new_value.to_string();
20605 self
20606 }
20607 /// The managed folder name/path prefix to filter the output list of results.
20608 ///
20609 /// Sets the *prefix* query property to the given value.
20610 pub fn prefix(mut self, new_value: &str) -> ManagedFolderListCall<'a, C> {
20611 self._prefix = Some(new_value.to_string());
20612 self
20613 }
20614 /// A previously-returned page token representing part of the larger set of results to view.
20615 ///
20616 /// Sets the *page token* query property to the given value.
20617 pub fn page_token(mut self, new_value: &str) -> ManagedFolderListCall<'a, C> {
20618 self._page_token = Some(new_value.to_string());
20619 self
20620 }
20621 /// Maximum number of items to return in a single page of responses.
20622 ///
20623 /// Sets the *page size* query property to the given value.
20624 pub fn page_size(mut self, new_value: i32) -> ManagedFolderListCall<'a, C> {
20625 self._page_size = Some(new_value);
20626 self
20627 }
20628 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20629 /// while executing the actual API request.
20630 ///
20631 /// ````text
20632 /// It should be used to handle progress information, and to implement a certain level of resilience.
20633 /// ````
20634 ///
20635 /// Sets the *delegate* property to the given value.
20636 pub fn delegate(
20637 mut self,
20638 new_value: &'a mut dyn common::Delegate,
20639 ) -> ManagedFolderListCall<'a, C> {
20640 self._delegate = Some(new_value);
20641 self
20642 }
20643
20644 /// Set any additional parameter of the query string used in the request.
20645 /// It should be used to set parameters which are not yet available through their own
20646 /// setters.
20647 ///
20648 /// Please note that this method must not be used to set any of the known parameters
20649 /// which have their own setter method. If done anyway, the request will fail.
20650 ///
20651 /// # Additional Parameters
20652 ///
20653 /// * *alt* (query-string) - Data format for the response.
20654 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20655 /// * *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.
20656 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20657 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20658 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
20659 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
20660 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
20661 pub fn param<T>(mut self, name: T, value: T) -> ManagedFolderListCall<'a, C>
20662 where
20663 T: AsRef<str>,
20664 {
20665 self._additional_params
20666 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20667 self
20668 }
20669
20670 /// Identifies the authorization scope for the method you are building.
20671 ///
20672 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20673 /// [`Scope::DevstorageReadOnly`].
20674 ///
20675 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20676 /// tokens for more than one scope.
20677 ///
20678 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20679 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20680 /// sufficient, a read-write scope will do as well.
20681 pub fn add_scope<St>(mut self, scope: St) -> ManagedFolderListCall<'a, C>
20682 where
20683 St: AsRef<str>,
20684 {
20685 self._scopes.insert(String::from(scope.as_ref()));
20686 self
20687 }
20688 /// Identifies the authorization scope(s) for the method you are building.
20689 ///
20690 /// See [`Self::add_scope()`] for details.
20691 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedFolderListCall<'a, C>
20692 where
20693 I: IntoIterator<Item = St>,
20694 St: AsRef<str>,
20695 {
20696 self._scopes
20697 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20698 self
20699 }
20700
20701 /// Removes all scopes, and no default scope will be used either.
20702 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20703 /// for details).
20704 pub fn clear_scopes(mut self) -> ManagedFolderListCall<'a, C> {
20705 self._scopes.clear();
20706 self
20707 }
20708}
20709
20710/// Updates an IAM policy for the specified managed folder.
20711///
20712/// A builder for the *setIamPolicy* method supported by a *managedFolder* resource.
20713/// It is not used directly, but through a [`ManagedFolderMethods`] instance.
20714///
20715/// # Example
20716///
20717/// Instantiate a resource method builder
20718///
20719/// ```test_harness,no_run
20720/// # extern crate hyper;
20721/// # extern crate hyper_rustls;
20722/// # extern crate google_storage1 as storage1;
20723/// use storage1::api::Policy;
20724/// # async fn dox() {
20725/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20726///
20727/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20728/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20729/// # .with_native_roots()
20730/// # .unwrap()
20731/// # .https_only()
20732/// # .enable_http2()
20733/// # .build();
20734///
20735/// # let executor = hyper_util::rt::TokioExecutor::new();
20736/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20737/// # secret,
20738/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20739/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20740/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20741/// # ),
20742/// # ).build().await.unwrap();
20743///
20744/// # let client = hyper_util::client::legacy::Client::builder(
20745/// # hyper_util::rt::TokioExecutor::new()
20746/// # )
20747/// # .build(
20748/// # hyper_rustls::HttpsConnectorBuilder::new()
20749/// # .with_native_roots()
20750/// # .unwrap()
20751/// # .https_or_http()
20752/// # .enable_http2()
20753/// # .build()
20754/// # );
20755/// # let mut hub = Storage::new(client, auth);
20756/// // As the method needs a request, you would usually fill it with the desired information
20757/// // into the respective structure. Some of the parts shown here might not be applicable !
20758/// // Values shown here are possibly random and not representative !
20759/// let mut req = Policy::default();
20760///
20761/// // You can configure optional parameters by calling the respective setters at will, and
20762/// // execute the final call using `doit()`.
20763/// // Values shown here are possibly random and not representative !
20764/// let result = hub.managed_folders().set_iam_policy(req, "bucket", "managedFolder")
20765/// .user_project("aliquyam")
20766/// .doit().await;
20767/// # }
20768/// ```
20769pub struct ManagedFolderSetIamPolicyCall<'a, C>
20770where
20771 C: 'a,
20772{
20773 hub: &'a Storage<C>,
20774 _request: Policy,
20775 _bucket: String,
20776 _managed_folder: String,
20777 _user_project: Option<String>,
20778 _delegate: Option<&'a mut dyn common::Delegate>,
20779 _additional_params: HashMap<String, String>,
20780 _scopes: BTreeSet<String>,
20781}
20782
20783impl<'a, C> common::CallBuilder for ManagedFolderSetIamPolicyCall<'a, C> {}
20784
20785impl<'a, C> ManagedFolderSetIamPolicyCall<'a, C>
20786where
20787 C: common::Connector,
20788{
20789 /// Perform the operation you have build so far.
20790 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
20791 use std::borrow::Cow;
20792 use std::io::{Read, Seek};
20793
20794 use common::{url::Params, ToParts};
20795 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20796
20797 let mut dd = common::DefaultDelegate;
20798 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20799 dlg.begin(common::MethodInfo {
20800 id: "storage.managedFolders.setIamPolicy",
20801 http_method: hyper::Method::PUT,
20802 });
20803
20804 for &field in ["alt", "bucket", "managedFolder", "userProject"].iter() {
20805 if self._additional_params.contains_key(field) {
20806 dlg.finished(false);
20807 return Err(common::Error::FieldClash(field));
20808 }
20809 }
20810
20811 let mut params = Params::with_capacity(6 + self._additional_params.len());
20812 params.push("bucket", self._bucket);
20813 params.push("managedFolder", self._managed_folder);
20814 if let Some(value) = self._user_project.as_ref() {
20815 params.push("userProject", value);
20816 }
20817
20818 params.extend(self._additional_params.iter());
20819
20820 params.push("alt", "json");
20821 let mut url = self.hub._base_url.clone() + "b/{bucket}/managedFolders/{managedFolder}/iam";
20822 if self._scopes.is_empty() {
20823 self._scopes
20824 .insert(Scope::DevstorageFullControl.as_ref().to_string());
20825 }
20826
20827 #[allow(clippy::single_element_loop)]
20828 for &(find_this, param_name) in
20829 [("{bucket}", "bucket"), ("{managedFolder}", "managedFolder")].iter()
20830 {
20831 url = params.uri_replacement(url, param_name, find_this, false);
20832 }
20833 {
20834 let to_remove = ["managedFolder", "bucket"];
20835 params.remove_params(&to_remove);
20836 }
20837
20838 let url = params.parse_with_url(&url);
20839
20840 let mut json_mime_type = mime::APPLICATION_JSON;
20841 let mut request_value_reader = {
20842 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20843 common::remove_json_null_values(&mut value);
20844 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20845 serde_json::to_writer(&mut dst, &value).unwrap();
20846 dst
20847 };
20848 let request_size = request_value_reader
20849 .seek(std::io::SeekFrom::End(0))
20850 .unwrap();
20851 request_value_reader
20852 .seek(std::io::SeekFrom::Start(0))
20853 .unwrap();
20854
20855 loop {
20856 let token = match self
20857 .hub
20858 .auth
20859 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20860 .await
20861 {
20862 Ok(token) => token,
20863 Err(e) => match dlg.token(e) {
20864 Ok(token) => token,
20865 Err(e) => {
20866 dlg.finished(false);
20867 return Err(common::Error::MissingToken(e));
20868 }
20869 },
20870 };
20871 request_value_reader
20872 .seek(std::io::SeekFrom::Start(0))
20873 .unwrap();
20874 let mut req_result = {
20875 let client = &self.hub.client;
20876 dlg.pre_request();
20877 let mut req_builder = hyper::Request::builder()
20878 .method(hyper::Method::PUT)
20879 .uri(url.as_str())
20880 .header(USER_AGENT, self.hub._user_agent.clone());
20881
20882 if let Some(token) = token.as_ref() {
20883 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20884 }
20885
20886 let request = req_builder
20887 .header(CONTENT_TYPE, json_mime_type.to_string())
20888 .header(CONTENT_LENGTH, request_size as u64)
20889 .body(common::to_body(
20890 request_value_reader.get_ref().clone().into(),
20891 ));
20892
20893 client.request(request.unwrap()).await
20894 };
20895
20896 match req_result {
20897 Err(err) => {
20898 if let common::Retry::After(d) = dlg.http_error(&err) {
20899 sleep(d).await;
20900 continue;
20901 }
20902 dlg.finished(false);
20903 return Err(common::Error::HttpError(err));
20904 }
20905 Ok(res) => {
20906 let (mut parts, body) = res.into_parts();
20907 let mut body = common::Body::new(body);
20908 if !parts.status.is_success() {
20909 let bytes = common::to_bytes(body).await.unwrap_or_default();
20910 let error = serde_json::from_str(&common::to_string(&bytes));
20911 let response = common::to_response(parts, bytes.into());
20912
20913 if let common::Retry::After(d) =
20914 dlg.http_failure(&response, error.as_ref().ok())
20915 {
20916 sleep(d).await;
20917 continue;
20918 }
20919
20920 dlg.finished(false);
20921
20922 return Err(match error {
20923 Ok(value) => common::Error::BadRequest(value),
20924 _ => common::Error::Failure(response),
20925 });
20926 }
20927 let response = {
20928 let bytes = common::to_bytes(body).await.unwrap_or_default();
20929 let encoded = common::to_string(&bytes);
20930 match serde_json::from_str(&encoded) {
20931 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20932 Err(error) => {
20933 dlg.response_json_decode_error(&encoded, &error);
20934 return Err(common::Error::JsonDecodeError(
20935 encoded.to_string(),
20936 error,
20937 ));
20938 }
20939 }
20940 };
20941
20942 dlg.finished(true);
20943 return Ok(response);
20944 }
20945 }
20946 }
20947 }
20948
20949 ///
20950 /// Sets the *request* property to the given value.
20951 ///
20952 /// Even though the property as already been set when instantiating this call,
20953 /// we provide this method for API completeness.
20954 pub fn request(mut self, new_value: Policy) -> ManagedFolderSetIamPolicyCall<'a, C> {
20955 self._request = new_value;
20956 self
20957 }
20958 /// Name of the bucket containing the managed folder.
20959 ///
20960 /// Sets the *bucket* path property to the given value.
20961 ///
20962 /// Even though the property as already been set when instantiating this call,
20963 /// we provide this method for API completeness.
20964 pub fn bucket(mut self, new_value: &str) -> ManagedFolderSetIamPolicyCall<'a, C> {
20965 self._bucket = new_value.to_string();
20966 self
20967 }
20968 /// The managed folder name/path.
20969 ///
20970 /// Sets the *managed folder* path property to the given value.
20971 ///
20972 /// Even though the property as already been set when instantiating this call,
20973 /// we provide this method for API completeness.
20974 pub fn managed_folder(mut self, new_value: &str) -> ManagedFolderSetIamPolicyCall<'a, C> {
20975 self._managed_folder = new_value.to_string();
20976 self
20977 }
20978 /// The project to be billed for this request. Required for Requester Pays buckets.
20979 ///
20980 /// Sets the *user project* query property to the given value.
20981 pub fn user_project(mut self, new_value: &str) -> ManagedFolderSetIamPolicyCall<'a, C> {
20982 self._user_project = Some(new_value.to_string());
20983 self
20984 }
20985 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20986 /// while executing the actual API request.
20987 ///
20988 /// ````text
20989 /// It should be used to handle progress information, and to implement a certain level of resilience.
20990 /// ````
20991 ///
20992 /// Sets the *delegate* property to the given value.
20993 pub fn delegate(
20994 mut self,
20995 new_value: &'a mut dyn common::Delegate,
20996 ) -> ManagedFolderSetIamPolicyCall<'a, C> {
20997 self._delegate = Some(new_value);
20998 self
20999 }
21000
21001 /// Set any additional parameter of the query string used in the request.
21002 /// It should be used to set parameters which are not yet available through their own
21003 /// setters.
21004 ///
21005 /// Please note that this method must not be used to set any of the known parameters
21006 /// which have their own setter method. If done anyway, the request will fail.
21007 ///
21008 /// # Additional Parameters
21009 ///
21010 /// * *alt* (query-string) - Data format for the response.
21011 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21012 /// * *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.
21013 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21014 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21015 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21016 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
21017 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21018 pub fn param<T>(mut self, name: T, value: T) -> ManagedFolderSetIamPolicyCall<'a, C>
21019 where
21020 T: AsRef<str>,
21021 {
21022 self._additional_params
21023 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21024 self
21025 }
21026
21027 /// Identifies the authorization scope for the method you are building.
21028 ///
21029 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21030 /// [`Scope::DevstorageFullControl`].
21031 ///
21032 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21033 /// tokens for more than one scope.
21034 ///
21035 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21036 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21037 /// sufficient, a read-write scope will do as well.
21038 pub fn add_scope<St>(mut self, scope: St) -> ManagedFolderSetIamPolicyCall<'a, C>
21039 where
21040 St: AsRef<str>,
21041 {
21042 self._scopes.insert(String::from(scope.as_ref()));
21043 self
21044 }
21045 /// Identifies the authorization scope(s) for the method you are building.
21046 ///
21047 /// See [`Self::add_scope()`] for details.
21048 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedFolderSetIamPolicyCall<'a, C>
21049 where
21050 I: IntoIterator<Item = St>,
21051 St: AsRef<str>,
21052 {
21053 self._scopes
21054 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21055 self
21056 }
21057
21058 /// Removes all scopes, and no default scope will be used either.
21059 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21060 /// for details).
21061 pub fn clear_scopes(mut self) -> ManagedFolderSetIamPolicyCall<'a, C> {
21062 self._scopes.clear();
21063 self
21064 }
21065}
21066
21067/// Tests a set of permissions on the given managed folder to see which, if any, are held by the caller.
21068///
21069/// A builder for the *testIamPermissions* method supported by a *managedFolder* resource.
21070/// It is not used directly, but through a [`ManagedFolderMethods`] instance.
21071///
21072/// # Example
21073///
21074/// Instantiate a resource method builder
21075///
21076/// ```test_harness,no_run
21077/// # extern crate hyper;
21078/// # extern crate hyper_rustls;
21079/// # extern crate google_storage1 as storage1;
21080/// # async fn dox() {
21081/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21082///
21083/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21084/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21085/// # .with_native_roots()
21086/// # .unwrap()
21087/// # .https_only()
21088/// # .enable_http2()
21089/// # .build();
21090///
21091/// # let executor = hyper_util::rt::TokioExecutor::new();
21092/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21093/// # secret,
21094/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21095/// # yup_oauth2::client::CustomHyperClientBuilder::from(
21096/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
21097/// # ),
21098/// # ).build().await.unwrap();
21099///
21100/// # let client = hyper_util::client::legacy::Client::builder(
21101/// # hyper_util::rt::TokioExecutor::new()
21102/// # )
21103/// # .build(
21104/// # hyper_rustls::HttpsConnectorBuilder::new()
21105/// # .with_native_roots()
21106/// # .unwrap()
21107/// # .https_or_http()
21108/// # .enable_http2()
21109/// # .build()
21110/// # );
21111/// # let mut hub = Storage::new(client, auth);
21112/// // You can configure optional parameters by calling the respective setters at will, and
21113/// // execute the final call using `doit()`.
21114/// // Values shown here are possibly random and not representative !
21115/// let result = hub.managed_folders().test_iam_permissions("bucket", "managedFolder", &vec!["ipsum".into()])
21116/// .user_project("Lorem")
21117/// .doit().await;
21118/// # }
21119/// ```
21120pub struct ManagedFolderTestIamPermissionCall<'a, C>
21121where
21122 C: 'a,
21123{
21124 hub: &'a Storage<C>,
21125 _bucket: String,
21126 _managed_folder: String,
21127 _permissions: Vec<String>,
21128 _user_project: Option<String>,
21129 _delegate: Option<&'a mut dyn common::Delegate>,
21130 _additional_params: HashMap<String, String>,
21131 _scopes: BTreeSet<String>,
21132}
21133
21134impl<'a, C> common::CallBuilder for ManagedFolderTestIamPermissionCall<'a, C> {}
21135
21136impl<'a, C> ManagedFolderTestIamPermissionCall<'a, C>
21137where
21138 C: common::Connector,
21139{
21140 /// Perform the operation you have build so far.
21141 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
21142 use std::borrow::Cow;
21143 use std::io::{Read, Seek};
21144
21145 use common::{url::Params, ToParts};
21146 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21147
21148 let mut dd = common::DefaultDelegate;
21149 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21150 dlg.begin(common::MethodInfo {
21151 id: "storage.managedFolders.testIamPermissions",
21152 http_method: hyper::Method::GET,
21153 });
21154
21155 for &field in [
21156 "alt",
21157 "bucket",
21158 "managedFolder",
21159 "permissions",
21160 "userProject",
21161 ]
21162 .iter()
21163 {
21164 if self._additional_params.contains_key(field) {
21165 dlg.finished(false);
21166 return Err(common::Error::FieldClash(field));
21167 }
21168 }
21169
21170 let mut params = Params::with_capacity(6 + self._additional_params.len());
21171 params.push("bucket", self._bucket);
21172 params.push("managedFolder", self._managed_folder);
21173 if !self._permissions.is_empty() {
21174 for f in self._permissions.iter() {
21175 params.push("permissions", f);
21176 }
21177 }
21178 if let Some(value) = self._user_project.as_ref() {
21179 params.push("userProject", value);
21180 }
21181
21182 params.extend(self._additional_params.iter());
21183
21184 params.push("alt", "json");
21185 let mut url = self.hub._base_url.clone()
21186 + "b/{bucket}/managedFolders/{managedFolder}/iam/testPermissions";
21187 if self._scopes.is_empty() {
21188 self._scopes
21189 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
21190 }
21191
21192 #[allow(clippy::single_element_loop)]
21193 for &(find_this, param_name) in
21194 [("{bucket}", "bucket"), ("{managedFolder}", "managedFolder")].iter()
21195 {
21196 url = params.uri_replacement(url, param_name, find_this, false);
21197 }
21198 {
21199 let to_remove = ["managedFolder", "bucket"];
21200 params.remove_params(&to_remove);
21201 }
21202
21203 let url = params.parse_with_url(&url);
21204
21205 loop {
21206 let token = match self
21207 .hub
21208 .auth
21209 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21210 .await
21211 {
21212 Ok(token) => token,
21213 Err(e) => match dlg.token(e) {
21214 Ok(token) => token,
21215 Err(e) => {
21216 dlg.finished(false);
21217 return Err(common::Error::MissingToken(e));
21218 }
21219 },
21220 };
21221 let mut req_result = {
21222 let client = &self.hub.client;
21223 dlg.pre_request();
21224 let mut req_builder = hyper::Request::builder()
21225 .method(hyper::Method::GET)
21226 .uri(url.as_str())
21227 .header(USER_AGENT, self.hub._user_agent.clone());
21228
21229 if let Some(token) = token.as_ref() {
21230 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21231 }
21232
21233 let request = req_builder
21234 .header(CONTENT_LENGTH, 0_u64)
21235 .body(common::to_body::<String>(None));
21236
21237 client.request(request.unwrap()).await
21238 };
21239
21240 match req_result {
21241 Err(err) => {
21242 if let common::Retry::After(d) = dlg.http_error(&err) {
21243 sleep(d).await;
21244 continue;
21245 }
21246 dlg.finished(false);
21247 return Err(common::Error::HttpError(err));
21248 }
21249 Ok(res) => {
21250 let (mut parts, body) = res.into_parts();
21251 let mut body = common::Body::new(body);
21252 if !parts.status.is_success() {
21253 let bytes = common::to_bytes(body).await.unwrap_or_default();
21254 let error = serde_json::from_str(&common::to_string(&bytes));
21255 let response = common::to_response(parts, bytes.into());
21256
21257 if let common::Retry::After(d) =
21258 dlg.http_failure(&response, error.as_ref().ok())
21259 {
21260 sleep(d).await;
21261 continue;
21262 }
21263
21264 dlg.finished(false);
21265
21266 return Err(match error {
21267 Ok(value) => common::Error::BadRequest(value),
21268 _ => common::Error::Failure(response),
21269 });
21270 }
21271 let response = {
21272 let bytes = common::to_bytes(body).await.unwrap_or_default();
21273 let encoded = common::to_string(&bytes);
21274 match serde_json::from_str(&encoded) {
21275 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21276 Err(error) => {
21277 dlg.response_json_decode_error(&encoded, &error);
21278 return Err(common::Error::JsonDecodeError(
21279 encoded.to_string(),
21280 error,
21281 ));
21282 }
21283 }
21284 };
21285
21286 dlg.finished(true);
21287 return Ok(response);
21288 }
21289 }
21290 }
21291 }
21292
21293 /// Name of the bucket containing the managed folder.
21294 ///
21295 /// Sets the *bucket* path property to the given value.
21296 ///
21297 /// Even though the property as already been set when instantiating this call,
21298 /// we provide this method for API completeness.
21299 pub fn bucket(mut self, new_value: &str) -> ManagedFolderTestIamPermissionCall<'a, C> {
21300 self._bucket = new_value.to_string();
21301 self
21302 }
21303 /// The managed folder name/path.
21304 ///
21305 /// Sets the *managed folder* path property to the given value.
21306 ///
21307 /// Even though the property as already been set when instantiating this call,
21308 /// we provide this method for API completeness.
21309 pub fn managed_folder(mut self, new_value: &str) -> ManagedFolderTestIamPermissionCall<'a, C> {
21310 self._managed_folder = new_value.to_string();
21311 self
21312 }
21313 /// Permissions to test.
21314 ///
21315 /// Append the given value to the *permissions* query property.
21316 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
21317 ///
21318 /// Even though the property as already been set when instantiating this call,
21319 /// we provide this method for API completeness.
21320 pub fn add_permissions(mut self, new_value: &str) -> ManagedFolderTestIamPermissionCall<'a, C> {
21321 self._permissions.push(new_value.to_string());
21322 self
21323 }
21324 /// The project to be billed for this request. Required for Requester Pays buckets.
21325 ///
21326 /// Sets the *user project* query property to the given value.
21327 pub fn user_project(mut self, new_value: &str) -> ManagedFolderTestIamPermissionCall<'a, C> {
21328 self._user_project = Some(new_value.to_string());
21329 self
21330 }
21331 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21332 /// while executing the actual API request.
21333 ///
21334 /// ````text
21335 /// It should be used to handle progress information, and to implement a certain level of resilience.
21336 /// ````
21337 ///
21338 /// Sets the *delegate* property to the given value.
21339 pub fn delegate(
21340 mut self,
21341 new_value: &'a mut dyn common::Delegate,
21342 ) -> ManagedFolderTestIamPermissionCall<'a, C> {
21343 self._delegate = Some(new_value);
21344 self
21345 }
21346
21347 /// Set any additional parameter of the query string used in the request.
21348 /// It should be used to set parameters which are not yet available through their own
21349 /// setters.
21350 ///
21351 /// Please note that this method must not be used to set any of the known parameters
21352 /// which have their own setter method. If done anyway, the request will fail.
21353 ///
21354 /// # Additional Parameters
21355 ///
21356 /// * *alt* (query-string) - Data format for the response.
21357 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21358 /// * *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.
21359 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21360 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21361 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21362 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
21363 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21364 pub fn param<T>(mut self, name: T, value: T) -> ManagedFolderTestIamPermissionCall<'a, C>
21365 where
21366 T: AsRef<str>,
21367 {
21368 self._additional_params
21369 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21370 self
21371 }
21372
21373 /// Identifies the authorization scope for the method you are building.
21374 ///
21375 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21376 /// [`Scope::DevstorageReadOnly`].
21377 ///
21378 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21379 /// tokens for more than one scope.
21380 ///
21381 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21382 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21383 /// sufficient, a read-write scope will do as well.
21384 pub fn add_scope<St>(mut self, scope: St) -> ManagedFolderTestIamPermissionCall<'a, C>
21385 where
21386 St: AsRef<str>,
21387 {
21388 self._scopes.insert(String::from(scope.as_ref()));
21389 self
21390 }
21391 /// Identifies the authorization scope(s) for the method you are building.
21392 ///
21393 /// See [`Self::add_scope()`] for details.
21394 pub fn add_scopes<I, St>(mut self, scopes: I) -> ManagedFolderTestIamPermissionCall<'a, C>
21395 where
21396 I: IntoIterator<Item = St>,
21397 St: AsRef<str>,
21398 {
21399 self._scopes
21400 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21401 self
21402 }
21403
21404 /// Removes all scopes, and no default scope will be used either.
21405 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21406 /// for details).
21407 pub fn clear_scopes(mut self) -> ManagedFolderTestIamPermissionCall<'a, C> {
21408 self._scopes.clear();
21409 self
21410 }
21411}
21412
21413/// Permanently deletes a notification subscription.
21414///
21415/// A builder for the *delete* method supported by a *notification* resource.
21416/// It is not used directly, but through a [`NotificationMethods`] instance.
21417///
21418/// # Example
21419///
21420/// Instantiate a resource method builder
21421///
21422/// ```test_harness,no_run
21423/// # extern crate hyper;
21424/// # extern crate hyper_rustls;
21425/// # extern crate google_storage1 as storage1;
21426/// # async fn dox() {
21427/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21428///
21429/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21430/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21431/// # .with_native_roots()
21432/// # .unwrap()
21433/// # .https_only()
21434/// # .enable_http2()
21435/// # .build();
21436///
21437/// # let executor = hyper_util::rt::TokioExecutor::new();
21438/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21439/// # secret,
21440/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21441/// # yup_oauth2::client::CustomHyperClientBuilder::from(
21442/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
21443/// # ),
21444/// # ).build().await.unwrap();
21445///
21446/// # let client = hyper_util::client::legacy::Client::builder(
21447/// # hyper_util::rt::TokioExecutor::new()
21448/// # )
21449/// # .build(
21450/// # hyper_rustls::HttpsConnectorBuilder::new()
21451/// # .with_native_roots()
21452/// # .unwrap()
21453/// # .https_or_http()
21454/// # .enable_http2()
21455/// # .build()
21456/// # );
21457/// # let mut hub = Storage::new(client, auth);
21458/// // You can configure optional parameters by calling the respective setters at will, and
21459/// // execute the final call using `doit()`.
21460/// // Values shown here are possibly random and not representative !
21461/// let result = hub.notifications().delete("bucket", "notification")
21462/// .user_project("sadipscing")
21463/// .doit().await;
21464/// # }
21465/// ```
21466pub struct NotificationDeleteCall<'a, C>
21467where
21468 C: 'a,
21469{
21470 hub: &'a Storage<C>,
21471 _bucket: String,
21472 _notification: String,
21473 _user_project: Option<String>,
21474 _delegate: Option<&'a mut dyn common::Delegate>,
21475 _additional_params: HashMap<String, String>,
21476 _scopes: BTreeSet<String>,
21477}
21478
21479impl<'a, C> common::CallBuilder for NotificationDeleteCall<'a, C> {}
21480
21481impl<'a, C> NotificationDeleteCall<'a, C>
21482where
21483 C: common::Connector,
21484{
21485 /// Perform the operation you have build so far.
21486 pub async fn doit(mut self) -> common::Result<common::Response> {
21487 use std::borrow::Cow;
21488 use std::io::{Read, Seek};
21489
21490 use common::{url::Params, ToParts};
21491 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21492
21493 let mut dd = common::DefaultDelegate;
21494 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21495 dlg.begin(common::MethodInfo {
21496 id: "storage.notifications.delete",
21497 http_method: hyper::Method::DELETE,
21498 });
21499
21500 for &field in ["bucket", "notification", "userProject"].iter() {
21501 if self._additional_params.contains_key(field) {
21502 dlg.finished(false);
21503 return Err(common::Error::FieldClash(field));
21504 }
21505 }
21506
21507 let mut params = Params::with_capacity(4 + self._additional_params.len());
21508 params.push("bucket", self._bucket);
21509 params.push("notification", self._notification);
21510 if let Some(value) = self._user_project.as_ref() {
21511 params.push("userProject", value);
21512 }
21513
21514 params.extend(self._additional_params.iter());
21515
21516 let mut url = self.hub._base_url.clone() + "b/{bucket}/notificationConfigs/{notification}";
21517 if self._scopes.is_empty() {
21518 self._scopes
21519 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
21520 }
21521
21522 #[allow(clippy::single_element_loop)]
21523 for &(find_this, param_name) in
21524 [("{bucket}", "bucket"), ("{notification}", "notification")].iter()
21525 {
21526 url = params.uri_replacement(url, param_name, find_this, false);
21527 }
21528 {
21529 let to_remove = ["notification", "bucket"];
21530 params.remove_params(&to_remove);
21531 }
21532
21533 let url = params.parse_with_url(&url);
21534
21535 loop {
21536 let token = match self
21537 .hub
21538 .auth
21539 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21540 .await
21541 {
21542 Ok(token) => token,
21543 Err(e) => match dlg.token(e) {
21544 Ok(token) => token,
21545 Err(e) => {
21546 dlg.finished(false);
21547 return Err(common::Error::MissingToken(e));
21548 }
21549 },
21550 };
21551 let mut req_result = {
21552 let client = &self.hub.client;
21553 dlg.pre_request();
21554 let mut req_builder = hyper::Request::builder()
21555 .method(hyper::Method::DELETE)
21556 .uri(url.as_str())
21557 .header(USER_AGENT, self.hub._user_agent.clone());
21558
21559 if let Some(token) = token.as_ref() {
21560 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21561 }
21562
21563 let request = req_builder
21564 .header(CONTENT_LENGTH, 0_u64)
21565 .body(common::to_body::<String>(None));
21566
21567 client.request(request.unwrap()).await
21568 };
21569
21570 match req_result {
21571 Err(err) => {
21572 if let common::Retry::After(d) = dlg.http_error(&err) {
21573 sleep(d).await;
21574 continue;
21575 }
21576 dlg.finished(false);
21577 return Err(common::Error::HttpError(err));
21578 }
21579 Ok(res) => {
21580 let (mut parts, body) = res.into_parts();
21581 let mut body = common::Body::new(body);
21582 if !parts.status.is_success() {
21583 let bytes = common::to_bytes(body).await.unwrap_or_default();
21584 let error = serde_json::from_str(&common::to_string(&bytes));
21585 let response = common::to_response(parts, bytes.into());
21586
21587 if let common::Retry::After(d) =
21588 dlg.http_failure(&response, error.as_ref().ok())
21589 {
21590 sleep(d).await;
21591 continue;
21592 }
21593
21594 dlg.finished(false);
21595
21596 return Err(match error {
21597 Ok(value) => common::Error::BadRequest(value),
21598 _ => common::Error::Failure(response),
21599 });
21600 }
21601 let response = common::Response::from_parts(parts, body);
21602
21603 dlg.finished(true);
21604 return Ok(response);
21605 }
21606 }
21607 }
21608 }
21609
21610 /// The parent bucket of the notification.
21611 ///
21612 /// Sets the *bucket* path property to the given value.
21613 ///
21614 /// Even though the property as already been set when instantiating this call,
21615 /// we provide this method for API completeness.
21616 pub fn bucket(mut self, new_value: &str) -> NotificationDeleteCall<'a, C> {
21617 self._bucket = new_value.to_string();
21618 self
21619 }
21620 /// ID of the notification to delete.
21621 ///
21622 /// Sets the *notification* path property to the given value.
21623 ///
21624 /// Even though the property as already been set when instantiating this call,
21625 /// we provide this method for API completeness.
21626 pub fn notification(mut self, new_value: &str) -> NotificationDeleteCall<'a, C> {
21627 self._notification = new_value.to_string();
21628 self
21629 }
21630 /// The project to be billed for this request. Required for Requester Pays buckets.
21631 ///
21632 /// Sets the *user project* query property to the given value.
21633 pub fn user_project(mut self, new_value: &str) -> NotificationDeleteCall<'a, C> {
21634 self._user_project = Some(new_value.to_string());
21635 self
21636 }
21637 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21638 /// while executing the actual API request.
21639 ///
21640 /// ````text
21641 /// It should be used to handle progress information, and to implement a certain level of resilience.
21642 /// ````
21643 ///
21644 /// Sets the *delegate* property to the given value.
21645 pub fn delegate(
21646 mut self,
21647 new_value: &'a mut dyn common::Delegate,
21648 ) -> NotificationDeleteCall<'a, C> {
21649 self._delegate = Some(new_value);
21650 self
21651 }
21652
21653 /// Set any additional parameter of the query string used in the request.
21654 /// It should be used to set parameters which are not yet available through their own
21655 /// setters.
21656 ///
21657 /// Please note that this method must not be used to set any of the known parameters
21658 /// which have their own setter method. If done anyway, the request will fail.
21659 ///
21660 /// # Additional Parameters
21661 ///
21662 /// * *alt* (query-string) - Data format for the response.
21663 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21664 /// * *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.
21665 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21666 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21667 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21668 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
21669 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21670 pub fn param<T>(mut self, name: T, value: T) -> NotificationDeleteCall<'a, C>
21671 where
21672 T: AsRef<str>,
21673 {
21674 self._additional_params
21675 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21676 self
21677 }
21678
21679 /// Identifies the authorization scope for the method you are building.
21680 ///
21681 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21682 /// [`Scope::DevstorageReadWrite`].
21683 ///
21684 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21685 /// tokens for more than one scope.
21686 ///
21687 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21688 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21689 /// sufficient, a read-write scope will do as well.
21690 pub fn add_scope<St>(mut self, scope: St) -> NotificationDeleteCall<'a, C>
21691 where
21692 St: AsRef<str>,
21693 {
21694 self._scopes.insert(String::from(scope.as_ref()));
21695 self
21696 }
21697 /// Identifies the authorization scope(s) for the method you are building.
21698 ///
21699 /// See [`Self::add_scope()`] for details.
21700 pub fn add_scopes<I, St>(mut self, scopes: I) -> NotificationDeleteCall<'a, C>
21701 where
21702 I: IntoIterator<Item = St>,
21703 St: AsRef<str>,
21704 {
21705 self._scopes
21706 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21707 self
21708 }
21709
21710 /// Removes all scopes, and no default scope will be used either.
21711 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21712 /// for details).
21713 pub fn clear_scopes(mut self) -> NotificationDeleteCall<'a, C> {
21714 self._scopes.clear();
21715 self
21716 }
21717}
21718
21719/// View a notification configuration.
21720///
21721/// A builder for the *get* method supported by a *notification* resource.
21722/// It is not used directly, but through a [`NotificationMethods`] instance.
21723///
21724/// # Example
21725///
21726/// Instantiate a resource method builder
21727///
21728/// ```test_harness,no_run
21729/// # extern crate hyper;
21730/// # extern crate hyper_rustls;
21731/// # extern crate google_storage1 as storage1;
21732/// # async fn dox() {
21733/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21734///
21735/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21736/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21737/// # .with_native_roots()
21738/// # .unwrap()
21739/// # .https_only()
21740/// # .enable_http2()
21741/// # .build();
21742///
21743/// # let executor = hyper_util::rt::TokioExecutor::new();
21744/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21745/// # secret,
21746/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21747/// # yup_oauth2::client::CustomHyperClientBuilder::from(
21748/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
21749/// # ),
21750/// # ).build().await.unwrap();
21751///
21752/// # let client = hyper_util::client::legacy::Client::builder(
21753/// # hyper_util::rt::TokioExecutor::new()
21754/// # )
21755/// # .build(
21756/// # hyper_rustls::HttpsConnectorBuilder::new()
21757/// # .with_native_roots()
21758/// # .unwrap()
21759/// # .https_or_http()
21760/// # .enable_http2()
21761/// # .build()
21762/// # );
21763/// # let mut hub = Storage::new(client, auth);
21764/// // You can configure optional parameters by calling the respective setters at will, and
21765/// // execute the final call using `doit()`.
21766/// // Values shown here are possibly random and not representative !
21767/// let result = hub.notifications().get("bucket", "notification")
21768/// .user_project("duo")
21769/// .doit().await;
21770/// # }
21771/// ```
21772pub struct NotificationGetCall<'a, C>
21773where
21774 C: 'a,
21775{
21776 hub: &'a Storage<C>,
21777 _bucket: String,
21778 _notification: String,
21779 _user_project: Option<String>,
21780 _delegate: Option<&'a mut dyn common::Delegate>,
21781 _additional_params: HashMap<String, String>,
21782 _scopes: BTreeSet<String>,
21783}
21784
21785impl<'a, C> common::CallBuilder for NotificationGetCall<'a, C> {}
21786
21787impl<'a, C> NotificationGetCall<'a, C>
21788where
21789 C: common::Connector,
21790{
21791 /// Perform the operation you have build so far.
21792 pub async fn doit(mut self) -> common::Result<(common::Response, Notification)> {
21793 use std::borrow::Cow;
21794 use std::io::{Read, Seek};
21795
21796 use common::{url::Params, ToParts};
21797 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21798
21799 let mut dd = common::DefaultDelegate;
21800 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21801 dlg.begin(common::MethodInfo {
21802 id: "storage.notifications.get",
21803 http_method: hyper::Method::GET,
21804 });
21805
21806 for &field in ["alt", "bucket", "notification", "userProject"].iter() {
21807 if self._additional_params.contains_key(field) {
21808 dlg.finished(false);
21809 return Err(common::Error::FieldClash(field));
21810 }
21811 }
21812
21813 let mut params = Params::with_capacity(5 + self._additional_params.len());
21814 params.push("bucket", self._bucket);
21815 params.push("notification", self._notification);
21816 if let Some(value) = self._user_project.as_ref() {
21817 params.push("userProject", value);
21818 }
21819
21820 params.extend(self._additional_params.iter());
21821
21822 params.push("alt", "json");
21823 let mut url = self.hub._base_url.clone() + "b/{bucket}/notificationConfigs/{notification}";
21824 if self._scopes.is_empty() {
21825 self._scopes
21826 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
21827 }
21828
21829 #[allow(clippy::single_element_loop)]
21830 for &(find_this, param_name) in
21831 [("{bucket}", "bucket"), ("{notification}", "notification")].iter()
21832 {
21833 url = params.uri_replacement(url, param_name, find_this, false);
21834 }
21835 {
21836 let to_remove = ["notification", "bucket"];
21837 params.remove_params(&to_remove);
21838 }
21839
21840 let url = params.parse_with_url(&url);
21841
21842 loop {
21843 let token = match self
21844 .hub
21845 .auth
21846 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21847 .await
21848 {
21849 Ok(token) => token,
21850 Err(e) => match dlg.token(e) {
21851 Ok(token) => token,
21852 Err(e) => {
21853 dlg.finished(false);
21854 return Err(common::Error::MissingToken(e));
21855 }
21856 },
21857 };
21858 let mut req_result = {
21859 let client = &self.hub.client;
21860 dlg.pre_request();
21861 let mut req_builder = hyper::Request::builder()
21862 .method(hyper::Method::GET)
21863 .uri(url.as_str())
21864 .header(USER_AGENT, self.hub._user_agent.clone());
21865
21866 if let Some(token) = token.as_ref() {
21867 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21868 }
21869
21870 let request = req_builder
21871 .header(CONTENT_LENGTH, 0_u64)
21872 .body(common::to_body::<String>(None));
21873
21874 client.request(request.unwrap()).await
21875 };
21876
21877 match req_result {
21878 Err(err) => {
21879 if let common::Retry::After(d) = dlg.http_error(&err) {
21880 sleep(d).await;
21881 continue;
21882 }
21883 dlg.finished(false);
21884 return Err(common::Error::HttpError(err));
21885 }
21886 Ok(res) => {
21887 let (mut parts, body) = res.into_parts();
21888 let mut body = common::Body::new(body);
21889 if !parts.status.is_success() {
21890 let bytes = common::to_bytes(body).await.unwrap_or_default();
21891 let error = serde_json::from_str(&common::to_string(&bytes));
21892 let response = common::to_response(parts, bytes.into());
21893
21894 if let common::Retry::After(d) =
21895 dlg.http_failure(&response, error.as_ref().ok())
21896 {
21897 sleep(d).await;
21898 continue;
21899 }
21900
21901 dlg.finished(false);
21902
21903 return Err(match error {
21904 Ok(value) => common::Error::BadRequest(value),
21905 _ => common::Error::Failure(response),
21906 });
21907 }
21908 let response = {
21909 let bytes = common::to_bytes(body).await.unwrap_or_default();
21910 let encoded = common::to_string(&bytes);
21911 match serde_json::from_str(&encoded) {
21912 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21913 Err(error) => {
21914 dlg.response_json_decode_error(&encoded, &error);
21915 return Err(common::Error::JsonDecodeError(
21916 encoded.to_string(),
21917 error,
21918 ));
21919 }
21920 }
21921 };
21922
21923 dlg.finished(true);
21924 return Ok(response);
21925 }
21926 }
21927 }
21928 }
21929
21930 /// The parent bucket of the notification.
21931 ///
21932 /// Sets the *bucket* path property to the given value.
21933 ///
21934 /// Even though the property as already been set when instantiating this call,
21935 /// we provide this method for API completeness.
21936 pub fn bucket(mut self, new_value: &str) -> NotificationGetCall<'a, C> {
21937 self._bucket = new_value.to_string();
21938 self
21939 }
21940 /// Notification ID
21941 ///
21942 /// Sets the *notification* path property to the given value.
21943 ///
21944 /// Even though the property as already been set when instantiating this call,
21945 /// we provide this method for API completeness.
21946 pub fn notification(mut self, new_value: &str) -> NotificationGetCall<'a, C> {
21947 self._notification = new_value.to_string();
21948 self
21949 }
21950 /// The project to be billed for this request. Required for Requester Pays buckets.
21951 ///
21952 /// Sets the *user project* query property to the given value.
21953 pub fn user_project(mut self, new_value: &str) -> NotificationGetCall<'a, C> {
21954 self._user_project = Some(new_value.to_string());
21955 self
21956 }
21957 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21958 /// while executing the actual API request.
21959 ///
21960 /// ````text
21961 /// It should be used to handle progress information, and to implement a certain level of resilience.
21962 /// ````
21963 ///
21964 /// Sets the *delegate* property to the given value.
21965 pub fn delegate(
21966 mut self,
21967 new_value: &'a mut dyn common::Delegate,
21968 ) -> NotificationGetCall<'a, C> {
21969 self._delegate = Some(new_value);
21970 self
21971 }
21972
21973 /// Set any additional parameter of the query string used in the request.
21974 /// It should be used to set parameters which are not yet available through their own
21975 /// setters.
21976 ///
21977 /// Please note that this method must not be used to set any of the known parameters
21978 /// which have their own setter method. If done anyway, the request will fail.
21979 ///
21980 /// # Additional Parameters
21981 ///
21982 /// * *alt* (query-string) - Data format for the response.
21983 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21984 /// * *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.
21985 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21986 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21987 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21988 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
21989 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21990 pub fn param<T>(mut self, name: T, value: T) -> NotificationGetCall<'a, C>
21991 where
21992 T: AsRef<str>,
21993 {
21994 self._additional_params
21995 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21996 self
21997 }
21998
21999 /// Identifies the authorization scope for the method you are building.
22000 ///
22001 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22002 /// [`Scope::DevstorageReadOnly`].
22003 ///
22004 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22005 /// tokens for more than one scope.
22006 ///
22007 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22008 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22009 /// sufficient, a read-write scope will do as well.
22010 pub fn add_scope<St>(mut self, scope: St) -> NotificationGetCall<'a, C>
22011 where
22012 St: AsRef<str>,
22013 {
22014 self._scopes.insert(String::from(scope.as_ref()));
22015 self
22016 }
22017 /// Identifies the authorization scope(s) for the method you are building.
22018 ///
22019 /// See [`Self::add_scope()`] for details.
22020 pub fn add_scopes<I, St>(mut self, scopes: I) -> NotificationGetCall<'a, C>
22021 where
22022 I: IntoIterator<Item = St>,
22023 St: AsRef<str>,
22024 {
22025 self._scopes
22026 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22027 self
22028 }
22029
22030 /// Removes all scopes, and no default scope will be used either.
22031 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22032 /// for details).
22033 pub fn clear_scopes(mut self) -> NotificationGetCall<'a, C> {
22034 self._scopes.clear();
22035 self
22036 }
22037}
22038
22039/// Creates a notification subscription for a given bucket.
22040///
22041/// A builder for the *insert* method supported by a *notification* resource.
22042/// It is not used directly, but through a [`NotificationMethods`] instance.
22043///
22044/// # Example
22045///
22046/// Instantiate a resource method builder
22047///
22048/// ```test_harness,no_run
22049/// # extern crate hyper;
22050/// # extern crate hyper_rustls;
22051/// # extern crate google_storage1 as storage1;
22052/// use storage1::api::Notification;
22053/// # async fn dox() {
22054/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22055///
22056/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22057/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22058/// # .with_native_roots()
22059/// # .unwrap()
22060/// # .https_only()
22061/// # .enable_http2()
22062/// # .build();
22063///
22064/// # let executor = hyper_util::rt::TokioExecutor::new();
22065/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22066/// # secret,
22067/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22068/// # yup_oauth2::client::CustomHyperClientBuilder::from(
22069/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
22070/// # ),
22071/// # ).build().await.unwrap();
22072///
22073/// # let client = hyper_util::client::legacy::Client::builder(
22074/// # hyper_util::rt::TokioExecutor::new()
22075/// # )
22076/// # .build(
22077/// # hyper_rustls::HttpsConnectorBuilder::new()
22078/// # .with_native_roots()
22079/// # .unwrap()
22080/// # .https_or_http()
22081/// # .enable_http2()
22082/// # .build()
22083/// # );
22084/// # let mut hub = Storage::new(client, auth);
22085/// // As the method needs a request, you would usually fill it with the desired information
22086/// // into the respective structure. Some of the parts shown here might not be applicable !
22087/// // Values shown here are possibly random and not representative !
22088/// let mut req = Notification::default();
22089///
22090/// // You can configure optional parameters by calling the respective setters at will, and
22091/// // execute the final call using `doit()`.
22092/// // Values shown here are possibly random and not representative !
22093/// let result = hub.notifications().insert(req, "bucket")
22094/// .user_project("magna")
22095/// .doit().await;
22096/// # }
22097/// ```
22098pub struct NotificationInsertCall<'a, C>
22099where
22100 C: 'a,
22101{
22102 hub: &'a Storage<C>,
22103 _request: Notification,
22104 _bucket: String,
22105 _user_project: Option<String>,
22106 _delegate: Option<&'a mut dyn common::Delegate>,
22107 _additional_params: HashMap<String, String>,
22108 _scopes: BTreeSet<String>,
22109}
22110
22111impl<'a, C> common::CallBuilder for NotificationInsertCall<'a, C> {}
22112
22113impl<'a, C> NotificationInsertCall<'a, C>
22114where
22115 C: common::Connector,
22116{
22117 /// Perform the operation you have build so far.
22118 pub async fn doit(mut self) -> common::Result<(common::Response, Notification)> {
22119 use std::borrow::Cow;
22120 use std::io::{Read, Seek};
22121
22122 use common::{url::Params, ToParts};
22123 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22124
22125 let mut dd = common::DefaultDelegate;
22126 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22127 dlg.begin(common::MethodInfo {
22128 id: "storage.notifications.insert",
22129 http_method: hyper::Method::POST,
22130 });
22131
22132 for &field in ["alt", "bucket", "userProject"].iter() {
22133 if self._additional_params.contains_key(field) {
22134 dlg.finished(false);
22135 return Err(common::Error::FieldClash(field));
22136 }
22137 }
22138
22139 let mut params = Params::with_capacity(5 + self._additional_params.len());
22140 params.push("bucket", self._bucket);
22141 if let Some(value) = self._user_project.as_ref() {
22142 params.push("userProject", value);
22143 }
22144
22145 params.extend(self._additional_params.iter());
22146
22147 params.push("alt", "json");
22148 let mut url = self.hub._base_url.clone() + "b/{bucket}/notificationConfigs";
22149 if self._scopes.is_empty() {
22150 self._scopes
22151 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
22152 }
22153
22154 #[allow(clippy::single_element_loop)]
22155 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
22156 url = params.uri_replacement(url, param_name, find_this, false);
22157 }
22158 {
22159 let to_remove = ["bucket"];
22160 params.remove_params(&to_remove);
22161 }
22162
22163 let url = params.parse_with_url(&url);
22164
22165 let mut json_mime_type = mime::APPLICATION_JSON;
22166 let mut request_value_reader = {
22167 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22168 common::remove_json_null_values(&mut value);
22169 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22170 serde_json::to_writer(&mut dst, &value).unwrap();
22171 dst
22172 };
22173 let request_size = request_value_reader
22174 .seek(std::io::SeekFrom::End(0))
22175 .unwrap();
22176 request_value_reader
22177 .seek(std::io::SeekFrom::Start(0))
22178 .unwrap();
22179
22180 loop {
22181 let token = match self
22182 .hub
22183 .auth
22184 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22185 .await
22186 {
22187 Ok(token) => token,
22188 Err(e) => match dlg.token(e) {
22189 Ok(token) => token,
22190 Err(e) => {
22191 dlg.finished(false);
22192 return Err(common::Error::MissingToken(e));
22193 }
22194 },
22195 };
22196 request_value_reader
22197 .seek(std::io::SeekFrom::Start(0))
22198 .unwrap();
22199 let mut req_result = {
22200 let client = &self.hub.client;
22201 dlg.pre_request();
22202 let mut req_builder = hyper::Request::builder()
22203 .method(hyper::Method::POST)
22204 .uri(url.as_str())
22205 .header(USER_AGENT, self.hub._user_agent.clone());
22206
22207 if let Some(token) = token.as_ref() {
22208 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22209 }
22210
22211 let request = req_builder
22212 .header(CONTENT_TYPE, json_mime_type.to_string())
22213 .header(CONTENT_LENGTH, request_size as u64)
22214 .body(common::to_body(
22215 request_value_reader.get_ref().clone().into(),
22216 ));
22217
22218 client.request(request.unwrap()).await
22219 };
22220
22221 match req_result {
22222 Err(err) => {
22223 if let common::Retry::After(d) = dlg.http_error(&err) {
22224 sleep(d).await;
22225 continue;
22226 }
22227 dlg.finished(false);
22228 return Err(common::Error::HttpError(err));
22229 }
22230 Ok(res) => {
22231 let (mut parts, body) = res.into_parts();
22232 let mut body = common::Body::new(body);
22233 if !parts.status.is_success() {
22234 let bytes = common::to_bytes(body).await.unwrap_or_default();
22235 let error = serde_json::from_str(&common::to_string(&bytes));
22236 let response = common::to_response(parts, bytes.into());
22237
22238 if let common::Retry::After(d) =
22239 dlg.http_failure(&response, error.as_ref().ok())
22240 {
22241 sleep(d).await;
22242 continue;
22243 }
22244
22245 dlg.finished(false);
22246
22247 return Err(match error {
22248 Ok(value) => common::Error::BadRequest(value),
22249 _ => common::Error::Failure(response),
22250 });
22251 }
22252 let response = {
22253 let bytes = common::to_bytes(body).await.unwrap_or_default();
22254 let encoded = common::to_string(&bytes);
22255 match serde_json::from_str(&encoded) {
22256 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22257 Err(error) => {
22258 dlg.response_json_decode_error(&encoded, &error);
22259 return Err(common::Error::JsonDecodeError(
22260 encoded.to_string(),
22261 error,
22262 ));
22263 }
22264 }
22265 };
22266
22267 dlg.finished(true);
22268 return Ok(response);
22269 }
22270 }
22271 }
22272 }
22273
22274 ///
22275 /// Sets the *request* property to the given value.
22276 ///
22277 /// Even though the property as already been set when instantiating this call,
22278 /// we provide this method for API completeness.
22279 pub fn request(mut self, new_value: Notification) -> NotificationInsertCall<'a, C> {
22280 self._request = new_value;
22281 self
22282 }
22283 /// The parent bucket of the notification.
22284 ///
22285 /// Sets the *bucket* path property to the given value.
22286 ///
22287 /// Even though the property as already been set when instantiating this call,
22288 /// we provide this method for API completeness.
22289 pub fn bucket(mut self, new_value: &str) -> NotificationInsertCall<'a, C> {
22290 self._bucket = new_value.to_string();
22291 self
22292 }
22293 /// The project to be billed for this request. Required for Requester Pays buckets.
22294 ///
22295 /// Sets the *user project* query property to the given value.
22296 pub fn user_project(mut self, new_value: &str) -> NotificationInsertCall<'a, C> {
22297 self._user_project = Some(new_value.to_string());
22298 self
22299 }
22300 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22301 /// while executing the actual API request.
22302 ///
22303 /// ````text
22304 /// It should be used to handle progress information, and to implement a certain level of resilience.
22305 /// ````
22306 ///
22307 /// Sets the *delegate* property to the given value.
22308 pub fn delegate(
22309 mut self,
22310 new_value: &'a mut dyn common::Delegate,
22311 ) -> NotificationInsertCall<'a, C> {
22312 self._delegate = Some(new_value);
22313 self
22314 }
22315
22316 /// Set any additional parameter of the query string used in the request.
22317 /// It should be used to set parameters which are not yet available through their own
22318 /// setters.
22319 ///
22320 /// Please note that this method must not be used to set any of the known parameters
22321 /// which have their own setter method. If done anyway, the request will fail.
22322 ///
22323 /// # Additional Parameters
22324 ///
22325 /// * *alt* (query-string) - Data format for the response.
22326 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22327 /// * *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.
22328 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22329 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22330 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
22331 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
22332 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
22333 pub fn param<T>(mut self, name: T, value: T) -> NotificationInsertCall<'a, C>
22334 where
22335 T: AsRef<str>,
22336 {
22337 self._additional_params
22338 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22339 self
22340 }
22341
22342 /// Identifies the authorization scope for the method you are building.
22343 ///
22344 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22345 /// [`Scope::DevstorageReadWrite`].
22346 ///
22347 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22348 /// tokens for more than one scope.
22349 ///
22350 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22351 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22352 /// sufficient, a read-write scope will do as well.
22353 pub fn add_scope<St>(mut self, scope: St) -> NotificationInsertCall<'a, C>
22354 where
22355 St: AsRef<str>,
22356 {
22357 self._scopes.insert(String::from(scope.as_ref()));
22358 self
22359 }
22360 /// Identifies the authorization scope(s) for the method you are building.
22361 ///
22362 /// See [`Self::add_scope()`] for details.
22363 pub fn add_scopes<I, St>(mut self, scopes: I) -> NotificationInsertCall<'a, C>
22364 where
22365 I: IntoIterator<Item = St>,
22366 St: AsRef<str>,
22367 {
22368 self._scopes
22369 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22370 self
22371 }
22372
22373 /// Removes all scopes, and no default scope will be used either.
22374 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22375 /// for details).
22376 pub fn clear_scopes(mut self) -> NotificationInsertCall<'a, C> {
22377 self._scopes.clear();
22378 self
22379 }
22380}
22381
22382/// Retrieves a list of notification subscriptions for a given bucket.
22383///
22384/// A builder for the *list* method supported by a *notification* resource.
22385/// It is not used directly, but through a [`NotificationMethods`] instance.
22386///
22387/// # Example
22388///
22389/// Instantiate a resource method builder
22390///
22391/// ```test_harness,no_run
22392/// # extern crate hyper;
22393/// # extern crate hyper_rustls;
22394/// # extern crate google_storage1 as storage1;
22395/// # async fn dox() {
22396/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22397///
22398/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22399/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22400/// # .with_native_roots()
22401/// # .unwrap()
22402/// # .https_only()
22403/// # .enable_http2()
22404/// # .build();
22405///
22406/// # let executor = hyper_util::rt::TokioExecutor::new();
22407/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22408/// # secret,
22409/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22410/// # yup_oauth2::client::CustomHyperClientBuilder::from(
22411/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
22412/// # ),
22413/// # ).build().await.unwrap();
22414///
22415/// # let client = hyper_util::client::legacy::Client::builder(
22416/// # hyper_util::rt::TokioExecutor::new()
22417/// # )
22418/// # .build(
22419/// # hyper_rustls::HttpsConnectorBuilder::new()
22420/// # .with_native_roots()
22421/// # .unwrap()
22422/// # .https_or_http()
22423/// # .enable_http2()
22424/// # .build()
22425/// # );
22426/// # let mut hub = Storage::new(client, auth);
22427/// // You can configure optional parameters by calling the respective setters at will, and
22428/// // execute the final call using `doit()`.
22429/// // Values shown here are possibly random and not representative !
22430/// let result = hub.notifications().list("bucket")
22431/// .user_project("rebum.")
22432/// .doit().await;
22433/// # }
22434/// ```
22435pub struct NotificationListCall<'a, C>
22436where
22437 C: 'a,
22438{
22439 hub: &'a Storage<C>,
22440 _bucket: String,
22441 _user_project: Option<String>,
22442 _delegate: Option<&'a mut dyn common::Delegate>,
22443 _additional_params: HashMap<String, String>,
22444 _scopes: BTreeSet<String>,
22445}
22446
22447impl<'a, C> common::CallBuilder for NotificationListCall<'a, C> {}
22448
22449impl<'a, C> NotificationListCall<'a, C>
22450where
22451 C: common::Connector,
22452{
22453 /// Perform the operation you have build so far.
22454 pub async fn doit(mut self) -> common::Result<(common::Response, Notifications)> {
22455 use std::borrow::Cow;
22456 use std::io::{Read, Seek};
22457
22458 use common::{url::Params, ToParts};
22459 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22460
22461 let mut dd = common::DefaultDelegate;
22462 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22463 dlg.begin(common::MethodInfo {
22464 id: "storage.notifications.list",
22465 http_method: hyper::Method::GET,
22466 });
22467
22468 for &field in ["alt", "bucket", "userProject"].iter() {
22469 if self._additional_params.contains_key(field) {
22470 dlg.finished(false);
22471 return Err(common::Error::FieldClash(field));
22472 }
22473 }
22474
22475 let mut params = Params::with_capacity(4 + self._additional_params.len());
22476 params.push("bucket", self._bucket);
22477 if let Some(value) = self._user_project.as_ref() {
22478 params.push("userProject", value);
22479 }
22480
22481 params.extend(self._additional_params.iter());
22482
22483 params.push("alt", "json");
22484 let mut url = self.hub._base_url.clone() + "b/{bucket}/notificationConfigs";
22485 if self._scopes.is_empty() {
22486 self._scopes
22487 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
22488 }
22489
22490 #[allow(clippy::single_element_loop)]
22491 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
22492 url = params.uri_replacement(url, param_name, find_this, false);
22493 }
22494 {
22495 let to_remove = ["bucket"];
22496 params.remove_params(&to_remove);
22497 }
22498
22499 let url = params.parse_with_url(&url);
22500
22501 loop {
22502 let token = match self
22503 .hub
22504 .auth
22505 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22506 .await
22507 {
22508 Ok(token) => token,
22509 Err(e) => match dlg.token(e) {
22510 Ok(token) => token,
22511 Err(e) => {
22512 dlg.finished(false);
22513 return Err(common::Error::MissingToken(e));
22514 }
22515 },
22516 };
22517 let mut req_result = {
22518 let client = &self.hub.client;
22519 dlg.pre_request();
22520 let mut req_builder = hyper::Request::builder()
22521 .method(hyper::Method::GET)
22522 .uri(url.as_str())
22523 .header(USER_AGENT, self.hub._user_agent.clone());
22524
22525 if let Some(token) = token.as_ref() {
22526 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22527 }
22528
22529 let request = req_builder
22530 .header(CONTENT_LENGTH, 0_u64)
22531 .body(common::to_body::<String>(None));
22532
22533 client.request(request.unwrap()).await
22534 };
22535
22536 match req_result {
22537 Err(err) => {
22538 if let common::Retry::After(d) = dlg.http_error(&err) {
22539 sleep(d).await;
22540 continue;
22541 }
22542 dlg.finished(false);
22543 return Err(common::Error::HttpError(err));
22544 }
22545 Ok(res) => {
22546 let (mut parts, body) = res.into_parts();
22547 let mut body = common::Body::new(body);
22548 if !parts.status.is_success() {
22549 let bytes = common::to_bytes(body).await.unwrap_or_default();
22550 let error = serde_json::from_str(&common::to_string(&bytes));
22551 let response = common::to_response(parts, bytes.into());
22552
22553 if let common::Retry::After(d) =
22554 dlg.http_failure(&response, error.as_ref().ok())
22555 {
22556 sleep(d).await;
22557 continue;
22558 }
22559
22560 dlg.finished(false);
22561
22562 return Err(match error {
22563 Ok(value) => common::Error::BadRequest(value),
22564 _ => common::Error::Failure(response),
22565 });
22566 }
22567 let response = {
22568 let bytes = common::to_bytes(body).await.unwrap_or_default();
22569 let encoded = common::to_string(&bytes);
22570 match serde_json::from_str(&encoded) {
22571 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22572 Err(error) => {
22573 dlg.response_json_decode_error(&encoded, &error);
22574 return Err(common::Error::JsonDecodeError(
22575 encoded.to_string(),
22576 error,
22577 ));
22578 }
22579 }
22580 };
22581
22582 dlg.finished(true);
22583 return Ok(response);
22584 }
22585 }
22586 }
22587 }
22588
22589 /// Name of a Google Cloud Storage bucket.
22590 ///
22591 /// Sets the *bucket* path property to the given value.
22592 ///
22593 /// Even though the property as already been set when instantiating this call,
22594 /// we provide this method for API completeness.
22595 pub fn bucket(mut self, new_value: &str) -> NotificationListCall<'a, C> {
22596 self._bucket = new_value.to_string();
22597 self
22598 }
22599 /// The project to be billed for this request. Required for Requester Pays buckets.
22600 ///
22601 /// Sets the *user project* query property to the given value.
22602 pub fn user_project(mut self, new_value: &str) -> NotificationListCall<'a, C> {
22603 self._user_project = Some(new_value.to_string());
22604 self
22605 }
22606 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22607 /// while executing the actual API request.
22608 ///
22609 /// ````text
22610 /// It should be used to handle progress information, and to implement a certain level of resilience.
22611 /// ````
22612 ///
22613 /// Sets the *delegate* property to the given value.
22614 pub fn delegate(
22615 mut self,
22616 new_value: &'a mut dyn common::Delegate,
22617 ) -> NotificationListCall<'a, C> {
22618 self._delegate = Some(new_value);
22619 self
22620 }
22621
22622 /// Set any additional parameter of the query string used in the request.
22623 /// It should be used to set parameters which are not yet available through their own
22624 /// setters.
22625 ///
22626 /// Please note that this method must not be used to set any of the known parameters
22627 /// which have their own setter method. If done anyway, the request will fail.
22628 ///
22629 /// # Additional Parameters
22630 ///
22631 /// * *alt* (query-string) - Data format for the response.
22632 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22633 /// * *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.
22634 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22635 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22636 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
22637 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
22638 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
22639 pub fn param<T>(mut self, name: T, value: T) -> NotificationListCall<'a, C>
22640 where
22641 T: AsRef<str>,
22642 {
22643 self._additional_params
22644 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22645 self
22646 }
22647
22648 /// Identifies the authorization scope for the method you are building.
22649 ///
22650 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22651 /// [`Scope::DevstorageReadOnly`].
22652 ///
22653 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22654 /// tokens for more than one scope.
22655 ///
22656 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22657 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22658 /// sufficient, a read-write scope will do as well.
22659 pub fn add_scope<St>(mut self, scope: St) -> NotificationListCall<'a, C>
22660 where
22661 St: AsRef<str>,
22662 {
22663 self._scopes.insert(String::from(scope.as_ref()));
22664 self
22665 }
22666 /// Identifies the authorization scope(s) for the method you are building.
22667 ///
22668 /// See [`Self::add_scope()`] for details.
22669 pub fn add_scopes<I, St>(mut self, scopes: I) -> NotificationListCall<'a, C>
22670 where
22671 I: IntoIterator<Item = St>,
22672 St: AsRef<str>,
22673 {
22674 self._scopes
22675 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22676 self
22677 }
22678
22679 /// Removes all scopes, and no default scope will be used either.
22680 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22681 /// for details).
22682 pub fn clear_scopes(mut self) -> NotificationListCall<'a, C> {
22683 self._scopes.clear();
22684 self
22685 }
22686}
22687
22688/// Permanently deletes the ACL entry for the specified entity on the specified object.
22689///
22690/// A builder for the *delete* method supported by a *objectAccessControl* resource.
22691/// It is not used directly, but through a [`ObjectAccessControlMethods`] instance.
22692///
22693/// # Example
22694///
22695/// Instantiate a resource method builder
22696///
22697/// ```test_harness,no_run
22698/// # extern crate hyper;
22699/// # extern crate hyper_rustls;
22700/// # extern crate google_storage1 as storage1;
22701/// # async fn dox() {
22702/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22703///
22704/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22705/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22706/// # .with_native_roots()
22707/// # .unwrap()
22708/// # .https_only()
22709/// # .enable_http2()
22710/// # .build();
22711///
22712/// # let executor = hyper_util::rt::TokioExecutor::new();
22713/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22714/// # secret,
22715/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22716/// # yup_oauth2::client::CustomHyperClientBuilder::from(
22717/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
22718/// # ),
22719/// # ).build().await.unwrap();
22720///
22721/// # let client = hyper_util::client::legacy::Client::builder(
22722/// # hyper_util::rt::TokioExecutor::new()
22723/// # )
22724/// # .build(
22725/// # hyper_rustls::HttpsConnectorBuilder::new()
22726/// # .with_native_roots()
22727/// # .unwrap()
22728/// # .https_or_http()
22729/// # .enable_http2()
22730/// # .build()
22731/// # );
22732/// # let mut hub = Storage::new(client, auth);
22733/// // You can configure optional parameters by calling the respective setters at will, and
22734/// // execute the final call using `doit()`.
22735/// // Values shown here are possibly random and not representative !
22736/// let result = hub.object_access_controls().delete("bucket", "object", "entity")
22737/// .user_project("amet.")
22738/// .generation(-11)
22739/// .doit().await;
22740/// # }
22741/// ```
22742pub struct ObjectAccessControlDeleteCall<'a, C>
22743where
22744 C: 'a,
22745{
22746 hub: &'a Storage<C>,
22747 _bucket: String,
22748 _object: String,
22749 _entity: String,
22750 _user_project: Option<String>,
22751 _generation: Option<i64>,
22752 _delegate: Option<&'a mut dyn common::Delegate>,
22753 _additional_params: HashMap<String, String>,
22754 _scopes: BTreeSet<String>,
22755}
22756
22757impl<'a, C> common::CallBuilder for ObjectAccessControlDeleteCall<'a, C> {}
22758
22759impl<'a, C> ObjectAccessControlDeleteCall<'a, C>
22760where
22761 C: common::Connector,
22762{
22763 /// Perform the operation you have build so far.
22764 pub async fn doit(mut self) -> common::Result<common::Response> {
22765 use std::borrow::Cow;
22766 use std::io::{Read, Seek};
22767
22768 use common::{url::Params, ToParts};
22769 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22770
22771 let mut dd = common::DefaultDelegate;
22772 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22773 dlg.begin(common::MethodInfo {
22774 id: "storage.objectAccessControls.delete",
22775 http_method: hyper::Method::DELETE,
22776 });
22777
22778 for &field in ["bucket", "object", "entity", "userProject", "generation"].iter() {
22779 if self._additional_params.contains_key(field) {
22780 dlg.finished(false);
22781 return Err(common::Error::FieldClash(field));
22782 }
22783 }
22784
22785 let mut params = Params::with_capacity(6 + self._additional_params.len());
22786 params.push("bucket", self._bucket);
22787 params.push("object", self._object);
22788 params.push("entity", self._entity);
22789 if let Some(value) = self._user_project.as_ref() {
22790 params.push("userProject", value);
22791 }
22792 if let Some(value) = self._generation.as_ref() {
22793 params.push("generation", value.to_string());
22794 }
22795
22796 params.extend(self._additional_params.iter());
22797
22798 let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}/acl/{entity}";
22799 if self._scopes.is_empty() {
22800 self._scopes
22801 .insert(Scope::DevstorageFullControl.as_ref().to_string());
22802 }
22803
22804 #[allow(clippy::single_element_loop)]
22805 for &(find_this, param_name) in [
22806 ("{bucket}", "bucket"),
22807 ("{object}", "object"),
22808 ("{entity}", "entity"),
22809 ]
22810 .iter()
22811 {
22812 url = params.uri_replacement(url, param_name, find_this, false);
22813 }
22814 {
22815 let to_remove = ["entity", "object", "bucket"];
22816 params.remove_params(&to_remove);
22817 }
22818
22819 let url = params.parse_with_url(&url);
22820
22821 loop {
22822 let token = match self
22823 .hub
22824 .auth
22825 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22826 .await
22827 {
22828 Ok(token) => token,
22829 Err(e) => match dlg.token(e) {
22830 Ok(token) => token,
22831 Err(e) => {
22832 dlg.finished(false);
22833 return Err(common::Error::MissingToken(e));
22834 }
22835 },
22836 };
22837 let mut req_result = {
22838 let client = &self.hub.client;
22839 dlg.pre_request();
22840 let mut req_builder = hyper::Request::builder()
22841 .method(hyper::Method::DELETE)
22842 .uri(url.as_str())
22843 .header(USER_AGENT, self.hub._user_agent.clone());
22844
22845 if let Some(token) = token.as_ref() {
22846 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22847 }
22848
22849 let request = req_builder
22850 .header(CONTENT_LENGTH, 0_u64)
22851 .body(common::to_body::<String>(None));
22852
22853 client.request(request.unwrap()).await
22854 };
22855
22856 match req_result {
22857 Err(err) => {
22858 if let common::Retry::After(d) = dlg.http_error(&err) {
22859 sleep(d).await;
22860 continue;
22861 }
22862 dlg.finished(false);
22863 return Err(common::Error::HttpError(err));
22864 }
22865 Ok(res) => {
22866 let (mut parts, body) = res.into_parts();
22867 let mut body = common::Body::new(body);
22868 if !parts.status.is_success() {
22869 let bytes = common::to_bytes(body).await.unwrap_or_default();
22870 let error = serde_json::from_str(&common::to_string(&bytes));
22871 let response = common::to_response(parts, bytes.into());
22872
22873 if let common::Retry::After(d) =
22874 dlg.http_failure(&response, error.as_ref().ok())
22875 {
22876 sleep(d).await;
22877 continue;
22878 }
22879
22880 dlg.finished(false);
22881
22882 return Err(match error {
22883 Ok(value) => common::Error::BadRequest(value),
22884 _ => common::Error::Failure(response),
22885 });
22886 }
22887 let response = common::Response::from_parts(parts, body);
22888
22889 dlg.finished(true);
22890 return Ok(response);
22891 }
22892 }
22893 }
22894 }
22895
22896 /// Name of a bucket.
22897 ///
22898 /// Sets the *bucket* path property to the given value.
22899 ///
22900 /// Even though the property as already been set when instantiating this call,
22901 /// we provide this method for API completeness.
22902 pub fn bucket(mut self, new_value: &str) -> ObjectAccessControlDeleteCall<'a, C> {
22903 self._bucket = new_value.to_string();
22904 self
22905 }
22906 /// 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).
22907 ///
22908 /// Sets the *object* path property to the given value.
22909 ///
22910 /// Even though the property as already been set when instantiating this call,
22911 /// we provide this method for API completeness.
22912 pub fn object(mut self, new_value: &str) -> ObjectAccessControlDeleteCall<'a, C> {
22913 self._object = new_value.to_string();
22914 self
22915 }
22916 /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
22917 ///
22918 /// Sets the *entity* path property to the given value.
22919 ///
22920 /// Even though the property as already been set when instantiating this call,
22921 /// we provide this method for API completeness.
22922 pub fn entity(mut self, new_value: &str) -> ObjectAccessControlDeleteCall<'a, C> {
22923 self._entity = new_value.to_string();
22924 self
22925 }
22926 /// The project to be billed for this request. Required for Requester Pays buckets.
22927 ///
22928 /// Sets the *user project* query property to the given value.
22929 pub fn user_project(mut self, new_value: &str) -> ObjectAccessControlDeleteCall<'a, C> {
22930 self._user_project = Some(new_value.to_string());
22931 self
22932 }
22933 /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
22934 ///
22935 /// Sets the *generation* query property to the given value.
22936 pub fn generation(mut self, new_value: i64) -> ObjectAccessControlDeleteCall<'a, C> {
22937 self._generation = Some(new_value);
22938 self
22939 }
22940 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22941 /// while executing the actual API request.
22942 ///
22943 /// ````text
22944 /// It should be used to handle progress information, and to implement a certain level of resilience.
22945 /// ````
22946 ///
22947 /// Sets the *delegate* property to the given value.
22948 pub fn delegate(
22949 mut self,
22950 new_value: &'a mut dyn common::Delegate,
22951 ) -> ObjectAccessControlDeleteCall<'a, C> {
22952 self._delegate = Some(new_value);
22953 self
22954 }
22955
22956 /// Set any additional parameter of the query string used in the request.
22957 /// It should be used to set parameters which are not yet available through their own
22958 /// setters.
22959 ///
22960 /// Please note that this method must not be used to set any of the known parameters
22961 /// which have their own setter method. If done anyway, the request will fail.
22962 ///
22963 /// # Additional Parameters
22964 ///
22965 /// * *alt* (query-string) - Data format for the response.
22966 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22967 /// * *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.
22968 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22969 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22970 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
22971 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
22972 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
22973 pub fn param<T>(mut self, name: T, value: T) -> ObjectAccessControlDeleteCall<'a, C>
22974 where
22975 T: AsRef<str>,
22976 {
22977 self._additional_params
22978 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22979 self
22980 }
22981
22982 /// Identifies the authorization scope for the method you are building.
22983 ///
22984 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22985 /// [`Scope::DevstorageFullControl`].
22986 ///
22987 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22988 /// tokens for more than one scope.
22989 ///
22990 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22991 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22992 /// sufficient, a read-write scope will do as well.
22993 pub fn add_scope<St>(mut self, scope: St) -> ObjectAccessControlDeleteCall<'a, C>
22994 where
22995 St: AsRef<str>,
22996 {
22997 self._scopes.insert(String::from(scope.as_ref()));
22998 self
22999 }
23000 /// Identifies the authorization scope(s) for the method you are building.
23001 ///
23002 /// See [`Self::add_scope()`] for details.
23003 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectAccessControlDeleteCall<'a, C>
23004 where
23005 I: IntoIterator<Item = St>,
23006 St: AsRef<str>,
23007 {
23008 self._scopes
23009 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23010 self
23011 }
23012
23013 /// Removes all scopes, and no default scope will be used either.
23014 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23015 /// for details).
23016 pub fn clear_scopes(mut self) -> ObjectAccessControlDeleteCall<'a, C> {
23017 self._scopes.clear();
23018 self
23019 }
23020}
23021
23022/// Returns the ACL entry for the specified entity on the specified object.
23023///
23024/// A builder for the *get* method supported by a *objectAccessControl* resource.
23025/// It is not used directly, but through a [`ObjectAccessControlMethods`] instance.
23026///
23027/// # Example
23028///
23029/// Instantiate a resource method builder
23030///
23031/// ```test_harness,no_run
23032/// # extern crate hyper;
23033/// # extern crate hyper_rustls;
23034/// # extern crate google_storage1 as storage1;
23035/// # async fn dox() {
23036/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23037///
23038/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23039/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23040/// # .with_native_roots()
23041/// # .unwrap()
23042/// # .https_only()
23043/// # .enable_http2()
23044/// # .build();
23045///
23046/// # let executor = hyper_util::rt::TokioExecutor::new();
23047/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23048/// # secret,
23049/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23050/// # yup_oauth2::client::CustomHyperClientBuilder::from(
23051/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
23052/// # ),
23053/// # ).build().await.unwrap();
23054///
23055/// # let client = hyper_util::client::legacy::Client::builder(
23056/// # hyper_util::rt::TokioExecutor::new()
23057/// # )
23058/// # .build(
23059/// # hyper_rustls::HttpsConnectorBuilder::new()
23060/// # .with_native_roots()
23061/// # .unwrap()
23062/// # .https_or_http()
23063/// # .enable_http2()
23064/// # .build()
23065/// # );
23066/// # let mut hub = Storage::new(client, auth);
23067/// // You can configure optional parameters by calling the respective setters at will, and
23068/// // execute the final call using `doit()`.
23069/// // Values shown here are possibly random and not representative !
23070/// let result = hub.object_access_controls().get("bucket", "object", "entity")
23071/// .user_project("Lorem")
23072/// .generation(-58)
23073/// .doit().await;
23074/// # }
23075/// ```
23076pub struct ObjectAccessControlGetCall<'a, C>
23077where
23078 C: 'a,
23079{
23080 hub: &'a Storage<C>,
23081 _bucket: String,
23082 _object: String,
23083 _entity: String,
23084 _user_project: Option<String>,
23085 _generation: Option<i64>,
23086 _delegate: Option<&'a mut dyn common::Delegate>,
23087 _additional_params: HashMap<String, String>,
23088 _scopes: BTreeSet<String>,
23089}
23090
23091impl<'a, C> common::CallBuilder for ObjectAccessControlGetCall<'a, C> {}
23092
23093impl<'a, C> ObjectAccessControlGetCall<'a, C>
23094where
23095 C: common::Connector,
23096{
23097 /// Perform the operation you have build so far.
23098 pub async fn doit(mut self) -> common::Result<(common::Response, ObjectAccessControl)> {
23099 use std::borrow::Cow;
23100 use std::io::{Read, Seek};
23101
23102 use common::{url::Params, ToParts};
23103 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23104
23105 let mut dd = common::DefaultDelegate;
23106 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23107 dlg.begin(common::MethodInfo {
23108 id: "storage.objectAccessControls.get",
23109 http_method: hyper::Method::GET,
23110 });
23111
23112 for &field in [
23113 "alt",
23114 "bucket",
23115 "object",
23116 "entity",
23117 "userProject",
23118 "generation",
23119 ]
23120 .iter()
23121 {
23122 if self._additional_params.contains_key(field) {
23123 dlg.finished(false);
23124 return Err(common::Error::FieldClash(field));
23125 }
23126 }
23127
23128 let mut params = Params::with_capacity(7 + self._additional_params.len());
23129 params.push("bucket", self._bucket);
23130 params.push("object", self._object);
23131 params.push("entity", self._entity);
23132 if let Some(value) = self._user_project.as_ref() {
23133 params.push("userProject", value);
23134 }
23135 if let Some(value) = self._generation.as_ref() {
23136 params.push("generation", value.to_string());
23137 }
23138
23139 params.extend(self._additional_params.iter());
23140
23141 params.push("alt", "json");
23142 let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}/acl/{entity}";
23143 if self._scopes.is_empty() {
23144 self._scopes
23145 .insert(Scope::DevstorageFullControl.as_ref().to_string());
23146 }
23147
23148 #[allow(clippy::single_element_loop)]
23149 for &(find_this, param_name) in [
23150 ("{bucket}", "bucket"),
23151 ("{object}", "object"),
23152 ("{entity}", "entity"),
23153 ]
23154 .iter()
23155 {
23156 url = params.uri_replacement(url, param_name, find_this, false);
23157 }
23158 {
23159 let to_remove = ["entity", "object", "bucket"];
23160 params.remove_params(&to_remove);
23161 }
23162
23163 let url = params.parse_with_url(&url);
23164
23165 loop {
23166 let token = match self
23167 .hub
23168 .auth
23169 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23170 .await
23171 {
23172 Ok(token) => token,
23173 Err(e) => match dlg.token(e) {
23174 Ok(token) => token,
23175 Err(e) => {
23176 dlg.finished(false);
23177 return Err(common::Error::MissingToken(e));
23178 }
23179 },
23180 };
23181 let mut req_result = {
23182 let client = &self.hub.client;
23183 dlg.pre_request();
23184 let mut req_builder = hyper::Request::builder()
23185 .method(hyper::Method::GET)
23186 .uri(url.as_str())
23187 .header(USER_AGENT, self.hub._user_agent.clone());
23188
23189 if let Some(token) = token.as_ref() {
23190 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23191 }
23192
23193 let request = req_builder
23194 .header(CONTENT_LENGTH, 0_u64)
23195 .body(common::to_body::<String>(None));
23196
23197 client.request(request.unwrap()).await
23198 };
23199
23200 match req_result {
23201 Err(err) => {
23202 if let common::Retry::After(d) = dlg.http_error(&err) {
23203 sleep(d).await;
23204 continue;
23205 }
23206 dlg.finished(false);
23207 return Err(common::Error::HttpError(err));
23208 }
23209 Ok(res) => {
23210 let (mut parts, body) = res.into_parts();
23211 let mut body = common::Body::new(body);
23212 if !parts.status.is_success() {
23213 let bytes = common::to_bytes(body).await.unwrap_or_default();
23214 let error = serde_json::from_str(&common::to_string(&bytes));
23215 let response = common::to_response(parts, bytes.into());
23216
23217 if let common::Retry::After(d) =
23218 dlg.http_failure(&response, error.as_ref().ok())
23219 {
23220 sleep(d).await;
23221 continue;
23222 }
23223
23224 dlg.finished(false);
23225
23226 return Err(match error {
23227 Ok(value) => common::Error::BadRequest(value),
23228 _ => common::Error::Failure(response),
23229 });
23230 }
23231 let response = {
23232 let bytes = common::to_bytes(body).await.unwrap_or_default();
23233 let encoded = common::to_string(&bytes);
23234 match serde_json::from_str(&encoded) {
23235 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23236 Err(error) => {
23237 dlg.response_json_decode_error(&encoded, &error);
23238 return Err(common::Error::JsonDecodeError(
23239 encoded.to_string(),
23240 error,
23241 ));
23242 }
23243 }
23244 };
23245
23246 dlg.finished(true);
23247 return Ok(response);
23248 }
23249 }
23250 }
23251 }
23252
23253 /// Name of a bucket.
23254 ///
23255 /// Sets the *bucket* path property to the given value.
23256 ///
23257 /// Even though the property as already been set when instantiating this call,
23258 /// we provide this method for API completeness.
23259 pub fn bucket(mut self, new_value: &str) -> ObjectAccessControlGetCall<'a, C> {
23260 self._bucket = new_value.to_string();
23261 self
23262 }
23263 /// 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).
23264 ///
23265 /// Sets the *object* path property to the given value.
23266 ///
23267 /// Even though the property as already been set when instantiating this call,
23268 /// we provide this method for API completeness.
23269 pub fn object(mut self, new_value: &str) -> ObjectAccessControlGetCall<'a, C> {
23270 self._object = new_value.to_string();
23271 self
23272 }
23273 /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
23274 ///
23275 /// Sets the *entity* path property to the given value.
23276 ///
23277 /// Even though the property as already been set when instantiating this call,
23278 /// we provide this method for API completeness.
23279 pub fn entity(mut self, new_value: &str) -> ObjectAccessControlGetCall<'a, C> {
23280 self._entity = new_value.to_string();
23281 self
23282 }
23283 /// The project to be billed for this request. Required for Requester Pays buckets.
23284 ///
23285 /// Sets the *user project* query property to the given value.
23286 pub fn user_project(mut self, new_value: &str) -> ObjectAccessControlGetCall<'a, C> {
23287 self._user_project = Some(new_value.to_string());
23288 self
23289 }
23290 /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
23291 ///
23292 /// Sets the *generation* query property to the given value.
23293 pub fn generation(mut self, new_value: i64) -> ObjectAccessControlGetCall<'a, C> {
23294 self._generation = Some(new_value);
23295 self
23296 }
23297 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23298 /// while executing the actual API request.
23299 ///
23300 /// ````text
23301 /// It should be used to handle progress information, and to implement a certain level of resilience.
23302 /// ````
23303 ///
23304 /// Sets the *delegate* property to the given value.
23305 pub fn delegate(
23306 mut self,
23307 new_value: &'a mut dyn common::Delegate,
23308 ) -> ObjectAccessControlGetCall<'a, C> {
23309 self._delegate = Some(new_value);
23310 self
23311 }
23312
23313 /// Set any additional parameter of the query string used in the request.
23314 /// It should be used to set parameters which are not yet available through their own
23315 /// setters.
23316 ///
23317 /// Please note that this method must not be used to set any of the known parameters
23318 /// which have their own setter method. If done anyway, the request will fail.
23319 ///
23320 /// # Additional Parameters
23321 ///
23322 /// * *alt* (query-string) - Data format for the response.
23323 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23324 /// * *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.
23325 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23326 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23327 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
23328 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
23329 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
23330 pub fn param<T>(mut self, name: T, value: T) -> ObjectAccessControlGetCall<'a, C>
23331 where
23332 T: AsRef<str>,
23333 {
23334 self._additional_params
23335 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23336 self
23337 }
23338
23339 /// Identifies the authorization scope for the method you are building.
23340 ///
23341 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23342 /// [`Scope::DevstorageFullControl`].
23343 ///
23344 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23345 /// tokens for more than one scope.
23346 ///
23347 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23348 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23349 /// sufficient, a read-write scope will do as well.
23350 pub fn add_scope<St>(mut self, scope: St) -> ObjectAccessControlGetCall<'a, C>
23351 where
23352 St: AsRef<str>,
23353 {
23354 self._scopes.insert(String::from(scope.as_ref()));
23355 self
23356 }
23357 /// Identifies the authorization scope(s) for the method you are building.
23358 ///
23359 /// See [`Self::add_scope()`] for details.
23360 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectAccessControlGetCall<'a, C>
23361 where
23362 I: IntoIterator<Item = St>,
23363 St: AsRef<str>,
23364 {
23365 self._scopes
23366 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23367 self
23368 }
23369
23370 /// Removes all scopes, and no default scope will be used either.
23371 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23372 /// for details).
23373 pub fn clear_scopes(mut self) -> ObjectAccessControlGetCall<'a, C> {
23374 self._scopes.clear();
23375 self
23376 }
23377}
23378
23379/// Creates a new ACL entry on the specified object.
23380///
23381/// A builder for the *insert* method supported by a *objectAccessControl* resource.
23382/// It is not used directly, but through a [`ObjectAccessControlMethods`] instance.
23383///
23384/// # Example
23385///
23386/// Instantiate a resource method builder
23387///
23388/// ```test_harness,no_run
23389/// # extern crate hyper;
23390/// # extern crate hyper_rustls;
23391/// # extern crate google_storage1 as storage1;
23392/// use storage1::api::ObjectAccessControl;
23393/// # async fn dox() {
23394/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23395///
23396/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23397/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23398/// # .with_native_roots()
23399/// # .unwrap()
23400/// # .https_only()
23401/// # .enable_http2()
23402/// # .build();
23403///
23404/// # let executor = hyper_util::rt::TokioExecutor::new();
23405/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23406/// # secret,
23407/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23408/// # yup_oauth2::client::CustomHyperClientBuilder::from(
23409/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
23410/// # ),
23411/// # ).build().await.unwrap();
23412///
23413/// # let client = hyper_util::client::legacy::Client::builder(
23414/// # hyper_util::rt::TokioExecutor::new()
23415/// # )
23416/// # .build(
23417/// # hyper_rustls::HttpsConnectorBuilder::new()
23418/// # .with_native_roots()
23419/// # .unwrap()
23420/// # .https_or_http()
23421/// # .enable_http2()
23422/// # .build()
23423/// # );
23424/// # let mut hub = Storage::new(client, auth);
23425/// // As the method needs a request, you would usually fill it with the desired information
23426/// // into the respective structure. Some of the parts shown here might not be applicable !
23427/// // Values shown here are possibly random and not representative !
23428/// let mut req = ObjectAccessControl::default();
23429///
23430/// // You can configure optional parameters by calling the respective setters at will, and
23431/// // execute the final call using `doit()`.
23432/// // Values shown here are possibly random and not representative !
23433/// let result = hub.object_access_controls().insert(req, "bucket", "object")
23434/// .user_project("tempor")
23435/// .generation(-34)
23436/// .doit().await;
23437/// # }
23438/// ```
23439pub struct ObjectAccessControlInsertCall<'a, C>
23440where
23441 C: 'a,
23442{
23443 hub: &'a Storage<C>,
23444 _request: ObjectAccessControl,
23445 _bucket: String,
23446 _object: String,
23447 _user_project: Option<String>,
23448 _generation: Option<i64>,
23449 _delegate: Option<&'a mut dyn common::Delegate>,
23450 _additional_params: HashMap<String, String>,
23451 _scopes: BTreeSet<String>,
23452}
23453
23454impl<'a, C> common::CallBuilder for ObjectAccessControlInsertCall<'a, C> {}
23455
23456impl<'a, C> ObjectAccessControlInsertCall<'a, C>
23457where
23458 C: common::Connector,
23459{
23460 /// Perform the operation you have build so far.
23461 pub async fn doit(mut self) -> common::Result<(common::Response, ObjectAccessControl)> {
23462 use std::borrow::Cow;
23463 use std::io::{Read, Seek};
23464
23465 use common::{url::Params, ToParts};
23466 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23467
23468 let mut dd = common::DefaultDelegate;
23469 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23470 dlg.begin(common::MethodInfo {
23471 id: "storage.objectAccessControls.insert",
23472 http_method: hyper::Method::POST,
23473 });
23474
23475 for &field in ["alt", "bucket", "object", "userProject", "generation"].iter() {
23476 if self._additional_params.contains_key(field) {
23477 dlg.finished(false);
23478 return Err(common::Error::FieldClash(field));
23479 }
23480 }
23481
23482 let mut params = Params::with_capacity(7 + self._additional_params.len());
23483 params.push("bucket", self._bucket);
23484 params.push("object", self._object);
23485 if let Some(value) = self._user_project.as_ref() {
23486 params.push("userProject", value);
23487 }
23488 if let Some(value) = self._generation.as_ref() {
23489 params.push("generation", value.to_string());
23490 }
23491
23492 params.extend(self._additional_params.iter());
23493
23494 params.push("alt", "json");
23495 let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}/acl";
23496 if self._scopes.is_empty() {
23497 self._scopes
23498 .insert(Scope::DevstorageFullControl.as_ref().to_string());
23499 }
23500
23501 #[allow(clippy::single_element_loop)]
23502 for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object")].iter() {
23503 url = params.uri_replacement(url, param_name, find_this, false);
23504 }
23505 {
23506 let to_remove = ["object", "bucket"];
23507 params.remove_params(&to_remove);
23508 }
23509
23510 let url = params.parse_with_url(&url);
23511
23512 let mut json_mime_type = mime::APPLICATION_JSON;
23513 let mut request_value_reader = {
23514 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23515 common::remove_json_null_values(&mut value);
23516 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23517 serde_json::to_writer(&mut dst, &value).unwrap();
23518 dst
23519 };
23520 let request_size = request_value_reader
23521 .seek(std::io::SeekFrom::End(0))
23522 .unwrap();
23523 request_value_reader
23524 .seek(std::io::SeekFrom::Start(0))
23525 .unwrap();
23526
23527 loop {
23528 let token = match self
23529 .hub
23530 .auth
23531 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23532 .await
23533 {
23534 Ok(token) => token,
23535 Err(e) => match dlg.token(e) {
23536 Ok(token) => token,
23537 Err(e) => {
23538 dlg.finished(false);
23539 return Err(common::Error::MissingToken(e));
23540 }
23541 },
23542 };
23543 request_value_reader
23544 .seek(std::io::SeekFrom::Start(0))
23545 .unwrap();
23546 let mut req_result = {
23547 let client = &self.hub.client;
23548 dlg.pre_request();
23549 let mut req_builder = hyper::Request::builder()
23550 .method(hyper::Method::POST)
23551 .uri(url.as_str())
23552 .header(USER_AGENT, self.hub._user_agent.clone());
23553
23554 if let Some(token) = token.as_ref() {
23555 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23556 }
23557
23558 let request = req_builder
23559 .header(CONTENT_TYPE, json_mime_type.to_string())
23560 .header(CONTENT_LENGTH, request_size as u64)
23561 .body(common::to_body(
23562 request_value_reader.get_ref().clone().into(),
23563 ));
23564
23565 client.request(request.unwrap()).await
23566 };
23567
23568 match req_result {
23569 Err(err) => {
23570 if let common::Retry::After(d) = dlg.http_error(&err) {
23571 sleep(d).await;
23572 continue;
23573 }
23574 dlg.finished(false);
23575 return Err(common::Error::HttpError(err));
23576 }
23577 Ok(res) => {
23578 let (mut parts, body) = res.into_parts();
23579 let mut body = common::Body::new(body);
23580 if !parts.status.is_success() {
23581 let bytes = common::to_bytes(body).await.unwrap_or_default();
23582 let error = serde_json::from_str(&common::to_string(&bytes));
23583 let response = common::to_response(parts, bytes.into());
23584
23585 if let common::Retry::After(d) =
23586 dlg.http_failure(&response, error.as_ref().ok())
23587 {
23588 sleep(d).await;
23589 continue;
23590 }
23591
23592 dlg.finished(false);
23593
23594 return Err(match error {
23595 Ok(value) => common::Error::BadRequest(value),
23596 _ => common::Error::Failure(response),
23597 });
23598 }
23599 let response = {
23600 let bytes = common::to_bytes(body).await.unwrap_or_default();
23601 let encoded = common::to_string(&bytes);
23602 match serde_json::from_str(&encoded) {
23603 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23604 Err(error) => {
23605 dlg.response_json_decode_error(&encoded, &error);
23606 return Err(common::Error::JsonDecodeError(
23607 encoded.to_string(),
23608 error,
23609 ));
23610 }
23611 }
23612 };
23613
23614 dlg.finished(true);
23615 return Ok(response);
23616 }
23617 }
23618 }
23619 }
23620
23621 ///
23622 /// Sets the *request* property to the given value.
23623 ///
23624 /// Even though the property as already been set when instantiating this call,
23625 /// we provide this method for API completeness.
23626 pub fn request(
23627 mut self,
23628 new_value: ObjectAccessControl,
23629 ) -> ObjectAccessControlInsertCall<'a, C> {
23630 self._request = new_value;
23631 self
23632 }
23633 /// Name of a bucket.
23634 ///
23635 /// Sets the *bucket* path property to the given value.
23636 ///
23637 /// Even though the property as already been set when instantiating this call,
23638 /// we provide this method for API completeness.
23639 pub fn bucket(mut self, new_value: &str) -> ObjectAccessControlInsertCall<'a, C> {
23640 self._bucket = new_value.to_string();
23641 self
23642 }
23643 /// 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).
23644 ///
23645 /// Sets the *object* path property to the given value.
23646 ///
23647 /// Even though the property as already been set when instantiating this call,
23648 /// we provide this method for API completeness.
23649 pub fn object(mut self, new_value: &str) -> ObjectAccessControlInsertCall<'a, C> {
23650 self._object = new_value.to_string();
23651 self
23652 }
23653 /// The project to be billed for this request. Required for Requester Pays buckets.
23654 ///
23655 /// Sets the *user project* query property to the given value.
23656 pub fn user_project(mut self, new_value: &str) -> ObjectAccessControlInsertCall<'a, C> {
23657 self._user_project = Some(new_value.to_string());
23658 self
23659 }
23660 /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
23661 ///
23662 /// Sets the *generation* query property to the given value.
23663 pub fn generation(mut self, new_value: i64) -> ObjectAccessControlInsertCall<'a, C> {
23664 self._generation = Some(new_value);
23665 self
23666 }
23667 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23668 /// while executing the actual API request.
23669 ///
23670 /// ````text
23671 /// It should be used to handle progress information, and to implement a certain level of resilience.
23672 /// ````
23673 ///
23674 /// Sets the *delegate* property to the given value.
23675 pub fn delegate(
23676 mut self,
23677 new_value: &'a mut dyn common::Delegate,
23678 ) -> ObjectAccessControlInsertCall<'a, C> {
23679 self._delegate = Some(new_value);
23680 self
23681 }
23682
23683 /// Set any additional parameter of the query string used in the request.
23684 /// It should be used to set parameters which are not yet available through their own
23685 /// setters.
23686 ///
23687 /// Please note that this method must not be used to set any of the known parameters
23688 /// which have their own setter method. If done anyway, the request will fail.
23689 ///
23690 /// # Additional Parameters
23691 ///
23692 /// * *alt* (query-string) - Data format for the response.
23693 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23694 /// * *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.
23695 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23696 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23697 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
23698 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
23699 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
23700 pub fn param<T>(mut self, name: T, value: T) -> ObjectAccessControlInsertCall<'a, C>
23701 where
23702 T: AsRef<str>,
23703 {
23704 self._additional_params
23705 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23706 self
23707 }
23708
23709 /// Identifies the authorization scope for the method you are building.
23710 ///
23711 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23712 /// [`Scope::DevstorageFullControl`].
23713 ///
23714 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23715 /// tokens for more than one scope.
23716 ///
23717 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23718 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23719 /// sufficient, a read-write scope will do as well.
23720 pub fn add_scope<St>(mut self, scope: St) -> ObjectAccessControlInsertCall<'a, C>
23721 where
23722 St: AsRef<str>,
23723 {
23724 self._scopes.insert(String::from(scope.as_ref()));
23725 self
23726 }
23727 /// Identifies the authorization scope(s) for the method you are building.
23728 ///
23729 /// See [`Self::add_scope()`] for details.
23730 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectAccessControlInsertCall<'a, C>
23731 where
23732 I: IntoIterator<Item = St>,
23733 St: AsRef<str>,
23734 {
23735 self._scopes
23736 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23737 self
23738 }
23739
23740 /// Removes all scopes, and no default scope will be used either.
23741 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23742 /// for details).
23743 pub fn clear_scopes(mut self) -> ObjectAccessControlInsertCall<'a, C> {
23744 self._scopes.clear();
23745 self
23746 }
23747}
23748
23749/// Retrieves ACL entries on the specified object.
23750///
23751/// A builder for the *list* method supported by a *objectAccessControl* resource.
23752/// It is not used directly, but through a [`ObjectAccessControlMethods`] instance.
23753///
23754/// # Example
23755///
23756/// Instantiate a resource method builder
23757///
23758/// ```test_harness,no_run
23759/// # extern crate hyper;
23760/// # extern crate hyper_rustls;
23761/// # extern crate google_storage1 as storage1;
23762/// # async fn dox() {
23763/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23764///
23765/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23766/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23767/// # .with_native_roots()
23768/// # .unwrap()
23769/// # .https_only()
23770/// # .enable_http2()
23771/// # .build();
23772///
23773/// # let executor = hyper_util::rt::TokioExecutor::new();
23774/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23775/// # secret,
23776/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23777/// # yup_oauth2::client::CustomHyperClientBuilder::from(
23778/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
23779/// # ),
23780/// # ).build().await.unwrap();
23781///
23782/// # let client = hyper_util::client::legacy::Client::builder(
23783/// # hyper_util::rt::TokioExecutor::new()
23784/// # )
23785/// # .build(
23786/// # hyper_rustls::HttpsConnectorBuilder::new()
23787/// # .with_native_roots()
23788/// # .unwrap()
23789/// # .https_or_http()
23790/// # .enable_http2()
23791/// # .build()
23792/// # );
23793/// # let mut hub = Storage::new(client, auth);
23794/// // You can configure optional parameters by calling the respective setters at will, and
23795/// // execute the final call using `doit()`.
23796/// // Values shown here are possibly random and not representative !
23797/// let result = hub.object_access_controls().list("bucket", "object")
23798/// .user_project("dolore")
23799/// .generation(-97)
23800/// .doit().await;
23801/// # }
23802/// ```
23803pub struct ObjectAccessControlListCall<'a, C>
23804where
23805 C: 'a,
23806{
23807 hub: &'a Storage<C>,
23808 _bucket: String,
23809 _object: String,
23810 _user_project: Option<String>,
23811 _generation: Option<i64>,
23812 _delegate: Option<&'a mut dyn common::Delegate>,
23813 _additional_params: HashMap<String, String>,
23814 _scopes: BTreeSet<String>,
23815}
23816
23817impl<'a, C> common::CallBuilder for ObjectAccessControlListCall<'a, C> {}
23818
23819impl<'a, C> ObjectAccessControlListCall<'a, C>
23820where
23821 C: common::Connector,
23822{
23823 /// Perform the operation you have build so far.
23824 pub async fn doit(mut self) -> common::Result<(common::Response, ObjectAccessControls)> {
23825 use std::borrow::Cow;
23826 use std::io::{Read, Seek};
23827
23828 use common::{url::Params, ToParts};
23829 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23830
23831 let mut dd = common::DefaultDelegate;
23832 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23833 dlg.begin(common::MethodInfo {
23834 id: "storage.objectAccessControls.list",
23835 http_method: hyper::Method::GET,
23836 });
23837
23838 for &field in ["alt", "bucket", "object", "userProject", "generation"].iter() {
23839 if self._additional_params.contains_key(field) {
23840 dlg.finished(false);
23841 return Err(common::Error::FieldClash(field));
23842 }
23843 }
23844
23845 let mut params = Params::with_capacity(6 + self._additional_params.len());
23846 params.push("bucket", self._bucket);
23847 params.push("object", self._object);
23848 if let Some(value) = self._user_project.as_ref() {
23849 params.push("userProject", value);
23850 }
23851 if let Some(value) = self._generation.as_ref() {
23852 params.push("generation", value.to_string());
23853 }
23854
23855 params.extend(self._additional_params.iter());
23856
23857 params.push("alt", "json");
23858 let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}/acl";
23859 if self._scopes.is_empty() {
23860 self._scopes
23861 .insert(Scope::DevstorageFullControl.as_ref().to_string());
23862 }
23863
23864 #[allow(clippy::single_element_loop)]
23865 for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object")].iter() {
23866 url = params.uri_replacement(url, param_name, find_this, false);
23867 }
23868 {
23869 let to_remove = ["object", "bucket"];
23870 params.remove_params(&to_remove);
23871 }
23872
23873 let url = params.parse_with_url(&url);
23874
23875 loop {
23876 let token = match self
23877 .hub
23878 .auth
23879 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23880 .await
23881 {
23882 Ok(token) => token,
23883 Err(e) => match dlg.token(e) {
23884 Ok(token) => token,
23885 Err(e) => {
23886 dlg.finished(false);
23887 return Err(common::Error::MissingToken(e));
23888 }
23889 },
23890 };
23891 let mut req_result = {
23892 let client = &self.hub.client;
23893 dlg.pre_request();
23894 let mut req_builder = hyper::Request::builder()
23895 .method(hyper::Method::GET)
23896 .uri(url.as_str())
23897 .header(USER_AGENT, self.hub._user_agent.clone());
23898
23899 if let Some(token) = token.as_ref() {
23900 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23901 }
23902
23903 let request = req_builder
23904 .header(CONTENT_LENGTH, 0_u64)
23905 .body(common::to_body::<String>(None));
23906
23907 client.request(request.unwrap()).await
23908 };
23909
23910 match req_result {
23911 Err(err) => {
23912 if let common::Retry::After(d) = dlg.http_error(&err) {
23913 sleep(d).await;
23914 continue;
23915 }
23916 dlg.finished(false);
23917 return Err(common::Error::HttpError(err));
23918 }
23919 Ok(res) => {
23920 let (mut parts, body) = res.into_parts();
23921 let mut body = common::Body::new(body);
23922 if !parts.status.is_success() {
23923 let bytes = common::to_bytes(body).await.unwrap_or_default();
23924 let error = serde_json::from_str(&common::to_string(&bytes));
23925 let response = common::to_response(parts, bytes.into());
23926
23927 if let common::Retry::After(d) =
23928 dlg.http_failure(&response, error.as_ref().ok())
23929 {
23930 sleep(d).await;
23931 continue;
23932 }
23933
23934 dlg.finished(false);
23935
23936 return Err(match error {
23937 Ok(value) => common::Error::BadRequest(value),
23938 _ => common::Error::Failure(response),
23939 });
23940 }
23941 let response = {
23942 let bytes = common::to_bytes(body).await.unwrap_or_default();
23943 let encoded = common::to_string(&bytes);
23944 match serde_json::from_str(&encoded) {
23945 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23946 Err(error) => {
23947 dlg.response_json_decode_error(&encoded, &error);
23948 return Err(common::Error::JsonDecodeError(
23949 encoded.to_string(),
23950 error,
23951 ));
23952 }
23953 }
23954 };
23955
23956 dlg.finished(true);
23957 return Ok(response);
23958 }
23959 }
23960 }
23961 }
23962
23963 /// Name of a bucket.
23964 ///
23965 /// Sets the *bucket* path property to the given value.
23966 ///
23967 /// Even though the property as already been set when instantiating this call,
23968 /// we provide this method for API completeness.
23969 pub fn bucket(mut self, new_value: &str) -> ObjectAccessControlListCall<'a, C> {
23970 self._bucket = new_value.to_string();
23971 self
23972 }
23973 /// 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).
23974 ///
23975 /// Sets the *object* path property to the given value.
23976 ///
23977 /// Even though the property as already been set when instantiating this call,
23978 /// we provide this method for API completeness.
23979 pub fn object(mut self, new_value: &str) -> ObjectAccessControlListCall<'a, C> {
23980 self._object = new_value.to_string();
23981 self
23982 }
23983 /// The project to be billed for this request. Required for Requester Pays buckets.
23984 ///
23985 /// Sets the *user project* query property to the given value.
23986 pub fn user_project(mut self, new_value: &str) -> ObjectAccessControlListCall<'a, C> {
23987 self._user_project = Some(new_value.to_string());
23988 self
23989 }
23990 /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
23991 ///
23992 /// Sets the *generation* query property to the given value.
23993 pub fn generation(mut self, new_value: i64) -> ObjectAccessControlListCall<'a, C> {
23994 self._generation = Some(new_value);
23995 self
23996 }
23997 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23998 /// while executing the actual API request.
23999 ///
24000 /// ````text
24001 /// It should be used to handle progress information, and to implement a certain level of resilience.
24002 /// ````
24003 ///
24004 /// Sets the *delegate* property to the given value.
24005 pub fn delegate(
24006 mut self,
24007 new_value: &'a mut dyn common::Delegate,
24008 ) -> ObjectAccessControlListCall<'a, C> {
24009 self._delegate = Some(new_value);
24010 self
24011 }
24012
24013 /// Set any additional parameter of the query string used in the request.
24014 /// It should be used to set parameters which are not yet available through their own
24015 /// setters.
24016 ///
24017 /// Please note that this method must not be used to set any of the known parameters
24018 /// which have their own setter method. If done anyway, the request will fail.
24019 ///
24020 /// # Additional Parameters
24021 ///
24022 /// * *alt* (query-string) - Data format for the response.
24023 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24024 /// * *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.
24025 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24026 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24027 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
24028 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
24029 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
24030 pub fn param<T>(mut self, name: T, value: T) -> ObjectAccessControlListCall<'a, C>
24031 where
24032 T: AsRef<str>,
24033 {
24034 self._additional_params
24035 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24036 self
24037 }
24038
24039 /// Identifies the authorization scope for the method you are building.
24040 ///
24041 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24042 /// [`Scope::DevstorageFullControl`].
24043 ///
24044 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24045 /// tokens for more than one scope.
24046 ///
24047 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24048 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24049 /// sufficient, a read-write scope will do as well.
24050 pub fn add_scope<St>(mut self, scope: St) -> ObjectAccessControlListCall<'a, C>
24051 where
24052 St: AsRef<str>,
24053 {
24054 self._scopes.insert(String::from(scope.as_ref()));
24055 self
24056 }
24057 /// Identifies the authorization scope(s) for the method you are building.
24058 ///
24059 /// See [`Self::add_scope()`] for details.
24060 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectAccessControlListCall<'a, C>
24061 where
24062 I: IntoIterator<Item = St>,
24063 St: AsRef<str>,
24064 {
24065 self._scopes
24066 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24067 self
24068 }
24069
24070 /// Removes all scopes, and no default scope will be used either.
24071 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24072 /// for details).
24073 pub fn clear_scopes(mut self) -> ObjectAccessControlListCall<'a, C> {
24074 self._scopes.clear();
24075 self
24076 }
24077}
24078
24079/// Patches an ACL entry on the specified object.
24080///
24081/// A builder for the *patch* method supported by a *objectAccessControl* resource.
24082/// It is not used directly, but through a [`ObjectAccessControlMethods`] instance.
24083///
24084/// # Example
24085///
24086/// Instantiate a resource method builder
24087///
24088/// ```test_harness,no_run
24089/// # extern crate hyper;
24090/// # extern crate hyper_rustls;
24091/// # extern crate google_storage1 as storage1;
24092/// use storage1::api::ObjectAccessControl;
24093/// # async fn dox() {
24094/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24095///
24096/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24097/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24098/// # .with_native_roots()
24099/// # .unwrap()
24100/// # .https_only()
24101/// # .enable_http2()
24102/// # .build();
24103///
24104/// # let executor = hyper_util::rt::TokioExecutor::new();
24105/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24106/// # secret,
24107/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24108/// # yup_oauth2::client::CustomHyperClientBuilder::from(
24109/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
24110/// # ),
24111/// # ).build().await.unwrap();
24112///
24113/// # let client = hyper_util::client::legacy::Client::builder(
24114/// # hyper_util::rt::TokioExecutor::new()
24115/// # )
24116/// # .build(
24117/// # hyper_rustls::HttpsConnectorBuilder::new()
24118/// # .with_native_roots()
24119/// # .unwrap()
24120/// # .https_or_http()
24121/// # .enable_http2()
24122/// # .build()
24123/// # );
24124/// # let mut hub = Storage::new(client, auth);
24125/// // As the method needs a request, you would usually fill it with the desired information
24126/// // into the respective structure. Some of the parts shown here might not be applicable !
24127/// // Values shown here are possibly random and not representative !
24128/// let mut req = ObjectAccessControl::default();
24129///
24130/// // You can configure optional parameters by calling the respective setters at will, and
24131/// // execute the final call using `doit()`.
24132/// // Values shown here are possibly random and not representative !
24133/// let result = hub.object_access_controls().patch(req, "bucket", "object", "entity")
24134/// .user_project("vero")
24135/// .generation(-20)
24136/// .doit().await;
24137/// # }
24138/// ```
24139pub struct ObjectAccessControlPatchCall<'a, C>
24140where
24141 C: 'a,
24142{
24143 hub: &'a Storage<C>,
24144 _request: ObjectAccessControl,
24145 _bucket: String,
24146 _object: String,
24147 _entity: String,
24148 _user_project: Option<String>,
24149 _generation: Option<i64>,
24150 _delegate: Option<&'a mut dyn common::Delegate>,
24151 _additional_params: HashMap<String, String>,
24152 _scopes: BTreeSet<String>,
24153}
24154
24155impl<'a, C> common::CallBuilder for ObjectAccessControlPatchCall<'a, C> {}
24156
24157impl<'a, C> ObjectAccessControlPatchCall<'a, C>
24158where
24159 C: common::Connector,
24160{
24161 /// Perform the operation you have build so far.
24162 pub async fn doit(mut self) -> common::Result<(common::Response, ObjectAccessControl)> {
24163 use std::borrow::Cow;
24164 use std::io::{Read, Seek};
24165
24166 use common::{url::Params, ToParts};
24167 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24168
24169 let mut dd = common::DefaultDelegate;
24170 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24171 dlg.begin(common::MethodInfo {
24172 id: "storage.objectAccessControls.patch",
24173 http_method: hyper::Method::PATCH,
24174 });
24175
24176 for &field in [
24177 "alt",
24178 "bucket",
24179 "object",
24180 "entity",
24181 "userProject",
24182 "generation",
24183 ]
24184 .iter()
24185 {
24186 if self._additional_params.contains_key(field) {
24187 dlg.finished(false);
24188 return Err(common::Error::FieldClash(field));
24189 }
24190 }
24191
24192 let mut params = Params::with_capacity(8 + self._additional_params.len());
24193 params.push("bucket", self._bucket);
24194 params.push("object", self._object);
24195 params.push("entity", self._entity);
24196 if let Some(value) = self._user_project.as_ref() {
24197 params.push("userProject", value);
24198 }
24199 if let Some(value) = self._generation.as_ref() {
24200 params.push("generation", value.to_string());
24201 }
24202
24203 params.extend(self._additional_params.iter());
24204
24205 params.push("alt", "json");
24206 let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}/acl/{entity}";
24207 if self._scopes.is_empty() {
24208 self._scopes
24209 .insert(Scope::DevstorageFullControl.as_ref().to_string());
24210 }
24211
24212 #[allow(clippy::single_element_loop)]
24213 for &(find_this, param_name) in [
24214 ("{bucket}", "bucket"),
24215 ("{object}", "object"),
24216 ("{entity}", "entity"),
24217 ]
24218 .iter()
24219 {
24220 url = params.uri_replacement(url, param_name, find_this, false);
24221 }
24222 {
24223 let to_remove = ["entity", "object", "bucket"];
24224 params.remove_params(&to_remove);
24225 }
24226
24227 let url = params.parse_with_url(&url);
24228
24229 let mut json_mime_type = mime::APPLICATION_JSON;
24230 let mut request_value_reader = {
24231 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24232 common::remove_json_null_values(&mut value);
24233 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24234 serde_json::to_writer(&mut dst, &value).unwrap();
24235 dst
24236 };
24237 let request_size = request_value_reader
24238 .seek(std::io::SeekFrom::End(0))
24239 .unwrap();
24240 request_value_reader
24241 .seek(std::io::SeekFrom::Start(0))
24242 .unwrap();
24243
24244 loop {
24245 let token = match self
24246 .hub
24247 .auth
24248 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24249 .await
24250 {
24251 Ok(token) => token,
24252 Err(e) => match dlg.token(e) {
24253 Ok(token) => token,
24254 Err(e) => {
24255 dlg.finished(false);
24256 return Err(common::Error::MissingToken(e));
24257 }
24258 },
24259 };
24260 request_value_reader
24261 .seek(std::io::SeekFrom::Start(0))
24262 .unwrap();
24263 let mut req_result = {
24264 let client = &self.hub.client;
24265 dlg.pre_request();
24266 let mut req_builder = hyper::Request::builder()
24267 .method(hyper::Method::PATCH)
24268 .uri(url.as_str())
24269 .header(USER_AGENT, self.hub._user_agent.clone());
24270
24271 if let Some(token) = token.as_ref() {
24272 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24273 }
24274
24275 let request = req_builder
24276 .header(CONTENT_TYPE, json_mime_type.to_string())
24277 .header(CONTENT_LENGTH, request_size as u64)
24278 .body(common::to_body(
24279 request_value_reader.get_ref().clone().into(),
24280 ));
24281
24282 client.request(request.unwrap()).await
24283 };
24284
24285 match req_result {
24286 Err(err) => {
24287 if let common::Retry::After(d) = dlg.http_error(&err) {
24288 sleep(d).await;
24289 continue;
24290 }
24291 dlg.finished(false);
24292 return Err(common::Error::HttpError(err));
24293 }
24294 Ok(res) => {
24295 let (mut parts, body) = res.into_parts();
24296 let mut body = common::Body::new(body);
24297 if !parts.status.is_success() {
24298 let bytes = common::to_bytes(body).await.unwrap_or_default();
24299 let error = serde_json::from_str(&common::to_string(&bytes));
24300 let response = common::to_response(parts, bytes.into());
24301
24302 if let common::Retry::After(d) =
24303 dlg.http_failure(&response, error.as_ref().ok())
24304 {
24305 sleep(d).await;
24306 continue;
24307 }
24308
24309 dlg.finished(false);
24310
24311 return Err(match error {
24312 Ok(value) => common::Error::BadRequest(value),
24313 _ => common::Error::Failure(response),
24314 });
24315 }
24316 let response = {
24317 let bytes = common::to_bytes(body).await.unwrap_or_default();
24318 let encoded = common::to_string(&bytes);
24319 match serde_json::from_str(&encoded) {
24320 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24321 Err(error) => {
24322 dlg.response_json_decode_error(&encoded, &error);
24323 return Err(common::Error::JsonDecodeError(
24324 encoded.to_string(),
24325 error,
24326 ));
24327 }
24328 }
24329 };
24330
24331 dlg.finished(true);
24332 return Ok(response);
24333 }
24334 }
24335 }
24336 }
24337
24338 ///
24339 /// Sets the *request* property to the given value.
24340 ///
24341 /// Even though the property as already been set when instantiating this call,
24342 /// we provide this method for API completeness.
24343 pub fn request(
24344 mut self,
24345 new_value: ObjectAccessControl,
24346 ) -> ObjectAccessControlPatchCall<'a, C> {
24347 self._request = new_value;
24348 self
24349 }
24350 /// Name of a bucket.
24351 ///
24352 /// Sets the *bucket* path property to the given value.
24353 ///
24354 /// Even though the property as already been set when instantiating this call,
24355 /// we provide this method for API completeness.
24356 pub fn bucket(mut self, new_value: &str) -> ObjectAccessControlPatchCall<'a, C> {
24357 self._bucket = new_value.to_string();
24358 self
24359 }
24360 /// 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).
24361 ///
24362 /// Sets the *object* path property to the given value.
24363 ///
24364 /// Even though the property as already been set when instantiating this call,
24365 /// we provide this method for API completeness.
24366 pub fn object(mut self, new_value: &str) -> ObjectAccessControlPatchCall<'a, C> {
24367 self._object = new_value.to_string();
24368 self
24369 }
24370 /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
24371 ///
24372 /// Sets the *entity* path property to the given value.
24373 ///
24374 /// Even though the property as already been set when instantiating this call,
24375 /// we provide this method for API completeness.
24376 pub fn entity(mut self, new_value: &str) -> ObjectAccessControlPatchCall<'a, C> {
24377 self._entity = new_value.to_string();
24378 self
24379 }
24380 /// The project to be billed for this request. Required for Requester Pays buckets.
24381 ///
24382 /// Sets the *user project* query property to the given value.
24383 pub fn user_project(mut self, new_value: &str) -> ObjectAccessControlPatchCall<'a, C> {
24384 self._user_project = Some(new_value.to_string());
24385 self
24386 }
24387 /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
24388 ///
24389 /// Sets the *generation* query property to the given value.
24390 pub fn generation(mut self, new_value: i64) -> ObjectAccessControlPatchCall<'a, C> {
24391 self._generation = Some(new_value);
24392 self
24393 }
24394 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24395 /// while executing the actual API request.
24396 ///
24397 /// ````text
24398 /// It should be used to handle progress information, and to implement a certain level of resilience.
24399 /// ````
24400 ///
24401 /// Sets the *delegate* property to the given value.
24402 pub fn delegate(
24403 mut self,
24404 new_value: &'a mut dyn common::Delegate,
24405 ) -> ObjectAccessControlPatchCall<'a, C> {
24406 self._delegate = Some(new_value);
24407 self
24408 }
24409
24410 /// Set any additional parameter of the query string used in the request.
24411 /// It should be used to set parameters which are not yet available through their own
24412 /// setters.
24413 ///
24414 /// Please note that this method must not be used to set any of the known parameters
24415 /// which have their own setter method. If done anyway, the request will fail.
24416 ///
24417 /// # Additional Parameters
24418 ///
24419 /// * *alt* (query-string) - Data format for the response.
24420 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24421 /// * *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.
24422 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24423 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24424 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
24425 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
24426 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
24427 pub fn param<T>(mut self, name: T, value: T) -> ObjectAccessControlPatchCall<'a, C>
24428 where
24429 T: AsRef<str>,
24430 {
24431 self._additional_params
24432 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24433 self
24434 }
24435
24436 /// Identifies the authorization scope for the method you are building.
24437 ///
24438 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24439 /// [`Scope::DevstorageFullControl`].
24440 ///
24441 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24442 /// tokens for more than one scope.
24443 ///
24444 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24445 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24446 /// sufficient, a read-write scope will do as well.
24447 pub fn add_scope<St>(mut self, scope: St) -> ObjectAccessControlPatchCall<'a, C>
24448 where
24449 St: AsRef<str>,
24450 {
24451 self._scopes.insert(String::from(scope.as_ref()));
24452 self
24453 }
24454 /// Identifies the authorization scope(s) for the method you are building.
24455 ///
24456 /// See [`Self::add_scope()`] for details.
24457 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectAccessControlPatchCall<'a, C>
24458 where
24459 I: IntoIterator<Item = St>,
24460 St: AsRef<str>,
24461 {
24462 self._scopes
24463 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24464 self
24465 }
24466
24467 /// Removes all scopes, and no default scope will be used either.
24468 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24469 /// for details).
24470 pub fn clear_scopes(mut self) -> ObjectAccessControlPatchCall<'a, C> {
24471 self._scopes.clear();
24472 self
24473 }
24474}
24475
24476/// Updates an ACL entry on the specified object.
24477///
24478/// A builder for the *update* method supported by a *objectAccessControl* resource.
24479/// It is not used directly, but through a [`ObjectAccessControlMethods`] instance.
24480///
24481/// # Example
24482///
24483/// Instantiate a resource method builder
24484///
24485/// ```test_harness,no_run
24486/// # extern crate hyper;
24487/// # extern crate hyper_rustls;
24488/// # extern crate google_storage1 as storage1;
24489/// use storage1::api::ObjectAccessControl;
24490/// # async fn dox() {
24491/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24492///
24493/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24494/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24495/// # .with_native_roots()
24496/// # .unwrap()
24497/// # .https_only()
24498/// # .enable_http2()
24499/// # .build();
24500///
24501/// # let executor = hyper_util::rt::TokioExecutor::new();
24502/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24503/// # secret,
24504/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24505/// # yup_oauth2::client::CustomHyperClientBuilder::from(
24506/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
24507/// # ),
24508/// # ).build().await.unwrap();
24509///
24510/// # let client = hyper_util::client::legacy::Client::builder(
24511/// # hyper_util::rt::TokioExecutor::new()
24512/// # )
24513/// # .build(
24514/// # hyper_rustls::HttpsConnectorBuilder::new()
24515/// # .with_native_roots()
24516/// # .unwrap()
24517/// # .https_or_http()
24518/// # .enable_http2()
24519/// # .build()
24520/// # );
24521/// # let mut hub = Storage::new(client, auth);
24522/// // As the method needs a request, you would usually fill it with the desired information
24523/// // into the respective structure. Some of the parts shown here might not be applicable !
24524/// // Values shown here are possibly random and not representative !
24525/// let mut req = ObjectAccessControl::default();
24526///
24527/// // You can configure optional parameters by calling the respective setters at will, and
24528/// // execute the final call using `doit()`.
24529/// // Values shown here are possibly random and not representative !
24530/// let result = hub.object_access_controls().update(req, "bucket", "object", "entity")
24531/// .user_project("duo")
24532/// .generation(-63)
24533/// .doit().await;
24534/// # }
24535/// ```
24536pub struct ObjectAccessControlUpdateCall<'a, C>
24537where
24538 C: 'a,
24539{
24540 hub: &'a Storage<C>,
24541 _request: ObjectAccessControl,
24542 _bucket: String,
24543 _object: String,
24544 _entity: String,
24545 _user_project: Option<String>,
24546 _generation: Option<i64>,
24547 _delegate: Option<&'a mut dyn common::Delegate>,
24548 _additional_params: HashMap<String, String>,
24549 _scopes: BTreeSet<String>,
24550}
24551
24552impl<'a, C> common::CallBuilder for ObjectAccessControlUpdateCall<'a, C> {}
24553
24554impl<'a, C> ObjectAccessControlUpdateCall<'a, C>
24555where
24556 C: common::Connector,
24557{
24558 /// Perform the operation you have build so far.
24559 pub async fn doit(mut self) -> common::Result<(common::Response, ObjectAccessControl)> {
24560 use std::borrow::Cow;
24561 use std::io::{Read, Seek};
24562
24563 use common::{url::Params, ToParts};
24564 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24565
24566 let mut dd = common::DefaultDelegate;
24567 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24568 dlg.begin(common::MethodInfo {
24569 id: "storage.objectAccessControls.update",
24570 http_method: hyper::Method::PUT,
24571 });
24572
24573 for &field in [
24574 "alt",
24575 "bucket",
24576 "object",
24577 "entity",
24578 "userProject",
24579 "generation",
24580 ]
24581 .iter()
24582 {
24583 if self._additional_params.contains_key(field) {
24584 dlg.finished(false);
24585 return Err(common::Error::FieldClash(field));
24586 }
24587 }
24588
24589 let mut params = Params::with_capacity(8 + self._additional_params.len());
24590 params.push("bucket", self._bucket);
24591 params.push("object", self._object);
24592 params.push("entity", self._entity);
24593 if let Some(value) = self._user_project.as_ref() {
24594 params.push("userProject", value);
24595 }
24596 if let Some(value) = self._generation.as_ref() {
24597 params.push("generation", value.to_string());
24598 }
24599
24600 params.extend(self._additional_params.iter());
24601
24602 params.push("alt", "json");
24603 let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}/acl/{entity}";
24604 if self._scopes.is_empty() {
24605 self._scopes
24606 .insert(Scope::DevstorageFullControl.as_ref().to_string());
24607 }
24608
24609 #[allow(clippy::single_element_loop)]
24610 for &(find_this, param_name) in [
24611 ("{bucket}", "bucket"),
24612 ("{object}", "object"),
24613 ("{entity}", "entity"),
24614 ]
24615 .iter()
24616 {
24617 url = params.uri_replacement(url, param_name, find_this, false);
24618 }
24619 {
24620 let to_remove = ["entity", "object", "bucket"];
24621 params.remove_params(&to_remove);
24622 }
24623
24624 let url = params.parse_with_url(&url);
24625
24626 let mut json_mime_type = mime::APPLICATION_JSON;
24627 let mut request_value_reader = {
24628 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24629 common::remove_json_null_values(&mut value);
24630 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24631 serde_json::to_writer(&mut dst, &value).unwrap();
24632 dst
24633 };
24634 let request_size = request_value_reader
24635 .seek(std::io::SeekFrom::End(0))
24636 .unwrap();
24637 request_value_reader
24638 .seek(std::io::SeekFrom::Start(0))
24639 .unwrap();
24640
24641 loop {
24642 let token = match self
24643 .hub
24644 .auth
24645 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24646 .await
24647 {
24648 Ok(token) => token,
24649 Err(e) => match dlg.token(e) {
24650 Ok(token) => token,
24651 Err(e) => {
24652 dlg.finished(false);
24653 return Err(common::Error::MissingToken(e));
24654 }
24655 },
24656 };
24657 request_value_reader
24658 .seek(std::io::SeekFrom::Start(0))
24659 .unwrap();
24660 let mut req_result = {
24661 let client = &self.hub.client;
24662 dlg.pre_request();
24663 let mut req_builder = hyper::Request::builder()
24664 .method(hyper::Method::PUT)
24665 .uri(url.as_str())
24666 .header(USER_AGENT, self.hub._user_agent.clone());
24667
24668 if let Some(token) = token.as_ref() {
24669 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24670 }
24671
24672 let request = req_builder
24673 .header(CONTENT_TYPE, json_mime_type.to_string())
24674 .header(CONTENT_LENGTH, request_size as u64)
24675 .body(common::to_body(
24676 request_value_reader.get_ref().clone().into(),
24677 ));
24678
24679 client.request(request.unwrap()).await
24680 };
24681
24682 match req_result {
24683 Err(err) => {
24684 if let common::Retry::After(d) = dlg.http_error(&err) {
24685 sleep(d).await;
24686 continue;
24687 }
24688 dlg.finished(false);
24689 return Err(common::Error::HttpError(err));
24690 }
24691 Ok(res) => {
24692 let (mut parts, body) = res.into_parts();
24693 let mut body = common::Body::new(body);
24694 if !parts.status.is_success() {
24695 let bytes = common::to_bytes(body).await.unwrap_or_default();
24696 let error = serde_json::from_str(&common::to_string(&bytes));
24697 let response = common::to_response(parts, bytes.into());
24698
24699 if let common::Retry::After(d) =
24700 dlg.http_failure(&response, error.as_ref().ok())
24701 {
24702 sleep(d).await;
24703 continue;
24704 }
24705
24706 dlg.finished(false);
24707
24708 return Err(match error {
24709 Ok(value) => common::Error::BadRequest(value),
24710 _ => common::Error::Failure(response),
24711 });
24712 }
24713 let response = {
24714 let bytes = common::to_bytes(body).await.unwrap_or_default();
24715 let encoded = common::to_string(&bytes);
24716 match serde_json::from_str(&encoded) {
24717 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24718 Err(error) => {
24719 dlg.response_json_decode_error(&encoded, &error);
24720 return Err(common::Error::JsonDecodeError(
24721 encoded.to_string(),
24722 error,
24723 ));
24724 }
24725 }
24726 };
24727
24728 dlg.finished(true);
24729 return Ok(response);
24730 }
24731 }
24732 }
24733 }
24734
24735 ///
24736 /// Sets the *request* property to the given value.
24737 ///
24738 /// Even though the property as already been set when instantiating this call,
24739 /// we provide this method for API completeness.
24740 pub fn request(
24741 mut self,
24742 new_value: ObjectAccessControl,
24743 ) -> ObjectAccessControlUpdateCall<'a, C> {
24744 self._request = new_value;
24745 self
24746 }
24747 /// Name of a bucket.
24748 ///
24749 /// Sets the *bucket* path property to the given value.
24750 ///
24751 /// Even though the property as already been set when instantiating this call,
24752 /// we provide this method for API completeness.
24753 pub fn bucket(mut self, new_value: &str) -> ObjectAccessControlUpdateCall<'a, C> {
24754 self._bucket = new_value.to_string();
24755 self
24756 }
24757 /// 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).
24758 ///
24759 /// Sets the *object* path property to the given value.
24760 ///
24761 /// Even though the property as already been set when instantiating this call,
24762 /// we provide this method for API completeness.
24763 pub fn object(mut self, new_value: &str) -> ObjectAccessControlUpdateCall<'a, C> {
24764 self._object = new_value.to_string();
24765 self
24766 }
24767 /// The entity holding the permission. Can be user-userId, user-emailAddress, group-groupId, group-emailAddress, allUsers, or allAuthenticatedUsers.
24768 ///
24769 /// Sets the *entity* path property to the given value.
24770 ///
24771 /// Even though the property as already been set when instantiating this call,
24772 /// we provide this method for API completeness.
24773 pub fn entity(mut self, new_value: &str) -> ObjectAccessControlUpdateCall<'a, C> {
24774 self._entity = new_value.to_string();
24775 self
24776 }
24777 /// The project to be billed for this request. Required for Requester Pays buckets.
24778 ///
24779 /// Sets the *user project* query property to the given value.
24780 pub fn user_project(mut self, new_value: &str) -> ObjectAccessControlUpdateCall<'a, C> {
24781 self._user_project = Some(new_value.to_string());
24782 self
24783 }
24784 /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
24785 ///
24786 /// Sets the *generation* query property to the given value.
24787 pub fn generation(mut self, new_value: i64) -> ObjectAccessControlUpdateCall<'a, C> {
24788 self._generation = Some(new_value);
24789 self
24790 }
24791 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24792 /// while executing the actual API request.
24793 ///
24794 /// ````text
24795 /// It should be used to handle progress information, and to implement a certain level of resilience.
24796 /// ````
24797 ///
24798 /// Sets the *delegate* property to the given value.
24799 pub fn delegate(
24800 mut self,
24801 new_value: &'a mut dyn common::Delegate,
24802 ) -> ObjectAccessControlUpdateCall<'a, C> {
24803 self._delegate = Some(new_value);
24804 self
24805 }
24806
24807 /// Set any additional parameter of the query string used in the request.
24808 /// It should be used to set parameters which are not yet available through their own
24809 /// setters.
24810 ///
24811 /// Please note that this method must not be used to set any of the known parameters
24812 /// which have their own setter method. If done anyway, the request will fail.
24813 ///
24814 /// # Additional Parameters
24815 ///
24816 /// * *alt* (query-string) - Data format for the response.
24817 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24818 /// * *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.
24819 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24820 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24821 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
24822 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
24823 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
24824 pub fn param<T>(mut self, name: T, value: T) -> ObjectAccessControlUpdateCall<'a, C>
24825 where
24826 T: AsRef<str>,
24827 {
24828 self._additional_params
24829 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24830 self
24831 }
24832
24833 /// Identifies the authorization scope for the method you are building.
24834 ///
24835 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24836 /// [`Scope::DevstorageFullControl`].
24837 ///
24838 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24839 /// tokens for more than one scope.
24840 ///
24841 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24842 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24843 /// sufficient, a read-write scope will do as well.
24844 pub fn add_scope<St>(mut self, scope: St) -> ObjectAccessControlUpdateCall<'a, C>
24845 where
24846 St: AsRef<str>,
24847 {
24848 self._scopes.insert(String::from(scope.as_ref()));
24849 self
24850 }
24851 /// Identifies the authorization scope(s) for the method you are building.
24852 ///
24853 /// See [`Self::add_scope()`] for details.
24854 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectAccessControlUpdateCall<'a, C>
24855 where
24856 I: IntoIterator<Item = St>,
24857 St: AsRef<str>,
24858 {
24859 self._scopes
24860 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24861 self
24862 }
24863
24864 /// Removes all scopes, and no default scope will be used either.
24865 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24866 /// for details).
24867 pub fn clear_scopes(mut self) -> ObjectAccessControlUpdateCall<'a, C> {
24868 self._scopes.clear();
24869 self
24870 }
24871}
24872
24873/// Initiates a long-running bulk restore operation on the specified bucket.
24874///
24875/// A builder for the *bulkRestore* method supported by a *object* resource.
24876/// It is not used directly, but through a [`ObjectMethods`] instance.
24877///
24878/// # Example
24879///
24880/// Instantiate a resource method builder
24881///
24882/// ```test_harness,no_run
24883/// # extern crate hyper;
24884/// # extern crate hyper_rustls;
24885/// # extern crate google_storage1 as storage1;
24886/// use storage1::api::BulkRestoreObjectsRequest;
24887/// # async fn dox() {
24888/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24889///
24890/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24891/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24892/// # .with_native_roots()
24893/// # .unwrap()
24894/// # .https_only()
24895/// # .enable_http2()
24896/// # .build();
24897///
24898/// # let executor = hyper_util::rt::TokioExecutor::new();
24899/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24900/// # secret,
24901/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24902/// # yup_oauth2::client::CustomHyperClientBuilder::from(
24903/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
24904/// # ),
24905/// # ).build().await.unwrap();
24906///
24907/// # let client = hyper_util::client::legacy::Client::builder(
24908/// # hyper_util::rt::TokioExecutor::new()
24909/// # )
24910/// # .build(
24911/// # hyper_rustls::HttpsConnectorBuilder::new()
24912/// # .with_native_roots()
24913/// # .unwrap()
24914/// # .https_or_http()
24915/// # .enable_http2()
24916/// # .build()
24917/// # );
24918/// # let mut hub = Storage::new(client, auth);
24919/// // As the method needs a request, you would usually fill it with the desired information
24920/// // into the respective structure. Some of the parts shown here might not be applicable !
24921/// // Values shown here are possibly random and not representative !
24922/// let mut req = BulkRestoreObjectsRequest::default();
24923///
24924/// // You can configure optional parameters by calling the respective setters at will, and
24925/// // execute the final call using `doit()`.
24926/// // Values shown here are possibly random and not representative !
24927/// let result = hub.objects().bulk_restore(req, "bucket")
24928/// .doit().await;
24929/// # }
24930/// ```
24931pub struct ObjectBulkRestoreCall<'a, C>
24932where
24933 C: 'a,
24934{
24935 hub: &'a Storage<C>,
24936 _request: BulkRestoreObjectsRequest,
24937 _bucket: String,
24938 _delegate: Option<&'a mut dyn common::Delegate>,
24939 _additional_params: HashMap<String, String>,
24940 _scopes: BTreeSet<String>,
24941}
24942
24943impl<'a, C> common::CallBuilder for ObjectBulkRestoreCall<'a, C> {}
24944
24945impl<'a, C> ObjectBulkRestoreCall<'a, C>
24946where
24947 C: common::Connector,
24948{
24949 /// Perform the operation you have build so far.
24950 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
24951 use std::borrow::Cow;
24952 use std::io::{Read, Seek};
24953
24954 use common::{url::Params, ToParts};
24955 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24956
24957 let mut dd = common::DefaultDelegate;
24958 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24959 dlg.begin(common::MethodInfo {
24960 id: "storage.objects.bulkRestore",
24961 http_method: hyper::Method::POST,
24962 });
24963
24964 for &field in ["alt", "bucket"].iter() {
24965 if self._additional_params.contains_key(field) {
24966 dlg.finished(false);
24967 return Err(common::Error::FieldClash(field));
24968 }
24969 }
24970
24971 let mut params = Params::with_capacity(4 + self._additional_params.len());
24972 params.push("bucket", self._bucket);
24973
24974 params.extend(self._additional_params.iter());
24975
24976 params.push("alt", "json");
24977 let mut url = self.hub._base_url.clone() + "b/{bucket}/o/bulkRestore";
24978 if self._scopes.is_empty() {
24979 self._scopes
24980 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
24981 }
24982
24983 #[allow(clippy::single_element_loop)]
24984 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
24985 url = params.uri_replacement(url, param_name, find_this, false);
24986 }
24987 {
24988 let to_remove = ["bucket"];
24989 params.remove_params(&to_remove);
24990 }
24991
24992 let url = params.parse_with_url(&url);
24993
24994 let mut json_mime_type = mime::APPLICATION_JSON;
24995 let mut request_value_reader = {
24996 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24997 common::remove_json_null_values(&mut value);
24998 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24999 serde_json::to_writer(&mut dst, &value).unwrap();
25000 dst
25001 };
25002 let request_size = request_value_reader
25003 .seek(std::io::SeekFrom::End(0))
25004 .unwrap();
25005 request_value_reader
25006 .seek(std::io::SeekFrom::Start(0))
25007 .unwrap();
25008
25009 loop {
25010 let token = match self
25011 .hub
25012 .auth
25013 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25014 .await
25015 {
25016 Ok(token) => token,
25017 Err(e) => match dlg.token(e) {
25018 Ok(token) => token,
25019 Err(e) => {
25020 dlg.finished(false);
25021 return Err(common::Error::MissingToken(e));
25022 }
25023 },
25024 };
25025 request_value_reader
25026 .seek(std::io::SeekFrom::Start(0))
25027 .unwrap();
25028 let mut req_result = {
25029 let client = &self.hub.client;
25030 dlg.pre_request();
25031 let mut req_builder = hyper::Request::builder()
25032 .method(hyper::Method::POST)
25033 .uri(url.as_str())
25034 .header(USER_AGENT, self.hub._user_agent.clone());
25035
25036 if let Some(token) = token.as_ref() {
25037 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25038 }
25039
25040 let request = req_builder
25041 .header(CONTENT_TYPE, json_mime_type.to_string())
25042 .header(CONTENT_LENGTH, request_size as u64)
25043 .body(common::to_body(
25044 request_value_reader.get_ref().clone().into(),
25045 ));
25046
25047 client.request(request.unwrap()).await
25048 };
25049
25050 match req_result {
25051 Err(err) => {
25052 if let common::Retry::After(d) = dlg.http_error(&err) {
25053 sleep(d).await;
25054 continue;
25055 }
25056 dlg.finished(false);
25057 return Err(common::Error::HttpError(err));
25058 }
25059 Ok(res) => {
25060 let (mut parts, body) = res.into_parts();
25061 let mut body = common::Body::new(body);
25062 if !parts.status.is_success() {
25063 let bytes = common::to_bytes(body).await.unwrap_or_default();
25064 let error = serde_json::from_str(&common::to_string(&bytes));
25065 let response = common::to_response(parts, bytes.into());
25066
25067 if let common::Retry::After(d) =
25068 dlg.http_failure(&response, error.as_ref().ok())
25069 {
25070 sleep(d).await;
25071 continue;
25072 }
25073
25074 dlg.finished(false);
25075
25076 return Err(match error {
25077 Ok(value) => common::Error::BadRequest(value),
25078 _ => common::Error::Failure(response),
25079 });
25080 }
25081 let response = {
25082 let bytes = common::to_bytes(body).await.unwrap_or_default();
25083 let encoded = common::to_string(&bytes);
25084 match serde_json::from_str(&encoded) {
25085 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25086 Err(error) => {
25087 dlg.response_json_decode_error(&encoded, &error);
25088 return Err(common::Error::JsonDecodeError(
25089 encoded.to_string(),
25090 error,
25091 ));
25092 }
25093 }
25094 };
25095
25096 dlg.finished(true);
25097 return Ok(response);
25098 }
25099 }
25100 }
25101 }
25102
25103 ///
25104 /// Sets the *request* property to the given value.
25105 ///
25106 /// Even though the property as already been set when instantiating this call,
25107 /// we provide this method for API completeness.
25108 pub fn request(mut self, new_value: BulkRestoreObjectsRequest) -> ObjectBulkRestoreCall<'a, C> {
25109 self._request = new_value;
25110 self
25111 }
25112 /// Name of the bucket in which the object resides.
25113 ///
25114 /// Sets the *bucket* path property to the given value.
25115 ///
25116 /// Even though the property as already been set when instantiating this call,
25117 /// we provide this method for API completeness.
25118 pub fn bucket(mut self, new_value: &str) -> ObjectBulkRestoreCall<'a, C> {
25119 self._bucket = new_value.to_string();
25120 self
25121 }
25122 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25123 /// while executing the actual API request.
25124 ///
25125 /// ````text
25126 /// It should be used to handle progress information, and to implement a certain level of resilience.
25127 /// ````
25128 ///
25129 /// Sets the *delegate* property to the given value.
25130 pub fn delegate(
25131 mut self,
25132 new_value: &'a mut dyn common::Delegate,
25133 ) -> ObjectBulkRestoreCall<'a, C> {
25134 self._delegate = Some(new_value);
25135 self
25136 }
25137
25138 /// Set any additional parameter of the query string used in the request.
25139 /// It should be used to set parameters which are not yet available through their own
25140 /// setters.
25141 ///
25142 /// Please note that this method must not be used to set any of the known parameters
25143 /// which have their own setter method. If done anyway, the request will fail.
25144 ///
25145 /// # Additional Parameters
25146 ///
25147 /// * *alt* (query-string) - Data format for the response.
25148 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25149 /// * *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.
25150 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25151 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25152 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
25153 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
25154 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
25155 pub fn param<T>(mut self, name: T, value: T) -> ObjectBulkRestoreCall<'a, C>
25156 where
25157 T: AsRef<str>,
25158 {
25159 self._additional_params
25160 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25161 self
25162 }
25163
25164 /// Identifies the authorization scope for the method you are building.
25165 ///
25166 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25167 /// [`Scope::DevstorageReadWrite`].
25168 ///
25169 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25170 /// tokens for more than one scope.
25171 ///
25172 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25173 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25174 /// sufficient, a read-write scope will do as well.
25175 pub fn add_scope<St>(mut self, scope: St) -> ObjectBulkRestoreCall<'a, C>
25176 where
25177 St: AsRef<str>,
25178 {
25179 self._scopes.insert(String::from(scope.as_ref()));
25180 self
25181 }
25182 /// Identifies the authorization scope(s) for the method you are building.
25183 ///
25184 /// See [`Self::add_scope()`] for details.
25185 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectBulkRestoreCall<'a, C>
25186 where
25187 I: IntoIterator<Item = St>,
25188 St: AsRef<str>,
25189 {
25190 self._scopes
25191 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25192 self
25193 }
25194
25195 /// Removes all scopes, and no default scope will be used either.
25196 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25197 /// for details).
25198 pub fn clear_scopes(mut self) -> ObjectBulkRestoreCall<'a, C> {
25199 self._scopes.clear();
25200 self
25201 }
25202}
25203
25204/// Concatenates a list of existing objects into a new object in the same bucket.
25205///
25206/// A builder for the *compose* method supported by a *object* resource.
25207/// It is not used directly, but through a [`ObjectMethods`] instance.
25208///
25209/// # Example
25210///
25211/// Instantiate a resource method builder
25212///
25213/// ```test_harness,no_run
25214/// # extern crate hyper;
25215/// # extern crate hyper_rustls;
25216/// # extern crate google_storage1 as storage1;
25217/// use storage1::api::ComposeRequest;
25218/// # async fn dox() {
25219/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25220///
25221/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25222/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25223/// # .with_native_roots()
25224/// # .unwrap()
25225/// # .https_only()
25226/// # .enable_http2()
25227/// # .build();
25228///
25229/// # let executor = hyper_util::rt::TokioExecutor::new();
25230/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25231/// # secret,
25232/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25233/// # yup_oauth2::client::CustomHyperClientBuilder::from(
25234/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
25235/// # ),
25236/// # ).build().await.unwrap();
25237///
25238/// # let client = hyper_util::client::legacy::Client::builder(
25239/// # hyper_util::rt::TokioExecutor::new()
25240/// # )
25241/// # .build(
25242/// # hyper_rustls::HttpsConnectorBuilder::new()
25243/// # .with_native_roots()
25244/// # .unwrap()
25245/// # .https_or_http()
25246/// # .enable_http2()
25247/// # .build()
25248/// # );
25249/// # let mut hub = Storage::new(client, auth);
25250/// // As the method needs a request, you would usually fill it with the desired information
25251/// // into the respective structure. Some of the parts shown here might not be applicable !
25252/// // Values shown here are possibly random and not representative !
25253/// let mut req = ComposeRequest::default();
25254///
25255/// // You can configure optional parameters by calling the respective setters at will, and
25256/// // execute the final call using `doit()`.
25257/// // Values shown here are possibly random and not representative !
25258/// let result = hub.objects().compose(req, "destinationBucket", "destinationObject")
25259/// .user_project("et")
25260/// .kms_key_name("Lorem")
25261/// .if_metageneration_match(-33)
25262/// .if_generation_match(-59)
25263/// .destination_predefined_acl("rebum.")
25264/// .doit().await;
25265/// # }
25266/// ```
25267pub struct ObjectComposeCall<'a, C>
25268where
25269 C: 'a,
25270{
25271 hub: &'a Storage<C>,
25272 _request: ComposeRequest,
25273 _destination_bucket: String,
25274 _destination_object: String,
25275 _user_project: Option<String>,
25276 _kms_key_name: Option<String>,
25277 _if_metageneration_match: Option<i64>,
25278 _if_generation_match: Option<i64>,
25279 _destination_predefined_acl: Option<String>,
25280 _delegate: Option<&'a mut dyn common::Delegate>,
25281 _additional_params: HashMap<String, String>,
25282 _scopes: BTreeSet<String>,
25283}
25284
25285impl<'a, C> common::CallBuilder for ObjectComposeCall<'a, C> {}
25286
25287impl<'a, C> ObjectComposeCall<'a, C>
25288where
25289 C: common::Connector,
25290{
25291 /// Perform the operation you have build so far.
25292 pub async fn doit(mut self) -> common::Result<(common::Response, Object)> {
25293 use std::borrow::Cow;
25294 use std::io::{Read, Seek};
25295
25296 use common::{url::Params, ToParts};
25297 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25298
25299 let mut dd = common::DefaultDelegate;
25300 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25301 dlg.begin(common::MethodInfo {
25302 id: "storage.objects.compose",
25303 http_method: hyper::Method::POST,
25304 });
25305
25306 for &field in [
25307 "alt",
25308 "destinationBucket",
25309 "destinationObject",
25310 "userProject",
25311 "kmsKeyName",
25312 "ifMetagenerationMatch",
25313 "ifGenerationMatch",
25314 "destinationPredefinedAcl",
25315 ]
25316 .iter()
25317 {
25318 if self._additional_params.contains_key(field) {
25319 dlg.finished(false);
25320 return Err(common::Error::FieldClash(field));
25321 }
25322 }
25323
25324 let mut params = Params::with_capacity(10 + self._additional_params.len());
25325 params.push("destinationBucket", self._destination_bucket);
25326 params.push("destinationObject", self._destination_object);
25327 if let Some(value) = self._user_project.as_ref() {
25328 params.push("userProject", value);
25329 }
25330 if let Some(value) = self._kms_key_name.as_ref() {
25331 params.push("kmsKeyName", value);
25332 }
25333 if let Some(value) = self._if_metageneration_match.as_ref() {
25334 params.push("ifMetagenerationMatch", value.to_string());
25335 }
25336 if let Some(value) = self._if_generation_match.as_ref() {
25337 params.push("ifGenerationMatch", value.to_string());
25338 }
25339 if let Some(value) = self._destination_predefined_acl.as_ref() {
25340 params.push("destinationPredefinedAcl", value);
25341 }
25342
25343 params.extend(self._additional_params.iter());
25344
25345 params.push("alt", "json");
25346 let mut url =
25347 self.hub._base_url.clone() + "b/{destinationBucket}/o/{destinationObject}/compose";
25348 if self._scopes.is_empty() {
25349 self._scopes
25350 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
25351 }
25352
25353 #[allow(clippy::single_element_loop)]
25354 for &(find_this, param_name) in [
25355 ("{destinationBucket}", "destinationBucket"),
25356 ("{destinationObject}", "destinationObject"),
25357 ]
25358 .iter()
25359 {
25360 url = params.uri_replacement(url, param_name, find_this, false);
25361 }
25362 {
25363 let to_remove = ["destinationObject", "destinationBucket"];
25364 params.remove_params(&to_remove);
25365 }
25366
25367 let url = params.parse_with_url(&url);
25368
25369 let mut json_mime_type = mime::APPLICATION_JSON;
25370 let mut request_value_reader = {
25371 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25372 common::remove_json_null_values(&mut value);
25373 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25374 serde_json::to_writer(&mut dst, &value).unwrap();
25375 dst
25376 };
25377 let request_size = request_value_reader
25378 .seek(std::io::SeekFrom::End(0))
25379 .unwrap();
25380 request_value_reader
25381 .seek(std::io::SeekFrom::Start(0))
25382 .unwrap();
25383
25384 loop {
25385 let token = match self
25386 .hub
25387 .auth
25388 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25389 .await
25390 {
25391 Ok(token) => token,
25392 Err(e) => match dlg.token(e) {
25393 Ok(token) => token,
25394 Err(e) => {
25395 dlg.finished(false);
25396 return Err(common::Error::MissingToken(e));
25397 }
25398 },
25399 };
25400 request_value_reader
25401 .seek(std::io::SeekFrom::Start(0))
25402 .unwrap();
25403 let mut req_result = {
25404 let client = &self.hub.client;
25405 dlg.pre_request();
25406 let mut req_builder = hyper::Request::builder()
25407 .method(hyper::Method::POST)
25408 .uri(url.as_str())
25409 .header(USER_AGENT, self.hub._user_agent.clone());
25410
25411 if let Some(token) = token.as_ref() {
25412 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25413 }
25414
25415 let request = req_builder
25416 .header(CONTENT_TYPE, json_mime_type.to_string())
25417 .header(CONTENT_LENGTH, request_size as u64)
25418 .body(common::to_body(
25419 request_value_reader.get_ref().clone().into(),
25420 ));
25421
25422 client.request(request.unwrap()).await
25423 };
25424
25425 match req_result {
25426 Err(err) => {
25427 if let common::Retry::After(d) = dlg.http_error(&err) {
25428 sleep(d).await;
25429 continue;
25430 }
25431 dlg.finished(false);
25432 return Err(common::Error::HttpError(err));
25433 }
25434 Ok(res) => {
25435 let (mut parts, body) = res.into_parts();
25436 let mut body = common::Body::new(body);
25437 if !parts.status.is_success() {
25438 let bytes = common::to_bytes(body).await.unwrap_or_default();
25439 let error = serde_json::from_str(&common::to_string(&bytes));
25440 let response = common::to_response(parts, bytes.into());
25441
25442 if let common::Retry::After(d) =
25443 dlg.http_failure(&response, error.as_ref().ok())
25444 {
25445 sleep(d).await;
25446 continue;
25447 }
25448
25449 dlg.finished(false);
25450
25451 return Err(match error {
25452 Ok(value) => common::Error::BadRequest(value),
25453 _ => common::Error::Failure(response),
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 ///
25479 /// Sets the *request* property to the given value.
25480 ///
25481 /// Even though the property as already been set when instantiating this call,
25482 /// we provide this method for API completeness.
25483 pub fn request(mut self, new_value: ComposeRequest) -> ObjectComposeCall<'a, C> {
25484 self._request = new_value;
25485 self
25486 }
25487 /// Name of the bucket containing the source objects. The destination object is stored in this bucket.
25488 ///
25489 /// Sets the *destination bucket* path property to the given value.
25490 ///
25491 /// Even though the property as already been set when instantiating this call,
25492 /// we provide this method for API completeness.
25493 pub fn destination_bucket(mut self, new_value: &str) -> ObjectComposeCall<'a, C> {
25494 self._destination_bucket = new_value.to_string();
25495 self
25496 }
25497 /// 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).
25498 ///
25499 /// Sets the *destination object* path property to the given value.
25500 ///
25501 /// Even though the property as already been set when instantiating this call,
25502 /// we provide this method for API completeness.
25503 pub fn destination_object(mut self, new_value: &str) -> ObjectComposeCall<'a, C> {
25504 self._destination_object = new_value.to_string();
25505 self
25506 }
25507 /// The project to be billed for this request. Required for Requester Pays buckets.
25508 ///
25509 /// Sets the *user project* query property to the given value.
25510 pub fn user_project(mut self, new_value: &str) -> ObjectComposeCall<'a, C> {
25511 self._user_project = Some(new_value.to_string());
25512 self
25513 }
25514 /// 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.
25515 ///
25516 /// Sets the *kms key name* query property to the given value.
25517 pub fn kms_key_name(mut self, new_value: &str) -> ObjectComposeCall<'a, C> {
25518 self._kms_key_name = Some(new_value.to_string());
25519 self
25520 }
25521 /// Makes the operation conditional on whether the object's current metageneration matches the given value.
25522 ///
25523 /// Sets the *if metageneration match* query property to the given value.
25524 pub fn if_metageneration_match(mut self, new_value: i64) -> ObjectComposeCall<'a, C> {
25525 self._if_metageneration_match = Some(new_value);
25526 self
25527 }
25528 /// 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.
25529 ///
25530 /// Sets the *if generation match* query property to the given value.
25531 pub fn if_generation_match(mut self, new_value: i64) -> ObjectComposeCall<'a, C> {
25532 self._if_generation_match = Some(new_value);
25533 self
25534 }
25535 /// Apply a predefined set of access controls to the destination object.
25536 ///
25537 /// Sets the *destination predefined acl* query property to the given value.
25538 pub fn destination_predefined_acl(mut self, new_value: &str) -> ObjectComposeCall<'a, C> {
25539 self._destination_predefined_acl = Some(new_value.to_string());
25540 self
25541 }
25542 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25543 /// while executing the actual API request.
25544 ///
25545 /// ````text
25546 /// It should be used to handle progress information, and to implement a certain level of resilience.
25547 /// ````
25548 ///
25549 /// Sets the *delegate* property to the given value.
25550 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ObjectComposeCall<'a, C> {
25551 self._delegate = Some(new_value);
25552 self
25553 }
25554
25555 /// Set any additional parameter of the query string used in the request.
25556 /// It should be used to set parameters which are not yet available through their own
25557 /// setters.
25558 ///
25559 /// Please note that this method must not be used to set any of the known parameters
25560 /// which have their own setter method. If done anyway, the request will fail.
25561 ///
25562 /// # Additional Parameters
25563 ///
25564 /// * *alt* (query-string) - Data format for the response.
25565 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25566 /// * *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.
25567 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25568 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25569 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
25570 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
25571 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
25572 pub fn param<T>(mut self, name: T, value: T) -> ObjectComposeCall<'a, C>
25573 where
25574 T: AsRef<str>,
25575 {
25576 self._additional_params
25577 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25578 self
25579 }
25580
25581 /// Identifies the authorization scope for the method you are building.
25582 ///
25583 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25584 /// [`Scope::DevstorageReadWrite`].
25585 ///
25586 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25587 /// tokens for more than one scope.
25588 ///
25589 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25590 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25591 /// sufficient, a read-write scope will do as well.
25592 pub fn add_scope<St>(mut self, scope: St) -> ObjectComposeCall<'a, C>
25593 where
25594 St: AsRef<str>,
25595 {
25596 self._scopes.insert(String::from(scope.as_ref()));
25597 self
25598 }
25599 /// Identifies the authorization scope(s) for the method you are building.
25600 ///
25601 /// See [`Self::add_scope()`] for details.
25602 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectComposeCall<'a, C>
25603 where
25604 I: IntoIterator<Item = St>,
25605 St: AsRef<str>,
25606 {
25607 self._scopes
25608 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25609 self
25610 }
25611
25612 /// Removes all scopes, and no default scope will be used either.
25613 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25614 /// for details).
25615 pub fn clear_scopes(mut self) -> ObjectComposeCall<'a, C> {
25616 self._scopes.clear();
25617 self
25618 }
25619}
25620
25621/// Copies a source object to a destination object. Optionally overrides metadata.
25622///
25623/// A builder for the *copy* method supported by a *object* resource.
25624/// It is not used directly, but through a [`ObjectMethods`] instance.
25625///
25626/// # Example
25627///
25628/// Instantiate a resource method builder
25629///
25630/// ```test_harness,no_run
25631/// # extern crate hyper;
25632/// # extern crate hyper_rustls;
25633/// # extern crate google_storage1 as storage1;
25634/// use storage1::api::Object;
25635/// # async fn dox() {
25636/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25637///
25638/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25639/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25640/// # .with_native_roots()
25641/// # .unwrap()
25642/// # .https_only()
25643/// # .enable_http2()
25644/// # .build();
25645///
25646/// # let executor = hyper_util::rt::TokioExecutor::new();
25647/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25648/// # secret,
25649/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25650/// # yup_oauth2::client::CustomHyperClientBuilder::from(
25651/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
25652/// # ),
25653/// # ).build().await.unwrap();
25654///
25655/// # let client = hyper_util::client::legacy::Client::builder(
25656/// # hyper_util::rt::TokioExecutor::new()
25657/// # )
25658/// # .build(
25659/// # hyper_rustls::HttpsConnectorBuilder::new()
25660/// # .with_native_roots()
25661/// # .unwrap()
25662/// # .https_or_http()
25663/// # .enable_http2()
25664/// # .build()
25665/// # );
25666/// # let mut hub = Storage::new(client, auth);
25667/// // As the method needs a request, you would usually fill it with the desired information
25668/// // into the respective structure. Some of the parts shown here might not be applicable !
25669/// // Values shown here are possibly random and not representative !
25670/// let mut req = Object::default();
25671///
25672/// // You can configure optional parameters by calling the respective setters at will, and
25673/// // execute the final call using `doit()`.
25674/// // Values shown here are possibly random and not representative !
25675/// let result = hub.objects().copy(req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject")
25676/// .user_project("aliquyam")
25677/// .source_generation(-37)
25678/// .projection("sit")
25679/// .if_source_metageneration_not_match(-26)
25680/// .if_source_metageneration_match(-16)
25681/// .if_source_generation_not_match(-19)
25682/// .if_source_generation_match(-96)
25683/// .if_metageneration_not_match(-19)
25684/// .if_metageneration_match(-30)
25685/// .if_generation_not_match(-38)
25686/// .if_generation_match(-64)
25687/// .destination_predefined_acl("dolor")
25688/// .destination_kms_key_name("aliquyam")
25689/// .doit().await;
25690/// # }
25691/// ```
25692pub struct ObjectCopyCall<'a, C>
25693where
25694 C: 'a,
25695{
25696 hub: &'a Storage<C>,
25697 _request: Object,
25698 _source_bucket: String,
25699 _source_object: String,
25700 _destination_bucket: String,
25701 _destination_object: String,
25702 _user_project: Option<String>,
25703 _source_generation: Option<i64>,
25704 _projection: Option<String>,
25705 _if_source_metageneration_not_match: Option<i64>,
25706 _if_source_metageneration_match: Option<i64>,
25707 _if_source_generation_not_match: Option<i64>,
25708 _if_source_generation_match: Option<i64>,
25709 _if_metageneration_not_match: Option<i64>,
25710 _if_metageneration_match: Option<i64>,
25711 _if_generation_not_match: Option<i64>,
25712 _if_generation_match: Option<i64>,
25713 _destination_predefined_acl: Option<String>,
25714 _destination_kms_key_name: Option<String>,
25715 _delegate: Option<&'a mut dyn common::Delegate>,
25716 _additional_params: HashMap<String, String>,
25717 _scopes: BTreeSet<String>,
25718}
25719
25720impl<'a, C> common::CallBuilder for ObjectCopyCall<'a, C> {}
25721
25722impl<'a, C> ObjectCopyCall<'a, C>
25723where
25724 C: common::Connector,
25725{
25726 /// Perform the operation you have build so far.
25727 pub async fn doit(mut self) -> common::Result<(common::Response, Object)> {
25728 use std::borrow::Cow;
25729 use std::io::{Read, Seek};
25730
25731 use common::{url::Params, ToParts};
25732 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25733
25734 let mut dd = common::DefaultDelegate;
25735 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25736 dlg.begin(common::MethodInfo {
25737 id: "storage.objects.copy",
25738 http_method: hyper::Method::POST,
25739 });
25740
25741 for &field in [
25742 "alt",
25743 "sourceBucket",
25744 "sourceObject",
25745 "destinationBucket",
25746 "destinationObject",
25747 "userProject",
25748 "sourceGeneration",
25749 "projection",
25750 "ifSourceMetagenerationNotMatch",
25751 "ifSourceMetagenerationMatch",
25752 "ifSourceGenerationNotMatch",
25753 "ifSourceGenerationMatch",
25754 "ifMetagenerationNotMatch",
25755 "ifMetagenerationMatch",
25756 "ifGenerationNotMatch",
25757 "ifGenerationMatch",
25758 "destinationPredefinedAcl",
25759 "destinationKmsKeyName",
25760 ]
25761 .iter()
25762 {
25763 if self._additional_params.contains_key(field) {
25764 dlg.finished(false);
25765 return Err(common::Error::FieldClash(field));
25766 }
25767 }
25768
25769 let mut params = Params::with_capacity(20 + self._additional_params.len());
25770 params.push("sourceBucket", self._source_bucket);
25771 params.push("sourceObject", self._source_object);
25772 params.push("destinationBucket", self._destination_bucket);
25773 params.push("destinationObject", self._destination_object);
25774 if let Some(value) = self._user_project.as_ref() {
25775 params.push("userProject", value);
25776 }
25777 if let Some(value) = self._source_generation.as_ref() {
25778 params.push("sourceGeneration", value.to_string());
25779 }
25780 if let Some(value) = self._projection.as_ref() {
25781 params.push("projection", value);
25782 }
25783 if let Some(value) = self._if_source_metageneration_not_match.as_ref() {
25784 params.push("ifSourceMetagenerationNotMatch", value.to_string());
25785 }
25786 if let Some(value) = self._if_source_metageneration_match.as_ref() {
25787 params.push("ifSourceMetagenerationMatch", value.to_string());
25788 }
25789 if let Some(value) = self._if_source_generation_not_match.as_ref() {
25790 params.push("ifSourceGenerationNotMatch", value.to_string());
25791 }
25792 if let Some(value) = self._if_source_generation_match.as_ref() {
25793 params.push("ifSourceGenerationMatch", value.to_string());
25794 }
25795 if let Some(value) = self._if_metageneration_not_match.as_ref() {
25796 params.push("ifMetagenerationNotMatch", value.to_string());
25797 }
25798 if let Some(value) = self._if_metageneration_match.as_ref() {
25799 params.push("ifMetagenerationMatch", value.to_string());
25800 }
25801 if let Some(value) = self._if_generation_not_match.as_ref() {
25802 params.push("ifGenerationNotMatch", value.to_string());
25803 }
25804 if let Some(value) = self._if_generation_match.as_ref() {
25805 params.push("ifGenerationMatch", value.to_string());
25806 }
25807 if let Some(value) = self._destination_predefined_acl.as_ref() {
25808 params.push("destinationPredefinedAcl", value);
25809 }
25810 if let Some(value) = self._destination_kms_key_name.as_ref() {
25811 params.push("destinationKmsKeyName", value);
25812 }
25813
25814 params.extend(self._additional_params.iter());
25815
25816 params.push("alt", "json");
25817 let mut url = self.hub._base_url.clone() + "b/{sourceBucket}/o/{sourceObject}/copyTo/b/{destinationBucket}/o/{destinationObject}";
25818 if self._scopes.is_empty() {
25819 self._scopes
25820 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
25821 }
25822
25823 #[allow(clippy::single_element_loop)]
25824 for &(find_this, param_name) in [
25825 ("{sourceBucket}", "sourceBucket"),
25826 ("{sourceObject}", "sourceObject"),
25827 ("{destinationBucket}", "destinationBucket"),
25828 ("{destinationObject}", "destinationObject"),
25829 ]
25830 .iter()
25831 {
25832 url = params.uri_replacement(url, param_name, find_this, false);
25833 }
25834 {
25835 let to_remove = [
25836 "destinationObject",
25837 "destinationBucket",
25838 "sourceObject",
25839 "sourceBucket",
25840 ];
25841 params.remove_params(&to_remove);
25842 }
25843
25844 let url = params.parse_with_url(&url);
25845
25846 let mut json_mime_type = mime::APPLICATION_JSON;
25847 let mut request_value_reader = {
25848 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25849 common::remove_json_null_values(&mut value);
25850 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25851 serde_json::to_writer(&mut dst, &value).unwrap();
25852 dst
25853 };
25854 let request_size = request_value_reader
25855 .seek(std::io::SeekFrom::End(0))
25856 .unwrap();
25857 request_value_reader
25858 .seek(std::io::SeekFrom::Start(0))
25859 .unwrap();
25860
25861 loop {
25862 let token = match self
25863 .hub
25864 .auth
25865 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25866 .await
25867 {
25868 Ok(token) => token,
25869 Err(e) => match dlg.token(e) {
25870 Ok(token) => token,
25871 Err(e) => {
25872 dlg.finished(false);
25873 return Err(common::Error::MissingToken(e));
25874 }
25875 },
25876 };
25877 request_value_reader
25878 .seek(std::io::SeekFrom::Start(0))
25879 .unwrap();
25880 let mut req_result = {
25881 let client = &self.hub.client;
25882 dlg.pre_request();
25883 let mut req_builder = hyper::Request::builder()
25884 .method(hyper::Method::POST)
25885 .uri(url.as_str())
25886 .header(USER_AGENT, self.hub._user_agent.clone());
25887
25888 if let Some(token) = token.as_ref() {
25889 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25890 }
25891
25892 let request = req_builder
25893 .header(CONTENT_TYPE, json_mime_type.to_string())
25894 .header(CONTENT_LENGTH, request_size as u64)
25895 .body(common::to_body(
25896 request_value_reader.get_ref().clone().into(),
25897 ));
25898
25899 client.request(request.unwrap()).await
25900 };
25901
25902 match req_result {
25903 Err(err) => {
25904 if let common::Retry::After(d) = dlg.http_error(&err) {
25905 sleep(d).await;
25906 continue;
25907 }
25908 dlg.finished(false);
25909 return Err(common::Error::HttpError(err));
25910 }
25911 Ok(res) => {
25912 let (mut parts, body) = res.into_parts();
25913 let mut body = common::Body::new(body);
25914 if !parts.status.is_success() {
25915 let bytes = common::to_bytes(body).await.unwrap_or_default();
25916 let error = serde_json::from_str(&common::to_string(&bytes));
25917 let response = common::to_response(parts, bytes.into());
25918
25919 if let common::Retry::After(d) =
25920 dlg.http_failure(&response, error.as_ref().ok())
25921 {
25922 sleep(d).await;
25923 continue;
25924 }
25925
25926 dlg.finished(false);
25927
25928 return Err(match error {
25929 Ok(value) => common::Error::BadRequest(value),
25930 _ => common::Error::Failure(response),
25931 });
25932 }
25933 let response = {
25934 let bytes = common::to_bytes(body).await.unwrap_or_default();
25935 let encoded = common::to_string(&bytes);
25936 match serde_json::from_str(&encoded) {
25937 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25938 Err(error) => {
25939 dlg.response_json_decode_error(&encoded, &error);
25940 return Err(common::Error::JsonDecodeError(
25941 encoded.to_string(),
25942 error,
25943 ));
25944 }
25945 }
25946 };
25947
25948 dlg.finished(true);
25949 return Ok(response);
25950 }
25951 }
25952 }
25953 }
25954
25955 ///
25956 /// Sets the *request* property to the given value.
25957 ///
25958 /// Even though the property as already been set when instantiating this call,
25959 /// we provide this method for API completeness.
25960 pub fn request(mut self, new_value: Object) -> ObjectCopyCall<'a, C> {
25961 self._request = new_value;
25962 self
25963 }
25964 /// Name of the bucket in which to find the source object.
25965 ///
25966 /// Sets the *source bucket* path property to the given value.
25967 ///
25968 /// Even though the property as already been set when instantiating this call,
25969 /// we provide this method for API completeness.
25970 pub fn source_bucket(mut self, new_value: &str) -> ObjectCopyCall<'a, C> {
25971 self._source_bucket = new_value.to_string();
25972 self
25973 }
25974 /// 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).
25975 ///
25976 /// Sets the *source object* path property to the given value.
25977 ///
25978 /// Even though the property as already been set when instantiating this call,
25979 /// we provide this method for API completeness.
25980 pub fn source_object(mut self, new_value: &str) -> ObjectCopyCall<'a, C> {
25981 self._source_object = new_value.to_string();
25982 self
25983 }
25984 /// 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).
25985 ///
25986 /// Sets the *destination bucket* path property to the given value.
25987 ///
25988 /// Even though the property as already been set when instantiating this call,
25989 /// we provide this method for API completeness.
25990 pub fn destination_bucket(mut self, new_value: &str) -> ObjectCopyCall<'a, C> {
25991 self._destination_bucket = new_value.to_string();
25992 self
25993 }
25994 /// Name of the new object. Required when the object metadata is not otherwise provided. Overrides the object metadata's name value, if any.
25995 ///
25996 /// Sets the *destination object* path property to the given value.
25997 ///
25998 /// Even though the property as already been set when instantiating this call,
25999 /// we provide this method for API completeness.
26000 pub fn destination_object(mut self, new_value: &str) -> ObjectCopyCall<'a, C> {
26001 self._destination_object = new_value.to_string();
26002 self
26003 }
26004 /// The project to be billed for this request. Required for Requester Pays buckets.
26005 ///
26006 /// Sets the *user project* query property to the given value.
26007 pub fn user_project(mut self, new_value: &str) -> ObjectCopyCall<'a, C> {
26008 self._user_project = Some(new_value.to_string());
26009 self
26010 }
26011 /// If present, selects a specific revision of the source object (as opposed to the latest version, the default).
26012 ///
26013 /// Sets the *source generation* query property to the given value.
26014 pub fn source_generation(mut self, new_value: i64) -> ObjectCopyCall<'a, C> {
26015 self._source_generation = Some(new_value);
26016 self
26017 }
26018 /// Set of properties to return. Defaults to noAcl, unless the object resource specifies the acl property, when it defaults to full.
26019 ///
26020 /// Sets the *projection* query property to the given value.
26021 pub fn projection(mut self, new_value: &str) -> ObjectCopyCall<'a, C> {
26022 self._projection = Some(new_value.to_string());
26023 self
26024 }
26025 /// Makes the operation conditional on whether the source object's current metageneration does not match the given value.
26026 ///
26027 /// Sets the *if source metageneration not match* query property to the given value.
26028 pub fn if_source_metageneration_not_match(mut self, new_value: i64) -> ObjectCopyCall<'a, C> {
26029 self._if_source_metageneration_not_match = Some(new_value);
26030 self
26031 }
26032 /// Makes the operation conditional on whether the source object's current metageneration matches the given value.
26033 ///
26034 /// Sets the *if source metageneration match* query property to the given value.
26035 pub fn if_source_metageneration_match(mut self, new_value: i64) -> ObjectCopyCall<'a, C> {
26036 self._if_source_metageneration_match = Some(new_value);
26037 self
26038 }
26039 /// Makes the operation conditional on whether the source object's current generation does not match the given value.
26040 ///
26041 /// Sets the *if source generation not match* query property to the given value.
26042 pub fn if_source_generation_not_match(mut self, new_value: i64) -> ObjectCopyCall<'a, C> {
26043 self._if_source_generation_not_match = Some(new_value);
26044 self
26045 }
26046 /// Makes the operation conditional on whether the source object's current generation matches the given value.
26047 ///
26048 /// Sets the *if source generation match* query property to the given value.
26049 pub fn if_source_generation_match(mut self, new_value: i64) -> ObjectCopyCall<'a, C> {
26050 self._if_source_generation_match = Some(new_value);
26051 self
26052 }
26053 /// Makes the operation conditional on whether the destination object's current metageneration does not match the given value.
26054 ///
26055 /// Sets the *if metageneration not match* query property to the given value.
26056 pub fn if_metageneration_not_match(mut self, new_value: i64) -> ObjectCopyCall<'a, C> {
26057 self._if_metageneration_not_match = Some(new_value);
26058 self
26059 }
26060 /// Makes the operation conditional on whether the destination object's current metageneration matches the given value.
26061 ///
26062 /// Sets the *if metageneration match* query property to the given value.
26063 pub fn if_metageneration_match(mut self, new_value: i64) -> ObjectCopyCall<'a, C> {
26064 self._if_metageneration_match = Some(new_value);
26065 self
26066 }
26067 /// 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.
26068 ///
26069 /// Sets the *if generation not match* query property to the given value.
26070 pub fn if_generation_not_match(mut self, new_value: i64) -> ObjectCopyCall<'a, C> {
26071 self._if_generation_not_match = Some(new_value);
26072 self
26073 }
26074 /// 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.
26075 ///
26076 /// Sets the *if generation match* query property to the given value.
26077 pub fn if_generation_match(mut self, new_value: i64) -> ObjectCopyCall<'a, C> {
26078 self._if_generation_match = Some(new_value);
26079 self
26080 }
26081 /// Apply a predefined set of access controls to the destination object.
26082 ///
26083 /// Sets the *destination predefined acl* query property to the given value.
26084 pub fn destination_predefined_acl(mut self, new_value: &str) -> ObjectCopyCall<'a, C> {
26085 self._destination_predefined_acl = Some(new_value.to_string());
26086 self
26087 }
26088 /// 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.
26089 ///
26090 /// Sets the *destination kms key name* query property to the given value.
26091 pub fn destination_kms_key_name(mut self, new_value: &str) -> ObjectCopyCall<'a, C> {
26092 self._destination_kms_key_name = Some(new_value.to_string());
26093 self
26094 }
26095 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26096 /// while executing the actual API request.
26097 ///
26098 /// ````text
26099 /// It should be used to handle progress information, and to implement a certain level of resilience.
26100 /// ````
26101 ///
26102 /// Sets the *delegate* property to the given value.
26103 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ObjectCopyCall<'a, C> {
26104 self._delegate = Some(new_value);
26105 self
26106 }
26107
26108 /// Set any additional parameter of the query string used in the request.
26109 /// It should be used to set parameters which are not yet available through their own
26110 /// setters.
26111 ///
26112 /// Please note that this method must not be used to set any of the known parameters
26113 /// which have their own setter method. If done anyway, the request will fail.
26114 ///
26115 /// # Additional Parameters
26116 ///
26117 /// * *alt* (query-string) - Data format for the response.
26118 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26119 /// * *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.
26120 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26121 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26122 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
26123 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
26124 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
26125 pub fn param<T>(mut self, name: T, value: T) -> ObjectCopyCall<'a, C>
26126 where
26127 T: AsRef<str>,
26128 {
26129 self._additional_params
26130 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26131 self
26132 }
26133
26134 /// Identifies the authorization scope for the method you are building.
26135 ///
26136 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26137 /// [`Scope::DevstorageReadWrite`].
26138 ///
26139 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26140 /// tokens for more than one scope.
26141 ///
26142 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26143 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26144 /// sufficient, a read-write scope will do as well.
26145 pub fn add_scope<St>(mut self, scope: St) -> ObjectCopyCall<'a, C>
26146 where
26147 St: AsRef<str>,
26148 {
26149 self._scopes.insert(String::from(scope.as_ref()));
26150 self
26151 }
26152 /// Identifies the authorization scope(s) for the method you are building.
26153 ///
26154 /// See [`Self::add_scope()`] for details.
26155 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectCopyCall<'a, C>
26156 where
26157 I: IntoIterator<Item = St>,
26158 St: AsRef<str>,
26159 {
26160 self._scopes
26161 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26162 self
26163 }
26164
26165 /// Removes all scopes, and no default scope will be used either.
26166 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26167 /// for details).
26168 pub fn clear_scopes(mut self) -> ObjectCopyCall<'a, C> {
26169 self._scopes.clear();
26170 self
26171 }
26172}
26173
26174/// Deletes an object and its metadata. Deletions are permanent if versioning is not enabled for the bucket, or if the generation parameter is used.
26175///
26176/// A builder for the *delete* method supported by a *object* resource.
26177/// It is not used directly, but through a [`ObjectMethods`] instance.
26178///
26179/// # Example
26180///
26181/// Instantiate a resource method builder
26182///
26183/// ```test_harness,no_run
26184/// # extern crate hyper;
26185/// # extern crate hyper_rustls;
26186/// # extern crate google_storage1 as storage1;
26187/// # async fn dox() {
26188/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26189///
26190/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26191/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26192/// # .with_native_roots()
26193/// # .unwrap()
26194/// # .https_only()
26195/// # .enable_http2()
26196/// # .build();
26197///
26198/// # let executor = hyper_util::rt::TokioExecutor::new();
26199/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26200/// # secret,
26201/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26202/// # yup_oauth2::client::CustomHyperClientBuilder::from(
26203/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
26204/// # ),
26205/// # ).build().await.unwrap();
26206///
26207/// # let client = hyper_util::client::legacy::Client::builder(
26208/// # hyper_util::rt::TokioExecutor::new()
26209/// # )
26210/// # .build(
26211/// # hyper_rustls::HttpsConnectorBuilder::new()
26212/// # .with_native_roots()
26213/// # .unwrap()
26214/// # .https_or_http()
26215/// # .enable_http2()
26216/// # .build()
26217/// # );
26218/// # let mut hub = Storage::new(client, auth);
26219/// // You can configure optional parameters by calling the respective setters at will, and
26220/// // execute the final call using `doit()`.
26221/// // Values shown here are possibly random and not representative !
26222/// let result = hub.objects().delete("bucket", "object")
26223/// .user_project("nonumy")
26224/// .if_metageneration_not_match(-18)
26225/// .if_metageneration_match(-8)
26226/// .if_generation_not_match(-23)
26227/// .if_generation_match(-39)
26228/// .generation(-43)
26229/// .doit().await;
26230/// # }
26231/// ```
26232pub struct ObjectDeleteCall<'a, C>
26233where
26234 C: 'a,
26235{
26236 hub: &'a Storage<C>,
26237 _bucket: String,
26238 _object: String,
26239 _user_project: Option<String>,
26240 _if_metageneration_not_match: Option<i64>,
26241 _if_metageneration_match: Option<i64>,
26242 _if_generation_not_match: Option<i64>,
26243 _if_generation_match: Option<i64>,
26244 _generation: Option<i64>,
26245 _delegate: Option<&'a mut dyn common::Delegate>,
26246 _additional_params: HashMap<String, String>,
26247 _scopes: BTreeSet<String>,
26248}
26249
26250impl<'a, C> common::CallBuilder for ObjectDeleteCall<'a, C> {}
26251
26252impl<'a, C> ObjectDeleteCall<'a, C>
26253where
26254 C: common::Connector,
26255{
26256 /// Perform the operation you have build so far.
26257 pub async fn doit(mut self) -> common::Result<common::Response> {
26258 use std::borrow::Cow;
26259 use std::io::{Read, Seek};
26260
26261 use common::{url::Params, ToParts};
26262 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26263
26264 let mut dd = common::DefaultDelegate;
26265 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26266 dlg.begin(common::MethodInfo {
26267 id: "storage.objects.delete",
26268 http_method: hyper::Method::DELETE,
26269 });
26270
26271 for &field in [
26272 "bucket",
26273 "object",
26274 "userProject",
26275 "ifMetagenerationNotMatch",
26276 "ifMetagenerationMatch",
26277 "ifGenerationNotMatch",
26278 "ifGenerationMatch",
26279 "generation",
26280 ]
26281 .iter()
26282 {
26283 if self._additional_params.contains_key(field) {
26284 dlg.finished(false);
26285 return Err(common::Error::FieldClash(field));
26286 }
26287 }
26288
26289 let mut params = Params::with_capacity(9 + self._additional_params.len());
26290 params.push("bucket", self._bucket);
26291 params.push("object", self._object);
26292 if let Some(value) = self._user_project.as_ref() {
26293 params.push("userProject", value);
26294 }
26295 if let Some(value) = self._if_metageneration_not_match.as_ref() {
26296 params.push("ifMetagenerationNotMatch", value.to_string());
26297 }
26298 if let Some(value) = self._if_metageneration_match.as_ref() {
26299 params.push("ifMetagenerationMatch", value.to_string());
26300 }
26301 if let Some(value) = self._if_generation_not_match.as_ref() {
26302 params.push("ifGenerationNotMatch", value.to_string());
26303 }
26304 if let Some(value) = self._if_generation_match.as_ref() {
26305 params.push("ifGenerationMatch", value.to_string());
26306 }
26307 if let Some(value) = self._generation.as_ref() {
26308 params.push("generation", value.to_string());
26309 }
26310
26311 params.extend(self._additional_params.iter());
26312
26313 let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}";
26314 if self._scopes.is_empty() {
26315 self._scopes
26316 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
26317 }
26318
26319 #[allow(clippy::single_element_loop)]
26320 for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object")].iter() {
26321 url = params.uri_replacement(url, param_name, find_this, false);
26322 }
26323 {
26324 let to_remove = ["object", "bucket"];
26325 params.remove_params(&to_remove);
26326 }
26327
26328 let url = params.parse_with_url(&url);
26329
26330 loop {
26331 let token = match self
26332 .hub
26333 .auth
26334 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26335 .await
26336 {
26337 Ok(token) => token,
26338 Err(e) => match dlg.token(e) {
26339 Ok(token) => token,
26340 Err(e) => {
26341 dlg.finished(false);
26342 return Err(common::Error::MissingToken(e));
26343 }
26344 },
26345 };
26346 let mut req_result = {
26347 let client = &self.hub.client;
26348 dlg.pre_request();
26349 let mut req_builder = hyper::Request::builder()
26350 .method(hyper::Method::DELETE)
26351 .uri(url.as_str())
26352 .header(USER_AGENT, self.hub._user_agent.clone());
26353
26354 if let Some(token) = token.as_ref() {
26355 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26356 }
26357
26358 let request = req_builder
26359 .header(CONTENT_LENGTH, 0_u64)
26360 .body(common::to_body::<String>(None));
26361
26362 client.request(request.unwrap()).await
26363 };
26364
26365 match req_result {
26366 Err(err) => {
26367 if let common::Retry::After(d) = dlg.http_error(&err) {
26368 sleep(d).await;
26369 continue;
26370 }
26371 dlg.finished(false);
26372 return Err(common::Error::HttpError(err));
26373 }
26374 Ok(res) => {
26375 let (mut parts, body) = res.into_parts();
26376 let mut body = common::Body::new(body);
26377 if !parts.status.is_success() {
26378 let bytes = common::to_bytes(body).await.unwrap_or_default();
26379 let error = serde_json::from_str(&common::to_string(&bytes));
26380 let response = common::to_response(parts, bytes.into());
26381
26382 if let common::Retry::After(d) =
26383 dlg.http_failure(&response, error.as_ref().ok())
26384 {
26385 sleep(d).await;
26386 continue;
26387 }
26388
26389 dlg.finished(false);
26390
26391 return Err(match error {
26392 Ok(value) => common::Error::BadRequest(value),
26393 _ => common::Error::Failure(response),
26394 });
26395 }
26396 let response = common::Response::from_parts(parts, body);
26397
26398 dlg.finished(true);
26399 return Ok(response);
26400 }
26401 }
26402 }
26403 }
26404
26405 /// Name of the bucket in which the object resides.
26406 ///
26407 /// Sets the *bucket* path property to the given value.
26408 ///
26409 /// Even though the property as already been set when instantiating this call,
26410 /// we provide this method for API completeness.
26411 pub fn bucket(mut self, new_value: &str) -> ObjectDeleteCall<'a, C> {
26412 self._bucket = new_value.to_string();
26413 self
26414 }
26415 /// 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).
26416 ///
26417 /// Sets the *object* path property to the given value.
26418 ///
26419 /// Even though the property as already been set when instantiating this call,
26420 /// we provide this method for API completeness.
26421 pub fn object(mut self, new_value: &str) -> ObjectDeleteCall<'a, C> {
26422 self._object = new_value.to_string();
26423 self
26424 }
26425 /// The project to be billed for this request. Required for Requester Pays buckets.
26426 ///
26427 /// Sets the *user project* query property to the given value.
26428 pub fn user_project(mut self, new_value: &str) -> ObjectDeleteCall<'a, C> {
26429 self._user_project = Some(new_value.to_string());
26430 self
26431 }
26432 /// Makes the operation conditional on whether the object's current metageneration does not match the given value.
26433 ///
26434 /// Sets the *if metageneration not match* query property to the given value.
26435 pub fn if_metageneration_not_match(mut self, new_value: i64) -> ObjectDeleteCall<'a, C> {
26436 self._if_metageneration_not_match = Some(new_value);
26437 self
26438 }
26439 /// Makes the operation conditional on whether the object's current metageneration matches the given value.
26440 ///
26441 /// Sets the *if metageneration match* query property to the given value.
26442 pub fn if_metageneration_match(mut self, new_value: i64) -> ObjectDeleteCall<'a, C> {
26443 self._if_metageneration_match = Some(new_value);
26444 self
26445 }
26446 /// 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.
26447 ///
26448 /// Sets the *if generation not match* query property to the given value.
26449 pub fn if_generation_not_match(mut self, new_value: i64) -> ObjectDeleteCall<'a, C> {
26450 self._if_generation_not_match = Some(new_value);
26451 self
26452 }
26453 /// 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.
26454 ///
26455 /// Sets the *if generation match* query property to the given value.
26456 pub fn if_generation_match(mut self, new_value: i64) -> ObjectDeleteCall<'a, C> {
26457 self._if_generation_match = Some(new_value);
26458 self
26459 }
26460 /// If present, permanently deletes a specific revision of this object (as opposed to the latest version, the default).
26461 ///
26462 /// Sets the *generation* query property to the given value.
26463 pub fn generation(mut self, new_value: i64) -> ObjectDeleteCall<'a, C> {
26464 self._generation = Some(new_value);
26465 self
26466 }
26467 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26468 /// while executing the actual API request.
26469 ///
26470 /// ````text
26471 /// It should be used to handle progress information, and to implement a certain level of resilience.
26472 /// ````
26473 ///
26474 /// Sets the *delegate* property to the given value.
26475 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ObjectDeleteCall<'a, C> {
26476 self._delegate = Some(new_value);
26477 self
26478 }
26479
26480 /// Set any additional parameter of the query string used in the request.
26481 /// It should be used to set parameters which are not yet available through their own
26482 /// setters.
26483 ///
26484 /// Please note that this method must not be used to set any of the known parameters
26485 /// which have their own setter method. If done anyway, the request will fail.
26486 ///
26487 /// # Additional Parameters
26488 ///
26489 /// * *alt* (query-string) - Data format for the response.
26490 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26491 /// * *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.
26492 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26493 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26494 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
26495 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
26496 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
26497 pub fn param<T>(mut self, name: T, value: T) -> ObjectDeleteCall<'a, C>
26498 where
26499 T: AsRef<str>,
26500 {
26501 self._additional_params
26502 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26503 self
26504 }
26505
26506 /// Identifies the authorization scope for the method you are building.
26507 ///
26508 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26509 /// [`Scope::DevstorageReadWrite`].
26510 ///
26511 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26512 /// tokens for more than one scope.
26513 ///
26514 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26515 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26516 /// sufficient, a read-write scope will do as well.
26517 pub fn add_scope<St>(mut self, scope: St) -> ObjectDeleteCall<'a, C>
26518 where
26519 St: AsRef<str>,
26520 {
26521 self._scopes.insert(String::from(scope.as_ref()));
26522 self
26523 }
26524 /// Identifies the authorization scope(s) for the method you are building.
26525 ///
26526 /// See [`Self::add_scope()`] for details.
26527 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectDeleteCall<'a, C>
26528 where
26529 I: IntoIterator<Item = St>,
26530 St: AsRef<str>,
26531 {
26532 self._scopes
26533 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26534 self
26535 }
26536
26537 /// Removes all scopes, and no default scope will be used either.
26538 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26539 /// for details).
26540 pub fn clear_scopes(mut self) -> ObjectDeleteCall<'a, C> {
26541 self._scopes.clear();
26542 self
26543 }
26544}
26545
26546/// Retrieves an object or its metadata.
26547///
26548/// This method supports **media download**. To enable it, adjust the builder like this:
26549/// `.param("alt", "media")`.
26550/// Please note that due to missing multi-part support on the server side, you will only receive the media,
26551/// but not the `Object` structure that you would usually get. The latter will be a default value.
26552///
26553/// A builder for the *get* method supported by a *object* resource.
26554/// It is not used directly, but through a [`ObjectMethods`] instance.
26555///
26556/// # Example
26557///
26558/// Instantiate a resource method builder
26559///
26560/// ```test_harness,no_run
26561/// # extern crate hyper;
26562/// # extern crate hyper_rustls;
26563/// # extern crate google_storage1 as storage1;
26564/// # async fn dox() {
26565/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26566///
26567/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26568/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26569/// # .with_native_roots()
26570/// # .unwrap()
26571/// # .https_only()
26572/// # .enable_http2()
26573/// # .build();
26574///
26575/// # let executor = hyper_util::rt::TokioExecutor::new();
26576/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26577/// # secret,
26578/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26579/// # yup_oauth2::client::CustomHyperClientBuilder::from(
26580/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
26581/// # ),
26582/// # ).build().await.unwrap();
26583///
26584/// # let client = hyper_util::client::legacy::Client::builder(
26585/// # hyper_util::rt::TokioExecutor::new()
26586/// # )
26587/// # .build(
26588/// # hyper_rustls::HttpsConnectorBuilder::new()
26589/// # .with_native_roots()
26590/// # .unwrap()
26591/// # .https_or_http()
26592/// # .enable_http2()
26593/// # .build()
26594/// # );
26595/// # let mut hub = Storage::new(client, auth);
26596/// // You can configure optional parameters by calling the respective setters at will, and
26597/// // execute the final call using `doit()`.
26598/// // Values shown here are possibly random and not representative !
26599/// let result = hub.objects().get("bucket", "object")
26600/// .user_project("dolor")
26601/// .soft_deleted(false)
26602/// .restore_token("At")
26603/// .projection("erat")
26604/// .if_metageneration_not_match(-71)
26605/// .if_metageneration_match(-5)
26606/// .if_generation_not_match(-73)
26607/// .if_generation_match(-19)
26608/// .generation(-96)
26609/// .doit().await;
26610/// # }
26611/// ```
26612pub struct ObjectGetCall<'a, C>
26613where
26614 C: 'a,
26615{
26616 hub: &'a Storage<C>,
26617 _bucket: String,
26618 _object: String,
26619 _user_project: Option<String>,
26620 _soft_deleted: Option<bool>,
26621 _restore_token: Option<String>,
26622 _projection: Option<String>,
26623 _if_metageneration_not_match: Option<i64>,
26624 _if_metageneration_match: Option<i64>,
26625 _if_generation_not_match: Option<i64>,
26626 _if_generation_match: Option<i64>,
26627 _generation: Option<i64>,
26628 _delegate: Option<&'a mut dyn common::Delegate>,
26629 _additional_params: HashMap<String, String>,
26630 _scopes: BTreeSet<String>,
26631}
26632
26633impl<'a, C> common::CallBuilder for ObjectGetCall<'a, C> {}
26634
26635impl<'a, C> ObjectGetCall<'a, C>
26636where
26637 C: common::Connector,
26638{
26639 /// Perform the operation you have build so far.
26640 pub async fn doit(mut self) -> common::Result<(common::Response, Object)> {
26641 use std::borrow::Cow;
26642 use std::io::{Read, Seek};
26643
26644 use common::{url::Params, ToParts};
26645 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26646
26647 let mut dd = common::DefaultDelegate;
26648 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26649 dlg.begin(common::MethodInfo {
26650 id: "storage.objects.get",
26651 http_method: hyper::Method::GET,
26652 });
26653
26654 for &field in [
26655 "bucket",
26656 "object",
26657 "userProject",
26658 "softDeleted",
26659 "restoreToken",
26660 "projection",
26661 "ifMetagenerationNotMatch",
26662 "ifMetagenerationMatch",
26663 "ifGenerationNotMatch",
26664 "ifGenerationMatch",
26665 "generation",
26666 ]
26667 .iter()
26668 {
26669 if self._additional_params.contains_key(field) {
26670 dlg.finished(false);
26671 return Err(common::Error::FieldClash(field));
26672 }
26673 }
26674
26675 let mut params = Params::with_capacity(12 + self._additional_params.len());
26676 params.push("bucket", self._bucket);
26677 params.push("object", self._object);
26678 if let Some(value) = self._user_project.as_ref() {
26679 params.push("userProject", value);
26680 }
26681 if let Some(value) = self._soft_deleted.as_ref() {
26682 params.push("softDeleted", value.to_string());
26683 }
26684 if let Some(value) = self._restore_token.as_ref() {
26685 params.push("restoreToken", value);
26686 }
26687 if let Some(value) = self._projection.as_ref() {
26688 params.push("projection", value);
26689 }
26690 if let Some(value) = self._if_metageneration_not_match.as_ref() {
26691 params.push("ifMetagenerationNotMatch", value.to_string());
26692 }
26693 if let Some(value) = self._if_metageneration_match.as_ref() {
26694 params.push("ifMetagenerationMatch", value.to_string());
26695 }
26696 if let Some(value) = self._if_generation_not_match.as_ref() {
26697 params.push("ifGenerationNotMatch", value.to_string());
26698 }
26699 if let Some(value) = self._if_generation_match.as_ref() {
26700 params.push("ifGenerationMatch", value.to_string());
26701 }
26702 if let Some(value) = self._generation.as_ref() {
26703 params.push("generation", value.to_string());
26704 }
26705
26706 params.extend(self._additional_params.iter());
26707
26708 let (alt_field_missing, enable_resource_parsing) = {
26709 if let Some(value) = params.get("alt") {
26710 (false, value == "json")
26711 } else {
26712 (true, true)
26713 }
26714 };
26715 if alt_field_missing {
26716 params.push("alt", "json");
26717 }
26718 let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}";
26719 if self._scopes.is_empty() {
26720 self._scopes
26721 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
26722 }
26723
26724 #[allow(clippy::single_element_loop)]
26725 for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object")].iter() {
26726 url = params.uri_replacement(url, param_name, find_this, false);
26727 }
26728 {
26729 let to_remove = ["object", "bucket"];
26730 params.remove_params(&to_remove);
26731 }
26732
26733 let url = params.parse_with_url(&url);
26734
26735 loop {
26736 let token = match self
26737 .hub
26738 .auth
26739 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26740 .await
26741 {
26742 Ok(token) => token,
26743 Err(e) => match dlg.token(e) {
26744 Ok(token) => token,
26745 Err(e) => {
26746 dlg.finished(false);
26747 return Err(common::Error::MissingToken(e));
26748 }
26749 },
26750 };
26751 let mut req_result = {
26752 let client = &self.hub.client;
26753 dlg.pre_request();
26754 let mut req_builder = hyper::Request::builder()
26755 .method(hyper::Method::GET)
26756 .uri(url.as_str())
26757 .header(USER_AGENT, self.hub._user_agent.clone());
26758
26759 if let Some(token) = token.as_ref() {
26760 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26761 }
26762
26763 let request = req_builder
26764 .header(CONTENT_LENGTH, 0_u64)
26765 .body(common::to_body::<String>(None));
26766
26767 client.request(request.unwrap()).await
26768 };
26769
26770 match req_result {
26771 Err(err) => {
26772 if let common::Retry::After(d) = dlg.http_error(&err) {
26773 sleep(d).await;
26774 continue;
26775 }
26776 dlg.finished(false);
26777 return Err(common::Error::HttpError(err));
26778 }
26779 Ok(res) => {
26780 let (mut parts, body) = res.into_parts();
26781 let mut body = common::Body::new(body);
26782 if !parts.status.is_success() {
26783 let bytes = common::to_bytes(body).await.unwrap_or_default();
26784 let error = serde_json::from_str(&common::to_string(&bytes));
26785 let response = common::to_response(parts, bytes.into());
26786
26787 if let common::Retry::After(d) =
26788 dlg.http_failure(&response, error.as_ref().ok())
26789 {
26790 sleep(d).await;
26791 continue;
26792 }
26793
26794 dlg.finished(false);
26795
26796 return Err(match error {
26797 Ok(value) => common::Error::BadRequest(value),
26798 _ => common::Error::Failure(response),
26799 });
26800 }
26801 let response = if enable_resource_parsing {
26802 let bytes = common::to_bytes(body).await.unwrap_or_default();
26803 let encoded = common::to_string(&bytes);
26804 match serde_json::from_str(&encoded) {
26805 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26806 Err(error) => {
26807 dlg.response_json_decode_error(&encoded, &error);
26808 return Err(common::Error::JsonDecodeError(
26809 encoded.to_string(),
26810 error,
26811 ));
26812 }
26813 }
26814 } else {
26815 (
26816 common::Response::from_parts(parts, body),
26817 Default::default(),
26818 )
26819 };
26820
26821 dlg.finished(true);
26822 return Ok(response);
26823 }
26824 }
26825 }
26826 }
26827
26828 /// Name of the bucket in which the object resides.
26829 ///
26830 /// Sets the *bucket* path property to the given value.
26831 ///
26832 /// Even though the property as already been set when instantiating this call,
26833 /// we provide this method for API completeness.
26834 pub fn bucket(mut self, new_value: &str) -> ObjectGetCall<'a, C> {
26835 self._bucket = new_value.to_string();
26836 self
26837 }
26838 /// 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).
26839 ///
26840 /// Sets the *object* path property to the given value.
26841 ///
26842 /// Even though the property as already been set when instantiating this call,
26843 /// we provide this method for API completeness.
26844 pub fn object(mut self, new_value: &str) -> ObjectGetCall<'a, C> {
26845 self._object = new_value.to_string();
26846 self
26847 }
26848 /// The project to be billed for this request. Required for Requester Pays buckets.
26849 ///
26850 /// Sets the *user project* query property to the given value.
26851 pub fn user_project(mut self, new_value: &str) -> ObjectGetCall<'a, C> {
26852 self._user_project = Some(new_value.to_string());
26853 self
26854 }
26855 /// If true, only soft-deleted object versions will be listed. The default is false. For more information, see [Soft Delete](https://cloud.google.com/storage/docs/soft-delete).
26856 ///
26857 /// Sets the *soft deleted* query property to the given value.
26858 pub fn soft_deleted(mut self, new_value: bool) -> ObjectGetCall<'a, C> {
26859 self._soft_deleted = Some(new_value);
26860 self
26861 }
26862 /// Restore token used to differentiate soft-deleted objects with the same name and generation. Only applicable for hierarchical namespace buckets and if softDeleted is set to true. This parameter is optional, and is only required in the rare case when there are multiple soft-deleted objects with the same name and generation.
26863 ///
26864 /// Sets the *restore token* query property to the given value.
26865 pub fn restore_token(mut self, new_value: &str) -> ObjectGetCall<'a, C> {
26866 self._restore_token = Some(new_value.to_string());
26867 self
26868 }
26869 /// Set of properties to return. Defaults to noAcl.
26870 ///
26871 /// Sets the *projection* query property to the given value.
26872 pub fn projection(mut self, new_value: &str) -> ObjectGetCall<'a, C> {
26873 self._projection = Some(new_value.to_string());
26874 self
26875 }
26876 /// Makes the operation conditional on whether the object's current metageneration does not match the given value.
26877 ///
26878 /// Sets the *if metageneration not match* query property to the given value.
26879 pub fn if_metageneration_not_match(mut self, new_value: i64) -> ObjectGetCall<'a, C> {
26880 self._if_metageneration_not_match = Some(new_value);
26881 self
26882 }
26883 /// Makes the operation conditional on whether the object's current metageneration matches the given value.
26884 ///
26885 /// Sets the *if metageneration match* query property to the given value.
26886 pub fn if_metageneration_match(mut self, new_value: i64) -> ObjectGetCall<'a, C> {
26887 self._if_metageneration_match = Some(new_value);
26888 self
26889 }
26890 /// 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.
26891 ///
26892 /// Sets the *if generation not match* query property to the given value.
26893 pub fn if_generation_not_match(mut self, new_value: i64) -> ObjectGetCall<'a, C> {
26894 self._if_generation_not_match = Some(new_value);
26895 self
26896 }
26897 /// 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.
26898 ///
26899 /// Sets the *if generation match* query property to the given value.
26900 pub fn if_generation_match(mut self, new_value: i64) -> ObjectGetCall<'a, C> {
26901 self._if_generation_match = Some(new_value);
26902 self
26903 }
26904 /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
26905 ///
26906 /// Sets the *generation* query property to the given value.
26907 pub fn generation(mut self, new_value: i64) -> ObjectGetCall<'a, C> {
26908 self._generation = Some(new_value);
26909 self
26910 }
26911 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26912 /// while executing the actual API request.
26913 ///
26914 /// ````text
26915 /// It should be used to handle progress information, and to implement a certain level of resilience.
26916 /// ````
26917 ///
26918 /// Sets the *delegate* property to the given value.
26919 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ObjectGetCall<'a, C> {
26920 self._delegate = Some(new_value);
26921 self
26922 }
26923
26924 /// Set any additional parameter of the query string used in the request.
26925 /// It should be used to set parameters which are not yet available through their own
26926 /// setters.
26927 ///
26928 /// Please note that this method must not be used to set any of the known parameters
26929 /// which have their own setter method. If done anyway, the request will fail.
26930 ///
26931 /// # Additional Parameters
26932 ///
26933 /// * *alt* (query-string) - Data format for the response.
26934 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26935 /// * *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.
26936 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26937 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26938 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
26939 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
26940 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
26941 pub fn param<T>(mut self, name: T, value: T) -> ObjectGetCall<'a, C>
26942 where
26943 T: AsRef<str>,
26944 {
26945 self._additional_params
26946 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26947 self
26948 }
26949
26950 /// Identifies the authorization scope for the method you are building.
26951 ///
26952 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26953 /// [`Scope::DevstorageReadOnly`].
26954 ///
26955 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26956 /// tokens for more than one scope.
26957 ///
26958 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26959 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26960 /// sufficient, a read-write scope will do as well.
26961 pub fn add_scope<St>(mut self, scope: St) -> ObjectGetCall<'a, C>
26962 where
26963 St: AsRef<str>,
26964 {
26965 self._scopes.insert(String::from(scope.as_ref()));
26966 self
26967 }
26968 /// Identifies the authorization scope(s) for the method you are building.
26969 ///
26970 /// See [`Self::add_scope()`] for details.
26971 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectGetCall<'a, C>
26972 where
26973 I: IntoIterator<Item = St>,
26974 St: AsRef<str>,
26975 {
26976 self._scopes
26977 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26978 self
26979 }
26980
26981 /// Removes all scopes, and no default scope will be used either.
26982 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26983 /// for details).
26984 pub fn clear_scopes(mut self) -> ObjectGetCall<'a, C> {
26985 self._scopes.clear();
26986 self
26987 }
26988}
26989
26990/// Returns an IAM policy for the specified object.
26991///
26992/// A builder for the *getIamPolicy* method supported by a *object* resource.
26993/// It is not used directly, but through a [`ObjectMethods`] instance.
26994///
26995/// # Example
26996///
26997/// Instantiate a resource method builder
26998///
26999/// ```test_harness,no_run
27000/// # extern crate hyper;
27001/// # extern crate hyper_rustls;
27002/// # extern crate google_storage1 as storage1;
27003/// # async fn dox() {
27004/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27005///
27006/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27007/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27008/// # .with_native_roots()
27009/// # .unwrap()
27010/// # .https_only()
27011/// # .enable_http2()
27012/// # .build();
27013///
27014/// # let executor = hyper_util::rt::TokioExecutor::new();
27015/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27016/// # secret,
27017/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27018/// # yup_oauth2::client::CustomHyperClientBuilder::from(
27019/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
27020/// # ),
27021/// # ).build().await.unwrap();
27022///
27023/// # let client = hyper_util::client::legacy::Client::builder(
27024/// # hyper_util::rt::TokioExecutor::new()
27025/// # )
27026/// # .build(
27027/// # hyper_rustls::HttpsConnectorBuilder::new()
27028/// # .with_native_roots()
27029/// # .unwrap()
27030/// # .https_or_http()
27031/// # .enable_http2()
27032/// # .build()
27033/// # );
27034/// # let mut hub = Storage::new(client, auth);
27035/// // You can configure optional parameters by calling the respective setters at will, and
27036/// // execute the final call using `doit()`.
27037/// // Values shown here are possibly random and not representative !
27038/// let result = hub.objects().get_iam_policy("bucket", "object")
27039/// .user_project("sadipscing")
27040/// .generation(-42)
27041/// .doit().await;
27042/// # }
27043/// ```
27044pub struct ObjectGetIamPolicyCall<'a, C>
27045where
27046 C: 'a,
27047{
27048 hub: &'a Storage<C>,
27049 _bucket: String,
27050 _object: String,
27051 _user_project: Option<String>,
27052 _generation: Option<i64>,
27053 _delegate: Option<&'a mut dyn common::Delegate>,
27054 _additional_params: HashMap<String, String>,
27055 _scopes: BTreeSet<String>,
27056}
27057
27058impl<'a, C> common::CallBuilder for ObjectGetIamPolicyCall<'a, C> {}
27059
27060impl<'a, C> ObjectGetIamPolicyCall<'a, C>
27061where
27062 C: common::Connector,
27063{
27064 /// Perform the operation you have build so far.
27065 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
27066 use std::borrow::Cow;
27067 use std::io::{Read, Seek};
27068
27069 use common::{url::Params, ToParts};
27070 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27071
27072 let mut dd = common::DefaultDelegate;
27073 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27074 dlg.begin(common::MethodInfo {
27075 id: "storage.objects.getIamPolicy",
27076 http_method: hyper::Method::GET,
27077 });
27078
27079 for &field in ["alt", "bucket", "object", "userProject", "generation"].iter() {
27080 if self._additional_params.contains_key(field) {
27081 dlg.finished(false);
27082 return Err(common::Error::FieldClash(field));
27083 }
27084 }
27085
27086 let mut params = Params::with_capacity(6 + self._additional_params.len());
27087 params.push("bucket", self._bucket);
27088 params.push("object", self._object);
27089 if let Some(value) = self._user_project.as_ref() {
27090 params.push("userProject", value);
27091 }
27092 if let Some(value) = self._generation.as_ref() {
27093 params.push("generation", value.to_string());
27094 }
27095
27096 params.extend(self._additional_params.iter());
27097
27098 params.push("alt", "json");
27099 let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}/iam";
27100 if self._scopes.is_empty() {
27101 self._scopes
27102 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
27103 }
27104
27105 #[allow(clippy::single_element_loop)]
27106 for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object")].iter() {
27107 url = params.uri_replacement(url, param_name, find_this, false);
27108 }
27109 {
27110 let to_remove = ["object", "bucket"];
27111 params.remove_params(&to_remove);
27112 }
27113
27114 let url = params.parse_with_url(&url);
27115
27116 loop {
27117 let token = match self
27118 .hub
27119 .auth
27120 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27121 .await
27122 {
27123 Ok(token) => token,
27124 Err(e) => match dlg.token(e) {
27125 Ok(token) => token,
27126 Err(e) => {
27127 dlg.finished(false);
27128 return Err(common::Error::MissingToken(e));
27129 }
27130 },
27131 };
27132 let mut req_result = {
27133 let client = &self.hub.client;
27134 dlg.pre_request();
27135 let mut req_builder = hyper::Request::builder()
27136 .method(hyper::Method::GET)
27137 .uri(url.as_str())
27138 .header(USER_AGENT, self.hub._user_agent.clone());
27139
27140 if let Some(token) = token.as_ref() {
27141 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27142 }
27143
27144 let request = req_builder
27145 .header(CONTENT_LENGTH, 0_u64)
27146 .body(common::to_body::<String>(None));
27147
27148 client.request(request.unwrap()).await
27149 };
27150
27151 match req_result {
27152 Err(err) => {
27153 if let common::Retry::After(d) = dlg.http_error(&err) {
27154 sleep(d).await;
27155 continue;
27156 }
27157 dlg.finished(false);
27158 return Err(common::Error::HttpError(err));
27159 }
27160 Ok(res) => {
27161 let (mut parts, body) = res.into_parts();
27162 let mut body = common::Body::new(body);
27163 if !parts.status.is_success() {
27164 let bytes = common::to_bytes(body).await.unwrap_or_default();
27165 let error = serde_json::from_str(&common::to_string(&bytes));
27166 let response = common::to_response(parts, bytes.into());
27167
27168 if let common::Retry::After(d) =
27169 dlg.http_failure(&response, error.as_ref().ok())
27170 {
27171 sleep(d).await;
27172 continue;
27173 }
27174
27175 dlg.finished(false);
27176
27177 return Err(match error {
27178 Ok(value) => common::Error::BadRequest(value),
27179 _ => common::Error::Failure(response),
27180 });
27181 }
27182 let response = {
27183 let bytes = common::to_bytes(body).await.unwrap_or_default();
27184 let encoded = common::to_string(&bytes);
27185 match serde_json::from_str(&encoded) {
27186 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27187 Err(error) => {
27188 dlg.response_json_decode_error(&encoded, &error);
27189 return Err(common::Error::JsonDecodeError(
27190 encoded.to_string(),
27191 error,
27192 ));
27193 }
27194 }
27195 };
27196
27197 dlg.finished(true);
27198 return Ok(response);
27199 }
27200 }
27201 }
27202 }
27203
27204 /// Name of the bucket in which the object resides.
27205 ///
27206 /// Sets the *bucket* path property to the given value.
27207 ///
27208 /// Even though the property as already been set when instantiating this call,
27209 /// we provide this method for API completeness.
27210 pub fn bucket(mut self, new_value: &str) -> ObjectGetIamPolicyCall<'a, C> {
27211 self._bucket = new_value.to_string();
27212 self
27213 }
27214 /// 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).
27215 ///
27216 /// Sets the *object* path property to the given value.
27217 ///
27218 /// Even though the property as already been set when instantiating this call,
27219 /// we provide this method for API completeness.
27220 pub fn object(mut self, new_value: &str) -> ObjectGetIamPolicyCall<'a, C> {
27221 self._object = new_value.to_string();
27222 self
27223 }
27224 /// The project to be billed for this request. Required for Requester Pays buckets.
27225 ///
27226 /// Sets the *user project* query property to the given value.
27227 pub fn user_project(mut self, new_value: &str) -> ObjectGetIamPolicyCall<'a, C> {
27228 self._user_project = Some(new_value.to_string());
27229 self
27230 }
27231 /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
27232 ///
27233 /// Sets the *generation* query property to the given value.
27234 pub fn generation(mut self, new_value: i64) -> ObjectGetIamPolicyCall<'a, C> {
27235 self._generation = Some(new_value);
27236 self
27237 }
27238 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27239 /// while executing the actual API request.
27240 ///
27241 /// ````text
27242 /// It should be used to handle progress information, and to implement a certain level of resilience.
27243 /// ````
27244 ///
27245 /// Sets the *delegate* property to the given value.
27246 pub fn delegate(
27247 mut self,
27248 new_value: &'a mut dyn common::Delegate,
27249 ) -> ObjectGetIamPolicyCall<'a, C> {
27250 self._delegate = Some(new_value);
27251 self
27252 }
27253
27254 /// Set any additional parameter of the query string used in the request.
27255 /// It should be used to set parameters which are not yet available through their own
27256 /// setters.
27257 ///
27258 /// Please note that this method must not be used to set any of the known parameters
27259 /// which have their own setter method. If done anyway, the request will fail.
27260 ///
27261 /// # Additional Parameters
27262 ///
27263 /// * *alt* (query-string) - Data format for the response.
27264 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27265 /// * *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.
27266 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27267 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27268 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
27269 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
27270 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
27271 pub fn param<T>(mut self, name: T, value: T) -> ObjectGetIamPolicyCall<'a, C>
27272 where
27273 T: AsRef<str>,
27274 {
27275 self._additional_params
27276 .insert(name.as_ref().to_string(), value.as_ref().to_string());
27277 self
27278 }
27279
27280 /// Identifies the authorization scope for the method you are building.
27281 ///
27282 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27283 /// [`Scope::DevstorageReadOnly`].
27284 ///
27285 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27286 /// tokens for more than one scope.
27287 ///
27288 /// Usually there is more than one suitable scope to authorize an operation, some of which may
27289 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27290 /// sufficient, a read-write scope will do as well.
27291 pub fn add_scope<St>(mut self, scope: St) -> ObjectGetIamPolicyCall<'a, C>
27292 where
27293 St: AsRef<str>,
27294 {
27295 self._scopes.insert(String::from(scope.as_ref()));
27296 self
27297 }
27298 /// Identifies the authorization scope(s) for the method you are building.
27299 ///
27300 /// See [`Self::add_scope()`] for details.
27301 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectGetIamPolicyCall<'a, C>
27302 where
27303 I: IntoIterator<Item = St>,
27304 St: AsRef<str>,
27305 {
27306 self._scopes
27307 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27308 self
27309 }
27310
27311 /// Removes all scopes, and no default scope will be used either.
27312 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27313 /// for details).
27314 pub fn clear_scopes(mut self) -> ObjectGetIamPolicyCall<'a, C> {
27315 self._scopes.clear();
27316 self
27317 }
27318}
27319
27320/// Stores a new object and metadata.
27321///
27322/// A builder for the *insert* method supported by a *object* resource.
27323/// It is not used directly, but through a [`ObjectMethods`] instance.
27324///
27325/// # Example
27326///
27327/// Instantiate a resource method builder
27328///
27329/// ```test_harness,no_run
27330/// # extern crate hyper;
27331/// # extern crate hyper_rustls;
27332/// # extern crate google_storage1 as storage1;
27333/// use storage1::api::Object;
27334/// use std::fs;
27335/// # async fn dox() {
27336/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27337///
27338/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27339/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27340/// # .with_native_roots()
27341/// # .unwrap()
27342/// # .https_only()
27343/// # .enable_http2()
27344/// # .build();
27345///
27346/// # let executor = hyper_util::rt::TokioExecutor::new();
27347/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27348/// # secret,
27349/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27350/// # yup_oauth2::client::CustomHyperClientBuilder::from(
27351/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
27352/// # ),
27353/// # ).build().await.unwrap();
27354///
27355/// # let client = hyper_util::client::legacy::Client::builder(
27356/// # hyper_util::rt::TokioExecutor::new()
27357/// # )
27358/// # .build(
27359/// # hyper_rustls::HttpsConnectorBuilder::new()
27360/// # .with_native_roots()
27361/// # .unwrap()
27362/// # .https_or_http()
27363/// # .enable_http2()
27364/// # .build()
27365/// # );
27366/// # let mut hub = Storage::new(client, auth);
27367/// // As the method needs a request, you would usually fill it with the desired information
27368/// // into the respective structure. Some of the parts shown here might not be applicable !
27369/// // Values shown here are possibly random and not representative !
27370/// let mut req = Object::default();
27371///
27372/// // You can configure optional parameters by calling the respective setters at will, and
27373/// // execute the final call using `upload_resumable(...)`.
27374/// // Values shown here are possibly random and not representative !
27375/// let result = hub.objects().insert(req, "bucket")
27376/// .user_project("ipsum")
27377/// .projection("Stet")
27378/// .predefined_acl("gubergren")
27379/// .name("ipsum")
27380/// .kms_key_name("no")
27381/// .if_metageneration_not_match(-98)
27382/// .if_metageneration_match(-13)
27383/// .if_generation_not_match(-47)
27384/// .if_generation_match(-56)
27385/// .content_encoding("justo")
27386/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
27387/// # }
27388/// ```
27389pub struct ObjectInsertCall<'a, C>
27390where
27391 C: 'a,
27392{
27393 hub: &'a Storage<C>,
27394 _request: Object,
27395 _bucket: String,
27396 _user_project: Option<String>,
27397 _projection: Option<String>,
27398 _predefined_acl: Option<String>,
27399 _name: Option<String>,
27400 _kms_key_name: Option<String>,
27401 _if_metageneration_not_match: Option<i64>,
27402 _if_metageneration_match: Option<i64>,
27403 _if_generation_not_match: Option<i64>,
27404 _if_generation_match: Option<i64>,
27405 _content_encoding: Option<String>,
27406 _delegate: Option<&'a mut dyn common::Delegate>,
27407 _additional_params: HashMap<String, String>,
27408 _scopes: BTreeSet<String>,
27409}
27410
27411impl<'a, C> common::CallBuilder for ObjectInsertCall<'a, C> {}
27412
27413impl<'a, C> ObjectInsertCall<'a, C>
27414where
27415 C: common::Connector,
27416{
27417 /// Perform the operation you have build so far.
27418 async fn doit<RS>(
27419 mut self,
27420 mut reader: RS,
27421 reader_mime_type: mime::Mime,
27422 protocol: common::UploadProtocol,
27423 ) -> common::Result<(common::Response, Object)>
27424 where
27425 RS: common::ReadSeek,
27426 {
27427 use std::borrow::Cow;
27428 use std::io::{Read, Seek};
27429
27430 use common::{url::Params, ToParts};
27431 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27432
27433 let mut dd = common::DefaultDelegate;
27434 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27435 dlg.begin(common::MethodInfo {
27436 id: "storage.objects.insert",
27437 http_method: hyper::Method::POST,
27438 });
27439
27440 for &field in [
27441 "alt",
27442 "bucket",
27443 "userProject",
27444 "projection",
27445 "predefinedAcl",
27446 "name",
27447 "kmsKeyName",
27448 "ifMetagenerationNotMatch",
27449 "ifMetagenerationMatch",
27450 "ifGenerationNotMatch",
27451 "ifGenerationMatch",
27452 "contentEncoding",
27453 ]
27454 .iter()
27455 {
27456 if self._additional_params.contains_key(field) {
27457 dlg.finished(false);
27458 return Err(common::Error::FieldClash(field));
27459 }
27460 }
27461
27462 let mut params = Params::with_capacity(14 + self._additional_params.len());
27463 params.push("bucket", self._bucket);
27464 if let Some(value) = self._user_project.as_ref() {
27465 params.push("userProject", value);
27466 }
27467 if let Some(value) = self._projection.as_ref() {
27468 params.push("projection", value);
27469 }
27470 if let Some(value) = self._predefined_acl.as_ref() {
27471 params.push("predefinedAcl", value);
27472 }
27473 if let Some(value) = self._name.as_ref() {
27474 params.push("name", value);
27475 }
27476 if let Some(value) = self._kms_key_name.as_ref() {
27477 params.push("kmsKeyName", value);
27478 }
27479 if let Some(value) = self._if_metageneration_not_match.as_ref() {
27480 params.push("ifMetagenerationNotMatch", value.to_string());
27481 }
27482 if let Some(value) = self._if_metageneration_match.as_ref() {
27483 params.push("ifMetagenerationMatch", value.to_string());
27484 }
27485 if let Some(value) = self._if_generation_not_match.as_ref() {
27486 params.push("ifGenerationNotMatch", value.to_string());
27487 }
27488 if let Some(value) = self._if_generation_match.as_ref() {
27489 params.push("ifGenerationMatch", value.to_string());
27490 }
27491 if let Some(value) = self._content_encoding.as_ref() {
27492 params.push("contentEncoding", value);
27493 }
27494
27495 params.extend(self._additional_params.iter());
27496
27497 params.push("alt", "json");
27498 let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
27499 (
27500 self.hub._root_url.clone() + "resumable/upload/storage/v1/b/{bucket}/o",
27501 "resumable",
27502 )
27503 } else if protocol == common::UploadProtocol::Simple {
27504 (
27505 self.hub._root_url.clone() + "upload/storage/v1/b/{bucket}/o",
27506 "multipart",
27507 )
27508 } else {
27509 unreachable!()
27510 };
27511 params.push("uploadType", upload_type);
27512 if self._scopes.is_empty() {
27513 self._scopes
27514 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
27515 }
27516
27517 #[allow(clippy::single_element_loop)]
27518 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
27519 url = params.uri_replacement(url, param_name, find_this, false);
27520 }
27521 {
27522 let to_remove = ["bucket"];
27523 params.remove_params(&to_remove);
27524 }
27525
27526 let url = params.parse_with_url(&url);
27527
27528 let mut json_mime_type = mime::APPLICATION_JSON;
27529 let mut request_value_reader = {
27530 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
27531 common::remove_json_null_values(&mut value);
27532 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
27533 serde_json::to_writer(&mut dst, &value).unwrap();
27534 dst
27535 };
27536 let request_size = request_value_reader
27537 .seek(std::io::SeekFrom::End(0))
27538 .unwrap();
27539 request_value_reader
27540 .seek(std::io::SeekFrom::Start(0))
27541 .unwrap();
27542
27543 let mut upload_url_from_server;
27544
27545 loop {
27546 let token = match self
27547 .hub
27548 .auth
27549 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27550 .await
27551 {
27552 Ok(token) => token,
27553 Err(e) => match dlg.token(e) {
27554 Ok(token) => token,
27555 Err(e) => {
27556 dlg.finished(false);
27557 return Err(common::Error::MissingToken(e));
27558 }
27559 },
27560 };
27561 request_value_reader
27562 .seek(std::io::SeekFrom::Start(0))
27563 .unwrap();
27564 let mut req_result = {
27565 let mut mp_reader: common::MultiPartReader = Default::default();
27566 let (mut body_reader, content_type) = match protocol {
27567 common::UploadProtocol::Simple => {
27568 mp_reader.reserve_exact(2);
27569 let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
27570 reader.seek(std::io::SeekFrom::Start(0)).unwrap();
27571
27572 mp_reader
27573 .add_part(
27574 &mut request_value_reader,
27575 request_size,
27576 json_mime_type.clone(),
27577 )
27578 .add_part(&mut reader, size, reader_mime_type.clone());
27579 (
27580 &mut mp_reader as &mut (dyn std::io::Read + Send),
27581 common::MultiPartReader::mime_type(),
27582 )
27583 }
27584 _ => (
27585 &mut request_value_reader as &mut (dyn std::io::Read + Send),
27586 json_mime_type.clone(),
27587 ),
27588 };
27589 let client = &self.hub.client;
27590 dlg.pre_request();
27591 let mut req_builder = hyper::Request::builder()
27592 .method(hyper::Method::POST)
27593 .uri(url.as_str())
27594 .header(USER_AGENT, self.hub._user_agent.clone());
27595
27596 if let Some(token) = token.as_ref() {
27597 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27598 }
27599
27600 upload_url_from_server = true;
27601 if protocol == common::UploadProtocol::Resumable {
27602 req_builder = req_builder
27603 .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
27604 }
27605
27606 let mut body_reader_bytes = vec![];
27607 body_reader.read_to_end(&mut body_reader_bytes).unwrap();
27608 let request = req_builder
27609 .header(CONTENT_TYPE, content_type.to_string())
27610 .body(common::to_body(body_reader_bytes.into()));
27611
27612 client.request(request.unwrap()).await
27613 };
27614
27615 match req_result {
27616 Err(err) => {
27617 if let common::Retry::After(d) = dlg.http_error(&err) {
27618 sleep(d).await;
27619 continue;
27620 }
27621 dlg.finished(false);
27622 return Err(common::Error::HttpError(err));
27623 }
27624 Ok(res) => {
27625 let (mut parts, body) = res.into_parts();
27626 let mut body = common::Body::new(body);
27627 if !parts.status.is_success() {
27628 let bytes = common::to_bytes(body).await.unwrap_or_default();
27629 let error = serde_json::from_str(&common::to_string(&bytes));
27630 let response = common::to_response(parts, bytes.into());
27631
27632 if let common::Retry::After(d) =
27633 dlg.http_failure(&response, error.as_ref().ok())
27634 {
27635 sleep(d).await;
27636 continue;
27637 }
27638
27639 dlg.finished(false);
27640
27641 return Err(match error {
27642 Ok(value) => common::Error::BadRequest(value),
27643 _ => common::Error::Failure(response),
27644 });
27645 }
27646 if protocol == common::UploadProtocol::Resumable {
27647 let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
27648 reader.seek(std::io::SeekFrom::Start(0)).unwrap();
27649
27650 let upload_result = {
27651 let url_str = &parts
27652 .headers
27653 .get("Location")
27654 .expect("LOCATION header is part of protocol")
27655 .to_str()
27656 .unwrap();
27657 if upload_url_from_server {
27658 dlg.store_upload_url(Some(url_str));
27659 }
27660
27661 common::ResumableUploadHelper {
27662 client: &self.hub.client,
27663 delegate: dlg,
27664 start_at: if upload_url_from_server {
27665 Some(0)
27666 } else {
27667 None
27668 },
27669 auth: &self.hub.auth,
27670 user_agent: &self.hub._user_agent,
27671 // TODO: Check this assumption
27672 auth_header: format!(
27673 "Bearer {}",
27674 token
27675 .ok_or_else(|| common::Error::MissingToken(
27676 "resumable upload requires token".into()
27677 ))?
27678 .as_str()
27679 ),
27680 url: url_str,
27681 reader: &mut reader,
27682 media_type: reader_mime_type.clone(),
27683 content_length: size,
27684 }
27685 .upload()
27686 .await
27687 };
27688 match upload_result {
27689 None => {
27690 dlg.finished(false);
27691 return Err(common::Error::Cancelled);
27692 }
27693 Some(Err(err)) => {
27694 dlg.finished(false);
27695 return Err(common::Error::HttpError(err));
27696 }
27697 Some(Ok(response)) => {
27698 (parts, body) = response.into_parts();
27699 if !parts.status.is_success() {
27700 dlg.store_upload_url(None);
27701 dlg.finished(false);
27702 return Err(common::Error::Failure(
27703 common::Response::from_parts(parts, body),
27704 ));
27705 }
27706 }
27707 }
27708 }
27709 let response = {
27710 let bytes = common::to_bytes(body).await.unwrap_or_default();
27711 let encoded = common::to_string(&bytes);
27712 match serde_json::from_str(&encoded) {
27713 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27714 Err(error) => {
27715 dlg.response_json_decode_error(&encoded, &error);
27716 return Err(common::Error::JsonDecodeError(
27717 encoded.to_string(),
27718 error,
27719 ));
27720 }
27721 }
27722 };
27723
27724 dlg.finished(true);
27725 return Ok(response);
27726 }
27727 }
27728 }
27729 }
27730
27731 /// Upload media in a resumable fashion.
27732 /// Even if the upload fails or is interrupted, it can be resumed for a
27733 /// certain amount of time as the server maintains state temporarily.
27734 ///
27735 /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
27736 /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
27737 /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
27738 /// `cancel_chunk_upload(...)`.
27739 ///
27740 /// * *multipart*: yes
27741 /// * *max size*: 0kb
27742 /// * *valid mime types*: '*/*'
27743 pub async fn upload_resumable<RS>(
27744 self,
27745 resumeable_stream: RS,
27746 mime_type: mime::Mime,
27747 ) -> common::Result<(common::Response, Object)>
27748 where
27749 RS: common::ReadSeek,
27750 {
27751 self.doit(
27752 resumeable_stream,
27753 mime_type,
27754 common::UploadProtocol::Resumable,
27755 )
27756 .await
27757 }
27758 /// Upload media all at once.
27759 /// If the upload fails for whichever reason, all progress is lost.
27760 ///
27761 /// * *multipart*: yes
27762 /// * *max size*: 0kb
27763 /// * *valid mime types*: '*/*'
27764 pub async fn upload<RS>(
27765 self,
27766 stream: RS,
27767 mime_type: mime::Mime,
27768 ) -> common::Result<(common::Response, Object)>
27769 where
27770 RS: common::ReadSeek,
27771 {
27772 self.doit(stream, mime_type, common::UploadProtocol::Simple)
27773 .await
27774 }
27775
27776 ///
27777 /// Sets the *request* property to the given value.
27778 ///
27779 /// Even though the property as already been set when instantiating this call,
27780 /// we provide this method for API completeness.
27781 pub fn request(mut self, new_value: Object) -> ObjectInsertCall<'a, C> {
27782 self._request = new_value;
27783 self
27784 }
27785 /// Name of the bucket in which to store the new object. Overrides the provided object metadata's bucket value, if any.
27786 ///
27787 /// Sets the *bucket* path property to the given value.
27788 ///
27789 /// Even though the property as already been set when instantiating this call,
27790 /// we provide this method for API completeness.
27791 pub fn bucket(mut self, new_value: &str) -> ObjectInsertCall<'a, C> {
27792 self._bucket = new_value.to_string();
27793 self
27794 }
27795 /// The project to be billed for this request. Required for Requester Pays buckets.
27796 ///
27797 /// Sets the *user project* query property to the given value.
27798 pub fn user_project(mut self, new_value: &str) -> ObjectInsertCall<'a, C> {
27799 self._user_project = Some(new_value.to_string());
27800 self
27801 }
27802 /// Set of properties to return. Defaults to noAcl, unless the object resource specifies the acl property, when it defaults to full.
27803 ///
27804 /// Sets the *projection* query property to the given value.
27805 pub fn projection(mut self, new_value: &str) -> ObjectInsertCall<'a, C> {
27806 self._projection = Some(new_value.to_string());
27807 self
27808 }
27809 /// Apply a predefined set of access controls to this object.
27810 ///
27811 /// Sets the *predefined acl* query property to the given value.
27812 pub fn predefined_acl(mut self, new_value: &str) -> ObjectInsertCall<'a, C> {
27813 self._predefined_acl = Some(new_value.to_string());
27814 self
27815 }
27816 /// 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).
27817 ///
27818 /// Sets the *name* query property to the given value.
27819 pub fn name(mut self, new_value: &str) -> ObjectInsertCall<'a, C> {
27820 self._name = Some(new_value.to_string());
27821 self
27822 }
27823 /// 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.
27824 ///
27825 /// Sets the *kms key name* query property to the given value.
27826 pub fn kms_key_name(mut self, new_value: &str) -> ObjectInsertCall<'a, C> {
27827 self._kms_key_name = Some(new_value.to_string());
27828 self
27829 }
27830 /// Makes the operation conditional on whether the object's current metageneration does not match the given value.
27831 ///
27832 /// Sets the *if metageneration not match* query property to the given value.
27833 pub fn if_metageneration_not_match(mut self, new_value: i64) -> ObjectInsertCall<'a, C> {
27834 self._if_metageneration_not_match = Some(new_value);
27835 self
27836 }
27837 /// Makes the operation conditional on whether the object's current metageneration matches the given value.
27838 ///
27839 /// Sets the *if metageneration match* query property to the given value.
27840 pub fn if_metageneration_match(mut self, new_value: i64) -> ObjectInsertCall<'a, C> {
27841 self._if_metageneration_match = Some(new_value);
27842 self
27843 }
27844 /// 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.
27845 ///
27846 /// Sets the *if generation not match* query property to the given value.
27847 pub fn if_generation_not_match(mut self, new_value: i64) -> ObjectInsertCall<'a, C> {
27848 self._if_generation_not_match = Some(new_value);
27849 self
27850 }
27851 /// 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.
27852 ///
27853 /// Sets the *if generation match* query property to the given value.
27854 pub fn if_generation_match(mut self, new_value: i64) -> ObjectInsertCall<'a, C> {
27855 self._if_generation_match = Some(new_value);
27856 self
27857 }
27858 /// 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.
27859 ///
27860 /// Sets the *content encoding* query property to the given value.
27861 pub fn content_encoding(mut self, new_value: &str) -> ObjectInsertCall<'a, C> {
27862 self._content_encoding = Some(new_value.to_string());
27863 self
27864 }
27865 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27866 /// while executing the actual API request.
27867 ///
27868 /// ````text
27869 /// It should be used to handle progress information, and to implement a certain level of resilience.
27870 /// ````
27871 ///
27872 /// Sets the *delegate* property to the given value.
27873 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ObjectInsertCall<'a, C> {
27874 self._delegate = Some(new_value);
27875 self
27876 }
27877
27878 /// Set any additional parameter of the query string used in the request.
27879 /// It should be used to set parameters which are not yet available through their own
27880 /// setters.
27881 ///
27882 /// Please note that this method must not be used to set any of the known parameters
27883 /// which have their own setter method. If done anyway, the request will fail.
27884 ///
27885 /// # Additional Parameters
27886 ///
27887 /// * *alt* (query-string) - Data format for the response.
27888 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27889 /// * *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.
27890 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27891 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27892 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
27893 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
27894 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
27895 pub fn param<T>(mut self, name: T, value: T) -> ObjectInsertCall<'a, C>
27896 where
27897 T: AsRef<str>,
27898 {
27899 self._additional_params
27900 .insert(name.as_ref().to_string(), value.as_ref().to_string());
27901 self
27902 }
27903
27904 /// Identifies the authorization scope for the method you are building.
27905 ///
27906 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27907 /// [`Scope::DevstorageReadWrite`].
27908 ///
27909 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27910 /// tokens for more than one scope.
27911 ///
27912 /// Usually there is more than one suitable scope to authorize an operation, some of which may
27913 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27914 /// sufficient, a read-write scope will do as well.
27915 pub fn add_scope<St>(mut self, scope: St) -> ObjectInsertCall<'a, C>
27916 where
27917 St: AsRef<str>,
27918 {
27919 self._scopes.insert(String::from(scope.as_ref()));
27920 self
27921 }
27922 /// Identifies the authorization scope(s) for the method you are building.
27923 ///
27924 /// See [`Self::add_scope()`] for details.
27925 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectInsertCall<'a, C>
27926 where
27927 I: IntoIterator<Item = St>,
27928 St: AsRef<str>,
27929 {
27930 self._scopes
27931 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27932 self
27933 }
27934
27935 /// Removes all scopes, and no default scope will be used either.
27936 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27937 /// for details).
27938 pub fn clear_scopes(mut self) -> ObjectInsertCall<'a, C> {
27939 self._scopes.clear();
27940 self
27941 }
27942}
27943
27944/// Retrieves a list of objects matching the criteria.
27945///
27946/// A builder for the *list* method supported by a *object* resource.
27947/// It is not used directly, but through a [`ObjectMethods`] instance.
27948///
27949/// # Example
27950///
27951/// Instantiate a resource method builder
27952///
27953/// ```test_harness,no_run
27954/// # extern crate hyper;
27955/// # extern crate hyper_rustls;
27956/// # extern crate google_storage1 as storage1;
27957/// # async fn dox() {
27958/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27959///
27960/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27961/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27962/// # .with_native_roots()
27963/// # .unwrap()
27964/// # .https_only()
27965/// # .enable_http2()
27966/// # .build();
27967///
27968/// # let executor = hyper_util::rt::TokioExecutor::new();
27969/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27970/// # secret,
27971/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27972/// # yup_oauth2::client::CustomHyperClientBuilder::from(
27973/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
27974/// # ),
27975/// # ).build().await.unwrap();
27976///
27977/// # let client = hyper_util::client::legacy::Client::builder(
27978/// # hyper_util::rt::TokioExecutor::new()
27979/// # )
27980/// # .build(
27981/// # hyper_rustls::HttpsConnectorBuilder::new()
27982/// # .with_native_roots()
27983/// # .unwrap()
27984/// # .https_or_http()
27985/// # .enable_http2()
27986/// # .build()
27987/// # );
27988/// # let mut hub = Storage::new(client, auth);
27989/// // You can configure optional parameters by calling the respective setters at will, and
27990/// // execute the final call using `doit()`.
27991/// // Values shown here are possibly random and not representative !
27992/// let result = hub.objects().list("bucket")
27993/// .versions(false)
27994/// .user_project("nonumy")
27995/// .start_offset("sea")
27996/// .soft_deleted(false)
27997/// .projection("kasd")
27998/// .prefix("justo")
27999/// .page_token("ea")
28000/// .max_results(24)
28001/// .match_glob("erat")
28002/// .include_trailing_delimiter(false)
28003/// .include_folders_as_prefixes(false)
28004/// .filter("nonumy")
28005/// .end_offset("erat")
28006/// .delimiter("erat")
28007/// .doit().await;
28008/// # }
28009/// ```
28010pub struct ObjectListCall<'a, C>
28011where
28012 C: 'a,
28013{
28014 hub: &'a Storage<C>,
28015 _bucket: String,
28016 _versions: Option<bool>,
28017 _user_project: Option<String>,
28018 _start_offset: Option<String>,
28019 _soft_deleted: Option<bool>,
28020 _projection: Option<String>,
28021 _prefix: Option<String>,
28022 _page_token: Option<String>,
28023 _max_results: Option<u32>,
28024 _match_glob: Option<String>,
28025 _include_trailing_delimiter: Option<bool>,
28026 _include_folders_as_prefixes: Option<bool>,
28027 _filter: Option<String>,
28028 _end_offset: Option<String>,
28029 _delimiter: Option<String>,
28030 _delegate: Option<&'a mut dyn common::Delegate>,
28031 _additional_params: HashMap<String, String>,
28032 _scopes: BTreeSet<String>,
28033}
28034
28035impl<'a, C> common::CallBuilder for ObjectListCall<'a, C> {}
28036
28037impl<'a, C> ObjectListCall<'a, C>
28038where
28039 C: common::Connector,
28040{
28041 /// Perform the operation you have build so far.
28042 pub async fn doit(mut self) -> common::Result<(common::Response, Objects)> {
28043 use std::borrow::Cow;
28044 use std::io::{Read, Seek};
28045
28046 use common::{url::Params, ToParts};
28047 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28048
28049 let mut dd = common::DefaultDelegate;
28050 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28051 dlg.begin(common::MethodInfo {
28052 id: "storage.objects.list",
28053 http_method: hyper::Method::GET,
28054 });
28055
28056 for &field in [
28057 "alt",
28058 "bucket",
28059 "versions",
28060 "userProject",
28061 "startOffset",
28062 "softDeleted",
28063 "projection",
28064 "prefix",
28065 "pageToken",
28066 "maxResults",
28067 "matchGlob",
28068 "includeTrailingDelimiter",
28069 "includeFoldersAsPrefixes",
28070 "filter",
28071 "endOffset",
28072 "delimiter",
28073 ]
28074 .iter()
28075 {
28076 if self._additional_params.contains_key(field) {
28077 dlg.finished(false);
28078 return Err(common::Error::FieldClash(field));
28079 }
28080 }
28081
28082 let mut params = Params::with_capacity(17 + self._additional_params.len());
28083 params.push("bucket", self._bucket);
28084 if let Some(value) = self._versions.as_ref() {
28085 params.push("versions", value.to_string());
28086 }
28087 if let Some(value) = self._user_project.as_ref() {
28088 params.push("userProject", value);
28089 }
28090 if let Some(value) = self._start_offset.as_ref() {
28091 params.push("startOffset", value);
28092 }
28093 if let Some(value) = self._soft_deleted.as_ref() {
28094 params.push("softDeleted", value.to_string());
28095 }
28096 if let Some(value) = self._projection.as_ref() {
28097 params.push("projection", value);
28098 }
28099 if let Some(value) = self._prefix.as_ref() {
28100 params.push("prefix", value);
28101 }
28102 if let Some(value) = self._page_token.as_ref() {
28103 params.push("pageToken", value);
28104 }
28105 if let Some(value) = self._max_results.as_ref() {
28106 params.push("maxResults", value.to_string());
28107 }
28108 if let Some(value) = self._match_glob.as_ref() {
28109 params.push("matchGlob", value);
28110 }
28111 if let Some(value) = self._include_trailing_delimiter.as_ref() {
28112 params.push("includeTrailingDelimiter", value.to_string());
28113 }
28114 if let Some(value) = self._include_folders_as_prefixes.as_ref() {
28115 params.push("includeFoldersAsPrefixes", value.to_string());
28116 }
28117 if let Some(value) = self._filter.as_ref() {
28118 params.push("filter", value);
28119 }
28120 if let Some(value) = self._end_offset.as_ref() {
28121 params.push("endOffset", value);
28122 }
28123 if let Some(value) = self._delimiter.as_ref() {
28124 params.push("delimiter", value);
28125 }
28126
28127 params.extend(self._additional_params.iter());
28128
28129 params.push("alt", "json");
28130 let mut url = self.hub._base_url.clone() + "b/{bucket}/o";
28131 if self._scopes.is_empty() {
28132 self._scopes
28133 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
28134 }
28135
28136 #[allow(clippy::single_element_loop)]
28137 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
28138 url = params.uri_replacement(url, param_name, find_this, false);
28139 }
28140 {
28141 let to_remove = ["bucket"];
28142 params.remove_params(&to_remove);
28143 }
28144
28145 let url = params.parse_with_url(&url);
28146
28147 loop {
28148 let token = match self
28149 .hub
28150 .auth
28151 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28152 .await
28153 {
28154 Ok(token) => token,
28155 Err(e) => match dlg.token(e) {
28156 Ok(token) => token,
28157 Err(e) => {
28158 dlg.finished(false);
28159 return Err(common::Error::MissingToken(e));
28160 }
28161 },
28162 };
28163 let mut req_result = {
28164 let client = &self.hub.client;
28165 dlg.pre_request();
28166 let mut req_builder = hyper::Request::builder()
28167 .method(hyper::Method::GET)
28168 .uri(url.as_str())
28169 .header(USER_AGENT, self.hub._user_agent.clone());
28170
28171 if let Some(token) = token.as_ref() {
28172 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28173 }
28174
28175 let request = req_builder
28176 .header(CONTENT_LENGTH, 0_u64)
28177 .body(common::to_body::<String>(None));
28178
28179 client.request(request.unwrap()).await
28180 };
28181
28182 match req_result {
28183 Err(err) => {
28184 if let common::Retry::After(d) = dlg.http_error(&err) {
28185 sleep(d).await;
28186 continue;
28187 }
28188 dlg.finished(false);
28189 return Err(common::Error::HttpError(err));
28190 }
28191 Ok(res) => {
28192 let (mut parts, body) = res.into_parts();
28193 let mut body = common::Body::new(body);
28194 if !parts.status.is_success() {
28195 let bytes = common::to_bytes(body).await.unwrap_or_default();
28196 let error = serde_json::from_str(&common::to_string(&bytes));
28197 let response = common::to_response(parts, bytes.into());
28198
28199 if let common::Retry::After(d) =
28200 dlg.http_failure(&response, error.as_ref().ok())
28201 {
28202 sleep(d).await;
28203 continue;
28204 }
28205
28206 dlg.finished(false);
28207
28208 return Err(match error {
28209 Ok(value) => common::Error::BadRequest(value),
28210 _ => common::Error::Failure(response),
28211 });
28212 }
28213 let response = {
28214 let bytes = common::to_bytes(body).await.unwrap_or_default();
28215 let encoded = common::to_string(&bytes);
28216 match serde_json::from_str(&encoded) {
28217 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28218 Err(error) => {
28219 dlg.response_json_decode_error(&encoded, &error);
28220 return Err(common::Error::JsonDecodeError(
28221 encoded.to_string(),
28222 error,
28223 ));
28224 }
28225 }
28226 };
28227
28228 dlg.finished(true);
28229 return Ok(response);
28230 }
28231 }
28232 }
28233 }
28234
28235 /// Name of the bucket in which to look for objects.
28236 ///
28237 /// Sets the *bucket* path property to the given value.
28238 ///
28239 /// Even though the property as already been set when instantiating this call,
28240 /// we provide this method for API completeness.
28241 pub fn bucket(mut self, new_value: &str) -> ObjectListCall<'a, C> {
28242 self._bucket = new_value.to_string();
28243 self
28244 }
28245 /// If true, lists all versions of an object as distinct results. The default is false. For more information, see [Object Versioning](https://cloud.google.com/storage/docs/object-versioning).
28246 ///
28247 /// Sets the *versions* query property to the given value.
28248 pub fn versions(mut self, new_value: bool) -> ObjectListCall<'a, C> {
28249 self._versions = Some(new_value);
28250 self
28251 }
28252 /// The project to be billed for this request. Required for Requester Pays buckets.
28253 ///
28254 /// Sets the *user project* query property to the given value.
28255 pub fn user_project(mut self, new_value: &str) -> ObjectListCall<'a, C> {
28256 self._user_project = Some(new_value.to_string());
28257 self
28258 }
28259 /// 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).
28260 ///
28261 /// Sets the *start offset* query property to the given value.
28262 pub fn start_offset(mut self, new_value: &str) -> ObjectListCall<'a, C> {
28263 self._start_offset = Some(new_value.to_string());
28264 self
28265 }
28266 /// If true, only soft-deleted object versions will be listed. The default is false. For more information, see [Soft Delete](https://cloud.google.com/storage/docs/soft-delete).
28267 ///
28268 /// Sets the *soft deleted* query property to the given value.
28269 pub fn soft_deleted(mut self, new_value: bool) -> ObjectListCall<'a, C> {
28270 self._soft_deleted = Some(new_value);
28271 self
28272 }
28273 /// Set of properties to return. Defaults to noAcl.
28274 ///
28275 /// Sets the *projection* query property to the given value.
28276 pub fn projection(mut self, new_value: &str) -> ObjectListCall<'a, C> {
28277 self._projection = Some(new_value.to_string());
28278 self
28279 }
28280 /// Filter results to objects whose names begin with this prefix.
28281 ///
28282 /// Sets the *prefix* query property to the given value.
28283 pub fn prefix(mut self, new_value: &str) -> ObjectListCall<'a, C> {
28284 self._prefix = Some(new_value.to_string());
28285 self
28286 }
28287 /// A previously-returned page token representing part of the larger set of results to view.
28288 ///
28289 /// Sets the *page token* query property to the given value.
28290 pub fn page_token(mut self, new_value: &str) -> ObjectListCall<'a, C> {
28291 self._page_token = Some(new_value.to_string());
28292 self
28293 }
28294 /// 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.
28295 ///
28296 /// Sets the *max results* query property to the given value.
28297 pub fn max_results(mut self, new_value: u32) -> ObjectListCall<'a, C> {
28298 self._max_results = Some(new_value);
28299 self
28300 }
28301 /// Filter results to objects and prefixes that match this glob pattern.
28302 ///
28303 /// Sets the *match glob* query property to the given value.
28304 pub fn match_glob(mut self, new_value: &str) -> ObjectListCall<'a, C> {
28305 self._match_glob = Some(new_value.to_string());
28306 self
28307 }
28308 /// If true, objects that end in exactly one instance of delimiter will have their metadata included in items in addition to prefixes.
28309 ///
28310 /// Sets the *include trailing delimiter* query property to the given value.
28311 pub fn include_trailing_delimiter(mut self, new_value: bool) -> ObjectListCall<'a, C> {
28312 self._include_trailing_delimiter = Some(new_value);
28313 self
28314 }
28315 /// Only applicable if delimiter is set to '/'. If true, will also include folders and managed folders (besides objects) in the returned prefixes.
28316 ///
28317 /// Sets the *include folders as prefixes* query property to the given value.
28318 pub fn include_folders_as_prefixes(mut self, new_value: bool) -> ObjectListCall<'a, C> {
28319 self._include_folders_as_prefixes = Some(new_value);
28320 self
28321 }
28322 /// Filter the returned objects. Currently only supported for the contexts field. If delimiter is set, the returned prefixes are exempt from this filter.
28323 ///
28324 /// Sets the *filter* query property to the given value.
28325 pub fn filter(mut self, new_value: &str) -> ObjectListCall<'a, C> {
28326 self._filter = Some(new_value.to_string());
28327 self
28328 }
28329 /// 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).
28330 ///
28331 /// Sets the *end offset* query property to the given value.
28332 pub fn end_offset(mut self, new_value: &str) -> ObjectListCall<'a, C> {
28333 self._end_offset = Some(new_value.to_string());
28334 self
28335 }
28336 /// 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.
28337 ///
28338 /// Sets the *delimiter* query property to the given value.
28339 pub fn delimiter(mut self, new_value: &str) -> ObjectListCall<'a, C> {
28340 self._delimiter = Some(new_value.to_string());
28341 self
28342 }
28343 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28344 /// while executing the actual API request.
28345 ///
28346 /// ````text
28347 /// It should be used to handle progress information, and to implement a certain level of resilience.
28348 /// ````
28349 ///
28350 /// Sets the *delegate* property to the given value.
28351 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ObjectListCall<'a, C> {
28352 self._delegate = Some(new_value);
28353 self
28354 }
28355
28356 /// Set any additional parameter of the query string used in the request.
28357 /// It should be used to set parameters which are not yet available through their own
28358 /// setters.
28359 ///
28360 /// Please note that this method must not be used to set any of the known parameters
28361 /// which have their own setter method. If done anyway, the request will fail.
28362 ///
28363 /// # Additional Parameters
28364 ///
28365 /// * *alt* (query-string) - Data format for the response.
28366 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28367 /// * *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.
28368 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28369 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28370 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
28371 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
28372 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
28373 pub fn param<T>(mut self, name: T, value: T) -> ObjectListCall<'a, C>
28374 where
28375 T: AsRef<str>,
28376 {
28377 self._additional_params
28378 .insert(name.as_ref().to_string(), value.as_ref().to_string());
28379 self
28380 }
28381
28382 /// Identifies the authorization scope for the method you are building.
28383 ///
28384 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28385 /// [`Scope::DevstorageReadOnly`].
28386 ///
28387 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28388 /// tokens for more than one scope.
28389 ///
28390 /// Usually there is more than one suitable scope to authorize an operation, some of which may
28391 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28392 /// sufficient, a read-write scope will do as well.
28393 pub fn add_scope<St>(mut self, scope: St) -> ObjectListCall<'a, C>
28394 where
28395 St: AsRef<str>,
28396 {
28397 self._scopes.insert(String::from(scope.as_ref()));
28398 self
28399 }
28400 /// Identifies the authorization scope(s) for the method you are building.
28401 ///
28402 /// See [`Self::add_scope()`] for details.
28403 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectListCall<'a, C>
28404 where
28405 I: IntoIterator<Item = St>,
28406 St: AsRef<str>,
28407 {
28408 self._scopes
28409 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28410 self
28411 }
28412
28413 /// Removes all scopes, and no default scope will be used either.
28414 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28415 /// for details).
28416 pub fn clear_scopes(mut self) -> ObjectListCall<'a, C> {
28417 self._scopes.clear();
28418 self
28419 }
28420}
28421
28422/// Moves the source object to the destination object in the same bucket.
28423///
28424/// A builder for the *move* method supported by a *object* resource.
28425/// It is not used directly, but through a [`ObjectMethods`] instance.
28426///
28427/// # Example
28428///
28429/// Instantiate a resource method builder
28430///
28431/// ```test_harness,no_run
28432/// # extern crate hyper;
28433/// # extern crate hyper_rustls;
28434/// # extern crate google_storage1 as storage1;
28435/// # async fn dox() {
28436/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28437///
28438/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28439/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28440/// # .with_native_roots()
28441/// # .unwrap()
28442/// # .https_only()
28443/// # .enable_http2()
28444/// # .build();
28445///
28446/// # let executor = hyper_util::rt::TokioExecutor::new();
28447/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28448/// # secret,
28449/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28450/// # yup_oauth2::client::CustomHyperClientBuilder::from(
28451/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
28452/// # ),
28453/// # ).build().await.unwrap();
28454///
28455/// # let client = hyper_util::client::legacy::Client::builder(
28456/// # hyper_util::rt::TokioExecutor::new()
28457/// # )
28458/// # .build(
28459/// # hyper_rustls::HttpsConnectorBuilder::new()
28460/// # .with_native_roots()
28461/// # .unwrap()
28462/// # .https_or_http()
28463/// # .enable_http2()
28464/// # .build()
28465/// # );
28466/// # let mut hub = Storage::new(client, auth);
28467/// // You can configure optional parameters by calling the respective setters at will, and
28468/// // execute the final call using `doit()`.
28469/// // Values shown here are possibly random and not representative !
28470/// let result = hub.objects().move_("bucket", "sourceObject", "destinationObject")
28471/// .user_project("eos")
28472/// .projection("duo")
28473/// .if_source_metageneration_not_match(-94)
28474/// .if_source_metageneration_match(-46)
28475/// .if_source_generation_not_match(-72)
28476/// .if_source_generation_match(-14)
28477/// .if_metageneration_not_match(-1)
28478/// .if_metageneration_match(-48)
28479/// .if_generation_not_match(-59)
28480/// .if_generation_match(-31)
28481/// .doit().await;
28482/// # }
28483/// ```
28484pub struct ObjectMoveCall<'a, C>
28485where
28486 C: 'a,
28487{
28488 hub: &'a Storage<C>,
28489 _bucket: String,
28490 _source_object: String,
28491 _destination_object: String,
28492 _user_project: Option<String>,
28493 _projection: Option<String>,
28494 _if_source_metageneration_not_match: Option<i64>,
28495 _if_source_metageneration_match: Option<i64>,
28496 _if_source_generation_not_match: Option<i64>,
28497 _if_source_generation_match: Option<i64>,
28498 _if_metageneration_not_match: Option<i64>,
28499 _if_metageneration_match: Option<i64>,
28500 _if_generation_not_match: Option<i64>,
28501 _if_generation_match: Option<i64>,
28502 _delegate: Option<&'a mut dyn common::Delegate>,
28503 _additional_params: HashMap<String, String>,
28504 _scopes: BTreeSet<String>,
28505}
28506
28507impl<'a, C> common::CallBuilder for ObjectMoveCall<'a, C> {}
28508
28509impl<'a, C> ObjectMoveCall<'a, C>
28510where
28511 C: common::Connector,
28512{
28513 /// Perform the operation you have build so far.
28514 pub async fn doit(mut self) -> common::Result<(common::Response, Object)> {
28515 use std::borrow::Cow;
28516 use std::io::{Read, Seek};
28517
28518 use common::{url::Params, ToParts};
28519 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28520
28521 let mut dd = common::DefaultDelegate;
28522 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28523 dlg.begin(common::MethodInfo {
28524 id: "storage.objects.move",
28525 http_method: hyper::Method::POST,
28526 });
28527
28528 for &field in [
28529 "alt",
28530 "bucket",
28531 "sourceObject",
28532 "destinationObject",
28533 "userProject",
28534 "projection",
28535 "ifSourceMetagenerationNotMatch",
28536 "ifSourceMetagenerationMatch",
28537 "ifSourceGenerationNotMatch",
28538 "ifSourceGenerationMatch",
28539 "ifMetagenerationNotMatch",
28540 "ifMetagenerationMatch",
28541 "ifGenerationNotMatch",
28542 "ifGenerationMatch",
28543 ]
28544 .iter()
28545 {
28546 if self._additional_params.contains_key(field) {
28547 dlg.finished(false);
28548 return Err(common::Error::FieldClash(field));
28549 }
28550 }
28551
28552 let mut params = Params::with_capacity(15 + self._additional_params.len());
28553 params.push("bucket", self._bucket);
28554 params.push("sourceObject", self._source_object);
28555 params.push("destinationObject", self._destination_object);
28556 if let Some(value) = self._user_project.as_ref() {
28557 params.push("userProject", value);
28558 }
28559 if let Some(value) = self._projection.as_ref() {
28560 params.push("projection", value);
28561 }
28562 if let Some(value) = self._if_source_metageneration_not_match.as_ref() {
28563 params.push("ifSourceMetagenerationNotMatch", value.to_string());
28564 }
28565 if let Some(value) = self._if_source_metageneration_match.as_ref() {
28566 params.push("ifSourceMetagenerationMatch", value.to_string());
28567 }
28568 if let Some(value) = self._if_source_generation_not_match.as_ref() {
28569 params.push("ifSourceGenerationNotMatch", value.to_string());
28570 }
28571 if let Some(value) = self._if_source_generation_match.as_ref() {
28572 params.push("ifSourceGenerationMatch", value.to_string());
28573 }
28574 if let Some(value) = self._if_metageneration_not_match.as_ref() {
28575 params.push("ifMetagenerationNotMatch", value.to_string());
28576 }
28577 if let Some(value) = self._if_metageneration_match.as_ref() {
28578 params.push("ifMetagenerationMatch", value.to_string());
28579 }
28580 if let Some(value) = self._if_generation_not_match.as_ref() {
28581 params.push("ifGenerationNotMatch", value.to_string());
28582 }
28583 if let Some(value) = self._if_generation_match.as_ref() {
28584 params.push("ifGenerationMatch", value.to_string());
28585 }
28586
28587 params.extend(self._additional_params.iter());
28588
28589 params.push("alt", "json");
28590 let mut url =
28591 self.hub._base_url.clone() + "b/{bucket}/o/{sourceObject}/moveTo/o/{destinationObject}";
28592 if self._scopes.is_empty() {
28593 self._scopes
28594 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
28595 }
28596
28597 #[allow(clippy::single_element_loop)]
28598 for &(find_this, param_name) in [
28599 ("{bucket}", "bucket"),
28600 ("{sourceObject}", "sourceObject"),
28601 ("{destinationObject}", "destinationObject"),
28602 ]
28603 .iter()
28604 {
28605 url = params.uri_replacement(url, param_name, find_this, false);
28606 }
28607 {
28608 let to_remove = ["destinationObject", "sourceObject", "bucket"];
28609 params.remove_params(&to_remove);
28610 }
28611
28612 let url = params.parse_with_url(&url);
28613
28614 loop {
28615 let token = match self
28616 .hub
28617 .auth
28618 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28619 .await
28620 {
28621 Ok(token) => token,
28622 Err(e) => match dlg.token(e) {
28623 Ok(token) => token,
28624 Err(e) => {
28625 dlg.finished(false);
28626 return Err(common::Error::MissingToken(e));
28627 }
28628 },
28629 };
28630 let mut req_result = {
28631 let client = &self.hub.client;
28632 dlg.pre_request();
28633 let mut req_builder = hyper::Request::builder()
28634 .method(hyper::Method::POST)
28635 .uri(url.as_str())
28636 .header(USER_AGENT, self.hub._user_agent.clone());
28637
28638 if let Some(token) = token.as_ref() {
28639 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28640 }
28641
28642 let request = req_builder
28643 .header(CONTENT_LENGTH, 0_u64)
28644 .body(common::to_body::<String>(None));
28645
28646 client.request(request.unwrap()).await
28647 };
28648
28649 match req_result {
28650 Err(err) => {
28651 if let common::Retry::After(d) = dlg.http_error(&err) {
28652 sleep(d).await;
28653 continue;
28654 }
28655 dlg.finished(false);
28656 return Err(common::Error::HttpError(err));
28657 }
28658 Ok(res) => {
28659 let (mut parts, body) = res.into_parts();
28660 let mut body = common::Body::new(body);
28661 if !parts.status.is_success() {
28662 let bytes = common::to_bytes(body).await.unwrap_or_default();
28663 let error = serde_json::from_str(&common::to_string(&bytes));
28664 let response = common::to_response(parts, bytes.into());
28665
28666 if let common::Retry::After(d) =
28667 dlg.http_failure(&response, error.as_ref().ok())
28668 {
28669 sleep(d).await;
28670 continue;
28671 }
28672
28673 dlg.finished(false);
28674
28675 return Err(match error {
28676 Ok(value) => common::Error::BadRequest(value),
28677 _ => common::Error::Failure(response),
28678 });
28679 }
28680 let response = {
28681 let bytes = common::to_bytes(body).await.unwrap_or_default();
28682 let encoded = common::to_string(&bytes);
28683 match serde_json::from_str(&encoded) {
28684 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28685 Err(error) => {
28686 dlg.response_json_decode_error(&encoded, &error);
28687 return Err(common::Error::JsonDecodeError(
28688 encoded.to_string(),
28689 error,
28690 ));
28691 }
28692 }
28693 };
28694
28695 dlg.finished(true);
28696 return Ok(response);
28697 }
28698 }
28699 }
28700 }
28701
28702 /// Name of the bucket in which the object resides.
28703 ///
28704 /// Sets the *bucket* path property to the given value.
28705 ///
28706 /// Even though the property as already been set when instantiating this call,
28707 /// we provide this method for API completeness.
28708 pub fn bucket(mut self, new_value: &str) -> ObjectMoveCall<'a, C> {
28709 self._bucket = new_value.to_string();
28710 self
28711 }
28712 /// 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).
28713 ///
28714 /// Sets the *source object* path property to the given value.
28715 ///
28716 /// Even though the property as already been set when instantiating this call,
28717 /// we provide this method for API completeness.
28718 pub fn source_object(mut self, new_value: &str) -> ObjectMoveCall<'a, C> {
28719 self._source_object = new_value.to_string();
28720 self
28721 }
28722 /// Name of the destination 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).
28723 ///
28724 /// Sets the *destination object* path property to the given value.
28725 ///
28726 /// Even though the property as already been set when instantiating this call,
28727 /// we provide this method for API completeness.
28728 pub fn destination_object(mut self, new_value: &str) -> ObjectMoveCall<'a, C> {
28729 self._destination_object = new_value.to_string();
28730 self
28731 }
28732 /// The project to be billed for this request. Required for Requester Pays buckets.
28733 ///
28734 /// Sets the *user project* query property to the given value.
28735 pub fn user_project(mut self, new_value: &str) -> ObjectMoveCall<'a, C> {
28736 self._user_project = Some(new_value.to_string());
28737 self
28738 }
28739 /// Set of properties to return. Defaults to noAcl.
28740 ///
28741 /// Sets the *projection* query property to the given value.
28742 pub fn projection(mut self, new_value: &str) -> ObjectMoveCall<'a, C> {
28743 self._projection = Some(new_value.to_string());
28744 self
28745 }
28746 /// Makes the operation conditional on whether the source object's current metageneration does not match the given value. `ifSourceMetagenerationMatch` and `ifSourceMetagenerationNotMatch` conditions are mutually exclusive: it's an error for both of them to be set in the request.
28747 ///
28748 /// Sets the *if source metageneration not match* query property to the given value.
28749 pub fn if_source_metageneration_not_match(mut self, new_value: i64) -> ObjectMoveCall<'a, C> {
28750 self._if_source_metageneration_not_match = Some(new_value);
28751 self
28752 }
28753 /// Makes the operation conditional on whether the source object's current metageneration matches the given value. `ifSourceMetagenerationMatch` and `ifSourceMetagenerationNotMatch` conditions are mutually exclusive: it's an error for both of them to be set in the request.
28754 ///
28755 /// Sets the *if source metageneration match* query property to the given value.
28756 pub fn if_source_metageneration_match(mut self, new_value: i64) -> ObjectMoveCall<'a, C> {
28757 self._if_source_metageneration_match = Some(new_value);
28758 self
28759 }
28760 /// Makes the operation conditional on whether the source object's current generation does not match the given value. `ifSourceGenerationMatch` and `ifSourceGenerationNotMatch` conditions are mutually exclusive: it's an error for both of them to be set in the request.
28761 ///
28762 /// Sets the *if source generation not match* query property to the given value.
28763 pub fn if_source_generation_not_match(mut self, new_value: i64) -> ObjectMoveCall<'a, C> {
28764 self._if_source_generation_not_match = Some(new_value);
28765 self
28766 }
28767 /// Makes the operation conditional on whether the source object's current generation matches the given value. `ifSourceGenerationMatch` and `ifSourceGenerationNotMatch` conditions are mutually exclusive: it's an error for both of them to be set in the request.
28768 ///
28769 /// Sets the *if source generation match* query property to the given value.
28770 pub fn if_source_generation_match(mut self, new_value: i64) -> ObjectMoveCall<'a, C> {
28771 self._if_source_generation_match = Some(new_value);
28772 self
28773 }
28774 /// Makes the operation conditional on whether the destination object's current metageneration does not match the given value. `ifMetagenerationMatch` and `ifMetagenerationNotMatch` conditions are mutually exclusive: it's an error for both of them to be set in the request.
28775 ///
28776 /// Sets the *if metageneration not match* query property to the given value.
28777 pub fn if_metageneration_not_match(mut self, new_value: i64) -> ObjectMoveCall<'a, C> {
28778 self._if_metageneration_not_match = Some(new_value);
28779 self
28780 }
28781 /// Makes the operation conditional on whether the destination object's current metageneration matches the given value. `ifMetagenerationMatch` and `ifMetagenerationNotMatch` conditions are mutually exclusive: it's an error for both of them to be set in the request.
28782 ///
28783 /// Sets the *if metageneration match* query property to the given value.
28784 pub fn if_metageneration_match(mut self, new_value: i64) -> ObjectMoveCall<'a, C> {
28785 self._if_metageneration_match = Some(new_value);
28786 self
28787 }
28788 /// 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.`ifGenerationMatch` and `ifGenerationNotMatch` conditions are mutually exclusive: it's an error for both of them to be set in the request.
28789 ///
28790 /// Sets the *if generation not match* query property to the given value.
28791 pub fn if_generation_not_match(mut self, new_value: i64) -> ObjectMoveCall<'a, C> {
28792 self._if_generation_not_match = Some(new_value);
28793 self
28794 }
28795 /// 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. `ifGenerationMatch` and `ifGenerationNotMatch` conditions are mutually exclusive: it's an error for both of them to be set in the request.
28796 ///
28797 /// Sets the *if generation match* query property to the given value.
28798 pub fn if_generation_match(mut self, new_value: i64) -> ObjectMoveCall<'a, C> {
28799 self._if_generation_match = Some(new_value);
28800 self
28801 }
28802 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28803 /// while executing the actual API request.
28804 ///
28805 /// ````text
28806 /// It should be used to handle progress information, and to implement a certain level of resilience.
28807 /// ````
28808 ///
28809 /// Sets the *delegate* property to the given value.
28810 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ObjectMoveCall<'a, C> {
28811 self._delegate = Some(new_value);
28812 self
28813 }
28814
28815 /// Set any additional parameter of the query string used in the request.
28816 /// It should be used to set parameters which are not yet available through their own
28817 /// setters.
28818 ///
28819 /// Please note that this method must not be used to set any of the known parameters
28820 /// which have their own setter method. If done anyway, the request will fail.
28821 ///
28822 /// # Additional Parameters
28823 ///
28824 /// * *alt* (query-string) - Data format for the response.
28825 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28826 /// * *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.
28827 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28828 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28829 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
28830 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
28831 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
28832 pub fn param<T>(mut self, name: T, value: T) -> ObjectMoveCall<'a, C>
28833 where
28834 T: AsRef<str>,
28835 {
28836 self._additional_params
28837 .insert(name.as_ref().to_string(), value.as_ref().to_string());
28838 self
28839 }
28840
28841 /// Identifies the authorization scope for the method you are building.
28842 ///
28843 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28844 /// [`Scope::DevstorageReadWrite`].
28845 ///
28846 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28847 /// tokens for more than one scope.
28848 ///
28849 /// Usually there is more than one suitable scope to authorize an operation, some of which may
28850 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28851 /// sufficient, a read-write scope will do as well.
28852 pub fn add_scope<St>(mut self, scope: St) -> ObjectMoveCall<'a, C>
28853 where
28854 St: AsRef<str>,
28855 {
28856 self._scopes.insert(String::from(scope.as_ref()));
28857 self
28858 }
28859 /// Identifies the authorization scope(s) for the method you are building.
28860 ///
28861 /// See [`Self::add_scope()`] for details.
28862 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectMoveCall<'a, C>
28863 where
28864 I: IntoIterator<Item = St>,
28865 St: AsRef<str>,
28866 {
28867 self._scopes
28868 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28869 self
28870 }
28871
28872 /// Removes all scopes, and no default scope will be used either.
28873 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28874 /// for details).
28875 pub fn clear_scopes(mut self) -> ObjectMoveCall<'a, C> {
28876 self._scopes.clear();
28877 self
28878 }
28879}
28880
28881/// Patches an object's metadata.
28882///
28883/// A builder for the *patch* method supported by a *object* resource.
28884/// It is not used directly, but through a [`ObjectMethods`] instance.
28885///
28886/// # Example
28887///
28888/// Instantiate a resource method builder
28889///
28890/// ```test_harness,no_run
28891/// # extern crate hyper;
28892/// # extern crate hyper_rustls;
28893/// # extern crate google_storage1 as storage1;
28894/// use storage1::api::Object;
28895/// # async fn dox() {
28896/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28897///
28898/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28899/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28900/// # .with_native_roots()
28901/// # .unwrap()
28902/// # .https_only()
28903/// # .enable_http2()
28904/// # .build();
28905///
28906/// # let executor = hyper_util::rt::TokioExecutor::new();
28907/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28908/// # secret,
28909/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28910/// # yup_oauth2::client::CustomHyperClientBuilder::from(
28911/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
28912/// # ),
28913/// # ).build().await.unwrap();
28914///
28915/// # let client = hyper_util::client::legacy::Client::builder(
28916/// # hyper_util::rt::TokioExecutor::new()
28917/// # )
28918/// # .build(
28919/// # hyper_rustls::HttpsConnectorBuilder::new()
28920/// # .with_native_roots()
28921/// # .unwrap()
28922/// # .https_or_http()
28923/// # .enable_http2()
28924/// # .build()
28925/// # );
28926/// # let mut hub = Storage::new(client, auth);
28927/// // As the method needs a request, you would usually fill it with the desired information
28928/// // into the respective structure. Some of the parts shown here might not be applicable !
28929/// // Values shown here are possibly random and not representative !
28930/// let mut req = Object::default();
28931///
28932/// // You can configure optional parameters by calling the respective setters at will, and
28933/// // execute the final call using `doit()`.
28934/// // Values shown here are possibly random and not representative !
28935/// let result = hub.objects().patch(req, "bucket", "object")
28936/// .user_project("Lorem")
28937/// .projection("At")
28938/// .predefined_acl("diam")
28939/// .override_unlocked_retention(false)
28940/// .if_metageneration_not_match(-93)
28941/// .if_metageneration_match(-18)
28942/// .if_generation_not_match(-17)
28943/// .if_generation_match(-84)
28944/// .generation(-55)
28945/// .doit().await;
28946/// # }
28947/// ```
28948pub struct ObjectPatchCall<'a, C>
28949where
28950 C: 'a,
28951{
28952 hub: &'a Storage<C>,
28953 _request: Object,
28954 _bucket: String,
28955 _object: String,
28956 _user_project: Option<String>,
28957 _projection: Option<String>,
28958 _predefined_acl: Option<String>,
28959 _override_unlocked_retention: Option<bool>,
28960 _if_metageneration_not_match: Option<i64>,
28961 _if_metageneration_match: Option<i64>,
28962 _if_generation_not_match: Option<i64>,
28963 _if_generation_match: Option<i64>,
28964 _generation: Option<i64>,
28965 _delegate: Option<&'a mut dyn common::Delegate>,
28966 _additional_params: HashMap<String, String>,
28967 _scopes: BTreeSet<String>,
28968}
28969
28970impl<'a, C> common::CallBuilder for ObjectPatchCall<'a, C> {}
28971
28972impl<'a, C> ObjectPatchCall<'a, C>
28973where
28974 C: common::Connector,
28975{
28976 /// Perform the operation you have build so far.
28977 pub async fn doit(mut self) -> common::Result<(common::Response, Object)> {
28978 use std::borrow::Cow;
28979 use std::io::{Read, Seek};
28980
28981 use common::{url::Params, ToParts};
28982 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28983
28984 let mut dd = common::DefaultDelegate;
28985 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28986 dlg.begin(common::MethodInfo {
28987 id: "storage.objects.patch",
28988 http_method: hyper::Method::PATCH,
28989 });
28990
28991 for &field in [
28992 "alt",
28993 "bucket",
28994 "object",
28995 "userProject",
28996 "projection",
28997 "predefinedAcl",
28998 "overrideUnlockedRetention",
28999 "ifMetagenerationNotMatch",
29000 "ifMetagenerationMatch",
29001 "ifGenerationNotMatch",
29002 "ifGenerationMatch",
29003 "generation",
29004 ]
29005 .iter()
29006 {
29007 if self._additional_params.contains_key(field) {
29008 dlg.finished(false);
29009 return Err(common::Error::FieldClash(field));
29010 }
29011 }
29012
29013 let mut params = Params::with_capacity(14 + self._additional_params.len());
29014 params.push("bucket", self._bucket);
29015 params.push("object", self._object);
29016 if let Some(value) = self._user_project.as_ref() {
29017 params.push("userProject", value);
29018 }
29019 if let Some(value) = self._projection.as_ref() {
29020 params.push("projection", value);
29021 }
29022 if let Some(value) = self._predefined_acl.as_ref() {
29023 params.push("predefinedAcl", value);
29024 }
29025 if let Some(value) = self._override_unlocked_retention.as_ref() {
29026 params.push("overrideUnlockedRetention", value.to_string());
29027 }
29028 if let Some(value) = self._if_metageneration_not_match.as_ref() {
29029 params.push("ifMetagenerationNotMatch", value.to_string());
29030 }
29031 if let Some(value) = self._if_metageneration_match.as_ref() {
29032 params.push("ifMetagenerationMatch", value.to_string());
29033 }
29034 if let Some(value) = self._if_generation_not_match.as_ref() {
29035 params.push("ifGenerationNotMatch", value.to_string());
29036 }
29037 if let Some(value) = self._if_generation_match.as_ref() {
29038 params.push("ifGenerationMatch", value.to_string());
29039 }
29040 if let Some(value) = self._generation.as_ref() {
29041 params.push("generation", value.to_string());
29042 }
29043
29044 params.extend(self._additional_params.iter());
29045
29046 params.push("alt", "json");
29047 let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}";
29048 if self._scopes.is_empty() {
29049 self._scopes
29050 .insert(Scope::DevstorageFullControl.as_ref().to_string());
29051 }
29052
29053 #[allow(clippy::single_element_loop)]
29054 for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object")].iter() {
29055 url = params.uri_replacement(url, param_name, find_this, false);
29056 }
29057 {
29058 let to_remove = ["object", "bucket"];
29059 params.remove_params(&to_remove);
29060 }
29061
29062 let url = params.parse_with_url(&url);
29063
29064 let mut json_mime_type = mime::APPLICATION_JSON;
29065 let mut request_value_reader = {
29066 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
29067 common::remove_json_null_values(&mut value);
29068 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
29069 serde_json::to_writer(&mut dst, &value).unwrap();
29070 dst
29071 };
29072 let request_size = request_value_reader
29073 .seek(std::io::SeekFrom::End(0))
29074 .unwrap();
29075 request_value_reader
29076 .seek(std::io::SeekFrom::Start(0))
29077 .unwrap();
29078
29079 loop {
29080 let token = match self
29081 .hub
29082 .auth
29083 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29084 .await
29085 {
29086 Ok(token) => token,
29087 Err(e) => match dlg.token(e) {
29088 Ok(token) => token,
29089 Err(e) => {
29090 dlg.finished(false);
29091 return Err(common::Error::MissingToken(e));
29092 }
29093 },
29094 };
29095 request_value_reader
29096 .seek(std::io::SeekFrom::Start(0))
29097 .unwrap();
29098 let mut req_result = {
29099 let client = &self.hub.client;
29100 dlg.pre_request();
29101 let mut req_builder = hyper::Request::builder()
29102 .method(hyper::Method::PATCH)
29103 .uri(url.as_str())
29104 .header(USER_AGENT, self.hub._user_agent.clone());
29105
29106 if let Some(token) = token.as_ref() {
29107 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29108 }
29109
29110 let request = req_builder
29111 .header(CONTENT_TYPE, json_mime_type.to_string())
29112 .header(CONTENT_LENGTH, request_size as u64)
29113 .body(common::to_body(
29114 request_value_reader.get_ref().clone().into(),
29115 ));
29116
29117 client.request(request.unwrap()).await
29118 };
29119
29120 match req_result {
29121 Err(err) => {
29122 if let common::Retry::After(d) = dlg.http_error(&err) {
29123 sleep(d).await;
29124 continue;
29125 }
29126 dlg.finished(false);
29127 return Err(common::Error::HttpError(err));
29128 }
29129 Ok(res) => {
29130 let (mut parts, body) = res.into_parts();
29131 let mut body = common::Body::new(body);
29132 if !parts.status.is_success() {
29133 let bytes = common::to_bytes(body).await.unwrap_or_default();
29134 let error = serde_json::from_str(&common::to_string(&bytes));
29135 let response = common::to_response(parts, bytes.into());
29136
29137 if let common::Retry::After(d) =
29138 dlg.http_failure(&response, error.as_ref().ok())
29139 {
29140 sleep(d).await;
29141 continue;
29142 }
29143
29144 dlg.finished(false);
29145
29146 return Err(match error {
29147 Ok(value) => common::Error::BadRequest(value),
29148 _ => common::Error::Failure(response),
29149 });
29150 }
29151 let response = {
29152 let bytes = common::to_bytes(body).await.unwrap_or_default();
29153 let encoded = common::to_string(&bytes);
29154 match serde_json::from_str(&encoded) {
29155 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29156 Err(error) => {
29157 dlg.response_json_decode_error(&encoded, &error);
29158 return Err(common::Error::JsonDecodeError(
29159 encoded.to_string(),
29160 error,
29161 ));
29162 }
29163 }
29164 };
29165
29166 dlg.finished(true);
29167 return Ok(response);
29168 }
29169 }
29170 }
29171 }
29172
29173 ///
29174 /// Sets the *request* property to the given value.
29175 ///
29176 /// Even though the property as already been set when instantiating this call,
29177 /// we provide this method for API completeness.
29178 pub fn request(mut self, new_value: Object) -> ObjectPatchCall<'a, C> {
29179 self._request = new_value;
29180 self
29181 }
29182 /// Name of the bucket in which the object resides.
29183 ///
29184 /// Sets the *bucket* path property to the given value.
29185 ///
29186 /// Even though the property as already been set when instantiating this call,
29187 /// we provide this method for API completeness.
29188 pub fn bucket(mut self, new_value: &str) -> ObjectPatchCall<'a, C> {
29189 self._bucket = new_value.to_string();
29190 self
29191 }
29192 /// 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).
29193 ///
29194 /// Sets the *object* path property to the given value.
29195 ///
29196 /// Even though the property as already been set when instantiating this call,
29197 /// we provide this method for API completeness.
29198 pub fn object(mut self, new_value: &str) -> ObjectPatchCall<'a, C> {
29199 self._object = new_value.to_string();
29200 self
29201 }
29202 /// The project to be billed for this request, for Requester Pays buckets.
29203 ///
29204 /// Sets the *user project* query property to the given value.
29205 pub fn user_project(mut self, new_value: &str) -> ObjectPatchCall<'a, C> {
29206 self._user_project = Some(new_value.to_string());
29207 self
29208 }
29209 /// Set of properties to return. Defaults to full.
29210 ///
29211 /// Sets the *projection* query property to the given value.
29212 pub fn projection(mut self, new_value: &str) -> ObjectPatchCall<'a, C> {
29213 self._projection = Some(new_value.to_string());
29214 self
29215 }
29216 /// Apply a predefined set of access controls to this object.
29217 ///
29218 /// Sets the *predefined acl* query property to the given value.
29219 pub fn predefined_acl(mut self, new_value: &str) -> ObjectPatchCall<'a, C> {
29220 self._predefined_acl = Some(new_value.to_string());
29221 self
29222 }
29223 /// Must be true to remove the retention configuration, reduce its unlocked retention period, or change its mode from unlocked to locked.
29224 ///
29225 /// Sets the *override unlocked retention* query property to the given value.
29226 pub fn override_unlocked_retention(mut self, new_value: bool) -> ObjectPatchCall<'a, C> {
29227 self._override_unlocked_retention = Some(new_value);
29228 self
29229 }
29230 /// Makes the operation conditional on whether the object's current metageneration does not match the given value.
29231 ///
29232 /// Sets the *if metageneration not match* query property to the given value.
29233 pub fn if_metageneration_not_match(mut self, new_value: i64) -> ObjectPatchCall<'a, C> {
29234 self._if_metageneration_not_match = Some(new_value);
29235 self
29236 }
29237 /// Makes the operation conditional on whether the object's current metageneration matches the given value.
29238 ///
29239 /// Sets the *if metageneration match* query property to the given value.
29240 pub fn if_metageneration_match(mut self, new_value: i64) -> ObjectPatchCall<'a, C> {
29241 self._if_metageneration_match = Some(new_value);
29242 self
29243 }
29244 /// 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.
29245 ///
29246 /// Sets the *if generation not match* query property to the given value.
29247 pub fn if_generation_not_match(mut self, new_value: i64) -> ObjectPatchCall<'a, C> {
29248 self._if_generation_not_match = Some(new_value);
29249 self
29250 }
29251 /// 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.
29252 ///
29253 /// Sets the *if generation match* query property to the given value.
29254 pub fn if_generation_match(mut self, new_value: i64) -> ObjectPatchCall<'a, C> {
29255 self._if_generation_match = Some(new_value);
29256 self
29257 }
29258 /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
29259 ///
29260 /// Sets the *generation* query property to the given value.
29261 pub fn generation(mut self, new_value: i64) -> ObjectPatchCall<'a, C> {
29262 self._generation = Some(new_value);
29263 self
29264 }
29265 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29266 /// while executing the actual API request.
29267 ///
29268 /// ````text
29269 /// It should be used to handle progress information, and to implement a certain level of resilience.
29270 /// ````
29271 ///
29272 /// Sets the *delegate* property to the given value.
29273 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ObjectPatchCall<'a, C> {
29274 self._delegate = Some(new_value);
29275 self
29276 }
29277
29278 /// Set any additional parameter of the query string used in the request.
29279 /// It should be used to set parameters which are not yet available through their own
29280 /// setters.
29281 ///
29282 /// Please note that this method must not be used to set any of the known parameters
29283 /// which have their own setter method. If done anyway, the request will fail.
29284 ///
29285 /// # Additional Parameters
29286 ///
29287 /// * *alt* (query-string) - Data format for the response.
29288 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29289 /// * *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.
29290 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29291 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29292 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
29293 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
29294 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
29295 pub fn param<T>(mut self, name: T, value: T) -> ObjectPatchCall<'a, C>
29296 where
29297 T: AsRef<str>,
29298 {
29299 self._additional_params
29300 .insert(name.as_ref().to_string(), value.as_ref().to_string());
29301 self
29302 }
29303
29304 /// Identifies the authorization scope for the method you are building.
29305 ///
29306 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29307 /// [`Scope::DevstorageFullControl`].
29308 ///
29309 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29310 /// tokens for more than one scope.
29311 ///
29312 /// Usually there is more than one suitable scope to authorize an operation, some of which may
29313 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29314 /// sufficient, a read-write scope will do as well.
29315 pub fn add_scope<St>(mut self, scope: St) -> ObjectPatchCall<'a, C>
29316 where
29317 St: AsRef<str>,
29318 {
29319 self._scopes.insert(String::from(scope.as_ref()));
29320 self
29321 }
29322 /// Identifies the authorization scope(s) for the method you are building.
29323 ///
29324 /// See [`Self::add_scope()`] for details.
29325 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectPatchCall<'a, C>
29326 where
29327 I: IntoIterator<Item = St>,
29328 St: AsRef<str>,
29329 {
29330 self._scopes
29331 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29332 self
29333 }
29334
29335 /// Removes all scopes, and no default scope will be used either.
29336 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29337 /// for details).
29338 pub fn clear_scopes(mut self) -> ObjectPatchCall<'a, C> {
29339 self._scopes.clear();
29340 self
29341 }
29342}
29343
29344/// Restores a soft-deleted object.
29345///
29346/// A builder for the *restore* method supported by a *object* resource.
29347/// It is not used directly, but through a [`ObjectMethods`] instance.
29348///
29349/// # Example
29350///
29351/// Instantiate a resource method builder
29352///
29353/// ```test_harness,no_run
29354/// # extern crate hyper;
29355/// # extern crate hyper_rustls;
29356/// # extern crate google_storage1 as storage1;
29357/// # async fn dox() {
29358/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29359///
29360/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29361/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
29362/// # .with_native_roots()
29363/// # .unwrap()
29364/// # .https_only()
29365/// # .enable_http2()
29366/// # .build();
29367///
29368/// # let executor = hyper_util::rt::TokioExecutor::new();
29369/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
29370/// # secret,
29371/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29372/// # yup_oauth2::client::CustomHyperClientBuilder::from(
29373/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
29374/// # ),
29375/// # ).build().await.unwrap();
29376///
29377/// # let client = hyper_util::client::legacy::Client::builder(
29378/// # hyper_util::rt::TokioExecutor::new()
29379/// # )
29380/// # .build(
29381/// # hyper_rustls::HttpsConnectorBuilder::new()
29382/// # .with_native_roots()
29383/// # .unwrap()
29384/// # .https_or_http()
29385/// # .enable_http2()
29386/// # .build()
29387/// # );
29388/// # let mut hub = Storage::new(client, auth);
29389/// // You can configure optional parameters by calling the respective setters at will, and
29390/// // execute the final call using `doit()`.
29391/// // Values shown here are possibly random and not representative !
29392/// let result = hub.objects().restore("bucket", "object", -53)
29393/// .user_project("sit")
29394/// .restore_token("Lorem")
29395/// .projection("Stet")
29396/// .if_metageneration_not_match(-70)
29397/// .if_metageneration_match(-94)
29398/// .if_generation_not_match(-32)
29399/// .if_generation_match(-31)
29400/// .copy_source_acl(false)
29401/// .doit().await;
29402/// # }
29403/// ```
29404pub struct ObjectRestoreCall<'a, C>
29405where
29406 C: 'a,
29407{
29408 hub: &'a Storage<C>,
29409 _bucket: String,
29410 _object: String,
29411 _generation: i64,
29412 _user_project: Option<String>,
29413 _restore_token: Option<String>,
29414 _projection: Option<String>,
29415 _if_metageneration_not_match: Option<i64>,
29416 _if_metageneration_match: Option<i64>,
29417 _if_generation_not_match: Option<i64>,
29418 _if_generation_match: Option<i64>,
29419 _copy_source_acl: Option<bool>,
29420 _delegate: Option<&'a mut dyn common::Delegate>,
29421 _additional_params: HashMap<String, String>,
29422 _scopes: BTreeSet<String>,
29423}
29424
29425impl<'a, C> common::CallBuilder for ObjectRestoreCall<'a, C> {}
29426
29427impl<'a, C> ObjectRestoreCall<'a, C>
29428where
29429 C: common::Connector,
29430{
29431 /// Perform the operation you have build so far.
29432 pub async fn doit(mut self) -> common::Result<(common::Response, Object)> {
29433 use std::borrow::Cow;
29434 use std::io::{Read, Seek};
29435
29436 use common::{url::Params, ToParts};
29437 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29438
29439 let mut dd = common::DefaultDelegate;
29440 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29441 dlg.begin(common::MethodInfo {
29442 id: "storage.objects.restore",
29443 http_method: hyper::Method::POST,
29444 });
29445
29446 for &field in [
29447 "alt",
29448 "bucket",
29449 "object",
29450 "generation",
29451 "userProject",
29452 "restoreToken",
29453 "projection",
29454 "ifMetagenerationNotMatch",
29455 "ifMetagenerationMatch",
29456 "ifGenerationNotMatch",
29457 "ifGenerationMatch",
29458 "copySourceAcl",
29459 ]
29460 .iter()
29461 {
29462 if self._additional_params.contains_key(field) {
29463 dlg.finished(false);
29464 return Err(common::Error::FieldClash(field));
29465 }
29466 }
29467
29468 let mut params = Params::with_capacity(13 + self._additional_params.len());
29469 params.push("bucket", self._bucket);
29470 params.push("object", self._object);
29471 params.push("generation", self._generation.to_string());
29472 if let Some(value) = self._user_project.as_ref() {
29473 params.push("userProject", value);
29474 }
29475 if let Some(value) = self._restore_token.as_ref() {
29476 params.push("restoreToken", value);
29477 }
29478 if let Some(value) = self._projection.as_ref() {
29479 params.push("projection", value);
29480 }
29481 if let Some(value) = self._if_metageneration_not_match.as_ref() {
29482 params.push("ifMetagenerationNotMatch", value.to_string());
29483 }
29484 if let Some(value) = self._if_metageneration_match.as_ref() {
29485 params.push("ifMetagenerationMatch", value.to_string());
29486 }
29487 if let Some(value) = self._if_generation_not_match.as_ref() {
29488 params.push("ifGenerationNotMatch", value.to_string());
29489 }
29490 if let Some(value) = self._if_generation_match.as_ref() {
29491 params.push("ifGenerationMatch", value.to_string());
29492 }
29493 if let Some(value) = self._copy_source_acl.as_ref() {
29494 params.push("copySourceAcl", value.to_string());
29495 }
29496
29497 params.extend(self._additional_params.iter());
29498
29499 params.push("alt", "json");
29500 let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}/restore";
29501 if self._scopes.is_empty() {
29502 self._scopes
29503 .insert(Scope::DevstorageFullControl.as_ref().to_string());
29504 }
29505
29506 #[allow(clippy::single_element_loop)]
29507 for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object")].iter() {
29508 url = params.uri_replacement(url, param_name, find_this, false);
29509 }
29510 {
29511 let to_remove = ["object", "bucket"];
29512 params.remove_params(&to_remove);
29513 }
29514
29515 let url = params.parse_with_url(&url);
29516
29517 loop {
29518 let token = match self
29519 .hub
29520 .auth
29521 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29522 .await
29523 {
29524 Ok(token) => token,
29525 Err(e) => match dlg.token(e) {
29526 Ok(token) => token,
29527 Err(e) => {
29528 dlg.finished(false);
29529 return Err(common::Error::MissingToken(e));
29530 }
29531 },
29532 };
29533 let mut req_result = {
29534 let client = &self.hub.client;
29535 dlg.pre_request();
29536 let mut req_builder = hyper::Request::builder()
29537 .method(hyper::Method::POST)
29538 .uri(url.as_str())
29539 .header(USER_AGENT, self.hub._user_agent.clone());
29540
29541 if let Some(token) = token.as_ref() {
29542 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29543 }
29544
29545 let request = req_builder
29546 .header(CONTENT_LENGTH, 0_u64)
29547 .body(common::to_body::<String>(None));
29548
29549 client.request(request.unwrap()).await
29550 };
29551
29552 match req_result {
29553 Err(err) => {
29554 if let common::Retry::After(d) = dlg.http_error(&err) {
29555 sleep(d).await;
29556 continue;
29557 }
29558 dlg.finished(false);
29559 return Err(common::Error::HttpError(err));
29560 }
29561 Ok(res) => {
29562 let (mut parts, body) = res.into_parts();
29563 let mut body = common::Body::new(body);
29564 if !parts.status.is_success() {
29565 let bytes = common::to_bytes(body).await.unwrap_or_default();
29566 let error = serde_json::from_str(&common::to_string(&bytes));
29567 let response = common::to_response(parts, bytes.into());
29568
29569 if let common::Retry::After(d) =
29570 dlg.http_failure(&response, error.as_ref().ok())
29571 {
29572 sleep(d).await;
29573 continue;
29574 }
29575
29576 dlg.finished(false);
29577
29578 return Err(match error {
29579 Ok(value) => common::Error::BadRequest(value),
29580 _ => common::Error::Failure(response),
29581 });
29582 }
29583 let response = {
29584 let bytes = common::to_bytes(body).await.unwrap_or_default();
29585 let encoded = common::to_string(&bytes);
29586 match serde_json::from_str(&encoded) {
29587 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29588 Err(error) => {
29589 dlg.response_json_decode_error(&encoded, &error);
29590 return Err(common::Error::JsonDecodeError(
29591 encoded.to_string(),
29592 error,
29593 ));
29594 }
29595 }
29596 };
29597
29598 dlg.finished(true);
29599 return Ok(response);
29600 }
29601 }
29602 }
29603 }
29604
29605 /// Name of the bucket in which the object resides.
29606 ///
29607 /// Sets the *bucket* path property to the given value.
29608 ///
29609 /// Even though the property as already been set when instantiating this call,
29610 /// we provide this method for API completeness.
29611 pub fn bucket(mut self, new_value: &str) -> ObjectRestoreCall<'a, C> {
29612 self._bucket = new_value.to_string();
29613 self
29614 }
29615 /// 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).
29616 ///
29617 /// Sets the *object* path property to the given value.
29618 ///
29619 /// Even though the property as already been set when instantiating this call,
29620 /// we provide this method for API completeness.
29621 pub fn object(mut self, new_value: &str) -> ObjectRestoreCall<'a, C> {
29622 self._object = new_value.to_string();
29623 self
29624 }
29625 /// Selects a specific revision of this object.
29626 ///
29627 /// Sets the *generation* query property to the given value.
29628 ///
29629 /// Even though the property as already been set when instantiating this call,
29630 /// we provide this method for API completeness.
29631 pub fn generation(mut self, new_value: i64) -> ObjectRestoreCall<'a, C> {
29632 self._generation = new_value;
29633 self
29634 }
29635 /// The project to be billed for this request. Required for Requester Pays buckets.
29636 ///
29637 /// Sets the *user project* query property to the given value.
29638 pub fn user_project(mut self, new_value: &str) -> ObjectRestoreCall<'a, C> {
29639 self._user_project = Some(new_value.to_string());
29640 self
29641 }
29642 /// Restore token used to differentiate sof-deleted objects with the same name and generation. Only applicable for hierarchical namespace buckets. This parameter is optional, and is only required in the rare case when there are multiple soft-deleted objects with the same name and generation.
29643 ///
29644 /// Sets the *restore token* query property to the given value.
29645 pub fn restore_token(mut self, new_value: &str) -> ObjectRestoreCall<'a, C> {
29646 self._restore_token = Some(new_value.to_string());
29647 self
29648 }
29649 /// Set of properties to return. Defaults to full.
29650 ///
29651 /// Sets the *projection* query property to the given value.
29652 pub fn projection(mut self, new_value: &str) -> ObjectRestoreCall<'a, C> {
29653 self._projection = Some(new_value.to_string());
29654 self
29655 }
29656 /// Makes the operation conditional on whether none of the object's live metagenerations match the given value.
29657 ///
29658 /// Sets the *if metageneration not match* query property to the given value.
29659 pub fn if_metageneration_not_match(mut self, new_value: i64) -> ObjectRestoreCall<'a, C> {
29660 self._if_metageneration_not_match = Some(new_value);
29661 self
29662 }
29663 /// Makes the operation conditional on whether the object's one live metageneration matches the given value.
29664 ///
29665 /// Sets the *if metageneration match* query property to the given value.
29666 pub fn if_metageneration_match(mut self, new_value: i64) -> ObjectRestoreCall<'a, C> {
29667 self._if_metageneration_match = Some(new_value);
29668 self
29669 }
29670 /// 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.
29671 ///
29672 /// Sets the *if generation not match* query property to the given value.
29673 pub fn if_generation_not_match(mut self, new_value: i64) -> ObjectRestoreCall<'a, C> {
29674 self._if_generation_not_match = Some(new_value);
29675 self
29676 }
29677 /// 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.
29678 ///
29679 /// Sets the *if generation match* query property to the given value.
29680 pub fn if_generation_match(mut self, new_value: i64) -> ObjectRestoreCall<'a, C> {
29681 self._if_generation_match = Some(new_value);
29682 self
29683 }
29684 /// If true, copies the source object's ACL; otherwise, uses the bucket's default object ACL. The default is false.
29685 ///
29686 /// Sets the *copy source acl* query property to the given value.
29687 pub fn copy_source_acl(mut self, new_value: bool) -> ObjectRestoreCall<'a, C> {
29688 self._copy_source_acl = Some(new_value);
29689 self
29690 }
29691 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29692 /// while executing the actual API request.
29693 ///
29694 /// ````text
29695 /// It should be used to handle progress information, and to implement a certain level of resilience.
29696 /// ````
29697 ///
29698 /// Sets the *delegate* property to the given value.
29699 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ObjectRestoreCall<'a, C> {
29700 self._delegate = Some(new_value);
29701 self
29702 }
29703
29704 /// Set any additional parameter of the query string used in the request.
29705 /// It should be used to set parameters which are not yet available through their own
29706 /// setters.
29707 ///
29708 /// Please note that this method must not be used to set any of the known parameters
29709 /// which have their own setter method. If done anyway, the request will fail.
29710 ///
29711 /// # Additional Parameters
29712 ///
29713 /// * *alt* (query-string) - Data format for the response.
29714 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29715 /// * *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.
29716 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29717 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29718 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
29719 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
29720 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
29721 pub fn param<T>(mut self, name: T, value: T) -> ObjectRestoreCall<'a, C>
29722 where
29723 T: AsRef<str>,
29724 {
29725 self._additional_params
29726 .insert(name.as_ref().to_string(), value.as_ref().to_string());
29727 self
29728 }
29729
29730 /// Identifies the authorization scope for the method you are building.
29731 ///
29732 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29733 /// [`Scope::DevstorageFullControl`].
29734 ///
29735 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29736 /// tokens for more than one scope.
29737 ///
29738 /// Usually there is more than one suitable scope to authorize an operation, some of which may
29739 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29740 /// sufficient, a read-write scope will do as well.
29741 pub fn add_scope<St>(mut self, scope: St) -> ObjectRestoreCall<'a, C>
29742 where
29743 St: AsRef<str>,
29744 {
29745 self._scopes.insert(String::from(scope.as_ref()));
29746 self
29747 }
29748 /// Identifies the authorization scope(s) for the method you are building.
29749 ///
29750 /// See [`Self::add_scope()`] for details.
29751 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectRestoreCall<'a, C>
29752 where
29753 I: IntoIterator<Item = St>,
29754 St: AsRef<str>,
29755 {
29756 self._scopes
29757 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29758 self
29759 }
29760
29761 /// Removes all scopes, and no default scope will be used either.
29762 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29763 /// for details).
29764 pub fn clear_scopes(mut self) -> ObjectRestoreCall<'a, C> {
29765 self._scopes.clear();
29766 self
29767 }
29768}
29769
29770/// Rewrites a source object to a destination object. Optionally overrides metadata.
29771///
29772/// A builder for the *rewrite* method supported by a *object* resource.
29773/// It is not used directly, but through a [`ObjectMethods`] instance.
29774///
29775/// # Example
29776///
29777/// Instantiate a resource method builder
29778///
29779/// ```test_harness,no_run
29780/// # extern crate hyper;
29781/// # extern crate hyper_rustls;
29782/// # extern crate google_storage1 as storage1;
29783/// use storage1::api::Object;
29784/// # async fn dox() {
29785/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29786///
29787/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29788/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
29789/// # .with_native_roots()
29790/// # .unwrap()
29791/// # .https_only()
29792/// # .enable_http2()
29793/// # .build();
29794///
29795/// # let executor = hyper_util::rt::TokioExecutor::new();
29796/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
29797/// # secret,
29798/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29799/// # yup_oauth2::client::CustomHyperClientBuilder::from(
29800/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
29801/// # ),
29802/// # ).build().await.unwrap();
29803///
29804/// # let client = hyper_util::client::legacy::Client::builder(
29805/// # hyper_util::rt::TokioExecutor::new()
29806/// # )
29807/// # .build(
29808/// # hyper_rustls::HttpsConnectorBuilder::new()
29809/// # .with_native_roots()
29810/// # .unwrap()
29811/// # .https_or_http()
29812/// # .enable_http2()
29813/// # .build()
29814/// # );
29815/// # let mut hub = Storage::new(client, auth);
29816/// // As the method needs a request, you would usually fill it with the desired information
29817/// // into the respective structure. Some of the parts shown here might not be applicable !
29818/// // Values shown here are possibly random and not representative !
29819/// let mut req = Object::default();
29820///
29821/// // You can configure optional parameters by calling the respective setters at will, and
29822/// // execute the final call using `doit()`.
29823/// // Values shown here are possibly random and not representative !
29824/// let result = hub.objects().rewrite(req, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject")
29825/// .user_project("sed")
29826/// .source_generation(-65)
29827/// .rewrite_token("aliquyam")
29828/// .projection("kasd")
29829/// .max_bytes_rewritten_per_call(-101)
29830/// .if_source_metageneration_not_match(-48)
29831/// .if_source_metageneration_match(-63)
29832/// .if_source_generation_not_match(-39)
29833/// .if_source_generation_match(-54)
29834/// .if_metageneration_not_match(-97)
29835/// .if_metageneration_match(-3)
29836/// .if_generation_not_match(-16)
29837/// .if_generation_match(-60)
29838/// .destination_predefined_acl("ipsum")
29839/// .destination_kms_key_name("ipsum")
29840/// .doit().await;
29841/// # }
29842/// ```
29843pub struct ObjectRewriteCall<'a, C>
29844where
29845 C: 'a,
29846{
29847 hub: &'a Storage<C>,
29848 _request: Object,
29849 _source_bucket: String,
29850 _source_object: String,
29851 _destination_bucket: String,
29852 _destination_object: String,
29853 _user_project: Option<String>,
29854 _source_generation: Option<i64>,
29855 _rewrite_token: Option<String>,
29856 _projection: Option<String>,
29857 _max_bytes_rewritten_per_call: Option<i64>,
29858 _if_source_metageneration_not_match: Option<i64>,
29859 _if_source_metageneration_match: Option<i64>,
29860 _if_source_generation_not_match: Option<i64>,
29861 _if_source_generation_match: Option<i64>,
29862 _if_metageneration_not_match: Option<i64>,
29863 _if_metageneration_match: Option<i64>,
29864 _if_generation_not_match: Option<i64>,
29865 _if_generation_match: Option<i64>,
29866 _destination_predefined_acl: Option<String>,
29867 _destination_kms_key_name: Option<String>,
29868 _delegate: Option<&'a mut dyn common::Delegate>,
29869 _additional_params: HashMap<String, String>,
29870 _scopes: BTreeSet<String>,
29871}
29872
29873impl<'a, C> common::CallBuilder for ObjectRewriteCall<'a, C> {}
29874
29875impl<'a, C> ObjectRewriteCall<'a, C>
29876where
29877 C: common::Connector,
29878{
29879 /// Perform the operation you have build so far.
29880 pub async fn doit(mut self) -> common::Result<(common::Response, RewriteResponse)> {
29881 use std::borrow::Cow;
29882 use std::io::{Read, Seek};
29883
29884 use common::{url::Params, ToParts};
29885 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29886
29887 let mut dd = common::DefaultDelegate;
29888 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29889 dlg.begin(common::MethodInfo {
29890 id: "storage.objects.rewrite",
29891 http_method: hyper::Method::POST,
29892 });
29893
29894 for &field in [
29895 "alt",
29896 "sourceBucket",
29897 "sourceObject",
29898 "destinationBucket",
29899 "destinationObject",
29900 "userProject",
29901 "sourceGeneration",
29902 "rewriteToken",
29903 "projection",
29904 "maxBytesRewrittenPerCall",
29905 "ifSourceMetagenerationNotMatch",
29906 "ifSourceMetagenerationMatch",
29907 "ifSourceGenerationNotMatch",
29908 "ifSourceGenerationMatch",
29909 "ifMetagenerationNotMatch",
29910 "ifMetagenerationMatch",
29911 "ifGenerationNotMatch",
29912 "ifGenerationMatch",
29913 "destinationPredefinedAcl",
29914 "destinationKmsKeyName",
29915 ]
29916 .iter()
29917 {
29918 if self._additional_params.contains_key(field) {
29919 dlg.finished(false);
29920 return Err(common::Error::FieldClash(field));
29921 }
29922 }
29923
29924 let mut params = Params::with_capacity(22 + self._additional_params.len());
29925 params.push("sourceBucket", self._source_bucket);
29926 params.push("sourceObject", self._source_object);
29927 params.push("destinationBucket", self._destination_bucket);
29928 params.push("destinationObject", self._destination_object);
29929 if let Some(value) = self._user_project.as_ref() {
29930 params.push("userProject", value);
29931 }
29932 if let Some(value) = self._source_generation.as_ref() {
29933 params.push("sourceGeneration", value.to_string());
29934 }
29935 if let Some(value) = self._rewrite_token.as_ref() {
29936 params.push("rewriteToken", value);
29937 }
29938 if let Some(value) = self._projection.as_ref() {
29939 params.push("projection", value);
29940 }
29941 if let Some(value) = self._max_bytes_rewritten_per_call.as_ref() {
29942 params.push("maxBytesRewrittenPerCall", value.to_string());
29943 }
29944 if let Some(value) = self._if_source_metageneration_not_match.as_ref() {
29945 params.push("ifSourceMetagenerationNotMatch", value.to_string());
29946 }
29947 if let Some(value) = self._if_source_metageneration_match.as_ref() {
29948 params.push("ifSourceMetagenerationMatch", value.to_string());
29949 }
29950 if let Some(value) = self._if_source_generation_not_match.as_ref() {
29951 params.push("ifSourceGenerationNotMatch", value.to_string());
29952 }
29953 if let Some(value) = self._if_source_generation_match.as_ref() {
29954 params.push("ifSourceGenerationMatch", value.to_string());
29955 }
29956 if let Some(value) = self._if_metageneration_not_match.as_ref() {
29957 params.push("ifMetagenerationNotMatch", value.to_string());
29958 }
29959 if let Some(value) = self._if_metageneration_match.as_ref() {
29960 params.push("ifMetagenerationMatch", value.to_string());
29961 }
29962 if let Some(value) = self._if_generation_not_match.as_ref() {
29963 params.push("ifGenerationNotMatch", value.to_string());
29964 }
29965 if let Some(value) = self._if_generation_match.as_ref() {
29966 params.push("ifGenerationMatch", value.to_string());
29967 }
29968 if let Some(value) = self._destination_predefined_acl.as_ref() {
29969 params.push("destinationPredefinedAcl", value);
29970 }
29971 if let Some(value) = self._destination_kms_key_name.as_ref() {
29972 params.push("destinationKmsKeyName", value);
29973 }
29974
29975 params.extend(self._additional_params.iter());
29976
29977 params.push("alt", "json");
29978 let mut url = self.hub._base_url.clone() + "b/{sourceBucket}/o/{sourceObject}/rewriteTo/b/{destinationBucket}/o/{destinationObject}";
29979 if self._scopes.is_empty() {
29980 self._scopes
29981 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
29982 }
29983
29984 #[allow(clippy::single_element_loop)]
29985 for &(find_this, param_name) in [
29986 ("{sourceBucket}", "sourceBucket"),
29987 ("{sourceObject}", "sourceObject"),
29988 ("{destinationBucket}", "destinationBucket"),
29989 ("{destinationObject}", "destinationObject"),
29990 ]
29991 .iter()
29992 {
29993 url = params.uri_replacement(url, param_name, find_this, false);
29994 }
29995 {
29996 let to_remove = [
29997 "destinationObject",
29998 "destinationBucket",
29999 "sourceObject",
30000 "sourceBucket",
30001 ];
30002 params.remove_params(&to_remove);
30003 }
30004
30005 let url = params.parse_with_url(&url);
30006
30007 let mut json_mime_type = mime::APPLICATION_JSON;
30008 let mut request_value_reader = {
30009 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
30010 common::remove_json_null_values(&mut value);
30011 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
30012 serde_json::to_writer(&mut dst, &value).unwrap();
30013 dst
30014 };
30015 let request_size = request_value_reader
30016 .seek(std::io::SeekFrom::End(0))
30017 .unwrap();
30018 request_value_reader
30019 .seek(std::io::SeekFrom::Start(0))
30020 .unwrap();
30021
30022 loop {
30023 let token = match self
30024 .hub
30025 .auth
30026 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30027 .await
30028 {
30029 Ok(token) => token,
30030 Err(e) => match dlg.token(e) {
30031 Ok(token) => token,
30032 Err(e) => {
30033 dlg.finished(false);
30034 return Err(common::Error::MissingToken(e));
30035 }
30036 },
30037 };
30038 request_value_reader
30039 .seek(std::io::SeekFrom::Start(0))
30040 .unwrap();
30041 let mut req_result = {
30042 let client = &self.hub.client;
30043 dlg.pre_request();
30044 let mut req_builder = hyper::Request::builder()
30045 .method(hyper::Method::POST)
30046 .uri(url.as_str())
30047 .header(USER_AGENT, self.hub._user_agent.clone());
30048
30049 if let Some(token) = token.as_ref() {
30050 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30051 }
30052
30053 let request = req_builder
30054 .header(CONTENT_TYPE, json_mime_type.to_string())
30055 .header(CONTENT_LENGTH, request_size as u64)
30056 .body(common::to_body(
30057 request_value_reader.get_ref().clone().into(),
30058 ));
30059
30060 client.request(request.unwrap()).await
30061 };
30062
30063 match req_result {
30064 Err(err) => {
30065 if let common::Retry::After(d) = dlg.http_error(&err) {
30066 sleep(d).await;
30067 continue;
30068 }
30069 dlg.finished(false);
30070 return Err(common::Error::HttpError(err));
30071 }
30072 Ok(res) => {
30073 let (mut parts, body) = res.into_parts();
30074 let mut body = common::Body::new(body);
30075 if !parts.status.is_success() {
30076 let bytes = common::to_bytes(body).await.unwrap_or_default();
30077 let error = serde_json::from_str(&common::to_string(&bytes));
30078 let response = common::to_response(parts, bytes.into());
30079
30080 if let common::Retry::After(d) =
30081 dlg.http_failure(&response, error.as_ref().ok())
30082 {
30083 sleep(d).await;
30084 continue;
30085 }
30086
30087 dlg.finished(false);
30088
30089 return Err(match error {
30090 Ok(value) => common::Error::BadRequest(value),
30091 _ => common::Error::Failure(response),
30092 });
30093 }
30094 let response = {
30095 let bytes = common::to_bytes(body).await.unwrap_or_default();
30096 let encoded = common::to_string(&bytes);
30097 match serde_json::from_str(&encoded) {
30098 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30099 Err(error) => {
30100 dlg.response_json_decode_error(&encoded, &error);
30101 return Err(common::Error::JsonDecodeError(
30102 encoded.to_string(),
30103 error,
30104 ));
30105 }
30106 }
30107 };
30108
30109 dlg.finished(true);
30110 return Ok(response);
30111 }
30112 }
30113 }
30114 }
30115
30116 ///
30117 /// Sets the *request* property to the given value.
30118 ///
30119 /// Even though the property as already been set when instantiating this call,
30120 /// we provide this method for API completeness.
30121 pub fn request(mut self, new_value: Object) -> ObjectRewriteCall<'a, C> {
30122 self._request = new_value;
30123 self
30124 }
30125 /// Name of the bucket in which to find the source object.
30126 ///
30127 /// Sets the *source bucket* path property to the given value.
30128 ///
30129 /// Even though the property as already been set when instantiating this call,
30130 /// we provide this method for API completeness.
30131 pub fn source_bucket(mut self, new_value: &str) -> ObjectRewriteCall<'a, C> {
30132 self._source_bucket = new_value.to_string();
30133 self
30134 }
30135 /// 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).
30136 ///
30137 /// Sets the *source object* path property to the given value.
30138 ///
30139 /// Even though the property as already been set when instantiating this call,
30140 /// we provide this method for API completeness.
30141 pub fn source_object(mut self, new_value: &str) -> ObjectRewriteCall<'a, C> {
30142 self._source_object = new_value.to_string();
30143 self
30144 }
30145 /// Name of the bucket in which to store the new object. Overrides the provided object metadata's bucket value, if any.
30146 ///
30147 /// Sets the *destination bucket* path property to the given value.
30148 ///
30149 /// Even though the property as already been set when instantiating this call,
30150 /// we provide this method for API completeness.
30151 pub fn destination_bucket(mut self, new_value: &str) -> ObjectRewriteCall<'a, C> {
30152 self._destination_bucket = new_value.to_string();
30153 self
30154 }
30155 /// 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).
30156 ///
30157 /// Sets the *destination object* path property to the given value.
30158 ///
30159 /// Even though the property as already been set when instantiating this call,
30160 /// we provide this method for API completeness.
30161 pub fn destination_object(mut self, new_value: &str) -> ObjectRewriteCall<'a, C> {
30162 self._destination_object = new_value.to_string();
30163 self
30164 }
30165 /// The project to be billed for this request. Required for Requester Pays buckets.
30166 ///
30167 /// Sets the *user project* query property to the given value.
30168 pub fn user_project(mut self, new_value: &str) -> ObjectRewriteCall<'a, C> {
30169 self._user_project = Some(new_value.to_string());
30170 self
30171 }
30172 /// If present, selects a specific revision of the source object (as opposed to the latest version, the default).
30173 ///
30174 /// Sets the *source generation* query property to the given value.
30175 pub fn source_generation(mut self, new_value: i64) -> ObjectRewriteCall<'a, C> {
30176 self._source_generation = Some(new_value);
30177 self
30178 }
30179 /// 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.
30180 ///
30181 /// Sets the *rewrite token* query property to the given value.
30182 pub fn rewrite_token(mut self, new_value: &str) -> ObjectRewriteCall<'a, C> {
30183 self._rewrite_token = Some(new_value.to_string());
30184 self
30185 }
30186 /// Set of properties to return. Defaults to noAcl, unless the object resource specifies the acl property, when it defaults to full.
30187 ///
30188 /// Sets the *projection* query property to the given value.
30189 pub fn projection(mut self, new_value: &str) -> ObjectRewriteCall<'a, C> {
30190 self._projection = Some(new_value.to_string());
30191 self
30192 }
30193 /// 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.
30194 ///
30195 /// Sets the *max bytes rewritten per call* query property to the given value.
30196 pub fn max_bytes_rewritten_per_call(mut self, new_value: i64) -> ObjectRewriteCall<'a, C> {
30197 self._max_bytes_rewritten_per_call = Some(new_value);
30198 self
30199 }
30200 /// Makes the operation conditional on whether the source object's current metageneration does not match the given value.
30201 ///
30202 /// Sets the *if source metageneration not match* query property to the given value.
30203 pub fn if_source_metageneration_not_match(
30204 mut self,
30205 new_value: i64,
30206 ) -> ObjectRewriteCall<'a, C> {
30207 self._if_source_metageneration_not_match = Some(new_value);
30208 self
30209 }
30210 /// Makes the operation conditional on whether the source object's current metageneration matches the given value.
30211 ///
30212 /// Sets the *if source metageneration match* query property to the given value.
30213 pub fn if_source_metageneration_match(mut self, new_value: i64) -> ObjectRewriteCall<'a, C> {
30214 self._if_source_metageneration_match = Some(new_value);
30215 self
30216 }
30217 /// Makes the operation conditional on whether the source object's current generation does not match the given value.
30218 ///
30219 /// Sets the *if source generation not match* query property to the given value.
30220 pub fn if_source_generation_not_match(mut self, new_value: i64) -> ObjectRewriteCall<'a, C> {
30221 self._if_source_generation_not_match = Some(new_value);
30222 self
30223 }
30224 /// Makes the operation conditional on whether the source object's current generation matches the given value.
30225 ///
30226 /// Sets the *if source generation match* query property to the given value.
30227 pub fn if_source_generation_match(mut self, new_value: i64) -> ObjectRewriteCall<'a, C> {
30228 self._if_source_generation_match = Some(new_value);
30229 self
30230 }
30231 /// Makes the operation conditional on whether the destination object's current metageneration does not match the given value.
30232 ///
30233 /// Sets the *if metageneration not match* query property to the given value.
30234 pub fn if_metageneration_not_match(mut self, new_value: i64) -> ObjectRewriteCall<'a, C> {
30235 self._if_metageneration_not_match = Some(new_value);
30236 self
30237 }
30238 /// Makes the operation conditional on whether the destination object's current metageneration matches the given value.
30239 ///
30240 /// Sets the *if metageneration match* query property to the given value.
30241 pub fn if_metageneration_match(mut self, new_value: i64) -> ObjectRewriteCall<'a, C> {
30242 self._if_metageneration_match = Some(new_value);
30243 self
30244 }
30245 /// 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.
30246 ///
30247 /// Sets the *if generation not match* query property to the given value.
30248 pub fn if_generation_not_match(mut self, new_value: i64) -> ObjectRewriteCall<'a, C> {
30249 self._if_generation_not_match = Some(new_value);
30250 self
30251 }
30252 /// 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.
30253 ///
30254 /// Sets the *if generation match* query property to the given value.
30255 pub fn if_generation_match(mut self, new_value: i64) -> ObjectRewriteCall<'a, C> {
30256 self._if_generation_match = Some(new_value);
30257 self
30258 }
30259 /// Apply a predefined set of access controls to the destination object.
30260 ///
30261 /// Sets the *destination predefined acl* query property to the given value.
30262 pub fn destination_predefined_acl(mut self, new_value: &str) -> ObjectRewriteCall<'a, C> {
30263 self._destination_predefined_acl = Some(new_value.to_string());
30264 self
30265 }
30266 /// 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.
30267 ///
30268 /// Sets the *destination kms key name* query property to the given value.
30269 pub fn destination_kms_key_name(mut self, new_value: &str) -> ObjectRewriteCall<'a, C> {
30270 self._destination_kms_key_name = Some(new_value.to_string());
30271 self
30272 }
30273 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30274 /// while executing the actual API request.
30275 ///
30276 /// ````text
30277 /// It should be used to handle progress information, and to implement a certain level of resilience.
30278 /// ````
30279 ///
30280 /// Sets the *delegate* property to the given value.
30281 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ObjectRewriteCall<'a, C> {
30282 self._delegate = Some(new_value);
30283 self
30284 }
30285
30286 /// Set any additional parameter of the query string used in the request.
30287 /// It should be used to set parameters which are not yet available through their own
30288 /// setters.
30289 ///
30290 /// Please note that this method must not be used to set any of the known parameters
30291 /// which have their own setter method. If done anyway, the request will fail.
30292 ///
30293 /// # Additional Parameters
30294 ///
30295 /// * *alt* (query-string) - Data format for the response.
30296 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30297 /// * *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.
30298 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30299 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30300 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
30301 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
30302 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
30303 pub fn param<T>(mut self, name: T, value: T) -> ObjectRewriteCall<'a, C>
30304 where
30305 T: AsRef<str>,
30306 {
30307 self._additional_params
30308 .insert(name.as_ref().to_string(), value.as_ref().to_string());
30309 self
30310 }
30311
30312 /// Identifies the authorization scope for the method you are building.
30313 ///
30314 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30315 /// [`Scope::DevstorageReadWrite`].
30316 ///
30317 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30318 /// tokens for more than one scope.
30319 ///
30320 /// Usually there is more than one suitable scope to authorize an operation, some of which may
30321 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30322 /// sufficient, a read-write scope will do as well.
30323 pub fn add_scope<St>(mut self, scope: St) -> ObjectRewriteCall<'a, C>
30324 where
30325 St: AsRef<str>,
30326 {
30327 self._scopes.insert(String::from(scope.as_ref()));
30328 self
30329 }
30330 /// Identifies the authorization scope(s) for the method you are building.
30331 ///
30332 /// See [`Self::add_scope()`] for details.
30333 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectRewriteCall<'a, C>
30334 where
30335 I: IntoIterator<Item = St>,
30336 St: AsRef<str>,
30337 {
30338 self._scopes
30339 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30340 self
30341 }
30342
30343 /// Removes all scopes, and no default scope will be used either.
30344 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30345 /// for details).
30346 pub fn clear_scopes(mut self) -> ObjectRewriteCall<'a, C> {
30347 self._scopes.clear();
30348 self
30349 }
30350}
30351
30352/// Updates an IAM policy for the specified object.
30353///
30354/// A builder for the *setIamPolicy* method supported by a *object* resource.
30355/// It is not used directly, but through a [`ObjectMethods`] instance.
30356///
30357/// # Example
30358///
30359/// Instantiate a resource method builder
30360///
30361/// ```test_harness,no_run
30362/// # extern crate hyper;
30363/// # extern crate hyper_rustls;
30364/// # extern crate google_storage1 as storage1;
30365/// use storage1::api::Policy;
30366/// # async fn dox() {
30367/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30368///
30369/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30370/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
30371/// # .with_native_roots()
30372/// # .unwrap()
30373/// # .https_only()
30374/// # .enable_http2()
30375/// # .build();
30376///
30377/// # let executor = hyper_util::rt::TokioExecutor::new();
30378/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
30379/// # secret,
30380/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30381/// # yup_oauth2::client::CustomHyperClientBuilder::from(
30382/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
30383/// # ),
30384/// # ).build().await.unwrap();
30385///
30386/// # let client = hyper_util::client::legacy::Client::builder(
30387/// # hyper_util::rt::TokioExecutor::new()
30388/// # )
30389/// # .build(
30390/// # hyper_rustls::HttpsConnectorBuilder::new()
30391/// # .with_native_roots()
30392/// # .unwrap()
30393/// # .https_or_http()
30394/// # .enable_http2()
30395/// # .build()
30396/// # );
30397/// # let mut hub = Storage::new(client, auth);
30398/// // As the method needs a request, you would usually fill it with the desired information
30399/// // into the respective structure. Some of the parts shown here might not be applicable !
30400/// // Values shown here are possibly random and not representative !
30401/// let mut req = Policy::default();
30402///
30403/// // You can configure optional parameters by calling the respective setters at will, and
30404/// // execute the final call using `doit()`.
30405/// // Values shown here are possibly random and not representative !
30406/// let result = hub.objects().set_iam_policy(req, "bucket", "object")
30407/// .user_project("eirmod")
30408/// .generation(-4)
30409/// .doit().await;
30410/// # }
30411/// ```
30412pub struct ObjectSetIamPolicyCall<'a, C>
30413where
30414 C: 'a,
30415{
30416 hub: &'a Storage<C>,
30417 _request: Policy,
30418 _bucket: String,
30419 _object: String,
30420 _user_project: Option<String>,
30421 _generation: Option<i64>,
30422 _delegate: Option<&'a mut dyn common::Delegate>,
30423 _additional_params: HashMap<String, String>,
30424 _scopes: BTreeSet<String>,
30425}
30426
30427impl<'a, C> common::CallBuilder for ObjectSetIamPolicyCall<'a, C> {}
30428
30429impl<'a, C> ObjectSetIamPolicyCall<'a, C>
30430where
30431 C: common::Connector,
30432{
30433 /// Perform the operation you have build so far.
30434 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
30435 use std::borrow::Cow;
30436 use std::io::{Read, Seek};
30437
30438 use common::{url::Params, ToParts};
30439 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30440
30441 let mut dd = common::DefaultDelegate;
30442 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30443 dlg.begin(common::MethodInfo {
30444 id: "storage.objects.setIamPolicy",
30445 http_method: hyper::Method::PUT,
30446 });
30447
30448 for &field in ["alt", "bucket", "object", "userProject", "generation"].iter() {
30449 if self._additional_params.contains_key(field) {
30450 dlg.finished(false);
30451 return Err(common::Error::FieldClash(field));
30452 }
30453 }
30454
30455 let mut params = Params::with_capacity(7 + self._additional_params.len());
30456 params.push("bucket", self._bucket);
30457 params.push("object", self._object);
30458 if let Some(value) = self._user_project.as_ref() {
30459 params.push("userProject", value);
30460 }
30461 if let Some(value) = self._generation.as_ref() {
30462 params.push("generation", value.to_string());
30463 }
30464
30465 params.extend(self._additional_params.iter());
30466
30467 params.push("alt", "json");
30468 let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}/iam";
30469 if self._scopes.is_empty() {
30470 self._scopes
30471 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
30472 }
30473
30474 #[allow(clippy::single_element_loop)]
30475 for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object")].iter() {
30476 url = params.uri_replacement(url, param_name, find_this, false);
30477 }
30478 {
30479 let to_remove = ["object", "bucket"];
30480 params.remove_params(&to_remove);
30481 }
30482
30483 let url = params.parse_with_url(&url);
30484
30485 let mut json_mime_type = mime::APPLICATION_JSON;
30486 let mut request_value_reader = {
30487 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
30488 common::remove_json_null_values(&mut value);
30489 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
30490 serde_json::to_writer(&mut dst, &value).unwrap();
30491 dst
30492 };
30493 let request_size = request_value_reader
30494 .seek(std::io::SeekFrom::End(0))
30495 .unwrap();
30496 request_value_reader
30497 .seek(std::io::SeekFrom::Start(0))
30498 .unwrap();
30499
30500 loop {
30501 let token = match self
30502 .hub
30503 .auth
30504 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30505 .await
30506 {
30507 Ok(token) => token,
30508 Err(e) => match dlg.token(e) {
30509 Ok(token) => token,
30510 Err(e) => {
30511 dlg.finished(false);
30512 return Err(common::Error::MissingToken(e));
30513 }
30514 },
30515 };
30516 request_value_reader
30517 .seek(std::io::SeekFrom::Start(0))
30518 .unwrap();
30519 let mut req_result = {
30520 let client = &self.hub.client;
30521 dlg.pre_request();
30522 let mut req_builder = hyper::Request::builder()
30523 .method(hyper::Method::PUT)
30524 .uri(url.as_str())
30525 .header(USER_AGENT, self.hub._user_agent.clone());
30526
30527 if let Some(token) = token.as_ref() {
30528 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30529 }
30530
30531 let request = req_builder
30532 .header(CONTENT_TYPE, json_mime_type.to_string())
30533 .header(CONTENT_LENGTH, request_size as u64)
30534 .body(common::to_body(
30535 request_value_reader.get_ref().clone().into(),
30536 ));
30537
30538 client.request(request.unwrap()).await
30539 };
30540
30541 match req_result {
30542 Err(err) => {
30543 if let common::Retry::After(d) = dlg.http_error(&err) {
30544 sleep(d).await;
30545 continue;
30546 }
30547 dlg.finished(false);
30548 return Err(common::Error::HttpError(err));
30549 }
30550 Ok(res) => {
30551 let (mut parts, body) = res.into_parts();
30552 let mut body = common::Body::new(body);
30553 if !parts.status.is_success() {
30554 let bytes = common::to_bytes(body).await.unwrap_or_default();
30555 let error = serde_json::from_str(&common::to_string(&bytes));
30556 let response = common::to_response(parts, bytes.into());
30557
30558 if let common::Retry::After(d) =
30559 dlg.http_failure(&response, error.as_ref().ok())
30560 {
30561 sleep(d).await;
30562 continue;
30563 }
30564
30565 dlg.finished(false);
30566
30567 return Err(match error {
30568 Ok(value) => common::Error::BadRequest(value),
30569 _ => common::Error::Failure(response),
30570 });
30571 }
30572 let response = {
30573 let bytes = common::to_bytes(body).await.unwrap_or_default();
30574 let encoded = common::to_string(&bytes);
30575 match serde_json::from_str(&encoded) {
30576 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30577 Err(error) => {
30578 dlg.response_json_decode_error(&encoded, &error);
30579 return Err(common::Error::JsonDecodeError(
30580 encoded.to_string(),
30581 error,
30582 ));
30583 }
30584 }
30585 };
30586
30587 dlg.finished(true);
30588 return Ok(response);
30589 }
30590 }
30591 }
30592 }
30593
30594 ///
30595 /// Sets the *request* property to the given value.
30596 ///
30597 /// Even though the property as already been set when instantiating this call,
30598 /// we provide this method for API completeness.
30599 pub fn request(mut self, new_value: Policy) -> ObjectSetIamPolicyCall<'a, C> {
30600 self._request = new_value;
30601 self
30602 }
30603 /// Name of the bucket in which the object resides.
30604 ///
30605 /// Sets the *bucket* path property to the given value.
30606 ///
30607 /// Even though the property as already been set when instantiating this call,
30608 /// we provide this method for API completeness.
30609 pub fn bucket(mut self, new_value: &str) -> ObjectSetIamPolicyCall<'a, C> {
30610 self._bucket = new_value.to_string();
30611 self
30612 }
30613 /// 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).
30614 ///
30615 /// Sets the *object* path property to the given value.
30616 ///
30617 /// Even though the property as already been set when instantiating this call,
30618 /// we provide this method for API completeness.
30619 pub fn object(mut self, new_value: &str) -> ObjectSetIamPolicyCall<'a, C> {
30620 self._object = new_value.to_string();
30621 self
30622 }
30623 /// The project to be billed for this request. Required for Requester Pays buckets.
30624 ///
30625 /// Sets the *user project* query property to the given value.
30626 pub fn user_project(mut self, new_value: &str) -> ObjectSetIamPolicyCall<'a, C> {
30627 self._user_project = Some(new_value.to_string());
30628 self
30629 }
30630 /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
30631 ///
30632 /// Sets the *generation* query property to the given value.
30633 pub fn generation(mut self, new_value: i64) -> ObjectSetIamPolicyCall<'a, C> {
30634 self._generation = Some(new_value);
30635 self
30636 }
30637 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30638 /// while executing the actual API request.
30639 ///
30640 /// ````text
30641 /// It should be used to handle progress information, and to implement a certain level of resilience.
30642 /// ````
30643 ///
30644 /// Sets the *delegate* property to the given value.
30645 pub fn delegate(
30646 mut self,
30647 new_value: &'a mut dyn common::Delegate,
30648 ) -> ObjectSetIamPolicyCall<'a, C> {
30649 self._delegate = Some(new_value);
30650 self
30651 }
30652
30653 /// Set any additional parameter of the query string used in the request.
30654 /// It should be used to set parameters which are not yet available through their own
30655 /// setters.
30656 ///
30657 /// Please note that this method must not be used to set any of the known parameters
30658 /// which have their own setter method. If done anyway, the request will fail.
30659 ///
30660 /// # Additional Parameters
30661 ///
30662 /// * *alt* (query-string) - Data format for the response.
30663 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30664 /// * *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.
30665 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30666 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30667 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
30668 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
30669 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
30670 pub fn param<T>(mut self, name: T, value: T) -> ObjectSetIamPolicyCall<'a, C>
30671 where
30672 T: AsRef<str>,
30673 {
30674 self._additional_params
30675 .insert(name.as_ref().to_string(), value.as_ref().to_string());
30676 self
30677 }
30678
30679 /// Identifies the authorization scope for the method you are building.
30680 ///
30681 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30682 /// [`Scope::DevstorageReadWrite`].
30683 ///
30684 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30685 /// tokens for more than one scope.
30686 ///
30687 /// Usually there is more than one suitable scope to authorize an operation, some of which may
30688 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30689 /// sufficient, a read-write scope will do as well.
30690 pub fn add_scope<St>(mut self, scope: St) -> ObjectSetIamPolicyCall<'a, C>
30691 where
30692 St: AsRef<str>,
30693 {
30694 self._scopes.insert(String::from(scope.as_ref()));
30695 self
30696 }
30697 /// Identifies the authorization scope(s) for the method you are building.
30698 ///
30699 /// See [`Self::add_scope()`] for details.
30700 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectSetIamPolicyCall<'a, C>
30701 where
30702 I: IntoIterator<Item = St>,
30703 St: AsRef<str>,
30704 {
30705 self._scopes
30706 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30707 self
30708 }
30709
30710 /// Removes all scopes, and no default scope will be used either.
30711 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30712 /// for details).
30713 pub fn clear_scopes(mut self) -> ObjectSetIamPolicyCall<'a, C> {
30714 self._scopes.clear();
30715 self
30716 }
30717}
30718
30719/// Tests a set of permissions on the given object to see which, if any, are held by the caller.
30720///
30721/// A builder for the *testIamPermissions* method supported by a *object* resource.
30722/// It is not used directly, but through a [`ObjectMethods`] instance.
30723///
30724/// # Example
30725///
30726/// Instantiate a resource method builder
30727///
30728/// ```test_harness,no_run
30729/// # extern crate hyper;
30730/// # extern crate hyper_rustls;
30731/// # extern crate google_storage1 as storage1;
30732/// # async fn dox() {
30733/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30734///
30735/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30736/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
30737/// # .with_native_roots()
30738/// # .unwrap()
30739/// # .https_only()
30740/// # .enable_http2()
30741/// # .build();
30742///
30743/// # let executor = hyper_util::rt::TokioExecutor::new();
30744/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
30745/// # secret,
30746/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30747/// # yup_oauth2::client::CustomHyperClientBuilder::from(
30748/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
30749/// # ),
30750/// # ).build().await.unwrap();
30751///
30752/// # let client = hyper_util::client::legacy::Client::builder(
30753/// # hyper_util::rt::TokioExecutor::new()
30754/// # )
30755/// # .build(
30756/// # hyper_rustls::HttpsConnectorBuilder::new()
30757/// # .with_native_roots()
30758/// # .unwrap()
30759/// # .https_or_http()
30760/// # .enable_http2()
30761/// # .build()
30762/// # );
30763/// # let mut hub = Storage::new(client, auth);
30764/// // You can configure optional parameters by calling the respective setters at will, and
30765/// // execute the final call using `doit()`.
30766/// // Values shown here are possibly random and not representative !
30767/// let result = hub.objects().test_iam_permissions("bucket", "object", &vec!["dolor".into()])
30768/// .user_project("consetetur")
30769/// .generation(-22)
30770/// .doit().await;
30771/// # }
30772/// ```
30773pub struct ObjectTestIamPermissionCall<'a, C>
30774where
30775 C: 'a,
30776{
30777 hub: &'a Storage<C>,
30778 _bucket: String,
30779 _object: String,
30780 _permissions: Vec<String>,
30781 _user_project: Option<String>,
30782 _generation: Option<i64>,
30783 _delegate: Option<&'a mut dyn common::Delegate>,
30784 _additional_params: HashMap<String, String>,
30785 _scopes: BTreeSet<String>,
30786}
30787
30788impl<'a, C> common::CallBuilder for ObjectTestIamPermissionCall<'a, C> {}
30789
30790impl<'a, C> ObjectTestIamPermissionCall<'a, C>
30791where
30792 C: common::Connector,
30793{
30794 /// Perform the operation you have build so far.
30795 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
30796 use std::borrow::Cow;
30797 use std::io::{Read, Seek};
30798
30799 use common::{url::Params, ToParts};
30800 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30801
30802 let mut dd = common::DefaultDelegate;
30803 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30804 dlg.begin(common::MethodInfo {
30805 id: "storage.objects.testIamPermissions",
30806 http_method: hyper::Method::GET,
30807 });
30808
30809 for &field in [
30810 "alt",
30811 "bucket",
30812 "object",
30813 "permissions",
30814 "userProject",
30815 "generation",
30816 ]
30817 .iter()
30818 {
30819 if self._additional_params.contains_key(field) {
30820 dlg.finished(false);
30821 return Err(common::Error::FieldClash(field));
30822 }
30823 }
30824
30825 let mut params = Params::with_capacity(7 + self._additional_params.len());
30826 params.push("bucket", self._bucket);
30827 params.push("object", self._object);
30828 if !self._permissions.is_empty() {
30829 for f in self._permissions.iter() {
30830 params.push("permissions", f);
30831 }
30832 }
30833 if let Some(value) = self._user_project.as_ref() {
30834 params.push("userProject", value);
30835 }
30836 if let Some(value) = self._generation.as_ref() {
30837 params.push("generation", value.to_string());
30838 }
30839
30840 params.extend(self._additional_params.iter());
30841
30842 params.push("alt", "json");
30843 let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}/iam/testPermissions";
30844 if self._scopes.is_empty() {
30845 self._scopes
30846 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
30847 }
30848
30849 #[allow(clippy::single_element_loop)]
30850 for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object")].iter() {
30851 url = params.uri_replacement(url, param_name, find_this, false);
30852 }
30853 {
30854 let to_remove = ["object", "bucket"];
30855 params.remove_params(&to_remove);
30856 }
30857
30858 let url = params.parse_with_url(&url);
30859
30860 loop {
30861 let token = match self
30862 .hub
30863 .auth
30864 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30865 .await
30866 {
30867 Ok(token) => token,
30868 Err(e) => match dlg.token(e) {
30869 Ok(token) => token,
30870 Err(e) => {
30871 dlg.finished(false);
30872 return Err(common::Error::MissingToken(e));
30873 }
30874 },
30875 };
30876 let mut req_result = {
30877 let client = &self.hub.client;
30878 dlg.pre_request();
30879 let mut req_builder = hyper::Request::builder()
30880 .method(hyper::Method::GET)
30881 .uri(url.as_str())
30882 .header(USER_AGENT, self.hub._user_agent.clone());
30883
30884 if let Some(token) = token.as_ref() {
30885 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30886 }
30887
30888 let request = req_builder
30889 .header(CONTENT_LENGTH, 0_u64)
30890 .body(common::to_body::<String>(None));
30891
30892 client.request(request.unwrap()).await
30893 };
30894
30895 match req_result {
30896 Err(err) => {
30897 if let common::Retry::After(d) = dlg.http_error(&err) {
30898 sleep(d).await;
30899 continue;
30900 }
30901 dlg.finished(false);
30902 return Err(common::Error::HttpError(err));
30903 }
30904 Ok(res) => {
30905 let (mut parts, body) = res.into_parts();
30906 let mut body = common::Body::new(body);
30907 if !parts.status.is_success() {
30908 let bytes = common::to_bytes(body).await.unwrap_or_default();
30909 let error = serde_json::from_str(&common::to_string(&bytes));
30910 let response = common::to_response(parts, bytes.into());
30911
30912 if let common::Retry::After(d) =
30913 dlg.http_failure(&response, error.as_ref().ok())
30914 {
30915 sleep(d).await;
30916 continue;
30917 }
30918
30919 dlg.finished(false);
30920
30921 return Err(match error {
30922 Ok(value) => common::Error::BadRequest(value),
30923 _ => common::Error::Failure(response),
30924 });
30925 }
30926 let response = {
30927 let bytes = common::to_bytes(body).await.unwrap_or_default();
30928 let encoded = common::to_string(&bytes);
30929 match serde_json::from_str(&encoded) {
30930 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30931 Err(error) => {
30932 dlg.response_json_decode_error(&encoded, &error);
30933 return Err(common::Error::JsonDecodeError(
30934 encoded.to_string(),
30935 error,
30936 ));
30937 }
30938 }
30939 };
30940
30941 dlg.finished(true);
30942 return Ok(response);
30943 }
30944 }
30945 }
30946 }
30947
30948 /// Name of the bucket in which the object resides.
30949 ///
30950 /// Sets the *bucket* path property to the given value.
30951 ///
30952 /// Even though the property as already been set when instantiating this call,
30953 /// we provide this method for API completeness.
30954 pub fn bucket(mut self, new_value: &str) -> ObjectTestIamPermissionCall<'a, C> {
30955 self._bucket = new_value.to_string();
30956 self
30957 }
30958 /// 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).
30959 ///
30960 /// Sets the *object* path property to the given value.
30961 ///
30962 /// Even though the property as already been set when instantiating this call,
30963 /// we provide this method for API completeness.
30964 pub fn object(mut self, new_value: &str) -> ObjectTestIamPermissionCall<'a, C> {
30965 self._object = new_value.to_string();
30966 self
30967 }
30968 /// Permissions to test.
30969 ///
30970 /// Append the given value to the *permissions* query property.
30971 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
30972 ///
30973 /// Even though the property as already been set when instantiating this call,
30974 /// we provide this method for API completeness.
30975 pub fn add_permissions(mut self, new_value: &str) -> ObjectTestIamPermissionCall<'a, C> {
30976 self._permissions.push(new_value.to_string());
30977 self
30978 }
30979 /// The project to be billed for this request. Required for Requester Pays buckets.
30980 ///
30981 /// Sets the *user project* query property to the given value.
30982 pub fn user_project(mut self, new_value: &str) -> ObjectTestIamPermissionCall<'a, C> {
30983 self._user_project = Some(new_value.to_string());
30984 self
30985 }
30986 /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
30987 ///
30988 /// Sets the *generation* query property to the given value.
30989 pub fn generation(mut self, new_value: i64) -> ObjectTestIamPermissionCall<'a, C> {
30990 self._generation = Some(new_value);
30991 self
30992 }
30993 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30994 /// while executing the actual API request.
30995 ///
30996 /// ````text
30997 /// It should be used to handle progress information, and to implement a certain level of resilience.
30998 /// ````
30999 ///
31000 /// Sets the *delegate* property to the given value.
31001 pub fn delegate(
31002 mut self,
31003 new_value: &'a mut dyn common::Delegate,
31004 ) -> ObjectTestIamPermissionCall<'a, C> {
31005 self._delegate = Some(new_value);
31006 self
31007 }
31008
31009 /// Set any additional parameter of the query string used in the request.
31010 /// It should be used to set parameters which are not yet available through their own
31011 /// setters.
31012 ///
31013 /// Please note that this method must not be used to set any of the known parameters
31014 /// which have their own setter method. If done anyway, the request will fail.
31015 ///
31016 /// # Additional Parameters
31017 ///
31018 /// * *alt* (query-string) - Data format for the response.
31019 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31020 /// * *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.
31021 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31022 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31023 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
31024 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
31025 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
31026 pub fn param<T>(mut self, name: T, value: T) -> ObjectTestIamPermissionCall<'a, C>
31027 where
31028 T: AsRef<str>,
31029 {
31030 self._additional_params
31031 .insert(name.as_ref().to_string(), value.as_ref().to_string());
31032 self
31033 }
31034
31035 /// Identifies the authorization scope for the method you are building.
31036 ///
31037 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31038 /// [`Scope::DevstorageReadOnly`].
31039 ///
31040 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31041 /// tokens for more than one scope.
31042 ///
31043 /// Usually there is more than one suitable scope to authorize an operation, some of which may
31044 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31045 /// sufficient, a read-write scope will do as well.
31046 pub fn add_scope<St>(mut self, scope: St) -> ObjectTestIamPermissionCall<'a, C>
31047 where
31048 St: AsRef<str>,
31049 {
31050 self._scopes.insert(String::from(scope.as_ref()));
31051 self
31052 }
31053 /// Identifies the authorization scope(s) for the method you are building.
31054 ///
31055 /// See [`Self::add_scope()`] for details.
31056 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectTestIamPermissionCall<'a, C>
31057 where
31058 I: IntoIterator<Item = St>,
31059 St: AsRef<str>,
31060 {
31061 self._scopes
31062 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31063 self
31064 }
31065
31066 /// Removes all scopes, and no default scope will be used either.
31067 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31068 /// for details).
31069 pub fn clear_scopes(mut self) -> ObjectTestIamPermissionCall<'a, C> {
31070 self._scopes.clear();
31071 self
31072 }
31073}
31074
31075/// Updates an object's metadata.
31076///
31077/// A builder for the *update* method supported by a *object* resource.
31078/// It is not used directly, but through a [`ObjectMethods`] instance.
31079///
31080/// # Example
31081///
31082/// Instantiate a resource method builder
31083///
31084/// ```test_harness,no_run
31085/// # extern crate hyper;
31086/// # extern crate hyper_rustls;
31087/// # extern crate google_storage1 as storage1;
31088/// use storage1::api::Object;
31089/// # async fn dox() {
31090/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31091///
31092/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31093/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
31094/// # .with_native_roots()
31095/// # .unwrap()
31096/// # .https_only()
31097/// # .enable_http2()
31098/// # .build();
31099///
31100/// # let executor = hyper_util::rt::TokioExecutor::new();
31101/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
31102/// # secret,
31103/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31104/// # yup_oauth2::client::CustomHyperClientBuilder::from(
31105/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
31106/// # ),
31107/// # ).build().await.unwrap();
31108///
31109/// # let client = hyper_util::client::legacy::Client::builder(
31110/// # hyper_util::rt::TokioExecutor::new()
31111/// # )
31112/// # .build(
31113/// # hyper_rustls::HttpsConnectorBuilder::new()
31114/// # .with_native_roots()
31115/// # .unwrap()
31116/// # .https_or_http()
31117/// # .enable_http2()
31118/// # .build()
31119/// # );
31120/// # let mut hub = Storage::new(client, auth);
31121/// // As the method needs a request, you would usually fill it with the desired information
31122/// // into the respective structure. Some of the parts shown here might not be applicable !
31123/// // Values shown here are possibly random and not representative !
31124/// let mut req = Object::default();
31125///
31126/// // You can configure optional parameters by calling the respective setters at will, and
31127/// // execute the final call using `doit()`.
31128/// // Values shown here are possibly random and not representative !
31129/// let result = hub.objects().update(req, "bucket", "object")
31130/// .user_project("nonumy")
31131/// .projection("diam")
31132/// .predefined_acl("ipsum")
31133/// .override_unlocked_retention(true)
31134/// .if_metageneration_not_match(-15)
31135/// .if_metageneration_match(-78)
31136/// .if_generation_not_match(-77)
31137/// .if_generation_match(-92)
31138/// .generation(-47)
31139/// .doit().await;
31140/// # }
31141/// ```
31142pub struct ObjectUpdateCall<'a, C>
31143where
31144 C: 'a,
31145{
31146 hub: &'a Storage<C>,
31147 _request: Object,
31148 _bucket: String,
31149 _object: String,
31150 _user_project: Option<String>,
31151 _projection: Option<String>,
31152 _predefined_acl: Option<String>,
31153 _override_unlocked_retention: Option<bool>,
31154 _if_metageneration_not_match: Option<i64>,
31155 _if_metageneration_match: Option<i64>,
31156 _if_generation_not_match: Option<i64>,
31157 _if_generation_match: Option<i64>,
31158 _generation: Option<i64>,
31159 _delegate: Option<&'a mut dyn common::Delegate>,
31160 _additional_params: HashMap<String, String>,
31161 _scopes: BTreeSet<String>,
31162}
31163
31164impl<'a, C> common::CallBuilder for ObjectUpdateCall<'a, C> {}
31165
31166impl<'a, C> ObjectUpdateCall<'a, C>
31167where
31168 C: common::Connector,
31169{
31170 /// Perform the operation you have build so far.
31171 pub async fn doit(mut self) -> common::Result<(common::Response, Object)> {
31172 use std::borrow::Cow;
31173 use std::io::{Read, Seek};
31174
31175 use common::{url::Params, ToParts};
31176 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31177
31178 let mut dd = common::DefaultDelegate;
31179 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31180 dlg.begin(common::MethodInfo {
31181 id: "storage.objects.update",
31182 http_method: hyper::Method::PUT,
31183 });
31184
31185 for &field in [
31186 "alt",
31187 "bucket",
31188 "object",
31189 "userProject",
31190 "projection",
31191 "predefinedAcl",
31192 "overrideUnlockedRetention",
31193 "ifMetagenerationNotMatch",
31194 "ifMetagenerationMatch",
31195 "ifGenerationNotMatch",
31196 "ifGenerationMatch",
31197 "generation",
31198 ]
31199 .iter()
31200 {
31201 if self._additional_params.contains_key(field) {
31202 dlg.finished(false);
31203 return Err(common::Error::FieldClash(field));
31204 }
31205 }
31206
31207 let mut params = Params::with_capacity(14 + self._additional_params.len());
31208 params.push("bucket", self._bucket);
31209 params.push("object", self._object);
31210 if let Some(value) = self._user_project.as_ref() {
31211 params.push("userProject", value);
31212 }
31213 if let Some(value) = self._projection.as_ref() {
31214 params.push("projection", value);
31215 }
31216 if let Some(value) = self._predefined_acl.as_ref() {
31217 params.push("predefinedAcl", value);
31218 }
31219 if let Some(value) = self._override_unlocked_retention.as_ref() {
31220 params.push("overrideUnlockedRetention", value.to_string());
31221 }
31222 if let Some(value) = self._if_metageneration_not_match.as_ref() {
31223 params.push("ifMetagenerationNotMatch", value.to_string());
31224 }
31225 if let Some(value) = self._if_metageneration_match.as_ref() {
31226 params.push("ifMetagenerationMatch", value.to_string());
31227 }
31228 if let Some(value) = self._if_generation_not_match.as_ref() {
31229 params.push("ifGenerationNotMatch", value.to_string());
31230 }
31231 if let Some(value) = self._if_generation_match.as_ref() {
31232 params.push("ifGenerationMatch", value.to_string());
31233 }
31234 if let Some(value) = self._generation.as_ref() {
31235 params.push("generation", value.to_string());
31236 }
31237
31238 params.extend(self._additional_params.iter());
31239
31240 params.push("alt", "json");
31241 let mut url = self.hub._base_url.clone() + "b/{bucket}/o/{object}";
31242 if self._scopes.is_empty() {
31243 self._scopes
31244 .insert(Scope::DevstorageFullControl.as_ref().to_string());
31245 }
31246
31247 #[allow(clippy::single_element_loop)]
31248 for &(find_this, param_name) in [("{bucket}", "bucket"), ("{object}", "object")].iter() {
31249 url = params.uri_replacement(url, param_name, find_this, false);
31250 }
31251 {
31252 let to_remove = ["object", "bucket"];
31253 params.remove_params(&to_remove);
31254 }
31255
31256 let url = params.parse_with_url(&url);
31257
31258 let mut json_mime_type = mime::APPLICATION_JSON;
31259 let mut request_value_reader = {
31260 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
31261 common::remove_json_null_values(&mut value);
31262 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
31263 serde_json::to_writer(&mut dst, &value).unwrap();
31264 dst
31265 };
31266 let request_size = request_value_reader
31267 .seek(std::io::SeekFrom::End(0))
31268 .unwrap();
31269 request_value_reader
31270 .seek(std::io::SeekFrom::Start(0))
31271 .unwrap();
31272
31273 loop {
31274 let token = match self
31275 .hub
31276 .auth
31277 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31278 .await
31279 {
31280 Ok(token) => token,
31281 Err(e) => match dlg.token(e) {
31282 Ok(token) => token,
31283 Err(e) => {
31284 dlg.finished(false);
31285 return Err(common::Error::MissingToken(e));
31286 }
31287 },
31288 };
31289 request_value_reader
31290 .seek(std::io::SeekFrom::Start(0))
31291 .unwrap();
31292 let mut req_result = {
31293 let client = &self.hub.client;
31294 dlg.pre_request();
31295 let mut req_builder = hyper::Request::builder()
31296 .method(hyper::Method::PUT)
31297 .uri(url.as_str())
31298 .header(USER_AGENT, self.hub._user_agent.clone());
31299
31300 if let Some(token) = token.as_ref() {
31301 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31302 }
31303
31304 let request = req_builder
31305 .header(CONTENT_TYPE, json_mime_type.to_string())
31306 .header(CONTENT_LENGTH, request_size as u64)
31307 .body(common::to_body(
31308 request_value_reader.get_ref().clone().into(),
31309 ));
31310
31311 client.request(request.unwrap()).await
31312 };
31313
31314 match req_result {
31315 Err(err) => {
31316 if let common::Retry::After(d) = dlg.http_error(&err) {
31317 sleep(d).await;
31318 continue;
31319 }
31320 dlg.finished(false);
31321 return Err(common::Error::HttpError(err));
31322 }
31323 Ok(res) => {
31324 let (mut parts, body) = res.into_parts();
31325 let mut body = common::Body::new(body);
31326 if !parts.status.is_success() {
31327 let bytes = common::to_bytes(body).await.unwrap_or_default();
31328 let error = serde_json::from_str(&common::to_string(&bytes));
31329 let response = common::to_response(parts, bytes.into());
31330
31331 if let common::Retry::After(d) =
31332 dlg.http_failure(&response, error.as_ref().ok())
31333 {
31334 sleep(d).await;
31335 continue;
31336 }
31337
31338 dlg.finished(false);
31339
31340 return Err(match error {
31341 Ok(value) => common::Error::BadRequest(value),
31342 _ => common::Error::Failure(response),
31343 });
31344 }
31345 let response = {
31346 let bytes = common::to_bytes(body).await.unwrap_or_default();
31347 let encoded = common::to_string(&bytes);
31348 match serde_json::from_str(&encoded) {
31349 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31350 Err(error) => {
31351 dlg.response_json_decode_error(&encoded, &error);
31352 return Err(common::Error::JsonDecodeError(
31353 encoded.to_string(),
31354 error,
31355 ));
31356 }
31357 }
31358 };
31359
31360 dlg.finished(true);
31361 return Ok(response);
31362 }
31363 }
31364 }
31365 }
31366
31367 ///
31368 /// Sets the *request* property to the given value.
31369 ///
31370 /// Even though the property as already been set when instantiating this call,
31371 /// we provide this method for API completeness.
31372 pub fn request(mut self, new_value: Object) -> ObjectUpdateCall<'a, C> {
31373 self._request = new_value;
31374 self
31375 }
31376 /// Name of the bucket in which the object resides.
31377 ///
31378 /// Sets the *bucket* path property to the given value.
31379 ///
31380 /// Even though the property as already been set when instantiating this call,
31381 /// we provide this method for API completeness.
31382 pub fn bucket(mut self, new_value: &str) -> ObjectUpdateCall<'a, C> {
31383 self._bucket = new_value.to_string();
31384 self
31385 }
31386 /// 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).
31387 ///
31388 /// Sets the *object* path property to the given value.
31389 ///
31390 /// Even though the property as already been set when instantiating this call,
31391 /// we provide this method for API completeness.
31392 pub fn object(mut self, new_value: &str) -> ObjectUpdateCall<'a, C> {
31393 self._object = new_value.to_string();
31394 self
31395 }
31396 /// The project to be billed for this request. Required for Requester Pays buckets.
31397 ///
31398 /// Sets the *user project* query property to the given value.
31399 pub fn user_project(mut self, new_value: &str) -> ObjectUpdateCall<'a, C> {
31400 self._user_project = Some(new_value.to_string());
31401 self
31402 }
31403 /// Set of properties to return. Defaults to full.
31404 ///
31405 /// Sets the *projection* query property to the given value.
31406 pub fn projection(mut self, new_value: &str) -> ObjectUpdateCall<'a, C> {
31407 self._projection = Some(new_value.to_string());
31408 self
31409 }
31410 /// Apply a predefined set of access controls to this object.
31411 ///
31412 /// Sets the *predefined acl* query property to the given value.
31413 pub fn predefined_acl(mut self, new_value: &str) -> ObjectUpdateCall<'a, C> {
31414 self._predefined_acl = Some(new_value.to_string());
31415 self
31416 }
31417 /// Must be true to remove the retention configuration, reduce its unlocked retention period, or change its mode from unlocked to locked.
31418 ///
31419 /// Sets the *override unlocked retention* query property to the given value.
31420 pub fn override_unlocked_retention(mut self, new_value: bool) -> ObjectUpdateCall<'a, C> {
31421 self._override_unlocked_retention = Some(new_value);
31422 self
31423 }
31424 /// Makes the operation conditional on whether the object's current metageneration does not match the given value.
31425 ///
31426 /// Sets the *if metageneration not match* query property to the given value.
31427 pub fn if_metageneration_not_match(mut self, new_value: i64) -> ObjectUpdateCall<'a, C> {
31428 self._if_metageneration_not_match = Some(new_value);
31429 self
31430 }
31431 /// Makes the operation conditional on whether the object's current metageneration matches the given value.
31432 ///
31433 /// Sets the *if metageneration match* query property to the given value.
31434 pub fn if_metageneration_match(mut self, new_value: i64) -> ObjectUpdateCall<'a, C> {
31435 self._if_metageneration_match = Some(new_value);
31436 self
31437 }
31438 /// 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.
31439 ///
31440 /// Sets the *if generation not match* query property to the given value.
31441 pub fn if_generation_not_match(mut self, new_value: i64) -> ObjectUpdateCall<'a, C> {
31442 self._if_generation_not_match = Some(new_value);
31443 self
31444 }
31445 /// 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.
31446 ///
31447 /// Sets the *if generation match* query property to the given value.
31448 pub fn if_generation_match(mut self, new_value: i64) -> ObjectUpdateCall<'a, C> {
31449 self._if_generation_match = Some(new_value);
31450 self
31451 }
31452 /// If present, selects a specific revision of this object (as opposed to the latest version, the default).
31453 ///
31454 /// Sets the *generation* query property to the given value.
31455 pub fn generation(mut self, new_value: i64) -> ObjectUpdateCall<'a, C> {
31456 self._generation = Some(new_value);
31457 self
31458 }
31459 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31460 /// while executing the actual API request.
31461 ///
31462 /// ````text
31463 /// It should be used to handle progress information, and to implement a certain level of resilience.
31464 /// ````
31465 ///
31466 /// Sets the *delegate* property to the given value.
31467 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ObjectUpdateCall<'a, C> {
31468 self._delegate = Some(new_value);
31469 self
31470 }
31471
31472 /// Set any additional parameter of the query string used in the request.
31473 /// It should be used to set parameters which are not yet available through their own
31474 /// setters.
31475 ///
31476 /// Please note that this method must not be used to set any of the known parameters
31477 /// which have their own setter method. If done anyway, the request will fail.
31478 ///
31479 /// # Additional Parameters
31480 ///
31481 /// * *alt* (query-string) - Data format for the response.
31482 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31483 /// * *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.
31484 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31485 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31486 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
31487 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
31488 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
31489 pub fn param<T>(mut self, name: T, value: T) -> ObjectUpdateCall<'a, C>
31490 where
31491 T: AsRef<str>,
31492 {
31493 self._additional_params
31494 .insert(name.as_ref().to_string(), value.as_ref().to_string());
31495 self
31496 }
31497
31498 /// Identifies the authorization scope for the method you are building.
31499 ///
31500 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31501 /// [`Scope::DevstorageFullControl`].
31502 ///
31503 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31504 /// tokens for more than one scope.
31505 ///
31506 /// Usually there is more than one suitable scope to authorize an operation, some of which may
31507 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31508 /// sufficient, a read-write scope will do as well.
31509 pub fn add_scope<St>(mut self, scope: St) -> ObjectUpdateCall<'a, C>
31510 where
31511 St: AsRef<str>,
31512 {
31513 self._scopes.insert(String::from(scope.as_ref()));
31514 self
31515 }
31516 /// Identifies the authorization scope(s) for the method you are building.
31517 ///
31518 /// See [`Self::add_scope()`] for details.
31519 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectUpdateCall<'a, C>
31520 where
31521 I: IntoIterator<Item = St>,
31522 St: AsRef<str>,
31523 {
31524 self._scopes
31525 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31526 self
31527 }
31528
31529 /// Removes all scopes, and no default scope will be used either.
31530 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31531 /// for details).
31532 pub fn clear_scopes(mut self) -> ObjectUpdateCall<'a, C> {
31533 self._scopes.clear();
31534 self
31535 }
31536}
31537
31538/// Watch for changes on all objects in a bucket.
31539///
31540/// A builder for the *watchAll* method supported by a *object* resource.
31541/// It is not used directly, but through a [`ObjectMethods`] instance.
31542///
31543/// # Example
31544///
31545/// Instantiate a resource method builder
31546///
31547/// ```test_harness,no_run
31548/// # extern crate hyper;
31549/// # extern crate hyper_rustls;
31550/// # extern crate google_storage1 as storage1;
31551/// use storage1::api::Channel;
31552/// # async fn dox() {
31553/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31554///
31555/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31556/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
31557/// # .with_native_roots()
31558/// # .unwrap()
31559/// # .https_only()
31560/// # .enable_http2()
31561/// # .build();
31562///
31563/// # let executor = hyper_util::rt::TokioExecutor::new();
31564/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
31565/// # secret,
31566/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31567/// # yup_oauth2::client::CustomHyperClientBuilder::from(
31568/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
31569/// # ),
31570/// # ).build().await.unwrap();
31571///
31572/// # let client = hyper_util::client::legacy::Client::builder(
31573/// # hyper_util::rt::TokioExecutor::new()
31574/// # )
31575/// # .build(
31576/// # hyper_rustls::HttpsConnectorBuilder::new()
31577/// # .with_native_roots()
31578/// # .unwrap()
31579/// # .https_or_http()
31580/// # .enable_http2()
31581/// # .build()
31582/// # );
31583/// # let mut hub = Storage::new(client, auth);
31584/// // As the method needs a request, you would usually fill it with the desired information
31585/// // into the respective structure. Some of the parts shown here might not be applicable !
31586/// // Values shown here are possibly random and not representative !
31587/// let mut req = Channel::default();
31588///
31589/// // You can configure optional parameters by calling the respective setters at will, and
31590/// // execute the final call using `doit()`.
31591/// // Values shown here are possibly random and not representative !
31592/// let result = hub.objects().watch_all(req, "bucket")
31593/// .versions(false)
31594/// .user_project("erat")
31595/// .start_offset("duo")
31596/// .projection("et")
31597/// .prefix("erat")
31598/// .page_token("sit")
31599/// .max_results(28)
31600/// .include_trailing_delimiter(false)
31601/// .end_offset("accusam")
31602/// .delimiter("ut")
31603/// .doit().await;
31604/// # }
31605/// ```
31606pub struct ObjectWatchAllCall<'a, C>
31607where
31608 C: 'a,
31609{
31610 hub: &'a Storage<C>,
31611 _request: Channel,
31612 _bucket: String,
31613 _versions: Option<bool>,
31614 _user_project: Option<String>,
31615 _start_offset: Option<String>,
31616 _projection: Option<String>,
31617 _prefix: Option<String>,
31618 _page_token: Option<String>,
31619 _max_results: Option<u32>,
31620 _include_trailing_delimiter: Option<bool>,
31621 _end_offset: Option<String>,
31622 _delimiter: Option<String>,
31623 _delegate: Option<&'a mut dyn common::Delegate>,
31624 _additional_params: HashMap<String, String>,
31625 _scopes: BTreeSet<String>,
31626}
31627
31628impl<'a, C> common::CallBuilder for ObjectWatchAllCall<'a, C> {}
31629
31630impl<'a, C> ObjectWatchAllCall<'a, C>
31631where
31632 C: common::Connector,
31633{
31634 /// Perform the operation you have build so far.
31635 pub async fn doit(mut self) -> common::Result<(common::Response, Channel)> {
31636 use std::borrow::Cow;
31637 use std::io::{Read, Seek};
31638
31639 use common::{url::Params, ToParts};
31640 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31641
31642 let mut dd = common::DefaultDelegate;
31643 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31644 dlg.begin(common::MethodInfo {
31645 id: "storage.objects.watchAll",
31646 http_method: hyper::Method::POST,
31647 });
31648
31649 for &field in [
31650 "alt",
31651 "bucket",
31652 "versions",
31653 "userProject",
31654 "startOffset",
31655 "projection",
31656 "prefix",
31657 "pageToken",
31658 "maxResults",
31659 "includeTrailingDelimiter",
31660 "endOffset",
31661 "delimiter",
31662 ]
31663 .iter()
31664 {
31665 if self._additional_params.contains_key(field) {
31666 dlg.finished(false);
31667 return Err(common::Error::FieldClash(field));
31668 }
31669 }
31670
31671 let mut params = Params::with_capacity(14 + self._additional_params.len());
31672 params.push("bucket", self._bucket);
31673 if let Some(value) = self._versions.as_ref() {
31674 params.push("versions", value.to_string());
31675 }
31676 if let Some(value) = self._user_project.as_ref() {
31677 params.push("userProject", value);
31678 }
31679 if let Some(value) = self._start_offset.as_ref() {
31680 params.push("startOffset", value);
31681 }
31682 if let Some(value) = self._projection.as_ref() {
31683 params.push("projection", value);
31684 }
31685 if let Some(value) = self._prefix.as_ref() {
31686 params.push("prefix", value);
31687 }
31688 if let Some(value) = self._page_token.as_ref() {
31689 params.push("pageToken", value);
31690 }
31691 if let Some(value) = self._max_results.as_ref() {
31692 params.push("maxResults", value.to_string());
31693 }
31694 if let Some(value) = self._include_trailing_delimiter.as_ref() {
31695 params.push("includeTrailingDelimiter", value.to_string());
31696 }
31697 if let Some(value) = self._end_offset.as_ref() {
31698 params.push("endOffset", value);
31699 }
31700 if let Some(value) = self._delimiter.as_ref() {
31701 params.push("delimiter", value);
31702 }
31703
31704 params.extend(self._additional_params.iter());
31705
31706 params.push("alt", "json");
31707 let mut url = self.hub._base_url.clone() + "b/{bucket}/o/watch";
31708 if self._scopes.is_empty() {
31709 self._scopes
31710 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
31711 }
31712
31713 #[allow(clippy::single_element_loop)]
31714 for &(find_this, param_name) in [("{bucket}", "bucket")].iter() {
31715 url = params.uri_replacement(url, param_name, find_this, false);
31716 }
31717 {
31718 let to_remove = ["bucket"];
31719 params.remove_params(&to_remove);
31720 }
31721
31722 let url = params.parse_with_url(&url);
31723
31724 let mut json_mime_type = mime::APPLICATION_JSON;
31725 let mut request_value_reader = {
31726 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
31727 common::remove_json_null_values(&mut value);
31728 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
31729 serde_json::to_writer(&mut dst, &value).unwrap();
31730 dst
31731 };
31732 let request_size = request_value_reader
31733 .seek(std::io::SeekFrom::End(0))
31734 .unwrap();
31735 request_value_reader
31736 .seek(std::io::SeekFrom::Start(0))
31737 .unwrap();
31738
31739 loop {
31740 let token = match self
31741 .hub
31742 .auth
31743 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31744 .await
31745 {
31746 Ok(token) => token,
31747 Err(e) => match dlg.token(e) {
31748 Ok(token) => token,
31749 Err(e) => {
31750 dlg.finished(false);
31751 return Err(common::Error::MissingToken(e));
31752 }
31753 },
31754 };
31755 request_value_reader
31756 .seek(std::io::SeekFrom::Start(0))
31757 .unwrap();
31758 let mut req_result = {
31759 let client = &self.hub.client;
31760 dlg.pre_request();
31761 let mut req_builder = hyper::Request::builder()
31762 .method(hyper::Method::POST)
31763 .uri(url.as_str())
31764 .header(USER_AGENT, self.hub._user_agent.clone());
31765
31766 if let Some(token) = token.as_ref() {
31767 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31768 }
31769
31770 let request = req_builder
31771 .header(CONTENT_TYPE, json_mime_type.to_string())
31772 .header(CONTENT_LENGTH, request_size as u64)
31773 .body(common::to_body(
31774 request_value_reader.get_ref().clone().into(),
31775 ));
31776
31777 client.request(request.unwrap()).await
31778 };
31779
31780 match req_result {
31781 Err(err) => {
31782 if let common::Retry::After(d) = dlg.http_error(&err) {
31783 sleep(d).await;
31784 continue;
31785 }
31786 dlg.finished(false);
31787 return Err(common::Error::HttpError(err));
31788 }
31789 Ok(res) => {
31790 let (mut parts, body) = res.into_parts();
31791 let mut body = common::Body::new(body);
31792 if !parts.status.is_success() {
31793 let bytes = common::to_bytes(body).await.unwrap_or_default();
31794 let error = serde_json::from_str(&common::to_string(&bytes));
31795 let response = common::to_response(parts, bytes.into());
31796
31797 if let common::Retry::After(d) =
31798 dlg.http_failure(&response, error.as_ref().ok())
31799 {
31800 sleep(d).await;
31801 continue;
31802 }
31803
31804 dlg.finished(false);
31805
31806 return Err(match error {
31807 Ok(value) => common::Error::BadRequest(value),
31808 _ => common::Error::Failure(response),
31809 });
31810 }
31811 let response = {
31812 let bytes = common::to_bytes(body).await.unwrap_or_default();
31813 let encoded = common::to_string(&bytes);
31814 match serde_json::from_str(&encoded) {
31815 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31816 Err(error) => {
31817 dlg.response_json_decode_error(&encoded, &error);
31818 return Err(common::Error::JsonDecodeError(
31819 encoded.to_string(),
31820 error,
31821 ));
31822 }
31823 }
31824 };
31825
31826 dlg.finished(true);
31827 return Ok(response);
31828 }
31829 }
31830 }
31831 }
31832
31833 ///
31834 /// Sets the *request* property to the given value.
31835 ///
31836 /// Even though the property as already been set when instantiating this call,
31837 /// we provide this method for API completeness.
31838 pub fn request(mut self, new_value: Channel) -> ObjectWatchAllCall<'a, C> {
31839 self._request = new_value;
31840 self
31841 }
31842 /// Name of the bucket in which to look for objects.
31843 ///
31844 /// Sets the *bucket* path property to the given value.
31845 ///
31846 /// Even though the property as already been set when instantiating this call,
31847 /// we provide this method for API completeness.
31848 pub fn bucket(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C> {
31849 self._bucket = new_value.to_string();
31850 self
31851 }
31852 /// If true, lists all versions of an object as distinct results. The default is false. For more information, see [Object Versioning](https://cloud.google.com/storage/docs/object-versioning).
31853 ///
31854 /// Sets the *versions* query property to the given value.
31855 pub fn versions(mut self, new_value: bool) -> ObjectWatchAllCall<'a, C> {
31856 self._versions = Some(new_value);
31857 self
31858 }
31859 /// The project to be billed for this request. Required for Requester Pays buckets.
31860 ///
31861 /// Sets the *user project* query property to the given value.
31862 pub fn user_project(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C> {
31863 self._user_project = Some(new_value.to_string());
31864 self
31865 }
31866 /// 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).
31867 ///
31868 /// Sets the *start offset* query property to the given value.
31869 pub fn start_offset(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C> {
31870 self._start_offset = Some(new_value.to_string());
31871 self
31872 }
31873 /// Set of properties to return. Defaults to noAcl.
31874 ///
31875 /// Sets the *projection* query property to the given value.
31876 pub fn projection(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C> {
31877 self._projection = Some(new_value.to_string());
31878 self
31879 }
31880 /// Filter results to objects whose names begin with this prefix.
31881 ///
31882 /// Sets the *prefix* query property to the given value.
31883 pub fn prefix(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C> {
31884 self._prefix = Some(new_value.to_string());
31885 self
31886 }
31887 /// A previously-returned page token representing part of the larger set of results to view.
31888 ///
31889 /// Sets the *page token* query property to the given value.
31890 pub fn page_token(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C> {
31891 self._page_token = Some(new_value.to_string());
31892 self
31893 }
31894 /// 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.
31895 ///
31896 /// Sets the *max results* query property to the given value.
31897 pub fn max_results(mut self, new_value: u32) -> ObjectWatchAllCall<'a, C> {
31898 self._max_results = Some(new_value);
31899 self
31900 }
31901 /// If true, objects that end in exactly one instance of delimiter will have their metadata included in items in addition to prefixes.
31902 ///
31903 /// Sets the *include trailing delimiter* query property to the given value.
31904 pub fn include_trailing_delimiter(mut self, new_value: bool) -> ObjectWatchAllCall<'a, C> {
31905 self._include_trailing_delimiter = Some(new_value);
31906 self
31907 }
31908 /// 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).
31909 ///
31910 /// Sets the *end offset* query property to the given value.
31911 pub fn end_offset(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C> {
31912 self._end_offset = Some(new_value.to_string());
31913 self
31914 }
31915 /// 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.
31916 ///
31917 /// Sets the *delimiter* query property to the given value.
31918 pub fn delimiter(mut self, new_value: &str) -> ObjectWatchAllCall<'a, C> {
31919 self._delimiter = Some(new_value.to_string());
31920 self
31921 }
31922 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31923 /// while executing the actual API request.
31924 ///
31925 /// ````text
31926 /// It should be used to handle progress information, and to implement a certain level of resilience.
31927 /// ````
31928 ///
31929 /// Sets the *delegate* property to the given value.
31930 pub fn delegate(
31931 mut self,
31932 new_value: &'a mut dyn common::Delegate,
31933 ) -> ObjectWatchAllCall<'a, C> {
31934 self._delegate = Some(new_value);
31935 self
31936 }
31937
31938 /// Set any additional parameter of the query string used in the request.
31939 /// It should be used to set parameters which are not yet available through their own
31940 /// setters.
31941 ///
31942 /// Please note that this method must not be used to set any of the known parameters
31943 /// which have their own setter method. If done anyway, the request will fail.
31944 ///
31945 /// # Additional Parameters
31946 ///
31947 /// * *alt* (query-string) - Data format for the response.
31948 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31949 /// * *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.
31950 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31951 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31952 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
31953 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
31954 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
31955 pub fn param<T>(mut self, name: T, value: T) -> ObjectWatchAllCall<'a, C>
31956 where
31957 T: AsRef<str>,
31958 {
31959 self._additional_params
31960 .insert(name.as_ref().to_string(), value.as_ref().to_string());
31961 self
31962 }
31963
31964 /// Identifies the authorization scope for the method you are building.
31965 ///
31966 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31967 /// [`Scope::DevstorageReadOnly`].
31968 ///
31969 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31970 /// tokens for more than one scope.
31971 ///
31972 /// Usually there is more than one suitable scope to authorize an operation, some of which may
31973 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31974 /// sufficient, a read-write scope will do as well.
31975 pub fn add_scope<St>(mut self, scope: St) -> ObjectWatchAllCall<'a, C>
31976 where
31977 St: AsRef<str>,
31978 {
31979 self._scopes.insert(String::from(scope.as_ref()));
31980 self
31981 }
31982 /// Identifies the authorization scope(s) for the method you are building.
31983 ///
31984 /// See [`Self::add_scope()`] for details.
31985 pub fn add_scopes<I, St>(mut self, scopes: I) -> ObjectWatchAllCall<'a, C>
31986 where
31987 I: IntoIterator<Item = St>,
31988 St: AsRef<str>,
31989 {
31990 self._scopes
31991 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31992 self
31993 }
31994
31995 /// Removes all scopes, and no default scope will be used either.
31996 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31997 /// for details).
31998 pub fn clear_scopes(mut self) -> ObjectWatchAllCall<'a, C> {
31999 self._scopes.clear();
32000 self
32001 }
32002}
32003
32004/// Creates a new HMAC key for the specified service account.
32005///
32006/// A builder for the *hmacKeys.create* method supported by a *project* resource.
32007/// It is not used directly, but through a [`ProjectMethods`] instance.
32008///
32009/// # Example
32010///
32011/// Instantiate a resource method builder
32012///
32013/// ```test_harness,no_run
32014/// # extern crate hyper;
32015/// # extern crate hyper_rustls;
32016/// # extern crate google_storage1 as storage1;
32017/// # async fn dox() {
32018/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32019///
32020/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32021/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
32022/// # .with_native_roots()
32023/// # .unwrap()
32024/// # .https_only()
32025/// # .enable_http2()
32026/// # .build();
32027///
32028/// # let executor = hyper_util::rt::TokioExecutor::new();
32029/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
32030/// # secret,
32031/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32032/// # yup_oauth2::client::CustomHyperClientBuilder::from(
32033/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
32034/// # ),
32035/// # ).build().await.unwrap();
32036///
32037/// # let client = hyper_util::client::legacy::Client::builder(
32038/// # hyper_util::rt::TokioExecutor::new()
32039/// # )
32040/// # .build(
32041/// # hyper_rustls::HttpsConnectorBuilder::new()
32042/// # .with_native_roots()
32043/// # .unwrap()
32044/// # .https_or_http()
32045/// # .enable_http2()
32046/// # .build()
32047/// # );
32048/// # let mut hub = Storage::new(client, auth);
32049/// // You can configure optional parameters by calling the respective setters at will, and
32050/// // execute the final call using `doit()`.
32051/// // Values shown here are possibly random and not representative !
32052/// let result = hub.projects().hmac_keys_create("projectId", "serviceAccountEmail")
32053/// .user_project("dolor")
32054/// .doit().await;
32055/// # }
32056/// ```
32057pub struct ProjectHmacKeyCreateCall<'a, C>
32058where
32059 C: 'a,
32060{
32061 hub: &'a Storage<C>,
32062 _project_id: String,
32063 _service_account_email: String,
32064 _user_project: Option<String>,
32065 _delegate: Option<&'a mut dyn common::Delegate>,
32066 _additional_params: HashMap<String, String>,
32067 _scopes: BTreeSet<String>,
32068}
32069
32070impl<'a, C> common::CallBuilder for ProjectHmacKeyCreateCall<'a, C> {}
32071
32072impl<'a, C> ProjectHmacKeyCreateCall<'a, C>
32073where
32074 C: common::Connector,
32075{
32076 /// Perform the operation you have build so far.
32077 pub async fn doit(mut self) -> common::Result<(common::Response, HmacKey)> {
32078 use std::borrow::Cow;
32079 use std::io::{Read, Seek};
32080
32081 use common::{url::Params, ToParts};
32082 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32083
32084 let mut dd = common::DefaultDelegate;
32085 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32086 dlg.begin(common::MethodInfo {
32087 id: "storage.projects.hmacKeys.create",
32088 http_method: hyper::Method::POST,
32089 });
32090
32091 for &field in ["alt", "projectId", "serviceAccountEmail", "userProject"].iter() {
32092 if self._additional_params.contains_key(field) {
32093 dlg.finished(false);
32094 return Err(common::Error::FieldClash(field));
32095 }
32096 }
32097
32098 let mut params = Params::with_capacity(5 + self._additional_params.len());
32099 params.push("projectId", self._project_id);
32100 params.push("serviceAccountEmail", self._service_account_email);
32101 if let Some(value) = self._user_project.as_ref() {
32102 params.push("userProject", value);
32103 }
32104
32105 params.extend(self._additional_params.iter());
32106
32107 params.push("alt", "json");
32108 let mut url = self.hub._base_url.clone() + "projects/{projectId}/hmacKeys";
32109 if self._scopes.is_empty() {
32110 self._scopes
32111 .insert(Scope::DevstorageFullControl.as_ref().to_string());
32112 }
32113
32114 #[allow(clippy::single_element_loop)]
32115 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
32116 url = params.uri_replacement(url, param_name, find_this, false);
32117 }
32118 {
32119 let to_remove = ["projectId"];
32120 params.remove_params(&to_remove);
32121 }
32122
32123 let url = params.parse_with_url(&url);
32124
32125 loop {
32126 let token = match self
32127 .hub
32128 .auth
32129 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32130 .await
32131 {
32132 Ok(token) => token,
32133 Err(e) => match dlg.token(e) {
32134 Ok(token) => token,
32135 Err(e) => {
32136 dlg.finished(false);
32137 return Err(common::Error::MissingToken(e));
32138 }
32139 },
32140 };
32141 let mut req_result = {
32142 let client = &self.hub.client;
32143 dlg.pre_request();
32144 let mut req_builder = hyper::Request::builder()
32145 .method(hyper::Method::POST)
32146 .uri(url.as_str())
32147 .header(USER_AGENT, self.hub._user_agent.clone());
32148
32149 if let Some(token) = token.as_ref() {
32150 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32151 }
32152
32153 let request = req_builder
32154 .header(CONTENT_LENGTH, 0_u64)
32155 .body(common::to_body::<String>(None));
32156
32157 client.request(request.unwrap()).await
32158 };
32159
32160 match req_result {
32161 Err(err) => {
32162 if let common::Retry::After(d) = dlg.http_error(&err) {
32163 sleep(d).await;
32164 continue;
32165 }
32166 dlg.finished(false);
32167 return Err(common::Error::HttpError(err));
32168 }
32169 Ok(res) => {
32170 let (mut parts, body) = res.into_parts();
32171 let mut body = common::Body::new(body);
32172 if !parts.status.is_success() {
32173 let bytes = common::to_bytes(body).await.unwrap_or_default();
32174 let error = serde_json::from_str(&common::to_string(&bytes));
32175 let response = common::to_response(parts, bytes.into());
32176
32177 if let common::Retry::After(d) =
32178 dlg.http_failure(&response, error.as_ref().ok())
32179 {
32180 sleep(d).await;
32181 continue;
32182 }
32183
32184 dlg.finished(false);
32185
32186 return Err(match error {
32187 Ok(value) => common::Error::BadRequest(value),
32188 _ => common::Error::Failure(response),
32189 });
32190 }
32191 let response = {
32192 let bytes = common::to_bytes(body).await.unwrap_or_default();
32193 let encoded = common::to_string(&bytes);
32194 match serde_json::from_str(&encoded) {
32195 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32196 Err(error) => {
32197 dlg.response_json_decode_error(&encoded, &error);
32198 return Err(common::Error::JsonDecodeError(
32199 encoded.to_string(),
32200 error,
32201 ));
32202 }
32203 }
32204 };
32205
32206 dlg.finished(true);
32207 return Ok(response);
32208 }
32209 }
32210 }
32211 }
32212
32213 /// Project ID owning the service account.
32214 ///
32215 /// Sets the *project id* path property to the given value.
32216 ///
32217 /// Even though the property as already been set when instantiating this call,
32218 /// we provide this method for API completeness.
32219 pub fn project_id(mut self, new_value: &str) -> ProjectHmacKeyCreateCall<'a, C> {
32220 self._project_id = new_value.to_string();
32221 self
32222 }
32223 /// Email address of the service account.
32224 ///
32225 /// Sets the *service account email* query property to the given value.
32226 ///
32227 /// Even though the property as already been set when instantiating this call,
32228 /// we provide this method for API completeness.
32229 pub fn service_account_email(mut self, new_value: &str) -> ProjectHmacKeyCreateCall<'a, C> {
32230 self._service_account_email = new_value.to_string();
32231 self
32232 }
32233 /// The project to be billed for this request.
32234 ///
32235 /// Sets the *user project* query property to the given value.
32236 pub fn user_project(mut self, new_value: &str) -> ProjectHmacKeyCreateCall<'a, C> {
32237 self._user_project = Some(new_value.to_string());
32238 self
32239 }
32240 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32241 /// while executing the actual API request.
32242 ///
32243 /// ````text
32244 /// It should be used to handle progress information, and to implement a certain level of resilience.
32245 /// ````
32246 ///
32247 /// Sets the *delegate* property to the given value.
32248 pub fn delegate(
32249 mut self,
32250 new_value: &'a mut dyn common::Delegate,
32251 ) -> ProjectHmacKeyCreateCall<'a, C> {
32252 self._delegate = Some(new_value);
32253 self
32254 }
32255
32256 /// Set any additional parameter of the query string used in the request.
32257 /// It should be used to set parameters which are not yet available through their own
32258 /// setters.
32259 ///
32260 /// Please note that this method must not be used to set any of the known parameters
32261 /// which have their own setter method. If done anyway, the request will fail.
32262 ///
32263 /// # Additional Parameters
32264 ///
32265 /// * *alt* (query-string) - Data format for the response.
32266 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32267 /// * *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.
32268 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32269 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32270 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
32271 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
32272 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
32273 pub fn param<T>(mut self, name: T, value: T) -> ProjectHmacKeyCreateCall<'a, C>
32274 where
32275 T: AsRef<str>,
32276 {
32277 self._additional_params
32278 .insert(name.as_ref().to_string(), value.as_ref().to_string());
32279 self
32280 }
32281
32282 /// Identifies the authorization scope for the method you are building.
32283 ///
32284 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32285 /// [`Scope::DevstorageFullControl`].
32286 ///
32287 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32288 /// tokens for more than one scope.
32289 ///
32290 /// Usually there is more than one suitable scope to authorize an operation, some of which may
32291 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32292 /// sufficient, a read-write scope will do as well.
32293 pub fn add_scope<St>(mut self, scope: St) -> ProjectHmacKeyCreateCall<'a, C>
32294 where
32295 St: AsRef<str>,
32296 {
32297 self._scopes.insert(String::from(scope.as_ref()));
32298 self
32299 }
32300 /// Identifies the authorization scope(s) for the method you are building.
32301 ///
32302 /// See [`Self::add_scope()`] for details.
32303 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectHmacKeyCreateCall<'a, C>
32304 where
32305 I: IntoIterator<Item = St>,
32306 St: AsRef<str>,
32307 {
32308 self._scopes
32309 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32310 self
32311 }
32312
32313 /// Removes all scopes, and no default scope will be used either.
32314 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32315 /// for details).
32316 pub fn clear_scopes(mut self) -> ProjectHmacKeyCreateCall<'a, C> {
32317 self._scopes.clear();
32318 self
32319 }
32320}
32321
32322/// Deletes an HMAC key.
32323///
32324/// A builder for the *hmacKeys.delete* method supported by a *project* resource.
32325/// It is not used directly, but through a [`ProjectMethods`] instance.
32326///
32327/// # Example
32328///
32329/// Instantiate a resource method builder
32330///
32331/// ```test_harness,no_run
32332/// # extern crate hyper;
32333/// # extern crate hyper_rustls;
32334/// # extern crate google_storage1 as storage1;
32335/// # async fn dox() {
32336/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32337///
32338/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32339/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
32340/// # .with_native_roots()
32341/// # .unwrap()
32342/// # .https_only()
32343/// # .enable_http2()
32344/// # .build();
32345///
32346/// # let executor = hyper_util::rt::TokioExecutor::new();
32347/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
32348/// # secret,
32349/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32350/// # yup_oauth2::client::CustomHyperClientBuilder::from(
32351/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
32352/// # ),
32353/// # ).build().await.unwrap();
32354///
32355/// # let client = hyper_util::client::legacy::Client::builder(
32356/// # hyper_util::rt::TokioExecutor::new()
32357/// # )
32358/// # .build(
32359/// # hyper_rustls::HttpsConnectorBuilder::new()
32360/// # .with_native_roots()
32361/// # .unwrap()
32362/// # .https_or_http()
32363/// # .enable_http2()
32364/// # .build()
32365/// # );
32366/// # let mut hub = Storage::new(client, auth);
32367/// // You can configure optional parameters by calling the respective setters at will, and
32368/// // execute the final call using `doit()`.
32369/// // Values shown here are possibly random and not representative !
32370/// let result = hub.projects().hmac_keys_delete("projectId", "accessId")
32371/// .user_project("aliquyam")
32372/// .doit().await;
32373/// # }
32374/// ```
32375pub struct ProjectHmacKeyDeleteCall<'a, C>
32376where
32377 C: 'a,
32378{
32379 hub: &'a Storage<C>,
32380 _project_id: String,
32381 _access_id: String,
32382 _user_project: Option<String>,
32383 _delegate: Option<&'a mut dyn common::Delegate>,
32384 _additional_params: HashMap<String, String>,
32385 _scopes: BTreeSet<String>,
32386}
32387
32388impl<'a, C> common::CallBuilder for ProjectHmacKeyDeleteCall<'a, C> {}
32389
32390impl<'a, C> ProjectHmacKeyDeleteCall<'a, C>
32391where
32392 C: common::Connector,
32393{
32394 /// Perform the operation you have build so far.
32395 pub async fn doit(mut self) -> common::Result<common::Response> {
32396 use std::borrow::Cow;
32397 use std::io::{Read, Seek};
32398
32399 use common::{url::Params, ToParts};
32400 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32401
32402 let mut dd = common::DefaultDelegate;
32403 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32404 dlg.begin(common::MethodInfo {
32405 id: "storage.projects.hmacKeys.delete",
32406 http_method: hyper::Method::DELETE,
32407 });
32408
32409 for &field in ["projectId", "accessId", "userProject"].iter() {
32410 if self._additional_params.contains_key(field) {
32411 dlg.finished(false);
32412 return Err(common::Error::FieldClash(field));
32413 }
32414 }
32415
32416 let mut params = Params::with_capacity(4 + self._additional_params.len());
32417 params.push("projectId", self._project_id);
32418 params.push("accessId", self._access_id);
32419 if let Some(value) = self._user_project.as_ref() {
32420 params.push("userProject", value);
32421 }
32422
32423 params.extend(self._additional_params.iter());
32424
32425 let mut url = self.hub._base_url.clone() + "projects/{projectId}/hmacKeys/{accessId}";
32426 if self._scopes.is_empty() {
32427 self._scopes
32428 .insert(Scope::DevstorageReadWrite.as_ref().to_string());
32429 }
32430
32431 #[allow(clippy::single_element_loop)]
32432 for &(find_this, param_name) in
32433 [("{projectId}", "projectId"), ("{accessId}", "accessId")].iter()
32434 {
32435 url = params.uri_replacement(url, param_name, find_this, false);
32436 }
32437 {
32438 let to_remove = ["accessId", "projectId"];
32439 params.remove_params(&to_remove);
32440 }
32441
32442 let url = params.parse_with_url(&url);
32443
32444 loop {
32445 let token = match self
32446 .hub
32447 .auth
32448 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32449 .await
32450 {
32451 Ok(token) => token,
32452 Err(e) => match dlg.token(e) {
32453 Ok(token) => token,
32454 Err(e) => {
32455 dlg.finished(false);
32456 return Err(common::Error::MissingToken(e));
32457 }
32458 },
32459 };
32460 let mut req_result = {
32461 let client = &self.hub.client;
32462 dlg.pre_request();
32463 let mut req_builder = hyper::Request::builder()
32464 .method(hyper::Method::DELETE)
32465 .uri(url.as_str())
32466 .header(USER_AGENT, self.hub._user_agent.clone());
32467
32468 if let Some(token) = token.as_ref() {
32469 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32470 }
32471
32472 let request = req_builder
32473 .header(CONTENT_LENGTH, 0_u64)
32474 .body(common::to_body::<String>(None));
32475
32476 client.request(request.unwrap()).await
32477 };
32478
32479 match req_result {
32480 Err(err) => {
32481 if let common::Retry::After(d) = dlg.http_error(&err) {
32482 sleep(d).await;
32483 continue;
32484 }
32485 dlg.finished(false);
32486 return Err(common::Error::HttpError(err));
32487 }
32488 Ok(res) => {
32489 let (mut parts, body) = res.into_parts();
32490 let mut body = common::Body::new(body);
32491 if !parts.status.is_success() {
32492 let bytes = common::to_bytes(body).await.unwrap_or_default();
32493 let error = serde_json::from_str(&common::to_string(&bytes));
32494 let response = common::to_response(parts, bytes.into());
32495
32496 if let common::Retry::After(d) =
32497 dlg.http_failure(&response, error.as_ref().ok())
32498 {
32499 sleep(d).await;
32500 continue;
32501 }
32502
32503 dlg.finished(false);
32504
32505 return Err(match error {
32506 Ok(value) => common::Error::BadRequest(value),
32507 _ => common::Error::Failure(response),
32508 });
32509 }
32510 let response = common::Response::from_parts(parts, body);
32511
32512 dlg.finished(true);
32513 return Ok(response);
32514 }
32515 }
32516 }
32517 }
32518
32519 /// Project ID owning the requested key
32520 ///
32521 /// Sets the *project id* path property to the given value.
32522 ///
32523 /// Even though the property as already been set when instantiating this call,
32524 /// we provide this method for API completeness.
32525 pub fn project_id(mut self, new_value: &str) -> ProjectHmacKeyDeleteCall<'a, C> {
32526 self._project_id = new_value.to_string();
32527 self
32528 }
32529 /// Name of the HMAC key to be deleted.
32530 ///
32531 /// Sets the *access id* path property to the given value.
32532 ///
32533 /// Even though the property as already been set when instantiating this call,
32534 /// we provide this method for API completeness.
32535 pub fn access_id(mut self, new_value: &str) -> ProjectHmacKeyDeleteCall<'a, C> {
32536 self._access_id = new_value.to_string();
32537 self
32538 }
32539 /// The project to be billed for this request.
32540 ///
32541 /// Sets the *user project* query property to the given value.
32542 pub fn user_project(mut self, new_value: &str) -> ProjectHmacKeyDeleteCall<'a, C> {
32543 self._user_project = Some(new_value.to_string());
32544 self
32545 }
32546 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32547 /// while executing the actual API request.
32548 ///
32549 /// ````text
32550 /// It should be used to handle progress information, and to implement a certain level of resilience.
32551 /// ````
32552 ///
32553 /// Sets the *delegate* property to the given value.
32554 pub fn delegate(
32555 mut self,
32556 new_value: &'a mut dyn common::Delegate,
32557 ) -> ProjectHmacKeyDeleteCall<'a, C> {
32558 self._delegate = Some(new_value);
32559 self
32560 }
32561
32562 /// Set any additional parameter of the query string used in the request.
32563 /// It should be used to set parameters which are not yet available through their own
32564 /// setters.
32565 ///
32566 /// Please note that this method must not be used to set any of the known parameters
32567 /// which have their own setter method. If done anyway, the request will fail.
32568 ///
32569 /// # Additional Parameters
32570 ///
32571 /// * *alt* (query-string) - Data format for the response.
32572 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32573 /// * *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.
32574 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32575 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32576 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
32577 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
32578 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
32579 pub fn param<T>(mut self, name: T, value: T) -> ProjectHmacKeyDeleteCall<'a, C>
32580 where
32581 T: AsRef<str>,
32582 {
32583 self._additional_params
32584 .insert(name.as_ref().to_string(), value.as_ref().to_string());
32585 self
32586 }
32587
32588 /// Identifies the authorization scope for the method you are building.
32589 ///
32590 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32591 /// [`Scope::DevstorageReadWrite`].
32592 ///
32593 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32594 /// tokens for more than one scope.
32595 ///
32596 /// Usually there is more than one suitable scope to authorize an operation, some of which may
32597 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32598 /// sufficient, a read-write scope will do as well.
32599 pub fn add_scope<St>(mut self, scope: St) -> ProjectHmacKeyDeleteCall<'a, C>
32600 where
32601 St: AsRef<str>,
32602 {
32603 self._scopes.insert(String::from(scope.as_ref()));
32604 self
32605 }
32606 /// Identifies the authorization scope(s) for the method you are building.
32607 ///
32608 /// See [`Self::add_scope()`] for details.
32609 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectHmacKeyDeleteCall<'a, C>
32610 where
32611 I: IntoIterator<Item = St>,
32612 St: AsRef<str>,
32613 {
32614 self._scopes
32615 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32616 self
32617 }
32618
32619 /// Removes all scopes, and no default scope will be used either.
32620 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32621 /// for details).
32622 pub fn clear_scopes(mut self) -> ProjectHmacKeyDeleteCall<'a, C> {
32623 self._scopes.clear();
32624 self
32625 }
32626}
32627
32628/// Retrieves an HMAC key's metadata
32629///
32630/// A builder for the *hmacKeys.get* method supported by a *project* resource.
32631/// It is not used directly, but through a [`ProjectMethods`] instance.
32632///
32633/// # Example
32634///
32635/// Instantiate a resource method builder
32636///
32637/// ```test_harness,no_run
32638/// # extern crate hyper;
32639/// # extern crate hyper_rustls;
32640/// # extern crate google_storage1 as storage1;
32641/// # async fn dox() {
32642/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32643///
32644/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32645/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
32646/// # .with_native_roots()
32647/// # .unwrap()
32648/// # .https_only()
32649/// # .enable_http2()
32650/// # .build();
32651///
32652/// # let executor = hyper_util::rt::TokioExecutor::new();
32653/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
32654/// # secret,
32655/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32656/// # yup_oauth2::client::CustomHyperClientBuilder::from(
32657/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
32658/// # ),
32659/// # ).build().await.unwrap();
32660///
32661/// # let client = hyper_util::client::legacy::Client::builder(
32662/// # hyper_util::rt::TokioExecutor::new()
32663/// # )
32664/// # .build(
32665/// # hyper_rustls::HttpsConnectorBuilder::new()
32666/// # .with_native_roots()
32667/// # .unwrap()
32668/// # .https_or_http()
32669/// # .enable_http2()
32670/// # .build()
32671/// # );
32672/// # let mut hub = Storage::new(client, auth);
32673/// // You can configure optional parameters by calling the respective setters at will, and
32674/// // execute the final call using `doit()`.
32675/// // Values shown here are possibly random and not representative !
32676/// let result = hub.projects().hmac_keys_get("projectId", "accessId")
32677/// .user_project("invidunt")
32678/// .doit().await;
32679/// # }
32680/// ```
32681pub struct ProjectHmacKeyGetCall<'a, C>
32682where
32683 C: 'a,
32684{
32685 hub: &'a Storage<C>,
32686 _project_id: String,
32687 _access_id: String,
32688 _user_project: Option<String>,
32689 _delegate: Option<&'a mut dyn common::Delegate>,
32690 _additional_params: HashMap<String, String>,
32691 _scopes: BTreeSet<String>,
32692}
32693
32694impl<'a, C> common::CallBuilder for ProjectHmacKeyGetCall<'a, C> {}
32695
32696impl<'a, C> ProjectHmacKeyGetCall<'a, C>
32697where
32698 C: common::Connector,
32699{
32700 /// Perform the operation you have build so far.
32701 pub async fn doit(mut self) -> common::Result<(common::Response, HmacKeyMetadata)> {
32702 use std::borrow::Cow;
32703 use std::io::{Read, Seek};
32704
32705 use common::{url::Params, ToParts};
32706 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32707
32708 let mut dd = common::DefaultDelegate;
32709 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32710 dlg.begin(common::MethodInfo {
32711 id: "storage.projects.hmacKeys.get",
32712 http_method: hyper::Method::GET,
32713 });
32714
32715 for &field in ["alt", "projectId", "accessId", "userProject"].iter() {
32716 if self._additional_params.contains_key(field) {
32717 dlg.finished(false);
32718 return Err(common::Error::FieldClash(field));
32719 }
32720 }
32721
32722 let mut params = Params::with_capacity(5 + self._additional_params.len());
32723 params.push("projectId", self._project_id);
32724 params.push("accessId", self._access_id);
32725 if let Some(value) = self._user_project.as_ref() {
32726 params.push("userProject", value);
32727 }
32728
32729 params.extend(self._additional_params.iter());
32730
32731 params.push("alt", "json");
32732 let mut url = self.hub._base_url.clone() + "projects/{projectId}/hmacKeys/{accessId}";
32733 if self._scopes.is_empty() {
32734 self._scopes
32735 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
32736 }
32737
32738 #[allow(clippy::single_element_loop)]
32739 for &(find_this, param_name) in
32740 [("{projectId}", "projectId"), ("{accessId}", "accessId")].iter()
32741 {
32742 url = params.uri_replacement(url, param_name, find_this, false);
32743 }
32744 {
32745 let to_remove = ["accessId", "projectId"];
32746 params.remove_params(&to_remove);
32747 }
32748
32749 let url = params.parse_with_url(&url);
32750
32751 loop {
32752 let token = match self
32753 .hub
32754 .auth
32755 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32756 .await
32757 {
32758 Ok(token) => token,
32759 Err(e) => match dlg.token(e) {
32760 Ok(token) => token,
32761 Err(e) => {
32762 dlg.finished(false);
32763 return Err(common::Error::MissingToken(e));
32764 }
32765 },
32766 };
32767 let mut req_result = {
32768 let client = &self.hub.client;
32769 dlg.pre_request();
32770 let mut req_builder = hyper::Request::builder()
32771 .method(hyper::Method::GET)
32772 .uri(url.as_str())
32773 .header(USER_AGENT, self.hub._user_agent.clone());
32774
32775 if let Some(token) = token.as_ref() {
32776 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32777 }
32778
32779 let request = req_builder
32780 .header(CONTENT_LENGTH, 0_u64)
32781 .body(common::to_body::<String>(None));
32782
32783 client.request(request.unwrap()).await
32784 };
32785
32786 match req_result {
32787 Err(err) => {
32788 if let common::Retry::After(d) = dlg.http_error(&err) {
32789 sleep(d).await;
32790 continue;
32791 }
32792 dlg.finished(false);
32793 return Err(common::Error::HttpError(err));
32794 }
32795 Ok(res) => {
32796 let (mut parts, body) = res.into_parts();
32797 let mut body = common::Body::new(body);
32798 if !parts.status.is_success() {
32799 let bytes = common::to_bytes(body).await.unwrap_or_default();
32800 let error = serde_json::from_str(&common::to_string(&bytes));
32801 let response = common::to_response(parts, bytes.into());
32802
32803 if let common::Retry::After(d) =
32804 dlg.http_failure(&response, error.as_ref().ok())
32805 {
32806 sleep(d).await;
32807 continue;
32808 }
32809
32810 dlg.finished(false);
32811
32812 return Err(match error {
32813 Ok(value) => common::Error::BadRequest(value),
32814 _ => common::Error::Failure(response),
32815 });
32816 }
32817 let response = {
32818 let bytes = common::to_bytes(body).await.unwrap_or_default();
32819 let encoded = common::to_string(&bytes);
32820 match serde_json::from_str(&encoded) {
32821 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32822 Err(error) => {
32823 dlg.response_json_decode_error(&encoded, &error);
32824 return Err(common::Error::JsonDecodeError(
32825 encoded.to_string(),
32826 error,
32827 ));
32828 }
32829 }
32830 };
32831
32832 dlg.finished(true);
32833 return Ok(response);
32834 }
32835 }
32836 }
32837 }
32838
32839 /// Project ID owning the service account of the requested key.
32840 ///
32841 /// Sets the *project id* path property to the given value.
32842 ///
32843 /// Even though the property as already been set when instantiating this call,
32844 /// we provide this method for API completeness.
32845 pub fn project_id(mut self, new_value: &str) -> ProjectHmacKeyGetCall<'a, C> {
32846 self._project_id = new_value.to_string();
32847 self
32848 }
32849 /// Name of the HMAC key.
32850 ///
32851 /// Sets the *access id* path property to the given value.
32852 ///
32853 /// Even though the property as already been set when instantiating this call,
32854 /// we provide this method for API completeness.
32855 pub fn access_id(mut self, new_value: &str) -> ProjectHmacKeyGetCall<'a, C> {
32856 self._access_id = new_value.to_string();
32857 self
32858 }
32859 /// The project to be billed for this request.
32860 ///
32861 /// Sets the *user project* query property to the given value.
32862 pub fn user_project(mut self, new_value: &str) -> ProjectHmacKeyGetCall<'a, C> {
32863 self._user_project = Some(new_value.to_string());
32864 self
32865 }
32866 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32867 /// while executing the actual API request.
32868 ///
32869 /// ````text
32870 /// It should be used to handle progress information, and to implement a certain level of resilience.
32871 /// ````
32872 ///
32873 /// Sets the *delegate* property to the given value.
32874 pub fn delegate(
32875 mut self,
32876 new_value: &'a mut dyn common::Delegate,
32877 ) -> ProjectHmacKeyGetCall<'a, C> {
32878 self._delegate = Some(new_value);
32879 self
32880 }
32881
32882 /// Set any additional parameter of the query string used in the request.
32883 /// It should be used to set parameters which are not yet available through their own
32884 /// setters.
32885 ///
32886 /// Please note that this method must not be used to set any of the known parameters
32887 /// which have their own setter method. If done anyway, the request will fail.
32888 ///
32889 /// # Additional Parameters
32890 ///
32891 /// * *alt* (query-string) - Data format for the response.
32892 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32893 /// * *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.
32894 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32895 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32896 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
32897 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
32898 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
32899 pub fn param<T>(mut self, name: T, value: T) -> ProjectHmacKeyGetCall<'a, C>
32900 where
32901 T: AsRef<str>,
32902 {
32903 self._additional_params
32904 .insert(name.as_ref().to_string(), value.as_ref().to_string());
32905 self
32906 }
32907
32908 /// Identifies the authorization scope for the method you are building.
32909 ///
32910 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32911 /// [`Scope::DevstorageReadOnly`].
32912 ///
32913 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32914 /// tokens for more than one scope.
32915 ///
32916 /// Usually there is more than one suitable scope to authorize an operation, some of which may
32917 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32918 /// sufficient, a read-write scope will do as well.
32919 pub fn add_scope<St>(mut self, scope: St) -> ProjectHmacKeyGetCall<'a, C>
32920 where
32921 St: AsRef<str>,
32922 {
32923 self._scopes.insert(String::from(scope.as_ref()));
32924 self
32925 }
32926 /// Identifies the authorization scope(s) for the method you are building.
32927 ///
32928 /// See [`Self::add_scope()`] for details.
32929 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectHmacKeyGetCall<'a, C>
32930 where
32931 I: IntoIterator<Item = St>,
32932 St: AsRef<str>,
32933 {
32934 self._scopes
32935 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32936 self
32937 }
32938
32939 /// Removes all scopes, and no default scope will be used either.
32940 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32941 /// for details).
32942 pub fn clear_scopes(mut self) -> ProjectHmacKeyGetCall<'a, C> {
32943 self._scopes.clear();
32944 self
32945 }
32946}
32947
32948/// Retrieves a list of HMAC keys matching the criteria.
32949///
32950/// A builder for the *hmacKeys.list* method supported by a *project* resource.
32951/// It is not used directly, but through a [`ProjectMethods`] instance.
32952///
32953/// # Example
32954///
32955/// Instantiate a resource method builder
32956///
32957/// ```test_harness,no_run
32958/// # extern crate hyper;
32959/// # extern crate hyper_rustls;
32960/// # extern crate google_storage1 as storage1;
32961/// # async fn dox() {
32962/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32963///
32964/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32965/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
32966/// # .with_native_roots()
32967/// # .unwrap()
32968/// # .https_only()
32969/// # .enable_http2()
32970/// # .build();
32971///
32972/// # let executor = hyper_util::rt::TokioExecutor::new();
32973/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
32974/// # secret,
32975/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32976/// # yup_oauth2::client::CustomHyperClientBuilder::from(
32977/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
32978/// # ),
32979/// # ).build().await.unwrap();
32980///
32981/// # let client = hyper_util::client::legacy::Client::builder(
32982/// # hyper_util::rt::TokioExecutor::new()
32983/// # )
32984/// # .build(
32985/// # hyper_rustls::HttpsConnectorBuilder::new()
32986/// # .with_native_roots()
32987/// # .unwrap()
32988/// # .https_or_http()
32989/// # .enable_http2()
32990/// # .build()
32991/// # );
32992/// # let mut hub = Storage::new(client, auth);
32993/// // You can configure optional parameters by calling the respective setters at will, and
32994/// // execute the final call using `doit()`.
32995/// // Values shown here are possibly random and not representative !
32996/// let result = hub.projects().hmac_keys_list("projectId")
32997/// .user_project("duo")
32998/// .show_deleted_keys(true)
32999/// .service_account_email("Stet")
33000/// .page_token("sadipscing")
33001/// .max_results(90)
33002/// .doit().await;
33003/// # }
33004/// ```
33005pub struct ProjectHmacKeyListCall<'a, C>
33006where
33007 C: 'a,
33008{
33009 hub: &'a Storage<C>,
33010 _project_id: String,
33011 _user_project: Option<String>,
33012 _show_deleted_keys: Option<bool>,
33013 _service_account_email: Option<String>,
33014 _page_token: Option<String>,
33015 _max_results: Option<u32>,
33016 _delegate: Option<&'a mut dyn common::Delegate>,
33017 _additional_params: HashMap<String, String>,
33018 _scopes: BTreeSet<String>,
33019}
33020
33021impl<'a, C> common::CallBuilder for ProjectHmacKeyListCall<'a, C> {}
33022
33023impl<'a, C> ProjectHmacKeyListCall<'a, C>
33024where
33025 C: common::Connector,
33026{
33027 /// Perform the operation you have build so far.
33028 pub async fn doit(mut self) -> common::Result<(common::Response, HmacKeysMetadata)> {
33029 use std::borrow::Cow;
33030 use std::io::{Read, Seek};
33031
33032 use common::{url::Params, ToParts};
33033 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33034
33035 let mut dd = common::DefaultDelegate;
33036 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33037 dlg.begin(common::MethodInfo {
33038 id: "storage.projects.hmacKeys.list",
33039 http_method: hyper::Method::GET,
33040 });
33041
33042 for &field in [
33043 "alt",
33044 "projectId",
33045 "userProject",
33046 "showDeletedKeys",
33047 "serviceAccountEmail",
33048 "pageToken",
33049 "maxResults",
33050 ]
33051 .iter()
33052 {
33053 if self._additional_params.contains_key(field) {
33054 dlg.finished(false);
33055 return Err(common::Error::FieldClash(field));
33056 }
33057 }
33058
33059 let mut params = Params::with_capacity(8 + self._additional_params.len());
33060 params.push("projectId", self._project_id);
33061 if let Some(value) = self._user_project.as_ref() {
33062 params.push("userProject", value);
33063 }
33064 if let Some(value) = self._show_deleted_keys.as_ref() {
33065 params.push("showDeletedKeys", value.to_string());
33066 }
33067 if let Some(value) = self._service_account_email.as_ref() {
33068 params.push("serviceAccountEmail", value);
33069 }
33070 if let Some(value) = self._page_token.as_ref() {
33071 params.push("pageToken", value);
33072 }
33073 if let Some(value) = self._max_results.as_ref() {
33074 params.push("maxResults", value.to_string());
33075 }
33076
33077 params.extend(self._additional_params.iter());
33078
33079 params.push("alt", "json");
33080 let mut url = self.hub._base_url.clone() + "projects/{projectId}/hmacKeys";
33081 if self._scopes.is_empty() {
33082 self._scopes
33083 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
33084 }
33085
33086 #[allow(clippy::single_element_loop)]
33087 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
33088 url = params.uri_replacement(url, param_name, find_this, false);
33089 }
33090 {
33091 let to_remove = ["projectId"];
33092 params.remove_params(&to_remove);
33093 }
33094
33095 let url = params.parse_with_url(&url);
33096
33097 loop {
33098 let token = match self
33099 .hub
33100 .auth
33101 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33102 .await
33103 {
33104 Ok(token) => token,
33105 Err(e) => match dlg.token(e) {
33106 Ok(token) => token,
33107 Err(e) => {
33108 dlg.finished(false);
33109 return Err(common::Error::MissingToken(e));
33110 }
33111 },
33112 };
33113 let mut req_result = {
33114 let client = &self.hub.client;
33115 dlg.pre_request();
33116 let mut req_builder = hyper::Request::builder()
33117 .method(hyper::Method::GET)
33118 .uri(url.as_str())
33119 .header(USER_AGENT, self.hub._user_agent.clone());
33120
33121 if let Some(token) = token.as_ref() {
33122 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33123 }
33124
33125 let request = req_builder
33126 .header(CONTENT_LENGTH, 0_u64)
33127 .body(common::to_body::<String>(None));
33128
33129 client.request(request.unwrap()).await
33130 };
33131
33132 match req_result {
33133 Err(err) => {
33134 if let common::Retry::After(d) = dlg.http_error(&err) {
33135 sleep(d).await;
33136 continue;
33137 }
33138 dlg.finished(false);
33139 return Err(common::Error::HttpError(err));
33140 }
33141 Ok(res) => {
33142 let (mut parts, body) = res.into_parts();
33143 let mut body = common::Body::new(body);
33144 if !parts.status.is_success() {
33145 let bytes = common::to_bytes(body).await.unwrap_or_default();
33146 let error = serde_json::from_str(&common::to_string(&bytes));
33147 let response = common::to_response(parts, bytes.into());
33148
33149 if let common::Retry::After(d) =
33150 dlg.http_failure(&response, error.as_ref().ok())
33151 {
33152 sleep(d).await;
33153 continue;
33154 }
33155
33156 dlg.finished(false);
33157
33158 return Err(match error {
33159 Ok(value) => common::Error::BadRequest(value),
33160 _ => common::Error::Failure(response),
33161 });
33162 }
33163 let response = {
33164 let bytes = common::to_bytes(body).await.unwrap_or_default();
33165 let encoded = common::to_string(&bytes);
33166 match serde_json::from_str(&encoded) {
33167 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33168 Err(error) => {
33169 dlg.response_json_decode_error(&encoded, &error);
33170 return Err(common::Error::JsonDecodeError(
33171 encoded.to_string(),
33172 error,
33173 ));
33174 }
33175 }
33176 };
33177
33178 dlg.finished(true);
33179 return Ok(response);
33180 }
33181 }
33182 }
33183 }
33184
33185 /// Name of the project in which to look for HMAC keys.
33186 ///
33187 /// Sets the *project id* path property to the given value.
33188 ///
33189 /// Even though the property as already been set when instantiating this call,
33190 /// we provide this method for API completeness.
33191 pub fn project_id(mut self, new_value: &str) -> ProjectHmacKeyListCall<'a, C> {
33192 self._project_id = new_value.to_string();
33193 self
33194 }
33195 /// The project to be billed for this request.
33196 ///
33197 /// Sets the *user project* query property to the given value.
33198 pub fn user_project(mut self, new_value: &str) -> ProjectHmacKeyListCall<'a, C> {
33199 self._user_project = Some(new_value.to_string());
33200 self
33201 }
33202 /// Whether or not to show keys in the DELETED state.
33203 ///
33204 /// Sets the *show deleted keys* query property to the given value.
33205 pub fn show_deleted_keys(mut self, new_value: bool) -> ProjectHmacKeyListCall<'a, C> {
33206 self._show_deleted_keys = Some(new_value);
33207 self
33208 }
33209 /// If present, only keys for the given service account are returned.
33210 ///
33211 /// Sets the *service account email* query property to the given value.
33212 pub fn service_account_email(mut self, new_value: &str) -> ProjectHmacKeyListCall<'a, C> {
33213 self._service_account_email = Some(new_value.to_string());
33214 self
33215 }
33216 /// A previously-returned page token representing part of the larger set of results to view.
33217 ///
33218 /// Sets the *page token* query property to the given value.
33219 pub fn page_token(mut self, new_value: &str) -> ProjectHmacKeyListCall<'a, C> {
33220 self._page_token = Some(new_value.to_string());
33221 self
33222 }
33223 /// 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.
33224 ///
33225 /// Sets the *max results* query property to the given value.
33226 pub fn max_results(mut self, new_value: u32) -> ProjectHmacKeyListCall<'a, C> {
33227 self._max_results = Some(new_value);
33228 self
33229 }
33230 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33231 /// while executing the actual API request.
33232 ///
33233 /// ````text
33234 /// It should be used to handle progress information, and to implement a certain level of resilience.
33235 /// ````
33236 ///
33237 /// Sets the *delegate* property to the given value.
33238 pub fn delegate(
33239 mut self,
33240 new_value: &'a mut dyn common::Delegate,
33241 ) -> ProjectHmacKeyListCall<'a, C> {
33242 self._delegate = Some(new_value);
33243 self
33244 }
33245
33246 /// Set any additional parameter of the query string used in the request.
33247 /// It should be used to set parameters which are not yet available through their own
33248 /// setters.
33249 ///
33250 /// Please note that this method must not be used to set any of the known parameters
33251 /// which have their own setter method. If done anyway, the request will fail.
33252 ///
33253 /// # Additional Parameters
33254 ///
33255 /// * *alt* (query-string) - Data format for the response.
33256 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33257 /// * *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.
33258 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33259 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33260 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
33261 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
33262 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
33263 pub fn param<T>(mut self, name: T, value: T) -> ProjectHmacKeyListCall<'a, C>
33264 where
33265 T: AsRef<str>,
33266 {
33267 self._additional_params
33268 .insert(name.as_ref().to_string(), value.as_ref().to_string());
33269 self
33270 }
33271
33272 /// Identifies the authorization scope for the method you are building.
33273 ///
33274 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33275 /// [`Scope::DevstorageReadOnly`].
33276 ///
33277 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33278 /// tokens for more than one scope.
33279 ///
33280 /// Usually there is more than one suitable scope to authorize an operation, some of which may
33281 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33282 /// sufficient, a read-write scope will do as well.
33283 pub fn add_scope<St>(mut self, scope: St) -> ProjectHmacKeyListCall<'a, C>
33284 where
33285 St: AsRef<str>,
33286 {
33287 self._scopes.insert(String::from(scope.as_ref()));
33288 self
33289 }
33290 /// Identifies the authorization scope(s) for the method you are building.
33291 ///
33292 /// See [`Self::add_scope()`] for details.
33293 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectHmacKeyListCall<'a, C>
33294 where
33295 I: IntoIterator<Item = St>,
33296 St: AsRef<str>,
33297 {
33298 self._scopes
33299 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33300 self
33301 }
33302
33303 /// Removes all scopes, and no default scope will be used either.
33304 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33305 /// for details).
33306 pub fn clear_scopes(mut self) -> ProjectHmacKeyListCall<'a, C> {
33307 self._scopes.clear();
33308 self
33309 }
33310}
33311
33312/// Updates the state of an HMAC key. See the [HMAC Key resource descriptor](https://cloud.google.com/storage/docs/json_api/v1/projects/hmacKeys/update#request-body) for valid states.
33313///
33314/// A builder for the *hmacKeys.update* method supported by a *project* resource.
33315/// It is not used directly, but through a [`ProjectMethods`] instance.
33316///
33317/// # Example
33318///
33319/// Instantiate a resource method builder
33320///
33321/// ```test_harness,no_run
33322/// # extern crate hyper;
33323/// # extern crate hyper_rustls;
33324/// # extern crate google_storage1 as storage1;
33325/// use storage1::api::HmacKeyMetadata;
33326/// # async fn dox() {
33327/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33328///
33329/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33330/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
33331/// # .with_native_roots()
33332/// # .unwrap()
33333/// # .https_only()
33334/// # .enable_http2()
33335/// # .build();
33336///
33337/// # let executor = hyper_util::rt::TokioExecutor::new();
33338/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
33339/// # secret,
33340/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33341/// # yup_oauth2::client::CustomHyperClientBuilder::from(
33342/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
33343/// # ),
33344/// # ).build().await.unwrap();
33345///
33346/// # let client = hyper_util::client::legacy::Client::builder(
33347/// # hyper_util::rt::TokioExecutor::new()
33348/// # )
33349/// # .build(
33350/// # hyper_rustls::HttpsConnectorBuilder::new()
33351/// # .with_native_roots()
33352/// # .unwrap()
33353/// # .https_or_http()
33354/// # .enable_http2()
33355/// # .build()
33356/// # );
33357/// # let mut hub = Storage::new(client, auth);
33358/// // As the method needs a request, you would usually fill it with the desired information
33359/// // into the respective structure. Some of the parts shown here might not be applicable !
33360/// // Values shown here are possibly random and not representative !
33361/// let mut req = HmacKeyMetadata::default();
33362///
33363/// // You can configure optional parameters by calling the respective setters at will, and
33364/// // execute the final call using `doit()`.
33365/// // Values shown here are possibly random and not representative !
33366/// let result = hub.projects().hmac_keys_update(req, "projectId", "accessId")
33367/// .user_project("sea")
33368/// .doit().await;
33369/// # }
33370/// ```
33371pub struct ProjectHmacKeyUpdateCall<'a, C>
33372where
33373 C: 'a,
33374{
33375 hub: &'a Storage<C>,
33376 _request: HmacKeyMetadata,
33377 _project_id: String,
33378 _access_id: String,
33379 _user_project: Option<String>,
33380 _delegate: Option<&'a mut dyn common::Delegate>,
33381 _additional_params: HashMap<String, String>,
33382 _scopes: BTreeSet<String>,
33383}
33384
33385impl<'a, C> common::CallBuilder for ProjectHmacKeyUpdateCall<'a, C> {}
33386
33387impl<'a, C> ProjectHmacKeyUpdateCall<'a, C>
33388where
33389 C: common::Connector,
33390{
33391 /// Perform the operation you have build so far.
33392 pub async fn doit(mut self) -> common::Result<(common::Response, HmacKeyMetadata)> {
33393 use std::borrow::Cow;
33394 use std::io::{Read, Seek};
33395
33396 use common::{url::Params, ToParts};
33397 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33398
33399 let mut dd = common::DefaultDelegate;
33400 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33401 dlg.begin(common::MethodInfo {
33402 id: "storage.projects.hmacKeys.update",
33403 http_method: hyper::Method::PUT,
33404 });
33405
33406 for &field in ["alt", "projectId", "accessId", "userProject"].iter() {
33407 if self._additional_params.contains_key(field) {
33408 dlg.finished(false);
33409 return Err(common::Error::FieldClash(field));
33410 }
33411 }
33412
33413 let mut params = Params::with_capacity(6 + self._additional_params.len());
33414 params.push("projectId", self._project_id);
33415 params.push("accessId", self._access_id);
33416 if let Some(value) = self._user_project.as_ref() {
33417 params.push("userProject", value);
33418 }
33419
33420 params.extend(self._additional_params.iter());
33421
33422 params.push("alt", "json");
33423 let mut url = self.hub._base_url.clone() + "projects/{projectId}/hmacKeys/{accessId}";
33424 if self._scopes.is_empty() {
33425 self._scopes
33426 .insert(Scope::DevstorageFullControl.as_ref().to_string());
33427 }
33428
33429 #[allow(clippy::single_element_loop)]
33430 for &(find_this, param_name) in
33431 [("{projectId}", "projectId"), ("{accessId}", "accessId")].iter()
33432 {
33433 url = params.uri_replacement(url, param_name, find_this, false);
33434 }
33435 {
33436 let to_remove = ["accessId", "projectId"];
33437 params.remove_params(&to_remove);
33438 }
33439
33440 let url = params.parse_with_url(&url);
33441
33442 let mut json_mime_type = mime::APPLICATION_JSON;
33443 let mut request_value_reader = {
33444 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
33445 common::remove_json_null_values(&mut value);
33446 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
33447 serde_json::to_writer(&mut dst, &value).unwrap();
33448 dst
33449 };
33450 let request_size = request_value_reader
33451 .seek(std::io::SeekFrom::End(0))
33452 .unwrap();
33453 request_value_reader
33454 .seek(std::io::SeekFrom::Start(0))
33455 .unwrap();
33456
33457 loop {
33458 let token = match self
33459 .hub
33460 .auth
33461 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33462 .await
33463 {
33464 Ok(token) => token,
33465 Err(e) => match dlg.token(e) {
33466 Ok(token) => token,
33467 Err(e) => {
33468 dlg.finished(false);
33469 return Err(common::Error::MissingToken(e));
33470 }
33471 },
33472 };
33473 request_value_reader
33474 .seek(std::io::SeekFrom::Start(0))
33475 .unwrap();
33476 let mut req_result = {
33477 let client = &self.hub.client;
33478 dlg.pre_request();
33479 let mut req_builder = hyper::Request::builder()
33480 .method(hyper::Method::PUT)
33481 .uri(url.as_str())
33482 .header(USER_AGENT, self.hub._user_agent.clone());
33483
33484 if let Some(token) = token.as_ref() {
33485 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33486 }
33487
33488 let request = req_builder
33489 .header(CONTENT_TYPE, json_mime_type.to_string())
33490 .header(CONTENT_LENGTH, request_size as u64)
33491 .body(common::to_body(
33492 request_value_reader.get_ref().clone().into(),
33493 ));
33494
33495 client.request(request.unwrap()).await
33496 };
33497
33498 match req_result {
33499 Err(err) => {
33500 if let common::Retry::After(d) = dlg.http_error(&err) {
33501 sleep(d).await;
33502 continue;
33503 }
33504 dlg.finished(false);
33505 return Err(common::Error::HttpError(err));
33506 }
33507 Ok(res) => {
33508 let (mut parts, body) = res.into_parts();
33509 let mut body = common::Body::new(body);
33510 if !parts.status.is_success() {
33511 let bytes = common::to_bytes(body).await.unwrap_or_default();
33512 let error = serde_json::from_str(&common::to_string(&bytes));
33513 let response = common::to_response(parts, bytes.into());
33514
33515 if let common::Retry::After(d) =
33516 dlg.http_failure(&response, error.as_ref().ok())
33517 {
33518 sleep(d).await;
33519 continue;
33520 }
33521
33522 dlg.finished(false);
33523
33524 return Err(match error {
33525 Ok(value) => common::Error::BadRequest(value),
33526 _ => common::Error::Failure(response),
33527 });
33528 }
33529 let response = {
33530 let bytes = common::to_bytes(body).await.unwrap_or_default();
33531 let encoded = common::to_string(&bytes);
33532 match serde_json::from_str(&encoded) {
33533 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33534 Err(error) => {
33535 dlg.response_json_decode_error(&encoded, &error);
33536 return Err(common::Error::JsonDecodeError(
33537 encoded.to_string(),
33538 error,
33539 ));
33540 }
33541 }
33542 };
33543
33544 dlg.finished(true);
33545 return Ok(response);
33546 }
33547 }
33548 }
33549 }
33550
33551 ///
33552 /// Sets the *request* property to the given value.
33553 ///
33554 /// Even though the property as already been set when instantiating this call,
33555 /// we provide this method for API completeness.
33556 pub fn request(mut self, new_value: HmacKeyMetadata) -> ProjectHmacKeyUpdateCall<'a, C> {
33557 self._request = new_value;
33558 self
33559 }
33560 /// Project ID owning the service account of the updated key.
33561 ///
33562 /// Sets the *project id* path property to the given value.
33563 ///
33564 /// Even though the property as already been set when instantiating this call,
33565 /// we provide this method for API completeness.
33566 pub fn project_id(mut self, new_value: &str) -> ProjectHmacKeyUpdateCall<'a, C> {
33567 self._project_id = new_value.to_string();
33568 self
33569 }
33570 /// Name of the HMAC key being updated.
33571 ///
33572 /// Sets the *access id* path property to the given value.
33573 ///
33574 /// Even though the property as already been set when instantiating this call,
33575 /// we provide this method for API completeness.
33576 pub fn access_id(mut self, new_value: &str) -> ProjectHmacKeyUpdateCall<'a, C> {
33577 self._access_id = new_value.to_string();
33578 self
33579 }
33580 /// The project to be billed for this request.
33581 ///
33582 /// Sets the *user project* query property to the given value.
33583 pub fn user_project(mut self, new_value: &str) -> ProjectHmacKeyUpdateCall<'a, C> {
33584 self._user_project = Some(new_value.to_string());
33585 self
33586 }
33587 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33588 /// while executing the actual API request.
33589 ///
33590 /// ````text
33591 /// It should be used to handle progress information, and to implement a certain level of resilience.
33592 /// ````
33593 ///
33594 /// Sets the *delegate* property to the given value.
33595 pub fn delegate(
33596 mut self,
33597 new_value: &'a mut dyn common::Delegate,
33598 ) -> ProjectHmacKeyUpdateCall<'a, C> {
33599 self._delegate = Some(new_value);
33600 self
33601 }
33602
33603 /// Set any additional parameter of the query string used in the request.
33604 /// It should be used to set parameters which are not yet available through their own
33605 /// setters.
33606 ///
33607 /// Please note that this method must not be used to set any of the known parameters
33608 /// which have their own setter method. If done anyway, the request will fail.
33609 ///
33610 /// # Additional Parameters
33611 ///
33612 /// * *alt* (query-string) - Data format for the response.
33613 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33614 /// * *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.
33615 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33616 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33617 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
33618 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
33619 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
33620 pub fn param<T>(mut self, name: T, value: T) -> ProjectHmacKeyUpdateCall<'a, C>
33621 where
33622 T: AsRef<str>,
33623 {
33624 self._additional_params
33625 .insert(name.as_ref().to_string(), value.as_ref().to_string());
33626 self
33627 }
33628
33629 /// Identifies the authorization scope for the method you are building.
33630 ///
33631 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33632 /// [`Scope::DevstorageFullControl`].
33633 ///
33634 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33635 /// tokens for more than one scope.
33636 ///
33637 /// Usually there is more than one suitable scope to authorize an operation, some of which may
33638 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33639 /// sufficient, a read-write scope will do as well.
33640 pub fn add_scope<St>(mut self, scope: St) -> ProjectHmacKeyUpdateCall<'a, C>
33641 where
33642 St: AsRef<str>,
33643 {
33644 self._scopes.insert(String::from(scope.as_ref()));
33645 self
33646 }
33647 /// Identifies the authorization scope(s) for the method you are building.
33648 ///
33649 /// See [`Self::add_scope()`] for details.
33650 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectHmacKeyUpdateCall<'a, C>
33651 where
33652 I: IntoIterator<Item = St>,
33653 St: AsRef<str>,
33654 {
33655 self._scopes
33656 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33657 self
33658 }
33659
33660 /// Removes all scopes, and no default scope will be used either.
33661 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33662 /// for details).
33663 pub fn clear_scopes(mut self) -> ProjectHmacKeyUpdateCall<'a, C> {
33664 self._scopes.clear();
33665 self
33666 }
33667}
33668
33669/// Get the email address of this project's Google Cloud Storage service account.
33670///
33671/// A builder for the *serviceAccount.get* method supported by a *project* resource.
33672/// It is not used directly, but through a [`ProjectMethods`] instance.
33673///
33674/// # Example
33675///
33676/// Instantiate a resource method builder
33677///
33678/// ```test_harness,no_run
33679/// # extern crate hyper;
33680/// # extern crate hyper_rustls;
33681/// # extern crate google_storage1 as storage1;
33682/// # async fn dox() {
33683/// # use storage1::{Storage, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33684///
33685/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33686/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
33687/// # .with_native_roots()
33688/// # .unwrap()
33689/// # .https_only()
33690/// # .enable_http2()
33691/// # .build();
33692///
33693/// # let executor = hyper_util::rt::TokioExecutor::new();
33694/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
33695/// # secret,
33696/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33697/// # yup_oauth2::client::CustomHyperClientBuilder::from(
33698/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
33699/// # ),
33700/// # ).build().await.unwrap();
33701///
33702/// # let client = hyper_util::client::legacy::Client::builder(
33703/// # hyper_util::rt::TokioExecutor::new()
33704/// # )
33705/// # .build(
33706/// # hyper_rustls::HttpsConnectorBuilder::new()
33707/// # .with_native_roots()
33708/// # .unwrap()
33709/// # .https_or_http()
33710/// # .enable_http2()
33711/// # .build()
33712/// # );
33713/// # let mut hub = Storage::new(client, auth);
33714/// // You can configure optional parameters by calling the respective setters at will, and
33715/// // execute the final call using `doit()`.
33716/// // Values shown here are possibly random and not representative !
33717/// let result = hub.projects().service_account_get("projectId")
33718/// .user_project("amet.")
33719/// .doit().await;
33720/// # }
33721/// ```
33722pub struct ProjectServiceAccountGetCall<'a, C>
33723where
33724 C: 'a,
33725{
33726 hub: &'a Storage<C>,
33727 _project_id: String,
33728 _user_project: Option<String>,
33729 _delegate: Option<&'a mut dyn common::Delegate>,
33730 _additional_params: HashMap<String, String>,
33731 _scopes: BTreeSet<String>,
33732}
33733
33734impl<'a, C> common::CallBuilder for ProjectServiceAccountGetCall<'a, C> {}
33735
33736impl<'a, C> ProjectServiceAccountGetCall<'a, C>
33737where
33738 C: common::Connector,
33739{
33740 /// Perform the operation you have build so far.
33741 pub async fn doit(mut self) -> common::Result<(common::Response, ServiceAccount)> {
33742 use std::borrow::Cow;
33743 use std::io::{Read, Seek};
33744
33745 use common::{url::Params, ToParts};
33746 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33747
33748 let mut dd = common::DefaultDelegate;
33749 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33750 dlg.begin(common::MethodInfo {
33751 id: "storage.projects.serviceAccount.get",
33752 http_method: hyper::Method::GET,
33753 });
33754
33755 for &field in ["alt", "projectId", "userProject"].iter() {
33756 if self._additional_params.contains_key(field) {
33757 dlg.finished(false);
33758 return Err(common::Error::FieldClash(field));
33759 }
33760 }
33761
33762 let mut params = Params::with_capacity(4 + self._additional_params.len());
33763 params.push("projectId", self._project_id);
33764 if let Some(value) = self._user_project.as_ref() {
33765 params.push("userProject", value);
33766 }
33767
33768 params.extend(self._additional_params.iter());
33769
33770 params.push("alt", "json");
33771 let mut url = self.hub._base_url.clone() + "projects/{projectId}/serviceAccount";
33772 if self._scopes.is_empty() {
33773 self._scopes
33774 .insert(Scope::DevstorageReadOnly.as_ref().to_string());
33775 }
33776
33777 #[allow(clippy::single_element_loop)]
33778 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
33779 url = params.uri_replacement(url, param_name, find_this, false);
33780 }
33781 {
33782 let to_remove = ["projectId"];
33783 params.remove_params(&to_remove);
33784 }
33785
33786 let url = params.parse_with_url(&url);
33787
33788 loop {
33789 let token = match self
33790 .hub
33791 .auth
33792 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33793 .await
33794 {
33795 Ok(token) => token,
33796 Err(e) => match dlg.token(e) {
33797 Ok(token) => token,
33798 Err(e) => {
33799 dlg.finished(false);
33800 return Err(common::Error::MissingToken(e));
33801 }
33802 },
33803 };
33804 let mut req_result = {
33805 let client = &self.hub.client;
33806 dlg.pre_request();
33807 let mut req_builder = hyper::Request::builder()
33808 .method(hyper::Method::GET)
33809 .uri(url.as_str())
33810 .header(USER_AGENT, self.hub._user_agent.clone());
33811
33812 if let Some(token) = token.as_ref() {
33813 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33814 }
33815
33816 let request = req_builder
33817 .header(CONTENT_LENGTH, 0_u64)
33818 .body(common::to_body::<String>(None));
33819
33820 client.request(request.unwrap()).await
33821 };
33822
33823 match req_result {
33824 Err(err) => {
33825 if let common::Retry::After(d) = dlg.http_error(&err) {
33826 sleep(d).await;
33827 continue;
33828 }
33829 dlg.finished(false);
33830 return Err(common::Error::HttpError(err));
33831 }
33832 Ok(res) => {
33833 let (mut parts, body) = res.into_parts();
33834 let mut body = common::Body::new(body);
33835 if !parts.status.is_success() {
33836 let bytes = common::to_bytes(body).await.unwrap_or_default();
33837 let error = serde_json::from_str(&common::to_string(&bytes));
33838 let response = common::to_response(parts, bytes.into());
33839
33840 if let common::Retry::After(d) =
33841 dlg.http_failure(&response, error.as_ref().ok())
33842 {
33843 sleep(d).await;
33844 continue;
33845 }
33846
33847 dlg.finished(false);
33848
33849 return Err(match error {
33850 Ok(value) => common::Error::BadRequest(value),
33851 _ => common::Error::Failure(response),
33852 });
33853 }
33854 let response = {
33855 let bytes = common::to_bytes(body).await.unwrap_or_default();
33856 let encoded = common::to_string(&bytes);
33857 match serde_json::from_str(&encoded) {
33858 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33859 Err(error) => {
33860 dlg.response_json_decode_error(&encoded, &error);
33861 return Err(common::Error::JsonDecodeError(
33862 encoded.to_string(),
33863 error,
33864 ));
33865 }
33866 }
33867 };
33868
33869 dlg.finished(true);
33870 return Ok(response);
33871 }
33872 }
33873 }
33874 }
33875
33876 /// Project ID
33877 ///
33878 /// Sets the *project id* path property to the given value.
33879 ///
33880 /// Even though the property as already been set when instantiating this call,
33881 /// we provide this method for API completeness.
33882 pub fn project_id(mut self, new_value: &str) -> ProjectServiceAccountGetCall<'a, C> {
33883 self._project_id = new_value.to_string();
33884 self
33885 }
33886 /// The project to be billed for this request.
33887 ///
33888 /// Sets the *user project* query property to the given value.
33889 pub fn user_project(mut self, new_value: &str) -> ProjectServiceAccountGetCall<'a, C> {
33890 self._user_project = Some(new_value.to_string());
33891 self
33892 }
33893 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33894 /// while executing the actual API request.
33895 ///
33896 /// ````text
33897 /// It should be used to handle progress information, and to implement a certain level of resilience.
33898 /// ````
33899 ///
33900 /// Sets the *delegate* property to the given value.
33901 pub fn delegate(
33902 mut self,
33903 new_value: &'a mut dyn common::Delegate,
33904 ) -> ProjectServiceAccountGetCall<'a, C> {
33905 self._delegate = Some(new_value);
33906 self
33907 }
33908
33909 /// Set any additional parameter of the query string used in the request.
33910 /// It should be used to set parameters which are not yet available through their own
33911 /// setters.
33912 ///
33913 /// Please note that this method must not be used to set any of the known parameters
33914 /// which have their own setter method. If done anyway, the request will fail.
33915 ///
33916 /// # Additional Parameters
33917 ///
33918 /// * *alt* (query-string) - Data format for the response.
33919 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33920 /// * *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.
33921 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33922 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33923 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
33924 /// * *uploadType* (query-string) - Upload protocol for media (e.g. "media", "multipart", "resumable").
33925 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
33926 pub fn param<T>(mut self, name: T, value: T) -> ProjectServiceAccountGetCall<'a, C>
33927 where
33928 T: AsRef<str>,
33929 {
33930 self._additional_params
33931 .insert(name.as_ref().to_string(), value.as_ref().to_string());
33932 self
33933 }
33934
33935 /// Identifies the authorization scope for the method you are building.
33936 ///
33937 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33938 /// [`Scope::DevstorageReadOnly`].
33939 ///
33940 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33941 /// tokens for more than one scope.
33942 ///
33943 /// Usually there is more than one suitable scope to authorize an operation, some of which may
33944 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33945 /// sufficient, a read-write scope will do as well.
33946 pub fn add_scope<St>(mut self, scope: St) -> ProjectServiceAccountGetCall<'a, C>
33947 where
33948 St: AsRef<str>,
33949 {
33950 self._scopes.insert(String::from(scope.as_ref()));
33951 self
33952 }
33953 /// Identifies the authorization scope(s) for the method you are building.
33954 ///
33955 /// See [`Self::add_scope()`] for details.
33956 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectServiceAccountGetCall<'a, C>
33957 where
33958 I: IntoIterator<Item = St>,
33959 St: AsRef<str>,
33960 {
33961 self._scopes
33962 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33963 self
33964 }
33965
33966 /// Removes all scopes, and no default scope will be used either.
33967 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33968 /// for details).
33969 pub fn clear_scopes(mut self) -> ProjectServiceAccountGetCall<'a, C> {
33970 self._scopes.clear();
33971 self
33972 }
33973}