google_file1/
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    /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17    CloudPlatform,
18}
19
20impl AsRef<str> for Scope {
21    fn as_ref(&self) -> &str {
22        match *self {
23            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
24        }
25    }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30    fn default() -> Scope {
31        Scope::CloudPlatform
32    }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all CloudFilestore related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_file1 as file1;
49/// use file1::api::Backup;
50/// use file1::{Result, Error};
51/// # async fn dox() {
52/// use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace  `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
63///     .with_native_roots()
64///     .unwrap()
65///     .https_only()
66///     .enable_http2()
67///     .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71///     secret,
72///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73///     yup_oauth2::client::CustomHyperClientBuilder::from(
74///         hyper_util::client::legacy::Client::builder(executor).build(connector),
75///     ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79///     hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82///     hyper_rustls::HttpsConnectorBuilder::new()
83///         .with_native_roots()
84///         .unwrap()
85///         .https_or_http()
86///         .enable_http2()
87///         .build()
88/// );
89/// let mut hub = CloudFilestore::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = Backup::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.projects().locations_backups_create(req, "parent")
99///              .backup_id("At")
100///              .doit().await;
101///
102/// match result {
103///     Err(e) => match e {
104///         // The Error enum provides details about what exactly happened.
105///         // You can also just use its `Debug`, `Display` or `Error` traits
106///          Error::HttpError(_)
107///         |Error::Io(_)
108///         |Error::MissingAPIKey
109///         |Error::MissingToken(_)
110///         |Error::Cancelled
111///         |Error::UploadSizeLimitExceeded(_, _)
112///         |Error::Failure(_)
113///         |Error::BadRequest(_)
114///         |Error::FieldClash(_)
115///         |Error::JsonDecodeError(_, _) => println!("{}", e),
116///     },
117///     Ok(res) => println!("Success: {:?}", res),
118/// }
119/// # }
120/// ```
121#[derive(Clone)]
122pub struct CloudFilestore<C> {
123    pub client: common::Client<C>,
124    pub auth: Box<dyn common::GetToken>,
125    _user_agent: String,
126    _base_url: String,
127    _root_url: String,
128}
129
130impl<C> common::Hub for CloudFilestore<C> {}
131
132impl<'a, C> CloudFilestore<C> {
133    pub fn new<A: 'static + common::GetToken>(
134        client: common::Client<C>,
135        auth: A,
136    ) -> CloudFilestore<C> {
137        CloudFilestore {
138            client,
139            auth: Box::new(auth),
140            _user_agent: "google-api-rust-client/7.0.0".to_string(),
141            _base_url: "https://file.googleapis.com/".to_string(),
142            _root_url: "https://file.googleapis.com/".to_string(),
143        }
144    }
145
146    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
147        ProjectMethods { hub: self }
148    }
149
150    /// Set the user-agent header field to use in all requests to the server.
151    /// It defaults to `google-api-rust-client/7.0.0`.
152    ///
153    /// Returns the previously set user-agent.
154    pub fn user_agent(&mut self, agent_name: String) -> String {
155        std::mem::replace(&mut self._user_agent, agent_name)
156    }
157
158    /// Set the base url to use in all requests to the server.
159    /// It defaults to `https://file.googleapis.com/`.
160    ///
161    /// Returns the previously set base url.
162    pub fn base_url(&mut self, new_base_url: String) -> String {
163        std::mem::replace(&mut self._base_url, new_base_url)
164    }
165
166    /// Set the root url to use in all requests to the server.
167    /// It defaults to `https://file.googleapis.com/`.
168    ///
169    /// Returns the previously set root url.
170    pub fn root_url(&mut self, new_root_url: String) -> String {
171        std::mem::replace(&mut self._root_url, new_root_url)
172    }
173}
174
175// ############
176// SCHEMAS ###
177// ##########
178/// A Filestore backup.
179///
180/// # Activities
181///
182/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
183/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
184///
185/// * [locations backups create projects](ProjectLocationBackupCreateCall) (request)
186/// * [locations backups get projects](ProjectLocationBackupGetCall) (response)
187/// * [locations backups patch projects](ProjectLocationBackupPatchCall) (request)
188#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
189#[serde_with::serde_as]
190#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
191pub struct Backup {
192    /// Output only. Capacity of the source file share when the backup was created.
193    #[serde(rename = "capacityGb")]
194    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
195    pub capacity_gb: Option<i64>,
196    /// Output only. The time when the backup was created.
197    #[serde(rename = "createTime")]
198    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
199    /// A description of the backup with 2048 characters or less. Requests with longer descriptions will be rejected.
200    pub description: Option<String>,
201    /// Output only. Amount of bytes that will be downloaded if the backup is restored. This may be different than storage bytes, since sequential backups of the same disk will share storage.
202    #[serde(rename = "downloadBytes")]
203    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
204    pub download_bytes: Option<i64>,
205    /// Output only. The file system protocol of the source Filestore instance that this backup is created from.
206    #[serde(rename = "fileSystemProtocol")]
207    pub file_system_protocol: Option<String>,
208    /// Immutable. KMS key name used for data encryption.
209    #[serde(rename = "kmsKey")]
210    pub kms_key: Option<String>,
211    /// Resource labels to represent user provided metadata.
212    pub labels: Option<HashMap<String, String>>,
213    /// Output only. The resource name of the backup, in the format `projects/{project_number}/locations/{location_id}/backups/{backup_id}`.
214    pub name: Option<String>,
215    /// Output only. Reserved for future use.
216    #[serde(rename = "satisfiesPzi")]
217    pub satisfies_pzi: Option<bool>,
218    /// Output only. Reserved for future use.
219    #[serde(rename = "satisfiesPzs")]
220    pub satisfies_pzs: Option<bool>,
221    /// Name of the file share in the source Filestore instance that the backup is created from.
222    #[serde(rename = "sourceFileShare")]
223    pub source_file_share: Option<String>,
224    /// The resource name of the source Filestore instance, in the format `projects/{project_number}/locations/{location_id}/instances/{instance_id}`, used to create this backup.
225    #[serde(rename = "sourceInstance")]
226    pub source_instance: Option<String>,
227    /// Output only. The service tier of the source Filestore instance that this backup is created from.
228    #[serde(rename = "sourceInstanceTier")]
229    pub source_instance_tier: Option<String>,
230    /// Output only. The backup state.
231    pub state: Option<String>,
232    /// Output only. The size of the storage used by the backup. As backups share storage, this number is expected to change with backup creation/deletion.
233    #[serde(rename = "storageBytes")]
234    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
235    pub storage_bytes: Option<i64>,
236    /// Optional. Input only. Immutable. Tag key-value pairs bound to this resource. Each key must be a namespaced name and each value a short name. Example: "123456789012/environment" : "production", "123456789013/costCenter" : "marketing" See the documentation for more information: - Namespaced name: https://cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing#retrieving_tag_key - Short name: https://cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing#retrieving_tag_value
237    pub tags: Option<HashMap<String, String>>,
238}
239
240impl common::RequestValue for Backup {}
241impl common::ResponseResult for Backup {}
242
243/// The request message for Operations.CancelOperation.
244///
245/// # Activities
246///
247/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
248/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
249///
250/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (request)
251#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
252#[serde_with::serde_as]
253#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
254pub struct CancelOperationRequest {
255    _never_set: Option<bool>,
256}
257
258impl common::RequestValue for CancelOperationRequest {}
259
260/// Directory Services configuration for Kerberos-based authentication.
261///
262/// This type is not used in any activity, and only used as *part* of another schema.
263///
264#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
265#[serde_with::serde_as]
266#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
267pub struct DirectoryServicesConfig {
268    /// Configuration for LDAP servers.
269    pub ldap: Option<LdapConfig>,
270}
271
272impl common::Part for DirectoryServicesConfig {}
273
274/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
275///
276/// # Activities
277///
278/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
279/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
280///
281/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
282/// * [locations operations delete projects](ProjectLocationOperationDeleteCall) (response)
283#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
284#[serde_with::serde_as]
285#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
286pub struct Empty {
287    _never_set: Option<bool>,
288}
289
290impl common::ResponseResult for Empty {}
291
292/// File share configuration for the instance.
293///
294/// This type is not used in any activity, and only used as *part* of another schema.
295///
296#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
297#[serde_with::serde_as]
298#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
299pub struct FileShareConfig {
300    /// File share capacity in gigabytes (GB). Filestore defines 1 GB as 1024^3 bytes.
301    #[serde(rename = "capacityGb")]
302    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
303    pub capacity_gb: Option<i64>,
304    /// Required. The name of the file share. Must use 1-16 characters for the basic service tier and 1-63 characters for all other service tiers. Must use lowercase letters, numbers, or underscores `[a-z0-9_]`. Must start with a letter. Immutable.
305    pub name: Option<String>,
306    /// Nfs Export Options. There is a limit of 10 export options per file share.
307    #[serde(rename = "nfsExportOptions")]
308    pub nfs_export_options: Option<Vec<NfsExportOptions>>,
309    /// The resource name of the backup, in the format `projects/{project_number}/locations/{location_id}/backups/{backup_id}`, that this file share has been restored from.
310    #[serde(rename = "sourceBackup")]
311    pub source_backup: Option<String>,
312    /// The resource name of the BackupDR backup, in the format `projects/{project_id}/locations/{location_id}/backupVaults/{backupvault_id}/dataSources/{datasource_id}/backups/{backup_id}`, TODO (b/443690479) - Remove visibility restrictions once the feature is ready
313    #[serde(rename = "sourceBackupdrBackup")]
314    pub source_backupdr_backup: Option<String>,
315}
316
317impl common::Part for FileShareConfig {}
318
319/// Fixed IOPS (input/output operations per second) parameters.
320///
321/// This type is not used in any activity, and only used as *part* of another schema.
322///
323#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
324#[serde_with::serde_as]
325#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
326pub struct FixedIOPS {
327    /// Required. Maximum IOPS.
328    #[serde(rename = "maxIops")]
329    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
330    pub max_iops: Option<i64>,
331}
332
333impl common::Part for FixedIOPS {}
334
335/// IOPS per TB. Filestore defines TB as 1024^4 bytes (TiB).
336///
337/// This type is not used in any activity, and only used as *part* of another schema.
338///
339#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
340#[serde_with::serde_as]
341#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
342pub struct IOPSPerTB {
343    /// Required. Maximum IOPS per TiB.
344    #[serde(rename = "maxIopsPerTb")]
345    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
346    pub max_iops_per_tb: Option<i64>,
347}
348
349impl common::Part for IOPSPerTB {}
350
351/// A Filestore instance.
352///
353/// # Activities
354///
355/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
356/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
357///
358/// * [locations instances create projects](ProjectLocationInstanceCreateCall) (request)
359/// * [locations instances get projects](ProjectLocationInstanceGetCall) (response)
360/// * [locations instances patch projects](ProjectLocationInstancePatchCall) (request)
361#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
362#[serde_with::serde_as]
363#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
364pub struct Instance {
365    /// Output only. The incremental increase or decrease in capacity, designated in some number of GB.
366    #[serde(rename = "capacityStepSizeGb")]
367    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
368    pub capacity_step_size_gb: Option<i64>,
369    /// Output only. The time when the instance was created.
370    #[serde(rename = "createTime")]
371    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
372    /// Output only. Indicates whether this instance supports configuring its performance. If true, the user can configure the instance's performance by using the 'performance_config' field.
373    #[serde(rename = "customPerformanceSupported")]
374    pub custom_performance_supported: Option<bool>,
375    /// Optional. Indicates whether the instance is protected against deletion.
376    #[serde(rename = "deletionProtectionEnabled")]
377    pub deletion_protection_enabled: Option<bool>,
378    /// Optional. The reason for enabling deletion protection.
379    #[serde(rename = "deletionProtectionReason")]
380    pub deletion_protection_reason: Option<String>,
381    /// The description of the instance (2048 characters or less).
382    pub description: Option<String>,
383    /// Optional. Directory Services configuration for Kerberos-based authentication. Should only be set if protocol is "NFS_V4_1".
384    #[serde(rename = "directoryServices")]
385    pub directory_services: Option<DirectoryServicesConfig>,
386    /// Server-specified ETag for the instance resource to prevent simultaneous updates from overwriting each other.
387    pub etag: Option<String>,
388    /// File system shares on the instance. For this version, only a single file share is supported.
389    #[serde(rename = "fileShares")]
390    pub file_shares: Option<Vec<FileShareConfig>>,
391    /// KMS key name used for data encryption.
392    #[serde(rename = "kmsKeyName")]
393    pub kms_key_name: Option<String>,
394    /// Resource labels to represent user provided metadata.
395    pub labels: Option<HashMap<String, String>>,
396    /// Output only. The maximum capacity of the instance in GB.
397    #[serde(rename = "maxCapacityGb")]
398    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
399    pub max_capacity_gb: Option<i64>,
400    /// Output only. The minimum capacity of the instance in GB.
401    #[serde(rename = "minCapacityGb")]
402    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
403    pub min_capacity_gb: Option<i64>,
404    /// Output only. The resource name of the instance, in the format `projects/{project}/locations/{location}/instances/{instance}`.
405    pub name: Option<String>,
406    /// VPC networks to which the instance is connected. For this version, only a single network is supported.
407    pub networks: Option<Vec<NetworkConfig>>,
408    /// Optional. Used to configure performance.
409    #[serde(rename = "performanceConfig")]
410    pub performance_config: Option<PerformanceConfig>,
411    /// Output only. Used for getting performance limits.
412    #[serde(rename = "performanceLimits")]
413    pub performance_limits: Option<PerformanceLimits>,
414    /// Immutable. The protocol indicates the access protocol for all shares in the instance. This field is immutable and it cannot be changed after the instance has been created. Default value: `NFS_V3`.
415    pub protocol: Option<String>,
416    /// Optional. Replication configuration.
417    pub replication: Option<Replication>,
418    /// Output only. Reserved for future use.
419    #[serde(rename = "satisfiesPzi")]
420    pub satisfies_pzi: Option<bool>,
421    /// Output only. Reserved for future use.
422    #[serde(rename = "satisfiesPzs")]
423    pub satisfies_pzs: Option<bool>,
424    /// Output only. The instance state.
425    pub state: Option<String>,
426    /// Output only. Additional information about the instance state, if available.
427    #[serde(rename = "statusMessage")]
428    pub status_message: Option<String>,
429    /// Output only. Field indicates all the reasons the instance is in "SUSPENDED" state.
430    #[serde(rename = "suspensionReasons")]
431    pub suspension_reasons: Option<Vec<String>>,
432    /// Optional. Input only. Immutable. Tag key-value pairs bound to this resource. Each key must be a namespaced name and each value a short name. Example: "123456789012/environment" : "production", "123456789013/costCenter" : "marketing" See the documentation for more information: - Namespaced name: https://cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing#retrieving_tag_key - Short name: https://cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing#retrieving_tag_value
433    pub tags: Option<HashMap<String, String>>,
434    /// The service tier of the instance.
435    pub tier: Option<String>,
436}
437
438impl common::RequestValue for Instance {}
439impl common::ResponseResult for Instance {}
440
441/// LdapConfig contains all the parameters for connecting to LDAP servers.
442///
443/// This type is not used in any activity, and only used as *part* of another schema.
444///
445#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
446#[serde_with::serde_as]
447#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
448pub struct LdapConfig {
449    /// Required. The LDAP domain name in the format of `my-domain.com`.
450    pub domain: Option<String>,
451    /// Optional. The groups Organizational Unit (OU) is optional. This parameter is a hint to allow faster lookup in the LDAP namespace. In case that this parameter is not provided, Filestore instance will query the whole LDAP namespace.
452    #[serde(rename = "groupsOu")]
453    pub groups_ou: Option<String>,
454    /// Required. The servers names are used for specifying the LDAP servers names. The LDAP servers names can come with two formats: 1. DNS name, for example: `ldap.example1.com`, `ldap.example2.com`. 2. IP address, for example: `10.0.0.1`, `10.0.0.2`, `10.0.0.3`. All servers names must be in the same format: either all DNS names or all IP addresses.
455    pub servers: Option<Vec<String>>,
456    /// Optional. The users Organizational Unit (OU) is optional. This parameter is a hint to allow faster lookup in the LDAP namespace. In case that this parameter is not provided, Filestore instance will query the whole LDAP namespace.
457    #[serde(rename = "usersOu")]
458    pub users_ou: Option<String>,
459}
460
461impl common::Part for LdapConfig {}
462
463/// ListBackupsResponse is the result of ListBackupsRequest.
464///
465/// # Activities
466///
467/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
468/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
469///
470/// * [locations backups list projects](ProjectLocationBackupListCall) (response)
471#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
472#[serde_with::serde_as]
473#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
474pub struct ListBackupsResponse {
475    /// A list of backups in the project for the specified location. If the `{location}` value in the request is "-", the response contains a list of backups from all locations. If any location is unreachable, the response will only return backups in reachable locations and the "unreachable" field will be populated with a list of unreachable locations.
476    pub backups: Option<Vec<Backup>>,
477    /// The token you can use to retrieve the next page of results. Not returned if there are no more results in the list.
478    #[serde(rename = "nextPageToken")]
479    pub next_page_token: Option<String>,
480    /// Unordered list. Locations that could not be reached.
481    pub unreachable: Option<Vec<String>>,
482}
483
484impl common::ResponseResult for ListBackupsResponse {}
485
486/// ListInstancesResponse is the result of ListInstancesRequest.
487///
488/// # Activities
489///
490/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
491/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
492///
493/// * [locations instances list projects](ProjectLocationInstanceListCall) (response)
494#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
495#[serde_with::serde_as]
496#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
497pub struct ListInstancesResponse {
498    /// A list of instances in the project for the specified location. If the `{location}` value in the request is "-", the response contains a list of instances from all locations. If any location is unreachable, the response will only return instances in reachable locations and the "unreachable" field will be populated with a list of unreachable locations.
499    pub instances: Option<Vec<Instance>>,
500    /// The token you can use to retrieve the next page of results. Not returned if there are no more results in the list.
501    #[serde(rename = "nextPageToken")]
502    pub next_page_token: Option<String>,
503    /// Unordered list. Locations that could not be reached.
504    pub unreachable: Option<Vec<String>>,
505}
506
507impl common::ResponseResult for ListInstancesResponse {}
508
509/// The response message for Locations.ListLocations.
510///
511/// # Activities
512///
513/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
514/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
515///
516/// * [locations list projects](ProjectLocationListCall) (response)
517#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
518#[serde_with::serde_as]
519#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
520pub struct ListLocationsResponse {
521    /// A list of locations that matches the specified filter in the request.
522    pub locations: Option<Vec<Location>>,
523    /// The standard List next-page token.
524    #[serde(rename = "nextPageToken")]
525    pub next_page_token: Option<String>,
526}
527
528impl common::ResponseResult for ListLocationsResponse {}
529
530/// The response message for Operations.ListOperations.
531///
532/// # Activities
533///
534/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
535/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
536///
537/// * [locations operations list projects](ProjectLocationOperationListCall) (response)
538#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
539#[serde_with::serde_as]
540#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
541pub struct ListOperationsResponse {
542    /// The standard List next-page token.
543    #[serde(rename = "nextPageToken")]
544    pub next_page_token: Option<String>,
545    /// A list of operations that matches the specified filter in the request.
546    pub operations: Option<Vec<Operation>>,
547    /// Unordered list. Unreachable resources. Populated when the request sets `ListOperationsRequest.return_partial_success` and reads across collections. For example, when attempting to list all resources across all supported locations.
548    pub unreachable: Option<Vec<String>>,
549}
550
551impl common::ResponseResult for ListOperationsResponse {}
552
553/// ListSnapshotsResponse is the result of ListSnapshotsRequest.
554///
555/// # Activities
556///
557/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
558/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
559///
560/// * [locations instances snapshots list projects](ProjectLocationInstanceSnapshotListCall) (response)
561#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
562#[serde_with::serde_as]
563#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
564pub struct ListSnapshotsResponse {
565    /// The token you can use to retrieve the next page of results. Not returned if there are no more results in the list.
566    #[serde(rename = "nextPageToken")]
567    pub next_page_token: Option<String>,
568    /// A list of snapshots in the project for the specified instance.
569    pub snapshots: Option<Vec<Snapshot>>,
570    /// Unordered list. Locations that could not be reached.
571    pub unreachable: Option<Vec<String>>,
572}
573
574impl common::ResponseResult for ListSnapshotsResponse {}
575
576/// A resource that represents a Google Cloud location.
577///
578/// # Activities
579///
580/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
581/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
582///
583/// * [locations get projects](ProjectLocationGetCall) (response)
584#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
585#[serde_with::serde_as]
586#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
587pub struct Location {
588    /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
589    #[serde(rename = "displayName")]
590    pub display_name: Option<String>,
591    /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
592    pub labels: Option<HashMap<String, String>>,
593    /// The canonical id for this location. For example: `"us-east1"`.
594    #[serde(rename = "locationId")]
595    pub location_id: Option<String>,
596    /// Service-specific metadata. For example the available capacity at the given location.
597    pub metadata: Option<HashMap<String, serde_json::Value>>,
598    /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
599    pub name: Option<String>,
600}
601
602impl common::ResponseResult for Location {}
603
604/// Network configuration for the instance.
605///
606/// This type is not used in any activity, and only used as *part* of another schema.
607///
608#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
609#[serde_with::serde_as]
610#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
611pub struct NetworkConfig {
612    /// The network connect mode of the Filestore instance. If not provided, the connect mode defaults to DIRECT_PEERING.
613    #[serde(rename = "connectMode")]
614    pub connect_mode: Option<String>,
615    /// Output only. IPv4 addresses in the format `{octet1}.{octet2}.{octet3}.{octet4}` or IPv6 addresses in the format `{block1}:{block2}:{block3}:{block4}:{block5}:{block6}:{block7}:{block8}`.
616    #[serde(rename = "ipAddresses")]
617    pub ip_addresses: Option<Vec<String>>,
618    /// Internet protocol versions for which the instance has IP addresses assigned. For this version, only MODE_IPV4 is supported.
619    pub modes: Option<Vec<String>>,
620    /// The name of the Google Compute Engine [VPC network](https://cloud.google.com/vpc/docs/vpc) to which the instance is connected.
621    pub network: Option<String>,
622    /// Optional. Private Service Connect configuration. Should only be set when connect_mode is PRIVATE_SERVICE_CONNECT.
623    #[serde(rename = "pscConfig")]
624    pub psc_config: Option<PscConfig>,
625    /// Optional, reserved_ip_range can have one of the following two types of values. * CIDR range value when using DIRECT_PEERING connect mode. * [Allocated IP address range](https://cloud.google.com/compute/docs/ip-addresses/reserve-static-internal-ip-address) when using PRIVATE_SERVICE_ACCESS connect mode. When the name of an allocated IP address range is specified, it must be one of the ranges associated with the private service access connection. When specified as a direct CIDR value, it must be a /29 CIDR block for Basic tier, a /24 CIDR block for High Scale tier, or a /26 CIDR block for Enterprise tier in one of the [internal IP address ranges](https://www.arin.net/reference/research/statistics/address_filters/) that identifies the range of IP addresses reserved for this instance. For example, 10.0.0.0/29, 192.168.0.0/24 or 192.168.0.0/26, respectively. The range you specify can't overlap with either existing subnets or assigned IP address ranges for other Filestore instances in the selected VPC network.
626    #[serde(rename = "reservedIpRange")]
627    pub reserved_ip_range: Option<String>,
628}
629
630impl common::Part for NetworkConfig {}
631
632/// NFS export options specifications.
633///
634/// This type is not used in any activity, and only used as *part* of another schema.
635///
636#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
637#[serde_with::serde_as]
638#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
639pub struct NfsExportOptions {
640    /// Either READ_ONLY, for allowing only read requests on the exported directory, or READ_WRITE, for allowing both read and write requests. The default is READ_WRITE.
641    #[serde(rename = "accessMode")]
642    pub access_mode: Option<String>,
643    /// An integer representing the anonymous group id with a default value of 65534. Anon_gid may only be set with squash_mode of ROOT_SQUASH. An error will be returned if this field is specified for other squash_mode settings.
644    #[serde(rename = "anonGid")]
645    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
646    pub anon_gid: Option<i64>,
647    /// An integer representing the anonymous user id with a default value of 65534. Anon_uid may only be set with squash_mode of ROOT_SQUASH. An error will be returned if this field is specified for other squash_mode settings.
648    #[serde(rename = "anonUid")]
649    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
650    pub anon_uid: Option<i64>,
651    /// List of either an IPv4 addresses in the format `{octet1}.{octet2}.{octet3}.{octet4}` or CIDR ranges in the format `{octet1}.{octet2}.{octet3}.{octet4}/{mask size}` which may mount the file share. Overlapping IP ranges are not allowed, both within and across NfsExportOptions. An error will be returned. The limit is 64 IP ranges/addresses for each FileShareConfig among all NfsExportOptions.
652    #[serde(rename = "ipRanges")]
653    pub ip_ranges: Option<Vec<String>>,
654    /// Optional. The source VPC network for ip_ranges. Required for instances using Private Service Connect, optional otherwise. If provided, must be the same network specified in the `NetworkConfig.network` field.
655    pub network: Option<String>,
656    /// Either NO_ROOT_SQUASH, for allowing root access on the exported directory, or ROOT_SQUASH, for not allowing root access. The default is NO_ROOT_SQUASH.
657    #[serde(rename = "squashMode")]
658    pub squash_mode: Option<String>,
659}
660
661impl common::Part for NfsExportOptions {}
662
663/// This resource represents a long-running operation that is the result of a network API call.
664///
665/// # Activities
666///
667/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
668/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
669///
670/// * [locations backups create projects](ProjectLocationBackupCreateCall) (response)
671/// * [locations backups delete projects](ProjectLocationBackupDeleteCall) (response)
672/// * [locations backups patch projects](ProjectLocationBackupPatchCall) (response)
673/// * [locations instances snapshots create projects](ProjectLocationInstanceSnapshotCreateCall) (response)
674/// * [locations instances snapshots delete projects](ProjectLocationInstanceSnapshotDeleteCall) (response)
675/// * [locations instances snapshots patch projects](ProjectLocationInstanceSnapshotPatchCall) (response)
676/// * [locations instances create projects](ProjectLocationInstanceCreateCall) (response)
677/// * [locations instances delete projects](ProjectLocationInstanceDeleteCall) (response)
678/// * [locations instances patch projects](ProjectLocationInstancePatchCall) (response)
679/// * [locations instances pause replica projects](ProjectLocationInstancePauseReplicaCall) (response)
680/// * [locations instances promote replica projects](ProjectLocationInstancePromoteReplicaCall) (response)
681/// * [locations instances restore projects](ProjectLocationInstanceRestoreCall) (response)
682/// * [locations instances resume replica projects](ProjectLocationInstanceResumeReplicaCall) (response)
683/// * [locations instances revert projects](ProjectLocationInstanceRevertCall) (response)
684/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
685#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
686#[serde_with::serde_as]
687#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
688pub struct Operation {
689    /// 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.
690    pub done: Option<bool>,
691    /// The error result of the operation in case of failure or cancellation.
692    pub error: Option<Status>,
693    /// 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.
694    pub metadata: Option<HashMap<String, serde_json::Value>>,
695    /// 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/{unique_id}`.
696    pub name: Option<String>,
697    /// The normal, successful response of the operation. 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`.
698    pub response: Option<HashMap<String, serde_json::Value>>,
699}
700
701impl common::ResponseResult for Operation {}
702
703/// PauseReplicaRequest pauses a Filestore standby instance (replica).
704///
705/// # Activities
706///
707/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
708/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
709///
710/// * [locations instances pause replica projects](ProjectLocationInstancePauseReplicaCall) (request)
711#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
712#[serde_with::serde_as]
713#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
714pub struct PauseReplicaRequest {
715    _never_set: Option<bool>,
716}
717
718impl common::RequestValue for PauseReplicaRequest {}
719
720/// Used for setting the performance configuration. If the user doesn't specify PerformanceConfig, automatically provision the default performance settings as described in https://cloud.google.com/filestore/docs/performance. Larger instances will be linearly set to more IOPS. If the instance's capacity is increased or decreased, its performance will be automatically adjusted upwards or downwards accordingly (respectively).
721///
722/// This type is not used in any activity, and only used as *part* of another schema.
723///
724#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
725#[serde_with::serde_as]
726#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
727pub struct PerformanceConfig {
728    /// Choose a fixed provisioned IOPS value for the instance, which will remain constant regardless of instance capacity. Value must be a multiple of 1000. If the chosen value is outside the supported range for the instance's capacity during instance creation, instance creation will fail with an `InvalidArgument` error. Similarly, if an instance capacity update would result in a value outside the supported range, the update will fail with an `InvalidArgument` error.
729    #[serde(rename = "fixedIops")]
730    pub fixed_iops: Option<FixedIOPS>,
731    /// Provision IOPS dynamically based on the capacity of the instance. Provisioned IOPS will be calculated by multiplying the capacity of the instance in TiB by the `iops_per_tb` value. For example, for a 2 TiB instance with an `iops_per_tb` value of 17000 the provisioned IOPS will be 34000. If the calculated value is outside the supported range for the instance's capacity during instance creation, instance creation will fail with an `InvalidArgument` error. Similarly, if an instance capacity update would result in a value outside the supported range, the update will fail with an `InvalidArgument` error.
732    #[serde(rename = "iopsPerTb")]
733    pub iops_per_tb: Option<IOPSPerTB>,
734}
735
736impl common::Part for PerformanceConfig {}
737
738/// The enforced performance limits, calculated from the instance's performance configuration.
739///
740/// This type is not used in any activity, and only used as *part* of another schema.
741///
742#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
743#[serde_with::serde_as]
744#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
745pub struct PerformanceLimits {
746    /// Output only. The maximum IOPS.
747    #[serde(rename = "maxIops")]
748    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
749    pub max_iops: Option<i64>,
750    /// Output only. The maximum read IOPS.
751    #[serde(rename = "maxReadIops")]
752    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
753    pub max_read_iops: Option<i64>,
754    /// Output only. The maximum read throughput in bytes per second.
755    #[serde(rename = "maxReadThroughputBps")]
756    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
757    pub max_read_throughput_bps: Option<i64>,
758    /// Output only. The maximum write IOPS.
759    #[serde(rename = "maxWriteIops")]
760    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
761    pub max_write_iops: Option<i64>,
762    /// Output only. The maximum write throughput in bytes per second.
763    #[serde(rename = "maxWriteThroughputBps")]
764    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
765    pub max_write_throughput_bps: Option<i64>,
766}
767
768impl common::Part for PerformanceLimits {}
769
770/// PromoteReplicaRequest promotes a Filestore standby instance (replica).
771///
772/// # Activities
773///
774/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
775/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
776///
777/// * [locations instances promote replica projects](ProjectLocationInstancePromoteReplicaCall) (request)
778#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
779#[serde_with::serde_as]
780#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
781pub struct PromoteReplicaRequest {
782    /// Optional. The resource name of the peer instance to promote, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}`. The peer instance is required if the operation is called on an active instance.
783    #[serde(rename = "peerInstance")]
784    pub peer_instance: Option<String>,
785}
786
787impl common::RequestValue for PromoteReplicaRequest {}
788
789/// Private Service Connect configuration.
790///
791/// This type is not used in any activity, and only used as *part* of another schema.
792///
793#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
794#[serde_with::serde_as]
795#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
796pub struct PscConfig {
797    /// Optional. Consumer service project in which the Private Service Connect endpoint would be set up. This is optional, and only relevant in case the network is a shared VPC. If this is not specified, the endpoint would be setup in the VPC host project.
798    #[serde(rename = "endpointProject")]
799    pub endpoint_project: Option<String>,
800}
801
802impl common::Part for PscConfig {}
803
804/// Replica configuration for the instance.
805///
806/// This type is not used in any activity, and only used as *part* of another schema.
807///
808#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
809#[serde_with::serde_as]
810#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
811pub struct ReplicaConfig {
812    /// Output only. The timestamp of the latest replication snapshot taken on the active instance and is already replicated safely.
813    #[serde(rename = "lastActiveSyncTime")]
814    pub last_active_sync_time: Option<chrono::DateTime<chrono::offset::Utc>>,
815    /// Optional. The name of the source instance for the replica, in the format `projects/{project}/locations/{location}/instances/{instance}`. This field is required when creating a replica.
816    #[serde(rename = "peerInstance")]
817    pub peer_instance: Option<String>,
818    /// Output only. The replica state.
819    pub state: Option<String>,
820    /// Output only. Additional information about the replication state, if available.
821    #[serde(rename = "stateReasons")]
822    pub state_reasons: Option<Vec<String>>,
823    /// Output only. The time when the replica state was updated.
824    #[serde(rename = "stateUpdateTime")]
825    pub state_update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
826}
827
828impl common::Part for ReplicaConfig {}
829
830/// Optional. The configuration used to replicate an instance.
831///
832/// This type is not used in any activity, and only used as *part* of another schema.
833///
834#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
835#[serde_with::serde_as]
836#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
837pub struct Replication {
838    /// Optional. Replication configuration for the replica instance associated with this instance. Only a single replica is supported.
839    pub replicas: Option<Vec<ReplicaConfig>>,
840    /// Optional. The replication role. When creating a new replica, this field must be set to `STANDBY`.
841    pub role: Option<String>,
842}
843
844impl common::Part for Replication {}
845
846/// RestoreInstanceRequest restores an existing instance’s file share from a backup.
847///
848/// # Activities
849///
850/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
851/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
852///
853/// * [locations instances restore projects](ProjectLocationInstanceRestoreCall) (request)
854#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
855#[serde_with::serde_as]
856#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
857pub struct RestoreInstanceRequest {
858    /// Required. Name of the file share in the Filestore instance that the backup is being restored to.
859    #[serde(rename = "fileShare")]
860    pub file_share: Option<String>,
861    /// The resource name of the backup, in the format `projects/{project_number}/locations/{location_id}/backups/{backup_id}`.
862    #[serde(rename = "sourceBackup")]
863    pub source_backup: Option<String>,
864}
865
866impl common::RequestValue for RestoreInstanceRequest {}
867
868/// ResumeReplicaRequest resumes a Filestore standby instance (replica).
869///
870/// # Activities
871///
872/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
873/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
874///
875/// * [locations instances resume replica projects](ProjectLocationInstanceResumeReplicaCall) (request)
876#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
877#[serde_with::serde_as]
878#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
879pub struct ResumeReplicaRequest {
880    _never_set: Option<bool>,
881}
882
883impl common::RequestValue for ResumeReplicaRequest {}
884
885/// RevertInstanceRequest reverts the given instance’s file share to the specified snapshot.
886///
887/// # Activities
888///
889/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
890/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
891///
892/// * [locations instances revert projects](ProjectLocationInstanceRevertCall) (request)
893#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
894#[serde_with::serde_as]
895#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
896pub struct RevertInstanceRequest {
897    /// Required. The snapshot resource ID, in the format 'my-snapshot', where the specified ID is the {snapshot_id} of the fully qualified name like `projects/{project_id}/locations/{location_id}/instances/{instance_id}/snapshots/{snapshot_id}`
898    #[serde(rename = "targetSnapshotId")]
899    pub target_snapshot_id: Option<String>,
900}
901
902impl common::RequestValue for RevertInstanceRequest {}
903
904/// A Filestore snapshot.
905///
906/// # Activities
907///
908/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
909/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
910///
911/// * [locations instances snapshots create projects](ProjectLocationInstanceSnapshotCreateCall) (request)
912/// * [locations instances snapshots get projects](ProjectLocationInstanceSnapshotGetCall) (response)
913/// * [locations instances snapshots patch projects](ProjectLocationInstanceSnapshotPatchCall) (request)
914#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
915#[serde_with::serde_as]
916#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
917pub struct Snapshot {
918    /// Output only. The time when the snapshot was created.
919    #[serde(rename = "createTime")]
920    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
921    /// A description of the snapshot with 2048 characters or less. Requests with longer descriptions will be rejected.
922    pub description: Option<String>,
923    /// Output only. The amount of bytes needed to allocate a full copy of the snapshot content
924    #[serde(rename = "filesystemUsedBytes")]
925    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
926    pub filesystem_used_bytes: Option<i64>,
927    /// Resource labels to represent user provided metadata.
928    pub labels: Option<HashMap<String, String>>,
929    /// Output only. The resource name of the snapshot, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}/snapshots/{snapshot_id}`.
930    pub name: Option<String>,
931    /// Output only. The snapshot state.
932    pub state: Option<String>,
933    /// Optional. Input only. Immutable. Tag key-value pairs bound to this resource. Each key must be a namespaced name and each value a short name. Example: "123456789012/environment" : "production", "123456789013/costCenter" : "marketing" See the documentation for more information: - Namespaced name: https://cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing#retrieving_tag_key - Short name: https://cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing#retrieving_tag_value
934    pub tags: Option<HashMap<String, String>>,
935}
936
937impl common::RequestValue for Snapshot {}
938impl common::ResponseResult for Snapshot {}
939
940/// 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).
941///
942/// This type is not used in any activity, and only used as *part* of another schema.
943///
944#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
945#[serde_with::serde_as]
946#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
947pub struct Status {
948    /// The status code, which should be an enum value of google.rpc.Code.
949    pub code: Option<i32>,
950    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
951    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
952    /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
953    pub message: Option<String>,
954}
955
956impl common::Part for Status {}
957
958// ###################
959// MethodBuilders ###
960// #################
961
962/// A builder providing access to all methods supported on *project* resources.
963/// It is not used directly, but through the [`CloudFilestore`] hub.
964///
965/// # Example
966///
967/// Instantiate a resource builder
968///
969/// ```test_harness,no_run
970/// extern crate hyper;
971/// extern crate hyper_rustls;
972/// extern crate google_file1 as file1;
973///
974/// # async fn dox() {
975/// use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
976///
977/// let secret: yup_oauth2::ApplicationSecret = Default::default();
978/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
979///     .with_native_roots()
980///     .unwrap()
981///     .https_only()
982///     .enable_http2()
983///     .build();
984///
985/// let executor = hyper_util::rt::TokioExecutor::new();
986/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
987///     secret,
988///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
989///     yup_oauth2::client::CustomHyperClientBuilder::from(
990///         hyper_util::client::legacy::Client::builder(executor).build(connector),
991///     ),
992/// ).build().await.unwrap();
993///
994/// let client = hyper_util::client::legacy::Client::builder(
995///     hyper_util::rt::TokioExecutor::new()
996/// )
997/// .build(
998///     hyper_rustls::HttpsConnectorBuilder::new()
999///         .with_native_roots()
1000///         .unwrap()
1001///         .https_or_http()
1002///         .enable_http2()
1003///         .build()
1004/// );
1005/// let mut hub = CloudFilestore::new(client, auth);
1006/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1007/// // like `locations_backups_create(...)`, `locations_backups_delete(...)`, `locations_backups_get(...)`, `locations_backups_list(...)`, `locations_backups_patch(...)`, `locations_get(...)`, `locations_instances_create(...)`, `locations_instances_delete(...)`, `locations_instances_get(...)`, `locations_instances_list(...)`, `locations_instances_patch(...)`, `locations_instances_pause_replica(...)`, `locations_instances_promote_replica(...)`, `locations_instances_restore(...)`, `locations_instances_resume_replica(...)`, `locations_instances_revert(...)`, `locations_instances_snapshots_create(...)`, `locations_instances_snapshots_delete(...)`, `locations_instances_snapshots_get(...)`, `locations_instances_snapshots_list(...)`, `locations_instances_snapshots_patch(...)`, `locations_list(...)`, `locations_operations_cancel(...)`, `locations_operations_delete(...)`, `locations_operations_get(...)` and `locations_operations_list(...)`
1008/// // to build up your call.
1009/// let rb = hub.projects();
1010/// # }
1011/// ```
1012pub struct ProjectMethods<'a, C>
1013where
1014    C: 'a,
1015{
1016    hub: &'a CloudFilestore<C>,
1017}
1018
1019impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1020
1021impl<'a, C> ProjectMethods<'a, C> {
1022    /// Create a builder to help you perform the following task:
1023    ///
1024    /// Creates a backup.
1025    ///
1026    /// # Arguments
1027    ///
1028    /// * `request` - No description provided.
1029    /// * `parent` - Required. The backup's project and location, in the format `projects/{project_number}/locations/{location}`. In Filestore, backup locations map to Google Cloud regions, for example **us-west1**.
1030    pub fn locations_backups_create(
1031        &self,
1032        request: Backup,
1033        parent: &str,
1034    ) -> ProjectLocationBackupCreateCall<'a, C> {
1035        ProjectLocationBackupCreateCall {
1036            hub: self.hub,
1037            _request: request,
1038            _parent: parent.to_string(),
1039            _backup_id: Default::default(),
1040            _delegate: Default::default(),
1041            _additional_params: Default::default(),
1042            _scopes: Default::default(),
1043        }
1044    }
1045
1046    /// Create a builder to help you perform the following task:
1047    ///
1048    /// Deletes a backup.
1049    ///
1050    /// # Arguments
1051    ///
1052    /// * `name` - Required. The backup resource name, in the format `projects/{project_number}/locations/{location}/backups/{backup_id}`
1053    pub fn locations_backups_delete(&self, name: &str) -> ProjectLocationBackupDeleteCall<'a, C> {
1054        ProjectLocationBackupDeleteCall {
1055            hub: self.hub,
1056            _name: name.to_string(),
1057            _delegate: Default::default(),
1058            _additional_params: Default::default(),
1059            _scopes: Default::default(),
1060        }
1061    }
1062
1063    /// Create a builder to help you perform the following task:
1064    ///
1065    /// Gets the details of a specific backup.
1066    ///
1067    /// # Arguments
1068    ///
1069    /// * `name` - Required. The backup resource name, in the format `projects/{project_number}/locations/{location}/backups/{backup_id}`.
1070    pub fn locations_backups_get(&self, name: &str) -> ProjectLocationBackupGetCall<'a, C> {
1071        ProjectLocationBackupGetCall {
1072            hub: self.hub,
1073            _name: name.to_string(),
1074            _delegate: Default::default(),
1075            _additional_params: Default::default(),
1076            _scopes: Default::default(),
1077        }
1078    }
1079
1080    /// Create a builder to help you perform the following task:
1081    ///
1082    /// Lists all backups in a project for either a specified location or for all locations.
1083    ///
1084    /// # Arguments
1085    ///
1086    /// * `parent` - Required. The project and location for which to retrieve backup information, in the format `projects/{project_number}/locations/{location}`. In Filestore, backup locations map to Google Cloud regions, for example **us-west1**. To retrieve backup information for all locations, use "-" for the `{location}` value.
1087    pub fn locations_backups_list(&self, parent: &str) -> ProjectLocationBackupListCall<'a, C> {
1088        ProjectLocationBackupListCall {
1089            hub: self.hub,
1090            _parent: parent.to_string(),
1091            _page_token: Default::default(),
1092            _page_size: Default::default(),
1093            _order_by: Default::default(),
1094            _filter: Default::default(),
1095            _delegate: Default::default(),
1096            _additional_params: Default::default(),
1097            _scopes: Default::default(),
1098        }
1099    }
1100
1101    /// Create a builder to help you perform the following task:
1102    ///
1103    /// Updates the settings of a specific backup.
1104    ///
1105    /// # Arguments
1106    ///
1107    /// * `request` - No description provided.
1108    /// * `name` - Output only. The resource name of the backup, in the format `projects/{project_number}/locations/{location_id}/backups/{backup_id}`.
1109    pub fn locations_backups_patch(
1110        &self,
1111        request: Backup,
1112        name: &str,
1113    ) -> ProjectLocationBackupPatchCall<'a, C> {
1114        ProjectLocationBackupPatchCall {
1115            hub: self.hub,
1116            _request: request,
1117            _name: name.to_string(),
1118            _update_mask: Default::default(),
1119            _delegate: Default::default(),
1120            _additional_params: Default::default(),
1121            _scopes: Default::default(),
1122        }
1123    }
1124
1125    /// Create a builder to help you perform the following task:
1126    ///
1127    /// Creates a snapshot.
1128    ///
1129    /// # Arguments
1130    ///
1131    /// * `request` - No description provided.
1132    /// * `parent` - Required. The Filestore Instance to create the snapshots of, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`
1133    pub fn locations_instances_snapshots_create(
1134        &self,
1135        request: Snapshot,
1136        parent: &str,
1137    ) -> ProjectLocationInstanceSnapshotCreateCall<'a, C> {
1138        ProjectLocationInstanceSnapshotCreateCall {
1139            hub: self.hub,
1140            _request: request,
1141            _parent: parent.to_string(),
1142            _snapshot_id: Default::default(),
1143            _delegate: Default::default(),
1144            _additional_params: Default::default(),
1145            _scopes: Default::default(),
1146        }
1147    }
1148
1149    /// Create a builder to help you perform the following task:
1150    ///
1151    /// Deletes a snapshot.
1152    ///
1153    /// # Arguments
1154    ///
1155    /// * `name` - Required. The snapshot resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}/snapshots/{snapshot_id}`
1156    pub fn locations_instances_snapshots_delete(
1157        &self,
1158        name: &str,
1159    ) -> ProjectLocationInstanceSnapshotDeleteCall<'a, C> {
1160        ProjectLocationInstanceSnapshotDeleteCall {
1161            hub: self.hub,
1162            _name: name.to_string(),
1163            _delegate: Default::default(),
1164            _additional_params: Default::default(),
1165            _scopes: Default::default(),
1166        }
1167    }
1168
1169    /// Create a builder to help you perform the following task:
1170    ///
1171    /// Gets the details of a specific snapshot.
1172    ///
1173    /// # Arguments
1174    ///
1175    /// * `name` - Required. The snapshot resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}/snapshots/{snapshot_id}`
1176    pub fn locations_instances_snapshots_get(
1177        &self,
1178        name: &str,
1179    ) -> ProjectLocationInstanceSnapshotGetCall<'a, C> {
1180        ProjectLocationInstanceSnapshotGetCall {
1181            hub: self.hub,
1182            _name: name.to_string(),
1183            _delegate: Default::default(),
1184            _additional_params: Default::default(),
1185            _scopes: Default::default(),
1186        }
1187    }
1188
1189    /// Create a builder to help you perform the following task:
1190    ///
1191    /// Lists all snapshots in a project for either a specified location or for all locations.
1192    ///
1193    /// # Arguments
1194    ///
1195    /// * `parent` - Required. The instance for which to retrieve snapshot information, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`.
1196    pub fn locations_instances_snapshots_list(
1197        &self,
1198        parent: &str,
1199    ) -> ProjectLocationInstanceSnapshotListCall<'a, C> {
1200        ProjectLocationInstanceSnapshotListCall {
1201            hub: self.hub,
1202            _parent: parent.to_string(),
1203            _return_partial_success: Default::default(),
1204            _page_token: Default::default(),
1205            _page_size: Default::default(),
1206            _order_by: Default::default(),
1207            _filter: Default::default(),
1208            _delegate: Default::default(),
1209            _additional_params: Default::default(),
1210            _scopes: Default::default(),
1211        }
1212    }
1213
1214    /// Create a builder to help you perform the following task:
1215    ///
1216    /// Updates the settings of a specific snapshot.
1217    ///
1218    /// # Arguments
1219    ///
1220    /// * `request` - No description provided.
1221    /// * `name` - Output only. The resource name of the snapshot, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}/snapshots/{snapshot_id}`.
1222    pub fn locations_instances_snapshots_patch(
1223        &self,
1224        request: Snapshot,
1225        name: &str,
1226    ) -> ProjectLocationInstanceSnapshotPatchCall<'a, C> {
1227        ProjectLocationInstanceSnapshotPatchCall {
1228            hub: self.hub,
1229            _request: request,
1230            _name: name.to_string(),
1231            _update_mask: Default::default(),
1232            _delegate: Default::default(),
1233            _additional_params: Default::default(),
1234            _scopes: Default::default(),
1235        }
1236    }
1237
1238    /// Create a builder to help you perform the following task:
1239    ///
1240    /// Creates an instance. When creating from a backup, the capacity of the new instance needs to be equal to or larger than the capacity of the backup (and also equal to or larger than the minimum capacity of the tier).
1241    ///
1242    /// # Arguments
1243    ///
1244    /// * `request` - No description provided.
1245    /// * `parent` - Required. The instance's project and location, in the format `projects/{project_id}/locations/{location}`. In Filestore, locations map to Google Cloud zones, for example **us-west1-b**.
1246    pub fn locations_instances_create(
1247        &self,
1248        request: Instance,
1249        parent: &str,
1250    ) -> ProjectLocationInstanceCreateCall<'a, C> {
1251        ProjectLocationInstanceCreateCall {
1252            hub: self.hub,
1253            _request: request,
1254            _parent: parent.to_string(),
1255            _instance_id: Default::default(),
1256            _delegate: Default::default(),
1257            _additional_params: Default::default(),
1258            _scopes: Default::default(),
1259        }
1260    }
1261
1262    /// Create a builder to help you perform the following task:
1263    ///
1264    /// Deletes an instance.
1265    ///
1266    /// # Arguments
1267    ///
1268    /// * `name` - Required. The instance resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`
1269    pub fn locations_instances_delete(
1270        &self,
1271        name: &str,
1272    ) -> ProjectLocationInstanceDeleteCall<'a, C> {
1273        ProjectLocationInstanceDeleteCall {
1274            hub: self.hub,
1275            _name: name.to_string(),
1276            _force: Default::default(),
1277            _delegate: Default::default(),
1278            _additional_params: Default::default(),
1279            _scopes: Default::default(),
1280        }
1281    }
1282
1283    /// Create a builder to help you perform the following task:
1284    ///
1285    /// Gets the details of a specific instance.
1286    ///
1287    /// # Arguments
1288    ///
1289    /// * `name` - Required. The instance resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`.
1290    pub fn locations_instances_get(&self, name: &str) -> ProjectLocationInstanceGetCall<'a, C> {
1291        ProjectLocationInstanceGetCall {
1292            hub: self.hub,
1293            _name: name.to_string(),
1294            _delegate: Default::default(),
1295            _additional_params: Default::default(),
1296            _scopes: Default::default(),
1297        }
1298    }
1299
1300    /// Create a builder to help you perform the following task:
1301    ///
1302    /// Lists all instances in a project for either a specified location or for all locations.
1303    ///
1304    /// # Arguments
1305    ///
1306    /// * `parent` - Required. The project and location for which to retrieve instance information, in the format `projects/{project_id}/locations/{location}`. In Cloud Filestore, locations map to Google Cloud zones, for example **us-west1-b**. To retrieve instance information for all locations, use "-" for the `{location}` value.
1307    pub fn locations_instances_list(&self, parent: &str) -> ProjectLocationInstanceListCall<'a, C> {
1308        ProjectLocationInstanceListCall {
1309            hub: self.hub,
1310            _parent: parent.to_string(),
1311            _page_token: Default::default(),
1312            _page_size: Default::default(),
1313            _order_by: Default::default(),
1314            _filter: Default::default(),
1315            _delegate: Default::default(),
1316            _additional_params: Default::default(),
1317            _scopes: Default::default(),
1318        }
1319    }
1320
1321    /// Create a builder to help you perform the following task:
1322    ///
1323    /// Updates the settings of a specific instance.
1324    ///
1325    /// # Arguments
1326    ///
1327    /// * `request` - No description provided.
1328    /// * `name` - Output only. The resource name of the instance, in the format `projects/{project}/locations/{location}/instances/{instance}`.
1329    pub fn locations_instances_patch(
1330        &self,
1331        request: Instance,
1332        name: &str,
1333    ) -> ProjectLocationInstancePatchCall<'a, C> {
1334        ProjectLocationInstancePatchCall {
1335            hub: self.hub,
1336            _request: request,
1337            _name: name.to_string(),
1338            _update_mask: Default::default(),
1339            _delegate: Default::default(),
1340            _additional_params: Default::default(),
1341            _scopes: Default::default(),
1342        }
1343    }
1344
1345    /// Create a builder to help you perform the following task:
1346    ///
1347    /// Pause the standby instance (replica). WARNING: This operation makes the standby instance's NFS filesystem writable. Any data written to the standby instance while paused will be lost when the replica is resumed or promoted.
1348    ///
1349    /// # Arguments
1350    ///
1351    /// * `request` - No description provided.
1352    /// * `name` - Required. The resource name of the instance, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}`.
1353    pub fn locations_instances_pause_replica(
1354        &self,
1355        request: PauseReplicaRequest,
1356        name: &str,
1357    ) -> ProjectLocationInstancePauseReplicaCall<'a, C> {
1358        ProjectLocationInstancePauseReplicaCall {
1359            hub: self.hub,
1360            _request: request,
1361            _name: name.to_string(),
1362            _delegate: Default::default(),
1363            _additional_params: Default::default(),
1364            _scopes: Default::default(),
1365        }
1366    }
1367
1368    /// Create a builder to help you perform the following task:
1369    ///
1370    /// Promote the standby instance (replica).
1371    ///
1372    /// # Arguments
1373    ///
1374    /// * `request` - No description provided.
1375    /// * `name` - Required. The resource name of the instance, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}`.
1376    pub fn locations_instances_promote_replica(
1377        &self,
1378        request: PromoteReplicaRequest,
1379        name: &str,
1380    ) -> ProjectLocationInstancePromoteReplicaCall<'a, C> {
1381        ProjectLocationInstancePromoteReplicaCall {
1382            hub: self.hub,
1383            _request: request,
1384            _name: name.to_string(),
1385            _delegate: Default::default(),
1386            _additional_params: Default::default(),
1387            _scopes: Default::default(),
1388        }
1389    }
1390
1391    /// Create a builder to help you perform the following task:
1392    ///
1393    /// Restores an existing instance's file share from a backup. The capacity of the instance needs to be equal to or larger than the capacity of the backup (and also equal to or larger than the minimum capacity of the tier).
1394    ///
1395    /// # Arguments
1396    ///
1397    /// * `request` - No description provided.
1398    /// * `name` - Required. The resource name of the instance, in the format `projects/{project_number}/locations/{location_id}/instances/{instance_id}`.
1399    pub fn locations_instances_restore(
1400        &self,
1401        request: RestoreInstanceRequest,
1402        name: &str,
1403    ) -> ProjectLocationInstanceRestoreCall<'a, C> {
1404        ProjectLocationInstanceRestoreCall {
1405            hub: self.hub,
1406            _request: request,
1407            _name: name.to_string(),
1408            _delegate: Default::default(),
1409            _additional_params: Default::default(),
1410            _scopes: Default::default(),
1411        }
1412    }
1413
1414    /// Create a builder to help you perform the following task:
1415    ///
1416    /// Resume the standby instance (replica). WARNING: Any data written to the standby instance while paused will be lost when the replica is resumed.
1417    ///
1418    /// # Arguments
1419    ///
1420    /// * `request` - No description provided.
1421    /// * `name` - Required. The resource name of the instance, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}`.
1422    pub fn locations_instances_resume_replica(
1423        &self,
1424        request: ResumeReplicaRequest,
1425        name: &str,
1426    ) -> ProjectLocationInstanceResumeReplicaCall<'a, C> {
1427        ProjectLocationInstanceResumeReplicaCall {
1428            hub: self.hub,
1429            _request: request,
1430            _name: name.to_string(),
1431            _delegate: Default::default(),
1432            _additional_params: Default::default(),
1433            _scopes: Default::default(),
1434        }
1435    }
1436
1437    /// Create a builder to help you perform the following task:
1438    ///
1439    /// Revert an existing instance's file system to a specified snapshot.
1440    ///
1441    /// # Arguments
1442    ///
1443    /// * `request` - No description provided.
1444    /// * `name` - Required. The resource name of the instance, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}`.
1445    pub fn locations_instances_revert(
1446        &self,
1447        request: RevertInstanceRequest,
1448        name: &str,
1449    ) -> ProjectLocationInstanceRevertCall<'a, C> {
1450        ProjectLocationInstanceRevertCall {
1451            hub: self.hub,
1452            _request: request,
1453            _name: name.to_string(),
1454            _delegate: Default::default(),
1455            _additional_params: Default::default(),
1456            _scopes: Default::default(),
1457        }
1458    }
1459
1460    /// Create a builder to help you perform the following task:
1461    ///
1462    /// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of `1`, corresponding to `Code.CANCELLED`.
1463    ///
1464    /// # Arguments
1465    ///
1466    /// * `request` - No description provided.
1467    /// * `name` - The name of the operation resource to be cancelled.
1468    pub fn locations_operations_cancel(
1469        &self,
1470        request: CancelOperationRequest,
1471        name: &str,
1472    ) -> ProjectLocationOperationCancelCall<'a, C> {
1473        ProjectLocationOperationCancelCall {
1474            hub: self.hub,
1475            _request: request,
1476            _name: name.to_string(),
1477            _delegate: Default::default(),
1478            _additional_params: Default::default(),
1479            _scopes: Default::default(),
1480        }
1481    }
1482
1483    /// Create a builder to help you perform the following task:
1484    ///
1485    /// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
1486    ///
1487    /// # Arguments
1488    ///
1489    /// * `name` - The name of the operation resource to be deleted.
1490    pub fn locations_operations_delete(
1491        &self,
1492        name: &str,
1493    ) -> ProjectLocationOperationDeleteCall<'a, C> {
1494        ProjectLocationOperationDeleteCall {
1495            hub: self.hub,
1496            _name: name.to_string(),
1497            _delegate: Default::default(),
1498            _additional_params: Default::default(),
1499            _scopes: Default::default(),
1500        }
1501    }
1502
1503    /// Create a builder to help you perform the following task:
1504    ///
1505    /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
1506    ///
1507    /// # Arguments
1508    ///
1509    /// * `name` - The name of the operation resource.
1510    pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
1511        ProjectLocationOperationGetCall {
1512            hub: self.hub,
1513            _name: name.to_string(),
1514            _delegate: Default::default(),
1515            _additional_params: Default::default(),
1516            _scopes: Default::default(),
1517        }
1518    }
1519
1520    /// Create a builder to help you perform the following task:
1521    ///
1522    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
1523    ///
1524    /// # Arguments
1525    ///
1526    /// * `name` - The name of the operation's parent resource.
1527    pub fn locations_operations_list(&self, name: &str) -> ProjectLocationOperationListCall<'a, C> {
1528        ProjectLocationOperationListCall {
1529            hub: self.hub,
1530            _name: name.to_string(),
1531            _return_partial_success: Default::default(),
1532            _page_token: Default::default(),
1533            _page_size: Default::default(),
1534            _filter: Default::default(),
1535            _delegate: Default::default(),
1536            _additional_params: Default::default(),
1537            _scopes: Default::default(),
1538        }
1539    }
1540
1541    /// Create a builder to help you perform the following task:
1542    ///
1543    /// Gets information about a location.
1544    ///
1545    /// # Arguments
1546    ///
1547    /// * `name` - Resource name for the location.
1548    pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
1549        ProjectLocationGetCall {
1550            hub: self.hub,
1551            _name: name.to_string(),
1552            _delegate: Default::default(),
1553            _additional_params: Default::default(),
1554            _scopes: Default::default(),
1555        }
1556    }
1557
1558    /// Create a builder to help you perform the following task:
1559    ///
1560    /// Lists information about the supported locations for this service.
1561    ///
1562    /// # Arguments
1563    ///
1564    /// * `name` - The resource that owns the locations collection, if applicable.
1565    pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
1566        ProjectLocationListCall {
1567            hub: self.hub,
1568            _name: name.to_string(),
1569            _page_token: Default::default(),
1570            _page_size: Default::default(),
1571            _filter: Default::default(),
1572            _extra_location_types: Default::default(),
1573            _delegate: Default::default(),
1574            _additional_params: Default::default(),
1575            _scopes: Default::default(),
1576        }
1577    }
1578}
1579
1580// ###################
1581// CallBuilders   ###
1582// #################
1583
1584/// Creates a backup.
1585///
1586/// A builder for the *locations.backups.create* method supported by a *project* resource.
1587/// It is not used directly, but through a [`ProjectMethods`] instance.
1588///
1589/// # Example
1590///
1591/// Instantiate a resource method builder
1592///
1593/// ```test_harness,no_run
1594/// # extern crate hyper;
1595/// # extern crate hyper_rustls;
1596/// # extern crate google_file1 as file1;
1597/// use file1::api::Backup;
1598/// # async fn dox() {
1599/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1600///
1601/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1602/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1603/// #     .with_native_roots()
1604/// #     .unwrap()
1605/// #     .https_only()
1606/// #     .enable_http2()
1607/// #     .build();
1608///
1609/// # let executor = hyper_util::rt::TokioExecutor::new();
1610/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1611/// #     secret,
1612/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1613/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1614/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1615/// #     ),
1616/// # ).build().await.unwrap();
1617///
1618/// # let client = hyper_util::client::legacy::Client::builder(
1619/// #     hyper_util::rt::TokioExecutor::new()
1620/// # )
1621/// # .build(
1622/// #     hyper_rustls::HttpsConnectorBuilder::new()
1623/// #         .with_native_roots()
1624/// #         .unwrap()
1625/// #         .https_or_http()
1626/// #         .enable_http2()
1627/// #         .build()
1628/// # );
1629/// # let mut hub = CloudFilestore::new(client, auth);
1630/// // As the method needs a request, you would usually fill it with the desired information
1631/// // into the respective structure. Some of the parts shown here might not be applicable !
1632/// // Values shown here are possibly random and not representative !
1633/// let mut req = Backup::default();
1634///
1635/// // You can configure optional parameters by calling the respective setters at will, and
1636/// // execute the final call using `doit()`.
1637/// // Values shown here are possibly random and not representative !
1638/// let result = hub.projects().locations_backups_create(req, "parent")
1639///              .backup_id("sed")
1640///              .doit().await;
1641/// # }
1642/// ```
1643pub struct ProjectLocationBackupCreateCall<'a, C>
1644where
1645    C: 'a,
1646{
1647    hub: &'a CloudFilestore<C>,
1648    _request: Backup,
1649    _parent: String,
1650    _backup_id: Option<String>,
1651    _delegate: Option<&'a mut dyn common::Delegate>,
1652    _additional_params: HashMap<String, String>,
1653    _scopes: BTreeSet<String>,
1654}
1655
1656impl<'a, C> common::CallBuilder for ProjectLocationBackupCreateCall<'a, C> {}
1657
1658impl<'a, C> ProjectLocationBackupCreateCall<'a, C>
1659where
1660    C: common::Connector,
1661{
1662    /// Perform the operation you have build so far.
1663    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1664        use std::borrow::Cow;
1665        use std::io::{Read, Seek};
1666
1667        use common::{url::Params, ToParts};
1668        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1669
1670        let mut dd = common::DefaultDelegate;
1671        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1672        dlg.begin(common::MethodInfo {
1673            id: "file.projects.locations.backups.create",
1674            http_method: hyper::Method::POST,
1675        });
1676
1677        for &field in ["alt", "parent", "backupId"].iter() {
1678            if self._additional_params.contains_key(field) {
1679                dlg.finished(false);
1680                return Err(common::Error::FieldClash(field));
1681            }
1682        }
1683
1684        let mut params = Params::with_capacity(5 + self._additional_params.len());
1685        params.push("parent", self._parent);
1686        if let Some(value) = self._backup_id.as_ref() {
1687            params.push("backupId", value);
1688        }
1689
1690        params.extend(self._additional_params.iter());
1691
1692        params.push("alt", "json");
1693        let mut url = self.hub._base_url.clone() + "v1/{+parent}/backups";
1694        if self._scopes.is_empty() {
1695            self._scopes
1696                .insert(Scope::CloudPlatform.as_ref().to_string());
1697        }
1698
1699        #[allow(clippy::single_element_loop)]
1700        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1701            url = params.uri_replacement(url, param_name, find_this, true);
1702        }
1703        {
1704            let to_remove = ["parent"];
1705            params.remove_params(&to_remove);
1706        }
1707
1708        let url = params.parse_with_url(&url);
1709
1710        let mut json_mime_type = mime::APPLICATION_JSON;
1711        let mut request_value_reader = {
1712            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1713            common::remove_json_null_values(&mut value);
1714            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1715            serde_json::to_writer(&mut dst, &value).unwrap();
1716            dst
1717        };
1718        let request_size = request_value_reader
1719            .seek(std::io::SeekFrom::End(0))
1720            .unwrap();
1721        request_value_reader
1722            .seek(std::io::SeekFrom::Start(0))
1723            .unwrap();
1724
1725        loop {
1726            let token = match self
1727                .hub
1728                .auth
1729                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1730                .await
1731            {
1732                Ok(token) => token,
1733                Err(e) => match dlg.token(e) {
1734                    Ok(token) => token,
1735                    Err(e) => {
1736                        dlg.finished(false);
1737                        return Err(common::Error::MissingToken(e));
1738                    }
1739                },
1740            };
1741            request_value_reader
1742                .seek(std::io::SeekFrom::Start(0))
1743                .unwrap();
1744            let mut req_result = {
1745                let client = &self.hub.client;
1746                dlg.pre_request();
1747                let mut req_builder = hyper::Request::builder()
1748                    .method(hyper::Method::POST)
1749                    .uri(url.as_str())
1750                    .header(USER_AGENT, self.hub._user_agent.clone());
1751
1752                if let Some(token) = token.as_ref() {
1753                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1754                }
1755
1756                let request = req_builder
1757                    .header(CONTENT_TYPE, json_mime_type.to_string())
1758                    .header(CONTENT_LENGTH, request_size as u64)
1759                    .body(common::to_body(
1760                        request_value_reader.get_ref().clone().into(),
1761                    ));
1762
1763                client.request(request.unwrap()).await
1764            };
1765
1766            match req_result {
1767                Err(err) => {
1768                    if let common::Retry::After(d) = dlg.http_error(&err) {
1769                        sleep(d).await;
1770                        continue;
1771                    }
1772                    dlg.finished(false);
1773                    return Err(common::Error::HttpError(err));
1774                }
1775                Ok(res) => {
1776                    let (mut parts, body) = res.into_parts();
1777                    let mut body = common::Body::new(body);
1778                    if !parts.status.is_success() {
1779                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1780                        let error = serde_json::from_str(&common::to_string(&bytes));
1781                        let response = common::to_response(parts, bytes.into());
1782
1783                        if let common::Retry::After(d) =
1784                            dlg.http_failure(&response, error.as_ref().ok())
1785                        {
1786                            sleep(d).await;
1787                            continue;
1788                        }
1789
1790                        dlg.finished(false);
1791
1792                        return Err(match error {
1793                            Ok(value) => common::Error::BadRequest(value),
1794                            _ => common::Error::Failure(response),
1795                        });
1796                    }
1797                    let response = {
1798                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1799                        let encoded = common::to_string(&bytes);
1800                        match serde_json::from_str(&encoded) {
1801                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1802                            Err(error) => {
1803                                dlg.response_json_decode_error(&encoded, &error);
1804                                return Err(common::Error::JsonDecodeError(
1805                                    encoded.to_string(),
1806                                    error,
1807                                ));
1808                            }
1809                        }
1810                    };
1811
1812                    dlg.finished(true);
1813                    return Ok(response);
1814                }
1815            }
1816        }
1817    }
1818
1819    ///
1820    /// Sets the *request* property to the given value.
1821    ///
1822    /// Even though the property as already been set when instantiating this call,
1823    /// we provide this method for API completeness.
1824    pub fn request(mut self, new_value: Backup) -> ProjectLocationBackupCreateCall<'a, C> {
1825        self._request = new_value;
1826        self
1827    }
1828    /// Required. The backup's project and location, in the format `projects/{project_number}/locations/{location}`. In Filestore, backup locations map to Google Cloud regions, for example **us-west1**.
1829    ///
1830    /// Sets the *parent* path property to the given value.
1831    ///
1832    /// Even though the property as already been set when instantiating this call,
1833    /// we provide this method for API completeness.
1834    pub fn parent(mut self, new_value: &str) -> ProjectLocationBackupCreateCall<'a, C> {
1835        self._parent = new_value.to_string();
1836        self
1837    }
1838    /// Required. The ID to use for the backup. The ID must be unique within the specified project and location. This value must start with a lowercase letter followed by up to 62 lowercase letters, numbers, or hyphens, and cannot end with a hyphen. Values that do not match this pattern will trigger an INVALID_ARGUMENT error.
1839    ///
1840    /// Sets the *backup id* query property to the given value.
1841    pub fn backup_id(mut self, new_value: &str) -> ProjectLocationBackupCreateCall<'a, C> {
1842        self._backup_id = Some(new_value.to_string());
1843        self
1844    }
1845    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1846    /// while executing the actual API request.
1847    ///
1848    /// ````text
1849    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1850    /// ````
1851    ///
1852    /// Sets the *delegate* property to the given value.
1853    pub fn delegate(
1854        mut self,
1855        new_value: &'a mut dyn common::Delegate,
1856    ) -> ProjectLocationBackupCreateCall<'a, C> {
1857        self._delegate = Some(new_value);
1858        self
1859    }
1860
1861    /// Set any additional parameter of the query string used in the request.
1862    /// It should be used to set parameters which are not yet available through their own
1863    /// setters.
1864    ///
1865    /// Please note that this method must not be used to set any of the known parameters
1866    /// which have their own setter method. If done anyway, the request will fail.
1867    ///
1868    /// # Additional Parameters
1869    ///
1870    /// * *$.xgafv* (query-string) - V1 error format.
1871    /// * *access_token* (query-string) - OAuth access token.
1872    /// * *alt* (query-string) - Data format for response.
1873    /// * *callback* (query-string) - JSONP
1874    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1875    /// * *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.
1876    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1877    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1878    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
1879    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1880    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1881    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBackupCreateCall<'a, C>
1882    where
1883        T: AsRef<str>,
1884    {
1885        self._additional_params
1886            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1887        self
1888    }
1889
1890    /// Identifies the authorization scope for the method you are building.
1891    ///
1892    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1893    /// [`Scope::CloudPlatform`].
1894    ///
1895    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1896    /// tokens for more than one scope.
1897    ///
1898    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1899    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1900    /// sufficient, a read-write scope will do as well.
1901    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBackupCreateCall<'a, C>
1902    where
1903        St: AsRef<str>,
1904    {
1905        self._scopes.insert(String::from(scope.as_ref()));
1906        self
1907    }
1908    /// Identifies the authorization scope(s) for the method you are building.
1909    ///
1910    /// See [`Self::add_scope()`] for details.
1911    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBackupCreateCall<'a, C>
1912    where
1913        I: IntoIterator<Item = St>,
1914        St: AsRef<str>,
1915    {
1916        self._scopes
1917            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1918        self
1919    }
1920
1921    /// Removes all scopes, and no default scope will be used either.
1922    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1923    /// for details).
1924    pub fn clear_scopes(mut self) -> ProjectLocationBackupCreateCall<'a, C> {
1925        self._scopes.clear();
1926        self
1927    }
1928}
1929
1930/// Deletes a backup.
1931///
1932/// A builder for the *locations.backups.delete* method supported by a *project* resource.
1933/// It is not used directly, but through a [`ProjectMethods`] instance.
1934///
1935/// # Example
1936///
1937/// Instantiate a resource method builder
1938///
1939/// ```test_harness,no_run
1940/// # extern crate hyper;
1941/// # extern crate hyper_rustls;
1942/// # extern crate google_file1 as file1;
1943/// # async fn dox() {
1944/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1945///
1946/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1947/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1948/// #     .with_native_roots()
1949/// #     .unwrap()
1950/// #     .https_only()
1951/// #     .enable_http2()
1952/// #     .build();
1953///
1954/// # let executor = hyper_util::rt::TokioExecutor::new();
1955/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1956/// #     secret,
1957/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1958/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1959/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1960/// #     ),
1961/// # ).build().await.unwrap();
1962///
1963/// # let client = hyper_util::client::legacy::Client::builder(
1964/// #     hyper_util::rt::TokioExecutor::new()
1965/// # )
1966/// # .build(
1967/// #     hyper_rustls::HttpsConnectorBuilder::new()
1968/// #         .with_native_roots()
1969/// #         .unwrap()
1970/// #         .https_or_http()
1971/// #         .enable_http2()
1972/// #         .build()
1973/// # );
1974/// # let mut hub = CloudFilestore::new(client, auth);
1975/// // You can configure optional parameters by calling the respective setters at will, and
1976/// // execute the final call using `doit()`.
1977/// // Values shown here are possibly random and not representative !
1978/// let result = hub.projects().locations_backups_delete("name")
1979///              .doit().await;
1980/// # }
1981/// ```
1982pub struct ProjectLocationBackupDeleteCall<'a, C>
1983where
1984    C: 'a,
1985{
1986    hub: &'a CloudFilestore<C>,
1987    _name: String,
1988    _delegate: Option<&'a mut dyn common::Delegate>,
1989    _additional_params: HashMap<String, String>,
1990    _scopes: BTreeSet<String>,
1991}
1992
1993impl<'a, C> common::CallBuilder for ProjectLocationBackupDeleteCall<'a, C> {}
1994
1995impl<'a, C> ProjectLocationBackupDeleteCall<'a, C>
1996where
1997    C: common::Connector,
1998{
1999    /// Perform the operation you have build so far.
2000    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2001        use std::borrow::Cow;
2002        use std::io::{Read, Seek};
2003
2004        use common::{url::Params, ToParts};
2005        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2006
2007        let mut dd = common::DefaultDelegate;
2008        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2009        dlg.begin(common::MethodInfo {
2010            id: "file.projects.locations.backups.delete",
2011            http_method: hyper::Method::DELETE,
2012        });
2013
2014        for &field in ["alt", "name"].iter() {
2015            if self._additional_params.contains_key(field) {
2016                dlg.finished(false);
2017                return Err(common::Error::FieldClash(field));
2018            }
2019        }
2020
2021        let mut params = Params::with_capacity(3 + self._additional_params.len());
2022        params.push("name", self._name);
2023
2024        params.extend(self._additional_params.iter());
2025
2026        params.push("alt", "json");
2027        let mut url = self.hub._base_url.clone() + "v1/{+name}";
2028        if self._scopes.is_empty() {
2029            self._scopes
2030                .insert(Scope::CloudPlatform.as_ref().to_string());
2031        }
2032
2033        #[allow(clippy::single_element_loop)]
2034        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2035            url = params.uri_replacement(url, param_name, find_this, true);
2036        }
2037        {
2038            let to_remove = ["name"];
2039            params.remove_params(&to_remove);
2040        }
2041
2042        let url = params.parse_with_url(&url);
2043
2044        loop {
2045            let token = match self
2046                .hub
2047                .auth
2048                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2049                .await
2050            {
2051                Ok(token) => token,
2052                Err(e) => match dlg.token(e) {
2053                    Ok(token) => token,
2054                    Err(e) => {
2055                        dlg.finished(false);
2056                        return Err(common::Error::MissingToken(e));
2057                    }
2058                },
2059            };
2060            let mut req_result = {
2061                let client = &self.hub.client;
2062                dlg.pre_request();
2063                let mut req_builder = hyper::Request::builder()
2064                    .method(hyper::Method::DELETE)
2065                    .uri(url.as_str())
2066                    .header(USER_AGENT, self.hub._user_agent.clone());
2067
2068                if let Some(token) = token.as_ref() {
2069                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2070                }
2071
2072                let request = req_builder
2073                    .header(CONTENT_LENGTH, 0_u64)
2074                    .body(common::to_body::<String>(None));
2075
2076                client.request(request.unwrap()).await
2077            };
2078
2079            match req_result {
2080                Err(err) => {
2081                    if let common::Retry::After(d) = dlg.http_error(&err) {
2082                        sleep(d).await;
2083                        continue;
2084                    }
2085                    dlg.finished(false);
2086                    return Err(common::Error::HttpError(err));
2087                }
2088                Ok(res) => {
2089                    let (mut parts, body) = res.into_parts();
2090                    let mut body = common::Body::new(body);
2091                    if !parts.status.is_success() {
2092                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2093                        let error = serde_json::from_str(&common::to_string(&bytes));
2094                        let response = common::to_response(parts, bytes.into());
2095
2096                        if let common::Retry::After(d) =
2097                            dlg.http_failure(&response, error.as_ref().ok())
2098                        {
2099                            sleep(d).await;
2100                            continue;
2101                        }
2102
2103                        dlg.finished(false);
2104
2105                        return Err(match error {
2106                            Ok(value) => common::Error::BadRequest(value),
2107                            _ => common::Error::Failure(response),
2108                        });
2109                    }
2110                    let response = {
2111                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2112                        let encoded = common::to_string(&bytes);
2113                        match serde_json::from_str(&encoded) {
2114                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2115                            Err(error) => {
2116                                dlg.response_json_decode_error(&encoded, &error);
2117                                return Err(common::Error::JsonDecodeError(
2118                                    encoded.to_string(),
2119                                    error,
2120                                ));
2121                            }
2122                        }
2123                    };
2124
2125                    dlg.finished(true);
2126                    return Ok(response);
2127                }
2128            }
2129        }
2130    }
2131
2132    /// Required. The backup resource name, in the format `projects/{project_number}/locations/{location}/backups/{backup_id}`
2133    ///
2134    /// Sets the *name* path property to the given value.
2135    ///
2136    /// Even though the property as already been set when instantiating this call,
2137    /// we provide this method for API completeness.
2138    pub fn name(mut self, new_value: &str) -> ProjectLocationBackupDeleteCall<'a, C> {
2139        self._name = new_value.to_string();
2140        self
2141    }
2142    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2143    /// while executing the actual API request.
2144    ///
2145    /// ````text
2146    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2147    /// ````
2148    ///
2149    /// Sets the *delegate* property to the given value.
2150    pub fn delegate(
2151        mut self,
2152        new_value: &'a mut dyn common::Delegate,
2153    ) -> ProjectLocationBackupDeleteCall<'a, C> {
2154        self._delegate = Some(new_value);
2155        self
2156    }
2157
2158    /// Set any additional parameter of the query string used in the request.
2159    /// It should be used to set parameters which are not yet available through their own
2160    /// setters.
2161    ///
2162    /// Please note that this method must not be used to set any of the known parameters
2163    /// which have their own setter method. If done anyway, the request will fail.
2164    ///
2165    /// # Additional Parameters
2166    ///
2167    /// * *$.xgafv* (query-string) - V1 error format.
2168    /// * *access_token* (query-string) - OAuth access token.
2169    /// * *alt* (query-string) - Data format for response.
2170    /// * *callback* (query-string) - JSONP
2171    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2172    /// * *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.
2173    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2174    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2175    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2176    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2177    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2178    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBackupDeleteCall<'a, C>
2179    where
2180        T: AsRef<str>,
2181    {
2182        self._additional_params
2183            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2184        self
2185    }
2186
2187    /// Identifies the authorization scope for the method you are building.
2188    ///
2189    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2190    /// [`Scope::CloudPlatform`].
2191    ///
2192    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2193    /// tokens for more than one scope.
2194    ///
2195    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2196    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2197    /// sufficient, a read-write scope will do as well.
2198    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBackupDeleteCall<'a, C>
2199    where
2200        St: AsRef<str>,
2201    {
2202        self._scopes.insert(String::from(scope.as_ref()));
2203        self
2204    }
2205    /// Identifies the authorization scope(s) for the method you are building.
2206    ///
2207    /// See [`Self::add_scope()`] for details.
2208    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBackupDeleteCall<'a, C>
2209    where
2210        I: IntoIterator<Item = St>,
2211        St: AsRef<str>,
2212    {
2213        self._scopes
2214            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2215        self
2216    }
2217
2218    /// Removes all scopes, and no default scope will be used either.
2219    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2220    /// for details).
2221    pub fn clear_scopes(mut self) -> ProjectLocationBackupDeleteCall<'a, C> {
2222        self._scopes.clear();
2223        self
2224    }
2225}
2226
2227/// Gets the details of a specific backup.
2228///
2229/// A builder for the *locations.backups.get* method supported by a *project* resource.
2230/// It is not used directly, but through a [`ProjectMethods`] instance.
2231///
2232/// # Example
2233///
2234/// Instantiate a resource method builder
2235///
2236/// ```test_harness,no_run
2237/// # extern crate hyper;
2238/// # extern crate hyper_rustls;
2239/// # extern crate google_file1 as file1;
2240/// # async fn dox() {
2241/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2242///
2243/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2244/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2245/// #     .with_native_roots()
2246/// #     .unwrap()
2247/// #     .https_only()
2248/// #     .enable_http2()
2249/// #     .build();
2250///
2251/// # let executor = hyper_util::rt::TokioExecutor::new();
2252/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2253/// #     secret,
2254/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2255/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2256/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2257/// #     ),
2258/// # ).build().await.unwrap();
2259///
2260/// # let client = hyper_util::client::legacy::Client::builder(
2261/// #     hyper_util::rt::TokioExecutor::new()
2262/// # )
2263/// # .build(
2264/// #     hyper_rustls::HttpsConnectorBuilder::new()
2265/// #         .with_native_roots()
2266/// #         .unwrap()
2267/// #         .https_or_http()
2268/// #         .enable_http2()
2269/// #         .build()
2270/// # );
2271/// # let mut hub = CloudFilestore::new(client, auth);
2272/// // You can configure optional parameters by calling the respective setters at will, and
2273/// // execute the final call using `doit()`.
2274/// // Values shown here are possibly random and not representative !
2275/// let result = hub.projects().locations_backups_get("name")
2276///              .doit().await;
2277/// # }
2278/// ```
2279pub struct ProjectLocationBackupGetCall<'a, C>
2280where
2281    C: 'a,
2282{
2283    hub: &'a CloudFilestore<C>,
2284    _name: String,
2285    _delegate: Option<&'a mut dyn common::Delegate>,
2286    _additional_params: HashMap<String, String>,
2287    _scopes: BTreeSet<String>,
2288}
2289
2290impl<'a, C> common::CallBuilder for ProjectLocationBackupGetCall<'a, C> {}
2291
2292impl<'a, C> ProjectLocationBackupGetCall<'a, C>
2293where
2294    C: common::Connector,
2295{
2296    /// Perform the operation you have build so far.
2297    pub async fn doit(mut self) -> common::Result<(common::Response, Backup)> {
2298        use std::borrow::Cow;
2299        use std::io::{Read, Seek};
2300
2301        use common::{url::Params, ToParts};
2302        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2303
2304        let mut dd = common::DefaultDelegate;
2305        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2306        dlg.begin(common::MethodInfo {
2307            id: "file.projects.locations.backups.get",
2308            http_method: hyper::Method::GET,
2309        });
2310
2311        for &field in ["alt", "name"].iter() {
2312            if self._additional_params.contains_key(field) {
2313                dlg.finished(false);
2314                return Err(common::Error::FieldClash(field));
2315            }
2316        }
2317
2318        let mut params = Params::with_capacity(3 + self._additional_params.len());
2319        params.push("name", self._name);
2320
2321        params.extend(self._additional_params.iter());
2322
2323        params.push("alt", "json");
2324        let mut url = self.hub._base_url.clone() + "v1/{+name}";
2325        if self._scopes.is_empty() {
2326            self._scopes
2327                .insert(Scope::CloudPlatform.as_ref().to_string());
2328        }
2329
2330        #[allow(clippy::single_element_loop)]
2331        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2332            url = params.uri_replacement(url, param_name, find_this, true);
2333        }
2334        {
2335            let to_remove = ["name"];
2336            params.remove_params(&to_remove);
2337        }
2338
2339        let url = params.parse_with_url(&url);
2340
2341        loop {
2342            let token = match self
2343                .hub
2344                .auth
2345                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2346                .await
2347            {
2348                Ok(token) => token,
2349                Err(e) => match dlg.token(e) {
2350                    Ok(token) => token,
2351                    Err(e) => {
2352                        dlg.finished(false);
2353                        return Err(common::Error::MissingToken(e));
2354                    }
2355                },
2356            };
2357            let mut req_result = {
2358                let client = &self.hub.client;
2359                dlg.pre_request();
2360                let mut req_builder = hyper::Request::builder()
2361                    .method(hyper::Method::GET)
2362                    .uri(url.as_str())
2363                    .header(USER_AGENT, self.hub._user_agent.clone());
2364
2365                if let Some(token) = token.as_ref() {
2366                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2367                }
2368
2369                let request = req_builder
2370                    .header(CONTENT_LENGTH, 0_u64)
2371                    .body(common::to_body::<String>(None));
2372
2373                client.request(request.unwrap()).await
2374            };
2375
2376            match req_result {
2377                Err(err) => {
2378                    if let common::Retry::After(d) = dlg.http_error(&err) {
2379                        sleep(d).await;
2380                        continue;
2381                    }
2382                    dlg.finished(false);
2383                    return Err(common::Error::HttpError(err));
2384                }
2385                Ok(res) => {
2386                    let (mut parts, body) = res.into_parts();
2387                    let mut body = common::Body::new(body);
2388                    if !parts.status.is_success() {
2389                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2390                        let error = serde_json::from_str(&common::to_string(&bytes));
2391                        let response = common::to_response(parts, bytes.into());
2392
2393                        if let common::Retry::After(d) =
2394                            dlg.http_failure(&response, error.as_ref().ok())
2395                        {
2396                            sleep(d).await;
2397                            continue;
2398                        }
2399
2400                        dlg.finished(false);
2401
2402                        return Err(match error {
2403                            Ok(value) => common::Error::BadRequest(value),
2404                            _ => common::Error::Failure(response),
2405                        });
2406                    }
2407                    let response = {
2408                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2409                        let encoded = common::to_string(&bytes);
2410                        match serde_json::from_str(&encoded) {
2411                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2412                            Err(error) => {
2413                                dlg.response_json_decode_error(&encoded, &error);
2414                                return Err(common::Error::JsonDecodeError(
2415                                    encoded.to_string(),
2416                                    error,
2417                                ));
2418                            }
2419                        }
2420                    };
2421
2422                    dlg.finished(true);
2423                    return Ok(response);
2424                }
2425            }
2426        }
2427    }
2428
2429    /// Required. The backup resource name, in the format `projects/{project_number}/locations/{location}/backups/{backup_id}`.
2430    ///
2431    /// Sets the *name* path property to the given value.
2432    ///
2433    /// Even though the property as already been set when instantiating this call,
2434    /// we provide this method for API completeness.
2435    pub fn name(mut self, new_value: &str) -> ProjectLocationBackupGetCall<'a, C> {
2436        self._name = new_value.to_string();
2437        self
2438    }
2439    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2440    /// while executing the actual API request.
2441    ///
2442    /// ````text
2443    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2444    /// ````
2445    ///
2446    /// Sets the *delegate* property to the given value.
2447    pub fn delegate(
2448        mut self,
2449        new_value: &'a mut dyn common::Delegate,
2450    ) -> ProjectLocationBackupGetCall<'a, C> {
2451        self._delegate = Some(new_value);
2452        self
2453    }
2454
2455    /// Set any additional parameter of the query string used in the request.
2456    /// It should be used to set parameters which are not yet available through their own
2457    /// setters.
2458    ///
2459    /// Please note that this method must not be used to set any of the known parameters
2460    /// which have their own setter method. If done anyway, the request will fail.
2461    ///
2462    /// # Additional Parameters
2463    ///
2464    /// * *$.xgafv* (query-string) - V1 error format.
2465    /// * *access_token* (query-string) - OAuth access token.
2466    /// * *alt* (query-string) - Data format for response.
2467    /// * *callback* (query-string) - JSONP
2468    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2469    /// * *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.
2470    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2471    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2472    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2473    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2474    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2475    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBackupGetCall<'a, C>
2476    where
2477        T: AsRef<str>,
2478    {
2479        self._additional_params
2480            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2481        self
2482    }
2483
2484    /// Identifies the authorization scope for the method you are building.
2485    ///
2486    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2487    /// [`Scope::CloudPlatform`].
2488    ///
2489    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2490    /// tokens for more than one scope.
2491    ///
2492    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2493    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2494    /// sufficient, a read-write scope will do as well.
2495    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBackupGetCall<'a, C>
2496    where
2497        St: AsRef<str>,
2498    {
2499        self._scopes.insert(String::from(scope.as_ref()));
2500        self
2501    }
2502    /// Identifies the authorization scope(s) for the method you are building.
2503    ///
2504    /// See [`Self::add_scope()`] for details.
2505    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBackupGetCall<'a, C>
2506    where
2507        I: IntoIterator<Item = St>,
2508        St: AsRef<str>,
2509    {
2510        self._scopes
2511            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2512        self
2513    }
2514
2515    /// Removes all scopes, and no default scope will be used either.
2516    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2517    /// for details).
2518    pub fn clear_scopes(mut self) -> ProjectLocationBackupGetCall<'a, C> {
2519        self._scopes.clear();
2520        self
2521    }
2522}
2523
2524/// Lists all backups in a project for either a specified location or for all locations.
2525///
2526/// A builder for the *locations.backups.list* method supported by a *project* resource.
2527/// It is not used directly, but through a [`ProjectMethods`] instance.
2528///
2529/// # Example
2530///
2531/// Instantiate a resource method builder
2532///
2533/// ```test_harness,no_run
2534/// # extern crate hyper;
2535/// # extern crate hyper_rustls;
2536/// # extern crate google_file1 as file1;
2537/// # async fn dox() {
2538/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2539///
2540/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2541/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2542/// #     .with_native_roots()
2543/// #     .unwrap()
2544/// #     .https_only()
2545/// #     .enable_http2()
2546/// #     .build();
2547///
2548/// # let executor = hyper_util::rt::TokioExecutor::new();
2549/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2550/// #     secret,
2551/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2552/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2553/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2554/// #     ),
2555/// # ).build().await.unwrap();
2556///
2557/// # let client = hyper_util::client::legacy::Client::builder(
2558/// #     hyper_util::rt::TokioExecutor::new()
2559/// # )
2560/// # .build(
2561/// #     hyper_rustls::HttpsConnectorBuilder::new()
2562/// #         .with_native_roots()
2563/// #         .unwrap()
2564/// #         .https_or_http()
2565/// #         .enable_http2()
2566/// #         .build()
2567/// # );
2568/// # let mut hub = CloudFilestore::new(client, auth);
2569/// // You can configure optional parameters by calling the respective setters at will, and
2570/// // execute the final call using `doit()`.
2571/// // Values shown here are possibly random and not representative !
2572/// let result = hub.projects().locations_backups_list("parent")
2573///              .page_token("duo")
2574///              .page_size(-55)
2575///              .order_by("gubergren")
2576///              .filter("Lorem")
2577///              .doit().await;
2578/// # }
2579/// ```
2580pub struct ProjectLocationBackupListCall<'a, C>
2581where
2582    C: 'a,
2583{
2584    hub: &'a CloudFilestore<C>,
2585    _parent: String,
2586    _page_token: Option<String>,
2587    _page_size: Option<i32>,
2588    _order_by: Option<String>,
2589    _filter: Option<String>,
2590    _delegate: Option<&'a mut dyn common::Delegate>,
2591    _additional_params: HashMap<String, String>,
2592    _scopes: BTreeSet<String>,
2593}
2594
2595impl<'a, C> common::CallBuilder for ProjectLocationBackupListCall<'a, C> {}
2596
2597impl<'a, C> ProjectLocationBackupListCall<'a, C>
2598where
2599    C: common::Connector,
2600{
2601    /// Perform the operation you have build so far.
2602    pub async fn doit(mut self) -> common::Result<(common::Response, ListBackupsResponse)> {
2603        use std::borrow::Cow;
2604        use std::io::{Read, Seek};
2605
2606        use common::{url::Params, ToParts};
2607        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2608
2609        let mut dd = common::DefaultDelegate;
2610        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2611        dlg.begin(common::MethodInfo {
2612            id: "file.projects.locations.backups.list",
2613            http_method: hyper::Method::GET,
2614        });
2615
2616        for &field in [
2617            "alt",
2618            "parent",
2619            "pageToken",
2620            "pageSize",
2621            "orderBy",
2622            "filter",
2623        ]
2624        .iter()
2625        {
2626            if self._additional_params.contains_key(field) {
2627                dlg.finished(false);
2628                return Err(common::Error::FieldClash(field));
2629            }
2630        }
2631
2632        let mut params = Params::with_capacity(7 + self._additional_params.len());
2633        params.push("parent", self._parent);
2634        if let Some(value) = self._page_token.as_ref() {
2635            params.push("pageToken", value);
2636        }
2637        if let Some(value) = self._page_size.as_ref() {
2638            params.push("pageSize", value.to_string());
2639        }
2640        if let Some(value) = self._order_by.as_ref() {
2641            params.push("orderBy", value);
2642        }
2643        if let Some(value) = self._filter.as_ref() {
2644            params.push("filter", value);
2645        }
2646
2647        params.extend(self._additional_params.iter());
2648
2649        params.push("alt", "json");
2650        let mut url = self.hub._base_url.clone() + "v1/{+parent}/backups";
2651        if self._scopes.is_empty() {
2652            self._scopes
2653                .insert(Scope::CloudPlatform.as_ref().to_string());
2654        }
2655
2656        #[allow(clippy::single_element_loop)]
2657        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2658            url = params.uri_replacement(url, param_name, find_this, true);
2659        }
2660        {
2661            let to_remove = ["parent"];
2662            params.remove_params(&to_remove);
2663        }
2664
2665        let url = params.parse_with_url(&url);
2666
2667        loop {
2668            let token = match self
2669                .hub
2670                .auth
2671                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2672                .await
2673            {
2674                Ok(token) => token,
2675                Err(e) => match dlg.token(e) {
2676                    Ok(token) => token,
2677                    Err(e) => {
2678                        dlg.finished(false);
2679                        return Err(common::Error::MissingToken(e));
2680                    }
2681                },
2682            };
2683            let mut req_result = {
2684                let client = &self.hub.client;
2685                dlg.pre_request();
2686                let mut req_builder = hyper::Request::builder()
2687                    .method(hyper::Method::GET)
2688                    .uri(url.as_str())
2689                    .header(USER_AGENT, self.hub._user_agent.clone());
2690
2691                if let Some(token) = token.as_ref() {
2692                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2693                }
2694
2695                let request = req_builder
2696                    .header(CONTENT_LENGTH, 0_u64)
2697                    .body(common::to_body::<String>(None));
2698
2699                client.request(request.unwrap()).await
2700            };
2701
2702            match req_result {
2703                Err(err) => {
2704                    if let common::Retry::After(d) = dlg.http_error(&err) {
2705                        sleep(d).await;
2706                        continue;
2707                    }
2708                    dlg.finished(false);
2709                    return Err(common::Error::HttpError(err));
2710                }
2711                Ok(res) => {
2712                    let (mut parts, body) = res.into_parts();
2713                    let mut body = common::Body::new(body);
2714                    if !parts.status.is_success() {
2715                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2716                        let error = serde_json::from_str(&common::to_string(&bytes));
2717                        let response = common::to_response(parts, bytes.into());
2718
2719                        if let common::Retry::After(d) =
2720                            dlg.http_failure(&response, error.as_ref().ok())
2721                        {
2722                            sleep(d).await;
2723                            continue;
2724                        }
2725
2726                        dlg.finished(false);
2727
2728                        return Err(match error {
2729                            Ok(value) => common::Error::BadRequest(value),
2730                            _ => common::Error::Failure(response),
2731                        });
2732                    }
2733                    let response = {
2734                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2735                        let encoded = common::to_string(&bytes);
2736                        match serde_json::from_str(&encoded) {
2737                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2738                            Err(error) => {
2739                                dlg.response_json_decode_error(&encoded, &error);
2740                                return Err(common::Error::JsonDecodeError(
2741                                    encoded.to_string(),
2742                                    error,
2743                                ));
2744                            }
2745                        }
2746                    };
2747
2748                    dlg.finished(true);
2749                    return Ok(response);
2750                }
2751            }
2752        }
2753    }
2754
2755    /// Required. The project and location for which to retrieve backup information, in the format `projects/{project_number}/locations/{location}`. In Filestore, backup locations map to Google Cloud regions, for example **us-west1**. To retrieve backup information for all locations, use "-" for the `{location}` value.
2756    ///
2757    /// Sets the *parent* path property to the given value.
2758    ///
2759    /// Even though the property as already been set when instantiating this call,
2760    /// we provide this method for API completeness.
2761    pub fn parent(mut self, new_value: &str) -> ProjectLocationBackupListCall<'a, C> {
2762        self._parent = new_value.to_string();
2763        self
2764    }
2765    /// The next_page_token value to use if there are additional results to retrieve for this list request.
2766    ///
2767    /// Sets the *page token* query property to the given value.
2768    pub fn page_token(mut self, new_value: &str) -> ProjectLocationBackupListCall<'a, C> {
2769        self._page_token = Some(new_value.to_string());
2770        self
2771    }
2772    /// The maximum number of items to return.
2773    ///
2774    /// Sets the *page size* query property to the given value.
2775    pub fn page_size(mut self, new_value: i32) -> ProjectLocationBackupListCall<'a, C> {
2776        self._page_size = Some(new_value);
2777        self
2778    }
2779    /// Sort results. Supported values are "name", "name desc" or "" (unsorted).
2780    ///
2781    /// Sets the *order by* query property to the given value.
2782    pub fn order_by(mut self, new_value: &str) -> ProjectLocationBackupListCall<'a, C> {
2783        self._order_by = Some(new_value.to_string());
2784        self
2785    }
2786    /// List filter.
2787    ///
2788    /// Sets the *filter* query property to the given value.
2789    pub fn filter(mut self, new_value: &str) -> ProjectLocationBackupListCall<'a, C> {
2790        self._filter = Some(new_value.to_string());
2791        self
2792    }
2793    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2794    /// while executing the actual API request.
2795    ///
2796    /// ````text
2797    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2798    /// ````
2799    ///
2800    /// Sets the *delegate* property to the given value.
2801    pub fn delegate(
2802        mut self,
2803        new_value: &'a mut dyn common::Delegate,
2804    ) -> ProjectLocationBackupListCall<'a, C> {
2805        self._delegate = Some(new_value);
2806        self
2807    }
2808
2809    /// Set any additional parameter of the query string used in the request.
2810    /// It should be used to set parameters which are not yet available through their own
2811    /// setters.
2812    ///
2813    /// Please note that this method must not be used to set any of the known parameters
2814    /// which have their own setter method. If done anyway, the request will fail.
2815    ///
2816    /// # Additional Parameters
2817    ///
2818    /// * *$.xgafv* (query-string) - V1 error format.
2819    /// * *access_token* (query-string) - OAuth access token.
2820    /// * *alt* (query-string) - Data format for response.
2821    /// * *callback* (query-string) - JSONP
2822    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2823    /// * *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.
2824    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2825    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2826    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2827    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2828    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2829    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBackupListCall<'a, C>
2830    where
2831        T: AsRef<str>,
2832    {
2833        self._additional_params
2834            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2835        self
2836    }
2837
2838    /// Identifies the authorization scope for the method you are building.
2839    ///
2840    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2841    /// [`Scope::CloudPlatform`].
2842    ///
2843    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2844    /// tokens for more than one scope.
2845    ///
2846    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2847    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2848    /// sufficient, a read-write scope will do as well.
2849    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBackupListCall<'a, C>
2850    where
2851        St: AsRef<str>,
2852    {
2853        self._scopes.insert(String::from(scope.as_ref()));
2854        self
2855    }
2856    /// Identifies the authorization scope(s) for the method you are building.
2857    ///
2858    /// See [`Self::add_scope()`] for details.
2859    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBackupListCall<'a, C>
2860    where
2861        I: IntoIterator<Item = St>,
2862        St: AsRef<str>,
2863    {
2864        self._scopes
2865            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2866        self
2867    }
2868
2869    /// Removes all scopes, and no default scope will be used either.
2870    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2871    /// for details).
2872    pub fn clear_scopes(mut self) -> ProjectLocationBackupListCall<'a, C> {
2873        self._scopes.clear();
2874        self
2875    }
2876}
2877
2878/// Updates the settings of a specific backup.
2879///
2880/// A builder for the *locations.backups.patch* method supported by a *project* resource.
2881/// It is not used directly, but through a [`ProjectMethods`] instance.
2882///
2883/// # Example
2884///
2885/// Instantiate a resource method builder
2886///
2887/// ```test_harness,no_run
2888/// # extern crate hyper;
2889/// # extern crate hyper_rustls;
2890/// # extern crate google_file1 as file1;
2891/// use file1::api::Backup;
2892/// # async fn dox() {
2893/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2894///
2895/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2896/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2897/// #     .with_native_roots()
2898/// #     .unwrap()
2899/// #     .https_only()
2900/// #     .enable_http2()
2901/// #     .build();
2902///
2903/// # let executor = hyper_util::rt::TokioExecutor::new();
2904/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2905/// #     secret,
2906/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2907/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2908/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2909/// #     ),
2910/// # ).build().await.unwrap();
2911///
2912/// # let client = hyper_util::client::legacy::Client::builder(
2913/// #     hyper_util::rt::TokioExecutor::new()
2914/// # )
2915/// # .build(
2916/// #     hyper_rustls::HttpsConnectorBuilder::new()
2917/// #         .with_native_roots()
2918/// #         .unwrap()
2919/// #         .https_or_http()
2920/// #         .enable_http2()
2921/// #         .build()
2922/// # );
2923/// # let mut hub = CloudFilestore::new(client, auth);
2924/// // As the method needs a request, you would usually fill it with the desired information
2925/// // into the respective structure. Some of the parts shown here might not be applicable !
2926/// // Values shown here are possibly random and not representative !
2927/// let mut req = Backup::default();
2928///
2929/// // You can configure optional parameters by calling the respective setters at will, and
2930/// // execute the final call using `doit()`.
2931/// // Values shown here are possibly random and not representative !
2932/// let result = hub.projects().locations_backups_patch(req, "name")
2933///              .update_mask(FieldMask::new::<&str>(&[]))
2934///              .doit().await;
2935/// # }
2936/// ```
2937pub struct ProjectLocationBackupPatchCall<'a, C>
2938where
2939    C: 'a,
2940{
2941    hub: &'a CloudFilestore<C>,
2942    _request: Backup,
2943    _name: String,
2944    _update_mask: Option<common::FieldMask>,
2945    _delegate: Option<&'a mut dyn common::Delegate>,
2946    _additional_params: HashMap<String, String>,
2947    _scopes: BTreeSet<String>,
2948}
2949
2950impl<'a, C> common::CallBuilder for ProjectLocationBackupPatchCall<'a, C> {}
2951
2952impl<'a, C> ProjectLocationBackupPatchCall<'a, C>
2953where
2954    C: common::Connector,
2955{
2956    /// Perform the operation you have build so far.
2957    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2958        use std::borrow::Cow;
2959        use std::io::{Read, Seek};
2960
2961        use common::{url::Params, ToParts};
2962        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2963
2964        let mut dd = common::DefaultDelegate;
2965        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2966        dlg.begin(common::MethodInfo {
2967            id: "file.projects.locations.backups.patch",
2968            http_method: hyper::Method::PATCH,
2969        });
2970
2971        for &field in ["alt", "name", "updateMask"].iter() {
2972            if self._additional_params.contains_key(field) {
2973                dlg.finished(false);
2974                return Err(common::Error::FieldClash(field));
2975            }
2976        }
2977
2978        let mut params = Params::with_capacity(5 + self._additional_params.len());
2979        params.push("name", self._name);
2980        if let Some(value) = self._update_mask.as_ref() {
2981            params.push("updateMask", value.to_string());
2982        }
2983
2984        params.extend(self._additional_params.iter());
2985
2986        params.push("alt", "json");
2987        let mut url = self.hub._base_url.clone() + "v1/{+name}";
2988        if self._scopes.is_empty() {
2989            self._scopes
2990                .insert(Scope::CloudPlatform.as_ref().to_string());
2991        }
2992
2993        #[allow(clippy::single_element_loop)]
2994        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2995            url = params.uri_replacement(url, param_name, find_this, true);
2996        }
2997        {
2998            let to_remove = ["name"];
2999            params.remove_params(&to_remove);
3000        }
3001
3002        let url = params.parse_with_url(&url);
3003
3004        let mut json_mime_type = mime::APPLICATION_JSON;
3005        let mut request_value_reader = {
3006            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3007            common::remove_json_null_values(&mut value);
3008            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3009            serde_json::to_writer(&mut dst, &value).unwrap();
3010            dst
3011        };
3012        let request_size = request_value_reader
3013            .seek(std::io::SeekFrom::End(0))
3014            .unwrap();
3015        request_value_reader
3016            .seek(std::io::SeekFrom::Start(0))
3017            .unwrap();
3018
3019        loop {
3020            let token = match self
3021                .hub
3022                .auth
3023                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3024                .await
3025            {
3026                Ok(token) => token,
3027                Err(e) => match dlg.token(e) {
3028                    Ok(token) => token,
3029                    Err(e) => {
3030                        dlg.finished(false);
3031                        return Err(common::Error::MissingToken(e));
3032                    }
3033                },
3034            };
3035            request_value_reader
3036                .seek(std::io::SeekFrom::Start(0))
3037                .unwrap();
3038            let mut req_result = {
3039                let client = &self.hub.client;
3040                dlg.pre_request();
3041                let mut req_builder = hyper::Request::builder()
3042                    .method(hyper::Method::PATCH)
3043                    .uri(url.as_str())
3044                    .header(USER_AGENT, self.hub._user_agent.clone());
3045
3046                if let Some(token) = token.as_ref() {
3047                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3048                }
3049
3050                let request = req_builder
3051                    .header(CONTENT_TYPE, json_mime_type.to_string())
3052                    .header(CONTENT_LENGTH, request_size as u64)
3053                    .body(common::to_body(
3054                        request_value_reader.get_ref().clone().into(),
3055                    ));
3056
3057                client.request(request.unwrap()).await
3058            };
3059
3060            match req_result {
3061                Err(err) => {
3062                    if let common::Retry::After(d) = dlg.http_error(&err) {
3063                        sleep(d).await;
3064                        continue;
3065                    }
3066                    dlg.finished(false);
3067                    return Err(common::Error::HttpError(err));
3068                }
3069                Ok(res) => {
3070                    let (mut parts, body) = res.into_parts();
3071                    let mut body = common::Body::new(body);
3072                    if !parts.status.is_success() {
3073                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3074                        let error = serde_json::from_str(&common::to_string(&bytes));
3075                        let response = common::to_response(parts, bytes.into());
3076
3077                        if let common::Retry::After(d) =
3078                            dlg.http_failure(&response, error.as_ref().ok())
3079                        {
3080                            sleep(d).await;
3081                            continue;
3082                        }
3083
3084                        dlg.finished(false);
3085
3086                        return Err(match error {
3087                            Ok(value) => common::Error::BadRequest(value),
3088                            _ => common::Error::Failure(response),
3089                        });
3090                    }
3091                    let response = {
3092                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3093                        let encoded = common::to_string(&bytes);
3094                        match serde_json::from_str(&encoded) {
3095                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3096                            Err(error) => {
3097                                dlg.response_json_decode_error(&encoded, &error);
3098                                return Err(common::Error::JsonDecodeError(
3099                                    encoded.to_string(),
3100                                    error,
3101                                ));
3102                            }
3103                        }
3104                    };
3105
3106                    dlg.finished(true);
3107                    return Ok(response);
3108                }
3109            }
3110        }
3111    }
3112
3113    ///
3114    /// Sets the *request* property to the given value.
3115    ///
3116    /// Even though the property as already been set when instantiating this call,
3117    /// we provide this method for API completeness.
3118    pub fn request(mut self, new_value: Backup) -> ProjectLocationBackupPatchCall<'a, C> {
3119        self._request = new_value;
3120        self
3121    }
3122    /// Output only. The resource name of the backup, in the format `projects/{project_number}/locations/{location_id}/backups/{backup_id}`.
3123    ///
3124    /// Sets the *name* path property to the given value.
3125    ///
3126    /// Even though the property as already been set when instantiating this call,
3127    /// we provide this method for API completeness.
3128    pub fn name(mut self, new_value: &str) -> ProjectLocationBackupPatchCall<'a, C> {
3129        self._name = new_value.to_string();
3130        self
3131    }
3132    /// Required. Mask of fields to update. At least one path must be supplied in this field.
3133    ///
3134    /// Sets the *update mask* query property to the given value.
3135    pub fn update_mask(
3136        mut self,
3137        new_value: common::FieldMask,
3138    ) -> ProjectLocationBackupPatchCall<'a, C> {
3139        self._update_mask = Some(new_value);
3140        self
3141    }
3142    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3143    /// while executing the actual API request.
3144    ///
3145    /// ````text
3146    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3147    /// ````
3148    ///
3149    /// Sets the *delegate* property to the given value.
3150    pub fn delegate(
3151        mut self,
3152        new_value: &'a mut dyn common::Delegate,
3153    ) -> ProjectLocationBackupPatchCall<'a, C> {
3154        self._delegate = Some(new_value);
3155        self
3156    }
3157
3158    /// Set any additional parameter of the query string used in the request.
3159    /// It should be used to set parameters which are not yet available through their own
3160    /// setters.
3161    ///
3162    /// Please note that this method must not be used to set any of the known parameters
3163    /// which have their own setter method. If done anyway, the request will fail.
3164    ///
3165    /// # Additional Parameters
3166    ///
3167    /// * *$.xgafv* (query-string) - V1 error format.
3168    /// * *access_token* (query-string) - OAuth access token.
3169    /// * *alt* (query-string) - Data format for response.
3170    /// * *callback* (query-string) - JSONP
3171    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3172    /// * *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.
3173    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3174    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3175    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3176    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3177    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3178    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBackupPatchCall<'a, C>
3179    where
3180        T: AsRef<str>,
3181    {
3182        self._additional_params
3183            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3184        self
3185    }
3186
3187    /// Identifies the authorization scope for the method you are building.
3188    ///
3189    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3190    /// [`Scope::CloudPlatform`].
3191    ///
3192    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3193    /// tokens for more than one scope.
3194    ///
3195    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3196    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3197    /// sufficient, a read-write scope will do as well.
3198    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBackupPatchCall<'a, C>
3199    where
3200        St: AsRef<str>,
3201    {
3202        self._scopes.insert(String::from(scope.as_ref()));
3203        self
3204    }
3205    /// Identifies the authorization scope(s) for the method you are building.
3206    ///
3207    /// See [`Self::add_scope()`] for details.
3208    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBackupPatchCall<'a, C>
3209    where
3210        I: IntoIterator<Item = St>,
3211        St: AsRef<str>,
3212    {
3213        self._scopes
3214            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3215        self
3216    }
3217
3218    /// Removes all scopes, and no default scope will be used either.
3219    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3220    /// for details).
3221    pub fn clear_scopes(mut self) -> ProjectLocationBackupPatchCall<'a, C> {
3222        self._scopes.clear();
3223        self
3224    }
3225}
3226
3227/// Creates a snapshot.
3228///
3229/// A builder for the *locations.instances.snapshots.create* method supported by a *project* resource.
3230/// It is not used directly, but through a [`ProjectMethods`] instance.
3231///
3232/// # Example
3233///
3234/// Instantiate a resource method builder
3235///
3236/// ```test_harness,no_run
3237/// # extern crate hyper;
3238/// # extern crate hyper_rustls;
3239/// # extern crate google_file1 as file1;
3240/// use file1::api::Snapshot;
3241/// # async fn dox() {
3242/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3243///
3244/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3245/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3246/// #     .with_native_roots()
3247/// #     .unwrap()
3248/// #     .https_only()
3249/// #     .enable_http2()
3250/// #     .build();
3251///
3252/// # let executor = hyper_util::rt::TokioExecutor::new();
3253/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3254/// #     secret,
3255/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3256/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3257/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3258/// #     ),
3259/// # ).build().await.unwrap();
3260///
3261/// # let client = hyper_util::client::legacy::Client::builder(
3262/// #     hyper_util::rt::TokioExecutor::new()
3263/// # )
3264/// # .build(
3265/// #     hyper_rustls::HttpsConnectorBuilder::new()
3266/// #         .with_native_roots()
3267/// #         .unwrap()
3268/// #         .https_or_http()
3269/// #         .enable_http2()
3270/// #         .build()
3271/// # );
3272/// # let mut hub = CloudFilestore::new(client, auth);
3273/// // As the method needs a request, you would usually fill it with the desired information
3274/// // into the respective structure. Some of the parts shown here might not be applicable !
3275/// // Values shown here are possibly random and not representative !
3276/// let mut req = Snapshot::default();
3277///
3278/// // You can configure optional parameters by calling the respective setters at will, and
3279/// // execute the final call using `doit()`.
3280/// // Values shown here are possibly random and not representative !
3281/// let result = hub.projects().locations_instances_snapshots_create(req, "parent")
3282///              .snapshot_id("dolor")
3283///              .doit().await;
3284/// # }
3285/// ```
3286pub struct ProjectLocationInstanceSnapshotCreateCall<'a, C>
3287where
3288    C: 'a,
3289{
3290    hub: &'a CloudFilestore<C>,
3291    _request: Snapshot,
3292    _parent: String,
3293    _snapshot_id: Option<String>,
3294    _delegate: Option<&'a mut dyn common::Delegate>,
3295    _additional_params: HashMap<String, String>,
3296    _scopes: BTreeSet<String>,
3297}
3298
3299impl<'a, C> common::CallBuilder for ProjectLocationInstanceSnapshotCreateCall<'a, C> {}
3300
3301impl<'a, C> ProjectLocationInstanceSnapshotCreateCall<'a, C>
3302where
3303    C: common::Connector,
3304{
3305    /// Perform the operation you have build so far.
3306    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3307        use std::borrow::Cow;
3308        use std::io::{Read, Seek};
3309
3310        use common::{url::Params, ToParts};
3311        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3312
3313        let mut dd = common::DefaultDelegate;
3314        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3315        dlg.begin(common::MethodInfo {
3316            id: "file.projects.locations.instances.snapshots.create",
3317            http_method: hyper::Method::POST,
3318        });
3319
3320        for &field in ["alt", "parent", "snapshotId"].iter() {
3321            if self._additional_params.contains_key(field) {
3322                dlg.finished(false);
3323                return Err(common::Error::FieldClash(field));
3324            }
3325        }
3326
3327        let mut params = Params::with_capacity(5 + self._additional_params.len());
3328        params.push("parent", self._parent);
3329        if let Some(value) = self._snapshot_id.as_ref() {
3330            params.push("snapshotId", value);
3331        }
3332
3333        params.extend(self._additional_params.iter());
3334
3335        params.push("alt", "json");
3336        let mut url = self.hub._base_url.clone() + "v1/{+parent}/snapshots";
3337        if self._scopes.is_empty() {
3338            self._scopes
3339                .insert(Scope::CloudPlatform.as_ref().to_string());
3340        }
3341
3342        #[allow(clippy::single_element_loop)]
3343        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3344            url = params.uri_replacement(url, param_name, find_this, true);
3345        }
3346        {
3347            let to_remove = ["parent"];
3348            params.remove_params(&to_remove);
3349        }
3350
3351        let url = params.parse_with_url(&url);
3352
3353        let mut json_mime_type = mime::APPLICATION_JSON;
3354        let mut request_value_reader = {
3355            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3356            common::remove_json_null_values(&mut value);
3357            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3358            serde_json::to_writer(&mut dst, &value).unwrap();
3359            dst
3360        };
3361        let request_size = request_value_reader
3362            .seek(std::io::SeekFrom::End(0))
3363            .unwrap();
3364        request_value_reader
3365            .seek(std::io::SeekFrom::Start(0))
3366            .unwrap();
3367
3368        loop {
3369            let token = match self
3370                .hub
3371                .auth
3372                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3373                .await
3374            {
3375                Ok(token) => token,
3376                Err(e) => match dlg.token(e) {
3377                    Ok(token) => token,
3378                    Err(e) => {
3379                        dlg.finished(false);
3380                        return Err(common::Error::MissingToken(e));
3381                    }
3382                },
3383            };
3384            request_value_reader
3385                .seek(std::io::SeekFrom::Start(0))
3386                .unwrap();
3387            let mut req_result = {
3388                let client = &self.hub.client;
3389                dlg.pre_request();
3390                let mut req_builder = hyper::Request::builder()
3391                    .method(hyper::Method::POST)
3392                    .uri(url.as_str())
3393                    .header(USER_AGENT, self.hub._user_agent.clone());
3394
3395                if let Some(token) = token.as_ref() {
3396                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3397                }
3398
3399                let request = req_builder
3400                    .header(CONTENT_TYPE, json_mime_type.to_string())
3401                    .header(CONTENT_LENGTH, request_size as u64)
3402                    .body(common::to_body(
3403                        request_value_reader.get_ref().clone().into(),
3404                    ));
3405
3406                client.request(request.unwrap()).await
3407            };
3408
3409            match req_result {
3410                Err(err) => {
3411                    if let common::Retry::After(d) = dlg.http_error(&err) {
3412                        sleep(d).await;
3413                        continue;
3414                    }
3415                    dlg.finished(false);
3416                    return Err(common::Error::HttpError(err));
3417                }
3418                Ok(res) => {
3419                    let (mut parts, body) = res.into_parts();
3420                    let mut body = common::Body::new(body);
3421                    if !parts.status.is_success() {
3422                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3423                        let error = serde_json::from_str(&common::to_string(&bytes));
3424                        let response = common::to_response(parts, bytes.into());
3425
3426                        if let common::Retry::After(d) =
3427                            dlg.http_failure(&response, error.as_ref().ok())
3428                        {
3429                            sleep(d).await;
3430                            continue;
3431                        }
3432
3433                        dlg.finished(false);
3434
3435                        return Err(match error {
3436                            Ok(value) => common::Error::BadRequest(value),
3437                            _ => common::Error::Failure(response),
3438                        });
3439                    }
3440                    let response = {
3441                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3442                        let encoded = common::to_string(&bytes);
3443                        match serde_json::from_str(&encoded) {
3444                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3445                            Err(error) => {
3446                                dlg.response_json_decode_error(&encoded, &error);
3447                                return Err(common::Error::JsonDecodeError(
3448                                    encoded.to_string(),
3449                                    error,
3450                                ));
3451                            }
3452                        }
3453                    };
3454
3455                    dlg.finished(true);
3456                    return Ok(response);
3457                }
3458            }
3459        }
3460    }
3461
3462    ///
3463    /// Sets the *request* property to the given value.
3464    ///
3465    /// Even though the property as already been set when instantiating this call,
3466    /// we provide this method for API completeness.
3467    pub fn request(
3468        mut self,
3469        new_value: Snapshot,
3470    ) -> ProjectLocationInstanceSnapshotCreateCall<'a, C> {
3471        self._request = new_value;
3472        self
3473    }
3474    /// Required. The Filestore Instance to create the snapshots of, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`
3475    ///
3476    /// Sets the *parent* path property to the given value.
3477    ///
3478    /// Even though the property as already been set when instantiating this call,
3479    /// we provide this method for API completeness.
3480    pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotCreateCall<'a, C> {
3481        self._parent = new_value.to_string();
3482        self
3483    }
3484    /// Required. The ID to use for the snapshot. The ID must be unique within the specified instance. This value must start with a lowercase letter followed by up to 62 lowercase letters, numbers, or hyphens, and cannot end with a hyphen.
3485    ///
3486    /// Sets the *snapshot id* query property to the given value.
3487    pub fn snapshot_id(
3488        mut self,
3489        new_value: &str,
3490    ) -> ProjectLocationInstanceSnapshotCreateCall<'a, C> {
3491        self._snapshot_id = Some(new_value.to_string());
3492        self
3493    }
3494    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3495    /// while executing the actual API request.
3496    ///
3497    /// ````text
3498    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3499    /// ````
3500    ///
3501    /// Sets the *delegate* property to the given value.
3502    pub fn delegate(
3503        mut self,
3504        new_value: &'a mut dyn common::Delegate,
3505    ) -> ProjectLocationInstanceSnapshotCreateCall<'a, C> {
3506        self._delegate = Some(new_value);
3507        self
3508    }
3509
3510    /// Set any additional parameter of the query string used in the request.
3511    /// It should be used to set parameters which are not yet available through their own
3512    /// setters.
3513    ///
3514    /// Please note that this method must not be used to set any of the known parameters
3515    /// which have their own setter method. If done anyway, the request will fail.
3516    ///
3517    /// # Additional Parameters
3518    ///
3519    /// * *$.xgafv* (query-string) - V1 error format.
3520    /// * *access_token* (query-string) - OAuth access token.
3521    /// * *alt* (query-string) - Data format for response.
3522    /// * *callback* (query-string) - JSONP
3523    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3524    /// * *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.
3525    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3526    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3527    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3528    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3529    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3530    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSnapshotCreateCall<'a, C>
3531    where
3532        T: AsRef<str>,
3533    {
3534        self._additional_params
3535            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3536        self
3537    }
3538
3539    /// Identifies the authorization scope for the method you are building.
3540    ///
3541    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3542    /// [`Scope::CloudPlatform`].
3543    ///
3544    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3545    /// tokens for more than one scope.
3546    ///
3547    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3548    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3549    /// sufficient, a read-write scope will do as well.
3550    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceSnapshotCreateCall<'a, C>
3551    where
3552        St: AsRef<str>,
3553    {
3554        self._scopes.insert(String::from(scope.as_ref()));
3555        self
3556    }
3557    /// Identifies the authorization scope(s) for the method you are building.
3558    ///
3559    /// See [`Self::add_scope()`] for details.
3560    pub fn add_scopes<I, St>(
3561        mut self,
3562        scopes: I,
3563    ) -> ProjectLocationInstanceSnapshotCreateCall<'a, C>
3564    where
3565        I: IntoIterator<Item = St>,
3566        St: AsRef<str>,
3567    {
3568        self._scopes
3569            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3570        self
3571    }
3572
3573    /// Removes all scopes, and no default scope will be used either.
3574    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3575    /// for details).
3576    pub fn clear_scopes(mut self) -> ProjectLocationInstanceSnapshotCreateCall<'a, C> {
3577        self._scopes.clear();
3578        self
3579    }
3580}
3581
3582/// Deletes a snapshot.
3583///
3584/// A builder for the *locations.instances.snapshots.delete* method supported by a *project* resource.
3585/// It is not used directly, but through a [`ProjectMethods`] instance.
3586///
3587/// # Example
3588///
3589/// Instantiate a resource method builder
3590///
3591/// ```test_harness,no_run
3592/// # extern crate hyper;
3593/// # extern crate hyper_rustls;
3594/// # extern crate google_file1 as file1;
3595/// # async fn dox() {
3596/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3597///
3598/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3599/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3600/// #     .with_native_roots()
3601/// #     .unwrap()
3602/// #     .https_only()
3603/// #     .enable_http2()
3604/// #     .build();
3605///
3606/// # let executor = hyper_util::rt::TokioExecutor::new();
3607/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3608/// #     secret,
3609/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3610/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3611/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3612/// #     ),
3613/// # ).build().await.unwrap();
3614///
3615/// # let client = hyper_util::client::legacy::Client::builder(
3616/// #     hyper_util::rt::TokioExecutor::new()
3617/// # )
3618/// # .build(
3619/// #     hyper_rustls::HttpsConnectorBuilder::new()
3620/// #         .with_native_roots()
3621/// #         .unwrap()
3622/// #         .https_or_http()
3623/// #         .enable_http2()
3624/// #         .build()
3625/// # );
3626/// # let mut hub = CloudFilestore::new(client, auth);
3627/// // You can configure optional parameters by calling the respective setters at will, and
3628/// // execute the final call using `doit()`.
3629/// // Values shown here are possibly random and not representative !
3630/// let result = hub.projects().locations_instances_snapshots_delete("name")
3631///              .doit().await;
3632/// # }
3633/// ```
3634pub struct ProjectLocationInstanceSnapshotDeleteCall<'a, C>
3635where
3636    C: 'a,
3637{
3638    hub: &'a CloudFilestore<C>,
3639    _name: String,
3640    _delegate: Option<&'a mut dyn common::Delegate>,
3641    _additional_params: HashMap<String, String>,
3642    _scopes: BTreeSet<String>,
3643}
3644
3645impl<'a, C> common::CallBuilder for ProjectLocationInstanceSnapshotDeleteCall<'a, C> {}
3646
3647impl<'a, C> ProjectLocationInstanceSnapshotDeleteCall<'a, C>
3648where
3649    C: common::Connector,
3650{
3651    /// Perform the operation you have build so far.
3652    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3653        use std::borrow::Cow;
3654        use std::io::{Read, Seek};
3655
3656        use common::{url::Params, ToParts};
3657        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3658
3659        let mut dd = common::DefaultDelegate;
3660        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3661        dlg.begin(common::MethodInfo {
3662            id: "file.projects.locations.instances.snapshots.delete",
3663            http_method: hyper::Method::DELETE,
3664        });
3665
3666        for &field in ["alt", "name"].iter() {
3667            if self._additional_params.contains_key(field) {
3668                dlg.finished(false);
3669                return Err(common::Error::FieldClash(field));
3670            }
3671        }
3672
3673        let mut params = Params::with_capacity(3 + self._additional_params.len());
3674        params.push("name", self._name);
3675
3676        params.extend(self._additional_params.iter());
3677
3678        params.push("alt", "json");
3679        let mut url = self.hub._base_url.clone() + "v1/{+name}";
3680        if self._scopes.is_empty() {
3681            self._scopes
3682                .insert(Scope::CloudPlatform.as_ref().to_string());
3683        }
3684
3685        #[allow(clippy::single_element_loop)]
3686        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3687            url = params.uri_replacement(url, param_name, find_this, true);
3688        }
3689        {
3690            let to_remove = ["name"];
3691            params.remove_params(&to_remove);
3692        }
3693
3694        let url = params.parse_with_url(&url);
3695
3696        loop {
3697            let token = match self
3698                .hub
3699                .auth
3700                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3701                .await
3702            {
3703                Ok(token) => token,
3704                Err(e) => match dlg.token(e) {
3705                    Ok(token) => token,
3706                    Err(e) => {
3707                        dlg.finished(false);
3708                        return Err(common::Error::MissingToken(e));
3709                    }
3710                },
3711            };
3712            let mut req_result = {
3713                let client = &self.hub.client;
3714                dlg.pre_request();
3715                let mut req_builder = hyper::Request::builder()
3716                    .method(hyper::Method::DELETE)
3717                    .uri(url.as_str())
3718                    .header(USER_AGENT, self.hub._user_agent.clone());
3719
3720                if let Some(token) = token.as_ref() {
3721                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3722                }
3723
3724                let request = req_builder
3725                    .header(CONTENT_LENGTH, 0_u64)
3726                    .body(common::to_body::<String>(None));
3727
3728                client.request(request.unwrap()).await
3729            };
3730
3731            match req_result {
3732                Err(err) => {
3733                    if let common::Retry::After(d) = dlg.http_error(&err) {
3734                        sleep(d).await;
3735                        continue;
3736                    }
3737                    dlg.finished(false);
3738                    return Err(common::Error::HttpError(err));
3739                }
3740                Ok(res) => {
3741                    let (mut parts, body) = res.into_parts();
3742                    let mut body = common::Body::new(body);
3743                    if !parts.status.is_success() {
3744                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3745                        let error = serde_json::from_str(&common::to_string(&bytes));
3746                        let response = common::to_response(parts, bytes.into());
3747
3748                        if let common::Retry::After(d) =
3749                            dlg.http_failure(&response, error.as_ref().ok())
3750                        {
3751                            sleep(d).await;
3752                            continue;
3753                        }
3754
3755                        dlg.finished(false);
3756
3757                        return Err(match error {
3758                            Ok(value) => common::Error::BadRequest(value),
3759                            _ => common::Error::Failure(response),
3760                        });
3761                    }
3762                    let response = {
3763                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3764                        let encoded = common::to_string(&bytes);
3765                        match serde_json::from_str(&encoded) {
3766                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3767                            Err(error) => {
3768                                dlg.response_json_decode_error(&encoded, &error);
3769                                return Err(common::Error::JsonDecodeError(
3770                                    encoded.to_string(),
3771                                    error,
3772                                ));
3773                            }
3774                        }
3775                    };
3776
3777                    dlg.finished(true);
3778                    return Ok(response);
3779                }
3780            }
3781        }
3782    }
3783
3784    /// Required. The snapshot resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}/snapshots/{snapshot_id}`
3785    ///
3786    /// Sets the *name* path property to the given value.
3787    ///
3788    /// Even though the property as already been set when instantiating this call,
3789    /// we provide this method for API completeness.
3790    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotDeleteCall<'a, C> {
3791        self._name = new_value.to_string();
3792        self
3793    }
3794    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3795    /// while executing the actual API request.
3796    ///
3797    /// ````text
3798    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3799    /// ````
3800    ///
3801    /// Sets the *delegate* property to the given value.
3802    pub fn delegate(
3803        mut self,
3804        new_value: &'a mut dyn common::Delegate,
3805    ) -> ProjectLocationInstanceSnapshotDeleteCall<'a, C> {
3806        self._delegate = Some(new_value);
3807        self
3808    }
3809
3810    /// Set any additional parameter of the query string used in the request.
3811    /// It should be used to set parameters which are not yet available through their own
3812    /// setters.
3813    ///
3814    /// Please note that this method must not be used to set any of the known parameters
3815    /// which have their own setter method. If done anyway, the request will fail.
3816    ///
3817    /// # Additional Parameters
3818    ///
3819    /// * *$.xgafv* (query-string) - V1 error format.
3820    /// * *access_token* (query-string) - OAuth access token.
3821    /// * *alt* (query-string) - Data format for response.
3822    /// * *callback* (query-string) - JSONP
3823    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3824    /// * *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.
3825    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3826    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3827    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3828    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3829    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3830    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSnapshotDeleteCall<'a, C>
3831    where
3832        T: AsRef<str>,
3833    {
3834        self._additional_params
3835            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3836        self
3837    }
3838
3839    /// Identifies the authorization scope for the method you are building.
3840    ///
3841    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3842    /// [`Scope::CloudPlatform`].
3843    ///
3844    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3845    /// tokens for more than one scope.
3846    ///
3847    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3848    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3849    /// sufficient, a read-write scope will do as well.
3850    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceSnapshotDeleteCall<'a, C>
3851    where
3852        St: AsRef<str>,
3853    {
3854        self._scopes.insert(String::from(scope.as_ref()));
3855        self
3856    }
3857    /// Identifies the authorization scope(s) for the method you are building.
3858    ///
3859    /// See [`Self::add_scope()`] for details.
3860    pub fn add_scopes<I, St>(
3861        mut self,
3862        scopes: I,
3863    ) -> ProjectLocationInstanceSnapshotDeleteCall<'a, C>
3864    where
3865        I: IntoIterator<Item = St>,
3866        St: AsRef<str>,
3867    {
3868        self._scopes
3869            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3870        self
3871    }
3872
3873    /// Removes all scopes, and no default scope will be used either.
3874    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3875    /// for details).
3876    pub fn clear_scopes(mut self) -> ProjectLocationInstanceSnapshotDeleteCall<'a, C> {
3877        self._scopes.clear();
3878        self
3879    }
3880}
3881
3882/// Gets the details of a specific snapshot.
3883///
3884/// A builder for the *locations.instances.snapshots.get* method supported by a *project* resource.
3885/// It is not used directly, but through a [`ProjectMethods`] instance.
3886///
3887/// # Example
3888///
3889/// Instantiate a resource method builder
3890///
3891/// ```test_harness,no_run
3892/// # extern crate hyper;
3893/// # extern crate hyper_rustls;
3894/// # extern crate google_file1 as file1;
3895/// # async fn dox() {
3896/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3897///
3898/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3899/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3900/// #     .with_native_roots()
3901/// #     .unwrap()
3902/// #     .https_only()
3903/// #     .enable_http2()
3904/// #     .build();
3905///
3906/// # let executor = hyper_util::rt::TokioExecutor::new();
3907/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3908/// #     secret,
3909/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3910/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3911/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3912/// #     ),
3913/// # ).build().await.unwrap();
3914///
3915/// # let client = hyper_util::client::legacy::Client::builder(
3916/// #     hyper_util::rt::TokioExecutor::new()
3917/// # )
3918/// # .build(
3919/// #     hyper_rustls::HttpsConnectorBuilder::new()
3920/// #         .with_native_roots()
3921/// #         .unwrap()
3922/// #         .https_or_http()
3923/// #         .enable_http2()
3924/// #         .build()
3925/// # );
3926/// # let mut hub = CloudFilestore::new(client, auth);
3927/// // You can configure optional parameters by calling the respective setters at will, and
3928/// // execute the final call using `doit()`.
3929/// // Values shown here are possibly random and not representative !
3930/// let result = hub.projects().locations_instances_snapshots_get("name")
3931///              .doit().await;
3932/// # }
3933/// ```
3934pub struct ProjectLocationInstanceSnapshotGetCall<'a, C>
3935where
3936    C: 'a,
3937{
3938    hub: &'a CloudFilestore<C>,
3939    _name: String,
3940    _delegate: Option<&'a mut dyn common::Delegate>,
3941    _additional_params: HashMap<String, String>,
3942    _scopes: BTreeSet<String>,
3943}
3944
3945impl<'a, C> common::CallBuilder for ProjectLocationInstanceSnapshotGetCall<'a, C> {}
3946
3947impl<'a, C> ProjectLocationInstanceSnapshotGetCall<'a, C>
3948where
3949    C: common::Connector,
3950{
3951    /// Perform the operation you have build so far.
3952    pub async fn doit(mut self) -> common::Result<(common::Response, Snapshot)> {
3953        use std::borrow::Cow;
3954        use std::io::{Read, Seek};
3955
3956        use common::{url::Params, ToParts};
3957        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3958
3959        let mut dd = common::DefaultDelegate;
3960        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3961        dlg.begin(common::MethodInfo {
3962            id: "file.projects.locations.instances.snapshots.get",
3963            http_method: hyper::Method::GET,
3964        });
3965
3966        for &field in ["alt", "name"].iter() {
3967            if self._additional_params.contains_key(field) {
3968                dlg.finished(false);
3969                return Err(common::Error::FieldClash(field));
3970            }
3971        }
3972
3973        let mut params = Params::with_capacity(3 + self._additional_params.len());
3974        params.push("name", self._name);
3975
3976        params.extend(self._additional_params.iter());
3977
3978        params.push("alt", "json");
3979        let mut url = self.hub._base_url.clone() + "v1/{+name}";
3980        if self._scopes.is_empty() {
3981            self._scopes
3982                .insert(Scope::CloudPlatform.as_ref().to_string());
3983        }
3984
3985        #[allow(clippy::single_element_loop)]
3986        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3987            url = params.uri_replacement(url, param_name, find_this, true);
3988        }
3989        {
3990            let to_remove = ["name"];
3991            params.remove_params(&to_remove);
3992        }
3993
3994        let url = params.parse_with_url(&url);
3995
3996        loop {
3997            let token = match self
3998                .hub
3999                .auth
4000                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4001                .await
4002            {
4003                Ok(token) => token,
4004                Err(e) => match dlg.token(e) {
4005                    Ok(token) => token,
4006                    Err(e) => {
4007                        dlg.finished(false);
4008                        return Err(common::Error::MissingToken(e));
4009                    }
4010                },
4011            };
4012            let mut req_result = {
4013                let client = &self.hub.client;
4014                dlg.pre_request();
4015                let mut req_builder = hyper::Request::builder()
4016                    .method(hyper::Method::GET)
4017                    .uri(url.as_str())
4018                    .header(USER_AGENT, self.hub._user_agent.clone());
4019
4020                if let Some(token) = token.as_ref() {
4021                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4022                }
4023
4024                let request = req_builder
4025                    .header(CONTENT_LENGTH, 0_u64)
4026                    .body(common::to_body::<String>(None));
4027
4028                client.request(request.unwrap()).await
4029            };
4030
4031            match req_result {
4032                Err(err) => {
4033                    if let common::Retry::After(d) = dlg.http_error(&err) {
4034                        sleep(d).await;
4035                        continue;
4036                    }
4037                    dlg.finished(false);
4038                    return Err(common::Error::HttpError(err));
4039                }
4040                Ok(res) => {
4041                    let (mut parts, body) = res.into_parts();
4042                    let mut body = common::Body::new(body);
4043                    if !parts.status.is_success() {
4044                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4045                        let error = serde_json::from_str(&common::to_string(&bytes));
4046                        let response = common::to_response(parts, bytes.into());
4047
4048                        if let common::Retry::After(d) =
4049                            dlg.http_failure(&response, error.as_ref().ok())
4050                        {
4051                            sleep(d).await;
4052                            continue;
4053                        }
4054
4055                        dlg.finished(false);
4056
4057                        return Err(match error {
4058                            Ok(value) => common::Error::BadRequest(value),
4059                            _ => common::Error::Failure(response),
4060                        });
4061                    }
4062                    let response = {
4063                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4064                        let encoded = common::to_string(&bytes);
4065                        match serde_json::from_str(&encoded) {
4066                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4067                            Err(error) => {
4068                                dlg.response_json_decode_error(&encoded, &error);
4069                                return Err(common::Error::JsonDecodeError(
4070                                    encoded.to_string(),
4071                                    error,
4072                                ));
4073                            }
4074                        }
4075                    };
4076
4077                    dlg.finished(true);
4078                    return Ok(response);
4079                }
4080            }
4081        }
4082    }
4083
4084    /// Required. The snapshot resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}/snapshots/{snapshot_id}`
4085    ///
4086    /// Sets the *name* path property to the given value.
4087    ///
4088    /// Even though the property as already been set when instantiating this call,
4089    /// we provide this method for API completeness.
4090    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotGetCall<'a, C> {
4091        self._name = new_value.to_string();
4092        self
4093    }
4094    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4095    /// while executing the actual API request.
4096    ///
4097    /// ````text
4098    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4099    /// ````
4100    ///
4101    /// Sets the *delegate* property to the given value.
4102    pub fn delegate(
4103        mut self,
4104        new_value: &'a mut dyn common::Delegate,
4105    ) -> ProjectLocationInstanceSnapshotGetCall<'a, C> {
4106        self._delegate = Some(new_value);
4107        self
4108    }
4109
4110    /// Set any additional parameter of the query string used in the request.
4111    /// It should be used to set parameters which are not yet available through their own
4112    /// setters.
4113    ///
4114    /// Please note that this method must not be used to set any of the known parameters
4115    /// which have their own setter method. If done anyway, the request will fail.
4116    ///
4117    /// # Additional Parameters
4118    ///
4119    /// * *$.xgafv* (query-string) - V1 error format.
4120    /// * *access_token* (query-string) - OAuth access token.
4121    /// * *alt* (query-string) - Data format for response.
4122    /// * *callback* (query-string) - JSONP
4123    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4124    /// * *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.
4125    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4126    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4127    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4128    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4129    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4130    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSnapshotGetCall<'a, C>
4131    where
4132        T: AsRef<str>,
4133    {
4134        self._additional_params
4135            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4136        self
4137    }
4138
4139    /// Identifies the authorization scope for the method you are building.
4140    ///
4141    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4142    /// [`Scope::CloudPlatform`].
4143    ///
4144    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4145    /// tokens for more than one scope.
4146    ///
4147    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4148    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4149    /// sufficient, a read-write scope will do as well.
4150    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceSnapshotGetCall<'a, C>
4151    where
4152        St: AsRef<str>,
4153    {
4154        self._scopes.insert(String::from(scope.as_ref()));
4155        self
4156    }
4157    /// Identifies the authorization scope(s) for the method you are building.
4158    ///
4159    /// See [`Self::add_scope()`] for details.
4160    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceSnapshotGetCall<'a, C>
4161    where
4162        I: IntoIterator<Item = St>,
4163        St: AsRef<str>,
4164    {
4165        self._scopes
4166            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4167        self
4168    }
4169
4170    /// Removes all scopes, and no default scope will be used either.
4171    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4172    /// for details).
4173    pub fn clear_scopes(mut self) -> ProjectLocationInstanceSnapshotGetCall<'a, C> {
4174        self._scopes.clear();
4175        self
4176    }
4177}
4178
4179/// Lists all snapshots in a project for either a specified location or for all locations.
4180///
4181/// A builder for the *locations.instances.snapshots.list* method supported by a *project* resource.
4182/// It is not used directly, but through a [`ProjectMethods`] instance.
4183///
4184/// # Example
4185///
4186/// Instantiate a resource method builder
4187///
4188/// ```test_harness,no_run
4189/// # extern crate hyper;
4190/// # extern crate hyper_rustls;
4191/// # extern crate google_file1 as file1;
4192/// # async fn dox() {
4193/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4194///
4195/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4196/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4197/// #     .with_native_roots()
4198/// #     .unwrap()
4199/// #     .https_only()
4200/// #     .enable_http2()
4201/// #     .build();
4202///
4203/// # let executor = hyper_util::rt::TokioExecutor::new();
4204/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4205/// #     secret,
4206/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4207/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4208/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4209/// #     ),
4210/// # ).build().await.unwrap();
4211///
4212/// # let client = hyper_util::client::legacy::Client::builder(
4213/// #     hyper_util::rt::TokioExecutor::new()
4214/// # )
4215/// # .build(
4216/// #     hyper_rustls::HttpsConnectorBuilder::new()
4217/// #         .with_native_roots()
4218/// #         .unwrap()
4219/// #         .https_or_http()
4220/// #         .enable_http2()
4221/// #         .build()
4222/// # );
4223/// # let mut hub = CloudFilestore::new(client, auth);
4224/// // You can configure optional parameters by calling the respective setters at will, and
4225/// // execute the final call using `doit()`.
4226/// // Values shown here are possibly random and not representative !
4227/// let result = hub.projects().locations_instances_snapshots_list("parent")
4228///              .return_partial_success(true)
4229///              .page_token("duo")
4230///              .page_size(-50)
4231///              .order_by("sed")
4232///              .filter("ut")
4233///              .doit().await;
4234/// # }
4235/// ```
4236pub struct ProjectLocationInstanceSnapshotListCall<'a, C>
4237where
4238    C: 'a,
4239{
4240    hub: &'a CloudFilestore<C>,
4241    _parent: String,
4242    _return_partial_success: Option<bool>,
4243    _page_token: Option<String>,
4244    _page_size: Option<i32>,
4245    _order_by: Option<String>,
4246    _filter: Option<String>,
4247    _delegate: Option<&'a mut dyn common::Delegate>,
4248    _additional_params: HashMap<String, String>,
4249    _scopes: BTreeSet<String>,
4250}
4251
4252impl<'a, C> common::CallBuilder for ProjectLocationInstanceSnapshotListCall<'a, C> {}
4253
4254impl<'a, C> ProjectLocationInstanceSnapshotListCall<'a, C>
4255where
4256    C: common::Connector,
4257{
4258    /// Perform the operation you have build so far.
4259    pub async fn doit(mut self) -> common::Result<(common::Response, ListSnapshotsResponse)> {
4260        use std::borrow::Cow;
4261        use std::io::{Read, Seek};
4262
4263        use common::{url::Params, ToParts};
4264        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4265
4266        let mut dd = common::DefaultDelegate;
4267        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4268        dlg.begin(common::MethodInfo {
4269            id: "file.projects.locations.instances.snapshots.list",
4270            http_method: hyper::Method::GET,
4271        });
4272
4273        for &field in [
4274            "alt",
4275            "parent",
4276            "returnPartialSuccess",
4277            "pageToken",
4278            "pageSize",
4279            "orderBy",
4280            "filter",
4281        ]
4282        .iter()
4283        {
4284            if self._additional_params.contains_key(field) {
4285                dlg.finished(false);
4286                return Err(common::Error::FieldClash(field));
4287            }
4288        }
4289
4290        let mut params = Params::with_capacity(8 + self._additional_params.len());
4291        params.push("parent", self._parent);
4292        if let Some(value) = self._return_partial_success.as_ref() {
4293            params.push("returnPartialSuccess", value.to_string());
4294        }
4295        if let Some(value) = self._page_token.as_ref() {
4296            params.push("pageToken", value);
4297        }
4298        if let Some(value) = self._page_size.as_ref() {
4299            params.push("pageSize", value.to_string());
4300        }
4301        if let Some(value) = self._order_by.as_ref() {
4302            params.push("orderBy", value);
4303        }
4304        if let Some(value) = self._filter.as_ref() {
4305            params.push("filter", value);
4306        }
4307
4308        params.extend(self._additional_params.iter());
4309
4310        params.push("alt", "json");
4311        let mut url = self.hub._base_url.clone() + "v1/{+parent}/snapshots";
4312        if self._scopes.is_empty() {
4313            self._scopes
4314                .insert(Scope::CloudPlatform.as_ref().to_string());
4315        }
4316
4317        #[allow(clippy::single_element_loop)]
4318        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4319            url = params.uri_replacement(url, param_name, find_this, true);
4320        }
4321        {
4322            let to_remove = ["parent"];
4323            params.remove_params(&to_remove);
4324        }
4325
4326        let url = params.parse_with_url(&url);
4327
4328        loop {
4329            let token = match self
4330                .hub
4331                .auth
4332                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4333                .await
4334            {
4335                Ok(token) => token,
4336                Err(e) => match dlg.token(e) {
4337                    Ok(token) => token,
4338                    Err(e) => {
4339                        dlg.finished(false);
4340                        return Err(common::Error::MissingToken(e));
4341                    }
4342                },
4343            };
4344            let mut req_result = {
4345                let client = &self.hub.client;
4346                dlg.pre_request();
4347                let mut req_builder = hyper::Request::builder()
4348                    .method(hyper::Method::GET)
4349                    .uri(url.as_str())
4350                    .header(USER_AGENT, self.hub._user_agent.clone());
4351
4352                if let Some(token) = token.as_ref() {
4353                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4354                }
4355
4356                let request = req_builder
4357                    .header(CONTENT_LENGTH, 0_u64)
4358                    .body(common::to_body::<String>(None));
4359
4360                client.request(request.unwrap()).await
4361            };
4362
4363            match req_result {
4364                Err(err) => {
4365                    if let common::Retry::After(d) = dlg.http_error(&err) {
4366                        sleep(d).await;
4367                        continue;
4368                    }
4369                    dlg.finished(false);
4370                    return Err(common::Error::HttpError(err));
4371                }
4372                Ok(res) => {
4373                    let (mut parts, body) = res.into_parts();
4374                    let mut body = common::Body::new(body);
4375                    if !parts.status.is_success() {
4376                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4377                        let error = serde_json::from_str(&common::to_string(&bytes));
4378                        let response = common::to_response(parts, bytes.into());
4379
4380                        if let common::Retry::After(d) =
4381                            dlg.http_failure(&response, error.as_ref().ok())
4382                        {
4383                            sleep(d).await;
4384                            continue;
4385                        }
4386
4387                        dlg.finished(false);
4388
4389                        return Err(match error {
4390                            Ok(value) => common::Error::BadRequest(value),
4391                            _ => common::Error::Failure(response),
4392                        });
4393                    }
4394                    let response = {
4395                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4396                        let encoded = common::to_string(&bytes);
4397                        match serde_json::from_str(&encoded) {
4398                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4399                            Err(error) => {
4400                                dlg.response_json_decode_error(&encoded, &error);
4401                                return Err(common::Error::JsonDecodeError(
4402                                    encoded.to_string(),
4403                                    error,
4404                                ));
4405                            }
4406                        }
4407                    };
4408
4409                    dlg.finished(true);
4410                    return Ok(response);
4411                }
4412            }
4413        }
4414    }
4415
4416    /// Required. The instance for which to retrieve snapshot information, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`.
4417    ///
4418    /// Sets the *parent* path property to the given value.
4419    ///
4420    /// Even though the property as already been set when instantiating this call,
4421    /// we provide this method for API completeness.
4422    pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotListCall<'a, C> {
4423        self._parent = new_value.to_string();
4424        self
4425    }
4426    /// Optional. If true, allow partial responses for multi-regional Aggregated List requests.
4427    ///
4428    /// Sets the *return partial success* query property to the given value.
4429    pub fn return_partial_success(
4430        mut self,
4431        new_value: bool,
4432    ) -> ProjectLocationInstanceSnapshotListCall<'a, C> {
4433        self._return_partial_success = Some(new_value);
4434        self
4435    }
4436    /// The next_page_token value to use if there are additional results to retrieve for this list request.
4437    ///
4438    /// Sets the *page token* query property to the given value.
4439    pub fn page_token(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotListCall<'a, C> {
4440        self._page_token = Some(new_value.to_string());
4441        self
4442    }
4443    /// The maximum number of items to return.
4444    ///
4445    /// Sets the *page size* query property to the given value.
4446    pub fn page_size(mut self, new_value: i32) -> ProjectLocationInstanceSnapshotListCall<'a, C> {
4447        self._page_size = Some(new_value);
4448        self
4449    }
4450    /// Sort results. Supported values are "name", "name desc" or "" (unsorted).
4451    ///
4452    /// Sets the *order by* query property to the given value.
4453    pub fn order_by(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotListCall<'a, C> {
4454        self._order_by = Some(new_value.to_string());
4455        self
4456    }
4457    /// List filter.
4458    ///
4459    /// Sets the *filter* query property to the given value.
4460    pub fn filter(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotListCall<'a, C> {
4461        self._filter = Some(new_value.to_string());
4462        self
4463    }
4464    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4465    /// while executing the actual API request.
4466    ///
4467    /// ````text
4468    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4469    /// ````
4470    ///
4471    /// Sets the *delegate* property to the given value.
4472    pub fn delegate(
4473        mut self,
4474        new_value: &'a mut dyn common::Delegate,
4475    ) -> ProjectLocationInstanceSnapshotListCall<'a, C> {
4476        self._delegate = Some(new_value);
4477        self
4478    }
4479
4480    /// Set any additional parameter of the query string used in the request.
4481    /// It should be used to set parameters which are not yet available through their own
4482    /// setters.
4483    ///
4484    /// Please note that this method must not be used to set any of the known parameters
4485    /// which have their own setter method. If done anyway, the request will fail.
4486    ///
4487    /// # Additional Parameters
4488    ///
4489    /// * *$.xgafv* (query-string) - V1 error format.
4490    /// * *access_token* (query-string) - OAuth access token.
4491    /// * *alt* (query-string) - Data format for response.
4492    /// * *callback* (query-string) - JSONP
4493    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4494    /// * *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.
4495    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4496    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4497    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4498    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4499    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4500    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSnapshotListCall<'a, C>
4501    where
4502        T: AsRef<str>,
4503    {
4504        self._additional_params
4505            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4506        self
4507    }
4508
4509    /// Identifies the authorization scope for the method you are building.
4510    ///
4511    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4512    /// [`Scope::CloudPlatform`].
4513    ///
4514    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4515    /// tokens for more than one scope.
4516    ///
4517    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4518    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4519    /// sufficient, a read-write scope will do as well.
4520    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceSnapshotListCall<'a, C>
4521    where
4522        St: AsRef<str>,
4523    {
4524        self._scopes.insert(String::from(scope.as_ref()));
4525        self
4526    }
4527    /// Identifies the authorization scope(s) for the method you are building.
4528    ///
4529    /// See [`Self::add_scope()`] for details.
4530    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceSnapshotListCall<'a, C>
4531    where
4532        I: IntoIterator<Item = St>,
4533        St: AsRef<str>,
4534    {
4535        self._scopes
4536            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4537        self
4538    }
4539
4540    /// Removes all scopes, and no default scope will be used either.
4541    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4542    /// for details).
4543    pub fn clear_scopes(mut self) -> ProjectLocationInstanceSnapshotListCall<'a, C> {
4544        self._scopes.clear();
4545        self
4546    }
4547}
4548
4549/// Updates the settings of a specific snapshot.
4550///
4551/// A builder for the *locations.instances.snapshots.patch* method supported by a *project* resource.
4552/// It is not used directly, but through a [`ProjectMethods`] instance.
4553///
4554/// # Example
4555///
4556/// Instantiate a resource method builder
4557///
4558/// ```test_harness,no_run
4559/// # extern crate hyper;
4560/// # extern crate hyper_rustls;
4561/// # extern crate google_file1 as file1;
4562/// use file1::api::Snapshot;
4563/// # async fn dox() {
4564/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4565///
4566/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4567/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4568/// #     .with_native_roots()
4569/// #     .unwrap()
4570/// #     .https_only()
4571/// #     .enable_http2()
4572/// #     .build();
4573///
4574/// # let executor = hyper_util::rt::TokioExecutor::new();
4575/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4576/// #     secret,
4577/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4578/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4579/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4580/// #     ),
4581/// # ).build().await.unwrap();
4582///
4583/// # let client = hyper_util::client::legacy::Client::builder(
4584/// #     hyper_util::rt::TokioExecutor::new()
4585/// # )
4586/// # .build(
4587/// #     hyper_rustls::HttpsConnectorBuilder::new()
4588/// #         .with_native_roots()
4589/// #         .unwrap()
4590/// #         .https_or_http()
4591/// #         .enable_http2()
4592/// #         .build()
4593/// # );
4594/// # let mut hub = CloudFilestore::new(client, auth);
4595/// // As the method needs a request, you would usually fill it with the desired information
4596/// // into the respective structure. Some of the parts shown here might not be applicable !
4597/// // Values shown here are possibly random and not representative !
4598/// let mut req = Snapshot::default();
4599///
4600/// // You can configure optional parameters by calling the respective setters at will, and
4601/// // execute the final call using `doit()`.
4602/// // Values shown here are possibly random and not representative !
4603/// let result = hub.projects().locations_instances_snapshots_patch(req, "name")
4604///              .update_mask(FieldMask::new::<&str>(&[]))
4605///              .doit().await;
4606/// # }
4607/// ```
4608pub struct ProjectLocationInstanceSnapshotPatchCall<'a, C>
4609where
4610    C: 'a,
4611{
4612    hub: &'a CloudFilestore<C>,
4613    _request: Snapshot,
4614    _name: String,
4615    _update_mask: Option<common::FieldMask>,
4616    _delegate: Option<&'a mut dyn common::Delegate>,
4617    _additional_params: HashMap<String, String>,
4618    _scopes: BTreeSet<String>,
4619}
4620
4621impl<'a, C> common::CallBuilder for ProjectLocationInstanceSnapshotPatchCall<'a, C> {}
4622
4623impl<'a, C> ProjectLocationInstanceSnapshotPatchCall<'a, C>
4624where
4625    C: common::Connector,
4626{
4627    /// Perform the operation you have build so far.
4628    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4629        use std::borrow::Cow;
4630        use std::io::{Read, Seek};
4631
4632        use common::{url::Params, ToParts};
4633        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4634
4635        let mut dd = common::DefaultDelegate;
4636        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4637        dlg.begin(common::MethodInfo {
4638            id: "file.projects.locations.instances.snapshots.patch",
4639            http_method: hyper::Method::PATCH,
4640        });
4641
4642        for &field in ["alt", "name", "updateMask"].iter() {
4643            if self._additional_params.contains_key(field) {
4644                dlg.finished(false);
4645                return Err(common::Error::FieldClash(field));
4646            }
4647        }
4648
4649        let mut params = Params::with_capacity(5 + self._additional_params.len());
4650        params.push("name", self._name);
4651        if let Some(value) = self._update_mask.as_ref() {
4652            params.push("updateMask", value.to_string());
4653        }
4654
4655        params.extend(self._additional_params.iter());
4656
4657        params.push("alt", "json");
4658        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4659        if self._scopes.is_empty() {
4660            self._scopes
4661                .insert(Scope::CloudPlatform.as_ref().to_string());
4662        }
4663
4664        #[allow(clippy::single_element_loop)]
4665        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4666            url = params.uri_replacement(url, param_name, find_this, true);
4667        }
4668        {
4669            let to_remove = ["name"];
4670            params.remove_params(&to_remove);
4671        }
4672
4673        let url = params.parse_with_url(&url);
4674
4675        let mut json_mime_type = mime::APPLICATION_JSON;
4676        let mut request_value_reader = {
4677            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4678            common::remove_json_null_values(&mut value);
4679            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4680            serde_json::to_writer(&mut dst, &value).unwrap();
4681            dst
4682        };
4683        let request_size = request_value_reader
4684            .seek(std::io::SeekFrom::End(0))
4685            .unwrap();
4686        request_value_reader
4687            .seek(std::io::SeekFrom::Start(0))
4688            .unwrap();
4689
4690        loop {
4691            let token = match self
4692                .hub
4693                .auth
4694                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4695                .await
4696            {
4697                Ok(token) => token,
4698                Err(e) => match dlg.token(e) {
4699                    Ok(token) => token,
4700                    Err(e) => {
4701                        dlg.finished(false);
4702                        return Err(common::Error::MissingToken(e));
4703                    }
4704                },
4705            };
4706            request_value_reader
4707                .seek(std::io::SeekFrom::Start(0))
4708                .unwrap();
4709            let mut req_result = {
4710                let client = &self.hub.client;
4711                dlg.pre_request();
4712                let mut req_builder = hyper::Request::builder()
4713                    .method(hyper::Method::PATCH)
4714                    .uri(url.as_str())
4715                    .header(USER_AGENT, self.hub._user_agent.clone());
4716
4717                if let Some(token) = token.as_ref() {
4718                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4719                }
4720
4721                let request = req_builder
4722                    .header(CONTENT_TYPE, json_mime_type.to_string())
4723                    .header(CONTENT_LENGTH, request_size as u64)
4724                    .body(common::to_body(
4725                        request_value_reader.get_ref().clone().into(),
4726                    ));
4727
4728                client.request(request.unwrap()).await
4729            };
4730
4731            match req_result {
4732                Err(err) => {
4733                    if let common::Retry::After(d) = dlg.http_error(&err) {
4734                        sleep(d).await;
4735                        continue;
4736                    }
4737                    dlg.finished(false);
4738                    return Err(common::Error::HttpError(err));
4739                }
4740                Ok(res) => {
4741                    let (mut parts, body) = res.into_parts();
4742                    let mut body = common::Body::new(body);
4743                    if !parts.status.is_success() {
4744                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4745                        let error = serde_json::from_str(&common::to_string(&bytes));
4746                        let response = common::to_response(parts, bytes.into());
4747
4748                        if let common::Retry::After(d) =
4749                            dlg.http_failure(&response, error.as_ref().ok())
4750                        {
4751                            sleep(d).await;
4752                            continue;
4753                        }
4754
4755                        dlg.finished(false);
4756
4757                        return Err(match error {
4758                            Ok(value) => common::Error::BadRequest(value),
4759                            _ => common::Error::Failure(response),
4760                        });
4761                    }
4762                    let response = {
4763                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4764                        let encoded = common::to_string(&bytes);
4765                        match serde_json::from_str(&encoded) {
4766                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4767                            Err(error) => {
4768                                dlg.response_json_decode_error(&encoded, &error);
4769                                return Err(common::Error::JsonDecodeError(
4770                                    encoded.to_string(),
4771                                    error,
4772                                ));
4773                            }
4774                        }
4775                    };
4776
4777                    dlg.finished(true);
4778                    return Ok(response);
4779                }
4780            }
4781        }
4782    }
4783
4784    ///
4785    /// Sets the *request* property to the given value.
4786    ///
4787    /// Even though the property as already been set when instantiating this call,
4788    /// we provide this method for API completeness.
4789    pub fn request(
4790        mut self,
4791        new_value: Snapshot,
4792    ) -> ProjectLocationInstanceSnapshotPatchCall<'a, C> {
4793        self._request = new_value;
4794        self
4795    }
4796    /// Output only. The resource name of the snapshot, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}/snapshots/{snapshot_id}`.
4797    ///
4798    /// Sets the *name* path property to the given value.
4799    ///
4800    /// Even though the property as already been set when instantiating this call,
4801    /// we provide this method for API completeness.
4802    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotPatchCall<'a, C> {
4803        self._name = new_value.to_string();
4804        self
4805    }
4806    /// Required. Mask of fields to update. At least one path must be supplied in this field.
4807    ///
4808    /// Sets the *update mask* query property to the given value.
4809    pub fn update_mask(
4810        mut self,
4811        new_value: common::FieldMask,
4812    ) -> ProjectLocationInstanceSnapshotPatchCall<'a, C> {
4813        self._update_mask = Some(new_value);
4814        self
4815    }
4816    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4817    /// while executing the actual API request.
4818    ///
4819    /// ````text
4820    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4821    /// ````
4822    ///
4823    /// Sets the *delegate* property to the given value.
4824    pub fn delegate(
4825        mut self,
4826        new_value: &'a mut dyn common::Delegate,
4827    ) -> ProjectLocationInstanceSnapshotPatchCall<'a, C> {
4828        self._delegate = Some(new_value);
4829        self
4830    }
4831
4832    /// Set any additional parameter of the query string used in the request.
4833    /// It should be used to set parameters which are not yet available through their own
4834    /// setters.
4835    ///
4836    /// Please note that this method must not be used to set any of the known parameters
4837    /// which have their own setter method. If done anyway, the request will fail.
4838    ///
4839    /// # Additional Parameters
4840    ///
4841    /// * *$.xgafv* (query-string) - V1 error format.
4842    /// * *access_token* (query-string) - OAuth access token.
4843    /// * *alt* (query-string) - Data format for response.
4844    /// * *callback* (query-string) - JSONP
4845    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4846    /// * *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.
4847    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4848    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4849    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4850    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4851    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4852    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSnapshotPatchCall<'a, C>
4853    where
4854        T: AsRef<str>,
4855    {
4856        self._additional_params
4857            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4858        self
4859    }
4860
4861    /// Identifies the authorization scope for the method you are building.
4862    ///
4863    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4864    /// [`Scope::CloudPlatform`].
4865    ///
4866    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4867    /// tokens for more than one scope.
4868    ///
4869    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4870    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4871    /// sufficient, a read-write scope will do as well.
4872    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceSnapshotPatchCall<'a, C>
4873    where
4874        St: AsRef<str>,
4875    {
4876        self._scopes.insert(String::from(scope.as_ref()));
4877        self
4878    }
4879    /// Identifies the authorization scope(s) for the method you are building.
4880    ///
4881    /// See [`Self::add_scope()`] for details.
4882    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceSnapshotPatchCall<'a, C>
4883    where
4884        I: IntoIterator<Item = St>,
4885        St: AsRef<str>,
4886    {
4887        self._scopes
4888            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4889        self
4890    }
4891
4892    /// Removes all scopes, and no default scope will be used either.
4893    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4894    /// for details).
4895    pub fn clear_scopes(mut self) -> ProjectLocationInstanceSnapshotPatchCall<'a, C> {
4896        self._scopes.clear();
4897        self
4898    }
4899}
4900
4901/// Creates an instance. When creating from a backup, the capacity of the new instance needs to be equal to or larger than the capacity of the backup (and also equal to or larger than the minimum capacity of the tier).
4902///
4903/// A builder for the *locations.instances.create* method supported by a *project* resource.
4904/// It is not used directly, but through a [`ProjectMethods`] instance.
4905///
4906/// # Example
4907///
4908/// Instantiate a resource method builder
4909///
4910/// ```test_harness,no_run
4911/// # extern crate hyper;
4912/// # extern crate hyper_rustls;
4913/// # extern crate google_file1 as file1;
4914/// use file1::api::Instance;
4915/// # async fn dox() {
4916/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4917///
4918/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4919/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4920/// #     .with_native_roots()
4921/// #     .unwrap()
4922/// #     .https_only()
4923/// #     .enable_http2()
4924/// #     .build();
4925///
4926/// # let executor = hyper_util::rt::TokioExecutor::new();
4927/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4928/// #     secret,
4929/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4930/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4931/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4932/// #     ),
4933/// # ).build().await.unwrap();
4934///
4935/// # let client = hyper_util::client::legacy::Client::builder(
4936/// #     hyper_util::rt::TokioExecutor::new()
4937/// # )
4938/// # .build(
4939/// #     hyper_rustls::HttpsConnectorBuilder::new()
4940/// #         .with_native_roots()
4941/// #         .unwrap()
4942/// #         .https_or_http()
4943/// #         .enable_http2()
4944/// #         .build()
4945/// # );
4946/// # let mut hub = CloudFilestore::new(client, auth);
4947/// // As the method needs a request, you would usually fill it with the desired information
4948/// // into the respective structure. Some of the parts shown here might not be applicable !
4949/// // Values shown here are possibly random and not representative !
4950/// let mut req = Instance::default();
4951///
4952/// // You can configure optional parameters by calling the respective setters at will, and
4953/// // execute the final call using `doit()`.
4954/// // Values shown here are possibly random and not representative !
4955/// let result = hub.projects().locations_instances_create(req, "parent")
4956///              .instance_id("est")
4957///              .doit().await;
4958/// # }
4959/// ```
4960pub struct ProjectLocationInstanceCreateCall<'a, C>
4961where
4962    C: 'a,
4963{
4964    hub: &'a CloudFilestore<C>,
4965    _request: Instance,
4966    _parent: String,
4967    _instance_id: Option<String>,
4968    _delegate: Option<&'a mut dyn common::Delegate>,
4969    _additional_params: HashMap<String, String>,
4970    _scopes: BTreeSet<String>,
4971}
4972
4973impl<'a, C> common::CallBuilder for ProjectLocationInstanceCreateCall<'a, C> {}
4974
4975impl<'a, C> ProjectLocationInstanceCreateCall<'a, C>
4976where
4977    C: common::Connector,
4978{
4979    /// Perform the operation you have build so far.
4980    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4981        use std::borrow::Cow;
4982        use std::io::{Read, Seek};
4983
4984        use common::{url::Params, ToParts};
4985        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4986
4987        let mut dd = common::DefaultDelegate;
4988        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4989        dlg.begin(common::MethodInfo {
4990            id: "file.projects.locations.instances.create",
4991            http_method: hyper::Method::POST,
4992        });
4993
4994        for &field in ["alt", "parent", "instanceId"].iter() {
4995            if self._additional_params.contains_key(field) {
4996                dlg.finished(false);
4997                return Err(common::Error::FieldClash(field));
4998            }
4999        }
5000
5001        let mut params = Params::with_capacity(5 + self._additional_params.len());
5002        params.push("parent", self._parent);
5003        if let Some(value) = self._instance_id.as_ref() {
5004            params.push("instanceId", value);
5005        }
5006
5007        params.extend(self._additional_params.iter());
5008
5009        params.push("alt", "json");
5010        let mut url = self.hub._base_url.clone() + "v1/{+parent}/instances";
5011        if self._scopes.is_empty() {
5012            self._scopes
5013                .insert(Scope::CloudPlatform.as_ref().to_string());
5014        }
5015
5016        #[allow(clippy::single_element_loop)]
5017        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5018            url = params.uri_replacement(url, param_name, find_this, true);
5019        }
5020        {
5021            let to_remove = ["parent"];
5022            params.remove_params(&to_remove);
5023        }
5024
5025        let url = params.parse_with_url(&url);
5026
5027        let mut json_mime_type = mime::APPLICATION_JSON;
5028        let mut request_value_reader = {
5029            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5030            common::remove_json_null_values(&mut value);
5031            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5032            serde_json::to_writer(&mut dst, &value).unwrap();
5033            dst
5034        };
5035        let request_size = request_value_reader
5036            .seek(std::io::SeekFrom::End(0))
5037            .unwrap();
5038        request_value_reader
5039            .seek(std::io::SeekFrom::Start(0))
5040            .unwrap();
5041
5042        loop {
5043            let token = match self
5044                .hub
5045                .auth
5046                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5047                .await
5048            {
5049                Ok(token) => token,
5050                Err(e) => match dlg.token(e) {
5051                    Ok(token) => token,
5052                    Err(e) => {
5053                        dlg.finished(false);
5054                        return Err(common::Error::MissingToken(e));
5055                    }
5056                },
5057            };
5058            request_value_reader
5059                .seek(std::io::SeekFrom::Start(0))
5060                .unwrap();
5061            let mut req_result = {
5062                let client = &self.hub.client;
5063                dlg.pre_request();
5064                let mut req_builder = hyper::Request::builder()
5065                    .method(hyper::Method::POST)
5066                    .uri(url.as_str())
5067                    .header(USER_AGENT, self.hub._user_agent.clone());
5068
5069                if let Some(token) = token.as_ref() {
5070                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5071                }
5072
5073                let request = req_builder
5074                    .header(CONTENT_TYPE, json_mime_type.to_string())
5075                    .header(CONTENT_LENGTH, request_size as u64)
5076                    .body(common::to_body(
5077                        request_value_reader.get_ref().clone().into(),
5078                    ));
5079
5080                client.request(request.unwrap()).await
5081            };
5082
5083            match req_result {
5084                Err(err) => {
5085                    if let common::Retry::After(d) = dlg.http_error(&err) {
5086                        sleep(d).await;
5087                        continue;
5088                    }
5089                    dlg.finished(false);
5090                    return Err(common::Error::HttpError(err));
5091                }
5092                Ok(res) => {
5093                    let (mut parts, body) = res.into_parts();
5094                    let mut body = common::Body::new(body);
5095                    if !parts.status.is_success() {
5096                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5097                        let error = serde_json::from_str(&common::to_string(&bytes));
5098                        let response = common::to_response(parts, bytes.into());
5099
5100                        if let common::Retry::After(d) =
5101                            dlg.http_failure(&response, error.as_ref().ok())
5102                        {
5103                            sleep(d).await;
5104                            continue;
5105                        }
5106
5107                        dlg.finished(false);
5108
5109                        return Err(match error {
5110                            Ok(value) => common::Error::BadRequest(value),
5111                            _ => common::Error::Failure(response),
5112                        });
5113                    }
5114                    let response = {
5115                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5116                        let encoded = common::to_string(&bytes);
5117                        match serde_json::from_str(&encoded) {
5118                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5119                            Err(error) => {
5120                                dlg.response_json_decode_error(&encoded, &error);
5121                                return Err(common::Error::JsonDecodeError(
5122                                    encoded.to_string(),
5123                                    error,
5124                                ));
5125                            }
5126                        }
5127                    };
5128
5129                    dlg.finished(true);
5130                    return Ok(response);
5131                }
5132            }
5133        }
5134    }
5135
5136    ///
5137    /// Sets the *request* property to the given value.
5138    ///
5139    /// Even though the property as already been set when instantiating this call,
5140    /// we provide this method for API completeness.
5141    pub fn request(mut self, new_value: Instance) -> ProjectLocationInstanceCreateCall<'a, C> {
5142        self._request = new_value;
5143        self
5144    }
5145    /// Required. The instance's project and location, in the format `projects/{project_id}/locations/{location}`. In Filestore, locations map to Google Cloud zones, for example **us-west1-b**.
5146    ///
5147    /// Sets the *parent* path property to the given value.
5148    ///
5149    /// Even though the property as already been set when instantiating this call,
5150    /// we provide this method for API completeness.
5151    pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceCreateCall<'a, C> {
5152        self._parent = new_value.to_string();
5153        self
5154    }
5155    /// Required. The name of the instance to create. The name must be unique for the specified project and location.
5156    ///
5157    /// Sets the *instance id* query property to the given value.
5158    pub fn instance_id(mut self, new_value: &str) -> ProjectLocationInstanceCreateCall<'a, C> {
5159        self._instance_id = Some(new_value.to_string());
5160        self
5161    }
5162    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5163    /// while executing the actual API request.
5164    ///
5165    /// ````text
5166    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5167    /// ````
5168    ///
5169    /// Sets the *delegate* property to the given value.
5170    pub fn delegate(
5171        mut self,
5172        new_value: &'a mut dyn common::Delegate,
5173    ) -> ProjectLocationInstanceCreateCall<'a, C> {
5174        self._delegate = Some(new_value);
5175        self
5176    }
5177
5178    /// Set any additional parameter of the query string used in the request.
5179    /// It should be used to set parameters which are not yet available through their own
5180    /// setters.
5181    ///
5182    /// Please note that this method must not be used to set any of the known parameters
5183    /// which have their own setter method. If done anyway, the request will fail.
5184    ///
5185    /// # Additional Parameters
5186    ///
5187    /// * *$.xgafv* (query-string) - V1 error format.
5188    /// * *access_token* (query-string) - OAuth access token.
5189    /// * *alt* (query-string) - Data format for response.
5190    /// * *callback* (query-string) - JSONP
5191    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5192    /// * *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.
5193    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5194    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5195    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5196    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5197    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5198    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceCreateCall<'a, C>
5199    where
5200        T: AsRef<str>,
5201    {
5202        self._additional_params
5203            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5204        self
5205    }
5206
5207    /// Identifies the authorization scope for the method you are building.
5208    ///
5209    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5210    /// [`Scope::CloudPlatform`].
5211    ///
5212    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5213    /// tokens for more than one scope.
5214    ///
5215    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5216    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5217    /// sufficient, a read-write scope will do as well.
5218    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceCreateCall<'a, C>
5219    where
5220        St: AsRef<str>,
5221    {
5222        self._scopes.insert(String::from(scope.as_ref()));
5223        self
5224    }
5225    /// Identifies the authorization scope(s) for the method you are building.
5226    ///
5227    /// See [`Self::add_scope()`] for details.
5228    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceCreateCall<'a, C>
5229    where
5230        I: IntoIterator<Item = St>,
5231        St: AsRef<str>,
5232    {
5233        self._scopes
5234            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5235        self
5236    }
5237
5238    /// Removes all scopes, and no default scope will be used either.
5239    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5240    /// for details).
5241    pub fn clear_scopes(mut self) -> ProjectLocationInstanceCreateCall<'a, C> {
5242        self._scopes.clear();
5243        self
5244    }
5245}
5246
5247/// Deletes an instance.
5248///
5249/// A builder for the *locations.instances.delete* method supported by a *project* resource.
5250/// It is not used directly, but through a [`ProjectMethods`] instance.
5251///
5252/// # Example
5253///
5254/// Instantiate a resource method builder
5255///
5256/// ```test_harness,no_run
5257/// # extern crate hyper;
5258/// # extern crate hyper_rustls;
5259/// # extern crate google_file1 as file1;
5260/// # async fn dox() {
5261/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5262///
5263/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5264/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5265/// #     .with_native_roots()
5266/// #     .unwrap()
5267/// #     .https_only()
5268/// #     .enable_http2()
5269/// #     .build();
5270///
5271/// # let executor = hyper_util::rt::TokioExecutor::new();
5272/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5273/// #     secret,
5274/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5275/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5276/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5277/// #     ),
5278/// # ).build().await.unwrap();
5279///
5280/// # let client = hyper_util::client::legacy::Client::builder(
5281/// #     hyper_util::rt::TokioExecutor::new()
5282/// # )
5283/// # .build(
5284/// #     hyper_rustls::HttpsConnectorBuilder::new()
5285/// #         .with_native_roots()
5286/// #         .unwrap()
5287/// #         .https_or_http()
5288/// #         .enable_http2()
5289/// #         .build()
5290/// # );
5291/// # let mut hub = CloudFilestore::new(client, auth);
5292/// // You can configure optional parameters by calling the respective setters at will, and
5293/// // execute the final call using `doit()`.
5294/// // Values shown here are possibly random and not representative !
5295/// let result = hub.projects().locations_instances_delete("name")
5296///              .force(true)
5297///              .doit().await;
5298/// # }
5299/// ```
5300pub struct ProjectLocationInstanceDeleteCall<'a, C>
5301where
5302    C: 'a,
5303{
5304    hub: &'a CloudFilestore<C>,
5305    _name: String,
5306    _force: Option<bool>,
5307    _delegate: Option<&'a mut dyn common::Delegate>,
5308    _additional_params: HashMap<String, String>,
5309    _scopes: BTreeSet<String>,
5310}
5311
5312impl<'a, C> common::CallBuilder for ProjectLocationInstanceDeleteCall<'a, C> {}
5313
5314impl<'a, C> ProjectLocationInstanceDeleteCall<'a, C>
5315where
5316    C: common::Connector,
5317{
5318    /// Perform the operation you have build so far.
5319    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5320        use std::borrow::Cow;
5321        use std::io::{Read, Seek};
5322
5323        use common::{url::Params, ToParts};
5324        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5325
5326        let mut dd = common::DefaultDelegate;
5327        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5328        dlg.begin(common::MethodInfo {
5329            id: "file.projects.locations.instances.delete",
5330            http_method: hyper::Method::DELETE,
5331        });
5332
5333        for &field in ["alt", "name", "force"].iter() {
5334            if self._additional_params.contains_key(field) {
5335                dlg.finished(false);
5336                return Err(common::Error::FieldClash(field));
5337            }
5338        }
5339
5340        let mut params = Params::with_capacity(4 + self._additional_params.len());
5341        params.push("name", self._name);
5342        if let Some(value) = self._force.as_ref() {
5343            params.push("force", value.to_string());
5344        }
5345
5346        params.extend(self._additional_params.iter());
5347
5348        params.push("alt", "json");
5349        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5350        if self._scopes.is_empty() {
5351            self._scopes
5352                .insert(Scope::CloudPlatform.as_ref().to_string());
5353        }
5354
5355        #[allow(clippy::single_element_loop)]
5356        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5357            url = params.uri_replacement(url, param_name, find_this, true);
5358        }
5359        {
5360            let to_remove = ["name"];
5361            params.remove_params(&to_remove);
5362        }
5363
5364        let url = params.parse_with_url(&url);
5365
5366        loop {
5367            let token = match self
5368                .hub
5369                .auth
5370                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5371                .await
5372            {
5373                Ok(token) => token,
5374                Err(e) => match dlg.token(e) {
5375                    Ok(token) => token,
5376                    Err(e) => {
5377                        dlg.finished(false);
5378                        return Err(common::Error::MissingToken(e));
5379                    }
5380                },
5381            };
5382            let mut req_result = {
5383                let client = &self.hub.client;
5384                dlg.pre_request();
5385                let mut req_builder = hyper::Request::builder()
5386                    .method(hyper::Method::DELETE)
5387                    .uri(url.as_str())
5388                    .header(USER_AGENT, self.hub._user_agent.clone());
5389
5390                if let Some(token) = token.as_ref() {
5391                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5392                }
5393
5394                let request = req_builder
5395                    .header(CONTENT_LENGTH, 0_u64)
5396                    .body(common::to_body::<String>(None));
5397
5398                client.request(request.unwrap()).await
5399            };
5400
5401            match req_result {
5402                Err(err) => {
5403                    if let common::Retry::After(d) = dlg.http_error(&err) {
5404                        sleep(d).await;
5405                        continue;
5406                    }
5407                    dlg.finished(false);
5408                    return Err(common::Error::HttpError(err));
5409                }
5410                Ok(res) => {
5411                    let (mut parts, body) = res.into_parts();
5412                    let mut body = common::Body::new(body);
5413                    if !parts.status.is_success() {
5414                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5415                        let error = serde_json::from_str(&common::to_string(&bytes));
5416                        let response = common::to_response(parts, bytes.into());
5417
5418                        if let common::Retry::After(d) =
5419                            dlg.http_failure(&response, error.as_ref().ok())
5420                        {
5421                            sleep(d).await;
5422                            continue;
5423                        }
5424
5425                        dlg.finished(false);
5426
5427                        return Err(match error {
5428                            Ok(value) => common::Error::BadRequest(value),
5429                            _ => common::Error::Failure(response),
5430                        });
5431                    }
5432                    let response = {
5433                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5434                        let encoded = common::to_string(&bytes);
5435                        match serde_json::from_str(&encoded) {
5436                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5437                            Err(error) => {
5438                                dlg.response_json_decode_error(&encoded, &error);
5439                                return Err(common::Error::JsonDecodeError(
5440                                    encoded.to_string(),
5441                                    error,
5442                                ));
5443                            }
5444                        }
5445                    };
5446
5447                    dlg.finished(true);
5448                    return Ok(response);
5449                }
5450            }
5451        }
5452    }
5453
5454    /// Required. The instance resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`
5455    ///
5456    /// Sets the *name* path property to the given value.
5457    ///
5458    /// Even though the property as already been set when instantiating this call,
5459    /// we provide this method for API completeness.
5460    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceDeleteCall<'a, C> {
5461        self._name = new_value.to_string();
5462        self
5463    }
5464    /// If set to true, all snapshots of the instance will also be deleted. (Otherwise, the request will only work if the instance has no snapshots.)
5465    ///
5466    /// Sets the *force* query property to the given value.
5467    pub fn force(mut self, new_value: bool) -> ProjectLocationInstanceDeleteCall<'a, C> {
5468        self._force = Some(new_value);
5469        self
5470    }
5471    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5472    /// while executing the actual API request.
5473    ///
5474    /// ````text
5475    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5476    /// ````
5477    ///
5478    /// Sets the *delegate* property to the given value.
5479    pub fn delegate(
5480        mut self,
5481        new_value: &'a mut dyn common::Delegate,
5482    ) -> ProjectLocationInstanceDeleteCall<'a, C> {
5483        self._delegate = Some(new_value);
5484        self
5485    }
5486
5487    /// Set any additional parameter of the query string used in the request.
5488    /// It should be used to set parameters which are not yet available through their own
5489    /// setters.
5490    ///
5491    /// Please note that this method must not be used to set any of the known parameters
5492    /// which have their own setter method. If done anyway, the request will fail.
5493    ///
5494    /// # Additional Parameters
5495    ///
5496    /// * *$.xgafv* (query-string) - V1 error format.
5497    /// * *access_token* (query-string) - OAuth access token.
5498    /// * *alt* (query-string) - Data format for response.
5499    /// * *callback* (query-string) - JSONP
5500    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5501    /// * *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.
5502    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5503    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5504    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5505    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5506    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5507    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceDeleteCall<'a, C>
5508    where
5509        T: AsRef<str>,
5510    {
5511        self._additional_params
5512            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5513        self
5514    }
5515
5516    /// Identifies the authorization scope for the method you are building.
5517    ///
5518    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5519    /// [`Scope::CloudPlatform`].
5520    ///
5521    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5522    /// tokens for more than one scope.
5523    ///
5524    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5525    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5526    /// sufficient, a read-write scope will do as well.
5527    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceDeleteCall<'a, C>
5528    where
5529        St: AsRef<str>,
5530    {
5531        self._scopes.insert(String::from(scope.as_ref()));
5532        self
5533    }
5534    /// Identifies the authorization scope(s) for the method you are building.
5535    ///
5536    /// See [`Self::add_scope()`] for details.
5537    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceDeleteCall<'a, C>
5538    where
5539        I: IntoIterator<Item = St>,
5540        St: AsRef<str>,
5541    {
5542        self._scopes
5543            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5544        self
5545    }
5546
5547    /// Removes all scopes, and no default scope will be used either.
5548    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5549    /// for details).
5550    pub fn clear_scopes(mut self) -> ProjectLocationInstanceDeleteCall<'a, C> {
5551        self._scopes.clear();
5552        self
5553    }
5554}
5555
5556/// Gets the details of a specific instance.
5557///
5558/// A builder for the *locations.instances.get* method supported by a *project* resource.
5559/// It is not used directly, but through a [`ProjectMethods`] instance.
5560///
5561/// # Example
5562///
5563/// Instantiate a resource method builder
5564///
5565/// ```test_harness,no_run
5566/// # extern crate hyper;
5567/// # extern crate hyper_rustls;
5568/// # extern crate google_file1 as file1;
5569/// # async fn dox() {
5570/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5571///
5572/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5573/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5574/// #     .with_native_roots()
5575/// #     .unwrap()
5576/// #     .https_only()
5577/// #     .enable_http2()
5578/// #     .build();
5579///
5580/// # let executor = hyper_util::rt::TokioExecutor::new();
5581/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5582/// #     secret,
5583/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5584/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5585/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5586/// #     ),
5587/// # ).build().await.unwrap();
5588///
5589/// # let client = hyper_util::client::legacy::Client::builder(
5590/// #     hyper_util::rt::TokioExecutor::new()
5591/// # )
5592/// # .build(
5593/// #     hyper_rustls::HttpsConnectorBuilder::new()
5594/// #         .with_native_roots()
5595/// #         .unwrap()
5596/// #         .https_or_http()
5597/// #         .enable_http2()
5598/// #         .build()
5599/// # );
5600/// # let mut hub = CloudFilestore::new(client, auth);
5601/// // You can configure optional parameters by calling the respective setters at will, and
5602/// // execute the final call using `doit()`.
5603/// // Values shown here are possibly random and not representative !
5604/// let result = hub.projects().locations_instances_get("name")
5605///              .doit().await;
5606/// # }
5607/// ```
5608pub struct ProjectLocationInstanceGetCall<'a, C>
5609where
5610    C: 'a,
5611{
5612    hub: &'a CloudFilestore<C>,
5613    _name: String,
5614    _delegate: Option<&'a mut dyn common::Delegate>,
5615    _additional_params: HashMap<String, String>,
5616    _scopes: BTreeSet<String>,
5617}
5618
5619impl<'a, C> common::CallBuilder for ProjectLocationInstanceGetCall<'a, C> {}
5620
5621impl<'a, C> ProjectLocationInstanceGetCall<'a, C>
5622where
5623    C: common::Connector,
5624{
5625    /// Perform the operation you have build so far.
5626    pub async fn doit(mut self) -> common::Result<(common::Response, Instance)> {
5627        use std::borrow::Cow;
5628        use std::io::{Read, Seek};
5629
5630        use common::{url::Params, ToParts};
5631        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5632
5633        let mut dd = common::DefaultDelegate;
5634        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5635        dlg.begin(common::MethodInfo {
5636            id: "file.projects.locations.instances.get",
5637            http_method: hyper::Method::GET,
5638        });
5639
5640        for &field in ["alt", "name"].iter() {
5641            if self._additional_params.contains_key(field) {
5642                dlg.finished(false);
5643                return Err(common::Error::FieldClash(field));
5644            }
5645        }
5646
5647        let mut params = Params::with_capacity(3 + self._additional_params.len());
5648        params.push("name", self._name);
5649
5650        params.extend(self._additional_params.iter());
5651
5652        params.push("alt", "json");
5653        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5654        if self._scopes.is_empty() {
5655            self._scopes
5656                .insert(Scope::CloudPlatform.as_ref().to_string());
5657        }
5658
5659        #[allow(clippy::single_element_loop)]
5660        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5661            url = params.uri_replacement(url, param_name, find_this, true);
5662        }
5663        {
5664            let to_remove = ["name"];
5665            params.remove_params(&to_remove);
5666        }
5667
5668        let url = params.parse_with_url(&url);
5669
5670        loop {
5671            let token = match self
5672                .hub
5673                .auth
5674                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5675                .await
5676            {
5677                Ok(token) => token,
5678                Err(e) => match dlg.token(e) {
5679                    Ok(token) => token,
5680                    Err(e) => {
5681                        dlg.finished(false);
5682                        return Err(common::Error::MissingToken(e));
5683                    }
5684                },
5685            };
5686            let mut req_result = {
5687                let client = &self.hub.client;
5688                dlg.pre_request();
5689                let mut req_builder = hyper::Request::builder()
5690                    .method(hyper::Method::GET)
5691                    .uri(url.as_str())
5692                    .header(USER_AGENT, self.hub._user_agent.clone());
5693
5694                if let Some(token) = token.as_ref() {
5695                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5696                }
5697
5698                let request = req_builder
5699                    .header(CONTENT_LENGTH, 0_u64)
5700                    .body(common::to_body::<String>(None));
5701
5702                client.request(request.unwrap()).await
5703            };
5704
5705            match req_result {
5706                Err(err) => {
5707                    if let common::Retry::After(d) = dlg.http_error(&err) {
5708                        sleep(d).await;
5709                        continue;
5710                    }
5711                    dlg.finished(false);
5712                    return Err(common::Error::HttpError(err));
5713                }
5714                Ok(res) => {
5715                    let (mut parts, body) = res.into_parts();
5716                    let mut body = common::Body::new(body);
5717                    if !parts.status.is_success() {
5718                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5719                        let error = serde_json::from_str(&common::to_string(&bytes));
5720                        let response = common::to_response(parts, bytes.into());
5721
5722                        if let common::Retry::After(d) =
5723                            dlg.http_failure(&response, error.as_ref().ok())
5724                        {
5725                            sleep(d).await;
5726                            continue;
5727                        }
5728
5729                        dlg.finished(false);
5730
5731                        return Err(match error {
5732                            Ok(value) => common::Error::BadRequest(value),
5733                            _ => common::Error::Failure(response),
5734                        });
5735                    }
5736                    let response = {
5737                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5738                        let encoded = common::to_string(&bytes);
5739                        match serde_json::from_str(&encoded) {
5740                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5741                            Err(error) => {
5742                                dlg.response_json_decode_error(&encoded, &error);
5743                                return Err(common::Error::JsonDecodeError(
5744                                    encoded.to_string(),
5745                                    error,
5746                                ));
5747                            }
5748                        }
5749                    };
5750
5751                    dlg.finished(true);
5752                    return Ok(response);
5753                }
5754            }
5755        }
5756    }
5757
5758    /// Required. The instance resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`.
5759    ///
5760    /// Sets the *name* path property to the given value.
5761    ///
5762    /// Even though the property as already been set when instantiating this call,
5763    /// we provide this method for API completeness.
5764    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceGetCall<'a, C> {
5765        self._name = new_value.to_string();
5766        self
5767    }
5768    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5769    /// while executing the actual API request.
5770    ///
5771    /// ````text
5772    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5773    /// ````
5774    ///
5775    /// Sets the *delegate* property to the given value.
5776    pub fn delegate(
5777        mut self,
5778        new_value: &'a mut dyn common::Delegate,
5779    ) -> ProjectLocationInstanceGetCall<'a, C> {
5780        self._delegate = Some(new_value);
5781        self
5782    }
5783
5784    /// Set any additional parameter of the query string used in the request.
5785    /// It should be used to set parameters which are not yet available through their own
5786    /// setters.
5787    ///
5788    /// Please note that this method must not be used to set any of the known parameters
5789    /// which have their own setter method. If done anyway, the request will fail.
5790    ///
5791    /// # Additional Parameters
5792    ///
5793    /// * *$.xgafv* (query-string) - V1 error format.
5794    /// * *access_token* (query-string) - OAuth access token.
5795    /// * *alt* (query-string) - Data format for response.
5796    /// * *callback* (query-string) - JSONP
5797    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5798    /// * *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.
5799    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5800    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5801    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5802    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5803    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5804    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceGetCall<'a, C>
5805    where
5806        T: AsRef<str>,
5807    {
5808        self._additional_params
5809            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5810        self
5811    }
5812
5813    /// Identifies the authorization scope for the method you are building.
5814    ///
5815    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5816    /// [`Scope::CloudPlatform`].
5817    ///
5818    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5819    /// tokens for more than one scope.
5820    ///
5821    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5822    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5823    /// sufficient, a read-write scope will do as well.
5824    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceGetCall<'a, C>
5825    where
5826        St: AsRef<str>,
5827    {
5828        self._scopes.insert(String::from(scope.as_ref()));
5829        self
5830    }
5831    /// Identifies the authorization scope(s) for the method you are building.
5832    ///
5833    /// See [`Self::add_scope()`] for details.
5834    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceGetCall<'a, C>
5835    where
5836        I: IntoIterator<Item = St>,
5837        St: AsRef<str>,
5838    {
5839        self._scopes
5840            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5841        self
5842    }
5843
5844    /// Removes all scopes, and no default scope will be used either.
5845    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5846    /// for details).
5847    pub fn clear_scopes(mut self) -> ProjectLocationInstanceGetCall<'a, C> {
5848        self._scopes.clear();
5849        self
5850    }
5851}
5852
5853/// Lists all instances in a project for either a specified location or for all locations.
5854///
5855/// A builder for the *locations.instances.list* method supported by a *project* resource.
5856/// It is not used directly, but through a [`ProjectMethods`] instance.
5857///
5858/// # Example
5859///
5860/// Instantiate a resource method builder
5861///
5862/// ```test_harness,no_run
5863/// # extern crate hyper;
5864/// # extern crate hyper_rustls;
5865/// # extern crate google_file1 as file1;
5866/// # async fn dox() {
5867/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5868///
5869/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5870/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5871/// #     .with_native_roots()
5872/// #     .unwrap()
5873/// #     .https_only()
5874/// #     .enable_http2()
5875/// #     .build();
5876///
5877/// # let executor = hyper_util::rt::TokioExecutor::new();
5878/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5879/// #     secret,
5880/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5881/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5882/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5883/// #     ),
5884/// # ).build().await.unwrap();
5885///
5886/// # let client = hyper_util::client::legacy::Client::builder(
5887/// #     hyper_util::rt::TokioExecutor::new()
5888/// # )
5889/// # .build(
5890/// #     hyper_rustls::HttpsConnectorBuilder::new()
5891/// #         .with_native_roots()
5892/// #         .unwrap()
5893/// #         .https_or_http()
5894/// #         .enable_http2()
5895/// #         .build()
5896/// # );
5897/// # let mut hub = CloudFilestore::new(client, auth);
5898/// // You can configure optional parameters by calling the respective setters at will, and
5899/// // execute the final call using `doit()`.
5900/// // Values shown here are possibly random and not representative !
5901/// let result = hub.projects().locations_instances_list("parent")
5902///              .page_token("ea")
5903///              .page_size(-99)
5904///              .order_by("Lorem")
5905///              .filter("eos")
5906///              .doit().await;
5907/// # }
5908/// ```
5909pub struct ProjectLocationInstanceListCall<'a, C>
5910where
5911    C: 'a,
5912{
5913    hub: &'a CloudFilestore<C>,
5914    _parent: String,
5915    _page_token: Option<String>,
5916    _page_size: Option<i32>,
5917    _order_by: Option<String>,
5918    _filter: Option<String>,
5919    _delegate: Option<&'a mut dyn common::Delegate>,
5920    _additional_params: HashMap<String, String>,
5921    _scopes: BTreeSet<String>,
5922}
5923
5924impl<'a, C> common::CallBuilder for ProjectLocationInstanceListCall<'a, C> {}
5925
5926impl<'a, C> ProjectLocationInstanceListCall<'a, C>
5927where
5928    C: common::Connector,
5929{
5930    /// Perform the operation you have build so far.
5931    pub async fn doit(mut self) -> common::Result<(common::Response, ListInstancesResponse)> {
5932        use std::borrow::Cow;
5933        use std::io::{Read, Seek};
5934
5935        use common::{url::Params, ToParts};
5936        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5937
5938        let mut dd = common::DefaultDelegate;
5939        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5940        dlg.begin(common::MethodInfo {
5941            id: "file.projects.locations.instances.list",
5942            http_method: hyper::Method::GET,
5943        });
5944
5945        for &field in [
5946            "alt",
5947            "parent",
5948            "pageToken",
5949            "pageSize",
5950            "orderBy",
5951            "filter",
5952        ]
5953        .iter()
5954        {
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(7 + self._additional_params.len());
5962        params.push("parent", self._parent);
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        if let Some(value) = self._order_by.as_ref() {
5970            params.push("orderBy", value);
5971        }
5972        if let Some(value) = self._filter.as_ref() {
5973            params.push("filter", value);
5974        }
5975
5976        params.extend(self._additional_params.iter());
5977
5978        params.push("alt", "json");
5979        let mut url = self.hub._base_url.clone() + "v1/{+parent}/instances";
5980        if self._scopes.is_empty() {
5981            self._scopes
5982                .insert(Scope::CloudPlatform.as_ref().to_string());
5983        }
5984
5985        #[allow(clippy::single_element_loop)]
5986        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5987            url = params.uri_replacement(url, param_name, find_this, true);
5988        }
5989        {
5990            let to_remove = ["parent"];
5991            params.remove_params(&to_remove);
5992        }
5993
5994        let url = params.parse_with_url(&url);
5995
5996        loop {
5997            let token = match self
5998                .hub
5999                .auth
6000                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6001                .await
6002            {
6003                Ok(token) => token,
6004                Err(e) => match dlg.token(e) {
6005                    Ok(token) => token,
6006                    Err(e) => {
6007                        dlg.finished(false);
6008                        return Err(common::Error::MissingToken(e));
6009                    }
6010                },
6011            };
6012            let mut req_result = {
6013                let client = &self.hub.client;
6014                dlg.pre_request();
6015                let mut req_builder = hyper::Request::builder()
6016                    .method(hyper::Method::GET)
6017                    .uri(url.as_str())
6018                    .header(USER_AGENT, self.hub._user_agent.clone());
6019
6020                if let Some(token) = token.as_ref() {
6021                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6022                }
6023
6024                let request = req_builder
6025                    .header(CONTENT_LENGTH, 0_u64)
6026                    .body(common::to_body::<String>(None));
6027
6028                client.request(request.unwrap()).await
6029            };
6030
6031            match req_result {
6032                Err(err) => {
6033                    if let common::Retry::After(d) = dlg.http_error(&err) {
6034                        sleep(d).await;
6035                        continue;
6036                    }
6037                    dlg.finished(false);
6038                    return Err(common::Error::HttpError(err));
6039                }
6040                Ok(res) => {
6041                    let (mut parts, body) = res.into_parts();
6042                    let mut body = common::Body::new(body);
6043                    if !parts.status.is_success() {
6044                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6045                        let error = serde_json::from_str(&common::to_string(&bytes));
6046                        let response = common::to_response(parts, bytes.into());
6047
6048                        if let common::Retry::After(d) =
6049                            dlg.http_failure(&response, error.as_ref().ok())
6050                        {
6051                            sleep(d).await;
6052                            continue;
6053                        }
6054
6055                        dlg.finished(false);
6056
6057                        return Err(match error {
6058                            Ok(value) => common::Error::BadRequest(value),
6059                            _ => common::Error::Failure(response),
6060                        });
6061                    }
6062                    let response = {
6063                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6064                        let encoded = common::to_string(&bytes);
6065                        match serde_json::from_str(&encoded) {
6066                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6067                            Err(error) => {
6068                                dlg.response_json_decode_error(&encoded, &error);
6069                                return Err(common::Error::JsonDecodeError(
6070                                    encoded.to_string(),
6071                                    error,
6072                                ));
6073                            }
6074                        }
6075                    };
6076
6077                    dlg.finished(true);
6078                    return Ok(response);
6079                }
6080            }
6081        }
6082    }
6083
6084    /// Required. The project and location for which to retrieve instance information, in the format `projects/{project_id}/locations/{location}`. In Cloud Filestore, locations map to Google Cloud zones, for example **us-west1-b**. To retrieve instance information for all locations, use "-" for the `{location}` value.
6085    ///
6086    /// Sets the *parent* path property to the given value.
6087    ///
6088    /// Even though the property as already been set when instantiating this call,
6089    /// we provide this method for API completeness.
6090    pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
6091        self._parent = new_value.to_string();
6092        self
6093    }
6094    /// The next_page_token value to use if there are additional results to retrieve for this list request.
6095    ///
6096    /// Sets the *page token* query property to the given value.
6097    pub fn page_token(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
6098        self._page_token = Some(new_value.to_string());
6099        self
6100    }
6101    /// The maximum number of items to return.
6102    ///
6103    /// Sets the *page size* query property to the given value.
6104    pub fn page_size(mut self, new_value: i32) -> ProjectLocationInstanceListCall<'a, C> {
6105        self._page_size = Some(new_value);
6106        self
6107    }
6108    /// Sort results. Supported values are "name", "name desc" or "" (unsorted).
6109    ///
6110    /// Sets the *order by* query property to the given value.
6111    pub fn order_by(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
6112        self._order_by = Some(new_value.to_string());
6113        self
6114    }
6115    /// List filter.
6116    ///
6117    /// Sets the *filter* query property to the given value.
6118    pub fn filter(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
6119        self._filter = Some(new_value.to_string());
6120        self
6121    }
6122    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6123    /// while executing the actual API request.
6124    ///
6125    /// ````text
6126    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6127    /// ````
6128    ///
6129    /// Sets the *delegate* property to the given value.
6130    pub fn delegate(
6131        mut self,
6132        new_value: &'a mut dyn common::Delegate,
6133    ) -> ProjectLocationInstanceListCall<'a, C> {
6134        self._delegate = Some(new_value);
6135        self
6136    }
6137
6138    /// Set any additional parameter of the query string used in the request.
6139    /// It should be used to set parameters which are not yet available through their own
6140    /// setters.
6141    ///
6142    /// Please note that this method must not be used to set any of the known parameters
6143    /// which have their own setter method. If done anyway, the request will fail.
6144    ///
6145    /// # Additional Parameters
6146    ///
6147    /// * *$.xgafv* (query-string) - V1 error format.
6148    /// * *access_token* (query-string) - OAuth access token.
6149    /// * *alt* (query-string) - Data format for response.
6150    /// * *callback* (query-string) - JSONP
6151    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6152    /// * *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.
6153    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6154    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6155    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6156    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6157    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6158    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceListCall<'a, C>
6159    where
6160        T: AsRef<str>,
6161    {
6162        self._additional_params
6163            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6164        self
6165    }
6166
6167    /// Identifies the authorization scope for the method you are building.
6168    ///
6169    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6170    /// [`Scope::CloudPlatform`].
6171    ///
6172    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6173    /// tokens for more than one scope.
6174    ///
6175    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6176    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6177    /// sufficient, a read-write scope will do as well.
6178    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceListCall<'a, C>
6179    where
6180        St: AsRef<str>,
6181    {
6182        self._scopes.insert(String::from(scope.as_ref()));
6183        self
6184    }
6185    /// Identifies the authorization scope(s) for the method you are building.
6186    ///
6187    /// See [`Self::add_scope()`] for details.
6188    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceListCall<'a, C>
6189    where
6190        I: IntoIterator<Item = St>,
6191        St: AsRef<str>,
6192    {
6193        self._scopes
6194            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6195        self
6196    }
6197
6198    /// Removes all scopes, and no default scope will be used either.
6199    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6200    /// for details).
6201    pub fn clear_scopes(mut self) -> ProjectLocationInstanceListCall<'a, C> {
6202        self._scopes.clear();
6203        self
6204    }
6205}
6206
6207/// Updates the settings of a specific instance.
6208///
6209/// A builder for the *locations.instances.patch* method supported by a *project* resource.
6210/// It is not used directly, but through a [`ProjectMethods`] instance.
6211///
6212/// # Example
6213///
6214/// Instantiate a resource method builder
6215///
6216/// ```test_harness,no_run
6217/// # extern crate hyper;
6218/// # extern crate hyper_rustls;
6219/// # extern crate google_file1 as file1;
6220/// use file1::api::Instance;
6221/// # async fn dox() {
6222/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6223///
6224/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6225/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6226/// #     .with_native_roots()
6227/// #     .unwrap()
6228/// #     .https_only()
6229/// #     .enable_http2()
6230/// #     .build();
6231///
6232/// # let executor = hyper_util::rt::TokioExecutor::new();
6233/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6234/// #     secret,
6235/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6236/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6237/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6238/// #     ),
6239/// # ).build().await.unwrap();
6240///
6241/// # let client = hyper_util::client::legacy::Client::builder(
6242/// #     hyper_util::rt::TokioExecutor::new()
6243/// # )
6244/// # .build(
6245/// #     hyper_rustls::HttpsConnectorBuilder::new()
6246/// #         .with_native_roots()
6247/// #         .unwrap()
6248/// #         .https_or_http()
6249/// #         .enable_http2()
6250/// #         .build()
6251/// # );
6252/// # let mut hub = CloudFilestore::new(client, auth);
6253/// // As the method needs a request, you would usually fill it with the desired information
6254/// // into the respective structure. Some of the parts shown here might not be applicable !
6255/// // Values shown here are possibly random and not representative !
6256/// let mut req = Instance::default();
6257///
6258/// // You can configure optional parameters by calling the respective setters at will, and
6259/// // execute the final call using `doit()`.
6260/// // Values shown here are possibly random and not representative !
6261/// let result = hub.projects().locations_instances_patch(req, "name")
6262///              .update_mask(FieldMask::new::<&str>(&[]))
6263///              .doit().await;
6264/// # }
6265/// ```
6266pub struct ProjectLocationInstancePatchCall<'a, C>
6267where
6268    C: 'a,
6269{
6270    hub: &'a CloudFilestore<C>,
6271    _request: Instance,
6272    _name: String,
6273    _update_mask: Option<common::FieldMask>,
6274    _delegate: Option<&'a mut dyn common::Delegate>,
6275    _additional_params: HashMap<String, String>,
6276    _scopes: BTreeSet<String>,
6277}
6278
6279impl<'a, C> common::CallBuilder for ProjectLocationInstancePatchCall<'a, C> {}
6280
6281impl<'a, C> ProjectLocationInstancePatchCall<'a, C>
6282where
6283    C: common::Connector,
6284{
6285    /// Perform the operation you have build so far.
6286    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6287        use std::borrow::Cow;
6288        use std::io::{Read, Seek};
6289
6290        use common::{url::Params, ToParts};
6291        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6292
6293        let mut dd = common::DefaultDelegate;
6294        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6295        dlg.begin(common::MethodInfo {
6296            id: "file.projects.locations.instances.patch",
6297            http_method: hyper::Method::PATCH,
6298        });
6299
6300        for &field in ["alt", "name", "updateMask"].iter() {
6301            if self._additional_params.contains_key(field) {
6302                dlg.finished(false);
6303                return Err(common::Error::FieldClash(field));
6304            }
6305        }
6306
6307        let mut params = Params::with_capacity(5 + self._additional_params.len());
6308        params.push("name", self._name);
6309        if let Some(value) = self._update_mask.as_ref() {
6310            params.push("updateMask", value.to_string());
6311        }
6312
6313        params.extend(self._additional_params.iter());
6314
6315        params.push("alt", "json");
6316        let mut url = self.hub._base_url.clone() + "v1/{+name}";
6317        if self._scopes.is_empty() {
6318            self._scopes
6319                .insert(Scope::CloudPlatform.as_ref().to_string());
6320        }
6321
6322        #[allow(clippy::single_element_loop)]
6323        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6324            url = params.uri_replacement(url, param_name, find_this, true);
6325        }
6326        {
6327            let to_remove = ["name"];
6328            params.remove_params(&to_remove);
6329        }
6330
6331        let url = params.parse_with_url(&url);
6332
6333        let mut json_mime_type = mime::APPLICATION_JSON;
6334        let mut request_value_reader = {
6335            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6336            common::remove_json_null_values(&mut value);
6337            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6338            serde_json::to_writer(&mut dst, &value).unwrap();
6339            dst
6340        };
6341        let request_size = request_value_reader
6342            .seek(std::io::SeekFrom::End(0))
6343            .unwrap();
6344        request_value_reader
6345            .seek(std::io::SeekFrom::Start(0))
6346            .unwrap();
6347
6348        loop {
6349            let token = match self
6350                .hub
6351                .auth
6352                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6353                .await
6354            {
6355                Ok(token) => token,
6356                Err(e) => match dlg.token(e) {
6357                    Ok(token) => token,
6358                    Err(e) => {
6359                        dlg.finished(false);
6360                        return Err(common::Error::MissingToken(e));
6361                    }
6362                },
6363            };
6364            request_value_reader
6365                .seek(std::io::SeekFrom::Start(0))
6366                .unwrap();
6367            let mut req_result = {
6368                let client = &self.hub.client;
6369                dlg.pre_request();
6370                let mut req_builder = hyper::Request::builder()
6371                    .method(hyper::Method::PATCH)
6372                    .uri(url.as_str())
6373                    .header(USER_AGENT, self.hub._user_agent.clone());
6374
6375                if let Some(token) = token.as_ref() {
6376                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6377                }
6378
6379                let request = req_builder
6380                    .header(CONTENT_TYPE, json_mime_type.to_string())
6381                    .header(CONTENT_LENGTH, request_size as u64)
6382                    .body(common::to_body(
6383                        request_value_reader.get_ref().clone().into(),
6384                    ));
6385
6386                client.request(request.unwrap()).await
6387            };
6388
6389            match req_result {
6390                Err(err) => {
6391                    if let common::Retry::After(d) = dlg.http_error(&err) {
6392                        sleep(d).await;
6393                        continue;
6394                    }
6395                    dlg.finished(false);
6396                    return Err(common::Error::HttpError(err));
6397                }
6398                Ok(res) => {
6399                    let (mut parts, body) = res.into_parts();
6400                    let mut body = common::Body::new(body);
6401                    if !parts.status.is_success() {
6402                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6403                        let error = serde_json::from_str(&common::to_string(&bytes));
6404                        let response = common::to_response(parts, bytes.into());
6405
6406                        if let common::Retry::After(d) =
6407                            dlg.http_failure(&response, error.as_ref().ok())
6408                        {
6409                            sleep(d).await;
6410                            continue;
6411                        }
6412
6413                        dlg.finished(false);
6414
6415                        return Err(match error {
6416                            Ok(value) => common::Error::BadRequest(value),
6417                            _ => common::Error::Failure(response),
6418                        });
6419                    }
6420                    let response = {
6421                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6422                        let encoded = common::to_string(&bytes);
6423                        match serde_json::from_str(&encoded) {
6424                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6425                            Err(error) => {
6426                                dlg.response_json_decode_error(&encoded, &error);
6427                                return Err(common::Error::JsonDecodeError(
6428                                    encoded.to_string(),
6429                                    error,
6430                                ));
6431                            }
6432                        }
6433                    };
6434
6435                    dlg.finished(true);
6436                    return Ok(response);
6437                }
6438            }
6439        }
6440    }
6441
6442    ///
6443    /// Sets the *request* property to the given value.
6444    ///
6445    /// Even though the property as already been set when instantiating this call,
6446    /// we provide this method for API completeness.
6447    pub fn request(mut self, new_value: Instance) -> ProjectLocationInstancePatchCall<'a, C> {
6448        self._request = new_value;
6449        self
6450    }
6451    /// Output only. The resource name of the instance, in the format `projects/{project}/locations/{location}/instances/{instance}`.
6452    ///
6453    /// Sets the *name* path property to the given value.
6454    ///
6455    /// Even though the property as already been set when instantiating this call,
6456    /// we provide this method for API completeness.
6457    pub fn name(mut self, new_value: &str) -> ProjectLocationInstancePatchCall<'a, C> {
6458        self._name = new_value.to_string();
6459        self
6460    }
6461    /// Mask of fields to update. At least one path must be supplied in this field. The elements of the repeated paths field may only include these fields: * "description" * "file_shares" * "labels" * "performance_config" * "deletion_protection_enabled" * "deletion_protection_reason"
6462    ///
6463    /// Sets the *update mask* query property to the given value.
6464    pub fn update_mask(
6465        mut self,
6466        new_value: common::FieldMask,
6467    ) -> ProjectLocationInstancePatchCall<'a, C> {
6468        self._update_mask = Some(new_value);
6469        self
6470    }
6471    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6472    /// while executing the actual API request.
6473    ///
6474    /// ````text
6475    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6476    /// ````
6477    ///
6478    /// Sets the *delegate* property to the given value.
6479    pub fn delegate(
6480        mut self,
6481        new_value: &'a mut dyn common::Delegate,
6482    ) -> ProjectLocationInstancePatchCall<'a, C> {
6483        self._delegate = Some(new_value);
6484        self
6485    }
6486
6487    /// Set any additional parameter of the query string used in the request.
6488    /// It should be used to set parameters which are not yet available through their own
6489    /// setters.
6490    ///
6491    /// Please note that this method must not be used to set any of the known parameters
6492    /// which have their own setter method. If done anyway, the request will fail.
6493    ///
6494    /// # Additional Parameters
6495    ///
6496    /// * *$.xgafv* (query-string) - V1 error format.
6497    /// * *access_token* (query-string) - OAuth access token.
6498    /// * *alt* (query-string) - Data format for response.
6499    /// * *callback* (query-string) - JSONP
6500    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6501    /// * *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.
6502    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6503    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6504    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6505    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6506    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6507    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstancePatchCall<'a, C>
6508    where
6509        T: AsRef<str>,
6510    {
6511        self._additional_params
6512            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6513        self
6514    }
6515
6516    /// Identifies the authorization scope for the method you are building.
6517    ///
6518    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6519    /// [`Scope::CloudPlatform`].
6520    ///
6521    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6522    /// tokens for more than one scope.
6523    ///
6524    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6525    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6526    /// sufficient, a read-write scope will do as well.
6527    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstancePatchCall<'a, C>
6528    where
6529        St: AsRef<str>,
6530    {
6531        self._scopes.insert(String::from(scope.as_ref()));
6532        self
6533    }
6534    /// Identifies the authorization scope(s) for the method you are building.
6535    ///
6536    /// See [`Self::add_scope()`] for details.
6537    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstancePatchCall<'a, C>
6538    where
6539        I: IntoIterator<Item = St>,
6540        St: AsRef<str>,
6541    {
6542        self._scopes
6543            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6544        self
6545    }
6546
6547    /// Removes all scopes, and no default scope will be used either.
6548    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6549    /// for details).
6550    pub fn clear_scopes(mut self) -> ProjectLocationInstancePatchCall<'a, C> {
6551        self._scopes.clear();
6552        self
6553    }
6554}
6555
6556/// Pause the standby instance (replica). WARNING: This operation makes the standby instance's NFS filesystem writable. Any data written to the standby instance while paused will be lost when the replica is resumed or promoted.
6557///
6558/// A builder for the *locations.instances.pauseReplica* method supported by a *project* resource.
6559/// It is not used directly, but through a [`ProjectMethods`] instance.
6560///
6561/// # Example
6562///
6563/// Instantiate a resource method builder
6564///
6565/// ```test_harness,no_run
6566/// # extern crate hyper;
6567/// # extern crate hyper_rustls;
6568/// # extern crate google_file1 as file1;
6569/// use file1::api::PauseReplicaRequest;
6570/// # async fn dox() {
6571/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6572///
6573/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6574/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6575/// #     .with_native_roots()
6576/// #     .unwrap()
6577/// #     .https_only()
6578/// #     .enable_http2()
6579/// #     .build();
6580///
6581/// # let executor = hyper_util::rt::TokioExecutor::new();
6582/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6583/// #     secret,
6584/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6585/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6586/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6587/// #     ),
6588/// # ).build().await.unwrap();
6589///
6590/// # let client = hyper_util::client::legacy::Client::builder(
6591/// #     hyper_util::rt::TokioExecutor::new()
6592/// # )
6593/// # .build(
6594/// #     hyper_rustls::HttpsConnectorBuilder::new()
6595/// #         .with_native_roots()
6596/// #         .unwrap()
6597/// #         .https_or_http()
6598/// #         .enable_http2()
6599/// #         .build()
6600/// # );
6601/// # let mut hub = CloudFilestore::new(client, auth);
6602/// // As the method needs a request, you would usually fill it with the desired information
6603/// // into the respective structure. Some of the parts shown here might not be applicable !
6604/// // Values shown here are possibly random and not representative !
6605/// let mut req = PauseReplicaRequest::default();
6606///
6607/// // You can configure optional parameters by calling the respective setters at will, and
6608/// // execute the final call using `doit()`.
6609/// // Values shown here are possibly random and not representative !
6610/// let result = hub.projects().locations_instances_pause_replica(req, "name")
6611///              .doit().await;
6612/// # }
6613/// ```
6614pub struct ProjectLocationInstancePauseReplicaCall<'a, C>
6615where
6616    C: 'a,
6617{
6618    hub: &'a CloudFilestore<C>,
6619    _request: PauseReplicaRequest,
6620    _name: String,
6621    _delegate: Option<&'a mut dyn common::Delegate>,
6622    _additional_params: HashMap<String, String>,
6623    _scopes: BTreeSet<String>,
6624}
6625
6626impl<'a, C> common::CallBuilder for ProjectLocationInstancePauseReplicaCall<'a, C> {}
6627
6628impl<'a, C> ProjectLocationInstancePauseReplicaCall<'a, C>
6629where
6630    C: common::Connector,
6631{
6632    /// Perform the operation you have build so far.
6633    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6634        use std::borrow::Cow;
6635        use std::io::{Read, Seek};
6636
6637        use common::{url::Params, ToParts};
6638        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6639
6640        let mut dd = common::DefaultDelegate;
6641        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6642        dlg.begin(common::MethodInfo {
6643            id: "file.projects.locations.instances.pauseReplica",
6644            http_method: hyper::Method::POST,
6645        });
6646
6647        for &field in ["alt", "name"].iter() {
6648            if self._additional_params.contains_key(field) {
6649                dlg.finished(false);
6650                return Err(common::Error::FieldClash(field));
6651            }
6652        }
6653
6654        let mut params = Params::with_capacity(4 + self._additional_params.len());
6655        params.push("name", self._name);
6656
6657        params.extend(self._additional_params.iter());
6658
6659        params.push("alt", "json");
6660        let mut url = self.hub._base_url.clone() + "v1/{+name}:pauseReplica";
6661        if self._scopes.is_empty() {
6662            self._scopes
6663                .insert(Scope::CloudPlatform.as_ref().to_string());
6664        }
6665
6666        #[allow(clippy::single_element_loop)]
6667        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6668            url = params.uri_replacement(url, param_name, find_this, true);
6669        }
6670        {
6671            let to_remove = ["name"];
6672            params.remove_params(&to_remove);
6673        }
6674
6675        let url = params.parse_with_url(&url);
6676
6677        let mut json_mime_type = mime::APPLICATION_JSON;
6678        let mut request_value_reader = {
6679            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6680            common::remove_json_null_values(&mut value);
6681            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6682            serde_json::to_writer(&mut dst, &value).unwrap();
6683            dst
6684        };
6685        let request_size = request_value_reader
6686            .seek(std::io::SeekFrom::End(0))
6687            .unwrap();
6688        request_value_reader
6689            .seek(std::io::SeekFrom::Start(0))
6690            .unwrap();
6691
6692        loop {
6693            let token = match self
6694                .hub
6695                .auth
6696                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6697                .await
6698            {
6699                Ok(token) => token,
6700                Err(e) => match dlg.token(e) {
6701                    Ok(token) => token,
6702                    Err(e) => {
6703                        dlg.finished(false);
6704                        return Err(common::Error::MissingToken(e));
6705                    }
6706                },
6707            };
6708            request_value_reader
6709                .seek(std::io::SeekFrom::Start(0))
6710                .unwrap();
6711            let mut req_result = {
6712                let client = &self.hub.client;
6713                dlg.pre_request();
6714                let mut req_builder = hyper::Request::builder()
6715                    .method(hyper::Method::POST)
6716                    .uri(url.as_str())
6717                    .header(USER_AGENT, self.hub._user_agent.clone());
6718
6719                if let Some(token) = token.as_ref() {
6720                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6721                }
6722
6723                let request = req_builder
6724                    .header(CONTENT_TYPE, json_mime_type.to_string())
6725                    .header(CONTENT_LENGTH, request_size as u64)
6726                    .body(common::to_body(
6727                        request_value_reader.get_ref().clone().into(),
6728                    ));
6729
6730                client.request(request.unwrap()).await
6731            };
6732
6733            match req_result {
6734                Err(err) => {
6735                    if let common::Retry::After(d) = dlg.http_error(&err) {
6736                        sleep(d).await;
6737                        continue;
6738                    }
6739                    dlg.finished(false);
6740                    return Err(common::Error::HttpError(err));
6741                }
6742                Ok(res) => {
6743                    let (mut parts, body) = res.into_parts();
6744                    let mut body = common::Body::new(body);
6745                    if !parts.status.is_success() {
6746                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6747                        let error = serde_json::from_str(&common::to_string(&bytes));
6748                        let response = common::to_response(parts, bytes.into());
6749
6750                        if let common::Retry::After(d) =
6751                            dlg.http_failure(&response, error.as_ref().ok())
6752                        {
6753                            sleep(d).await;
6754                            continue;
6755                        }
6756
6757                        dlg.finished(false);
6758
6759                        return Err(match error {
6760                            Ok(value) => common::Error::BadRequest(value),
6761                            _ => common::Error::Failure(response),
6762                        });
6763                    }
6764                    let response = {
6765                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6766                        let encoded = common::to_string(&bytes);
6767                        match serde_json::from_str(&encoded) {
6768                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6769                            Err(error) => {
6770                                dlg.response_json_decode_error(&encoded, &error);
6771                                return Err(common::Error::JsonDecodeError(
6772                                    encoded.to_string(),
6773                                    error,
6774                                ));
6775                            }
6776                        }
6777                    };
6778
6779                    dlg.finished(true);
6780                    return Ok(response);
6781                }
6782            }
6783        }
6784    }
6785
6786    ///
6787    /// Sets the *request* property to the given value.
6788    ///
6789    /// Even though the property as already been set when instantiating this call,
6790    /// we provide this method for API completeness.
6791    pub fn request(
6792        mut self,
6793        new_value: PauseReplicaRequest,
6794    ) -> ProjectLocationInstancePauseReplicaCall<'a, C> {
6795        self._request = new_value;
6796        self
6797    }
6798    /// Required. The resource name of the instance, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}`.
6799    ///
6800    /// Sets the *name* path property to the given value.
6801    ///
6802    /// Even though the property as already been set when instantiating this call,
6803    /// we provide this method for API completeness.
6804    pub fn name(mut self, new_value: &str) -> ProjectLocationInstancePauseReplicaCall<'a, C> {
6805        self._name = new_value.to_string();
6806        self
6807    }
6808    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6809    /// while executing the actual API request.
6810    ///
6811    /// ````text
6812    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6813    /// ````
6814    ///
6815    /// Sets the *delegate* property to the given value.
6816    pub fn delegate(
6817        mut self,
6818        new_value: &'a mut dyn common::Delegate,
6819    ) -> ProjectLocationInstancePauseReplicaCall<'a, C> {
6820        self._delegate = Some(new_value);
6821        self
6822    }
6823
6824    /// Set any additional parameter of the query string used in the request.
6825    /// It should be used to set parameters which are not yet available through their own
6826    /// setters.
6827    ///
6828    /// Please note that this method must not be used to set any of the known parameters
6829    /// which have their own setter method. If done anyway, the request will fail.
6830    ///
6831    /// # Additional Parameters
6832    ///
6833    /// * *$.xgafv* (query-string) - V1 error format.
6834    /// * *access_token* (query-string) - OAuth access token.
6835    /// * *alt* (query-string) - Data format for response.
6836    /// * *callback* (query-string) - JSONP
6837    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6838    /// * *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.
6839    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6840    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6841    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6842    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6843    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6844    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstancePauseReplicaCall<'a, C>
6845    where
6846        T: AsRef<str>,
6847    {
6848        self._additional_params
6849            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6850        self
6851    }
6852
6853    /// Identifies the authorization scope for the method you are building.
6854    ///
6855    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6856    /// [`Scope::CloudPlatform`].
6857    ///
6858    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6859    /// tokens for more than one scope.
6860    ///
6861    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6862    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6863    /// sufficient, a read-write scope will do as well.
6864    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstancePauseReplicaCall<'a, C>
6865    where
6866        St: AsRef<str>,
6867    {
6868        self._scopes.insert(String::from(scope.as_ref()));
6869        self
6870    }
6871    /// Identifies the authorization scope(s) for the method you are building.
6872    ///
6873    /// See [`Self::add_scope()`] for details.
6874    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstancePauseReplicaCall<'a, C>
6875    where
6876        I: IntoIterator<Item = St>,
6877        St: AsRef<str>,
6878    {
6879        self._scopes
6880            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6881        self
6882    }
6883
6884    /// Removes all scopes, and no default scope will be used either.
6885    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6886    /// for details).
6887    pub fn clear_scopes(mut self) -> ProjectLocationInstancePauseReplicaCall<'a, C> {
6888        self._scopes.clear();
6889        self
6890    }
6891}
6892
6893/// Promote the standby instance (replica).
6894///
6895/// A builder for the *locations.instances.promoteReplica* method supported by a *project* resource.
6896/// It is not used directly, but through a [`ProjectMethods`] instance.
6897///
6898/// # Example
6899///
6900/// Instantiate a resource method builder
6901///
6902/// ```test_harness,no_run
6903/// # extern crate hyper;
6904/// # extern crate hyper_rustls;
6905/// # extern crate google_file1 as file1;
6906/// use file1::api::PromoteReplicaRequest;
6907/// # async fn dox() {
6908/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6909///
6910/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6911/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6912/// #     .with_native_roots()
6913/// #     .unwrap()
6914/// #     .https_only()
6915/// #     .enable_http2()
6916/// #     .build();
6917///
6918/// # let executor = hyper_util::rt::TokioExecutor::new();
6919/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6920/// #     secret,
6921/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6922/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6923/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6924/// #     ),
6925/// # ).build().await.unwrap();
6926///
6927/// # let client = hyper_util::client::legacy::Client::builder(
6928/// #     hyper_util::rt::TokioExecutor::new()
6929/// # )
6930/// # .build(
6931/// #     hyper_rustls::HttpsConnectorBuilder::new()
6932/// #         .with_native_roots()
6933/// #         .unwrap()
6934/// #         .https_or_http()
6935/// #         .enable_http2()
6936/// #         .build()
6937/// # );
6938/// # let mut hub = CloudFilestore::new(client, auth);
6939/// // As the method needs a request, you would usually fill it with the desired information
6940/// // into the respective structure. Some of the parts shown here might not be applicable !
6941/// // Values shown here are possibly random and not representative !
6942/// let mut req = PromoteReplicaRequest::default();
6943///
6944/// // You can configure optional parameters by calling the respective setters at will, and
6945/// // execute the final call using `doit()`.
6946/// // Values shown here are possibly random and not representative !
6947/// let result = hub.projects().locations_instances_promote_replica(req, "name")
6948///              .doit().await;
6949/// # }
6950/// ```
6951pub struct ProjectLocationInstancePromoteReplicaCall<'a, C>
6952where
6953    C: 'a,
6954{
6955    hub: &'a CloudFilestore<C>,
6956    _request: PromoteReplicaRequest,
6957    _name: String,
6958    _delegate: Option<&'a mut dyn common::Delegate>,
6959    _additional_params: HashMap<String, String>,
6960    _scopes: BTreeSet<String>,
6961}
6962
6963impl<'a, C> common::CallBuilder for ProjectLocationInstancePromoteReplicaCall<'a, C> {}
6964
6965impl<'a, C> ProjectLocationInstancePromoteReplicaCall<'a, C>
6966where
6967    C: common::Connector,
6968{
6969    /// Perform the operation you have build so far.
6970    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6971        use std::borrow::Cow;
6972        use std::io::{Read, Seek};
6973
6974        use common::{url::Params, ToParts};
6975        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6976
6977        let mut dd = common::DefaultDelegate;
6978        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6979        dlg.begin(common::MethodInfo {
6980            id: "file.projects.locations.instances.promoteReplica",
6981            http_method: hyper::Method::POST,
6982        });
6983
6984        for &field in ["alt", "name"].iter() {
6985            if self._additional_params.contains_key(field) {
6986                dlg.finished(false);
6987                return Err(common::Error::FieldClash(field));
6988            }
6989        }
6990
6991        let mut params = Params::with_capacity(4 + self._additional_params.len());
6992        params.push("name", self._name);
6993
6994        params.extend(self._additional_params.iter());
6995
6996        params.push("alt", "json");
6997        let mut url = self.hub._base_url.clone() + "v1/{+name}:promoteReplica";
6998        if self._scopes.is_empty() {
6999            self._scopes
7000                .insert(Scope::CloudPlatform.as_ref().to_string());
7001        }
7002
7003        #[allow(clippy::single_element_loop)]
7004        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7005            url = params.uri_replacement(url, param_name, find_this, true);
7006        }
7007        {
7008            let to_remove = ["name"];
7009            params.remove_params(&to_remove);
7010        }
7011
7012        let url = params.parse_with_url(&url);
7013
7014        let mut json_mime_type = mime::APPLICATION_JSON;
7015        let mut request_value_reader = {
7016            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7017            common::remove_json_null_values(&mut value);
7018            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7019            serde_json::to_writer(&mut dst, &value).unwrap();
7020            dst
7021        };
7022        let request_size = request_value_reader
7023            .seek(std::io::SeekFrom::End(0))
7024            .unwrap();
7025        request_value_reader
7026            .seek(std::io::SeekFrom::Start(0))
7027            .unwrap();
7028
7029        loop {
7030            let token = match self
7031                .hub
7032                .auth
7033                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7034                .await
7035            {
7036                Ok(token) => token,
7037                Err(e) => match dlg.token(e) {
7038                    Ok(token) => token,
7039                    Err(e) => {
7040                        dlg.finished(false);
7041                        return Err(common::Error::MissingToken(e));
7042                    }
7043                },
7044            };
7045            request_value_reader
7046                .seek(std::io::SeekFrom::Start(0))
7047                .unwrap();
7048            let mut req_result = {
7049                let client = &self.hub.client;
7050                dlg.pre_request();
7051                let mut req_builder = hyper::Request::builder()
7052                    .method(hyper::Method::POST)
7053                    .uri(url.as_str())
7054                    .header(USER_AGENT, self.hub._user_agent.clone());
7055
7056                if let Some(token) = token.as_ref() {
7057                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7058                }
7059
7060                let request = req_builder
7061                    .header(CONTENT_TYPE, json_mime_type.to_string())
7062                    .header(CONTENT_LENGTH, request_size as u64)
7063                    .body(common::to_body(
7064                        request_value_reader.get_ref().clone().into(),
7065                    ));
7066
7067                client.request(request.unwrap()).await
7068            };
7069
7070            match req_result {
7071                Err(err) => {
7072                    if let common::Retry::After(d) = dlg.http_error(&err) {
7073                        sleep(d).await;
7074                        continue;
7075                    }
7076                    dlg.finished(false);
7077                    return Err(common::Error::HttpError(err));
7078                }
7079                Ok(res) => {
7080                    let (mut parts, body) = res.into_parts();
7081                    let mut body = common::Body::new(body);
7082                    if !parts.status.is_success() {
7083                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7084                        let error = serde_json::from_str(&common::to_string(&bytes));
7085                        let response = common::to_response(parts, bytes.into());
7086
7087                        if let common::Retry::After(d) =
7088                            dlg.http_failure(&response, error.as_ref().ok())
7089                        {
7090                            sleep(d).await;
7091                            continue;
7092                        }
7093
7094                        dlg.finished(false);
7095
7096                        return Err(match error {
7097                            Ok(value) => common::Error::BadRequest(value),
7098                            _ => common::Error::Failure(response),
7099                        });
7100                    }
7101                    let response = {
7102                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7103                        let encoded = common::to_string(&bytes);
7104                        match serde_json::from_str(&encoded) {
7105                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7106                            Err(error) => {
7107                                dlg.response_json_decode_error(&encoded, &error);
7108                                return Err(common::Error::JsonDecodeError(
7109                                    encoded.to_string(),
7110                                    error,
7111                                ));
7112                            }
7113                        }
7114                    };
7115
7116                    dlg.finished(true);
7117                    return Ok(response);
7118                }
7119            }
7120        }
7121    }
7122
7123    ///
7124    /// Sets the *request* property to the given value.
7125    ///
7126    /// Even though the property as already been set when instantiating this call,
7127    /// we provide this method for API completeness.
7128    pub fn request(
7129        mut self,
7130        new_value: PromoteReplicaRequest,
7131    ) -> ProjectLocationInstancePromoteReplicaCall<'a, C> {
7132        self._request = new_value;
7133        self
7134    }
7135    /// Required. The resource name of the instance, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}`.
7136    ///
7137    /// Sets the *name* path property to the given value.
7138    ///
7139    /// Even though the property as already been set when instantiating this call,
7140    /// we provide this method for API completeness.
7141    pub fn name(mut self, new_value: &str) -> ProjectLocationInstancePromoteReplicaCall<'a, C> {
7142        self._name = new_value.to_string();
7143        self
7144    }
7145    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7146    /// while executing the actual API request.
7147    ///
7148    /// ````text
7149    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7150    /// ````
7151    ///
7152    /// Sets the *delegate* property to the given value.
7153    pub fn delegate(
7154        mut self,
7155        new_value: &'a mut dyn common::Delegate,
7156    ) -> ProjectLocationInstancePromoteReplicaCall<'a, C> {
7157        self._delegate = Some(new_value);
7158        self
7159    }
7160
7161    /// Set any additional parameter of the query string used in the request.
7162    /// It should be used to set parameters which are not yet available through their own
7163    /// setters.
7164    ///
7165    /// Please note that this method must not be used to set any of the known parameters
7166    /// which have their own setter method. If done anyway, the request will fail.
7167    ///
7168    /// # Additional Parameters
7169    ///
7170    /// * *$.xgafv* (query-string) - V1 error format.
7171    /// * *access_token* (query-string) - OAuth access token.
7172    /// * *alt* (query-string) - Data format for response.
7173    /// * *callback* (query-string) - JSONP
7174    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7175    /// * *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.
7176    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7177    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7178    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7179    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7180    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7181    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstancePromoteReplicaCall<'a, C>
7182    where
7183        T: AsRef<str>,
7184    {
7185        self._additional_params
7186            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7187        self
7188    }
7189
7190    /// Identifies the authorization scope for the method you are building.
7191    ///
7192    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7193    /// [`Scope::CloudPlatform`].
7194    ///
7195    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7196    /// tokens for more than one scope.
7197    ///
7198    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7199    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7200    /// sufficient, a read-write scope will do as well.
7201    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstancePromoteReplicaCall<'a, C>
7202    where
7203        St: AsRef<str>,
7204    {
7205        self._scopes.insert(String::from(scope.as_ref()));
7206        self
7207    }
7208    /// Identifies the authorization scope(s) for the method you are building.
7209    ///
7210    /// See [`Self::add_scope()`] for details.
7211    pub fn add_scopes<I, St>(
7212        mut self,
7213        scopes: I,
7214    ) -> ProjectLocationInstancePromoteReplicaCall<'a, C>
7215    where
7216        I: IntoIterator<Item = St>,
7217        St: AsRef<str>,
7218    {
7219        self._scopes
7220            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7221        self
7222    }
7223
7224    /// Removes all scopes, and no default scope will be used either.
7225    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7226    /// for details).
7227    pub fn clear_scopes(mut self) -> ProjectLocationInstancePromoteReplicaCall<'a, C> {
7228        self._scopes.clear();
7229        self
7230    }
7231}
7232
7233/// Restores an existing instance's file share from a backup. The capacity of the instance needs to be equal to or larger than the capacity of the backup (and also equal to or larger than the minimum capacity of the tier).
7234///
7235/// A builder for the *locations.instances.restore* method supported by a *project* resource.
7236/// It is not used directly, but through a [`ProjectMethods`] instance.
7237///
7238/// # Example
7239///
7240/// Instantiate a resource method builder
7241///
7242/// ```test_harness,no_run
7243/// # extern crate hyper;
7244/// # extern crate hyper_rustls;
7245/// # extern crate google_file1 as file1;
7246/// use file1::api::RestoreInstanceRequest;
7247/// # async fn dox() {
7248/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7249///
7250/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7251/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7252/// #     .with_native_roots()
7253/// #     .unwrap()
7254/// #     .https_only()
7255/// #     .enable_http2()
7256/// #     .build();
7257///
7258/// # let executor = hyper_util::rt::TokioExecutor::new();
7259/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7260/// #     secret,
7261/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7262/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7263/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7264/// #     ),
7265/// # ).build().await.unwrap();
7266///
7267/// # let client = hyper_util::client::legacy::Client::builder(
7268/// #     hyper_util::rt::TokioExecutor::new()
7269/// # )
7270/// # .build(
7271/// #     hyper_rustls::HttpsConnectorBuilder::new()
7272/// #         .with_native_roots()
7273/// #         .unwrap()
7274/// #         .https_or_http()
7275/// #         .enable_http2()
7276/// #         .build()
7277/// # );
7278/// # let mut hub = CloudFilestore::new(client, auth);
7279/// // As the method needs a request, you would usually fill it with the desired information
7280/// // into the respective structure. Some of the parts shown here might not be applicable !
7281/// // Values shown here are possibly random and not representative !
7282/// let mut req = RestoreInstanceRequest::default();
7283///
7284/// // You can configure optional parameters by calling the respective setters at will, and
7285/// // execute the final call using `doit()`.
7286/// // Values shown here are possibly random and not representative !
7287/// let result = hub.projects().locations_instances_restore(req, "name")
7288///              .doit().await;
7289/// # }
7290/// ```
7291pub struct ProjectLocationInstanceRestoreCall<'a, C>
7292where
7293    C: 'a,
7294{
7295    hub: &'a CloudFilestore<C>,
7296    _request: RestoreInstanceRequest,
7297    _name: String,
7298    _delegate: Option<&'a mut dyn common::Delegate>,
7299    _additional_params: HashMap<String, String>,
7300    _scopes: BTreeSet<String>,
7301}
7302
7303impl<'a, C> common::CallBuilder for ProjectLocationInstanceRestoreCall<'a, C> {}
7304
7305impl<'a, C> ProjectLocationInstanceRestoreCall<'a, C>
7306where
7307    C: common::Connector,
7308{
7309    /// Perform the operation you have build so far.
7310    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7311        use std::borrow::Cow;
7312        use std::io::{Read, Seek};
7313
7314        use common::{url::Params, ToParts};
7315        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7316
7317        let mut dd = common::DefaultDelegate;
7318        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7319        dlg.begin(common::MethodInfo {
7320            id: "file.projects.locations.instances.restore",
7321            http_method: hyper::Method::POST,
7322        });
7323
7324        for &field in ["alt", "name"].iter() {
7325            if self._additional_params.contains_key(field) {
7326                dlg.finished(false);
7327                return Err(common::Error::FieldClash(field));
7328            }
7329        }
7330
7331        let mut params = Params::with_capacity(4 + self._additional_params.len());
7332        params.push("name", self._name);
7333
7334        params.extend(self._additional_params.iter());
7335
7336        params.push("alt", "json");
7337        let mut url = self.hub._base_url.clone() + "v1/{+name}:restore";
7338        if self._scopes.is_empty() {
7339            self._scopes
7340                .insert(Scope::CloudPlatform.as_ref().to_string());
7341        }
7342
7343        #[allow(clippy::single_element_loop)]
7344        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7345            url = params.uri_replacement(url, param_name, find_this, true);
7346        }
7347        {
7348            let to_remove = ["name"];
7349            params.remove_params(&to_remove);
7350        }
7351
7352        let url = params.parse_with_url(&url);
7353
7354        let mut json_mime_type = mime::APPLICATION_JSON;
7355        let mut request_value_reader = {
7356            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7357            common::remove_json_null_values(&mut value);
7358            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7359            serde_json::to_writer(&mut dst, &value).unwrap();
7360            dst
7361        };
7362        let request_size = request_value_reader
7363            .seek(std::io::SeekFrom::End(0))
7364            .unwrap();
7365        request_value_reader
7366            .seek(std::io::SeekFrom::Start(0))
7367            .unwrap();
7368
7369        loop {
7370            let token = match self
7371                .hub
7372                .auth
7373                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7374                .await
7375            {
7376                Ok(token) => token,
7377                Err(e) => match dlg.token(e) {
7378                    Ok(token) => token,
7379                    Err(e) => {
7380                        dlg.finished(false);
7381                        return Err(common::Error::MissingToken(e));
7382                    }
7383                },
7384            };
7385            request_value_reader
7386                .seek(std::io::SeekFrom::Start(0))
7387                .unwrap();
7388            let mut req_result = {
7389                let client = &self.hub.client;
7390                dlg.pre_request();
7391                let mut req_builder = hyper::Request::builder()
7392                    .method(hyper::Method::POST)
7393                    .uri(url.as_str())
7394                    .header(USER_AGENT, self.hub._user_agent.clone());
7395
7396                if let Some(token) = token.as_ref() {
7397                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7398                }
7399
7400                let request = req_builder
7401                    .header(CONTENT_TYPE, json_mime_type.to_string())
7402                    .header(CONTENT_LENGTH, request_size as u64)
7403                    .body(common::to_body(
7404                        request_value_reader.get_ref().clone().into(),
7405                    ));
7406
7407                client.request(request.unwrap()).await
7408            };
7409
7410            match req_result {
7411                Err(err) => {
7412                    if let common::Retry::After(d) = dlg.http_error(&err) {
7413                        sleep(d).await;
7414                        continue;
7415                    }
7416                    dlg.finished(false);
7417                    return Err(common::Error::HttpError(err));
7418                }
7419                Ok(res) => {
7420                    let (mut parts, body) = res.into_parts();
7421                    let mut body = common::Body::new(body);
7422                    if !parts.status.is_success() {
7423                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7424                        let error = serde_json::from_str(&common::to_string(&bytes));
7425                        let response = common::to_response(parts, bytes.into());
7426
7427                        if let common::Retry::After(d) =
7428                            dlg.http_failure(&response, error.as_ref().ok())
7429                        {
7430                            sleep(d).await;
7431                            continue;
7432                        }
7433
7434                        dlg.finished(false);
7435
7436                        return Err(match error {
7437                            Ok(value) => common::Error::BadRequest(value),
7438                            _ => common::Error::Failure(response),
7439                        });
7440                    }
7441                    let response = {
7442                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7443                        let encoded = common::to_string(&bytes);
7444                        match serde_json::from_str(&encoded) {
7445                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7446                            Err(error) => {
7447                                dlg.response_json_decode_error(&encoded, &error);
7448                                return Err(common::Error::JsonDecodeError(
7449                                    encoded.to_string(),
7450                                    error,
7451                                ));
7452                            }
7453                        }
7454                    };
7455
7456                    dlg.finished(true);
7457                    return Ok(response);
7458                }
7459            }
7460        }
7461    }
7462
7463    ///
7464    /// Sets the *request* property to the given value.
7465    ///
7466    /// Even though the property as already been set when instantiating this call,
7467    /// we provide this method for API completeness.
7468    pub fn request(
7469        mut self,
7470        new_value: RestoreInstanceRequest,
7471    ) -> ProjectLocationInstanceRestoreCall<'a, C> {
7472        self._request = new_value;
7473        self
7474    }
7475    /// Required. The resource name of the instance, in the format `projects/{project_number}/locations/{location_id}/instances/{instance_id}`.
7476    ///
7477    /// Sets the *name* path property to the given value.
7478    ///
7479    /// Even though the property as already been set when instantiating this call,
7480    /// we provide this method for API completeness.
7481    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceRestoreCall<'a, C> {
7482        self._name = new_value.to_string();
7483        self
7484    }
7485    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7486    /// while executing the actual API request.
7487    ///
7488    /// ````text
7489    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7490    /// ````
7491    ///
7492    /// Sets the *delegate* property to the given value.
7493    pub fn delegate(
7494        mut self,
7495        new_value: &'a mut dyn common::Delegate,
7496    ) -> ProjectLocationInstanceRestoreCall<'a, C> {
7497        self._delegate = Some(new_value);
7498        self
7499    }
7500
7501    /// Set any additional parameter of the query string used in the request.
7502    /// It should be used to set parameters which are not yet available through their own
7503    /// setters.
7504    ///
7505    /// Please note that this method must not be used to set any of the known parameters
7506    /// which have their own setter method. If done anyway, the request will fail.
7507    ///
7508    /// # Additional Parameters
7509    ///
7510    /// * *$.xgafv* (query-string) - V1 error format.
7511    /// * *access_token* (query-string) - OAuth access token.
7512    /// * *alt* (query-string) - Data format for response.
7513    /// * *callback* (query-string) - JSONP
7514    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7515    /// * *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.
7516    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7517    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7518    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7519    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7520    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7521    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceRestoreCall<'a, C>
7522    where
7523        T: AsRef<str>,
7524    {
7525        self._additional_params
7526            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7527        self
7528    }
7529
7530    /// Identifies the authorization scope for the method you are building.
7531    ///
7532    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7533    /// [`Scope::CloudPlatform`].
7534    ///
7535    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7536    /// tokens for more than one scope.
7537    ///
7538    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7539    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7540    /// sufficient, a read-write scope will do as well.
7541    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceRestoreCall<'a, C>
7542    where
7543        St: AsRef<str>,
7544    {
7545        self._scopes.insert(String::from(scope.as_ref()));
7546        self
7547    }
7548    /// Identifies the authorization scope(s) for the method you are building.
7549    ///
7550    /// See [`Self::add_scope()`] for details.
7551    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceRestoreCall<'a, C>
7552    where
7553        I: IntoIterator<Item = St>,
7554        St: AsRef<str>,
7555    {
7556        self._scopes
7557            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7558        self
7559    }
7560
7561    /// Removes all scopes, and no default scope will be used either.
7562    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7563    /// for details).
7564    pub fn clear_scopes(mut self) -> ProjectLocationInstanceRestoreCall<'a, C> {
7565        self._scopes.clear();
7566        self
7567    }
7568}
7569
7570/// Resume the standby instance (replica). WARNING: Any data written to the standby instance while paused will be lost when the replica is resumed.
7571///
7572/// A builder for the *locations.instances.resumeReplica* method supported by a *project* resource.
7573/// It is not used directly, but through a [`ProjectMethods`] instance.
7574///
7575/// # Example
7576///
7577/// Instantiate a resource method builder
7578///
7579/// ```test_harness,no_run
7580/// # extern crate hyper;
7581/// # extern crate hyper_rustls;
7582/// # extern crate google_file1 as file1;
7583/// use file1::api::ResumeReplicaRequest;
7584/// # async fn dox() {
7585/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7586///
7587/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7588/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7589/// #     .with_native_roots()
7590/// #     .unwrap()
7591/// #     .https_only()
7592/// #     .enable_http2()
7593/// #     .build();
7594///
7595/// # let executor = hyper_util::rt::TokioExecutor::new();
7596/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7597/// #     secret,
7598/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7599/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7600/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7601/// #     ),
7602/// # ).build().await.unwrap();
7603///
7604/// # let client = hyper_util::client::legacy::Client::builder(
7605/// #     hyper_util::rt::TokioExecutor::new()
7606/// # )
7607/// # .build(
7608/// #     hyper_rustls::HttpsConnectorBuilder::new()
7609/// #         .with_native_roots()
7610/// #         .unwrap()
7611/// #         .https_or_http()
7612/// #         .enable_http2()
7613/// #         .build()
7614/// # );
7615/// # let mut hub = CloudFilestore::new(client, auth);
7616/// // As the method needs a request, you would usually fill it with the desired information
7617/// // into the respective structure. Some of the parts shown here might not be applicable !
7618/// // Values shown here are possibly random and not representative !
7619/// let mut req = ResumeReplicaRequest::default();
7620///
7621/// // You can configure optional parameters by calling the respective setters at will, and
7622/// // execute the final call using `doit()`.
7623/// // Values shown here are possibly random and not representative !
7624/// let result = hub.projects().locations_instances_resume_replica(req, "name")
7625///              .doit().await;
7626/// # }
7627/// ```
7628pub struct ProjectLocationInstanceResumeReplicaCall<'a, C>
7629where
7630    C: 'a,
7631{
7632    hub: &'a CloudFilestore<C>,
7633    _request: ResumeReplicaRequest,
7634    _name: String,
7635    _delegate: Option<&'a mut dyn common::Delegate>,
7636    _additional_params: HashMap<String, String>,
7637    _scopes: BTreeSet<String>,
7638}
7639
7640impl<'a, C> common::CallBuilder for ProjectLocationInstanceResumeReplicaCall<'a, C> {}
7641
7642impl<'a, C> ProjectLocationInstanceResumeReplicaCall<'a, C>
7643where
7644    C: common::Connector,
7645{
7646    /// Perform the operation you have build so far.
7647    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7648        use std::borrow::Cow;
7649        use std::io::{Read, Seek};
7650
7651        use common::{url::Params, ToParts};
7652        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7653
7654        let mut dd = common::DefaultDelegate;
7655        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7656        dlg.begin(common::MethodInfo {
7657            id: "file.projects.locations.instances.resumeReplica",
7658            http_method: hyper::Method::POST,
7659        });
7660
7661        for &field in ["alt", "name"].iter() {
7662            if self._additional_params.contains_key(field) {
7663                dlg.finished(false);
7664                return Err(common::Error::FieldClash(field));
7665            }
7666        }
7667
7668        let mut params = Params::with_capacity(4 + self._additional_params.len());
7669        params.push("name", self._name);
7670
7671        params.extend(self._additional_params.iter());
7672
7673        params.push("alt", "json");
7674        let mut url = self.hub._base_url.clone() + "v1/{+name}:resumeReplica";
7675        if self._scopes.is_empty() {
7676            self._scopes
7677                .insert(Scope::CloudPlatform.as_ref().to_string());
7678        }
7679
7680        #[allow(clippy::single_element_loop)]
7681        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7682            url = params.uri_replacement(url, param_name, find_this, true);
7683        }
7684        {
7685            let to_remove = ["name"];
7686            params.remove_params(&to_remove);
7687        }
7688
7689        let url = params.parse_with_url(&url);
7690
7691        let mut json_mime_type = mime::APPLICATION_JSON;
7692        let mut request_value_reader = {
7693            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7694            common::remove_json_null_values(&mut value);
7695            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7696            serde_json::to_writer(&mut dst, &value).unwrap();
7697            dst
7698        };
7699        let request_size = request_value_reader
7700            .seek(std::io::SeekFrom::End(0))
7701            .unwrap();
7702        request_value_reader
7703            .seek(std::io::SeekFrom::Start(0))
7704            .unwrap();
7705
7706        loop {
7707            let token = match self
7708                .hub
7709                .auth
7710                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7711                .await
7712            {
7713                Ok(token) => token,
7714                Err(e) => match dlg.token(e) {
7715                    Ok(token) => token,
7716                    Err(e) => {
7717                        dlg.finished(false);
7718                        return Err(common::Error::MissingToken(e));
7719                    }
7720                },
7721            };
7722            request_value_reader
7723                .seek(std::io::SeekFrom::Start(0))
7724                .unwrap();
7725            let mut req_result = {
7726                let client = &self.hub.client;
7727                dlg.pre_request();
7728                let mut req_builder = hyper::Request::builder()
7729                    .method(hyper::Method::POST)
7730                    .uri(url.as_str())
7731                    .header(USER_AGENT, self.hub._user_agent.clone());
7732
7733                if let Some(token) = token.as_ref() {
7734                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7735                }
7736
7737                let request = req_builder
7738                    .header(CONTENT_TYPE, json_mime_type.to_string())
7739                    .header(CONTENT_LENGTH, request_size as u64)
7740                    .body(common::to_body(
7741                        request_value_reader.get_ref().clone().into(),
7742                    ));
7743
7744                client.request(request.unwrap()).await
7745            };
7746
7747            match req_result {
7748                Err(err) => {
7749                    if let common::Retry::After(d) = dlg.http_error(&err) {
7750                        sleep(d).await;
7751                        continue;
7752                    }
7753                    dlg.finished(false);
7754                    return Err(common::Error::HttpError(err));
7755                }
7756                Ok(res) => {
7757                    let (mut parts, body) = res.into_parts();
7758                    let mut body = common::Body::new(body);
7759                    if !parts.status.is_success() {
7760                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7761                        let error = serde_json::from_str(&common::to_string(&bytes));
7762                        let response = common::to_response(parts, bytes.into());
7763
7764                        if let common::Retry::After(d) =
7765                            dlg.http_failure(&response, error.as_ref().ok())
7766                        {
7767                            sleep(d).await;
7768                            continue;
7769                        }
7770
7771                        dlg.finished(false);
7772
7773                        return Err(match error {
7774                            Ok(value) => common::Error::BadRequest(value),
7775                            _ => common::Error::Failure(response),
7776                        });
7777                    }
7778                    let response = {
7779                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7780                        let encoded = common::to_string(&bytes);
7781                        match serde_json::from_str(&encoded) {
7782                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7783                            Err(error) => {
7784                                dlg.response_json_decode_error(&encoded, &error);
7785                                return Err(common::Error::JsonDecodeError(
7786                                    encoded.to_string(),
7787                                    error,
7788                                ));
7789                            }
7790                        }
7791                    };
7792
7793                    dlg.finished(true);
7794                    return Ok(response);
7795                }
7796            }
7797        }
7798    }
7799
7800    ///
7801    /// Sets the *request* property to the given value.
7802    ///
7803    /// Even though the property as already been set when instantiating this call,
7804    /// we provide this method for API completeness.
7805    pub fn request(
7806        mut self,
7807        new_value: ResumeReplicaRequest,
7808    ) -> ProjectLocationInstanceResumeReplicaCall<'a, C> {
7809        self._request = new_value;
7810        self
7811    }
7812    /// Required. The resource name of the instance, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}`.
7813    ///
7814    /// Sets the *name* path property to the given value.
7815    ///
7816    /// Even though the property as already been set when instantiating this call,
7817    /// we provide this method for API completeness.
7818    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceResumeReplicaCall<'a, C> {
7819        self._name = new_value.to_string();
7820        self
7821    }
7822    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7823    /// while executing the actual API request.
7824    ///
7825    /// ````text
7826    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7827    /// ````
7828    ///
7829    /// Sets the *delegate* property to the given value.
7830    pub fn delegate(
7831        mut self,
7832        new_value: &'a mut dyn common::Delegate,
7833    ) -> ProjectLocationInstanceResumeReplicaCall<'a, C> {
7834        self._delegate = Some(new_value);
7835        self
7836    }
7837
7838    /// Set any additional parameter of the query string used in the request.
7839    /// It should be used to set parameters which are not yet available through their own
7840    /// setters.
7841    ///
7842    /// Please note that this method must not be used to set any of the known parameters
7843    /// which have their own setter method. If done anyway, the request will fail.
7844    ///
7845    /// # Additional Parameters
7846    ///
7847    /// * *$.xgafv* (query-string) - V1 error format.
7848    /// * *access_token* (query-string) - OAuth access token.
7849    /// * *alt* (query-string) - Data format for response.
7850    /// * *callback* (query-string) - JSONP
7851    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7852    /// * *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.
7853    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7854    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7855    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7856    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7857    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7858    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceResumeReplicaCall<'a, C>
7859    where
7860        T: AsRef<str>,
7861    {
7862        self._additional_params
7863            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7864        self
7865    }
7866
7867    /// Identifies the authorization scope for the method you are building.
7868    ///
7869    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7870    /// [`Scope::CloudPlatform`].
7871    ///
7872    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7873    /// tokens for more than one scope.
7874    ///
7875    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7876    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7877    /// sufficient, a read-write scope will do as well.
7878    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceResumeReplicaCall<'a, C>
7879    where
7880        St: AsRef<str>,
7881    {
7882        self._scopes.insert(String::from(scope.as_ref()));
7883        self
7884    }
7885    /// Identifies the authorization scope(s) for the method you are building.
7886    ///
7887    /// See [`Self::add_scope()`] for details.
7888    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceResumeReplicaCall<'a, C>
7889    where
7890        I: IntoIterator<Item = St>,
7891        St: AsRef<str>,
7892    {
7893        self._scopes
7894            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7895        self
7896    }
7897
7898    /// Removes all scopes, and no default scope will be used either.
7899    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7900    /// for details).
7901    pub fn clear_scopes(mut self) -> ProjectLocationInstanceResumeReplicaCall<'a, C> {
7902        self._scopes.clear();
7903        self
7904    }
7905}
7906
7907/// Revert an existing instance's file system to a specified snapshot.
7908///
7909/// A builder for the *locations.instances.revert* method supported by a *project* resource.
7910/// It is not used directly, but through a [`ProjectMethods`] instance.
7911///
7912/// # Example
7913///
7914/// Instantiate a resource method builder
7915///
7916/// ```test_harness,no_run
7917/// # extern crate hyper;
7918/// # extern crate hyper_rustls;
7919/// # extern crate google_file1 as file1;
7920/// use file1::api::RevertInstanceRequest;
7921/// # async fn dox() {
7922/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7923///
7924/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7925/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7926/// #     .with_native_roots()
7927/// #     .unwrap()
7928/// #     .https_only()
7929/// #     .enable_http2()
7930/// #     .build();
7931///
7932/// # let executor = hyper_util::rt::TokioExecutor::new();
7933/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7934/// #     secret,
7935/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7936/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7937/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7938/// #     ),
7939/// # ).build().await.unwrap();
7940///
7941/// # let client = hyper_util::client::legacy::Client::builder(
7942/// #     hyper_util::rt::TokioExecutor::new()
7943/// # )
7944/// # .build(
7945/// #     hyper_rustls::HttpsConnectorBuilder::new()
7946/// #         .with_native_roots()
7947/// #         .unwrap()
7948/// #         .https_or_http()
7949/// #         .enable_http2()
7950/// #         .build()
7951/// # );
7952/// # let mut hub = CloudFilestore::new(client, auth);
7953/// // As the method needs a request, you would usually fill it with the desired information
7954/// // into the respective structure. Some of the parts shown here might not be applicable !
7955/// // Values shown here are possibly random and not representative !
7956/// let mut req = RevertInstanceRequest::default();
7957///
7958/// // You can configure optional parameters by calling the respective setters at will, and
7959/// // execute the final call using `doit()`.
7960/// // Values shown here are possibly random and not representative !
7961/// let result = hub.projects().locations_instances_revert(req, "name")
7962///              .doit().await;
7963/// # }
7964/// ```
7965pub struct ProjectLocationInstanceRevertCall<'a, C>
7966where
7967    C: 'a,
7968{
7969    hub: &'a CloudFilestore<C>,
7970    _request: RevertInstanceRequest,
7971    _name: String,
7972    _delegate: Option<&'a mut dyn common::Delegate>,
7973    _additional_params: HashMap<String, String>,
7974    _scopes: BTreeSet<String>,
7975}
7976
7977impl<'a, C> common::CallBuilder for ProjectLocationInstanceRevertCall<'a, C> {}
7978
7979impl<'a, C> ProjectLocationInstanceRevertCall<'a, C>
7980where
7981    C: common::Connector,
7982{
7983    /// Perform the operation you have build so far.
7984    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7985        use std::borrow::Cow;
7986        use std::io::{Read, Seek};
7987
7988        use common::{url::Params, ToParts};
7989        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7990
7991        let mut dd = common::DefaultDelegate;
7992        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7993        dlg.begin(common::MethodInfo {
7994            id: "file.projects.locations.instances.revert",
7995            http_method: hyper::Method::POST,
7996        });
7997
7998        for &field in ["alt", "name"].iter() {
7999            if self._additional_params.contains_key(field) {
8000                dlg.finished(false);
8001                return Err(common::Error::FieldClash(field));
8002            }
8003        }
8004
8005        let mut params = Params::with_capacity(4 + self._additional_params.len());
8006        params.push("name", self._name);
8007
8008        params.extend(self._additional_params.iter());
8009
8010        params.push("alt", "json");
8011        let mut url = self.hub._base_url.clone() + "v1/{+name}:revert";
8012        if self._scopes.is_empty() {
8013            self._scopes
8014                .insert(Scope::CloudPlatform.as_ref().to_string());
8015        }
8016
8017        #[allow(clippy::single_element_loop)]
8018        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8019            url = params.uri_replacement(url, param_name, find_this, true);
8020        }
8021        {
8022            let to_remove = ["name"];
8023            params.remove_params(&to_remove);
8024        }
8025
8026        let url = params.parse_with_url(&url);
8027
8028        let mut json_mime_type = mime::APPLICATION_JSON;
8029        let mut request_value_reader = {
8030            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8031            common::remove_json_null_values(&mut value);
8032            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8033            serde_json::to_writer(&mut dst, &value).unwrap();
8034            dst
8035        };
8036        let request_size = request_value_reader
8037            .seek(std::io::SeekFrom::End(0))
8038            .unwrap();
8039        request_value_reader
8040            .seek(std::io::SeekFrom::Start(0))
8041            .unwrap();
8042
8043        loop {
8044            let token = match self
8045                .hub
8046                .auth
8047                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8048                .await
8049            {
8050                Ok(token) => token,
8051                Err(e) => match dlg.token(e) {
8052                    Ok(token) => token,
8053                    Err(e) => {
8054                        dlg.finished(false);
8055                        return Err(common::Error::MissingToken(e));
8056                    }
8057                },
8058            };
8059            request_value_reader
8060                .seek(std::io::SeekFrom::Start(0))
8061                .unwrap();
8062            let mut req_result = {
8063                let client = &self.hub.client;
8064                dlg.pre_request();
8065                let mut req_builder = hyper::Request::builder()
8066                    .method(hyper::Method::POST)
8067                    .uri(url.as_str())
8068                    .header(USER_AGENT, self.hub._user_agent.clone());
8069
8070                if let Some(token) = token.as_ref() {
8071                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8072                }
8073
8074                let request = req_builder
8075                    .header(CONTENT_TYPE, json_mime_type.to_string())
8076                    .header(CONTENT_LENGTH, request_size as u64)
8077                    .body(common::to_body(
8078                        request_value_reader.get_ref().clone().into(),
8079                    ));
8080
8081                client.request(request.unwrap()).await
8082            };
8083
8084            match req_result {
8085                Err(err) => {
8086                    if let common::Retry::After(d) = dlg.http_error(&err) {
8087                        sleep(d).await;
8088                        continue;
8089                    }
8090                    dlg.finished(false);
8091                    return Err(common::Error::HttpError(err));
8092                }
8093                Ok(res) => {
8094                    let (mut parts, body) = res.into_parts();
8095                    let mut body = common::Body::new(body);
8096                    if !parts.status.is_success() {
8097                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8098                        let error = serde_json::from_str(&common::to_string(&bytes));
8099                        let response = common::to_response(parts, bytes.into());
8100
8101                        if let common::Retry::After(d) =
8102                            dlg.http_failure(&response, error.as_ref().ok())
8103                        {
8104                            sleep(d).await;
8105                            continue;
8106                        }
8107
8108                        dlg.finished(false);
8109
8110                        return Err(match error {
8111                            Ok(value) => common::Error::BadRequest(value),
8112                            _ => common::Error::Failure(response),
8113                        });
8114                    }
8115                    let response = {
8116                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8117                        let encoded = common::to_string(&bytes);
8118                        match serde_json::from_str(&encoded) {
8119                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8120                            Err(error) => {
8121                                dlg.response_json_decode_error(&encoded, &error);
8122                                return Err(common::Error::JsonDecodeError(
8123                                    encoded.to_string(),
8124                                    error,
8125                                ));
8126                            }
8127                        }
8128                    };
8129
8130                    dlg.finished(true);
8131                    return Ok(response);
8132                }
8133            }
8134        }
8135    }
8136
8137    ///
8138    /// Sets the *request* property to the given value.
8139    ///
8140    /// Even though the property as already been set when instantiating this call,
8141    /// we provide this method for API completeness.
8142    pub fn request(
8143        mut self,
8144        new_value: RevertInstanceRequest,
8145    ) -> ProjectLocationInstanceRevertCall<'a, C> {
8146        self._request = new_value;
8147        self
8148    }
8149    /// Required. The resource name of the instance, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}`.
8150    ///
8151    /// Sets the *name* path property to the given value.
8152    ///
8153    /// Even though the property as already been set when instantiating this call,
8154    /// we provide this method for API completeness.
8155    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceRevertCall<'a, C> {
8156        self._name = new_value.to_string();
8157        self
8158    }
8159    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8160    /// while executing the actual API request.
8161    ///
8162    /// ````text
8163    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8164    /// ````
8165    ///
8166    /// Sets the *delegate* property to the given value.
8167    pub fn delegate(
8168        mut self,
8169        new_value: &'a mut dyn common::Delegate,
8170    ) -> ProjectLocationInstanceRevertCall<'a, C> {
8171        self._delegate = Some(new_value);
8172        self
8173    }
8174
8175    /// Set any additional parameter of the query string used in the request.
8176    /// It should be used to set parameters which are not yet available through their own
8177    /// setters.
8178    ///
8179    /// Please note that this method must not be used to set any of the known parameters
8180    /// which have their own setter method. If done anyway, the request will fail.
8181    ///
8182    /// # Additional Parameters
8183    ///
8184    /// * *$.xgafv* (query-string) - V1 error format.
8185    /// * *access_token* (query-string) - OAuth access token.
8186    /// * *alt* (query-string) - Data format for response.
8187    /// * *callback* (query-string) - JSONP
8188    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8189    /// * *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.
8190    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8191    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8192    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8193    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8194    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8195    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceRevertCall<'a, C>
8196    where
8197        T: AsRef<str>,
8198    {
8199        self._additional_params
8200            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8201        self
8202    }
8203
8204    /// Identifies the authorization scope for the method you are building.
8205    ///
8206    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8207    /// [`Scope::CloudPlatform`].
8208    ///
8209    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8210    /// tokens for more than one scope.
8211    ///
8212    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8213    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8214    /// sufficient, a read-write scope will do as well.
8215    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceRevertCall<'a, C>
8216    where
8217        St: AsRef<str>,
8218    {
8219        self._scopes.insert(String::from(scope.as_ref()));
8220        self
8221    }
8222    /// Identifies the authorization scope(s) for the method you are building.
8223    ///
8224    /// See [`Self::add_scope()`] for details.
8225    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceRevertCall<'a, C>
8226    where
8227        I: IntoIterator<Item = St>,
8228        St: AsRef<str>,
8229    {
8230        self._scopes
8231            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8232        self
8233    }
8234
8235    /// Removes all scopes, and no default scope will be used either.
8236    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8237    /// for details).
8238    pub fn clear_scopes(mut self) -> ProjectLocationInstanceRevertCall<'a, C> {
8239        self._scopes.clear();
8240        self
8241    }
8242}
8243
8244/// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of `1`, corresponding to `Code.CANCELLED`.
8245///
8246/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
8247/// It is not used directly, but through a [`ProjectMethods`] instance.
8248///
8249/// # Example
8250///
8251/// Instantiate a resource method builder
8252///
8253/// ```test_harness,no_run
8254/// # extern crate hyper;
8255/// # extern crate hyper_rustls;
8256/// # extern crate google_file1 as file1;
8257/// use file1::api::CancelOperationRequest;
8258/// # async fn dox() {
8259/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8260///
8261/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8262/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8263/// #     .with_native_roots()
8264/// #     .unwrap()
8265/// #     .https_only()
8266/// #     .enable_http2()
8267/// #     .build();
8268///
8269/// # let executor = hyper_util::rt::TokioExecutor::new();
8270/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8271/// #     secret,
8272/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8273/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8274/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8275/// #     ),
8276/// # ).build().await.unwrap();
8277///
8278/// # let client = hyper_util::client::legacy::Client::builder(
8279/// #     hyper_util::rt::TokioExecutor::new()
8280/// # )
8281/// # .build(
8282/// #     hyper_rustls::HttpsConnectorBuilder::new()
8283/// #         .with_native_roots()
8284/// #         .unwrap()
8285/// #         .https_or_http()
8286/// #         .enable_http2()
8287/// #         .build()
8288/// # );
8289/// # let mut hub = CloudFilestore::new(client, auth);
8290/// // As the method needs a request, you would usually fill it with the desired information
8291/// // into the respective structure. Some of the parts shown here might not be applicable !
8292/// // Values shown here are possibly random and not representative !
8293/// let mut req = CancelOperationRequest::default();
8294///
8295/// // You can configure optional parameters by calling the respective setters at will, and
8296/// // execute the final call using `doit()`.
8297/// // Values shown here are possibly random and not representative !
8298/// let result = hub.projects().locations_operations_cancel(req, "name")
8299///              .doit().await;
8300/// # }
8301/// ```
8302pub struct ProjectLocationOperationCancelCall<'a, C>
8303where
8304    C: 'a,
8305{
8306    hub: &'a CloudFilestore<C>,
8307    _request: CancelOperationRequest,
8308    _name: String,
8309    _delegate: Option<&'a mut dyn common::Delegate>,
8310    _additional_params: HashMap<String, String>,
8311    _scopes: BTreeSet<String>,
8312}
8313
8314impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
8315
8316impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
8317where
8318    C: common::Connector,
8319{
8320    /// Perform the operation you have build so far.
8321    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
8322        use std::borrow::Cow;
8323        use std::io::{Read, Seek};
8324
8325        use common::{url::Params, ToParts};
8326        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8327
8328        let mut dd = common::DefaultDelegate;
8329        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8330        dlg.begin(common::MethodInfo {
8331            id: "file.projects.locations.operations.cancel",
8332            http_method: hyper::Method::POST,
8333        });
8334
8335        for &field in ["alt", "name"].iter() {
8336            if self._additional_params.contains_key(field) {
8337                dlg.finished(false);
8338                return Err(common::Error::FieldClash(field));
8339            }
8340        }
8341
8342        let mut params = Params::with_capacity(4 + self._additional_params.len());
8343        params.push("name", self._name);
8344
8345        params.extend(self._additional_params.iter());
8346
8347        params.push("alt", "json");
8348        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
8349        if self._scopes.is_empty() {
8350            self._scopes
8351                .insert(Scope::CloudPlatform.as_ref().to_string());
8352        }
8353
8354        #[allow(clippy::single_element_loop)]
8355        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8356            url = params.uri_replacement(url, param_name, find_this, true);
8357        }
8358        {
8359            let to_remove = ["name"];
8360            params.remove_params(&to_remove);
8361        }
8362
8363        let url = params.parse_with_url(&url);
8364
8365        let mut json_mime_type = mime::APPLICATION_JSON;
8366        let mut request_value_reader = {
8367            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8368            common::remove_json_null_values(&mut value);
8369            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8370            serde_json::to_writer(&mut dst, &value).unwrap();
8371            dst
8372        };
8373        let request_size = request_value_reader
8374            .seek(std::io::SeekFrom::End(0))
8375            .unwrap();
8376        request_value_reader
8377            .seek(std::io::SeekFrom::Start(0))
8378            .unwrap();
8379
8380        loop {
8381            let token = match self
8382                .hub
8383                .auth
8384                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8385                .await
8386            {
8387                Ok(token) => token,
8388                Err(e) => match dlg.token(e) {
8389                    Ok(token) => token,
8390                    Err(e) => {
8391                        dlg.finished(false);
8392                        return Err(common::Error::MissingToken(e));
8393                    }
8394                },
8395            };
8396            request_value_reader
8397                .seek(std::io::SeekFrom::Start(0))
8398                .unwrap();
8399            let mut req_result = {
8400                let client = &self.hub.client;
8401                dlg.pre_request();
8402                let mut req_builder = hyper::Request::builder()
8403                    .method(hyper::Method::POST)
8404                    .uri(url.as_str())
8405                    .header(USER_AGENT, self.hub._user_agent.clone());
8406
8407                if let Some(token) = token.as_ref() {
8408                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8409                }
8410
8411                let request = req_builder
8412                    .header(CONTENT_TYPE, json_mime_type.to_string())
8413                    .header(CONTENT_LENGTH, request_size as u64)
8414                    .body(common::to_body(
8415                        request_value_reader.get_ref().clone().into(),
8416                    ));
8417
8418                client.request(request.unwrap()).await
8419            };
8420
8421            match req_result {
8422                Err(err) => {
8423                    if let common::Retry::After(d) = dlg.http_error(&err) {
8424                        sleep(d).await;
8425                        continue;
8426                    }
8427                    dlg.finished(false);
8428                    return Err(common::Error::HttpError(err));
8429                }
8430                Ok(res) => {
8431                    let (mut parts, body) = res.into_parts();
8432                    let mut body = common::Body::new(body);
8433                    if !parts.status.is_success() {
8434                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8435                        let error = serde_json::from_str(&common::to_string(&bytes));
8436                        let response = common::to_response(parts, bytes.into());
8437
8438                        if let common::Retry::After(d) =
8439                            dlg.http_failure(&response, error.as_ref().ok())
8440                        {
8441                            sleep(d).await;
8442                            continue;
8443                        }
8444
8445                        dlg.finished(false);
8446
8447                        return Err(match error {
8448                            Ok(value) => common::Error::BadRequest(value),
8449                            _ => common::Error::Failure(response),
8450                        });
8451                    }
8452                    let response = {
8453                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8454                        let encoded = common::to_string(&bytes);
8455                        match serde_json::from_str(&encoded) {
8456                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8457                            Err(error) => {
8458                                dlg.response_json_decode_error(&encoded, &error);
8459                                return Err(common::Error::JsonDecodeError(
8460                                    encoded.to_string(),
8461                                    error,
8462                                ));
8463                            }
8464                        }
8465                    };
8466
8467                    dlg.finished(true);
8468                    return Ok(response);
8469                }
8470            }
8471        }
8472    }
8473
8474    ///
8475    /// Sets the *request* property to the given value.
8476    ///
8477    /// Even though the property as already been set when instantiating this call,
8478    /// we provide this method for API completeness.
8479    pub fn request(
8480        mut self,
8481        new_value: CancelOperationRequest,
8482    ) -> ProjectLocationOperationCancelCall<'a, C> {
8483        self._request = new_value;
8484        self
8485    }
8486    /// The name of the operation resource to be cancelled.
8487    ///
8488    /// Sets the *name* path property to the given value.
8489    ///
8490    /// Even though the property as already been set when instantiating this call,
8491    /// we provide this method for API completeness.
8492    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
8493        self._name = new_value.to_string();
8494        self
8495    }
8496    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8497    /// while executing the actual API request.
8498    ///
8499    /// ````text
8500    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8501    /// ````
8502    ///
8503    /// Sets the *delegate* property to the given value.
8504    pub fn delegate(
8505        mut self,
8506        new_value: &'a mut dyn common::Delegate,
8507    ) -> ProjectLocationOperationCancelCall<'a, C> {
8508        self._delegate = Some(new_value);
8509        self
8510    }
8511
8512    /// Set any additional parameter of the query string used in the request.
8513    /// It should be used to set parameters which are not yet available through their own
8514    /// setters.
8515    ///
8516    /// Please note that this method must not be used to set any of the known parameters
8517    /// which have their own setter method. If done anyway, the request will fail.
8518    ///
8519    /// # Additional Parameters
8520    ///
8521    /// * *$.xgafv* (query-string) - V1 error format.
8522    /// * *access_token* (query-string) - OAuth access token.
8523    /// * *alt* (query-string) - Data format for response.
8524    /// * *callback* (query-string) - JSONP
8525    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8526    /// * *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.
8527    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8528    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8529    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8530    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8531    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8532    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
8533    where
8534        T: AsRef<str>,
8535    {
8536        self._additional_params
8537            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8538        self
8539    }
8540
8541    /// Identifies the authorization scope for the method you are building.
8542    ///
8543    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8544    /// [`Scope::CloudPlatform`].
8545    ///
8546    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8547    /// tokens for more than one scope.
8548    ///
8549    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8550    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8551    /// sufficient, a read-write scope will do as well.
8552    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
8553    where
8554        St: AsRef<str>,
8555    {
8556        self._scopes.insert(String::from(scope.as_ref()));
8557        self
8558    }
8559    /// Identifies the authorization scope(s) for the method you are building.
8560    ///
8561    /// See [`Self::add_scope()`] for details.
8562    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
8563    where
8564        I: IntoIterator<Item = St>,
8565        St: AsRef<str>,
8566    {
8567        self._scopes
8568            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8569        self
8570    }
8571
8572    /// Removes all scopes, and no default scope will be used either.
8573    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8574    /// for details).
8575    pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
8576        self._scopes.clear();
8577        self
8578    }
8579}
8580
8581/// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
8582///
8583/// A builder for the *locations.operations.delete* method supported by a *project* resource.
8584/// It is not used directly, but through a [`ProjectMethods`] instance.
8585///
8586/// # Example
8587///
8588/// Instantiate a resource method builder
8589///
8590/// ```test_harness,no_run
8591/// # extern crate hyper;
8592/// # extern crate hyper_rustls;
8593/// # extern crate google_file1 as file1;
8594/// # async fn dox() {
8595/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8596///
8597/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8598/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8599/// #     .with_native_roots()
8600/// #     .unwrap()
8601/// #     .https_only()
8602/// #     .enable_http2()
8603/// #     .build();
8604///
8605/// # let executor = hyper_util::rt::TokioExecutor::new();
8606/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8607/// #     secret,
8608/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8609/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8610/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8611/// #     ),
8612/// # ).build().await.unwrap();
8613///
8614/// # let client = hyper_util::client::legacy::Client::builder(
8615/// #     hyper_util::rt::TokioExecutor::new()
8616/// # )
8617/// # .build(
8618/// #     hyper_rustls::HttpsConnectorBuilder::new()
8619/// #         .with_native_roots()
8620/// #         .unwrap()
8621/// #         .https_or_http()
8622/// #         .enable_http2()
8623/// #         .build()
8624/// # );
8625/// # let mut hub = CloudFilestore::new(client, auth);
8626/// // You can configure optional parameters by calling the respective setters at will, and
8627/// // execute the final call using `doit()`.
8628/// // Values shown here are possibly random and not representative !
8629/// let result = hub.projects().locations_operations_delete("name")
8630///              .doit().await;
8631/// # }
8632/// ```
8633pub struct ProjectLocationOperationDeleteCall<'a, C>
8634where
8635    C: 'a,
8636{
8637    hub: &'a CloudFilestore<C>,
8638    _name: String,
8639    _delegate: Option<&'a mut dyn common::Delegate>,
8640    _additional_params: HashMap<String, String>,
8641    _scopes: BTreeSet<String>,
8642}
8643
8644impl<'a, C> common::CallBuilder for ProjectLocationOperationDeleteCall<'a, C> {}
8645
8646impl<'a, C> ProjectLocationOperationDeleteCall<'a, C>
8647where
8648    C: common::Connector,
8649{
8650    /// Perform the operation you have build so far.
8651    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
8652        use std::borrow::Cow;
8653        use std::io::{Read, Seek};
8654
8655        use common::{url::Params, ToParts};
8656        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8657
8658        let mut dd = common::DefaultDelegate;
8659        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8660        dlg.begin(common::MethodInfo {
8661            id: "file.projects.locations.operations.delete",
8662            http_method: hyper::Method::DELETE,
8663        });
8664
8665        for &field in ["alt", "name"].iter() {
8666            if self._additional_params.contains_key(field) {
8667                dlg.finished(false);
8668                return Err(common::Error::FieldClash(field));
8669            }
8670        }
8671
8672        let mut params = Params::with_capacity(3 + self._additional_params.len());
8673        params.push("name", self._name);
8674
8675        params.extend(self._additional_params.iter());
8676
8677        params.push("alt", "json");
8678        let mut url = self.hub._base_url.clone() + "v1/{+name}";
8679        if self._scopes.is_empty() {
8680            self._scopes
8681                .insert(Scope::CloudPlatform.as_ref().to_string());
8682        }
8683
8684        #[allow(clippy::single_element_loop)]
8685        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8686            url = params.uri_replacement(url, param_name, find_this, true);
8687        }
8688        {
8689            let to_remove = ["name"];
8690            params.remove_params(&to_remove);
8691        }
8692
8693        let url = params.parse_with_url(&url);
8694
8695        loop {
8696            let token = match self
8697                .hub
8698                .auth
8699                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8700                .await
8701            {
8702                Ok(token) => token,
8703                Err(e) => match dlg.token(e) {
8704                    Ok(token) => token,
8705                    Err(e) => {
8706                        dlg.finished(false);
8707                        return Err(common::Error::MissingToken(e));
8708                    }
8709                },
8710            };
8711            let mut req_result = {
8712                let client = &self.hub.client;
8713                dlg.pre_request();
8714                let mut req_builder = hyper::Request::builder()
8715                    .method(hyper::Method::DELETE)
8716                    .uri(url.as_str())
8717                    .header(USER_AGENT, self.hub._user_agent.clone());
8718
8719                if let Some(token) = token.as_ref() {
8720                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8721                }
8722
8723                let request = req_builder
8724                    .header(CONTENT_LENGTH, 0_u64)
8725                    .body(common::to_body::<String>(None));
8726
8727                client.request(request.unwrap()).await
8728            };
8729
8730            match req_result {
8731                Err(err) => {
8732                    if let common::Retry::After(d) = dlg.http_error(&err) {
8733                        sleep(d).await;
8734                        continue;
8735                    }
8736                    dlg.finished(false);
8737                    return Err(common::Error::HttpError(err));
8738                }
8739                Ok(res) => {
8740                    let (mut parts, body) = res.into_parts();
8741                    let mut body = common::Body::new(body);
8742                    if !parts.status.is_success() {
8743                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8744                        let error = serde_json::from_str(&common::to_string(&bytes));
8745                        let response = common::to_response(parts, bytes.into());
8746
8747                        if let common::Retry::After(d) =
8748                            dlg.http_failure(&response, error.as_ref().ok())
8749                        {
8750                            sleep(d).await;
8751                            continue;
8752                        }
8753
8754                        dlg.finished(false);
8755
8756                        return Err(match error {
8757                            Ok(value) => common::Error::BadRequest(value),
8758                            _ => common::Error::Failure(response),
8759                        });
8760                    }
8761                    let response = {
8762                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8763                        let encoded = common::to_string(&bytes);
8764                        match serde_json::from_str(&encoded) {
8765                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8766                            Err(error) => {
8767                                dlg.response_json_decode_error(&encoded, &error);
8768                                return Err(common::Error::JsonDecodeError(
8769                                    encoded.to_string(),
8770                                    error,
8771                                ));
8772                            }
8773                        }
8774                    };
8775
8776                    dlg.finished(true);
8777                    return Ok(response);
8778                }
8779            }
8780        }
8781    }
8782
8783    /// The name of the operation resource to be deleted.
8784    ///
8785    /// Sets the *name* path property to the given value.
8786    ///
8787    /// Even though the property as already been set when instantiating this call,
8788    /// we provide this method for API completeness.
8789    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationDeleteCall<'a, C> {
8790        self._name = new_value.to_string();
8791        self
8792    }
8793    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8794    /// while executing the actual API request.
8795    ///
8796    /// ````text
8797    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8798    /// ````
8799    ///
8800    /// Sets the *delegate* property to the given value.
8801    pub fn delegate(
8802        mut self,
8803        new_value: &'a mut dyn common::Delegate,
8804    ) -> ProjectLocationOperationDeleteCall<'a, C> {
8805        self._delegate = Some(new_value);
8806        self
8807    }
8808
8809    /// Set any additional parameter of the query string used in the request.
8810    /// It should be used to set parameters which are not yet available through their own
8811    /// setters.
8812    ///
8813    /// Please note that this method must not be used to set any of the known parameters
8814    /// which have their own setter method. If done anyway, the request will fail.
8815    ///
8816    /// # Additional Parameters
8817    ///
8818    /// * *$.xgafv* (query-string) - V1 error format.
8819    /// * *access_token* (query-string) - OAuth access token.
8820    /// * *alt* (query-string) - Data format for response.
8821    /// * *callback* (query-string) - JSONP
8822    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8823    /// * *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.
8824    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8825    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8826    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8827    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8828    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8829    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationDeleteCall<'a, C>
8830    where
8831        T: AsRef<str>,
8832    {
8833        self._additional_params
8834            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8835        self
8836    }
8837
8838    /// Identifies the authorization scope for the method you are building.
8839    ///
8840    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8841    /// [`Scope::CloudPlatform`].
8842    ///
8843    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8844    /// tokens for more than one scope.
8845    ///
8846    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8847    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8848    /// sufficient, a read-write scope will do as well.
8849    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationDeleteCall<'a, C>
8850    where
8851        St: AsRef<str>,
8852    {
8853        self._scopes.insert(String::from(scope.as_ref()));
8854        self
8855    }
8856    /// Identifies the authorization scope(s) for the method you are building.
8857    ///
8858    /// See [`Self::add_scope()`] for details.
8859    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationDeleteCall<'a, C>
8860    where
8861        I: IntoIterator<Item = St>,
8862        St: AsRef<str>,
8863    {
8864        self._scopes
8865            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8866        self
8867    }
8868
8869    /// Removes all scopes, and no default scope will be used either.
8870    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8871    /// for details).
8872    pub fn clear_scopes(mut self) -> ProjectLocationOperationDeleteCall<'a, C> {
8873        self._scopes.clear();
8874        self
8875    }
8876}
8877
8878/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
8879///
8880/// A builder for the *locations.operations.get* method supported by a *project* resource.
8881/// It is not used directly, but through a [`ProjectMethods`] instance.
8882///
8883/// # Example
8884///
8885/// Instantiate a resource method builder
8886///
8887/// ```test_harness,no_run
8888/// # extern crate hyper;
8889/// # extern crate hyper_rustls;
8890/// # extern crate google_file1 as file1;
8891/// # async fn dox() {
8892/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8893///
8894/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8895/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8896/// #     .with_native_roots()
8897/// #     .unwrap()
8898/// #     .https_only()
8899/// #     .enable_http2()
8900/// #     .build();
8901///
8902/// # let executor = hyper_util::rt::TokioExecutor::new();
8903/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8904/// #     secret,
8905/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8906/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8907/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8908/// #     ),
8909/// # ).build().await.unwrap();
8910///
8911/// # let client = hyper_util::client::legacy::Client::builder(
8912/// #     hyper_util::rt::TokioExecutor::new()
8913/// # )
8914/// # .build(
8915/// #     hyper_rustls::HttpsConnectorBuilder::new()
8916/// #         .with_native_roots()
8917/// #         .unwrap()
8918/// #         .https_or_http()
8919/// #         .enable_http2()
8920/// #         .build()
8921/// # );
8922/// # let mut hub = CloudFilestore::new(client, auth);
8923/// // You can configure optional parameters by calling the respective setters at will, and
8924/// // execute the final call using `doit()`.
8925/// // Values shown here are possibly random and not representative !
8926/// let result = hub.projects().locations_operations_get("name")
8927///              .doit().await;
8928/// # }
8929/// ```
8930pub struct ProjectLocationOperationGetCall<'a, C>
8931where
8932    C: 'a,
8933{
8934    hub: &'a CloudFilestore<C>,
8935    _name: String,
8936    _delegate: Option<&'a mut dyn common::Delegate>,
8937    _additional_params: HashMap<String, String>,
8938    _scopes: BTreeSet<String>,
8939}
8940
8941impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
8942
8943impl<'a, C> ProjectLocationOperationGetCall<'a, C>
8944where
8945    C: common::Connector,
8946{
8947    /// Perform the operation you have build so far.
8948    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8949        use std::borrow::Cow;
8950        use std::io::{Read, Seek};
8951
8952        use common::{url::Params, ToParts};
8953        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8954
8955        let mut dd = common::DefaultDelegate;
8956        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8957        dlg.begin(common::MethodInfo {
8958            id: "file.projects.locations.operations.get",
8959            http_method: hyper::Method::GET,
8960        });
8961
8962        for &field in ["alt", "name"].iter() {
8963            if self._additional_params.contains_key(field) {
8964                dlg.finished(false);
8965                return Err(common::Error::FieldClash(field));
8966            }
8967        }
8968
8969        let mut params = Params::with_capacity(3 + self._additional_params.len());
8970        params.push("name", self._name);
8971
8972        params.extend(self._additional_params.iter());
8973
8974        params.push("alt", "json");
8975        let mut url = self.hub._base_url.clone() + "v1/{+name}";
8976        if self._scopes.is_empty() {
8977            self._scopes
8978                .insert(Scope::CloudPlatform.as_ref().to_string());
8979        }
8980
8981        #[allow(clippy::single_element_loop)]
8982        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8983            url = params.uri_replacement(url, param_name, find_this, true);
8984        }
8985        {
8986            let to_remove = ["name"];
8987            params.remove_params(&to_remove);
8988        }
8989
8990        let url = params.parse_with_url(&url);
8991
8992        loop {
8993            let token = match self
8994                .hub
8995                .auth
8996                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8997                .await
8998            {
8999                Ok(token) => token,
9000                Err(e) => match dlg.token(e) {
9001                    Ok(token) => token,
9002                    Err(e) => {
9003                        dlg.finished(false);
9004                        return Err(common::Error::MissingToken(e));
9005                    }
9006                },
9007            };
9008            let mut req_result = {
9009                let client = &self.hub.client;
9010                dlg.pre_request();
9011                let mut req_builder = hyper::Request::builder()
9012                    .method(hyper::Method::GET)
9013                    .uri(url.as_str())
9014                    .header(USER_AGENT, self.hub._user_agent.clone());
9015
9016                if let Some(token) = token.as_ref() {
9017                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9018                }
9019
9020                let request = req_builder
9021                    .header(CONTENT_LENGTH, 0_u64)
9022                    .body(common::to_body::<String>(None));
9023
9024                client.request(request.unwrap()).await
9025            };
9026
9027            match req_result {
9028                Err(err) => {
9029                    if let common::Retry::After(d) = dlg.http_error(&err) {
9030                        sleep(d).await;
9031                        continue;
9032                    }
9033                    dlg.finished(false);
9034                    return Err(common::Error::HttpError(err));
9035                }
9036                Ok(res) => {
9037                    let (mut parts, body) = res.into_parts();
9038                    let mut body = common::Body::new(body);
9039                    if !parts.status.is_success() {
9040                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9041                        let error = serde_json::from_str(&common::to_string(&bytes));
9042                        let response = common::to_response(parts, bytes.into());
9043
9044                        if let common::Retry::After(d) =
9045                            dlg.http_failure(&response, error.as_ref().ok())
9046                        {
9047                            sleep(d).await;
9048                            continue;
9049                        }
9050
9051                        dlg.finished(false);
9052
9053                        return Err(match error {
9054                            Ok(value) => common::Error::BadRequest(value),
9055                            _ => common::Error::Failure(response),
9056                        });
9057                    }
9058                    let response = {
9059                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9060                        let encoded = common::to_string(&bytes);
9061                        match serde_json::from_str(&encoded) {
9062                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9063                            Err(error) => {
9064                                dlg.response_json_decode_error(&encoded, &error);
9065                                return Err(common::Error::JsonDecodeError(
9066                                    encoded.to_string(),
9067                                    error,
9068                                ));
9069                            }
9070                        }
9071                    };
9072
9073                    dlg.finished(true);
9074                    return Ok(response);
9075                }
9076            }
9077        }
9078    }
9079
9080    /// The name of the operation resource.
9081    ///
9082    /// Sets the *name* path property to the given value.
9083    ///
9084    /// Even though the property as already been set when instantiating this call,
9085    /// we provide this method for API completeness.
9086    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
9087        self._name = new_value.to_string();
9088        self
9089    }
9090    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9091    /// while executing the actual API request.
9092    ///
9093    /// ````text
9094    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9095    /// ````
9096    ///
9097    /// Sets the *delegate* property to the given value.
9098    pub fn delegate(
9099        mut self,
9100        new_value: &'a mut dyn common::Delegate,
9101    ) -> ProjectLocationOperationGetCall<'a, C> {
9102        self._delegate = Some(new_value);
9103        self
9104    }
9105
9106    /// Set any additional parameter of the query string used in the request.
9107    /// It should be used to set parameters which are not yet available through their own
9108    /// setters.
9109    ///
9110    /// Please note that this method must not be used to set any of the known parameters
9111    /// which have their own setter method. If done anyway, the request will fail.
9112    ///
9113    /// # Additional Parameters
9114    ///
9115    /// * *$.xgafv* (query-string) - V1 error format.
9116    /// * *access_token* (query-string) - OAuth access token.
9117    /// * *alt* (query-string) - Data format for response.
9118    /// * *callback* (query-string) - JSONP
9119    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9120    /// * *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.
9121    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9122    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9123    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9124    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9125    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9126    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
9127    where
9128        T: AsRef<str>,
9129    {
9130        self._additional_params
9131            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9132        self
9133    }
9134
9135    /// Identifies the authorization scope for the method you are building.
9136    ///
9137    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9138    /// [`Scope::CloudPlatform`].
9139    ///
9140    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9141    /// tokens for more than one scope.
9142    ///
9143    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9144    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9145    /// sufficient, a read-write scope will do as well.
9146    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
9147    where
9148        St: AsRef<str>,
9149    {
9150        self._scopes.insert(String::from(scope.as_ref()));
9151        self
9152    }
9153    /// Identifies the authorization scope(s) for the method you are building.
9154    ///
9155    /// See [`Self::add_scope()`] for details.
9156    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
9157    where
9158        I: IntoIterator<Item = St>,
9159        St: AsRef<str>,
9160    {
9161        self._scopes
9162            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9163        self
9164    }
9165
9166    /// Removes all scopes, and no default scope will be used either.
9167    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9168    /// for details).
9169    pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
9170        self._scopes.clear();
9171        self
9172    }
9173}
9174
9175/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
9176///
9177/// A builder for the *locations.operations.list* method supported by a *project* resource.
9178/// It is not used directly, but through a [`ProjectMethods`] instance.
9179///
9180/// # Example
9181///
9182/// Instantiate a resource method builder
9183///
9184/// ```test_harness,no_run
9185/// # extern crate hyper;
9186/// # extern crate hyper_rustls;
9187/// # extern crate google_file1 as file1;
9188/// # async fn dox() {
9189/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9190///
9191/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9192/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9193/// #     .with_native_roots()
9194/// #     .unwrap()
9195/// #     .https_only()
9196/// #     .enable_http2()
9197/// #     .build();
9198///
9199/// # let executor = hyper_util::rt::TokioExecutor::new();
9200/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9201/// #     secret,
9202/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9203/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9204/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9205/// #     ),
9206/// # ).build().await.unwrap();
9207///
9208/// # let client = hyper_util::client::legacy::Client::builder(
9209/// #     hyper_util::rt::TokioExecutor::new()
9210/// # )
9211/// # .build(
9212/// #     hyper_rustls::HttpsConnectorBuilder::new()
9213/// #         .with_native_roots()
9214/// #         .unwrap()
9215/// #         .https_or_http()
9216/// #         .enable_http2()
9217/// #         .build()
9218/// # );
9219/// # let mut hub = CloudFilestore::new(client, auth);
9220/// // You can configure optional parameters by calling the respective setters at will, and
9221/// // execute the final call using `doit()`.
9222/// // Values shown here are possibly random and not representative !
9223/// let result = hub.projects().locations_operations_list("name")
9224///              .return_partial_success(true)
9225///              .page_token("vero")
9226///              .page_size(-31)
9227///              .filter("sed")
9228///              .doit().await;
9229/// # }
9230/// ```
9231pub struct ProjectLocationOperationListCall<'a, C>
9232where
9233    C: 'a,
9234{
9235    hub: &'a CloudFilestore<C>,
9236    _name: String,
9237    _return_partial_success: Option<bool>,
9238    _page_token: Option<String>,
9239    _page_size: Option<i32>,
9240    _filter: Option<String>,
9241    _delegate: Option<&'a mut dyn common::Delegate>,
9242    _additional_params: HashMap<String, String>,
9243    _scopes: BTreeSet<String>,
9244}
9245
9246impl<'a, C> common::CallBuilder for ProjectLocationOperationListCall<'a, C> {}
9247
9248impl<'a, C> ProjectLocationOperationListCall<'a, C>
9249where
9250    C: common::Connector,
9251{
9252    /// Perform the operation you have build so far.
9253    pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
9254        use std::borrow::Cow;
9255        use std::io::{Read, Seek};
9256
9257        use common::{url::Params, ToParts};
9258        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9259
9260        let mut dd = common::DefaultDelegate;
9261        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9262        dlg.begin(common::MethodInfo {
9263            id: "file.projects.locations.operations.list",
9264            http_method: hyper::Method::GET,
9265        });
9266
9267        for &field in [
9268            "alt",
9269            "name",
9270            "returnPartialSuccess",
9271            "pageToken",
9272            "pageSize",
9273            "filter",
9274        ]
9275        .iter()
9276        {
9277            if self._additional_params.contains_key(field) {
9278                dlg.finished(false);
9279                return Err(common::Error::FieldClash(field));
9280            }
9281        }
9282
9283        let mut params = Params::with_capacity(7 + self._additional_params.len());
9284        params.push("name", self._name);
9285        if let Some(value) = self._return_partial_success.as_ref() {
9286            params.push("returnPartialSuccess", value.to_string());
9287        }
9288        if let Some(value) = self._page_token.as_ref() {
9289            params.push("pageToken", value);
9290        }
9291        if let Some(value) = self._page_size.as_ref() {
9292            params.push("pageSize", value.to_string());
9293        }
9294        if let Some(value) = self._filter.as_ref() {
9295            params.push("filter", value);
9296        }
9297
9298        params.extend(self._additional_params.iter());
9299
9300        params.push("alt", "json");
9301        let mut url = self.hub._base_url.clone() + "v1/{+name}/operations";
9302        if self._scopes.is_empty() {
9303            self._scopes
9304                .insert(Scope::CloudPlatform.as_ref().to_string());
9305        }
9306
9307        #[allow(clippy::single_element_loop)]
9308        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9309            url = params.uri_replacement(url, param_name, find_this, true);
9310        }
9311        {
9312            let to_remove = ["name"];
9313            params.remove_params(&to_remove);
9314        }
9315
9316        let url = params.parse_with_url(&url);
9317
9318        loop {
9319            let token = match self
9320                .hub
9321                .auth
9322                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9323                .await
9324            {
9325                Ok(token) => token,
9326                Err(e) => match dlg.token(e) {
9327                    Ok(token) => token,
9328                    Err(e) => {
9329                        dlg.finished(false);
9330                        return Err(common::Error::MissingToken(e));
9331                    }
9332                },
9333            };
9334            let mut req_result = {
9335                let client = &self.hub.client;
9336                dlg.pre_request();
9337                let mut req_builder = hyper::Request::builder()
9338                    .method(hyper::Method::GET)
9339                    .uri(url.as_str())
9340                    .header(USER_AGENT, self.hub._user_agent.clone());
9341
9342                if let Some(token) = token.as_ref() {
9343                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9344                }
9345
9346                let request = req_builder
9347                    .header(CONTENT_LENGTH, 0_u64)
9348                    .body(common::to_body::<String>(None));
9349
9350                client.request(request.unwrap()).await
9351            };
9352
9353            match req_result {
9354                Err(err) => {
9355                    if let common::Retry::After(d) = dlg.http_error(&err) {
9356                        sleep(d).await;
9357                        continue;
9358                    }
9359                    dlg.finished(false);
9360                    return Err(common::Error::HttpError(err));
9361                }
9362                Ok(res) => {
9363                    let (mut parts, body) = res.into_parts();
9364                    let mut body = common::Body::new(body);
9365                    if !parts.status.is_success() {
9366                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9367                        let error = serde_json::from_str(&common::to_string(&bytes));
9368                        let response = common::to_response(parts, bytes.into());
9369
9370                        if let common::Retry::After(d) =
9371                            dlg.http_failure(&response, error.as_ref().ok())
9372                        {
9373                            sleep(d).await;
9374                            continue;
9375                        }
9376
9377                        dlg.finished(false);
9378
9379                        return Err(match error {
9380                            Ok(value) => common::Error::BadRequest(value),
9381                            _ => common::Error::Failure(response),
9382                        });
9383                    }
9384                    let response = {
9385                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9386                        let encoded = common::to_string(&bytes);
9387                        match serde_json::from_str(&encoded) {
9388                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9389                            Err(error) => {
9390                                dlg.response_json_decode_error(&encoded, &error);
9391                                return Err(common::Error::JsonDecodeError(
9392                                    encoded.to_string(),
9393                                    error,
9394                                ));
9395                            }
9396                        }
9397                    };
9398
9399                    dlg.finished(true);
9400                    return Ok(response);
9401                }
9402            }
9403        }
9404    }
9405
9406    /// The name of the operation's parent resource.
9407    ///
9408    /// Sets the *name* path property to the given value.
9409    ///
9410    /// Even though the property as already been set when instantiating this call,
9411    /// we provide this method for API completeness.
9412    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
9413        self._name = new_value.to_string();
9414        self
9415    }
9416    /// When set to `true`, operations that are reachable are returned as normal, and those that are unreachable are returned in the ListOperationsResponse.unreachable field. This can only be `true` when reading across collections. For example, when `parent` is set to `"projects/example/locations/-"`. This field is not supported by default and will result in an `UNIMPLEMENTED` error if set unless explicitly documented otherwise in service or product specific documentation.
9417    ///
9418    /// Sets the *return partial success* query property to the given value.
9419    pub fn return_partial_success(
9420        mut self,
9421        new_value: bool,
9422    ) -> ProjectLocationOperationListCall<'a, C> {
9423        self._return_partial_success = Some(new_value);
9424        self
9425    }
9426    /// The standard list page token.
9427    ///
9428    /// Sets the *page token* query property to the given value.
9429    pub fn page_token(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
9430        self._page_token = Some(new_value.to_string());
9431        self
9432    }
9433    /// The standard list page size.
9434    ///
9435    /// Sets the *page size* query property to the given value.
9436    pub fn page_size(mut self, new_value: i32) -> ProjectLocationOperationListCall<'a, C> {
9437        self._page_size = Some(new_value);
9438        self
9439    }
9440    /// The standard list filter.
9441    ///
9442    /// Sets the *filter* query property to the given value.
9443    pub fn filter(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
9444        self._filter = Some(new_value.to_string());
9445        self
9446    }
9447    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9448    /// while executing the actual API request.
9449    ///
9450    /// ````text
9451    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9452    /// ````
9453    ///
9454    /// Sets the *delegate* property to the given value.
9455    pub fn delegate(
9456        mut self,
9457        new_value: &'a mut dyn common::Delegate,
9458    ) -> ProjectLocationOperationListCall<'a, C> {
9459        self._delegate = Some(new_value);
9460        self
9461    }
9462
9463    /// Set any additional parameter of the query string used in the request.
9464    /// It should be used to set parameters which are not yet available through their own
9465    /// setters.
9466    ///
9467    /// Please note that this method must not be used to set any of the known parameters
9468    /// which have their own setter method. If done anyway, the request will fail.
9469    ///
9470    /// # Additional Parameters
9471    ///
9472    /// * *$.xgafv* (query-string) - V1 error format.
9473    /// * *access_token* (query-string) - OAuth access token.
9474    /// * *alt* (query-string) - Data format for response.
9475    /// * *callback* (query-string) - JSONP
9476    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9477    /// * *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.
9478    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9479    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9480    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9481    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9482    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9483    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationListCall<'a, C>
9484    where
9485        T: AsRef<str>,
9486    {
9487        self._additional_params
9488            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9489        self
9490    }
9491
9492    /// Identifies the authorization scope for the method you are building.
9493    ///
9494    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9495    /// [`Scope::CloudPlatform`].
9496    ///
9497    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9498    /// tokens for more than one scope.
9499    ///
9500    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9501    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9502    /// sufficient, a read-write scope will do as well.
9503    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationListCall<'a, C>
9504    where
9505        St: AsRef<str>,
9506    {
9507        self._scopes.insert(String::from(scope.as_ref()));
9508        self
9509    }
9510    /// Identifies the authorization scope(s) for the method you are building.
9511    ///
9512    /// See [`Self::add_scope()`] for details.
9513    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationListCall<'a, C>
9514    where
9515        I: IntoIterator<Item = St>,
9516        St: AsRef<str>,
9517    {
9518        self._scopes
9519            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9520        self
9521    }
9522
9523    /// Removes all scopes, and no default scope will be used either.
9524    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9525    /// for details).
9526    pub fn clear_scopes(mut self) -> ProjectLocationOperationListCall<'a, C> {
9527        self._scopes.clear();
9528        self
9529    }
9530}
9531
9532/// Gets information about a location.
9533///
9534/// A builder for the *locations.get* method supported by a *project* resource.
9535/// It is not used directly, but through a [`ProjectMethods`] instance.
9536///
9537/// # Example
9538///
9539/// Instantiate a resource method builder
9540///
9541/// ```test_harness,no_run
9542/// # extern crate hyper;
9543/// # extern crate hyper_rustls;
9544/// # extern crate google_file1 as file1;
9545/// # async fn dox() {
9546/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9547///
9548/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9549/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9550/// #     .with_native_roots()
9551/// #     .unwrap()
9552/// #     .https_only()
9553/// #     .enable_http2()
9554/// #     .build();
9555///
9556/// # let executor = hyper_util::rt::TokioExecutor::new();
9557/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9558/// #     secret,
9559/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9560/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9561/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9562/// #     ),
9563/// # ).build().await.unwrap();
9564///
9565/// # let client = hyper_util::client::legacy::Client::builder(
9566/// #     hyper_util::rt::TokioExecutor::new()
9567/// # )
9568/// # .build(
9569/// #     hyper_rustls::HttpsConnectorBuilder::new()
9570/// #         .with_native_roots()
9571/// #         .unwrap()
9572/// #         .https_or_http()
9573/// #         .enable_http2()
9574/// #         .build()
9575/// # );
9576/// # let mut hub = CloudFilestore::new(client, auth);
9577/// // You can configure optional parameters by calling the respective setters at will, and
9578/// // execute the final call using `doit()`.
9579/// // Values shown here are possibly random and not representative !
9580/// let result = hub.projects().locations_get("name")
9581///              .doit().await;
9582/// # }
9583/// ```
9584pub struct ProjectLocationGetCall<'a, C>
9585where
9586    C: 'a,
9587{
9588    hub: &'a CloudFilestore<C>,
9589    _name: String,
9590    _delegate: Option<&'a mut dyn common::Delegate>,
9591    _additional_params: HashMap<String, String>,
9592    _scopes: BTreeSet<String>,
9593}
9594
9595impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
9596
9597impl<'a, C> ProjectLocationGetCall<'a, C>
9598where
9599    C: common::Connector,
9600{
9601    /// Perform the operation you have build so far.
9602    pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
9603        use std::borrow::Cow;
9604        use std::io::{Read, Seek};
9605
9606        use common::{url::Params, ToParts};
9607        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9608
9609        let mut dd = common::DefaultDelegate;
9610        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9611        dlg.begin(common::MethodInfo {
9612            id: "file.projects.locations.get",
9613            http_method: hyper::Method::GET,
9614        });
9615
9616        for &field in ["alt", "name"].iter() {
9617            if self._additional_params.contains_key(field) {
9618                dlg.finished(false);
9619                return Err(common::Error::FieldClash(field));
9620            }
9621        }
9622
9623        let mut params = Params::with_capacity(3 + self._additional_params.len());
9624        params.push("name", self._name);
9625
9626        params.extend(self._additional_params.iter());
9627
9628        params.push("alt", "json");
9629        let mut url = self.hub._base_url.clone() + "v1/{+name}";
9630        if self._scopes.is_empty() {
9631            self._scopes
9632                .insert(Scope::CloudPlatform.as_ref().to_string());
9633        }
9634
9635        #[allow(clippy::single_element_loop)]
9636        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9637            url = params.uri_replacement(url, param_name, find_this, true);
9638        }
9639        {
9640            let to_remove = ["name"];
9641            params.remove_params(&to_remove);
9642        }
9643
9644        let url = params.parse_with_url(&url);
9645
9646        loop {
9647            let token = match self
9648                .hub
9649                .auth
9650                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9651                .await
9652            {
9653                Ok(token) => token,
9654                Err(e) => match dlg.token(e) {
9655                    Ok(token) => token,
9656                    Err(e) => {
9657                        dlg.finished(false);
9658                        return Err(common::Error::MissingToken(e));
9659                    }
9660                },
9661            };
9662            let mut req_result = {
9663                let client = &self.hub.client;
9664                dlg.pre_request();
9665                let mut req_builder = hyper::Request::builder()
9666                    .method(hyper::Method::GET)
9667                    .uri(url.as_str())
9668                    .header(USER_AGENT, self.hub._user_agent.clone());
9669
9670                if let Some(token) = token.as_ref() {
9671                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9672                }
9673
9674                let request = req_builder
9675                    .header(CONTENT_LENGTH, 0_u64)
9676                    .body(common::to_body::<String>(None));
9677
9678                client.request(request.unwrap()).await
9679            };
9680
9681            match req_result {
9682                Err(err) => {
9683                    if let common::Retry::After(d) = dlg.http_error(&err) {
9684                        sleep(d).await;
9685                        continue;
9686                    }
9687                    dlg.finished(false);
9688                    return Err(common::Error::HttpError(err));
9689                }
9690                Ok(res) => {
9691                    let (mut parts, body) = res.into_parts();
9692                    let mut body = common::Body::new(body);
9693                    if !parts.status.is_success() {
9694                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9695                        let error = serde_json::from_str(&common::to_string(&bytes));
9696                        let response = common::to_response(parts, bytes.into());
9697
9698                        if let common::Retry::After(d) =
9699                            dlg.http_failure(&response, error.as_ref().ok())
9700                        {
9701                            sleep(d).await;
9702                            continue;
9703                        }
9704
9705                        dlg.finished(false);
9706
9707                        return Err(match error {
9708                            Ok(value) => common::Error::BadRequest(value),
9709                            _ => common::Error::Failure(response),
9710                        });
9711                    }
9712                    let response = {
9713                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9714                        let encoded = common::to_string(&bytes);
9715                        match serde_json::from_str(&encoded) {
9716                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9717                            Err(error) => {
9718                                dlg.response_json_decode_error(&encoded, &error);
9719                                return Err(common::Error::JsonDecodeError(
9720                                    encoded.to_string(),
9721                                    error,
9722                                ));
9723                            }
9724                        }
9725                    };
9726
9727                    dlg.finished(true);
9728                    return Ok(response);
9729                }
9730            }
9731        }
9732    }
9733
9734    /// Resource name for the location.
9735    ///
9736    /// Sets the *name* path property to the given value.
9737    ///
9738    /// Even though the property as already been set when instantiating this call,
9739    /// we provide this method for API completeness.
9740    pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
9741        self._name = new_value.to_string();
9742        self
9743    }
9744    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9745    /// while executing the actual API request.
9746    ///
9747    /// ````text
9748    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9749    /// ````
9750    ///
9751    /// Sets the *delegate* property to the given value.
9752    pub fn delegate(
9753        mut self,
9754        new_value: &'a mut dyn common::Delegate,
9755    ) -> ProjectLocationGetCall<'a, C> {
9756        self._delegate = Some(new_value);
9757        self
9758    }
9759
9760    /// Set any additional parameter of the query string used in the request.
9761    /// It should be used to set parameters which are not yet available through their own
9762    /// setters.
9763    ///
9764    /// Please note that this method must not be used to set any of the known parameters
9765    /// which have their own setter method. If done anyway, the request will fail.
9766    ///
9767    /// # Additional Parameters
9768    ///
9769    /// * *$.xgafv* (query-string) - V1 error format.
9770    /// * *access_token* (query-string) - OAuth access token.
9771    /// * *alt* (query-string) - Data format for response.
9772    /// * *callback* (query-string) - JSONP
9773    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9774    /// * *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.
9775    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9776    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9777    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9778    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9779    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9780    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
9781    where
9782        T: AsRef<str>,
9783    {
9784        self._additional_params
9785            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9786        self
9787    }
9788
9789    /// Identifies the authorization scope for the method you are building.
9790    ///
9791    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9792    /// [`Scope::CloudPlatform`].
9793    ///
9794    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9795    /// tokens for more than one scope.
9796    ///
9797    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9798    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9799    /// sufficient, a read-write scope will do as well.
9800    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
9801    where
9802        St: AsRef<str>,
9803    {
9804        self._scopes.insert(String::from(scope.as_ref()));
9805        self
9806    }
9807    /// Identifies the authorization scope(s) for the method you are building.
9808    ///
9809    /// See [`Self::add_scope()`] for details.
9810    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
9811    where
9812        I: IntoIterator<Item = St>,
9813        St: AsRef<str>,
9814    {
9815        self._scopes
9816            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9817        self
9818    }
9819
9820    /// Removes all scopes, and no default scope will be used either.
9821    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9822    /// for details).
9823    pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
9824        self._scopes.clear();
9825        self
9826    }
9827}
9828
9829/// Lists information about the supported locations for this service.
9830///
9831/// A builder for the *locations.list* method supported by a *project* resource.
9832/// It is not used directly, but through a [`ProjectMethods`] instance.
9833///
9834/// # Example
9835///
9836/// Instantiate a resource method builder
9837///
9838/// ```test_harness,no_run
9839/// # extern crate hyper;
9840/// # extern crate hyper_rustls;
9841/// # extern crate google_file1 as file1;
9842/// # async fn dox() {
9843/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9844///
9845/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9846/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9847/// #     .with_native_roots()
9848/// #     .unwrap()
9849/// #     .https_only()
9850/// #     .enable_http2()
9851/// #     .build();
9852///
9853/// # let executor = hyper_util::rt::TokioExecutor::new();
9854/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9855/// #     secret,
9856/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9857/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9858/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9859/// #     ),
9860/// # ).build().await.unwrap();
9861///
9862/// # let client = hyper_util::client::legacy::Client::builder(
9863/// #     hyper_util::rt::TokioExecutor::new()
9864/// # )
9865/// # .build(
9866/// #     hyper_rustls::HttpsConnectorBuilder::new()
9867/// #         .with_native_roots()
9868/// #         .unwrap()
9869/// #         .https_or_http()
9870/// #         .enable_http2()
9871/// #         .build()
9872/// # );
9873/// # let mut hub = CloudFilestore::new(client, auth);
9874/// // You can configure optional parameters by calling the respective setters at will, and
9875/// // execute the final call using `doit()`.
9876/// // Values shown here are possibly random and not representative !
9877/// let result = hub.projects().locations_list("name")
9878///              .page_token("et")
9879///              .page_size(-28)
9880///              .filter("amet.")
9881///              .add_extra_location_types("consetetur")
9882///              .doit().await;
9883/// # }
9884/// ```
9885pub struct ProjectLocationListCall<'a, C>
9886where
9887    C: 'a,
9888{
9889    hub: &'a CloudFilestore<C>,
9890    _name: String,
9891    _page_token: Option<String>,
9892    _page_size: Option<i32>,
9893    _filter: Option<String>,
9894    _extra_location_types: Vec<String>,
9895    _delegate: Option<&'a mut dyn common::Delegate>,
9896    _additional_params: HashMap<String, String>,
9897    _scopes: BTreeSet<String>,
9898}
9899
9900impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
9901
9902impl<'a, C> ProjectLocationListCall<'a, C>
9903where
9904    C: common::Connector,
9905{
9906    /// Perform the operation you have build so far.
9907    pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
9908        use std::borrow::Cow;
9909        use std::io::{Read, Seek};
9910
9911        use common::{url::Params, ToParts};
9912        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9913
9914        let mut dd = common::DefaultDelegate;
9915        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9916        dlg.begin(common::MethodInfo {
9917            id: "file.projects.locations.list",
9918            http_method: hyper::Method::GET,
9919        });
9920
9921        for &field in [
9922            "alt",
9923            "name",
9924            "pageToken",
9925            "pageSize",
9926            "filter",
9927            "extraLocationTypes",
9928        ]
9929        .iter()
9930        {
9931            if self._additional_params.contains_key(field) {
9932                dlg.finished(false);
9933                return Err(common::Error::FieldClash(field));
9934            }
9935        }
9936
9937        let mut params = Params::with_capacity(7 + self._additional_params.len());
9938        params.push("name", self._name);
9939        if let Some(value) = self._page_token.as_ref() {
9940            params.push("pageToken", value);
9941        }
9942        if let Some(value) = self._page_size.as_ref() {
9943            params.push("pageSize", value.to_string());
9944        }
9945        if let Some(value) = self._filter.as_ref() {
9946            params.push("filter", value);
9947        }
9948        if !self._extra_location_types.is_empty() {
9949            for f in self._extra_location_types.iter() {
9950                params.push("extraLocationTypes", f);
9951            }
9952        }
9953
9954        params.extend(self._additional_params.iter());
9955
9956        params.push("alt", "json");
9957        let mut url = self.hub._base_url.clone() + "v1/{+name}/locations";
9958        if self._scopes.is_empty() {
9959            self._scopes
9960                .insert(Scope::CloudPlatform.as_ref().to_string());
9961        }
9962
9963        #[allow(clippy::single_element_loop)]
9964        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9965            url = params.uri_replacement(url, param_name, find_this, true);
9966        }
9967        {
9968            let to_remove = ["name"];
9969            params.remove_params(&to_remove);
9970        }
9971
9972        let url = params.parse_with_url(&url);
9973
9974        loop {
9975            let token = match self
9976                .hub
9977                .auth
9978                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9979                .await
9980            {
9981                Ok(token) => token,
9982                Err(e) => match dlg.token(e) {
9983                    Ok(token) => token,
9984                    Err(e) => {
9985                        dlg.finished(false);
9986                        return Err(common::Error::MissingToken(e));
9987                    }
9988                },
9989            };
9990            let mut req_result = {
9991                let client = &self.hub.client;
9992                dlg.pre_request();
9993                let mut req_builder = hyper::Request::builder()
9994                    .method(hyper::Method::GET)
9995                    .uri(url.as_str())
9996                    .header(USER_AGENT, self.hub._user_agent.clone());
9997
9998                if let Some(token) = token.as_ref() {
9999                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10000                }
10001
10002                let request = req_builder
10003                    .header(CONTENT_LENGTH, 0_u64)
10004                    .body(common::to_body::<String>(None));
10005
10006                client.request(request.unwrap()).await
10007            };
10008
10009            match req_result {
10010                Err(err) => {
10011                    if let common::Retry::After(d) = dlg.http_error(&err) {
10012                        sleep(d).await;
10013                        continue;
10014                    }
10015                    dlg.finished(false);
10016                    return Err(common::Error::HttpError(err));
10017                }
10018                Ok(res) => {
10019                    let (mut parts, body) = res.into_parts();
10020                    let mut body = common::Body::new(body);
10021                    if !parts.status.is_success() {
10022                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10023                        let error = serde_json::from_str(&common::to_string(&bytes));
10024                        let response = common::to_response(parts, bytes.into());
10025
10026                        if let common::Retry::After(d) =
10027                            dlg.http_failure(&response, error.as_ref().ok())
10028                        {
10029                            sleep(d).await;
10030                            continue;
10031                        }
10032
10033                        dlg.finished(false);
10034
10035                        return Err(match error {
10036                            Ok(value) => common::Error::BadRequest(value),
10037                            _ => common::Error::Failure(response),
10038                        });
10039                    }
10040                    let response = {
10041                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10042                        let encoded = common::to_string(&bytes);
10043                        match serde_json::from_str(&encoded) {
10044                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10045                            Err(error) => {
10046                                dlg.response_json_decode_error(&encoded, &error);
10047                                return Err(common::Error::JsonDecodeError(
10048                                    encoded.to_string(),
10049                                    error,
10050                                ));
10051                            }
10052                        }
10053                    };
10054
10055                    dlg.finished(true);
10056                    return Ok(response);
10057                }
10058            }
10059        }
10060    }
10061
10062    /// The resource that owns the locations collection, if applicable.
10063    ///
10064    /// Sets the *name* path property to the given value.
10065    ///
10066    /// Even though the property as already been set when instantiating this call,
10067    /// we provide this method for API completeness.
10068    pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
10069        self._name = new_value.to_string();
10070        self
10071    }
10072    /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
10073    ///
10074    /// Sets the *page token* query property to the given value.
10075    pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
10076        self._page_token = Some(new_value.to_string());
10077        self
10078    }
10079    /// The maximum number of results to return. If not set, the service selects a default.
10080    ///
10081    /// Sets the *page size* query property to the given value.
10082    pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
10083        self._page_size = Some(new_value);
10084        self
10085    }
10086    /// A filter to narrow down results to a preferred subset. The filtering language accepts strings like `"displayName=tokyo"`, and is documented in more detail in [AIP-160](https://google.aip.dev/160).
10087    ///
10088    /// Sets the *filter* query property to the given value.
10089    pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
10090        self._filter = Some(new_value.to_string());
10091        self
10092    }
10093    /// Optional. Do not use this field. It is unsupported and is ignored unless explicitly documented otherwise. This is primarily for internal usage.
10094    ///
10095    /// Append the given value to the *extra location types* query property.
10096    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
10097    pub fn add_extra_location_types(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
10098        self._extra_location_types.push(new_value.to_string());
10099        self
10100    }
10101    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10102    /// while executing the actual API request.
10103    ///
10104    /// ````text
10105    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10106    /// ````
10107    ///
10108    /// Sets the *delegate* property to the given value.
10109    pub fn delegate(
10110        mut self,
10111        new_value: &'a mut dyn common::Delegate,
10112    ) -> ProjectLocationListCall<'a, C> {
10113        self._delegate = Some(new_value);
10114        self
10115    }
10116
10117    /// Set any additional parameter of the query string used in the request.
10118    /// It should be used to set parameters which are not yet available through their own
10119    /// setters.
10120    ///
10121    /// Please note that this method must not be used to set any of the known parameters
10122    /// which have their own setter method. If done anyway, the request will fail.
10123    ///
10124    /// # Additional Parameters
10125    ///
10126    /// * *$.xgafv* (query-string) - V1 error format.
10127    /// * *access_token* (query-string) - OAuth access token.
10128    /// * *alt* (query-string) - Data format for response.
10129    /// * *callback* (query-string) - JSONP
10130    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10131    /// * *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.
10132    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10133    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10134    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
10135    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10136    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10137    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
10138    where
10139        T: AsRef<str>,
10140    {
10141        self._additional_params
10142            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10143        self
10144    }
10145
10146    /// Identifies the authorization scope for the method you are building.
10147    ///
10148    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10149    /// [`Scope::CloudPlatform`].
10150    ///
10151    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10152    /// tokens for more than one scope.
10153    ///
10154    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10155    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10156    /// sufficient, a read-write scope will do as well.
10157    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
10158    where
10159        St: AsRef<str>,
10160    {
10161        self._scopes.insert(String::from(scope.as_ref()));
10162        self
10163    }
10164    /// Identifies the authorization scope(s) for the method you are building.
10165    ///
10166    /// See [`Self::add_scope()`] for details.
10167    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
10168    where
10169        I: IntoIterator<Item = St>,
10170        St: AsRef<str>,
10171    {
10172        self._scopes
10173            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10174        self
10175    }
10176
10177    /// Removes all scopes, and no default scope will be used either.
10178    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10179    /// for details).
10180    pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
10181        self._scopes.clear();
10182        self
10183    }
10184}