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 auth = yup_oauth2::InstalledFlowAuthenticator::builder(
63/// secret,
64/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
65/// ).build().await.unwrap();
66///
67/// let client = hyper_util::client::legacy::Client::builder(
68/// hyper_util::rt::TokioExecutor::new()
69/// )
70/// .build(
71/// hyper_rustls::HttpsConnectorBuilder::new()
72/// .with_native_roots()
73/// .unwrap()
74/// .https_or_http()
75/// .enable_http1()
76/// .build()
77/// );
78/// let mut hub = CloudFilestore::new(client, auth);
79/// // As the method needs a request, you would usually fill it with the desired information
80/// // into the respective structure. Some of the parts shown here might not be applicable !
81/// // Values shown here are possibly random and not representative !
82/// let mut req = Backup::default();
83///
84/// // You can configure optional parameters by calling the respective setters at will, and
85/// // execute the final call using `doit()`.
86/// // Values shown here are possibly random and not representative !
87/// let result = hub.projects().locations_backups_create(req, "parent")
88/// .backup_id("At")
89/// .doit().await;
90///
91/// match result {
92/// Err(e) => match e {
93/// // The Error enum provides details about what exactly happened.
94/// // You can also just use its `Debug`, `Display` or `Error` traits
95/// Error::HttpError(_)
96/// |Error::Io(_)
97/// |Error::MissingAPIKey
98/// |Error::MissingToken(_)
99/// |Error::Cancelled
100/// |Error::UploadSizeLimitExceeded(_, _)
101/// |Error::Failure(_)
102/// |Error::BadRequest(_)
103/// |Error::FieldClash(_)
104/// |Error::JsonDecodeError(_, _) => println!("{}", e),
105/// },
106/// Ok(res) => println!("Success: {:?}", res),
107/// }
108/// # }
109/// ```
110#[derive(Clone)]
111pub struct CloudFilestore<C> {
112 pub client: common::Client<C>,
113 pub auth: Box<dyn common::GetToken>,
114 _user_agent: String,
115 _base_url: String,
116 _root_url: String,
117}
118
119impl<C> common::Hub for CloudFilestore<C> {}
120
121impl<'a, C> CloudFilestore<C> {
122 pub fn new<A: 'static + common::GetToken>(
123 client: common::Client<C>,
124 auth: A,
125 ) -> CloudFilestore<C> {
126 CloudFilestore {
127 client,
128 auth: Box::new(auth),
129 _user_agent: "google-api-rust-client/6.0.0".to_string(),
130 _base_url: "https://file.googleapis.com/".to_string(),
131 _root_url: "https://file.googleapis.com/".to_string(),
132 }
133 }
134
135 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
136 ProjectMethods { hub: self }
137 }
138
139 /// Set the user-agent header field to use in all requests to the server.
140 /// It defaults to `google-api-rust-client/6.0.0`.
141 ///
142 /// Returns the previously set user-agent.
143 pub fn user_agent(&mut self, agent_name: String) -> String {
144 std::mem::replace(&mut self._user_agent, agent_name)
145 }
146
147 /// Set the base url to use in all requests to the server.
148 /// It defaults to `https://file.googleapis.com/`.
149 ///
150 /// Returns the previously set base url.
151 pub fn base_url(&mut self, new_base_url: String) -> String {
152 std::mem::replace(&mut self._base_url, new_base_url)
153 }
154
155 /// Set the root url to use in all requests to the server.
156 /// It defaults to `https://file.googleapis.com/`.
157 ///
158 /// Returns the previously set root url.
159 pub fn root_url(&mut self, new_root_url: String) -> String {
160 std::mem::replace(&mut self._root_url, new_root_url)
161 }
162}
163
164// ############
165// SCHEMAS ###
166// ##########
167/// A Filestore backup.
168///
169/// # Activities
170///
171/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
172/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
173///
174/// * [locations backups create projects](ProjectLocationBackupCreateCall) (request)
175/// * [locations backups get projects](ProjectLocationBackupGetCall) (response)
176/// * [locations backups patch projects](ProjectLocationBackupPatchCall) (request)
177#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
178#[serde_with::serde_as]
179#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
180pub struct Backup {
181 /// Output only. Capacity of the source file share when the backup was created.
182 #[serde(rename = "capacityGb")]
183 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
184 pub capacity_gb: Option<i64>,
185 /// Output only. The time when the backup was created.
186 #[serde(rename = "createTime")]
187 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
188 /// A description of the backup with 2048 characters or less. Requests with longer descriptions will be rejected.
189 pub description: Option<String>,
190 /// 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.
191 #[serde(rename = "downloadBytes")]
192 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
193 pub download_bytes: Option<i64>,
194 /// Immutable. KMS key name used for data encryption.
195 #[serde(rename = "kmsKey")]
196 pub kms_key: Option<String>,
197 /// Resource labels to represent user provided metadata.
198 pub labels: Option<HashMap<String, String>>,
199 /// Output only. The resource name of the backup, in the format `projects/{project_number}/locations/{location_id}/backups/{backup_id}`.
200 pub name: Option<String>,
201 /// Output only. Reserved for future use.
202 #[serde(rename = "satisfiesPzi")]
203 pub satisfies_pzi: Option<bool>,
204 /// Output only. Reserved for future use.
205 #[serde(rename = "satisfiesPzs")]
206 pub satisfies_pzs: Option<bool>,
207 /// Name of the file share in the source Filestore instance that the backup is created from.
208 #[serde(rename = "sourceFileShare")]
209 pub source_file_share: Option<String>,
210 /// 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.
211 #[serde(rename = "sourceInstance")]
212 pub source_instance: Option<String>,
213 /// Output only. The service tier of the source Filestore instance that this backup is created from.
214 #[serde(rename = "sourceInstanceTier")]
215 pub source_instance_tier: Option<String>,
216 /// Output only. The backup state.
217 pub state: Option<String>,
218 /// 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.
219 #[serde(rename = "storageBytes")]
220 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
221 pub storage_bytes: Option<i64>,
222 /// Optional. Input only. Immutable. Tag keys/values directly bound to this resource. For example: "123/environment": "production", "123/costCenter": "marketing"
223 pub tags: Option<HashMap<String, String>>,
224}
225
226impl common::RequestValue for Backup {}
227impl common::ResponseResult for Backup {}
228
229/// The request message for Operations.CancelOperation.
230///
231/// # Activities
232///
233/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
234/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
235///
236/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (request)
237#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
238#[serde_with::serde_as]
239#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
240pub struct CancelOperationRequest {
241 _never_set: Option<bool>,
242}
243
244impl common::RequestValue for CancelOperationRequest {}
245
246/// 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); }
247///
248/// # Activities
249///
250/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
251/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
252///
253/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
254/// * [locations operations delete projects](ProjectLocationOperationDeleteCall) (response)
255#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
256#[serde_with::serde_as]
257#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
258pub struct Empty {
259 _never_set: Option<bool>,
260}
261
262impl common::ResponseResult for Empty {}
263
264/// File share configuration for the instance.
265///
266/// This type is not used in any activity, and only used as *part* of another schema.
267///
268#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
269#[serde_with::serde_as]
270#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
271pub struct FileShareConfig {
272 /// File share capacity in gigabytes (GB). Filestore defines 1 GB as 1024^3 bytes.
273 #[serde(rename = "capacityGb")]
274 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
275 pub capacity_gb: Option<i64>,
276 /// 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.
277 pub name: Option<String>,
278 /// Nfs Export Options. There is a limit of 10 export options per file share.
279 #[serde(rename = "nfsExportOptions")]
280 pub nfs_export_options: Option<Vec<NfsExportOptions>>,
281 /// 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.
282 #[serde(rename = "sourceBackup")]
283 pub source_backup: Option<String>,
284}
285
286impl common::Part for FileShareConfig {}
287
288/// A Filestore instance.
289///
290/// # Activities
291///
292/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
293/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
294///
295/// * [locations instances create projects](ProjectLocationInstanceCreateCall) (request)
296/// * [locations instances get projects](ProjectLocationInstanceGetCall) (response)
297/// * [locations instances patch projects](ProjectLocationInstancePatchCall) (request)
298#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
299#[serde_with::serde_as]
300#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
301pub struct Instance {
302 /// Output only. The time when the instance was created.
303 #[serde(rename = "createTime")]
304 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
305 /// The description of the instance (2048 characters or less).
306 pub description: Option<String>,
307 /// Server-specified ETag for the instance resource to prevent simultaneous updates from overwriting each other.
308 pub etag: Option<String>,
309 /// File system shares on the instance. For this version, only a single file share is supported.
310 #[serde(rename = "fileShares")]
311 pub file_shares: Option<Vec<FileShareConfig>>,
312 /// KMS key name used for data encryption.
313 #[serde(rename = "kmsKeyName")]
314 pub kms_key_name: Option<String>,
315 /// Resource labels to represent user provided metadata.
316 pub labels: Option<HashMap<String, String>>,
317 /// Output only. The resource name of the instance, in the format `projects/{project}/locations/{location}/instances/{instance}`.
318 pub name: Option<String>,
319 /// VPC networks to which the instance is connected. For this version, only a single network is supported.
320 pub networks: Option<Vec<NetworkConfig>>,
321 /// Optional. Replicaition configuration.
322 pub replication: Option<Replication>,
323 /// Output only. Reserved for future use.
324 #[serde(rename = "satisfiesPzi")]
325 pub satisfies_pzi: Option<bool>,
326 /// Output only. Reserved for future use.
327 #[serde(rename = "satisfiesPzs")]
328 pub satisfies_pzs: Option<bool>,
329 /// Output only. The instance state.
330 pub state: Option<String>,
331 /// Output only. Additional information about the instance state, if available.
332 #[serde(rename = "statusMessage")]
333 pub status_message: Option<String>,
334 /// Output only. Field indicates all the reasons the instance is in "SUSPENDED" state.
335 #[serde(rename = "suspensionReasons")]
336 pub suspension_reasons: Option<Vec<String>>,
337 /// Optional. Input only. Immutable. Tag keys/values directly bound to this resource. For example: "123/environment": "production", "123/costCenter": "marketing"
338 pub tags: Option<HashMap<String, String>>,
339 /// The service tier of the instance.
340 pub tier: Option<String>,
341}
342
343impl common::RequestValue for Instance {}
344impl common::ResponseResult for Instance {}
345
346/// ListBackupsResponse is the result of ListBackupsRequest.
347///
348/// # Activities
349///
350/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
351/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
352///
353/// * [locations backups list projects](ProjectLocationBackupListCall) (response)
354#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
355#[serde_with::serde_as]
356#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
357pub struct ListBackupsResponse {
358 /// 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.
359 pub backups: Option<Vec<Backup>>,
360 /// The token you can use to retrieve the next page of results. Not returned if there are no more results in the list.
361 #[serde(rename = "nextPageToken")]
362 pub next_page_token: Option<String>,
363 /// Locations that could not be reached.
364 pub unreachable: Option<Vec<String>>,
365}
366
367impl common::ResponseResult for ListBackupsResponse {}
368
369/// ListInstancesResponse is the result of ListInstancesRequest.
370///
371/// # Activities
372///
373/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
374/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
375///
376/// * [locations instances list projects](ProjectLocationInstanceListCall) (response)
377#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
378#[serde_with::serde_as]
379#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
380pub struct ListInstancesResponse {
381 /// 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.
382 pub instances: Option<Vec<Instance>>,
383 /// The token you can use to retrieve the next page of results. Not returned if there are no more results in the list.
384 #[serde(rename = "nextPageToken")]
385 pub next_page_token: Option<String>,
386 /// Locations that could not be reached.
387 pub unreachable: Option<Vec<String>>,
388}
389
390impl common::ResponseResult for ListInstancesResponse {}
391
392/// The response message for Locations.ListLocations.
393///
394/// # Activities
395///
396/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
397/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
398///
399/// * [locations list projects](ProjectLocationListCall) (response)
400#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
401#[serde_with::serde_as]
402#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
403pub struct ListLocationsResponse {
404 /// A list of locations that matches the specified filter in the request.
405 pub locations: Option<Vec<Location>>,
406 /// The standard List next-page token.
407 #[serde(rename = "nextPageToken")]
408 pub next_page_token: Option<String>,
409}
410
411impl common::ResponseResult for ListLocationsResponse {}
412
413/// The response message for Operations.ListOperations.
414///
415/// # Activities
416///
417/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
418/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
419///
420/// * [locations operations list projects](ProjectLocationOperationListCall) (response)
421#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
422#[serde_with::serde_as]
423#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
424pub struct ListOperationsResponse {
425 /// The standard List next-page token.
426 #[serde(rename = "nextPageToken")]
427 pub next_page_token: Option<String>,
428 /// A list of operations that matches the specified filter in the request.
429 pub operations: Option<Vec<Operation>>,
430}
431
432impl common::ResponseResult for ListOperationsResponse {}
433
434/// ListSnapshotsResponse is the result of ListSnapshotsRequest.
435///
436/// # Activities
437///
438/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
439/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
440///
441/// * [locations instances snapshots list projects](ProjectLocationInstanceSnapshotListCall) (response)
442#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
443#[serde_with::serde_as]
444#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
445pub struct ListSnapshotsResponse {
446 /// The token you can use to retrieve the next page of results. Not returned if there are no more results in the list.
447 #[serde(rename = "nextPageToken")]
448 pub next_page_token: Option<String>,
449 /// A list of snapshots in the project for the specified instance.
450 pub snapshots: Option<Vec<Snapshot>>,
451}
452
453impl common::ResponseResult for ListSnapshotsResponse {}
454
455/// A resource that represents a Google Cloud location.
456///
457/// # Activities
458///
459/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
460/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
461///
462/// * [locations get projects](ProjectLocationGetCall) (response)
463#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
464#[serde_with::serde_as]
465#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
466pub struct Location {
467 /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
468 #[serde(rename = "displayName")]
469 pub display_name: Option<String>,
470 /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
471 pub labels: Option<HashMap<String, String>>,
472 /// The canonical id for this location. For example: `"us-east1"`.
473 #[serde(rename = "locationId")]
474 pub location_id: Option<String>,
475 /// Service-specific metadata. For example the available capacity at the given location.
476 pub metadata: Option<HashMap<String, serde_json::Value>>,
477 /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
478 pub name: Option<String>,
479}
480
481impl common::ResponseResult for Location {}
482
483/// Network configuration for the instance.
484///
485/// This type is not used in any activity, and only used as *part* of another schema.
486///
487#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
488#[serde_with::serde_as]
489#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
490pub struct NetworkConfig {
491 /// The network connect mode of the Filestore instance. If not provided, the connect mode defaults to DIRECT_PEERING.
492 #[serde(rename = "connectMode")]
493 pub connect_mode: Option<String>,
494 /// 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}`.
495 #[serde(rename = "ipAddresses")]
496 pub ip_addresses: Option<Vec<String>>,
497 /// Internet protocol versions for which the instance has IP addresses assigned. For this version, only MODE_IPV4 is supported.
498 pub modes: Option<Vec<String>>,
499 /// The name of the Google Compute Engine [VPC network](https://cloud.google.com/vpc/docs/vpc) to which the instance is connected.
500 pub network: Option<String>,
501 /// 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.
502 #[serde(rename = "reservedIpRange")]
503 pub reserved_ip_range: Option<String>,
504}
505
506impl common::Part for NetworkConfig {}
507
508/// NFS export options specifications.
509///
510/// This type is not used in any activity, and only used as *part* of another schema.
511///
512#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
513#[serde_with::serde_as]
514#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
515pub struct NfsExportOptions {
516 /// 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.
517 #[serde(rename = "accessMode")]
518 pub access_mode: Option<String>,
519 /// 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.
520 #[serde(rename = "anonGid")]
521 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
522 pub anon_gid: Option<i64>,
523 /// 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.
524 #[serde(rename = "anonUid")]
525 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
526 pub anon_uid: Option<i64>,
527 /// 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.
528 #[serde(rename = "ipRanges")]
529 pub ip_ranges: Option<Vec<String>>,
530 /// 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.
531 #[serde(rename = "squashMode")]
532 pub squash_mode: Option<String>,
533}
534
535impl common::Part for NfsExportOptions {}
536
537/// This resource represents a long-running operation that is the result of a network API call.
538///
539/// # Activities
540///
541/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
542/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
543///
544/// * [locations backups create projects](ProjectLocationBackupCreateCall) (response)
545/// * [locations backups delete projects](ProjectLocationBackupDeleteCall) (response)
546/// * [locations backups patch projects](ProjectLocationBackupPatchCall) (response)
547/// * [locations instances snapshots create projects](ProjectLocationInstanceSnapshotCreateCall) (response)
548/// * [locations instances snapshots delete projects](ProjectLocationInstanceSnapshotDeleteCall) (response)
549/// * [locations instances snapshots patch projects](ProjectLocationInstanceSnapshotPatchCall) (response)
550/// * [locations instances create projects](ProjectLocationInstanceCreateCall) (response)
551/// * [locations instances delete projects](ProjectLocationInstanceDeleteCall) (response)
552/// * [locations instances patch projects](ProjectLocationInstancePatchCall) (response)
553/// * [locations instances promote replica projects](ProjectLocationInstancePromoteReplicaCall) (response)
554/// * [locations instances restore projects](ProjectLocationInstanceRestoreCall) (response)
555/// * [locations instances revert projects](ProjectLocationInstanceRevertCall) (response)
556/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
557#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
558#[serde_with::serde_as]
559#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
560pub struct Operation {
561 /// 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.
562 pub done: Option<bool>,
563 /// The error result of the operation in case of failure or cancellation.
564 pub error: Option<Status>,
565 /// 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.
566 pub metadata: Option<HashMap<String, serde_json::Value>>,
567 /// 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}`.
568 pub name: Option<String>,
569 /// 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`.
570 pub response: Option<HashMap<String, serde_json::Value>>,
571}
572
573impl common::ResponseResult for Operation {}
574
575/// PromoteReplicaRequest promotes a Filestore standby instance (replica).
576///
577/// # Activities
578///
579/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
580/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
581///
582/// * [locations instances promote replica projects](ProjectLocationInstancePromoteReplicaCall) (request)
583#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
584#[serde_with::serde_as]
585#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
586pub struct PromoteReplicaRequest {
587 _never_set: Option<bool>,
588}
589
590impl common::RequestValue for PromoteReplicaRequest {}
591
592/// Replica configuration for the instance.
593///
594/// This type is not used in any activity, and only used as *part* of another schema.
595///
596#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
597#[serde_with::serde_as]
598#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
599pub struct ReplicaConfig {
600 /// Output only. The timestamp of the latest replication snapshot taken on the active instance and is already replicated safely.
601 #[serde(rename = "lastActiveSyncTime")]
602 pub last_active_sync_time: Option<chrono::DateTime<chrono::offset::Utc>>,
603 /// Optional. The peer instance.
604 #[serde(rename = "peerInstance")]
605 pub peer_instance: Option<String>,
606 /// Output only. The replica state.
607 pub state: Option<String>,
608 /// Output only. Additional information about the replication state, if available.
609 #[serde(rename = "stateReasons")]
610 pub state_reasons: Option<Vec<String>>,
611}
612
613impl common::Part for ReplicaConfig {}
614
615/// Replication specifications.
616///
617/// This type is not used in any activity, and only used as *part* of another schema.
618///
619#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
620#[serde_with::serde_as]
621#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
622pub struct Replication {
623 /// Optional. Replicas configuration on the instance. For now, only a single replica config is supported.
624 pub replicas: Option<Vec<ReplicaConfig>>,
625 /// Optional. The replication role.
626 pub role: Option<String>,
627}
628
629impl common::Part for Replication {}
630
631/// RestoreInstanceRequest restores an existing instance’s file share from a backup.
632///
633/// # Activities
634///
635/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
636/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
637///
638/// * [locations instances restore projects](ProjectLocationInstanceRestoreCall) (request)
639#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
640#[serde_with::serde_as]
641#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
642pub struct RestoreInstanceRequest {
643 /// Required. Name of the file share in the Filestore instance that the backup is being restored to.
644 #[serde(rename = "fileShare")]
645 pub file_share: Option<String>,
646 /// The resource name of the backup, in the format `projects/{project_number}/locations/{location_id}/backups/{backup_id}`.
647 #[serde(rename = "sourceBackup")]
648 pub source_backup: Option<String>,
649}
650
651impl common::RequestValue for RestoreInstanceRequest {}
652
653/// RevertInstanceRequest reverts the given instance’s file share to the specified snapshot.
654///
655/// # Activities
656///
657/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
658/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
659///
660/// * [locations instances revert projects](ProjectLocationInstanceRevertCall) (request)
661#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
662#[serde_with::serde_as]
663#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
664pub struct RevertInstanceRequest {
665 /// 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}`
666 #[serde(rename = "targetSnapshotId")]
667 pub target_snapshot_id: Option<String>,
668}
669
670impl common::RequestValue for RevertInstanceRequest {}
671
672/// A Filestore snapshot.
673///
674/// # Activities
675///
676/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
677/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
678///
679/// * [locations instances snapshots create projects](ProjectLocationInstanceSnapshotCreateCall) (request)
680/// * [locations instances snapshots get projects](ProjectLocationInstanceSnapshotGetCall) (response)
681/// * [locations instances snapshots patch projects](ProjectLocationInstanceSnapshotPatchCall) (request)
682#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
683#[serde_with::serde_as]
684#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
685pub struct Snapshot {
686 /// Output only. The time when the snapshot was created.
687 #[serde(rename = "createTime")]
688 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
689 /// A description of the snapshot with 2048 characters or less. Requests with longer descriptions will be rejected.
690 pub description: Option<String>,
691 /// Output only. The amount of bytes needed to allocate a full copy of the snapshot content
692 #[serde(rename = "filesystemUsedBytes")]
693 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
694 pub filesystem_used_bytes: Option<i64>,
695 /// Resource labels to represent user provided metadata.
696 pub labels: Option<HashMap<String, String>>,
697 /// Output only. The resource name of the snapshot, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}/snapshots/{snapshot_id}`.
698 pub name: Option<String>,
699 /// Output only. The snapshot state.
700 pub state: Option<String>,
701 /// Optional. Input only. Immutable. Tag keys/values directly bound to this resource. For example: "123/environment": "production", "123/costCenter": "marketing"
702 pub tags: Option<HashMap<String, String>>,
703}
704
705impl common::RequestValue for Snapshot {}
706impl common::ResponseResult for Snapshot {}
707
708/// 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).
709///
710/// This type is not used in any activity, and only used as *part* of another schema.
711///
712#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
713#[serde_with::serde_as]
714#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
715pub struct Status {
716 /// The status code, which should be an enum value of google.rpc.Code.
717 pub code: Option<i32>,
718 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
719 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
720 /// 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.
721 pub message: Option<String>,
722}
723
724impl common::Part for Status {}
725
726// ###################
727// MethodBuilders ###
728// #################
729
730/// A builder providing access to all methods supported on *project* resources.
731/// It is not used directly, but through the [`CloudFilestore`] hub.
732///
733/// # Example
734///
735/// Instantiate a resource builder
736///
737/// ```test_harness,no_run
738/// extern crate hyper;
739/// extern crate hyper_rustls;
740/// extern crate google_file1 as file1;
741///
742/// # async fn dox() {
743/// use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
744///
745/// let secret: yup_oauth2::ApplicationSecret = Default::default();
746/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
747/// secret,
748/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
749/// ).build().await.unwrap();
750///
751/// let client = hyper_util::client::legacy::Client::builder(
752/// hyper_util::rt::TokioExecutor::new()
753/// )
754/// .build(
755/// hyper_rustls::HttpsConnectorBuilder::new()
756/// .with_native_roots()
757/// .unwrap()
758/// .https_or_http()
759/// .enable_http1()
760/// .build()
761/// );
762/// let mut hub = CloudFilestore::new(client, auth);
763/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
764/// // 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_promote_replica(...)`, `locations_instances_restore(...)`, `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(...)`
765/// // to build up your call.
766/// let rb = hub.projects();
767/// # }
768/// ```
769pub struct ProjectMethods<'a, C>
770where
771 C: 'a,
772{
773 hub: &'a CloudFilestore<C>,
774}
775
776impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
777
778impl<'a, C> ProjectMethods<'a, C> {
779 /// Create a builder to help you perform the following task:
780 ///
781 /// Creates a backup.
782 ///
783 /// # Arguments
784 ///
785 /// * `request` - No description provided.
786 /// * `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**.
787 pub fn locations_backups_create(
788 &self,
789 request: Backup,
790 parent: &str,
791 ) -> ProjectLocationBackupCreateCall<'a, C> {
792 ProjectLocationBackupCreateCall {
793 hub: self.hub,
794 _request: request,
795 _parent: parent.to_string(),
796 _backup_id: Default::default(),
797 _delegate: Default::default(),
798 _additional_params: Default::default(),
799 _scopes: Default::default(),
800 }
801 }
802
803 /// Create a builder to help you perform the following task:
804 ///
805 /// Deletes a backup.
806 ///
807 /// # Arguments
808 ///
809 /// * `name` - Required. The backup resource name, in the format `projects/{project_number}/locations/{location}/backups/{backup_id}`
810 pub fn locations_backups_delete(&self, name: &str) -> ProjectLocationBackupDeleteCall<'a, C> {
811 ProjectLocationBackupDeleteCall {
812 hub: self.hub,
813 _name: name.to_string(),
814 _delegate: Default::default(),
815 _additional_params: Default::default(),
816 _scopes: Default::default(),
817 }
818 }
819
820 /// Create a builder to help you perform the following task:
821 ///
822 /// Gets the details of a specific backup.
823 ///
824 /// # Arguments
825 ///
826 /// * `name` - Required. The backup resource name, in the format `projects/{project_number}/locations/{location}/backups/{backup_id}`.
827 pub fn locations_backups_get(&self, name: &str) -> ProjectLocationBackupGetCall<'a, C> {
828 ProjectLocationBackupGetCall {
829 hub: self.hub,
830 _name: name.to_string(),
831 _delegate: Default::default(),
832 _additional_params: Default::default(),
833 _scopes: Default::default(),
834 }
835 }
836
837 /// Create a builder to help you perform the following task:
838 ///
839 /// Lists all backups in a project for either a specified location or for all locations.
840 ///
841 /// # Arguments
842 ///
843 /// * `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.
844 pub fn locations_backups_list(&self, parent: &str) -> ProjectLocationBackupListCall<'a, C> {
845 ProjectLocationBackupListCall {
846 hub: self.hub,
847 _parent: parent.to_string(),
848 _page_token: Default::default(),
849 _page_size: Default::default(),
850 _order_by: Default::default(),
851 _filter: Default::default(),
852 _delegate: Default::default(),
853 _additional_params: Default::default(),
854 _scopes: Default::default(),
855 }
856 }
857
858 /// Create a builder to help you perform the following task:
859 ///
860 /// Updates the settings of a specific backup.
861 ///
862 /// # Arguments
863 ///
864 /// * `request` - No description provided.
865 /// * `name` - Output only. The resource name of the backup, in the format `projects/{project_number}/locations/{location_id}/backups/{backup_id}`.
866 pub fn locations_backups_patch(
867 &self,
868 request: Backup,
869 name: &str,
870 ) -> ProjectLocationBackupPatchCall<'a, C> {
871 ProjectLocationBackupPatchCall {
872 hub: self.hub,
873 _request: request,
874 _name: name.to_string(),
875 _update_mask: Default::default(),
876 _delegate: Default::default(),
877 _additional_params: Default::default(),
878 _scopes: Default::default(),
879 }
880 }
881
882 /// Create a builder to help you perform the following task:
883 ///
884 /// Creates a snapshot.
885 ///
886 /// # Arguments
887 ///
888 /// * `request` - No description provided.
889 /// * `parent` - Required. The Filestore Instance to create the snapshots of, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`
890 pub fn locations_instances_snapshots_create(
891 &self,
892 request: Snapshot,
893 parent: &str,
894 ) -> ProjectLocationInstanceSnapshotCreateCall<'a, C> {
895 ProjectLocationInstanceSnapshotCreateCall {
896 hub: self.hub,
897 _request: request,
898 _parent: parent.to_string(),
899 _snapshot_id: Default::default(),
900 _delegate: Default::default(),
901 _additional_params: Default::default(),
902 _scopes: Default::default(),
903 }
904 }
905
906 /// Create a builder to help you perform the following task:
907 ///
908 /// Deletes a snapshot.
909 ///
910 /// # Arguments
911 ///
912 /// * `name` - Required. The snapshot resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}/snapshots/{snapshot_id}`
913 pub fn locations_instances_snapshots_delete(
914 &self,
915 name: &str,
916 ) -> ProjectLocationInstanceSnapshotDeleteCall<'a, C> {
917 ProjectLocationInstanceSnapshotDeleteCall {
918 hub: self.hub,
919 _name: name.to_string(),
920 _delegate: Default::default(),
921 _additional_params: Default::default(),
922 _scopes: Default::default(),
923 }
924 }
925
926 /// Create a builder to help you perform the following task:
927 ///
928 /// Gets the details of a specific snapshot.
929 ///
930 /// # Arguments
931 ///
932 /// * `name` - Required. The snapshot resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}/snapshots/{snapshot_id}`
933 pub fn locations_instances_snapshots_get(
934 &self,
935 name: &str,
936 ) -> ProjectLocationInstanceSnapshotGetCall<'a, C> {
937 ProjectLocationInstanceSnapshotGetCall {
938 hub: self.hub,
939 _name: name.to_string(),
940 _delegate: Default::default(),
941 _additional_params: Default::default(),
942 _scopes: Default::default(),
943 }
944 }
945
946 /// Create a builder to help you perform the following task:
947 ///
948 /// Lists all snapshots in a project for either a specified location or for all locations.
949 ///
950 /// # Arguments
951 ///
952 /// * `parent` - Required. The instance for which to retrieve snapshot information, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`.
953 pub fn locations_instances_snapshots_list(
954 &self,
955 parent: &str,
956 ) -> ProjectLocationInstanceSnapshotListCall<'a, C> {
957 ProjectLocationInstanceSnapshotListCall {
958 hub: self.hub,
959 _parent: parent.to_string(),
960 _page_token: Default::default(),
961 _page_size: Default::default(),
962 _order_by: Default::default(),
963 _filter: Default::default(),
964 _delegate: Default::default(),
965 _additional_params: Default::default(),
966 _scopes: Default::default(),
967 }
968 }
969
970 /// Create a builder to help you perform the following task:
971 ///
972 /// Updates the settings of a specific snapshot.
973 ///
974 /// # Arguments
975 ///
976 /// * `request` - No description provided.
977 /// * `name` - Output only. The resource name of the snapshot, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}/snapshots/{snapshot_id}`.
978 pub fn locations_instances_snapshots_patch(
979 &self,
980 request: Snapshot,
981 name: &str,
982 ) -> ProjectLocationInstanceSnapshotPatchCall<'a, C> {
983 ProjectLocationInstanceSnapshotPatchCall {
984 hub: self.hub,
985 _request: request,
986 _name: name.to_string(),
987 _update_mask: Default::default(),
988 _delegate: Default::default(),
989 _additional_params: Default::default(),
990 _scopes: Default::default(),
991 }
992 }
993
994 /// Create a builder to help you perform the following task:
995 ///
996 /// 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).
997 ///
998 /// # Arguments
999 ///
1000 /// * `request` - No description provided.
1001 /// * `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**.
1002 pub fn locations_instances_create(
1003 &self,
1004 request: Instance,
1005 parent: &str,
1006 ) -> ProjectLocationInstanceCreateCall<'a, C> {
1007 ProjectLocationInstanceCreateCall {
1008 hub: self.hub,
1009 _request: request,
1010 _parent: parent.to_string(),
1011 _instance_id: Default::default(),
1012 _delegate: Default::default(),
1013 _additional_params: Default::default(),
1014 _scopes: Default::default(),
1015 }
1016 }
1017
1018 /// Create a builder to help you perform the following task:
1019 ///
1020 /// Deletes an instance.
1021 ///
1022 /// # Arguments
1023 ///
1024 /// * `name` - Required. The instance resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`
1025 pub fn locations_instances_delete(
1026 &self,
1027 name: &str,
1028 ) -> ProjectLocationInstanceDeleteCall<'a, C> {
1029 ProjectLocationInstanceDeleteCall {
1030 hub: self.hub,
1031 _name: name.to_string(),
1032 _force: Default::default(),
1033 _delegate: Default::default(),
1034 _additional_params: Default::default(),
1035 _scopes: Default::default(),
1036 }
1037 }
1038
1039 /// Create a builder to help you perform the following task:
1040 ///
1041 /// Gets the details of a specific instance.
1042 ///
1043 /// # Arguments
1044 ///
1045 /// * `name` - Required. The instance resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`.
1046 pub fn locations_instances_get(&self, name: &str) -> ProjectLocationInstanceGetCall<'a, C> {
1047 ProjectLocationInstanceGetCall {
1048 hub: self.hub,
1049 _name: name.to_string(),
1050 _delegate: Default::default(),
1051 _additional_params: Default::default(),
1052 _scopes: Default::default(),
1053 }
1054 }
1055
1056 /// Create a builder to help you perform the following task:
1057 ///
1058 /// Lists all instances in a project for either a specified location or for all locations.
1059 ///
1060 /// # Arguments
1061 ///
1062 /// * `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.
1063 pub fn locations_instances_list(&self, parent: &str) -> ProjectLocationInstanceListCall<'a, C> {
1064 ProjectLocationInstanceListCall {
1065 hub: self.hub,
1066 _parent: parent.to_string(),
1067 _page_token: Default::default(),
1068 _page_size: Default::default(),
1069 _order_by: Default::default(),
1070 _filter: Default::default(),
1071 _delegate: Default::default(),
1072 _additional_params: Default::default(),
1073 _scopes: Default::default(),
1074 }
1075 }
1076
1077 /// Create a builder to help you perform the following task:
1078 ///
1079 /// Updates the settings of a specific instance.
1080 ///
1081 /// # Arguments
1082 ///
1083 /// * `request` - No description provided.
1084 /// * `name` - Output only. The resource name of the instance, in the format `projects/{project}/locations/{location}/instances/{instance}`.
1085 pub fn locations_instances_patch(
1086 &self,
1087 request: Instance,
1088 name: &str,
1089 ) -> ProjectLocationInstancePatchCall<'a, C> {
1090 ProjectLocationInstancePatchCall {
1091 hub: self.hub,
1092 _request: request,
1093 _name: name.to_string(),
1094 _update_mask: 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 /// Promote an standby instance (replica).
1104 ///
1105 /// # Arguments
1106 ///
1107 /// * `request` - No description provided.
1108 /// * `name` - Required. The resource name of the instance, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}`.
1109 pub fn locations_instances_promote_replica(
1110 &self,
1111 request: PromoteReplicaRequest,
1112 name: &str,
1113 ) -> ProjectLocationInstancePromoteReplicaCall<'a, C> {
1114 ProjectLocationInstancePromoteReplicaCall {
1115 hub: self.hub,
1116 _request: request,
1117 _name: name.to_string(),
1118 _delegate: Default::default(),
1119 _additional_params: Default::default(),
1120 _scopes: Default::default(),
1121 }
1122 }
1123
1124 /// Create a builder to help you perform the following task:
1125 ///
1126 /// 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).
1127 ///
1128 /// # Arguments
1129 ///
1130 /// * `request` - No description provided.
1131 /// * `name` - Required. The resource name of the instance, in the format `projects/{project_number}/locations/{location_id}/instances/{instance_id}`.
1132 pub fn locations_instances_restore(
1133 &self,
1134 request: RestoreInstanceRequest,
1135 name: &str,
1136 ) -> ProjectLocationInstanceRestoreCall<'a, C> {
1137 ProjectLocationInstanceRestoreCall {
1138 hub: self.hub,
1139 _request: request,
1140 _name: name.to_string(),
1141 _delegate: Default::default(),
1142 _additional_params: Default::default(),
1143 _scopes: Default::default(),
1144 }
1145 }
1146
1147 /// Create a builder to help you perform the following task:
1148 ///
1149 /// Revert an existing instance's file system to a specified snapshot.
1150 ///
1151 /// # Arguments
1152 ///
1153 /// * `request` - No description provided.
1154 /// * `name` - Required. The resource name of the instance, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}`.
1155 pub fn locations_instances_revert(
1156 &self,
1157 request: RevertInstanceRequest,
1158 name: &str,
1159 ) -> ProjectLocationInstanceRevertCall<'a, C> {
1160 ProjectLocationInstanceRevertCall {
1161 hub: self.hub,
1162 _request: request,
1163 _name: name.to_string(),
1164 _delegate: Default::default(),
1165 _additional_params: Default::default(),
1166 _scopes: Default::default(),
1167 }
1168 }
1169
1170 /// Create a builder to help you perform the following task:
1171 ///
1172 /// 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`.
1173 ///
1174 /// # Arguments
1175 ///
1176 /// * `request` - No description provided.
1177 /// * `name` - The name of the operation resource to be cancelled.
1178 pub fn locations_operations_cancel(
1179 &self,
1180 request: CancelOperationRequest,
1181 name: &str,
1182 ) -> ProjectLocationOperationCancelCall<'a, C> {
1183 ProjectLocationOperationCancelCall {
1184 hub: self.hub,
1185 _request: request,
1186 _name: name.to_string(),
1187 _delegate: Default::default(),
1188 _additional_params: Default::default(),
1189 _scopes: Default::default(),
1190 }
1191 }
1192
1193 /// Create a builder to help you perform the following task:
1194 ///
1195 /// 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`.
1196 ///
1197 /// # Arguments
1198 ///
1199 /// * `name` - The name of the operation resource to be deleted.
1200 pub fn locations_operations_delete(
1201 &self,
1202 name: &str,
1203 ) -> ProjectLocationOperationDeleteCall<'a, C> {
1204 ProjectLocationOperationDeleteCall {
1205 hub: self.hub,
1206 _name: name.to_string(),
1207 _delegate: Default::default(),
1208 _additional_params: Default::default(),
1209 _scopes: Default::default(),
1210 }
1211 }
1212
1213 /// Create a builder to help you perform the following task:
1214 ///
1215 /// 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.
1216 ///
1217 /// # Arguments
1218 ///
1219 /// * `name` - The name of the operation resource.
1220 pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
1221 ProjectLocationOperationGetCall {
1222 hub: self.hub,
1223 _name: name.to_string(),
1224 _delegate: Default::default(),
1225 _additional_params: Default::default(),
1226 _scopes: Default::default(),
1227 }
1228 }
1229
1230 /// Create a builder to help you perform the following task:
1231 ///
1232 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
1233 ///
1234 /// # Arguments
1235 ///
1236 /// * `name` - The name of the operation's parent resource.
1237 pub fn locations_operations_list(&self, name: &str) -> ProjectLocationOperationListCall<'a, C> {
1238 ProjectLocationOperationListCall {
1239 hub: self.hub,
1240 _name: name.to_string(),
1241 _page_token: Default::default(),
1242 _page_size: Default::default(),
1243 _filter: Default::default(),
1244 _delegate: Default::default(),
1245 _additional_params: Default::default(),
1246 _scopes: Default::default(),
1247 }
1248 }
1249
1250 /// Create a builder to help you perform the following task:
1251 ///
1252 /// Gets information about a location.
1253 ///
1254 /// # Arguments
1255 ///
1256 /// * `name` - Resource name for the location.
1257 pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
1258 ProjectLocationGetCall {
1259 hub: self.hub,
1260 _name: name.to_string(),
1261 _delegate: Default::default(),
1262 _additional_params: Default::default(),
1263 _scopes: Default::default(),
1264 }
1265 }
1266
1267 /// Create a builder to help you perform the following task:
1268 ///
1269 /// Lists information about the supported locations for this service.
1270 ///
1271 /// # Arguments
1272 ///
1273 /// * `name` - The resource that owns the locations collection, if applicable.
1274 pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
1275 ProjectLocationListCall {
1276 hub: self.hub,
1277 _name: name.to_string(),
1278 _page_token: Default::default(),
1279 _page_size: Default::default(),
1280 _include_unrevealed_locations: Default::default(),
1281 _filter: Default::default(),
1282 _delegate: Default::default(),
1283 _additional_params: Default::default(),
1284 _scopes: Default::default(),
1285 }
1286 }
1287}
1288
1289// ###################
1290// CallBuilders ###
1291// #################
1292
1293/// Creates a backup.
1294///
1295/// A builder for the *locations.backups.create* method supported by a *project* resource.
1296/// It is not used directly, but through a [`ProjectMethods`] instance.
1297///
1298/// # Example
1299///
1300/// Instantiate a resource method builder
1301///
1302/// ```test_harness,no_run
1303/// # extern crate hyper;
1304/// # extern crate hyper_rustls;
1305/// # extern crate google_file1 as file1;
1306/// use file1::api::Backup;
1307/// # async fn dox() {
1308/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1309///
1310/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1311/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1312/// # secret,
1313/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1314/// # ).build().await.unwrap();
1315///
1316/// # let client = hyper_util::client::legacy::Client::builder(
1317/// # hyper_util::rt::TokioExecutor::new()
1318/// # )
1319/// # .build(
1320/// # hyper_rustls::HttpsConnectorBuilder::new()
1321/// # .with_native_roots()
1322/// # .unwrap()
1323/// # .https_or_http()
1324/// # .enable_http1()
1325/// # .build()
1326/// # );
1327/// # let mut hub = CloudFilestore::new(client, auth);
1328/// // As the method needs a request, you would usually fill it with the desired information
1329/// // into the respective structure. Some of the parts shown here might not be applicable !
1330/// // Values shown here are possibly random and not representative !
1331/// let mut req = Backup::default();
1332///
1333/// // You can configure optional parameters by calling the respective setters at will, and
1334/// // execute the final call using `doit()`.
1335/// // Values shown here are possibly random and not representative !
1336/// let result = hub.projects().locations_backups_create(req, "parent")
1337/// .backup_id("sed")
1338/// .doit().await;
1339/// # }
1340/// ```
1341pub struct ProjectLocationBackupCreateCall<'a, C>
1342where
1343 C: 'a,
1344{
1345 hub: &'a CloudFilestore<C>,
1346 _request: Backup,
1347 _parent: String,
1348 _backup_id: Option<String>,
1349 _delegate: Option<&'a mut dyn common::Delegate>,
1350 _additional_params: HashMap<String, String>,
1351 _scopes: BTreeSet<String>,
1352}
1353
1354impl<'a, C> common::CallBuilder for ProjectLocationBackupCreateCall<'a, C> {}
1355
1356impl<'a, C> ProjectLocationBackupCreateCall<'a, C>
1357where
1358 C: common::Connector,
1359{
1360 /// Perform the operation you have build so far.
1361 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1362 use std::borrow::Cow;
1363 use std::io::{Read, Seek};
1364
1365 use common::{url::Params, ToParts};
1366 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1367
1368 let mut dd = common::DefaultDelegate;
1369 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1370 dlg.begin(common::MethodInfo {
1371 id: "file.projects.locations.backups.create",
1372 http_method: hyper::Method::POST,
1373 });
1374
1375 for &field in ["alt", "parent", "backupId"].iter() {
1376 if self._additional_params.contains_key(field) {
1377 dlg.finished(false);
1378 return Err(common::Error::FieldClash(field));
1379 }
1380 }
1381
1382 let mut params = Params::with_capacity(5 + self._additional_params.len());
1383 params.push("parent", self._parent);
1384 if let Some(value) = self._backup_id.as_ref() {
1385 params.push("backupId", value);
1386 }
1387
1388 params.extend(self._additional_params.iter());
1389
1390 params.push("alt", "json");
1391 let mut url = self.hub._base_url.clone() + "v1/{+parent}/backups";
1392 if self._scopes.is_empty() {
1393 self._scopes
1394 .insert(Scope::CloudPlatform.as_ref().to_string());
1395 }
1396
1397 #[allow(clippy::single_element_loop)]
1398 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1399 url = params.uri_replacement(url, param_name, find_this, true);
1400 }
1401 {
1402 let to_remove = ["parent"];
1403 params.remove_params(&to_remove);
1404 }
1405
1406 let url = params.parse_with_url(&url);
1407
1408 let mut json_mime_type = mime::APPLICATION_JSON;
1409 let mut request_value_reader = {
1410 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1411 common::remove_json_null_values(&mut value);
1412 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1413 serde_json::to_writer(&mut dst, &value).unwrap();
1414 dst
1415 };
1416 let request_size = request_value_reader
1417 .seek(std::io::SeekFrom::End(0))
1418 .unwrap();
1419 request_value_reader
1420 .seek(std::io::SeekFrom::Start(0))
1421 .unwrap();
1422
1423 loop {
1424 let token = match self
1425 .hub
1426 .auth
1427 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1428 .await
1429 {
1430 Ok(token) => token,
1431 Err(e) => match dlg.token(e) {
1432 Ok(token) => token,
1433 Err(e) => {
1434 dlg.finished(false);
1435 return Err(common::Error::MissingToken(e));
1436 }
1437 },
1438 };
1439 request_value_reader
1440 .seek(std::io::SeekFrom::Start(0))
1441 .unwrap();
1442 let mut req_result = {
1443 let client = &self.hub.client;
1444 dlg.pre_request();
1445 let mut req_builder = hyper::Request::builder()
1446 .method(hyper::Method::POST)
1447 .uri(url.as_str())
1448 .header(USER_AGENT, self.hub._user_agent.clone());
1449
1450 if let Some(token) = token.as_ref() {
1451 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1452 }
1453
1454 let request = req_builder
1455 .header(CONTENT_TYPE, json_mime_type.to_string())
1456 .header(CONTENT_LENGTH, request_size as u64)
1457 .body(common::to_body(
1458 request_value_reader.get_ref().clone().into(),
1459 ));
1460
1461 client.request(request.unwrap()).await
1462 };
1463
1464 match req_result {
1465 Err(err) => {
1466 if let common::Retry::After(d) = dlg.http_error(&err) {
1467 sleep(d).await;
1468 continue;
1469 }
1470 dlg.finished(false);
1471 return Err(common::Error::HttpError(err));
1472 }
1473 Ok(res) => {
1474 let (mut parts, body) = res.into_parts();
1475 let mut body = common::Body::new(body);
1476 if !parts.status.is_success() {
1477 let bytes = common::to_bytes(body).await.unwrap_or_default();
1478 let error = serde_json::from_str(&common::to_string(&bytes));
1479 let response = common::to_response(parts, bytes.into());
1480
1481 if let common::Retry::After(d) =
1482 dlg.http_failure(&response, error.as_ref().ok())
1483 {
1484 sleep(d).await;
1485 continue;
1486 }
1487
1488 dlg.finished(false);
1489
1490 return Err(match error {
1491 Ok(value) => common::Error::BadRequest(value),
1492 _ => common::Error::Failure(response),
1493 });
1494 }
1495 let response = {
1496 let bytes = common::to_bytes(body).await.unwrap_or_default();
1497 let encoded = common::to_string(&bytes);
1498 match serde_json::from_str(&encoded) {
1499 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1500 Err(error) => {
1501 dlg.response_json_decode_error(&encoded, &error);
1502 return Err(common::Error::JsonDecodeError(
1503 encoded.to_string(),
1504 error,
1505 ));
1506 }
1507 }
1508 };
1509
1510 dlg.finished(true);
1511 return Ok(response);
1512 }
1513 }
1514 }
1515 }
1516
1517 ///
1518 /// Sets the *request* property to the given value.
1519 ///
1520 /// Even though the property as already been set when instantiating this call,
1521 /// we provide this method for API completeness.
1522 pub fn request(mut self, new_value: Backup) -> ProjectLocationBackupCreateCall<'a, C> {
1523 self._request = new_value;
1524 self
1525 }
1526 /// 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**.
1527 ///
1528 /// Sets the *parent* path property to the given value.
1529 ///
1530 /// Even though the property as already been set when instantiating this call,
1531 /// we provide this method for API completeness.
1532 pub fn parent(mut self, new_value: &str) -> ProjectLocationBackupCreateCall<'a, C> {
1533 self._parent = new_value.to_string();
1534 self
1535 }
1536 /// 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.
1537 ///
1538 /// Sets the *backup id* query property to the given value.
1539 pub fn backup_id(mut self, new_value: &str) -> ProjectLocationBackupCreateCall<'a, C> {
1540 self._backup_id = Some(new_value.to_string());
1541 self
1542 }
1543 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1544 /// while executing the actual API request.
1545 ///
1546 /// ````text
1547 /// It should be used to handle progress information, and to implement a certain level of resilience.
1548 /// ````
1549 ///
1550 /// Sets the *delegate* property to the given value.
1551 pub fn delegate(
1552 mut self,
1553 new_value: &'a mut dyn common::Delegate,
1554 ) -> ProjectLocationBackupCreateCall<'a, C> {
1555 self._delegate = Some(new_value);
1556 self
1557 }
1558
1559 /// Set any additional parameter of the query string used in the request.
1560 /// It should be used to set parameters which are not yet available through their own
1561 /// setters.
1562 ///
1563 /// Please note that this method must not be used to set any of the known parameters
1564 /// which have their own setter method. If done anyway, the request will fail.
1565 ///
1566 /// # Additional Parameters
1567 ///
1568 /// * *$.xgafv* (query-string) - V1 error format.
1569 /// * *access_token* (query-string) - OAuth access token.
1570 /// * *alt* (query-string) - Data format for response.
1571 /// * *callback* (query-string) - JSONP
1572 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1573 /// * *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.
1574 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1575 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1576 /// * *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.
1577 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1578 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1579 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBackupCreateCall<'a, C>
1580 where
1581 T: AsRef<str>,
1582 {
1583 self._additional_params
1584 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1585 self
1586 }
1587
1588 /// Identifies the authorization scope for the method you are building.
1589 ///
1590 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1591 /// [`Scope::CloudPlatform`].
1592 ///
1593 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1594 /// tokens for more than one scope.
1595 ///
1596 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1597 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1598 /// sufficient, a read-write scope will do as well.
1599 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBackupCreateCall<'a, C>
1600 where
1601 St: AsRef<str>,
1602 {
1603 self._scopes.insert(String::from(scope.as_ref()));
1604 self
1605 }
1606 /// Identifies the authorization scope(s) for the method you are building.
1607 ///
1608 /// See [`Self::add_scope()`] for details.
1609 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBackupCreateCall<'a, C>
1610 where
1611 I: IntoIterator<Item = St>,
1612 St: AsRef<str>,
1613 {
1614 self._scopes
1615 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1616 self
1617 }
1618
1619 /// Removes all scopes, and no default scope will be used either.
1620 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1621 /// for details).
1622 pub fn clear_scopes(mut self) -> ProjectLocationBackupCreateCall<'a, C> {
1623 self._scopes.clear();
1624 self
1625 }
1626}
1627
1628/// Deletes a backup.
1629///
1630/// A builder for the *locations.backups.delete* method supported by a *project* resource.
1631/// It is not used directly, but through a [`ProjectMethods`] instance.
1632///
1633/// # Example
1634///
1635/// Instantiate a resource method builder
1636///
1637/// ```test_harness,no_run
1638/// # extern crate hyper;
1639/// # extern crate hyper_rustls;
1640/// # extern crate google_file1 as file1;
1641/// # async fn dox() {
1642/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1643///
1644/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1645/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1646/// # secret,
1647/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1648/// # ).build().await.unwrap();
1649///
1650/// # let client = hyper_util::client::legacy::Client::builder(
1651/// # hyper_util::rt::TokioExecutor::new()
1652/// # )
1653/// # .build(
1654/// # hyper_rustls::HttpsConnectorBuilder::new()
1655/// # .with_native_roots()
1656/// # .unwrap()
1657/// # .https_or_http()
1658/// # .enable_http1()
1659/// # .build()
1660/// # );
1661/// # let mut hub = CloudFilestore::new(client, auth);
1662/// // You can configure optional parameters by calling the respective setters at will, and
1663/// // execute the final call using `doit()`.
1664/// // Values shown here are possibly random and not representative !
1665/// let result = hub.projects().locations_backups_delete("name")
1666/// .doit().await;
1667/// # }
1668/// ```
1669pub struct ProjectLocationBackupDeleteCall<'a, C>
1670where
1671 C: 'a,
1672{
1673 hub: &'a CloudFilestore<C>,
1674 _name: String,
1675 _delegate: Option<&'a mut dyn common::Delegate>,
1676 _additional_params: HashMap<String, String>,
1677 _scopes: BTreeSet<String>,
1678}
1679
1680impl<'a, C> common::CallBuilder for ProjectLocationBackupDeleteCall<'a, C> {}
1681
1682impl<'a, C> ProjectLocationBackupDeleteCall<'a, C>
1683where
1684 C: common::Connector,
1685{
1686 /// Perform the operation you have build so far.
1687 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1688 use std::borrow::Cow;
1689 use std::io::{Read, Seek};
1690
1691 use common::{url::Params, ToParts};
1692 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1693
1694 let mut dd = common::DefaultDelegate;
1695 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1696 dlg.begin(common::MethodInfo {
1697 id: "file.projects.locations.backups.delete",
1698 http_method: hyper::Method::DELETE,
1699 });
1700
1701 for &field in ["alt", "name"].iter() {
1702 if self._additional_params.contains_key(field) {
1703 dlg.finished(false);
1704 return Err(common::Error::FieldClash(field));
1705 }
1706 }
1707
1708 let mut params = Params::with_capacity(3 + self._additional_params.len());
1709 params.push("name", self._name);
1710
1711 params.extend(self._additional_params.iter());
1712
1713 params.push("alt", "json");
1714 let mut url = self.hub._base_url.clone() + "v1/{+name}";
1715 if self._scopes.is_empty() {
1716 self._scopes
1717 .insert(Scope::CloudPlatform.as_ref().to_string());
1718 }
1719
1720 #[allow(clippy::single_element_loop)]
1721 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1722 url = params.uri_replacement(url, param_name, find_this, true);
1723 }
1724 {
1725 let to_remove = ["name"];
1726 params.remove_params(&to_remove);
1727 }
1728
1729 let url = params.parse_with_url(&url);
1730
1731 loop {
1732 let token = match self
1733 .hub
1734 .auth
1735 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1736 .await
1737 {
1738 Ok(token) => token,
1739 Err(e) => match dlg.token(e) {
1740 Ok(token) => token,
1741 Err(e) => {
1742 dlg.finished(false);
1743 return Err(common::Error::MissingToken(e));
1744 }
1745 },
1746 };
1747 let mut req_result = {
1748 let client = &self.hub.client;
1749 dlg.pre_request();
1750 let mut req_builder = hyper::Request::builder()
1751 .method(hyper::Method::DELETE)
1752 .uri(url.as_str())
1753 .header(USER_AGENT, self.hub._user_agent.clone());
1754
1755 if let Some(token) = token.as_ref() {
1756 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1757 }
1758
1759 let request = req_builder
1760 .header(CONTENT_LENGTH, 0_u64)
1761 .body(common::to_body::<String>(None));
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 /// Required. The backup resource name, in the format `projects/{project_number}/locations/{location}/backups/{backup_id}`
1820 ///
1821 /// Sets the *name* path property to the given value.
1822 ///
1823 /// Even though the property as already been set when instantiating this call,
1824 /// we provide this method for API completeness.
1825 pub fn name(mut self, new_value: &str) -> ProjectLocationBackupDeleteCall<'a, C> {
1826 self._name = new_value.to_string();
1827 self
1828 }
1829 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1830 /// while executing the actual API request.
1831 ///
1832 /// ````text
1833 /// It should be used to handle progress information, and to implement a certain level of resilience.
1834 /// ````
1835 ///
1836 /// Sets the *delegate* property to the given value.
1837 pub fn delegate(
1838 mut self,
1839 new_value: &'a mut dyn common::Delegate,
1840 ) -> ProjectLocationBackupDeleteCall<'a, C> {
1841 self._delegate = Some(new_value);
1842 self
1843 }
1844
1845 /// Set any additional parameter of the query string used in the request.
1846 /// It should be used to set parameters which are not yet available through their own
1847 /// setters.
1848 ///
1849 /// Please note that this method must not be used to set any of the known parameters
1850 /// which have their own setter method. If done anyway, the request will fail.
1851 ///
1852 /// # Additional Parameters
1853 ///
1854 /// * *$.xgafv* (query-string) - V1 error format.
1855 /// * *access_token* (query-string) - OAuth access token.
1856 /// * *alt* (query-string) - Data format for response.
1857 /// * *callback* (query-string) - JSONP
1858 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1859 /// * *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.
1860 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1861 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1862 /// * *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.
1863 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1864 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1865 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBackupDeleteCall<'a, C>
1866 where
1867 T: AsRef<str>,
1868 {
1869 self._additional_params
1870 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1871 self
1872 }
1873
1874 /// Identifies the authorization scope for the method you are building.
1875 ///
1876 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1877 /// [`Scope::CloudPlatform`].
1878 ///
1879 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1880 /// tokens for more than one scope.
1881 ///
1882 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1883 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1884 /// sufficient, a read-write scope will do as well.
1885 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBackupDeleteCall<'a, C>
1886 where
1887 St: AsRef<str>,
1888 {
1889 self._scopes.insert(String::from(scope.as_ref()));
1890 self
1891 }
1892 /// Identifies the authorization scope(s) for the method you are building.
1893 ///
1894 /// See [`Self::add_scope()`] for details.
1895 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBackupDeleteCall<'a, C>
1896 where
1897 I: IntoIterator<Item = St>,
1898 St: AsRef<str>,
1899 {
1900 self._scopes
1901 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1902 self
1903 }
1904
1905 /// Removes all scopes, and no default scope will be used either.
1906 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1907 /// for details).
1908 pub fn clear_scopes(mut self) -> ProjectLocationBackupDeleteCall<'a, C> {
1909 self._scopes.clear();
1910 self
1911 }
1912}
1913
1914/// Gets the details of a specific backup.
1915///
1916/// A builder for the *locations.backups.get* method supported by a *project* resource.
1917/// It is not used directly, but through a [`ProjectMethods`] instance.
1918///
1919/// # Example
1920///
1921/// Instantiate a resource method builder
1922///
1923/// ```test_harness,no_run
1924/// # extern crate hyper;
1925/// # extern crate hyper_rustls;
1926/// # extern crate google_file1 as file1;
1927/// # async fn dox() {
1928/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1929///
1930/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1931/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1932/// # secret,
1933/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1934/// # ).build().await.unwrap();
1935///
1936/// # let client = hyper_util::client::legacy::Client::builder(
1937/// # hyper_util::rt::TokioExecutor::new()
1938/// # )
1939/// # .build(
1940/// # hyper_rustls::HttpsConnectorBuilder::new()
1941/// # .with_native_roots()
1942/// # .unwrap()
1943/// # .https_or_http()
1944/// # .enable_http1()
1945/// # .build()
1946/// # );
1947/// # let mut hub = CloudFilestore::new(client, auth);
1948/// // You can configure optional parameters by calling the respective setters at will, and
1949/// // execute the final call using `doit()`.
1950/// // Values shown here are possibly random and not representative !
1951/// let result = hub.projects().locations_backups_get("name")
1952/// .doit().await;
1953/// # }
1954/// ```
1955pub struct ProjectLocationBackupGetCall<'a, C>
1956where
1957 C: 'a,
1958{
1959 hub: &'a CloudFilestore<C>,
1960 _name: String,
1961 _delegate: Option<&'a mut dyn common::Delegate>,
1962 _additional_params: HashMap<String, String>,
1963 _scopes: BTreeSet<String>,
1964}
1965
1966impl<'a, C> common::CallBuilder for ProjectLocationBackupGetCall<'a, C> {}
1967
1968impl<'a, C> ProjectLocationBackupGetCall<'a, C>
1969where
1970 C: common::Connector,
1971{
1972 /// Perform the operation you have build so far.
1973 pub async fn doit(mut self) -> common::Result<(common::Response, Backup)> {
1974 use std::borrow::Cow;
1975 use std::io::{Read, Seek};
1976
1977 use common::{url::Params, ToParts};
1978 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1979
1980 let mut dd = common::DefaultDelegate;
1981 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1982 dlg.begin(common::MethodInfo {
1983 id: "file.projects.locations.backups.get",
1984 http_method: hyper::Method::GET,
1985 });
1986
1987 for &field in ["alt", "name"].iter() {
1988 if self._additional_params.contains_key(field) {
1989 dlg.finished(false);
1990 return Err(common::Error::FieldClash(field));
1991 }
1992 }
1993
1994 let mut params = Params::with_capacity(3 + self._additional_params.len());
1995 params.push("name", self._name);
1996
1997 params.extend(self._additional_params.iter());
1998
1999 params.push("alt", "json");
2000 let mut url = self.hub._base_url.clone() + "v1/{+name}";
2001 if self._scopes.is_empty() {
2002 self._scopes
2003 .insert(Scope::CloudPlatform.as_ref().to_string());
2004 }
2005
2006 #[allow(clippy::single_element_loop)]
2007 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2008 url = params.uri_replacement(url, param_name, find_this, true);
2009 }
2010 {
2011 let to_remove = ["name"];
2012 params.remove_params(&to_remove);
2013 }
2014
2015 let url = params.parse_with_url(&url);
2016
2017 loop {
2018 let token = match self
2019 .hub
2020 .auth
2021 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2022 .await
2023 {
2024 Ok(token) => token,
2025 Err(e) => match dlg.token(e) {
2026 Ok(token) => token,
2027 Err(e) => {
2028 dlg.finished(false);
2029 return Err(common::Error::MissingToken(e));
2030 }
2031 },
2032 };
2033 let mut req_result = {
2034 let client = &self.hub.client;
2035 dlg.pre_request();
2036 let mut req_builder = hyper::Request::builder()
2037 .method(hyper::Method::GET)
2038 .uri(url.as_str())
2039 .header(USER_AGENT, self.hub._user_agent.clone());
2040
2041 if let Some(token) = token.as_ref() {
2042 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2043 }
2044
2045 let request = req_builder
2046 .header(CONTENT_LENGTH, 0_u64)
2047 .body(common::to_body::<String>(None));
2048
2049 client.request(request.unwrap()).await
2050 };
2051
2052 match req_result {
2053 Err(err) => {
2054 if let common::Retry::After(d) = dlg.http_error(&err) {
2055 sleep(d).await;
2056 continue;
2057 }
2058 dlg.finished(false);
2059 return Err(common::Error::HttpError(err));
2060 }
2061 Ok(res) => {
2062 let (mut parts, body) = res.into_parts();
2063 let mut body = common::Body::new(body);
2064 if !parts.status.is_success() {
2065 let bytes = common::to_bytes(body).await.unwrap_or_default();
2066 let error = serde_json::from_str(&common::to_string(&bytes));
2067 let response = common::to_response(parts, bytes.into());
2068
2069 if let common::Retry::After(d) =
2070 dlg.http_failure(&response, error.as_ref().ok())
2071 {
2072 sleep(d).await;
2073 continue;
2074 }
2075
2076 dlg.finished(false);
2077
2078 return Err(match error {
2079 Ok(value) => common::Error::BadRequest(value),
2080 _ => common::Error::Failure(response),
2081 });
2082 }
2083 let response = {
2084 let bytes = common::to_bytes(body).await.unwrap_or_default();
2085 let encoded = common::to_string(&bytes);
2086 match serde_json::from_str(&encoded) {
2087 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2088 Err(error) => {
2089 dlg.response_json_decode_error(&encoded, &error);
2090 return Err(common::Error::JsonDecodeError(
2091 encoded.to_string(),
2092 error,
2093 ));
2094 }
2095 }
2096 };
2097
2098 dlg.finished(true);
2099 return Ok(response);
2100 }
2101 }
2102 }
2103 }
2104
2105 /// Required. The backup resource name, in the format `projects/{project_number}/locations/{location}/backups/{backup_id}`.
2106 ///
2107 /// Sets the *name* path property to the given value.
2108 ///
2109 /// Even though the property as already been set when instantiating this call,
2110 /// we provide this method for API completeness.
2111 pub fn name(mut self, new_value: &str) -> ProjectLocationBackupGetCall<'a, C> {
2112 self._name = new_value.to_string();
2113 self
2114 }
2115 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2116 /// while executing the actual API request.
2117 ///
2118 /// ````text
2119 /// It should be used to handle progress information, and to implement a certain level of resilience.
2120 /// ````
2121 ///
2122 /// Sets the *delegate* property to the given value.
2123 pub fn delegate(
2124 mut self,
2125 new_value: &'a mut dyn common::Delegate,
2126 ) -> ProjectLocationBackupGetCall<'a, C> {
2127 self._delegate = Some(new_value);
2128 self
2129 }
2130
2131 /// Set any additional parameter of the query string used in the request.
2132 /// It should be used to set parameters which are not yet available through their own
2133 /// setters.
2134 ///
2135 /// Please note that this method must not be used to set any of the known parameters
2136 /// which have their own setter method. If done anyway, the request will fail.
2137 ///
2138 /// # Additional Parameters
2139 ///
2140 /// * *$.xgafv* (query-string) - V1 error format.
2141 /// * *access_token* (query-string) - OAuth access token.
2142 /// * *alt* (query-string) - Data format for response.
2143 /// * *callback* (query-string) - JSONP
2144 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2145 /// * *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.
2146 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2147 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2148 /// * *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.
2149 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2150 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2151 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBackupGetCall<'a, C>
2152 where
2153 T: AsRef<str>,
2154 {
2155 self._additional_params
2156 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2157 self
2158 }
2159
2160 /// Identifies the authorization scope for the method you are building.
2161 ///
2162 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2163 /// [`Scope::CloudPlatform`].
2164 ///
2165 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2166 /// tokens for more than one scope.
2167 ///
2168 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2169 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2170 /// sufficient, a read-write scope will do as well.
2171 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBackupGetCall<'a, C>
2172 where
2173 St: AsRef<str>,
2174 {
2175 self._scopes.insert(String::from(scope.as_ref()));
2176 self
2177 }
2178 /// Identifies the authorization scope(s) for the method you are building.
2179 ///
2180 /// See [`Self::add_scope()`] for details.
2181 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBackupGetCall<'a, C>
2182 where
2183 I: IntoIterator<Item = St>,
2184 St: AsRef<str>,
2185 {
2186 self._scopes
2187 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2188 self
2189 }
2190
2191 /// Removes all scopes, and no default scope will be used either.
2192 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2193 /// for details).
2194 pub fn clear_scopes(mut self) -> ProjectLocationBackupGetCall<'a, C> {
2195 self._scopes.clear();
2196 self
2197 }
2198}
2199
2200/// Lists all backups in a project for either a specified location or for all locations.
2201///
2202/// A builder for the *locations.backups.list* method supported by a *project* resource.
2203/// It is not used directly, but through a [`ProjectMethods`] instance.
2204///
2205/// # Example
2206///
2207/// Instantiate a resource method builder
2208///
2209/// ```test_harness,no_run
2210/// # extern crate hyper;
2211/// # extern crate hyper_rustls;
2212/// # extern crate google_file1 as file1;
2213/// # async fn dox() {
2214/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2215///
2216/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2217/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2218/// # secret,
2219/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2220/// # ).build().await.unwrap();
2221///
2222/// # let client = hyper_util::client::legacy::Client::builder(
2223/// # hyper_util::rt::TokioExecutor::new()
2224/// # )
2225/// # .build(
2226/// # hyper_rustls::HttpsConnectorBuilder::new()
2227/// # .with_native_roots()
2228/// # .unwrap()
2229/// # .https_or_http()
2230/// # .enable_http1()
2231/// # .build()
2232/// # );
2233/// # let mut hub = CloudFilestore::new(client, auth);
2234/// // You can configure optional parameters by calling the respective setters at will, and
2235/// // execute the final call using `doit()`.
2236/// // Values shown here are possibly random and not representative !
2237/// let result = hub.projects().locations_backups_list("parent")
2238/// .page_token("duo")
2239/// .page_size(-55)
2240/// .order_by("gubergren")
2241/// .filter("Lorem")
2242/// .doit().await;
2243/// # }
2244/// ```
2245pub struct ProjectLocationBackupListCall<'a, C>
2246where
2247 C: 'a,
2248{
2249 hub: &'a CloudFilestore<C>,
2250 _parent: String,
2251 _page_token: Option<String>,
2252 _page_size: Option<i32>,
2253 _order_by: Option<String>,
2254 _filter: Option<String>,
2255 _delegate: Option<&'a mut dyn common::Delegate>,
2256 _additional_params: HashMap<String, String>,
2257 _scopes: BTreeSet<String>,
2258}
2259
2260impl<'a, C> common::CallBuilder for ProjectLocationBackupListCall<'a, C> {}
2261
2262impl<'a, C> ProjectLocationBackupListCall<'a, C>
2263where
2264 C: common::Connector,
2265{
2266 /// Perform the operation you have build so far.
2267 pub async fn doit(mut self) -> common::Result<(common::Response, ListBackupsResponse)> {
2268 use std::borrow::Cow;
2269 use std::io::{Read, Seek};
2270
2271 use common::{url::Params, ToParts};
2272 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2273
2274 let mut dd = common::DefaultDelegate;
2275 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2276 dlg.begin(common::MethodInfo {
2277 id: "file.projects.locations.backups.list",
2278 http_method: hyper::Method::GET,
2279 });
2280
2281 for &field in [
2282 "alt",
2283 "parent",
2284 "pageToken",
2285 "pageSize",
2286 "orderBy",
2287 "filter",
2288 ]
2289 .iter()
2290 {
2291 if self._additional_params.contains_key(field) {
2292 dlg.finished(false);
2293 return Err(common::Error::FieldClash(field));
2294 }
2295 }
2296
2297 let mut params = Params::with_capacity(7 + self._additional_params.len());
2298 params.push("parent", self._parent);
2299 if let Some(value) = self._page_token.as_ref() {
2300 params.push("pageToken", value);
2301 }
2302 if let Some(value) = self._page_size.as_ref() {
2303 params.push("pageSize", value.to_string());
2304 }
2305 if let Some(value) = self._order_by.as_ref() {
2306 params.push("orderBy", value);
2307 }
2308 if let Some(value) = self._filter.as_ref() {
2309 params.push("filter", value);
2310 }
2311
2312 params.extend(self._additional_params.iter());
2313
2314 params.push("alt", "json");
2315 let mut url = self.hub._base_url.clone() + "v1/{+parent}/backups";
2316 if self._scopes.is_empty() {
2317 self._scopes
2318 .insert(Scope::CloudPlatform.as_ref().to_string());
2319 }
2320
2321 #[allow(clippy::single_element_loop)]
2322 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2323 url = params.uri_replacement(url, param_name, find_this, true);
2324 }
2325 {
2326 let to_remove = ["parent"];
2327 params.remove_params(&to_remove);
2328 }
2329
2330 let url = params.parse_with_url(&url);
2331
2332 loop {
2333 let token = match self
2334 .hub
2335 .auth
2336 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2337 .await
2338 {
2339 Ok(token) => token,
2340 Err(e) => match dlg.token(e) {
2341 Ok(token) => token,
2342 Err(e) => {
2343 dlg.finished(false);
2344 return Err(common::Error::MissingToken(e));
2345 }
2346 },
2347 };
2348 let mut req_result = {
2349 let client = &self.hub.client;
2350 dlg.pre_request();
2351 let mut req_builder = hyper::Request::builder()
2352 .method(hyper::Method::GET)
2353 .uri(url.as_str())
2354 .header(USER_AGENT, self.hub._user_agent.clone());
2355
2356 if let Some(token) = token.as_ref() {
2357 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2358 }
2359
2360 let request = req_builder
2361 .header(CONTENT_LENGTH, 0_u64)
2362 .body(common::to_body::<String>(None));
2363
2364 client.request(request.unwrap()).await
2365 };
2366
2367 match req_result {
2368 Err(err) => {
2369 if let common::Retry::After(d) = dlg.http_error(&err) {
2370 sleep(d).await;
2371 continue;
2372 }
2373 dlg.finished(false);
2374 return Err(common::Error::HttpError(err));
2375 }
2376 Ok(res) => {
2377 let (mut parts, body) = res.into_parts();
2378 let mut body = common::Body::new(body);
2379 if !parts.status.is_success() {
2380 let bytes = common::to_bytes(body).await.unwrap_or_default();
2381 let error = serde_json::from_str(&common::to_string(&bytes));
2382 let response = common::to_response(parts, bytes.into());
2383
2384 if let common::Retry::After(d) =
2385 dlg.http_failure(&response, error.as_ref().ok())
2386 {
2387 sleep(d).await;
2388 continue;
2389 }
2390
2391 dlg.finished(false);
2392
2393 return Err(match error {
2394 Ok(value) => common::Error::BadRequest(value),
2395 _ => common::Error::Failure(response),
2396 });
2397 }
2398 let response = {
2399 let bytes = common::to_bytes(body).await.unwrap_or_default();
2400 let encoded = common::to_string(&bytes);
2401 match serde_json::from_str(&encoded) {
2402 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2403 Err(error) => {
2404 dlg.response_json_decode_error(&encoded, &error);
2405 return Err(common::Error::JsonDecodeError(
2406 encoded.to_string(),
2407 error,
2408 ));
2409 }
2410 }
2411 };
2412
2413 dlg.finished(true);
2414 return Ok(response);
2415 }
2416 }
2417 }
2418 }
2419
2420 /// 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.
2421 ///
2422 /// Sets the *parent* path property to the given value.
2423 ///
2424 /// Even though the property as already been set when instantiating this call,
2425 /// we provide this method for API completeness.
2426 pub fn parent(mut self, new_value: &str) -> ProjectLocationBackupListCall<'a, C> {
2427 self._parent = new_value.to_string();
2428 self
2429 }
2430 /// The next_page_token value to use if there are additional results to retrieve for this list request.
2431 ///
2432 /// Sets the *page token* query property to the given value.
2433 pub fn page_token(mut self, new_value: &str) -> ProjectLocationBackupListCall<'a, C> {
2434 self._page_token = Some(new_value.to_string());
2435 self
2436 }
2437 /// The maximum number of items to return.
2438 ///
2439 /// Sets the *page size* query property to the given value.
2440 pub fn page_size(mut self, new_value: i32) -> ProjectLocationBackupListCall<'a, C> {
2441 self._page_size = Some(new_value);
2442 self
2443 }
2444 /// Sort results. Supported values are "name", "name desc" or "" (unsorted).
2445 ///
2446 /// Sets the *order by* query property to the given value.
2447 pub fn order_by(mut self, new_value: &str) -> ProjectLocationBackupListCall<'a, C> {
2448 self._order_by = Some(new_value.to_string());
2449 self
2450 }
2451 /// List filter.
2452 ///
2453 /// Sets the *filter* query property to the given value.
2454 pub fn filter(mut self, new_value: &str) -> ProjectLocationBackupListCall<'a, C> {
2455 self._filter = Some(new_value.to_string());
2456 self
2457 }
2458 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2459 /// while executing the actual API request.
2460 ///
2461 /// ````text
2462 /// It should be used to handle progress information, and to implement a certain level of resilience.
2463 /// ````
2464 ///
2465 /// Sets the *delegate* property to the given value.
2466 pub fn delegate(
2467 mut self,
2468 new_value: &'a mut dyn common::Delegate,
2469 ) -> ProjectLocationBackupListCall<'a, C> {
2470 self._delegate = Some(new_value);
2471 self
2472 }
2473
2474 /// Set any additional parameter of the query string used in the request.
2475 /// It should be used to set parameters which are not yet available through their own
2476 /// setters.
2477 ///
2478 /// Please note that this method must not be used to set any of the known parameters
2479 /// which have their own setter method. If done anyway, the request will fail.
2480 ///
2481 /// # Additional Parameters
2482 ///
2483 /// * *$.xgafv* (query-string) - V1 error format.
2484 /// * *access_token* (query-string) - OAuth access token.
2485 /// * *alt* (query-string) - Data format for response.
2486 /// * *callback* (query-string) - JSONP
2487 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2488 /// * *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.
2489 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2490 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2491 /// * *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.
2492 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2493 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2494 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBackupListCall<'a, C>
2495 where
2496 T: AsRef<str>,
2497 {
2498 self._additional_params
2499 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2500 self
2501 }
2502
2503 /// Identifies the authorization scope for the method you are building.
2504 ///
2505 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2506 /// [`Scope::CloudPlatform`].
2507 ///
2508 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2509 /// tokens for more than one scope.
2510 ///
2511 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2512 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2513 /// sufficient, a read-write scope will do as well.
2514 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBackupListCall<'a, C>
2515 where
2516 St: AsRef<str>,
2517 {
2518 self._scopes.insert(String::from(scope.as_ref()));
2519 self
2520 }
2521 /// Identifies the authorization scope(s) for the method you are building.
2522 ///
2523 /// See [`Self::add_scope()`] for details.
2524 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBackupListCall<'a, C>
2525 where
2526 I: IntoIterator<Item = St>,
2527 St: AsRef<str>,
2528 {
2529 self._scopes
2530 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2531 self
2532 }
2533
2534 /// Removes all scopes, and no default scope will be used either.
2535 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2536 /// for details).
2537 pub fn clear_scopes(mut self) -> ProjectLocationBackupListCall<'a, C> {
2538 self._scopes.clear();
2539 self
2540 }
2541}
2542
2543/// Updates the settings of a specific backup.
2544///
2545/// A builder for the *locations.backups.patch* method supported by a *project* resource.
2546/// It is not used directly, but through a [`ProjectMethods`] instance.
2547///
2548/// # Example
2549///
2550/// Instantiate a resource method builder
2551///
2552/// ```test_harness,no_run
2553/// # extern crate hyper;
2554/// # extern crate hyper_rustls;
2555/// # extern crate google_file1 as file1;
2556/// use file1::api::Backup;
2557/// # async fn dox() {
2558/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2559///
2560/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2561/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2562/// # secret,
2563/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2564/// # ).build().await.unwrap();
2565///
2566/// # let client = hyper_util::client::legacy::Client::builder(
2567/// # hyper_util::rt::TokioExecutor::new()
2568/// # )
2569/// # .build(
2570/// # hyper_rustls::HttpsConnectorBuilder::new()
2571/// # .with_native_roots()
2572/// # .unwrap()
2573/// # .https_or_http()
2574/// # .enable_http1()
2575/// # .build()
2576/// # );
2577/// # let mut hub = CloudFilestore::new(client, auth);
2578/// // As the method needs a request, you would usually fill it with the desired information
2579/// // into the respective structure. Some of the parts shown here might not be applicable !
2580/// // Values shown here are possibly random and not representative !
2581/// let mut req = Backup::default();
2582///
2583/// // You can configure optional parameters by calling the respective setters at will, and
2584/// // execute the final call using `doit()`.
2585/// // Values shown here are possibly random and not representative !
2586/// let result = hub.projects().locations_backups_patch(req, "name")
2587/// .update_mask(FieldMask::new::<&str>(&[]))
2588/// .doit().await;
2589/// # }
2590/// ```
2591pub struct ProjectLocationBackupPatchCall<'a, C>
2592where
2593 C: 'a,
2594{
2595 hub: &'a CloudFilestore<C>,
2596 _request: Backup,
2597 _name: String,
2598 _update_mask: Option<common::FieldMask>,
2599 _delegate: Option<&'a mut dyn common::Delegate>,
2600 _additional_params: HashMap<String, String>,
2601 _scopes: BTreeSet<String>,
2602}
2603
2604impl<'a, C> common::CallBuilder for ProjectLocationBackupPatchCall<'a, C> {}
2605
2606impl<'a, C> ProjectLocationBackupPatchCall<'a, C>
2607where
2608 C: common::Connector,
2609{
2610 /// Perform the operation you have build so far.
2611 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2612 use std::borrow::Cow;
2613 use std::io::{Read, Seek};
2614
2615 use common::{url::Params, ToParts};
2616 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2617
2618 let mut dd = common::DefaultDelegate;
2619 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2620 dlg.begin(common::MethodInfo {
2621 id: "file.projects.locations.backups.patch",
2622 http_method: hyper::Method::PATCH,
2623 });
2624
2625 for &field in ["alt", "name", "updateMask"].iter() {
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(5 + self._additional_params.len());
2633 params.push("name", self._name);
2634 if let Some(value) = self._update_mask.as_ref() {
2635 params.push("updateMask", value.to_string());
2636 }
2637
2638 params.extend(self._additional_params.iter());
2639
2640 params.push("alt", "json");
2641 let mut url = self.hub._base_url.clone() + "v1/{+name}";
2642 if self._scopes.is_empty() {
2643 self._scopes
2644 .insert(Scope::CloudPlatform.as_ref().to_string());
2645 }
2646
2647 #[allow(clippy::single_element_loop)]
2648 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2649 url = params.uri_replacement(url, param_name, find_this, true);
2650 }
2651 {
2652 let to_remove = ["name"];
2653 params.remove_params(&to_remove);
2654 }
2655
2656 let url = params.parse_with_url(&url);
2657
2658 let mut json_mime_type = mime::APPLICATION_JSON;
2659 let mut request_value_reader = {
2660 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2661 common::remove_json_null_values(&mut value);
2662 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2663 serde_json::to_writer(&mut dst, &value).unwrap();
2664 dst
2665 };
2666 let request_size = request_value_reader
2667 .seek(std::io::SeekFrom::End(0))
2668 .unwrap();
2669 request_value_reader
2670 .seek(std::io::SeekFrom::Start(0))
2671 .unwrap();
2672
2673 loop {
2674 let token = match self
2675 .hub
2676 .auth
2677 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2678 .await
2679 {
2680 Ok(token) => token,
2681 Err(e) => match dlg.token(e) {
2682 Ok(token) => token,
2683 Err(e) => {
2684 dlg.finished(false);
2685 return Err(common::Error::MissingToken(e));
2686 }
2687 },
2688 };
2689 request_value_reader
2690 .seek(std::io::SeekFrom::Start(0))
2691 .unwrap();
2692 let mut req_result = {
2693 let client = &self.hub.client;
2694 dlg.pre_request();
2695 let mut req_builder = hyper::Request::builder()
2696 .method(hyper::Method::PATCH)
2697 .uri(url.as_str())
2698 .header(USER_AGENT, self.hub._user_agent.clone());
2699
2700 if let Some(token) = token.as_ref() {
2701 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2702 }
2703
2704 let request = req_builder
2705 .header(CONTENT_TYPE, json_mime_type.to_string())
2706 .header(CONTENT_LENGTH, request_size as u64)
2707 .body(common::to_body(
2708 request_value_reader.get_ref().clone().into(),
2709 ));
2710
2711 client.request(request.unwrap()).await
2712 };
2713
2714 match req_result {
2715 Err(err) => {
2716 if let common::Retry::After(d) = dlg.http_error(&err) {
2717 sleep(d).await;
2718 continue;
2719 }
2720 dlg.finished(false);
2721 return Err(common::Error::HttpError(err));
2722 }
2723 Ok(res) => {
2724 let (mut parts, body) = res.into_parts();
2725 let mut body = common::Body::new(body);
2726 if !parts.status.is_success() {
2727 let bytes = common::to_bytes(body).await.unwrap_or_default();
2728 let error = serde_json::from_str(&common::to_string(&bytes));
2729 let response = common::to_response(parts, bytes.into());
2730
2731 if let common::Retry::After(d) =
2732 dlg.http_failure(&response, error.as_ref().ok())
2733 {
2734 sleep(d).await;
2735 continue;
2736 }
2737
2738 dlg.finished(false);
2739
2740 return Err(match error {
2741 Ok(value) => common::Error::BadRequest(value),
2742 _ => common::Error::Failure(response),
2743 });
2744 }
2745 let response = {
2746 let bytes = common::to_bytes(body).await.unwrap_or_default();
2747 let encoded = common::to_string(&bytes);
2748 match serde_json::from_str(&encoded) {
2749 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2750 Err(error) => {
2751 dlg.response_json_decode_error(&encoded, &error);
2752 return Err(common::Error::JsonDecodeError(
2753 encoded.to_string(),
2754 error,
2755 ));
2756 }
2757 }
2758 };
2759
2760 dlg.finished(true);
2761 return Ok(response);
2762 }
2763 }
2764 }
2765 }
2766
2767 ///
2768 /// Sets the *request* property to the given value.
2769 ///
2770 /// Even though the property as already been set when instantiating this call,
2771 /// we provide this method for API completeness.
2772 pub fn request(mut self, new_value: Backup) -> ProjectLocationBackupPatchCall<'a, C> {
2773 self._request = new_value;
2774 self
2775 }
2776 /// Output only. The resource name of the backup, in the format `projects/{project_number}/locations/{location_id}/backups/{backup_id}`.
2777 ///
2778 /// Sets the *name* path property to the given value.
2779 ///
2780 /// Even though the property as already been set when instantiating this call,
2781 /// we provide this method for API completeness.
2782 pub fn name(mut self, new_value: &str) -> ProjectLocationBackupPatchCall<'a, C> {
2783 self._name = new_value.to_string();
2784 self
2785 }
2786 /// Required. Mask of fields to update. At least one path must be supplied in this field.
2787 ///
2788 /// Sets the *update mask* query property to the given value.
2789 pub fn update_mask(
2790 mut self,
2791 new_value: common::FieldMask,
2792 ) -> ProjectLocationBackupPatchCall<'a, C> {
2793 self._update_mask = Some(new_value);
2794 self
2795 }
2796 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2797 /// while executing the actual API request.
2798 ///
2799 /// ````text
2800 /// It should be used to handle progress information, and to implement a certain level of resilience.
2801 /// ````
2802 ///
2803 /// Sets the *delegate* property to the given value.
2804 pub fn delegate(
2805 mut self,
2806 new_value: &'a mut dyn common::Delegate,
2807 ) -> ProjectLocationBackupPatchCall<'a, C> {
2808 self._delegate = Some(new_value);
2809 self
2810 }
2811
2812 /// Set any additional parameter of the query string used in the request.
2813 /// It should be used to set parameters which are not yet available through their own
2814 /// setters.
2815 ///
2816 /// Please note that this method must not be used to set any of the known parameters
2817 /// which have their own setter method. If done anyway, the request will fail.
2818 ///
2819 /// # Additional Parameters
2820 ///
2821 /// * *$.xgafv* (query-string) - V1 error format.
2822 /// * *access_token* (query-string) - OAuth access token.
2823 /// * *alt* (query-string) - Data format for response.
2824 /// * *callback* (query-string) - JSONP
2825 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2826 /// * *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.
2827 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2828 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2829 /// * *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.
2830 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2831 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2832 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBackupPatchCall<'a, C>
2833 where
2834 T: AsRef<str>,
2835 {
2836 self._additional_params
2837 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2838 self
2839 }
2840
2841 /// Identifies the authorization scope for the method you are building.
2842 ///
2843 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2844 /// [`Scope::CloudPlatform`].
2845 ///
2846 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2847 /// tokens for more than one scope.
2848 ///
2849 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2850 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2851 /// sufficient, a read-write scope will do as well.
2852 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBackupPatchCall<'a, C>
2853 where
2854 St: AsRef<str>,
2855 {
2856 self._scopes.insert(String::from(scope.as_ref()));
2857 self
2858 }
2859 /// Identifies the authorization scope(s) for the method you are building.
2860 ///
2861 /// See [`Self::add_scope()`] for details.
2862 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBackupPatchCall<'a, C>
2863 where
2864 I: IntoIterator<Item = St>,
2865 St: AsRef<str>,
2866 {
2867 self._scopes
2868 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2869 self
2870 }
2871
2872 /// Removes all scopes, and no default scope will be used either.
2873 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2874 /// for details).
2875 pub fn clear_scopes(mut self) -> ProjectLocationBackupPatchCall<'a, C> {
2876 self._scopes.clear();
2877 self
2878 }
2879}
2880
2881/// Creates a snapshot.
2882///
2883/// A builder for the *locations.instances.snapshots.create* method supported by a *project* resource.
2884/// It is not used directly, but through a [`ProjectMethods`] instance.
2885///
2886/// # Example
2887///
2888/// Instantiate a resource method builder
2889///
2890/// ```test_harness,no_run
2891/// # extern crate hyper;
2892/// # extern crate hyper_rustls;
2893/// # extern crate google_file1 as file1;
2894/// use file1::api::Snapshot;
2895/// # async fn dox() {
2896/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2897///
2898/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2899/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2900/// # secret,
2901/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2902/// # ).build().await.unwrap();
2903///
2904/// # let client = hyper_util::client::legacy::Client::builder(
2905/// # hyper_util::rt::TokioExecutor::new()
2906/// # )
2907/// # .build(
2908/// # hyper_rustls::HttpsConnectorBuilder::new()
2909/// # .with_native_roots()
2910/// # .unwrap()
2911/// # .https_or_http()
2912/// # .enable_http1()
2913/// # .build()
2914/// # );
2915/// # let mut hub = CloudFilestore::new(client, auth);
2916/// // As the method needs a request, you would usually fill it with the desired information
2917/// // into the respective structure. Some of the parts shown here might not be applicable !
2918/// // Values shown here are possibly random and not representative !
2919/// let mut req = Snapshot::default();
2920///
2921/// // You can configure optional parameters by calling the respective setters at will, and
2922/// // execute the final call using `doit()`.
2923/// // Values shown here are possibly random and not representative !
2924/// let result = hub.projects().locations_instances_snapshots_create(req, "parent")
2925/// .snapshot_id("dolor")
2926/// .doit().await;
2927/// # }
2928/// ```
2929pub struct ProjectLocationInstanceSnapshotCreateCall<'a, C>
2930where
2931 C: 'a,
2932{
2933 hub: &'a CloudFilestore<C>,
2934 _request: Snapshot,
2935 _parent: String,
2936 _snapshot_id: Option<String>,
2937 _delegate: Option<&'a mut dyn common::Delegate>,
2938 _additional_params: HashMap<String, String>,
2939 _scopes: BTreeSet<String>,
2940}
2941
2942impl<'a, C> common::CallBuilder for ProjectLocationInstanceSnapshotCreateCall<'a, C> {}
2943
2944impl<'a, C> ProjectLocationInstanceSnapshotCreateCall<'a, C>
2945where
2946 C: common::Connector,
2947{
2948 /// Perform the operation you have build so far.
2949 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2950 use std::borrow::Cow;
2951 use std::io::{Read, Seek};
2952
2953 use common::{url::Params, ToParts};
2954 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2955
2956 let mut dd = common::DefaultDelegate;
2957 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2958 dlg.begin(common::MethodInfo {
2959 id: "file.projects.locations.instances.snapshots.create",
2960 http_method: hyper::Method::POST,
2961 });
2962
2963 for &field in ["alt", "parent", "snapshotId"].iter() {
2964 if self._additional_params.contains_key(field) {
2965 dlg.finished(false);
2966 return Err(common::Error::FieldClash(field));
2967 }
2968 }
2969
2970 let mut params = Params::with_capacity(5 + self._additional_params.len());
2971 params.push("parent", self._parent);
2972 if let Some(value) = self._snapshot_id.as_ref() {
2973 params.push("snapshotId", value);
2974 }
2975
2976 params.extend(self._additional_params.iter());
2977
2978 params.push("alt", "json");
2979 let mut url = self.hub._base_url.clone() + "v1/{+parent}/snapshots";
2980 if self._scopes.is_empty() {
2981 self._scopes
2982 .insert(Scope::CloudPlatform.as_ref().to_string());
2983 }
2984
2985 #[allow(clippy::single_element_loop)]
2986 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2987 url = params.uri_replacement(url, param_name, find_this, true);
2988 }
2989 {
2990 let to_remove = ["parent"];
2991 params.remove_params(&to_remove);
2992 }
2993
2994 let url = params.parse_with_url(&url);
2995
2996 let mut json_mime_type = mime::APPLICATION_JSON;
2997 let mut request_value_reader = {
2998 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2999 common::remove_json_null_values(&mut value);
3000 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3001 serde_json::to_writer(&mut dst, &value).unwrap();
3002 dst
3003 };
3004 let request_size = request_value_reader
3005 .seek(std::io::SeekFrom::End(0))
3006 .unwrap();
3007 request_value_reader
3008 .seek(std::io::SeekFrom::Start(0))
3009 .unwrap();
3010
3011 loop {
3012 let token = match self
3013 .hub
3014 .auth
3015 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3016 .await
3017 {
3018 Ok(token) => token,
3019 Err(e) => match dlg.token(e) {
3020 Ok(token) => token,
3021 Err(e) => {
3022 dlg.finished(false);
3023 return Err(common::Error::MissingToken(e));
3024 }
3025 },
3026 };
3027 request_value_reader
3028 .seek(std::io::SeekFrom::Start(0))
3029 .unwrap();
3030 let mut req_result = {
3031 let client = &self.hub.client;
3032 dlg.pre_request();
3033 let mut req_builder = hyper::Request::builder()
3034 .method(hyper::Method::POST)
3035 .uri(url.as_str())
3036 .header(USER_AGENT, self.hub._user_agent.clone());
3037
3038 if let Some(token) = token.as_ref() {
3039 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3040 }
3041
3042 let request = req_builder
3043 .header(CONTENT_TYPE, json_mime_type.to_string())
3044 .header(CONTENT_LENGTH, request_size as u64)
3045 .body(common::to_body(
3046 request_value_reader.get_ref().clone().into(),
3047 ));
3048
3049 client.request(request.unwrap()).await
3050 };
3051
3052 match req_result {
3053 Err(err) => {
3054 if let common::Retry::After(d) = dlg.http_error(&err) {
3055 sleep(d).await;
3056 continue;
3057 }
3058 dlg.finished(false);
3059 return Err(common::Error::HttpError(err));
3060 }
3061 Ok(res) => {
3062 let (mut parts, body) = res.into_parts();
3063 let mut body = common::Body::new(body);
3064 if !parts.status.is_success() {
3065 let bytes = common::to_bytes(body).await.unwrap_or_default();
3066 let error = serde_json::from_str(&common::to_string(&bytes));
3067 let response = common::to_response(parts, bytes.into());
3068
3069 if let common::Retry::After(d) =
3070 dlg.http_failure(&response, error.as_ref().ok())
3071 {
3072 sleep(d).await;
3073 continue;
3074 }
3075
3076 dlg.finished(false);
3077
3078 return Err(match error {
3079 Ok(value) => common::Error::BadRequest(value),
3080 _ => common::Error::Failure(response),
3081 });
3082 }
3083 let response = {
3084 let bytes = common::to_bytes(body).await.unwrap_or_default();
3085 let encoded = common::to_string(&bytes);
3086 match serde_json::from_str(&encoded) {
3087 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3088 Err(error) => {
3089 dlg.response_json_decode_error(&encoded, &error);
3090 return Err(common::Error::JsonDecodeError(
3091 encoded.to_string(),
3092 error,
3093 ));
3094 }
3095 }
3096 };
3097
3098 dlg.finished(true);
3099 return Ok(response);
3100 }
3101 }
3102 }
3103 }
3104
3105 ///
3106 /// Sets the *request* property to the given value.
3107 ///
3108 /// Even though the property as already been set when instantiating this call,
3109 /// we provide this method for API completeness.
3110 pub fn request(
3111 mut self,
3112 new_value: Snapshot,
3113 ) -> ProjectLocationInstanceSnapshotCreateCall<'a, C> {
3114 self._request = new_value;
3115 self
3116 }
3117 /// Required. The Filestore Instance to create the snapshots of, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`
3118 ///
3119 /// Sets the *parent* path property to the given value.
3120 ///
3121 /// Even though the property as already been set when instantiating this call,
3122 /// we provide this method for API completeness.
3123 pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotCreateCall<'a, C> {
3124 self._parent = new_value.to_string();
3125 self
3126 }
3127 /// 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.
3128 ///
3129 /// Sets the *snapshot id* query property to the given value.
3130 pub fn snapshot_id(
3131 mut self,
3132 new_value: &str,
3133 ) -> ProjectLocationInstanceSnapshotCreateCall<'a, C> {
3134 self._snapshot_id = Some(new_value.to_string());
3135 self
3136 }
3137 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3138 /// while executing the actual API request.
3139 ///
3140 /// ````text
3141 /// It should be used to handle progress information, and to implement a certain level of resilience.
3142 /// ````
3143 ///
3144 /// Sets the *delegate* property to the given value.
3145 pub fn delegate(
3146 mut self,
3147 new_value: &'a mut dyn common::Delegate,
3148 ) -> ProjectLocationInstanceSnapshotCreateCall<'a, C> {
3149 self._delegate = Some(new_value);
3150 self
3151 }
3152
3153 /// Set any additional parameter of the query string used in the request.
3154 /// It should be used to set parameters which are not yet available through their own
3155 /// setters.
3156 ///
3157 /// Please note that this method must not be used to set any of the known parameters
3158 /// which have their own setter method. If done anyway, the request will fail.
3159 ///
3160 /// # Additional Parameters
3161 ///
3162 /// * *$.xgafv* (query-string) - V1 error format.
3163 /// * *access_token* (query-string) - OAuth access token.
3164 /// * *alt* (query-string) - Data format for response.
3165 /// * *callback* (query-string) - JSONP
3166 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3167 /// * *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.
3168 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3169 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3170 /// * *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.
3171 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3172 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3173 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSnapshotCreateCall<'a, C>
3174 where
3175 T: AsRef<str>,
3176 {
3177 self._additional_params
3178 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3179 self
3180 }
3181
3182 /// Identifies the authorization scope for the method you are building.
3183 ///
3184 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3185 /// [`Scope::CloudPlatform`].
3186 ///
3187 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3188 /// tokens for more than one scope.
3189 ///
3190 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3191 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3192 /// sufficient, a read-write scope will do as well.
3193 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceSnapshotCreateCall<'a, C>
3194 where
3195 St: AsRef<str>,
3196 {
3197 self._scopes.insert(String::from(scope.as_ref()));
3198 self
3199 }
3200 /// Identifies the authorization scope(s) for the method you are building.
3201 ///
3202 /// See [`Self::add_scope()`] for details.
3203 pub fn add_scopes<I, St>(
3204 mut self,
3205 scopes: I,
3206 ) -> ProjectLocationInstanceSnapshotCreateCall<'a, C>
3207 where
3208 I: IntoIterator<Item = St>,
3209 St: AsRef<str>,
3210 {
3211 self._scopes
3212 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3213 self
3214 }
3215
3216 /// Removes all scopes, and no default scope will be used either.
3217 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3218 /// for details).
3219 pub fn clear_scopes(mut self) -> ProjectLocationInstanceSnapshotCreateCall<'a, C> {
3220 self._scopes.clear();
3221 self
3222 }
3223}
3224
3225/// Deletes a snapshot.
3226///
3227/// A builder for the *locations.instances.snapshots.delete* method supported by a *project* resource.
3228/// It is not used directly, but through a [`ProjectMethods`] instance.
3229///
3230/// # Example
3231///
3232/// Instantiate a resource method builder
3233///
3234/// ```test_harness,no_run
3235/// # extern crate hyper;
3236/// # extern crate hyper_rustls;
3237/// # extern crate google_file1 as file1;
3238/// # async fn dox() {
3239/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3240///
3241/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3242/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3243/// # secret,
3244/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3245/// # ).build().await.unwrap();
3246///
3247/// # let client = hyper_util::client::legacy::Client::builder(
3248/// # hyper_util::rt::TokioExecutor::new()
3249/// # )
3250/// # .build(
3251/// # hyper_rustls::HttpsConnectorBuilder::new()
3252/// # .with_native_roots()
3253/// # .unwrap()
3254/// # .https_or_http()
3255/// # .enable_http1()
3256/// # .build()
3257/// # );
3258/// # let mut hub = CloudFilestore::new(client, auth);
3259/// // You can configure optional parameters by calling the respective setters at will, and
3260/// // execute the final call using `doit()`.
3261/// // Values shown here are possibly random and not representative !
3262/// let result = hub.projects().locations_instances_snapshots_delete("name")
3263/// .doit().await;
3264/// # }
3265/// ```
3266pub struct ProjectLocationInstanceSnapshotDeleteCall<'a, C>
3267where
3268 C: 'a,
3269{
3270 hub: &'a CloudFilestore<C>,
3271 _name: String,
3272 _delegate: Option<&'a mut dyn common::Delegate>,
3273 _additional_params: HashMap<String, String>,
3274 _scopes: BTreeSet<String>,
3275}
3276
3277impl<'a, C> common::CallBuilder for ProjectLocationInstanceSnapshotDeleteCall<'a, C> {}
3278
3279impl<'a, C> ProjectLocationInstanceSnapshotDeleteCall<'a, C>
3280where
3281 C: common::Connector,
3282{
3283 /// Perform the operation you have build so far.
3284 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3285 use std::borrow::Cow;
3286 use std::io::{Read, Seek};
3287
3288 use common::{url::Params, ToParts};
3289 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3290
3291 let mut dd = common::DefaultDelegate;
3292 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3293 dlg.begin(common::MethodInfo {
3294 id: "file.projects.locations.instances.snapshots.delete",
3295 http_method: hyper::Method::DELETE,
3296 });
3297
3298 for &field in ["alt", "name"].iter() {
3299 if self._additional_params.contains_key(field) {
3300 dlg.finished(false);
3301 return Err(common::Error::FieldClash(field));
3302 }
3303 }
3304
3305 let mut params = Params::with_capacity(3 + self._additional_params.len());
3306 params.push("name", self._name);
3307
3308 params.extend(self._additional_params.iter());
3309
3310 params.push("alt", "json");
3311 let mut url = self.hub._base_url.clone() + "v1/{+name}";
3312 if self._scopes.is_empty() {
3313 self._scopes
3314 .insert(Scope::CloudPlatform.as_ref().to_string());
3315 }
3316
3317 #[allow(clippy::single_element_loop)]
3318 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3319 url = params.uri_replacement(url, param_name, find_this, true);
3320 }
3321 {
3322 let to_remove = ["name"];
3323 params.remove_params(&to_remove);
3324 }
3325
3326 let url = params.parse_with_url(&url);
3327
3328 loop {
3329 let token = match self
3330 .hub
3331 .auth
3332 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3333 .await
3334 {
3335 Ok(token) => token,
3336 Err(e) => match dlg.token(e) {
3337 Ok(token) => token,
3338 Err(e) => {
3339 dlg.finished(false);
3340 return Err(common::Error::MissingToken(e));
3341 }
3342 },
3343 };
3344 let mut req_result = {
3345 let client = &self.hub.client;
3346 dlg.pre_request();
3347 let mut req_builder = hyper::Request::builder()
3348 .method(hyper::Method::DELETE)
3349 .uri(url.as_str())
3350 .header(USER_AGENT, self.hub._user_agent.clone());
3351
3352 if let Some(token) = token.as_ref() {
3353 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3354 }
3355
3356 let request = req_builder
3357 .header(CONTENT_LENGTH, 0_u64)
3358 .body(common::to_body::<String>(None));
3359
3360 client.request(request.unwrap()).await
3361 };
3362
3363 match req_result {
3364 Err(err) => {
3365 if let common::Retry::After(d) = dlg.http_error(&err) {
3366 sleep(d).await;
3367 continue;
3368 }
3369 dlg.finished(false);
3370 return Err(common::Error::HttpError(err));
3371 }
3372 Ok(res) => {
3373 let (mut parts, body) = res.into_parts();
3374 let mut body = common::Body::new(body);
3375 if !parts.status.is_success() {
3376 let bytes = common::to_bytes(body).await.unwrap_or_default();
3377 let error = serde_json::from_str(&common::to_string(&bytes));
3378 let response = common::to_response(parts, bytes.into());
3379
3380 if let common::Retry::After(d) =
3381 dlg.http_failure(&response, error.as_ref().ok())
3382 {
3383 sleep(d).await;
3384 continue;
3385 }
3386
3387 dlg.finished(false);
3388
3389 return Err(match error {
3390 Ok(value) => common::Error::BadRequest(value),
3391 _ => common::Error::Failure(response),
3392 });
3393 }
3394 let response = {
3395 let bytes = common::to_bytes(body).await.unwrap_or_default();
3396 let encoded = common::to_string(&bytes);
3397 match serde_json::from_str(&encoded) {
3398 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3399 Err(error) => {
3400 dlg.response_json_decode_error(&encoded, &error);
3401 return Err(common::Error::JsonDecodeError(
3402 encoded.to_string(),
3403 error,
3404 ));
3405 }
3406 }
3407 };
3408
3409 dlg.finished(true);
3410 return Ok(response);
3411 }
3412 }
3413 }
3414 }
3415
3416 /// Required. The snapshot resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}/snapshots/{snapshot_id}`
3417 ///
3418 /// Sets the *name* path property to the given value.
3419 ///
3420 /// Even though the property as already been set when instantiating this call,
3421 /// we provide this method for API completeness.
3422 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotDeleteCall<'a, C> {
3423 self._name = new_value.to_string();
3424 self
3425 }
3426 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3427 /// while executing the actual API request.
3428 ///
3429 /// ````text
3430 /// It should be used to handle progress information, and to implement a certain level of resilience.
3431 /// ````
3432 ///
3433 /// Sets the *delegate* property to the given value.
3434 pub fn delegate(
3435 mut self,
3436 new_value: &'a mut dyn common::Delegate,
3437 ) -> ProjectLocationInstanceSnapshotDeleteCall<'a, C> {
3438 self._delegate = Some(new_value);
3439 self
3440 }
3441
3442 /// Set any additional parameter of the query string used in the request.
3443 /// It should be used to set parameters which are not yet available through their own
3444 /// setters.
3445 ///
3446 /// Please note that this method must not be used to set any of the known parameters
3447 /// which have their own setter method. If done anyway, the request will fail.
3448 ///
3449 /// # Additional Parameters
3450 ///
3451 /// * *$.xgafv* (query-string) - V1 error format.
3452 /// * *access_token* (query-string) - OAuth access token.
3453 /// * *alt* (query-string) - Data format for response.
3454 /// * *callback* (query-string) - JSONP
3455 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3456 /// * *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.
3457 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3458 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3459 /// * *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.
3460 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3461 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3462 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSnapshotDeleteCall<'a, C>
3463 where
3464 T: AsRef<str>,
3465 {
3466 self._additional_params
3467 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3468 self
3469 }
3470
3471 /// Identifies the authorization scope for the method you are building.
3472 ///
3473 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3474 /// [`Scope::CloudPlatform`].
3475 ///
3476 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3477 /// tokens for more than one scope.
3478 ///
3479 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3480 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3481 /// sufficient, a read-write scope will do as well.
3482 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceSnapshotDeleteCall<'a, C>
3483 where
3484 St: AsRef<str>,
3485 {
3486 self._scopes.insert(String::from(scope.as_ref()));
3487 self
3488 }
3489 /// Identifies the authorization scope(s) for the method you are building.
3490 ///
3491 /// See [`Self::add_scope()`] for details.
3492 pub fn add_scopes<I, St>(
3493 mut self,
3494 scopes: I,
3495 ) -> ProjectLocationInstanceSnapshotDeleteCall<'a, C>
3496 where
3497 I: IntoIterator<Item = St>,
3498 St: AsRef<str>,
3499 {
3500 self._scopes
3501 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3502 self
3503 }
3504
3505 /// Removes all scopes, and no default scope will be used either.
3506 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3507 /// for details).
3508 pub fn clear_scopes(mut self) -> ProjectLocationInstanceSnapshotDeleteCall<'a, C> {
3509 self._scopes.clear();
3510 self
3511 }
3512}
3513
3514/// Gets the details of a specific snapshot.
3515///
3516/// A builder for the *locations.instances.snapshots.get* method supported by a *project* resource.
3517/// It is not used directly, but through a [`ProjectMethods`] instance.
3518///
3519/// # Example
3520///
3521/// Instantiate a resource method builder
3522///
3523/// ```test_harness,no_run
3524/// # extern crate hyper;
3525/// # extern crate hyper_rustls;
3526/// # extern crate google_file1 as file1;
3527/// # async fn dox() {
3528/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3529///
3530/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3531/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3532/// # secret,
3533/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3534/// # ).build().await.unwrap();
3535///
3536/// # let client = hyper_util::client::legacy::Client::builder(
3537/// # hyper_util::rt::TokioExecutor::new()
3538/// # )
3539/// # .build(
3540/// # hyper_rustls::HttpsConnectorBuilder::new()
3541/// # .with_native_roots()
3542/// # .unwrap()
3543/// # .https_or_http()
3544/// # .enable_http1()
3545/// # .build()
3546/// # );
3547/// # let mut hub = CloudFilestore::new(client, auth);
3548/// // You can configure optional parameters by calling the respective setters at will, and
3549/// // execute the final call using `doit()`.
3550/// // Values shown here are possibly random and not representative !
3551/// let result = hub.projects().locations_instances_snapshots_get("name")
3552/// .doit().await;
3553/// # }
3554/// ```
3555pub struct ProjectLocationInstanceSnapshotGetCall<'a, C>
3556where
3557 C: 'a,
3558{
3559 hub: &'a CloudFilestore<C>,
3560 _name: String,
3561 _delegate: Option<&'a mut dyn common::Delegate>,
3562 _additional_params: HashMap<String, String>,
3563 _scopes: BTreeSet<String>,
3564}
3565
3566impl<'a, C> common::CallBuilder for ProjectLocationInstanceSnapshotGetCall<'a, C> {}
3567
3568impl<'a, C> ProjectLocationInstanceSnapshotGetCall<'a, C>
3569where
3570 C: common::Connector,
3571{
3572 /// Perform the operation you have build so far.
3573 pub async fn doit(mut self) -> common::Result<(common::Response, Snapshot)> {
3574 use std::borrow::Cow;
3575 use std::io::{Read, Seek};
3576
3577 use common::{url::Params, ToParts};
3578 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3579
3580 let mut dd = common::DefaultDelegate;
3581 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3582 dlg.begin(common::MethodInfo {
3583 id: "file.projects.locations.instances.snapshots.get",
3584 http_method: hyper::Method::GET,
3585 });
3586
3587 for &field in ["alt", "name"].iter() {
3588 if self._additional_params.contains_key(field) {
3589 dlg.finished(false);
3590 return Err(common::Error::FieldClash(field));
3591 }
3592 }
3593
3594 let mut params = Params::with_capacity(3 + self._additional_params.len());
3595 params.push("name", self._name);
3596
3597 params.extend(self._additional_params.iter());
3598
3599 params.push("alt", "json");
3600 let mut url = self.hub._base_url.clone() + "v1/{+name}";
3601 if self._scopes.is_empty() {
3602 self._scopes
3603 .insert(Scope::CloudPlatform.as_ref().to_string());
3604 }
3605
3606 #[allow(clippy::single_element_loop)]
3607 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3608 url = params.uri_replacement(url, param_name, find_this, true);
3609 }
3610 {
3611 let to_remove = ["name"];
3612 params.remove_params(&to_remove);
3613 }
3614
3615 let url = params.parse_with_url(&url);
3616
3617 loop {
3618 let token = match self
3619 .hub
3620 .auth
3621 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3622 .await
3623 {
3624 Ok(token) => token,
3625 Err(e) => match dlg.token(e) {
3626 Ok(token) => token,
3627 Err(e) => {
3628 dlg.finished(false);
3629 return Err(common::Error::MissingToken(e));
3630 }
3631 },
3632 };
3633 let mut req_result = {
3634 let client = &self.hub.client;
3635 dlg.pre_request();
3636 let mut req_builder = hyper::Request::builder()
3637 .method(hyper::Method::GET)
3638 .uri(url.as_str())
3639 .header(USER_AGENT, self.hub._user_agent.clone());
3640
3641 if let Some(token) = token.as_ref() {
3642 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3643 }
3644
3645 let request = req_builder
3646 .header(CONTENT_LENGTH, 0_u64)
3647 .body(common::to_body::<String>(None));
3648
3649 client.request(request.unwrap()).await
3650 };
3651
3652 match req_result {
3653 Err(err) => {
3654 if let common::Retry::After(d) = dlg.http_error(&err) {
3655 sleep(d).await;
3656 continue;
3657 }
3658 dlg.finished(false);
3659 return Err(common::Error::HttpError(err));
3660 }
3661 Ok(res) => {
3662 let (mut parts, body) = res.into_parts();
3663 let mut body = common::Body::new(body);
3664 if !parts.status.is_success() {
3665 let bytes = common::to_bytes(body).await.unwrap_or_default();
3666 let error = serde_json::from_str(&common::to_string(&bytes));
3667 let response = common::to_response(parts, bytes.into());
3668
3669 if let common::Retry::After(d) =
3670 dlg.http_failure(&response, error.as_ref().ok())
3671 {
3672 sleep(d).await;
3673 continue;
3674 }
3675
3676 dlg.finished(false);
3677
3678 return Err(match error {
3679 Ok(value) => common::Error::BadRequest(value),
3680 _ => common::Error::Failure(response),
3681 });
3682 }
3683 let response = {
3684 let bytes = common::to_bytes(body).await.unwrap_or_default();
3685 let encoded = common::to_string(&bytes);
3686 match serde_json::from_str(&encoded) {
3687 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3688 Err(error) => {
3689 dlg.response_json_decode_error(&encoded, &error);
3690 return Err(common::Error::JsonDecodeError(
3691 encoded.to_string(),
3692 error,
3693 ));
3694 }
3695 }
3696 };
3697
3698 dlg.finished(true);
3699 return Ok(response);
3700 }
3701 }
3702 }
3703 }
3704
3705 /// Required. The snapshot resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}/snapshots/{snapshot_id}`
3706 ///
3707 /// Sets the *name* path property to the given value.
3708 ///
3709 /// Even though the property as already been set when instantiating this call,
3710 /// we provide this method for API completeness.
3711 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotGetCall<'a, C> {
3712 self._name = new_value.to_string();
3713 self
3714 }
3715 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3716 /// while executing the actual API request.
3717 ///
3718 /// ````text
3719 /// It should be used to handle progress information, and to implement a certain level of resilience.
3720 /// ````
3721 ///
3722 /// Sets the *delegate* property to the given value.
3723 pub fn delegate(
3724 mut self,
3725 new_value: &'a mut dyn common::Delegate,
3726 ) -> ProjectLocationInstanceSnapshotGetCall<'a, C> {
3727 self._delegate = Some(new_value);
3728 self
3729 }
3730
3731 /// Set any additional parameter of the query string used in the request.
3732 /// It should be used to set parameters which are not yet available through their own
3733 /// setters.
3734 ///
3735 /// Please note that this method must not be used to set any of the known parameters
3736 /// which have their own setter method. If done anyway, the request will fail.
3737 ///
3738 /// # Additional Parameters
3739 ///
3740 /// * *$.xgafv* (query-string) - V1 error format.
3741 /// * *access_token* (query-string) - OAuth access token.
3742 /// * *alt* (query-string) - Data format for response.
3743 /// * *callback* (query-string) - JSONP
3744 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3745 /// * *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.
3746 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3747 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3748 /// * *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.
3749 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3750 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3751 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSnapshotGetCall<'a, C>
3752 where
3753 T: AsRef<str>,
3754 {
3755 self._additional_params
3756 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3757 self
3758 }
3759
3760 /// Identifies the authorization scope for the method you are building.
3761 ///
3762 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3763 /// [`Scope::CloudPlatform`].
3764 ///
3765 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3766 /// tokens for more than one scope.
3767 ///
3768 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3769 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3770 /// sufficient, a read-write scope will do as well.
3771 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceSnapshotGetCall<'a, C>
3772 where
3773 St: AsRef<str>,
3774 {
3775 self._scopes.insert(String::from(scope.as_ref()));
3776 self
3777 }
3778 /// Identifies the authorization scope(s) for the method you are building.
3779 ///
3780 /// See [`Self::add_scope()`] for details.
3781 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceSnapshotGetCall<'a, C>
3782 where
3783 I: IntoIterator<Item = St>,
3784 St: AsRef<str>,
3785 {
3786 self._scopes
3787 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3788 self
3789 }
3790
3791 /// Removes all scopes, and no default scope will be used either.
3792 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3793 /// for details).
3794 pub fn clear_scopes(mut self) -> ProjectLocationInstanceSnapshotGetCall<'a, C> {
3795 self._scopes.clear();
3796 self
3797 }
3798}
3799
3800/// Lists all snapshots in a project for either a specified location or for all locations.
3801///
3802/// A builder for the *locations.instances.snapshots.list* method supported by a *project* resource.
3803/// It is not used directly, but through a [`ProjectMethods`] instance.
3804///
3805/// # Example
3806///
3807/// Instantiate a resource method builder
3808///
3809/// ```test_harness,no_run
3810/// # extern crate hyper;
3811/// # extern crate hyper_rustls;
3812/// # extern crate google_file1 as file1;
3813/// # async fn dox() {
3814/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3815///
3816/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3817/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3818/// # secret,
3819/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3820/// # ).build().await.unwrap();
3821///
3822/// # let client = hyper_util::client::legacy::Client::builder(
3823/// # hyper_util::rt::TokioExecutor::new()
3824/// # )
3825/// # .build(
3826/// # hyper_rustls::HttpsConnectorBuilder::new()
3827/// # .with_native_roots()
3828/// # .unwrap()
3829/// # .https_or_http()
3830/// # .enable_http1()
3831/// # .build()
3832/// # );
3833/// # let mut hub = CloudFilestore::new(client, auth);
3834/// // You can configure optional parameters by calling the respective setters at will, and
3835/// // execute the final call using `doit()`.
3836/// // Values shown here are possibly random and not representative !
3837/// let result = hub.projects().locations_instances_snapshots_list("parent")
3838/// .page_token("amet")
3839/// .page_size(-20)
3840/// .order_by("ipsum")
3841/// .filter("sed")
3842/// .doit().await;
3843/// # }
3844/// ```
3845pub struct ProjectLocationInstanceSnapshotListCall<'a, C>
3846where
3847 C: 'a,
3848{
3849 hub: &'a CloudFilestore<C>,
3850 _parent: String,
3851 _page_token: Option<String>,
3852 _page_size: Option<i32>,
3853 _order_by: Option<String>,
3854 _filter: Option<String>,
3855 _delegate: Option<&'a mut dyn common::Delegate>,
3856 _additional_params: HashMap<String, String>,
3857 _scopes: BTreeSet<String>,
3858}
3859
3860impl<'a, C> common::CallBuilder for ProjectLocationInstanceSnapshotListCall<'a, C> {}
3861
3862impl<'a, C> ProjectLocationInstanceSnapshotListCall<'a, C>
3863where
3864 C: common::Connector,
3865{
3866 /// Perform the operation you have build so far.
3867 pub async fn doit(mut self) -> common::Result<(common::Response, ListSnapshotsResponse)> {
3868 use std::borrow::Cow;
3869 use std::io::{Read, Seek};
3870
3871 use common::{url::Params, ToParts};
3872 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3873
3874 let mut dd = common::DefaultDelegate;
3875 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3876 dlg.begin(common::MethodInfo {
3877 id: "file.projects.locations.instances.snapshots.list",
3878 http_method: hyper::Method::GET,
3879 });
3880
3881 for &field in [
3882 "alt",
3883 "parent",
3884 "pageToken",
3885 "pageSize",
3886 "orderBy",
3887 "filter",
3888 ]
3889 .iter()
3890 {
3891 if self._additional_params.contains_key(field) {
3892 dlg.finished(false);
3893 return Err(common::Error::FieldClash(field));
3894 }
3895 }
3896
3897 let mut params = Params::with_capacity(7 + self._additional_params.len());
3898 params.push("parent", self._parent);
3899 if let Some(value) = self._page_token.as_ref() {
3900 params.push("pageToken", value);
3901 }
3902 if let Some(value) = self._page_size.as_ref() {
3903 params.push("pageSize", value.to_string());
3904 }
3905 if let Some(value) = self._order_by.as_ref() {
3906 params.push("orderBy", value);
3907 }
3908 if let Some(value) = self._filter.as_ref() {
3909 params.push("filter", value);
3910 }
3911
3912 params.extend(self._additional_params.iter());
3913
3914 params.push("alt", "json");
3915 let mut url = self.hub._base_url.clone() + "v1/{+parent}/snapshots";
3916 if self._scopes.is_empty() {
3917 self._scopes
3918 .insert(Scope::CloudPlatform.as_ref().to_string());
3919 }
3920
3921 #[allow(clippy::single_element_loop)]
3922 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3923 url = params.uri_replacement(url, param_name, find_this, true);
3924 }
3925 {
3926 let to_remove = ["parent"];
3927 params.remove_params(&to_remove);
3928 }
3929
3930 let url = params.parse_with_url(&url);
3931
3932 loop {
3933 let token = match self
3934 .hub
3935 .auth
3936 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3937 .await
3938 {
3939 Ok(token) => token,
3940 Err(e) => match dlg.token(e) {
3941 Ok(token) => token,
3942 Err(e) => {
3943 dlg.finished(false);
3944 return Err(common::Error::MissingToken(e));
3945 }
3946 },
3947 };
3948 let mut req_result = {
3949 let client = &self.hub.client;
3950 dlg.pre_request();
3951 let mut req_builder = hyper::Request::builder()
3952 .method(hyper::Method::GET)
3953 .uri(url.as_str())
3954 .header(USER_AGENT, self.hub._user_agent.clone());
3955
3956 if let Some(token) = token.as_ref() {
3957 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3958 }
3959
3960 let request = req_builder
3961 .header(CONTENT_LENGTH, 0_u64)
3962 .body(common::to_body::<String>(None));
3963
3964 client.request(request.unwrap()).await
3965 };
3966
3967 match req_result {
3968 Err(err) => {
3969 if let common::Retry::After(d) = dlg.http_error(&err) {
3970 sleep(d).await;
3971 continue;
3972 }
3973 dlg.finished(false);
3974 return Err(common::Error::HttpError(err));
3975 }
3976 Ok(res) => {
3977 let (mut parts, body) = res.into_parts();
3978 let mut body = common::Body::new(body);
3979 if !parts.status.is_success() {
3980 let bytes = common::to_bytes(body).await.unwrap_or_default();
3981 let error = serde_json::from_str(&common::to_string(&bytes));
3982 let response = common::to_response(parts, bytes.into());
3983
3984 if let common::Retry::After(d) =
3985 dlg.http_failure(&response, error.as_ref().ok())
3986 {
3987 sleep(d).await;
3988 continue;
3989 }
3990
3991 dlg.finished(false);
3992
3993 return Err(match error {
3994 Ok(value) => common::Error::BadRequest(value),
3995 _ => common::Error::Failure(response),
3996 });
3997 }
3998 let response = {
3999 let bytes = common::to_bytes(body).await.unwrap_or_default();
4000 let encoded = common::to_string(&bytes);
4001 match serde_json::from_str(&encoded) {
4002 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4003 Err(error) => {
4004 dlg.response_json_decode_error(&encoded, &error);
4005 return Err(common::Error::JsonDecodeError(
4006 encoded.to_string(),
4007 error,
4008 ));
4009 }
4010 }
4011 };
4012
4013 dlg.finished(true);
4014 return Ok(response);
4015 }
4016 }
4017 }
4018 }
4019
4020 /// Required. The instance for which to retrieve snapshot information, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`.
4021 ///
4022 /// Sets the *parent* path property to the given value.
4023 ///
4024 /// Even though the property as already been set when instantiating this call,
4025 /// we provide this method for API completeness.
4026 pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotListCall<'a, C> {
4027 self._parent = new_value.to_string();
4028 self
4029 }
4030 /// The next_page_token value to use if there are additional results to retrieve for this list request.
4031 ///
4032 /// Sets the *page token* query property to the given value.
4033 pub fn page_token(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotListCall<'a, C> {
4034 self._page_token = Some(new_value.to_string());
4035 self
4036 }
4037 /// The maximum number of items to return.
4038 ///
4039 /// Sets the *page size* query property to the given value.
4040 pub fn page_size(mut self, new_value: i32) -> ProjectLocationInstanceSnapshotListCall<'a, C> {
4041 self._page_size = Some(new_value);
4042 self
4043 }
4044 /// Sort results. Supported values are "name", "name desc" or "" (unsorted).
4045 ///
4046 /// Sets the *order by* query property to the given value.
4047 pub fn order_by(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotListCall<'a, C> {
4048 self._order_by = Some(new_value.to_string());
4049 self
4050 }
4051 /// List filter.
4052 ///
4053 /// Sets the *filter* query property to the given value.
4054 pub fn filter(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotListCall<'a, C> {
4055 self._filter = Some(new_value.to_string());
4056 self
4057 }
4058 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4059 /// while executing the actual API request.
4060 ///
4061 /// ````text
4062 /// It should be used to handle progress information, and to implement a certain level of resilience.
4063 /// ````
4064 ///
4065 /// Sets the *delegate* property to the given value.
4066 pub fn delegate(
4067 mut self,
4068 new_value: &'a mut dyn common::Delegate,
4069 ) -> ProjectLocationInstanceSnapshotListCall<'a, C> {
4070 self._delegate = Some(new_value);
4071 self
4072 }
4073
4074 /// Set any additional parameter of the query string used in the request.
4075 /// It should be used to set parameters which are not yet available through their own
4076 /// setters.
4077 ///
4078 /// Please note that this method must not be used to set any of the known parameters
4079 /// which have their own setter method. If done anyway, the request will fail.
4080 ///
4081 /// # Additional Parameters
4082 ///
4083 /// * *$.xgafv* (query-string) - V1 error format.
4084 /// * *access_token* (query-string) - OAuth access token.
4085 /// * *alt* (query-string) - Data format for response.
4086 /// * *callback* (query-string) - JSONP
4087 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4088 /// * *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.
4089 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4090 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4091 /// * *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.
4092 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4093 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4094 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSnapshotListCall<'a, C>
4095 where
4096 T: AsRef<str>,
4097 {
4098 self._additional_params
4099 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4100 self
4101 }
4102
4103 /// Identifies the authorization scope for the method you are building.
4104 ///
4105 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4106 /// [`Scope::CloudPlatform`].
4107 ///
4108 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4109 /// tokens for more than one scope.
4110 ///
4111 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4112 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4113 /// sufficient, a read-write scope will do as well.
4114 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceSnapshotListCall<'a, C>
4115 where
4116 St: AsRef<str>,
4117 {
4118 self._scopes.insert(String::from(scope.as_ref()));
4119 self
4120 }
4121 /// Identifies the authorization scope(s) for the method you are building.
4122 ///
4123 /// See [`Self::add_scope()`] for details.
4124 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceSnapshotListCall<'a, C>
4125 where
4126 I: IntoIterator<Item = St>,
4127 St: AsRef<str>,
4128 {
4129 self._scopes
4130 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4131 self
4132 }
4133
4134 /// Removes all scopes, and no default scope will be used either.
4135 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4136 /// for details).
4137 pub fn clear_scopes(mut self) -> ProjectLocationInstanceSnapshotListCall<'a, C> {
4138 self._scopes.clear();
4139 self
4140 }
4141}
4142
4143/// Updates the settings of a specific snapshot.
4144///
4145/// A builder for the *locations.instances.snapshots.patch* method supported by a *project* resource.
4146/// It is not used directly, but through a [`ProjectMethods`] instance.
4147///
4148/// # Example
4149///
4150/// Instantiate a resource method builder
4151///
4152/// ```test_harness,no_run
4153/// # extern crate hyper;
4154/// # extern crate hyper_rustls;
4155/// # extern crate google_file1 as file1;
4156/// use file1::api::Snapshot;
4157/// # async fn dox() {
4158/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4159///
4160/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4161/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4162/// # secret,
4163/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4164/// # ).build().await.unwrap();
4165///
4166/// # let client = hyper_util::client::legacy::Client::builder(
4167/// # hyper_util::rt::TokioExecutor::new()
4168/// # )
4169/// # .build(
4170/// # hyper_rustls::HttpsConnectorBuilder::new()
4171/// # .with_native_roots()
4172/// # .unwrap()
4173/// # .https_or_http()
4174/// # .enable_http1()
4175/// # .build()
4176/// # );
4177/// # let mut hub = CloudFilestore::new(client, auth);
4178/// // As the method needs a request, you would usually fill it with the desired information
4179/// // into the respective structure. Some of the parts shown here might not be applicable !
4180/// // Values shown here are possibly random and not representative !
4181/// let mut req = Snapshot::default();
4182///
4183/// // You can configure optional parameters by calling the respective setters at will, and
4184/// // execute the final call using `doit()`.
4185/// // Values shown here are possibly random and not representative !
4186/// let result = hub.projects().locations_instances_snapshots_patch(req, "name")
4187/// .update_mask(FieldMask::new::<&str>(&[]))
4188/// .doit().await;
4189/// # }
4190/// ```
4191pub struct ProjectLocationInstanceSnapshotPatchCall<'a, C>
4192where
4193 C: 'a,
4194{
4195 hub: &'a CloudFilestore<C>,
4196 _request: Snapshot,
4197 _name: String,
4198 _update_mask: Option<common::FieldMask>,
4199 _delegate: Option<&'a mut dyn common::Delegate>,
4200 _additional_params: HashMap<String, String>,
4201 _scopes: BTreeSet<String>,
4202}
4203
4204impl<'a, C> common::CallBuilder for ProjectLocationInstanceSnapshotPatchCall<'a, C> {}
4205
4206impl<'a, C> ProjectLocationInstanceSnapshotPatchCall<'a, C>
4207where
4208 C: common::Connector,
4209{
4210 /// Perform the operation you have build so far.
4211 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4212 use std::borrow::Cow;
4213 use std::io::{Read, Seek};
4214
4215 use common::{url::Params, ToParts};
4216 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4217
4218 let mut dd = common::DefaultDelegate;
4219 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4220 dlg.begin(common::MethodInfo {
4221 id: "file.projects.locations.instances.snapshots.patch",
4222 http_method: hyper::Method::PATCH,
4223 });
4224
4225 for &field in ["alt", "name", "updateMask"].iter() {
4226 if self._additional_params.contains_key(field) {
4227 dlg.finished(false);
4228 return Err(common::Error::FieldClash(field));
4229 }
4230 }
4231
4232 let mut params = Params::with_capacity(5 + self._additional_params.len());
4233 params.push("name", self._name);
4234 if let Some(value) = self._update_mask.as_ref() {
4235 params.push("updateMask", value.to_string());
4236 }
4237
4238 params.extend(self._additional_params.iter());
4239
4240 params.push("alt", "json");
4241 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4242 if self._scopes.is_empty() {
4243 self._scopes
4244 .insert(Scope::CloudPlatform.as_ref().to_string());
4245 }
4246
4247 #[allow(clippy::single_element_loop)]
4248 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4249 url = params.uri_replacement(url, param_name, find_this, true);
4250 }
4251 {
4252 let to_remove = ["name"];
4253 params.remove_params(&to_remove);
4254 }
4255
4256 let url = params.parse_with_url(&url);
4257
4258 let mut json_mime_type = mime::APPLICATION_JSON;
4259 let mut request_value_reader = {
4260 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4261 common::remove_json_null_values(&mut value);
4262 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4263 serde_json::to_writer(&mut dst, &value).unwrap();
4264 dst
4265 };
4266 let request_size = request_value_reader
4267 .seek(std::io::SeekFrom::End(0))
4268 .unwrap();
4269 request_value_reader
4270 .seek(std::io::SeekFrom::Start(0))
4271 .unwrap();
4272
4273 loop {
4274 let token = match self
4275 .hub
4276 .auth
4277 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4278 .await
4279 {
4280 Ok(token) => token,
4281 Err(e) => match dlg.token(e) {
4282 Ok(token) => token,
4283 Err(e) => {
4284 dlg.finished(false);
4285 return Err(common::Error::MissingToken(e));
4286 }
4287 },
4288 };
4289 request_value_reader
4290 .seek(std::io::SeekFrom::Start(0))
4291 .unwrap();
4292 let mut req_result = {
4293 let client = &self.hub.client;
4294 dlg.pre_request();
4295 let mut req_builder = hyper::Request::builder()
4296 .method(hyper::Method::PATCH)
4297 .uri(url.as_str())
4298 .header(USER_AGENT, self.hub._user_agent.clone());
4299
4300 if let Some(token) = token.as_ref() {
4301 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4302 }
4303
4304 let request = req_builder
4305 .header(CONTENT_TYPE, json_mime_type.to_string())
4306 .header(CONTENT_LENGTH, request_size as u64)
4307 .body(common::to_body(
4308 request_value_reader.get_ref().clone().into(),
4309 ));
4310
4311 client.request(request.unwrap()).await
4312 };
4313
4314 match req_result {
4315 Err(err) => {
4316 if let common::Retry::After(d) = dlg.http_error(&err) {
4317 sleep(d).await;
4318 continue;
4319 }
4320 dlg.finished(false);
4321 return Err(common::Error::HttpError(err));
4322 }
4323 Ok(res) => {
4324 let (mut parts, body) = res.into_parts();
4325 let mut body = common::Body::new(body);
4326 if !parts.status.is_success() {
4327 let bytes = common::to_bytes(body).await.unwrap_or_default();
4328 let error = serde_json::from_str(&common::to_string(&bytes));
4329 let response = common::to_response(parts, bytes.into());
4330
4331 if let common::Retry::After(d) =
4332 dlg.http_failure(&response, error.as_ref().ok())
4333 {
4334 sleep(d).await;
4335 continue;
4336 }
4337
4338 dlg.finished(false);
4339
4340 return Err(match error {
4341 Ok(value) => common::Error::BadRequest(value),
4342 _ => common::Error::Failure(response),
4343 });
4344 }
4345 let response = {
4346 let bytes = common::to_bytes(body).await.unwrap_or_default();
4347 let encoded = common::to_string(&bytes);
4348 match serde_json::from_str(&encoded) {
4349 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4350 Err(error) => {
4351 dlg.response_json_decode_error(&encoded, &error);
4352 return Err(common::Error::JsonDecodeError(
4353 encoded.to_string(),
4354 error,
4355 ));
4356 }
4357 }
4358 };
4359
4360 dlg.finished(true);
4361 return Ok(response);
4362 }
4363 }
4364 }
4365 }
4366
4367 ///
4368 /// Sets the *request* property to the given value.
4369 ///
4370 /// Even though the property as already been set when instantiating this call,
4371 /// we provide this method for API completeness.
4372 pub fn request(
4373 mut self,
4374 new_value: Snapshot,
4375 ) -> ProjectLocationInstanceSnapshotPatchCall<'a, C> {
4376 self._request = new_value;
4377 self
4378 }
4379 /// Output only. The resource name of the snapshot, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}/snapshots/{snapshot_id}`.
4380 ///
4381 /// Sets the *name* path property to the given value.
4382 ///
4383 /// Even though the property as already been set when instantiating this call,
4384 /// we provide this method for API completeness.
4385 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotPatchCall<'a, C> {
4386 self._name = new_value.to_string();
4387 self
4388 }
4389 /// Required. Mask of fields to update. At least one path must be supplied in this field.
4390 ///
4391 /// Sets the *update mask* query property to the given value.
4392 pub fn update_mask(
4393 mut self,
4394 new_value: common::FieldMask,
4395 ) -> ProjectLocationInstanceSnapshotPatchCall<'a, C> {
4396 self._update_mask = Some(new_value);
4397 self
4398 }
4399 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4400 /// while executing the actual API request.
4401 ///
4402 /// ````text
4403 /// It should be used to handle progress information, and to implement a certain level of resilience.
4404 /// ````
4405 ///
4406 /// Sets the *delegate* property to the given value.
4407 pub fn delegate(
4408 mut self,
4409 new_value: &'a mut dyn common::Delegate,
4410 ) -> ProjectLocationInstanceSnapshotPatchCall<'a, C> {
4411 self._delegate = Some(new_value);
4412 self
4413 }
4414
4415 /// Set any additional parameter of the query string used in the request.
4416 /// It should be used to set parameters which are not yet available through their own
4417 /// setters.
4418 ///
4419 /// Please note that this method must not be used to set any of the known parameters
4420 /// which have their own setter method. If done anyway, the request will fail.
4421 ///
4422 /// # Additional Parameters
4423 ///
4424 /// * *$.xgafv* (query-string) - V1 error format.
4425 /// * *access_token* (query-string) - OAuth access token.
4426 /// * *alt* (query-string) - Data format for response.
4427 /// * *callback* (query-string) - JSONP
4428 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4429 /// * *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.
4430 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4431 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4432 /// * *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.
4433 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4434 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4435 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSnapshotPatchCall<'a, C>
4436 where
4437 T: AsRef<str>,
4438 {
4439 self._additional_params
4440 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4441 self
4442 }
4443
4444 /// Identifies the authorization scope for the method you are building.
4445 ///
4446 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4447 /// [`Scope::CloudPlatform`].
4448 ///
4449 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4450 /// tokens for more than one scope.
4451 ///
4452 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4453 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4454 /// sufficient, a read-write scope will do as well.
4455 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceSnapshotPatchCall<'a, C>
4456 where
4457 St: AsRef<str>,
4458 {
4459 self._scopes.insert(String::from(scope.as_ref()));
4460 self
4461 }
4462 /// Identifies the authorization scope(s) for the method you are building.
4463 ///
4464 /// See [`Self::add_scope()`] for details.
4465 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceSnapshotPatchCall<'a, C>
4466 where
4467 I: IntoIterator<Item = St>,
4468 St: AsRef<str>,
4469 {
4470 self._scopes
4471 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4472 self
4473 }
4474
4475 /// Removes all scopes, and no default scope will be used either.
4476 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4477 /// for details).
4478 pub fn clear_scopes(mut self) -> ProjectLocationInstanceSnapshotPatchCall<'a, C> {
4479 self._scopes.clear();
4480 self
4481 }
4482}
4483
4484/// 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).
4485///
4486/// A builder for the *locations.instances.create* method supported by a *project* resource.
4487/// It is not used directly, but through a [`ProjectMethods`] instance.
4488///
4489/// # Example
4490///
4491/// Instantiate a resource method builder
4492///
4493/// ```test_harness,no_run
4494/// # extern crate hyper;
4495/// # extern crate hyper_rustls;
4496/// # extern crate google_file1 as file1;
4497/// use file1::api::Instance;
4498/// # async fn dox() {
4499/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4500///
4501/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4502/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4503/// # secret,
4504/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4505/// # ).build().await.unwrap();
4506///
4507/// # let client = hyper_util::client::legacy::Client::builder(
4508/// # hyper_util::rt::TokioExecutor::new()
4509/// # )
4510/// # .build(
4511/// # hyper_rustls::HttpsConnectorBuilder::new()
4512/// # .with_native_roots()
4513/// # .unwrap()
4514/// # .https_or_http()
4515/// # .enable_http1()
4516/// # .build()
4517/// # );
4518/// # let mut hub = CloudFilestore::new(client, auth);
4519/// // As the method needs a request, you would usually fill it with the desired information
4520/// // into the respective structure. Some of the parts shown here might not be applicable !
4521/// // Values shown here are possibly random and not representative !
4522/// let mut req = Instance::default();
4523///
4524/// // You can configure optional parameters by calling the respective setters at will, and
4525/// // execute the final call using `doit()`.
4526/// // Values shown here are possibly random and not representative !
4527/// let result = hub.projects().locations_instances_create(req, "parent")
4528/// .instance_id("rebum.")
4529/// .doit().await;
4530/// # }
4531/// ```
4532pub struct ProjectLocationInstanceCreateCall<'a, C>
4533where
4534 C: 'a,
4535{
4536 hub: &'a CloudFilestore<C>,
4537 _request: Instance,
4538 _parent: String,
4539 _instance_id: Option<String>,
4540 _delegate: Option<&'a mut dyn common::Delegate>,
4541 _additional_params: HashMap<String, String>,
4542 _scopes: BTreeSet<String>,
4543}
4544
4545impl<'a, C> common::CallBuilder for ProjectLocationInstanceCreateCall<'a, C> {}
4546
4547impl<'a, C> ProjectLocationInstanceCreateCall<'a, C>
4548where
4549 C: common::Connector,
4550{
4551 /// Perform the operation you have build so far.
4552 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4553 use std::borrow::Cow;
4554 use std::io::{Read, Seek};
4555
4556 use common::{url::Params, ToParts};
4557 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4558
4559 let mut dd = common::DefaultDelegate;
4560 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4561 dlg.begin(common::MethodInfo {
4562 id: "file.projects.locations.instances.create",
4563 http_method: hyper::Method::POST,
4564 });
4565
4566 for &field in ["alt", "parent", "instanceId"].iter() {
4567 if self._additional_params.contains_key(field) {
4568 dlg.finished(false);
4569 return Err(common::Error::FieldClash(field));
4570 }
4571 }
4572
4573 let mut params = Params::with_capacity(5 + self._additional_params.len());
4574 params.push("parent", self._parent);
4575 if let Some(value) = self._instance_id.as_ref() {
4576 params.push("instanceId", value);
4577 }
4578
4579 params.extend(self._additional_params.iter());
4580
4581 params.push("alt", "json");
4582 let mut url = self.hub._base_url.clone() + "v1/{+parent}/instances";
4583 if self._scopes.is_empty() {
4584 self._scopes
4585 .insert(Scope::CloudPlatform.as_ref().to_string());
4586 }
4587
4588 #[allow(clippy::single_element_loop)]
4589 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4590 url = params.uri_replacement(url, param_name, find_this, true);
4591 }
4592 {
4593 let to_remove = ["parent"];
4594 params.remove_params(&to_remove);
4595 }
4596
4597 let url = params.parse_with_url(&url);
4598
4599 let mut json_mime_type = mime::APPLICATION_JSON;
4600 let mut request_value_reader = {
4601 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4602 common::remove_json_null_values(&mut value);
4603 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4604 serde_json::to_writer(&mut dst, &value).unwrap();
4605 dst
4606 };
4607 let request_size = request_value_reader
4608 .seek(std::io::SeekFrom::End(0))
4609 .unwrap();
4610 request_value_reader
4611 .seek(std::io::SeekFrom::Start(0))
4612 .unwrap();
4613
4614 loop {
4615 let token = match self
4616 .hub
4617 .auth
4618 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4619 .await
4620 {
4621 Ok(token) => token,
4622 Err(e) => match dlg.token(e) {
4623 Ok(token) => token,
4624 Err(e) => {
4625 dlg.finished(false);
4626 return Err(common::Error::MissingToken(e));
4627 }
4628 },
4629 };
4630 request_value_reader
4631 .seek(std::io::SeekFrom::Start(0))
4632 .unwrap();
4633 let mut req_result = {
4634 let client = &self.hub.client;
4635 dlg.pre_request();
4636 let mut req_builder = hyper::Request::builder()
4637 .method(hyper::Method::POST)
4638 .uri(url.as_str())
4639 .header(USER_AGENT, self.hub._user_agent.clone());
4640
4641 if let Some(token) = token.as_ref() {
4642 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4643 }
4644
4645 let request = req_builder
4646 .header(CONTENT_TYPE, json_mime_type.to_string())
4647 .header(CONTENT_LENGTH, request_size as u64)
4648 .body(common::to_body(
4649 request_value_reader.get_ref().clone().into(),
4650 ));
4651
4652 client.request(request.unwrap()).await
4653 };
4654
4655 match req_result {
4656 Err(err) => {
4657 if let common::Retry::After(d) = dlg.http_error(&err) {
4658 sleep(d).await;
4659 continue;
4660 }
4661 dlg.finished(false);
4662 return Err(common::Error::HttpError(err));
4663 }
4664 Ok(res) => {
4665 let (mut parts, body) = res.into_parts();
4666 let mut body = common::Body::new(body);
4667 if !parts.status.is_success() {
4668 let bytes = common::to_bytes(body).await.unwrap_or_default();
4669 let error = serde_json::from_str(&common::to_string(&bytes));
4670 let response = common::to_response(parts, bytes.into());
4671
4672 if let common::Retry::After(d) =
4673 dlg.http_failure(&response, error.as_ref().ok())
4674 {
4675 sleep(d).await;
4676 continue;
4677 }
4678
4679 dlg.finished(false);
4680
4681 return Err(match error {
4682 Ok(value) => common::Error::BadRequest(value),
4683 _ => common::Error::Failure(response),
4684 });
4685 }
4686 let response = {
4687 let bytes = common::to_bytes(body).await.unwrap_or_default();
4688 let encoded = common::to_string(&bytes);
4689 match serde_json::from_str(&encoded) {
4690 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4691 Err(error) => {
4692 dlg.response_json_decode_error(&encoded, &error);
4693 return Err(common::Error::JsonDecodeError(
4694 encoded.to_string(),
4695 error,
4696 ));
4697 }
4698 }
4699 };
4700
4701 dlg.finished(true);
4702 return Ok(response);
4703 }
4704 }
4705 }
4706 }
4707
4708 ///
4709 /// Sets the *request* property to the given value.
4710 ///
4711 /// Even though the property as already been set when instantiating this call,
4712 /// we provide this method for API completeness.
4713 pub fn request(mut self, new_value: Instance) -> ProjectLocationInstanceCreateCall<'a, C> {
4714 self._request = new_value;
4715 self
4716 }
4717 /// 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**.
4718 ///
4719 /// Sets the *parent* path property to the given value.
4720 ///
4721 /// Even though the property as already been set when instantiating this call,
4722 /// we provide this method for API completeness.
4723 pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceCreateCall<'a, C> {
4724 self._parent = new_value.to_string();
4725 self
4726 }
4727 /// Required. The name of the instance to create. The name must be unique for the specified project and location.
4728 ///
4729 /// Sets the *instance id* query property to the given value.
4730 pub fn instance_id(mut self, new_value: &str) -> ProjectLocationInstanceCreateCall<'a, C> {
4731 self._instance_id = Some(new_value.to_string());
4732 self
4733 }
4734 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4735 /// while executing the actual API request.
4736 ///
4737 /// ````text
4738 /// It should be used to handle progress information, and to implement a certain level of resilience.
4739 /// ````
4740 ///
4741 /// Sets the *delegate* property to the given value.
4742 pub fn delegate(
4743 mut self,
4744 new_value: &'a mut dyn common::Delegate,
4745 ) -> ProjectLocationInstanceCreateCall<'a, C> {
4746 self._delegate = Some(new_value);
4747 self
4748 }
4749
4750 /// Set any additional parameter of the query string used in the request.
4751 /// It should be used to set parameters which are not yet available through their own
4752 /// setters.
4753 ///
4754 /// Please note that this method must not be used to set any of the known parameters
4755 /// which have their own setter method. If done anyway, the request will fail.
4756 ///
4757 /// # Additional Parameters
4758 ///
4759 /// * *$.xgafv* (query-string) - V1 error format.
4760 /// * *access_token* (query-string) - OAuth access token.
4761 /// * *alt* (query-string) - Data format for response.
4762 /// * *callback* (query-string) - JSONP
4763 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4764 /// * *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.
4765 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4766 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4767 /// * *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.
4768 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4769 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4770 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceCreateCall<'a, C>
4771 where
4772 T: AsRef<str>,
4773 {
4774 self._additional_params
4775 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4776 self
4777 }
4778
4779 /// Identifies the authorization scope for the method you are building.
4780 ///
4781 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4782 /// [`Scope::CloudPlatform`].
4783 ///
4784 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4785 /// tokens for more than one scope.
4786 ///
4787 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4788 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4789 /// sufficient, a read-write scope will do as well.
4790 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceCreateCall<'a, C>
4791 where
4792 St: AsRef<str>,
4793 {
4794 self._scopes.insert(String::from(scope.as_ref()));
4795 self
4796 }
4797 /// Identifies the authorization scope(s) for the method you are building.
4798 ///
4799 /// See [`Self::add_scope()`] for details.
4800 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceCreateCall<'a, C>
4801 where
4802 I: IntoIterator<Item = St>,
4803 St: AsRef<str>,
4804 {
4805 self._scopes
4806 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4807 self
4808 }
4809
4810 /// Removes all scopes, and no default scope will be used either.
4811 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4812 /// for details).
4813 pub fn clear_scopes(mut self) -> ProjectLocationInstanceCreateCall<'a, C> {
4814 self._scopes.clear();
4815 self
4816 }
4817}
4818
4819/// Deletes an instance.
4820///
4821/// A builder for the *locations.instances.delete* method supported by a *project* resource.
4822/// It is not used directly, but through a [`ProjectMethods`] instance.
4823///
4824/// # Example
4825///
4826/// Instantiate a resource method builder
4827///
4828/// ```test_harness,no_run
4829/// # extern crate hyper;
4830/// # extern crate hyper_rustls;
4831/// # extern crate google_file1 as file1;
4832/// # async fn dox() {
4833/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4834///
4835/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4836/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4837/// # secret,
4838/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4839/// # ).build().await.unwrap();
4840///
4841/// # let client = hyper_util::client::legacy::Client::builder(
4842/// # hyper_util::rt::TokioExecutor::new()
4843/// # )
4844/// # .build(
4845/// # hyper_rustls::HttpsConnectorBuilder::new()
4846/// # .with_native_roots()
4847/// # .unwrap()
4848/// # .https_or_http()
4849/// # .enable_http1()
4850/// # .build()
4851/// # );
4852/// # let mut hub = CloudFilestore::new(client, auth);
4853/// // You can configure optional parameters by calling the respective setters at will, and
4854/// // execute the final call using `doit()`.
4855/// // Values shown here are possibly random and not representative !
4856/// let result = hub.projects().locations_instances_delete("name")
4857/// .force(true)
4858/// .doit().await;
4859/// # }
4860/// ```
4861pub struct ProjectLocationInstanceDeleteCall<'a, C>
4862where
4863 C: 'a,
4864{
4865 hub: &'a CloudFilestore<C>,
4866 _name: String,
4867 _force: Option<bool>,
4868 _delegate: Option<&'a mut dyn common::Delegate>,
4869 _additional_params: HashMap<String, String>,
4870 _scopes: BTreeSet<String>,
4871}
4872
4873impl<'a, C> common::CallBuilder for ProjectLocationInstanceDeleteCall<'a, C> {}
4874
4875impl<'a, C> ProjectLocationInstanceDeleteCall<'a, C>
4876where
4877 C: common::Connector,
4878{
4879 /// Perform the operation you have build so far.
4880 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4881 use std::borrow::Cow;
4882 use std::io::{Read, Seek};
4883
4884 use common::{url::Params, ToParts};
4885 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4886
4887 let mut dd = common::DefaultDelegate;
4888 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4889 dlg.begin(common::MethodInfo {
4890 id: "file.projects.locations.instances.delete",
4891 http_method: hyper::Method::DELETE,
4892 });
4893
4894 for &field in ["alt", "name", "force"].iter() {
4895 if self._additional_params.contains_key(field) {
4896 dlg.finished(false);
4897 return Err(common::Error::FieldClash(field));
4898 }
4899 }
4900
4901 let mut params = Params::with_capacity(4 + self._additional_params.len());
4902 params.push("name", self._name);
4903 if let Some(value) = self._force.as_ref() {
4904 params.push("force", value.to_string());
4905 }
4906
4907 params.extend(self._additional_params.iter());
4908
4909 params.push("alt", "json");
4910 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4911 if self._scopes.is_empty() {
4912 self._scopes
4913 .insert(Scope::CloudPlatform.as_ref().to_string());
4914 }
4915
4916 #[allow(clippy::single_element_loop)]
4917 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4918 url = params.uri_replacement(url, param_name, find_this, true);
4919 }
4920 {
4921 let to_remove = ["name"];
4922 params.remove_params(&to_remove);
4923 }
4924
4925 let url = params.parse_with_url(&url);
4926
4927 loop {
4928 let token = match self
4929 .hub
4930 .auth
4931 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4932 .await
4933 {
4934 Ok(token) => token,
4935 Err(e) => match dlg.token(e) {
4936 Ok(token) => token,
4937 Err(e) => {
4938 dlg.finished(false);
4939 return Err(common::Error::MissingToken(e));
4940 }
4941 },
4942 };
4943 let mut req_result = {
4944 let client = &self.hub.client;
4945 dlg.pre_request();
4946 let mut req_builder = hyper::Request::builder()
4947 .method(hyper::Method::DELETE)
4948 .uri(url.as_str())
4949 .header(USER_AGENT, self.hub._user_agent.clone());
4950
4951 if let Some(token) = token.as_ref() {
4952 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4953 }
4954
4955 let request = req_builder
4956 .header(CONTENT_LENGTH, 0_u64)
4957 .body(common::to_body::<String>(None));
4958
4959 client.request(request.unwrap()).await
4960 };
4961
4962 match req_result {
4963 Err(err) => {
4964 if let common::Retry::After(d) = dlg.http_error(&err) {
4965 sleep(d).await;
4966 continue;
4967 }
4968 dlg.finished(false);
4969 return Err(common::Error::HttpError(err));
4970 }
4971 Ok(res) => {
4972 let (mut parts, body) = res.into_parts();
4973 let mut body = common::Body::new(body);
4974 if !parts.status.is_success() {
4975 let bytes = common::to_bytes(body).await.unwrap_or_default();
4976 let error = serde_json::from_str(&common::to_string(&bytes));
4977 let response = common::to_response(parts, bytes.into());
4978
4979 if let common::Retry::After(d) =
4980 dlg.http_failure(&response, error.as_ref().ok())
4981 {
4982 sleep(d).await;
4983 continue;
4984 }
4985
4986 dlg.finished(false);
4987
4988 return Err(match error {
4989 Ok(value) => common::Error::BadRequest(value),
4990 _ => common::Error::Failure(response),
4991 });
4992 }
4993 let response = {
4994 let bytes = common::to_bytes(body).await.unwrap_or_default();
4995 let encoded = common::to_string(&bytes);
4996 match serde_json::from_str(&encoded) {
4997 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4998 Err(error) => {
4999 dlg.response_json_decode_error(&encoded, &error);
5000 return Err(common::Error::JsonDecodeError(
5001 encoded.to_string(),
5002 error,
5003 ));
5004 }
5005 }
5006 };
5007
5008 dlg.finished(true);
5009 return Ok(response);
5010 }
5011 }
5012 }
5013 }
5014
5015 /// Required. The instance resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`
5016 ///
5017 /// Sets the *name* path property to the given value.
5018 ///
5019 /// Even though the property as already been set when instantiating this call,
5020 /// we provide this method for API completeness.
5021 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceDeleteCall<'a, C> {
5022 self._name = new_value.to_string();
5023 self
5024 }
5025 /// 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.)
5026 ///
5027 /// Sets the *force* query property to the given value.
5028 pub fn force(mut self, new_value: bool) -> ProjectLocationInstanceDeleteCall<'a, C> {
5029 self._force = Some(new_value);
5030 self
5031 }
5032 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5033 /// while executing the actual API request.
5034 ///
5035 /// ````text
5036 /// It should be used to handle progress information, and to implement a certain level of resilience.
5037 /// ````
5038 ///
5039 /// Sets the *delegate* property to the given value.
5040 pub fn delegate(
5041 mut self,
5042 new_value: &'a mut dyn common::Delegate,
5043 ) -> ProjectLocationInstanceDeleteCall<'a, C> {
5044 self._delegate = Some(new_value);
5045 self
5046 }
5047
5048 /// Set any additional parameter of the query string used in the request.
5049 /// It should be used to set parameters which are not yet available through their own
5050 /// setters.
5051 ///
5052 /// Please note that this method must not be used to set any of the known parameters
5053 /// which have their own setter method. If done anyway, the request will fail.
5054 ///
5055 /// # Additional Parameters
5056 ///
5057 /// * *$.xgafv* (query-string) - V1 error format.
5058 /// * *access_token* (query-string) - OAuth access token.
5059 /// * *alt* (query-string) - Data format for response.
5060 /// * *callback* (query-string) - JSONP
5061 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5062 /// * *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.
5063 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5064 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5065 /// * *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.
5066 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5067 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5068 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceDeleteCall<'a, C>
5069 where
5070 T: AsRef<str>,
5071 {
5072 self._additional_params
5073 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5074 self
5075 }
5076
5077 /// Identifies the authorization scope for the method you are building.
5078 ///
5079 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5080 /// [`Scope::CloudPlatform`].
5081 ///
5082 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5083 /// tokens for more than one scope.
5084 ///
5085 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5086 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5087 /// sufficient, a read-write scope will do as well.
5088 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceDeleteCall<'a, C>
5089 where
5090 St: AsRef<str>,
5091 {
5092 self._scopes.insert(String::from(scope.as_ref()));
5093 self
5094 }
5095 /// Identifies the authorization scope(s) for the method you are building.
5096 ///
5097 /// See [`Self::add_scope()`] for details.
5098 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceDeleteCall<'a, C>
5099 where
5100 I: IntoIterator<Item = St>,
5101 St: AsRef<str>,
5102 {
5103 self._scopes
5104 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5105 self
5106 }
5107
5108 /// Removes all scopes, and no default scope will be used either.
5109 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5110 /// for details).
5111 pub fn clear_scopes(mut self) -> ProjectLocationInstanceDeleteCall<'a, C> {
5112 self._scopes.clear();
5113 self
5114 }
5115}
5116
5117/// Gets the details of a specific instance.
5118///
5119/// A builder for the *locations.instances.get* method supported by a *project* resource.
5120/// It is not used directly, but through a [`ProjectMethods`] instance.
5121///
5122/// # Example
5123///
5124/// Instantiate a resource method builder
5125///
5126/// ```test_harness,no_run
5127/// # extern crate hyper;
5128/// # extern crate hyper_rustls;
5129/// # extern crate google_file1 as file1;
5130/// # async fn dox() {
5131/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5132///
5133/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5134/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5135/// # secret,
5136/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5137/// # ).build().await.unwrap();
5138///
5139/// # let client = hyper_util::client::legacy::Client::builder(
5140/// # hyper_util::rt::TokioExecutor::new()
5141/// # )
5142/// # .build(
5143/// # hyper_rustls::HttpsConnectorBuilder::new()
5144/// # .with_native_roots()
5145/// # .unwrap()
5146/// # .https_or_http()
5147/// # .enable_http1()
5148/// # .build()
5149/// # );
5150/// # let mut hub = CloudFilestore::new(client, auth);
5151/// // You can configure optional parameters by calling the respective setters at will, and
5152/// // execute the final call using `doit()`.
5153/// // Values shown here are possibly random and not representative !
5154/// let result = hub.projects().locations_instances_get("name")
5155/// .doit().await;
5156/// # }
5157/// ```
5158pub struct ProjectLocationInstanceGetCall<'a, C>
5159where
5160 C: 'a,
5161{
5162 hub: &'a CloudFilestore<C>,
5163 _name: String,
5164 _delegate: Option<&'a mut dyn common::Delegate>,
5165 _additional_params: HashMap<String, String>,
5166 _scopes: BTreeSet<String>,
5167}
5168
5169impl<'a, C> common::CallBuilder for ProjectLocationInstanceGetCall<'a, C> {}
5170
5171impl<'a, C> ProjectLocationInstanceGetCall<'a, C>
5172where
5173 C: common::Connector,
5174{
5175 /// Perform the operation you have build so far.
5176 pub async fn doit(mut self) -> common::Result<(common::Response, Instance)> {
5177 use std::borrow::Cow;
5178 use std::io::{Read, Seek};
5179
5180 use common::{url::Params, ToParts};
5181 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5182
5183 let mut dd = common::DefaultDelegate;
5184 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5185 dlg.begin(common::MethodInfo {
5186 id: "file.projects.locations.instances.get",
5187 http_method: hyper::Method::GET,
5188 });
5189
5190 for &field in ["alt", "name"].iter() {
5191 if self._additional_params.contains_key(field) {
5192 dlg.finished(false);
5193 return Err(common::Error::FieldClash(field));
5194 }
5195 }
5196
5197 let mut params = Params::with_capacity(3 + self._additional_params.len());
5198 params.push("name", self._name);
5199
5200 params.extend(self._additional_params.iter());
5201
5202 params.push("alt", "json");
5203 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5204 if self._scopes.is_empty() {
5205 self._scopes
5206 .insert(Scope::CloudPlatform.as_ref().to_string());
5207 }
5208
5209 #[allow(clippy::single_element_loop)]
5210 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5211 url = params.uri_replacement(url, param_name, find_this, true);
5212 }
5213 {
5214 let to_remove = ["name"];
5215 params.remove_params(&to_remove);
5216 }
5217
5218 let url = params.parse_with_url(&url);
5219
5220 loop {
5221 let token = match self
5222 .hub
5223 .auth
5224 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5225 .await
5226 {
5227 Ok(token) => token,
5228 Err(e) => match dlg.token(e) {
5229 Ok(token) => token,
5230 Err(e) => {
5231 dlg.finished(false);
5232 return Err(common::Error::MissingToken(e));
5233 }
5234 },
5235 };
5236 let mut req_result = {
5237 let client = &self.hub.client;
5238 dlg.pre_request();
5239 let mut req_builder = hyper::Request::builder()
5240 .method(hyper::Method::GET)
5241 .uri(url.as_str())
5242 .header(USER_AGENT, self.hub._user_agent.clone());
5243
5244 if let Some(token) = token.as_ref() {
5245 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5246 }
5247
5248 let request = req_builder
5249 .header(CONTENT_LENGTH, 0_u64)
5250 .body(common::to_body::<String>(None));
5251
5252 client.request(request.unwrap()).await
5253 };
5254
5255 match req_result {
5256 Err(err) => {
5257 if let common::Retry::After(d) = dlg.http_error(&err) {
5258 sleep(d).await;
5259 continue;
5260 }
5261 dlg.finished(false);
5262 return Err(common::Error::HttpError(err));
5263 }
5264 Ok(res) => {
5265 let (mut parts, body) = res.into_parts();
5266 let mut body = common::Body::new(body);
5267 if !parts.status.is_success() {
5268 let bytes = common::to_bytes(body).await.unwrap_or_default();
5269 let error = serde_json::from_str(&common::to_string(&bytes));
5270 let response = common::to_response(parts, bytes.into());
5271
5272 if let common::Retry::After(d) =
5273 dlg.http_failure(&response, error.as_ref().ok())
5274 {
5275 sleep(d).await;
5276 continue;
5277 }
5278
5279 dlg.finished(false);
5280
5281 return Err(match error {
5282 Ok(value) => common::Error::BadRequest(value),
5283 _ => common::Error::Failure(response),
5284 });
5285 }
5286 let response = {
5287 let bytes = common::to_bytes(body).await.unwrap_or_default();
5288 let encoded = common::to_string(&bytes);
5289 match serde_json::from_str(&encoded) {
5290 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5291 Err(error) => {
5292 dlg.response_json_decode_error(&encoded, &error);
5293 return Err(common::Error::JsonDecodeError(
5294 encoded.to_string(),
5295 error,
5296 ));
5297 }
5298 }
5299 };
5300
5301 dlg.finished(true);
5302 return Ok(response);
5303 }
5304 }
5305 }
5306 }
5307
5308 /// Required. The instance resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`.
5309 ///
5310 /// Sets the *name* path property to the given value.
5311 ///
5312 /// Even though the property as already been set when instantiating this call,
5313 /// we provide this method for API completeness.
5314 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceGetCall<'a, C> {
5315 self._name = new_value.to_string();
5316 self
5317 }
5318 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5319 /// while executing the actual API request.
5320 ///
5321 /// ````text
5322 /// It should be used to handle progress information, and to implement a certain level of resilience.
5323 /// ````
5324 ///
5325 /// Sets the *delegate* property to the given value.
5326 pub fn delegate(
5327 mut self,
5328 new_value: &'a mut dyn common::Delegate,
5329 ) -> ProjectLocationInstanceGetCall<'a, C> {
5330 self._delegate = Some(new_value);
5331 self
5332 }
5333
5334 /// Set any additional parameter of the query string used in the request.
5335 /// It should be used to set parameters which are not yet available through their own
5336 /// setters.
5337 ///
5338 /// Please note that this method must not be used to set any of the known parameters
5339 /// which have their own setter method. If done anyway, the request will fail.
5340 ///
5341 /// # Additional Parameters
5342 ///
5343 /// * *$.xgafv* (query-string) - V1 error format.
5344 /// * *access_token* (query-string) - OAuth access token.
5345 /// * *alt* (query-string) - Data format for response.
5346 /// * *callback* (query-string) - JSONP
5347 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5348 /// * *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.
5349 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5350 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5351 /// * *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.
5352 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5353 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5354 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceGetCall<'a, C>
5355 where
5356 T: AsRef<str>,
5357 {
5358 self._additional_params
5359 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5360 self
5361 }
5362
5363 /// Identifies the authorization scope for the method you are building.
5364 ///
5365 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5366 /// [`Scope::CloudPlatform`].
5367 ///
5368 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5369 /// tokens for more than one scope.
5370 ///
5371 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5372 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5373 /// sufficient, a read-write scope will do as well.
5374 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceGetCall<'a, C>
5375 where
5376 St: AsRef<str>,
5377 {
5378 self._scopes.insert(String::from(scope.as_ref()));
5379 self
5380 }
5381 /// Identifies the authorization scope(s) for the method you are building.
5382 ///
5383 /// See [`Self::add_scope()`] for details.
5384 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceGetCall<'a, C>
5385 where
5386 I: IntoIterator<Item = St>,
5387 St: AsRef<str>,
5388 {
5389 self._scopes
5390 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5391 self
5392 }
5393
5394 /// Removes all scopes, and no default scope will be used either.
5395 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5396 /// for details).
5397 pub fn clear_scopes(mut self) -> ProjectLocationInstanceGetCall<'a, C> {
5398 self._scopes.clear();
5399 self
5400 }
5401}
5402
5403/// Lists all instances in a project for either a specified location or for all locations.
5404///
5405/// A builder for the *locations.instances.list* method supported by a *project* resource.
5406/// It is not used directly, but through a [`ProjectMethods`] instance.
5407///
5408/// # Example
5409///
5410/// Instantiate a resource method builder
5411///
5412/// ```test_harness,no_run
5413/// # extern crate hyper;
5414/// # extern crate hyper_rustls;
5415/// # extern crate google_file1 as file1;
5416/// # async fn dox() {
5417/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5418///
5419/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5420/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5421/// # secret,
5422/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5423/// # ).build().await.unwrap();
5424///
5425/// # let client = hyper_util::client::legacy::Client::builder(
5426/// # hyper_util::rt::TokioExecutor::new()
5427/// # )
5428/// # .build(
5429/// # hyper_rustls::HttpsConnectorBuilder::new()
5430/// # .with_native_roots()
5431/// # .unwrap()
5432/// # .https_or_http()
5433/// # .enable_http1()
5434/// # .build()
5435/// # );
5436/// # let mut hub = CloudFilestore::new(client, auth);
5437/// // You can configure optional parameters by calling the respective setters at will, and
5438/// // execute the final call using `doit()`.
5439/// // Values shown here are possibly random and not representative !
5440/// let result = hub.projects().locations_instances_list("parent")
5441/// .page_token("gubergren")
5442/// .page_size(-17)
5443/// .order_by("dolor")
5444/// .filter("Lorem")
5445/// .doit().await;
5446/// # }
5447/// ```
5448pub struct ProjectLocationInstanceListCall<'a, C>
5449where
5450 C: 'a,
5451{
5452 hub: &'a CloudFilestore<C>,
5453 _parent: String,
5454 _page_token: Option<String>,
5455 _page_size: Option<i32>,
5456 _order_by: Option<String>,
5457 _filter: Option<String>,
5458 _delegate: Option<&'a mut dyn common::Delegate>,
5459 _additional_params: HashMap<String, String>,
5460 _scopes: BTreeSet<String>,
5461}
5462
5463impl<'a, C> common::CallBuilder for ProjectLocationInstanceListCall<'a, C> {}
5464
5465impl<'a, C> ProjectLocationInstanceListCall<'a, C>
5466where
5467 C: common::Connector,
5468{
5469 /// Perform the operation you have build so far.
5470 pub async fn doit(mut self) -> common::Result<(common::Response, ListInstancesResponse)> {
5471 use std::borrow::Cow;
5472 use std::io::{Read, Seek};
5473
5474 use common::{url::Params, ToParts};
5475 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5476
5477 let mut dd = common::DefaultDelegate;
5478 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5479 dlg.begin(common::MethodInfo {
5480 id: "file.projects.locations.instances.list",
5481 http_method: hyper::Method::GET,
5482 });
5483
5484 for &field in [
5485 "alt",
5486 "parent",
5487 "pageToken",
5488 "pageSize",
5489 "orderBy",
5490 "filter",
5491 ]
5492 .iter()
5493 {
5494 if self._additional_params.contains_key(field) {
5495 dlg.finished(false);
5496 return Err(common::Error::FieldClash(field));
5497 }
5498 }
5499
5500 let mut params = Params::with_capacity(7 + self._additional_params.len());
5501 params.push("parent", self._parent);
5502 if let Some(value) = self._page_token.as_ref() {
5503 params.push("pageToken", value);
5504 }
5505 if let Some(value) = self._page_size.as_ref() {
5506 params.push("pageSize", value.to_string());
5507 }
5508 if let Some(value) = self._order_by.as_ref() {
5509 params.push("orderBy", value);
5510 }
5511 if let Some(value) = self._filter.as_ref() {
5512 params.push("filter", value);
5513 }
5514
5515 params.extend(self._additional_params.iter());
5516
5517 params.push("alt", "json");
5518 let mut url = self.hub._base_url.clone() + "v1/{+parent}/instances";
5519 if self._scopes.is_empty() {
5520 self._scopes
5521 .insert(Scope::CloudPlatform.as_ref().to_string());
5522 }
5523
5524 #[allow(clippy::single_element_loop)]
5525 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5526 url = params.uri_replacement(url, param_name, find_this, true);
5527 }
5528 {
5529 let to_remove = ["parent"];
5530 params.remove_params(&to_remove);
5531 }
5532
5533 let url = params.parse_with_url(&url);
5534
5535 loop {
5536 let token = match self
5537 .hub
5538 .auth
5539 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5540 .await
5541 {
5542 Ok(token) => token,
5543 Err(e) => match dlg.token(e) {
5544 Ok(token) => token,
5545 Err(e) => {
5546 dlg.finished(false);
5547 return Err(common::Error::MissingToken(e));
5548 }
5549 },
5550 };
5551 let mut req_result = {
5552 let client = &self.hub.client;
5553 dlg.pre_request();
5554 let mut req_builder = hyper::Request::builder()
5555 .method(hyper::Method::GET)
5556 .uri(url.as_str())
5557 .header(USER_AGENT, self.hub._user_agent.clone());
5558
5559 if let Some(token) = token.as_ref() {
5560 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5561 }
5562
5563 let request = req_builder
5564 .header(CONTENT_LENGTH, 0_u64)
5565 .body(common::to_body::<String>(None));
5566
5567 client.request(request.unwrap()).await
5568 };
5569
5570 match req_result {
5571 Err(err) => {
5572 if let common::Retry::After(d) = dlg.http_error(&err) {
5573 sleep(d).await;
5574 continue;
5575 }
5576 dlg.finished(false);
5577 return Err(common::Error::HttpError(err));
5578 }
5579 Ok(res) => {
5580 let (mut parts, body) = res.into_parts();
5581 let mut body = common::Body::new(body);
5582 if !parts.status.is_success() {
5583 let bytes = common::to_bytes(body).await.unwrap_or_default();
5584 let error = serde_json::from_str(&common::to_string(&bytes));
5585 let response = common::to_response(parts, bytes.into());
5586
5587 if let common::Retry::After(d) =
5588 dlg.http_failure(&response, error.as_ref().ok())
5589 {
5590 sleep(d).await;
5591 continue;
5592 }
5593
5594 dlg.finished(false);
5595
5596 return Err(match error {
5597 Ok(value) => common::Error::BadRequest(value),
5598 _ => common::Error::Failure(response),
5599 });
5600 }
5601 let response = {
5602 let bytes = common::to_bytes(body).await.unwrap_or_default();
5603 let encoded = common::to_string(&bytes);
5604 match serde_json::from_str(&encoded) {
5605 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5606 Err(error) => {
5607 dlg.response_json_decode_error(&encoded, &error);
5608 return Err(common::Error::JsonDecodeError(
5609 encoded.to_string(),
5610 error,
5611 ));
5612 }
5613 }
5614 };
5615
5616 dlg.finished(true);
5617 return Ok(response);
5618 }
5619 }
5620 }
5621 }
5622
5623 /// 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.
5624 ///
5625 /// Sets the *parent* path property to the given value.
5626 ///
5627 /// Even though the property as already been set when instantiating this call,
5628 /// we provide this method for API completeness.
5629 pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
5630 self._parent = new_value.to_string();
5631 self
5632 }
5633 /// The next_page_token value to use if there are additional results to retrieve for this list request.
5634 ///
5635 /// Sets the *page token* query property to the given value.
5636 pub fn page_token(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
5637 self._page_token = Some(new_value.to_string());
5638 self
5639 }
5640 /// The maximum number of items to return.
5641 ///
5642 /// Sets the *page size* query property to the given value.
5643 pub fn page_size(mut self, new_value: i32) -> ProjectLocationInstanceListCall<'a, C> {
5644 self._page_size = Some(new_value);
5645 self
5646 }
5647 /// Sort results. Supported values are "name", "name desc" or "" (unsorted).
5648 ///
5649 /// Sets the *order by* query property to the given value.
5650 pub fn order_by(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
5651 self._order_by = Some(new_value.to_string());
5652 self
5653 }
5654 /// List filter.
5655 ///
5656 /// Sets the *filter* query property to the given value.
5657 pub fn filter(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
5658 self._filter = Some(new_value.to_string());
5659 self
5660 }
5661 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5662 /// while executing the actual API request.
5663 ///
5664 /// ````text
5665 /// It should be used to handle progress information, and to implement a certain level of resilience.
5666 /// ````
5667 ///
5668 /// Sets the *delegate* property to the given value.
5669 pub fn delegate(
5670 mut self,
5671 new_value: &'a mut dyn common::Delegate,
5672 ) -> ProjectLocationInstanceListCall<'a, C> {
5673 self._delegate = Some(new_value);
5674 self
5675 }
5676
5677 /// Set any additional parameter of the query string used in the request.
5678 /// It should be used to set parameters which are not yet available through their own
5679 /// setters.
5680 ///
5681 /// Please note that this method must not be used to set any of the known parameters
5682 /// which have their own setter method. If done anyway, the request will fail.
5683 ///
5684 /// # Additional Parameters
5685 ///
5686 /// * *$.xgafv* (query-string) - V1 error format.
5687 /// * *access_token* (query-string) - OAuth access token.
5688 /// * *alt* (query-string) - Data format for response.
5689 /// * *callback* (query-string) - JSONP
5690 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5691 /// * *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.
5692 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5693 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5694 /// * *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.
5695 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5696 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5697 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceListCall<'a, C>
5698 where
5699 T: AsRef<str>,
5700 {
5701 self._additional_params
5702 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5703 self
5704 }
5705
5706 /// Identifies the authorization scope for the method you are building.
5707 ///
5708 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5709 /// [`Scope::CloudPlatform`].
5710 ///
5711 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5712 /// tokens for more than one scope.
5713 ///
5714 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5715 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5716 /// sufficient, a read-write scope will do as well.
5717 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceListCall<'a, C>
5718 where
5719 St: AsRef<str>,
5720 {
5721 self._scopes.insert(String::from(scope.as_ref()));
5722 self
5723 }
5724 /// Identifies the authorization scope(s) for the method you are building.
5725 ///
5726 /// See [`Self::add_scope()`] for details.
5727 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceListCall<'a, C>
5728 where
5729 I: IntoIterator<Item = St>,
5730 St: AsRef<str>,
5731 {
5732 self._scopes
5733 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5734 self
5735 }
5736
5737 /// Removes all scopes, and no default scope will be used either.
5738 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5739 /// for details).
5740 pub fn clear_scopes(mut self) -> ProjectLocationInstanceListCall<'a, C> {
5741 self._scopes.clear();
5742 self
5743 }
5744}
5745
5746/// Updates the settings of a specific instance.
5747///
5748/// A builder for the *locations.instances.patch* method supported by a *project* resource.
5749/// It is not used directly, but through a [`ProjectMethods`] instance.
5750///
5751/// # Example
5752///
5753/// Instantiate a resource method builder
5754///
5755/// ```test_harness,no_run
5756/// # extern crate hyper;
5757/// # extern crate hyper_rustls;
5758/// # extern crate google_file1 as file1;
5759/// use file1::api::Instance;
5760/// # async fn dox() {
5761/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5762///
5763/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5764/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5765/// # secret,
5766/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5767/// # ).build().await.unwrap();
5768///
5769/// # let client = hyper_util::client::legacy::Client::builder(
5770/// # hyper_util::rt::TokioExecutor::new()
5771/// # )
5772/// # .build(
5773/// # hyper_rustls::HttpsConnectorBuilder::new()
5774/// # .with_native_roots()
5775/// # .unwrap()
5776/// # .https_or_http()
5777/// # .enable_http1()
5778/// # .build()
5779/// # );
5780/// # let mut hub = CloudFilestore::new(client, auth);
5781/// // As the method needs a request, you would usually fill it with the desired information
5782/// // into the respective structure. Some of the parts shown here might not be applicable !
5783/// // Values shown here are possibly random and not representative !
5784/// let mut req = Instance::default();
5785///
5786/// // You can configure optional parameters by calling the respective setters at will, and
5787/// // execute the final call using `doit()`.
5788/// // Values shown here are possibly random and not representative !
5789/// let result = hub.projects().locations_instances_patch(req, "name")
5790/// .update_mask(FieldMask::new::<&str>(&[]))
5791/// .doit().await;
5792/// # }
5793/// ```
5794pub struct ProjectLocationInstancePatchCall<'a, C>
5795where
5796 C: 'a,
5797{
5798 hub: &'a CloudFilestore<C>,
5799 _request: Instance,
5800 _name: String,
5801 _update_mask: Option<common::FieldMask>,
5802 _delegate: Option<&'a mut dyn common::Delegate>,
5803 _additional_params: HashMap<String, String>,
5804 _scopes: BTreeSet<String>,
5805}
5806
5807impl<'a, C> common::CallBuilder for ProjectLocationInstancePatchCall<'a, C> {}
5808
5809impl<'a, C> ProjectLocationInstancePatchCall<'a, C>
5810where
5811 C: common::Connector,
5812{
5813 /// Perform the operation you have build so far.
5814 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5815 use std::borrow::Cow;
5816 use std::io::{Read, Seek};
5817
5818 use common::{url::Params, ToParts};
5819 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5820
5821 let mut dd = common::DefaultDelegate;
5822 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5823 dlg.begin(common::MethodInfo {
5824 id: "file.projects.locations.instances.patch",
5825 http_method: hyper::Method::PATCH,
5826 });
5827
5828 for &field in ["alt", "name", "updateMask"].iter() {
5829 if self._additional_params.contains_key(field) {
5830 dlg.finished(false);
5831 return Err(common::Error::FieldClash(field));
5832 }
5833 }
5834
5835 let mut params = Params::with_capacity(5 + self._additional_params.len());
5836 params.push("name", self._name);
5837 if let Some(value) = self._update_mask.as_ref() {
5838 params.push("updateMask", value.to_string());
5839 }
5840
5841 params.extend(self._additional_params.iter());
5842
5843 params.push("alt", "json");
5844 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5845 if self._scopes.is_empty() {
5846 self._scopes
5847 .insert(Scope::CloudPlatform.as_ref().to_string());
5848 }
5849
5850 #[allow(clippy::single_element_loop)]
5851 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5852 url = params.uri_replacement(url, param_name, find_this, true);
5853 }
5854 {
5855 let to_remove = ["name"];
5856 params.remove_params(&to_remove);
5857 }
5858
5859 let url = params.parse_with_url(&url);
5860
5861 let mut json_mime_type = mime::APPLICATION_JSON;
5862 let mut request_value_reader = {
5863 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5864 common::remove_json_null_values(&mut value);
5865 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5866 serde_json::to_writer(&mut dst, &value).unwrap();
5867 dst
5868 };
5869 let request_size = request_value_reader
5870 .seek(std::io::SeekFrom::End(0))
5871 .unwrap();
5872 request_value_reader
5873 .seek(std::io::SeekFrom::Start(0))
5874 .unwrap();
5875
5876 loop {
5877 let token = match self
5878 .hub
5879 .auth
5880 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5881 .await
5882 {
5883 Ok(token) => token,
5884 Err(e) => match dlg.token(e) {
5885 Ok(token) => token,
5886 Err(e) => {
5887 dlg.finished(false);
5888 return Err(common::Error::MissingToken(e));
5889 }
5890 },
5891 };
5892 request_value_reader
5893 .seek(std::io::SeekFrom::Start(0))
5894 .unwrap();
5895 let mut req_result = {
5896 let client = &self.hub.client;
5897 dlg.pre_request();
5898 let mut req_builder = hyper::Request::builder()
5899 .method(hyper::Method::PATCH)
5900 .uri(url.as_str())
5901 .header(USER_AGENT, self.hub._user_agent.clone());
5902
5903 if let Some(token) = token.as_ref() {
5904 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5905 }
5906
5907 let request = req_builder
5908 .header(CONTENT_TYPE, json_mime_type.to_string())
5909 .header(CONTENT_LENGTH, request_size as u64)
5910 .body(common::to_body(
5911 request_value_reader.get_ref().clone().into(),
5912 ));
5913
5914 client.request(request.unwrap()).await
5915 };
5916
5917 match req_result {
5918 Err(err) => {
5919 if let common::Retry::After(d) = dlg.http_error(&err) {
5920 sleep(d).await;
5921 continue;
5922 }
5923 dlg.finished(false);
5924 return Err(common::Error::HttpError(err));
5925 }
5926 Ok(res) => {
5927 let (mut parts, body) = res.into_parts();
5928 let mut body = common::Body::new(body);
5929 if !parts.status.is_success() {
5930 let bytes = common::to_bytes(body).await.unwrap_or_default();
5931 let error = serde_json::from_str(&common::to_string(&bytes));
5932 let response = common::to_response(parts, bytes.into());
5933
5934 if let common::Retry::After(d) =
5935 dlg.http_failure(&response, error.as_ref().ok())
5936 {
5937 sleep(d).await;
5938 continue;
5939 }
5940
5941 dlg.finished(false);
5942
5943 return Err(match error {
5944 Ok(value) => common::Error::BadRequest(value),
5945 _ => common::Error::Failure(response),
5946 });
5947 }
5948 let response = {
5949 let bytes = common::to_bytes(body).await.unwrap_or_default();
5950 let encoded = common::to_string(&bytes);
5951 match serde_json::from_str(&encoded) {
5952 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5953 Err(error) => {
5954 dlg.response_json_decode_error(&encoded, &error);
5955 return Err(common::Error::JsonDecodeError(
5956 encoded.to_string(),
5957 error,
5958 ));
5959 }
5960 }
5961 };
5962
5963 dlg.finished(true);
5964 return Ok(response);
5965 }
5966 }
5967 }
5968 }
5969
5970 ///
5971 /// Sets the *request* property to the given value.
5972 ///
5973 /// Even though the property as already been set when instantiating this call,
5974 /// we provide this method for API completeness.
5975 pub fn request(mut self, new_value: Instance) -> ProjectLocationInstancePatchCall<'a, C> {
5976 self._request = new_value;
5977 self
5978 }
5979 /// Output only. The resource name of the instance, in the format `projects/{project}/locations/{location}/instances/{instance}`.
5980 ///
5981 /// Sets the *name* path property to the given value.
5982 ///
5983 /// Even though the property as already been set when instantiating this call,
5984 /// we provide this method for API completeness.
5985 pub fn name(mut self, new_value: &str) -> ProjectLocationInstancePatchCall<'a, C> {
5986 self._name = new_value.to_string();
5987 self
5988 }
5989 /// 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"
5990 ///
5991 /// Sets the *update mask* query property to the given value.
5992 pub fn update_mask(
5993 mut self,
5994 new_value: common::FieldMask,
5995 ) -> ProjectLocationInstancePatchCall<'a, C> {
5996 self._update_mask = Some(new_value);
5997 self
5998 }
5999 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6000 /// while executing the actual API request.
6001 ///
6002 /// ````text
6003 /// It should be used to handle progress information, and to implement a certain level of resilience.
6004 /// ````
6005 ///
6006 /// Sets the *delegate* property to the given value.
6007 pub fn delegate(
6008 mut self,
6009 new_value: &'a mut dyn common::Delegate,
6010 ) -> ProjectLocationInstancePatchCall<'a, C> {
6011 self._delegate = Some(new_value);
6012 self
6013 }
6014
6015 /// Set any additional parameter of the query string used in the request.
6016 /// It should be used to set parameters which are not yet available through their own
6017 /// setters.
6018 ///
6019 /// Please note that this method must not be used to set any of the known parameters
6020 /// which have their own setter method. If done anyway, the request will fail.
6021 ///
6022 /// # Additional Parameters
6023 ///
6024 /// * *$.xgafv* (query-string) - V1 error format.
6025 /// * *access_token* (query-string) - OAuth access token.
6026 /// * *alt* (query-string) - Data format for response.
6027 /// * *callback* (query-string) - JSONP
6028 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6029 /// * *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.
6030 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6031 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6032 /// * *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.
6033 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6034 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6035 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstancePatchCall<'a, C>
6036 where
6037 T: AsRef<str>,
6038 {
6039 self._additional_params
6040 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6041 self
6042 }
6043
6044 /// Identifies the authorization scope for the method you are building.
6045 ///
6046 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6047 /// [`Scope::CloudPlatform`].
6048 ///
6049 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6050 /// tokens for more than one scope.
6051 ///
6052 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6053 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6054 /// sufficient, a read-write scope will do as well.
6055 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstancePatchCall<'a, C>
6056 where
6057 St: AsRef<str>,
6058 {
6059 self._scopes.insert(String::from(scope.as_ref()));
6060 self
6061 }
6062 /// Identifies the authorization scope(s) for the method you are building.
6063 ///
6064 /// See [`Self::add_scope()`] for details.
6065 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstancePatchCall<'a, C>
6066 where
6067 I: IntoIterator<Item = St>,
6068 St: AsRef<str>,
6069 {
6070 self._scopes
6071 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6072 self
6073 }
6074
6075 /// Removes all scopes, and no default scope will be used either.
6076 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6077 /// for details).
6078 pub fn clear_scopes(mut self) -> ProjectLocationInstancePatchCall<'a, C> {
6079 self._scopes.clear();
6080 self
6081 }
6082}
6083
6084/// Promote an standby instance (replica).
6085///
6086/// A builder for the *locations.instances.promoteReplica* method supported by a *project* resource.
6087/// It is not used directly, but through a [`ProjectMethods`] instance.
6088///
6089/// # Example
6090///
6091/// Instantiate a resource method builder
6092///
6093/// ```test_harness,no_run
6094/// # extern crate hyper;
6095/// # extern crate hyper_rustls;
6096/// # extern crate google_file1 as file1;
6097/// use file1::api::PromoteReplicaRequest;
6098/// # async fn dox() {
6099/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6100///
6101/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6102/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6103/// # secret,
6104/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6105/// # ).build().await.unwrap();
6106///
6107/// # let client = hyper_util::client::legacy::Client::builder(
6108/// # hyper_util::rt::TokioExecutor::new()
6109/// # )
6110/// # .build(
6111/// # hyper_rustls::HttpsConnectorBuilder::new()
6112/// # .with_native_roots()
6113/// # .unwrap()
6114/// # .https_or_http()
6115/// # .enable_http1()
6116/// # .build()
6117/// # );
6118/// # let mut hub = CloudFilestore::new(client, auth);
6119/// // As the method needs a request, you would usually fill it with the desired information
6120/// // into the respective structure. Some of the parts shown here might not be applicable !
6121/// // Values shown here are possibly random and not representative !
6122/// let mut req = PromoteReplicaRequest::default();
6123///
6124/// // You can configure optional parameters by calling the respective setters at will, and
6125/// // execute the final call using `doit()`.
6126/// // Values shown here are possibly random and not representative !
6127/// let result = hub.projects().locations_instances_promote_replica(req, "name")
6128/// .doit().await;
6129/// # }
6130/// ```
6131pub struct ProjectLocationInstancePromoteReplicaCall<'a, C>
6132where
6133 C: 'a,
6134{
6135 hub: &'a CloudFilestore<C>,
6136 _request: PromoteReplicaRequest,
6137 _name: String,
6138 _delegate: Option<&'a mut dyn common::Delegate>,
6139 _additional_params: HashMap<String, String>,
6140 _scopes: BTreeSet<String>,
6141}
6142
6143impl<'a, C> common::CallBuilder for ProjectLocationInstancePromoteReplicaCall<'a, C> {}
6144
6145impl<'a, C> ProjectLocationInstancePromoteReplicaCall<'a, C>
6146where
6147 C: common::Connector,
6148{
6149 /// Perform the operation you have build so far.
6150 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6151 use std::borrow::Cow;
6152 use std::io::{Read, Seek};
6153
6154 use common::{url::Params, ToParts};
6155 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6156
6157 let mut dd = common::DefaultDelegate;
6158 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6159 dlg.begin(common::MethodInfo {
6160 id: "file.projects.locations.instances.promoteReplica",
6161 http_method: hyper::Method::POST,
6162 });
6163
6164 for &field in ["alt", "name"].iter() {
6165 if self._additional_params.contains_key(field) {
6166 dlg.finished(false);
6167 return Err(common::Error::FieldClash(field));
6168 }
6169 }
6170
6171 let mut params = Params::with_capacity(4 + self._additional_params.len());
6172 params.push("name", self._name);
6173
6174 params.extend(self._additional_params.iter());
6175
6176 params.push("alt", "json");
6177 let mut url = self.hub._base_url.clone() + "v1/{+name}:promoteReplica";
6178 if self._scopes.is_empty() {
6179 self._scopes
6180 .insert(Scope::CloudPlatform.as_ref().to_string());
6181 }
6182
6183 #[allow(clippy::single_element_loop)]
6184 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6185 url = params.uri_replacement(url, param_name, find_this, true);
6186 }
6187 {
6188 let to_remove = ["name"];
6189 params.remove_params(&to_remove);
6190 }
6191
6192 let url = params.parse_with_url(&url);
6193
6194 let mut json_mime_type = mime::APPLICATION_JSON;
6195 let mut request_value_reader = {
6196 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6197 common::remove_json_null_values(&mut value);
6198 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6199 serde_json::to_writer(&mut dst, &value).unwrap();
6200 dst
6201 };
6202 let request_size = request_value_reader
6203 .seek(std::io::SeekFrom::End(0))
6204 .unwrap();
6205 request_value_reader
6206 .seek(std::io::SeekFrom::Start(0))
6207 .unwrap();
6208
6209 loop {
6210 let token = match self
6211 .hub
6212 .auth
6213 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6214 .await
6215 {
6216 Ok(token) => token,
6217 Err(e) => match dlg.token(e) {
6218 Ok(token) => token,
6219 Err(e) => {
6220 dlg.finished(false);
6221 return Err(common::Error::MissingToken(e));
6222 }
6223 },
6224 };
6225 request_value_reader
6226 .seek(std::io::SeekFrom::Start(0))
6227 .unwrap();
6228 let mut req_result = {
6229 let client = &self.hub.client;
6230 dlg.pre_request();
6231 let mut req_builder = hyper::Request::builder()
6232 .method(hyper::Method::POST)
6233 .uri(url.as_str())
6234 .header(USER_AGENT, self.hub._user_agent.clone());
6235
6236 if let Some(token) = token.as_ref() {
6237 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6238 }
6239
6240 let request = req_builder
6241 .header(CONTENT_TYPE, json_mime_type.to_string())
6242 .header(CONTENT_LENGTH, request_size as u64)
6243 .body(common::to_body(
6244 request_value_reader.get_ref().clone().into(),
6245 ));
6246
6247 client.request(request.unwrap()).await
6248 };
6249
6250 match req_result {
6251 Err(err) => {
6252 if let common::Retry::After(d) = dlg.http_error(&err) {
6253 sleep(d).await;
6254 continue;
6255 }
6256 dlg.finished(false);
6257 return Err(common::Error::HttpError(err));
6258 }
6259 Ok(res) => {
6260 let (mut parts, body) = res.into_parts();
6261 let mut body = common::Body::new(body);
6262 if !parts.status.is_success() {
6263 let bytes = common::to_bytes(body).await.unwrap_or_default();
6264 let error = serde_json::from_str(&common::to_string(&bytes));
6265 let response = common::to_response(parts, bytes.into());
6266
6267 if let common::Retry::After(d) =
6268 dlg.http_failure(&response, error.as_ref().ok())
6269 {
6270 sleep(d).await;
6271 continue;
6272 }
6273
6274 dlg.finished(false);
6275
6276 return Err(match error {
6277 Ok(value) => common::Error::BadRequest(value),
6278 _ => common::Error::Failure(response),
6279 });
6280 }
6281 let response = {
6282 let bytes = common::to_bytes(body).await.unwrap_or_default();
6283 let encoded = common::to_string(&bytes);
6284 match serde_json::from_str(&encoded) {
6285 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6286 Err(error) => {
6287 dlg.response_json_decode_error(&encoded, &error);
6288 return Err(common::Error::JsonDecodeError(
6289 encoded.to_string(),
6290 error,
6291 ));
6292 }
6293 }
6294 };
6295
6296 dlg.finished(true);
6297 return Ok(response);
6298 }
6299 }
6300 }
6301 }
6302
6303 ///
6304 /// Sets the *request* property to the given value.
6305 ///
6306 /// Even though the property as already been set when instantiating this call,
6307 /// we provide this method for API completeness.
6308 pub fn request(
6309 mut self,
6310 new_value: PromoteReplicaRequest,
6311 ) -> ProjectLocationInstancePromoteReplicaCall<'a, C> {
6312 self._request = new_value;
6313 self
6314 }
6315 /// Required. The resource name of the instance, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}`.
6316 ///
6317 /// Sets the *name* path property to the given value.
6318 ///
6319 /// Even though the property as already been set when instantiating this call,
6320 /// we provide this method for API completeness.
6321 pub fn name(mut self, new_value: &str) -> ProjectLocationInstancePromoteReplicaCall<'a, C> {
6322 self._name = new_value.to_string();
6323 self
6324 }
6325 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6326 /// while executing the actual API request.
6327 ///
6328 /// ````text
6329 /// It should be used to handle progress information, and to implement a certain level of resilience.
6330 /// ````
6331 ///
6332 /// Sets the *delegate* property to the given value.
6333 pub fn delegate(
6334 mut self,
6335 new_value: &'a mut dyn common::Delegate,
6336 ) -> ProjectLocationInstancePromoteReplicaCall<'a, C> {
6337 self._delegate = Some(new_value);
6338 self
6339 }
6340
6341 /// Set any additional parameter of the query string used in the request.
6342 /// It should be used to set parameters which are not yet available through their own
6343 /// setters.
6344 ///
6345 /// Please note that this method must not be used to set any of the known parameters
6346 /// which have their own setter method. If done anyway, the request will fail.
6347 ///
6348 /// # Additional Parameters
6349 ///
6350 /// * *$.xgafv* (query-string) - V1 error format.
6351 /// * *access_token* (query-string) - OAuth access token.
6352 /// * *alt* (query-string) - Data format for response.
6353 /// * *callback* (query-string) - JSONP
6354 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6355 /// * *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.
6356 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6357 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6358 /// * *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.
6359 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6360 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6361 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstancePromoteReplicaCall<'a, C>
6362 where
6363 T: AsRef<str>,
6364 {
6365 self._additional_params
6366 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6367 self
6368 }
6369
6370 /// Identifies the authorization scope for the method you are building.
6371 ///
6372 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6373 /// [`Scope::CloudPlatform`].
6374 ///
6375 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6376 /// tokens for more than one scope.
6377 ///
6378 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6379 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6380 /// sufficient, a read-write scope will do as well.
6381 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstancePromoteReplicaCall<'a, C>
6382 where
6383 St: AsRef<str>,
6384 {
6385 self._scopes.insert(String::from(scope.as_ref()));
6386 self
6387 }
6388 /// Identifies the authorization scope(s) for the method you are building.
6389 ///
6390 /// See [`Self::add_scope()`] for details.
6391 pub fn add_scopes<I, St>(
6392 mut self,
6393 scopes: I,
6394 ) -> ProjectLocationInstancePromoteReplicaCall<'a, C>
6395 where
6396 I: IntoIterator<Item = St>,
6397 St: AsRef<str>,
6398 {
6399 self._scopes
6400 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6401 self
6402 }
6403
6404 /// Removes all scopes, and no default scope will be used either.
6405 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6406 /// for details).
6407 pub fn clear_scopes(mut self) -> ProjectLocationInstancePromoteReplicaCall<'a, C> {
6408 self._scopes.clear();
6409 self
6410 }
6411}
6412
6413/// 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).
6414///
6415/// A builder for the *locations.instances.restore* method supported by a *project* resource.
6416/// It is not used directly, but through a [`ProjectMethods`] instance.
6417///
6418/// # Example
6419///
6420/// Instantiate a resource method builder
6421///
6422/// ```test_harness,no_run
6423/// # extern crate hyper;
6424/// # extern crate hyper_rustls;
6425/// # extern crate google_file1 as file1;
6426/// use file1::api::RestoreInstanceRequest;
6427/// # async fn dox() {
6428/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6429///
6430/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6431/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6432/// # secret,
6433/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6434/// # ).build().await.unwrap();
6435///
6436/// # let client = hyper_util::client::legacy::Client::builder(
6437/// # hyper_util::rt::TokioExecutor::new()
6438/// # )
6439/// # .build(
6440/// # hyper_rustls::HttpsConnectorBuilder::new()
6441/// # .with_native_roots()
6442/// # .unwrap()
6443/// # .https_or_http()
6444/// # .enable_http1()
6445/// # .build()
6446/// # );
6447/// # let mut hub = CloudFilestore::new(client, auth);
6448/// // As the method needs a request, you would usually fill it with the desired information
6449/// // into the respective structure. Some of the parts shown here might not be applicable !
6450/// // Values shown here are possibly random and not representative !
6451/// let mut req = RestoreInstanceRequest::default();
6452///
6453/// // You can configure optional parameters by calling the respective setters at will, and
6454/// // execute the final call using `doit()`.
6455/// // Values shown here are possibly random and not representative !
6456/// let result = hub.projects().locations_instances_restore(req, "name")
6457/// .doit().await;
6458/// # }
6459/// ```
6460pub struct ProjectLocationInstanceRestoreCall<'a, C>
6461where
6462 C: 'a,
6463{
6464 hub: &'a CloudFilestore<C>,
6465 _request: RestoreInstanceRequest,
6466 _name: String,
6467 _delegate: Option<&'a mut dyn common::Delegate>,
6468 _additional_params: HashMap<String, String>,
6469 _scopes: BTreeSet<String>,
6470}
6471
6472impl<'a, C> common::CallBuilder for ProjectLocationInstanceRestoreCall<'a, C> {}
6473
6474impl<'a, C> ProjectLocationInstanceRestoreCall<'a, C>
6475where
6476 C: common::Connector,
6477{
6478 /// Perform the operation you have build so far.
6479 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6480 use std::borrow::Cow;
6481 use std::io::{Read, Seek};
6482
6483 use common::{url::Params, ToParts};
6484 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6485
6486 let mut dd = common::DefaultDelegate;
6487 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6488 dlg.begin(common::MethodInfo {
6489 id: "file.projects.locations.instances.restore",
6490 http_method: hyper::Method::POST,
6491 });
6492
6493 for &field in ["alt", "name"].iter() {
6494 if self._additional_params.contains_key(field) {
6495 dlg.finished(false);
6496 return Err(common::Error::FieldClash(field));
6497 }
6498 }
6499
6500 let mut params = Params::with_capacity(4 + self._additional_params.len());
6501 params.push("name", self._name);
6502
6503 params.extend(self._additional_params.iter());
6504
6505 params.push("alt", "json");
6506 let mut url = self.hub._base_url.clone() + "v1/{+name}:restore";
6507 if self._scopes.is_empty() {
6508 self._scopes
6509 .insert(Scope::CloudPlatform.as_ref().to_string());
6510 }
6511
6512 #[allow(clippy::single_element_loop)]
6513 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6514 url = params.uri_replacement(url, param_name, find_this, true);
6515 }
6516 {
6517 let to_remove = ["name"];
6518 params.remove_params(&to_remove);
6519 }
6520
6521 let url = params.parse_with_url(&url);
6522
6523 let mut json_mime_type = mime::APPLICATION_JSON;
6524 let mut request_value_reader = {
6525 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6526 common::remove_json_null_values(&mut value);
6527 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6528 serde_json::to_writer(&mut dst, &value).unwrap();
6529 dst
6530 };
6531 let request_size = request_value_reader
6532 .seek(std::io::SeekFrom::End(0))
6533 .unwrap();
6534 request_value_reader
6535 .seek(std::io::SeekFrom::Start(0))
6536 .unwrap();
6537
6538 loop {
6539 let token = match self
6540 .hub
6541 .auth
6542 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6543 .await
6544 {
6545 Ok(token) => token,
6546 Err(e) => match dlg.token(e) {
6547 Ok(token) => token,
6548 Err(e) => {
6549 dlg.finished(false);
6550 return Err(common::Error::MissingToken(e));
6551 }
6552 },
6553 };
6554 request_value_reader
6555 .seek(std::io::SeekFrom::Start(0))
6556 .unwrap();
6557 let mut req_result = {
6558 let client = &self.hub.client;
6559 dlg.pre_request();
6560 let mut req_builder = hyper::Request::builder()
6561 .method(hyper::Method::POST)
6562 .uri(url.as_str())
6563 .header(USER_AGENT, self.hub._user_agent.clone());
6564
6565 if let Some(token) = token.as_ref() {
6566 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6567 }
6568
6569 let request = req_builder
6570 .header(CONTENT_TYPE, json_mime_type.to_string())
6571 .header(CONTENT_LENGTH, request_size as u64)
6572 .body(common::to_body(
6573 request_value_reader.get_ref().clone().into(),
6574 ));
6575
6576 client.request(request.unwrap()).await
6577 };
6578
6579 match req_result {
6580 Err(err) => {
6581 if let common::Retry::After(d) = dlg.http_error(&err) {
6582 sleep(d).await;
6583 continue;
6584 }
6585 dlg.finished(false);
6586 return Err(common::Error::HttpError(err));
6587 }
6588 Ok(res) => {
6589 let (mut parts, body) = res.into_parts();
6590 let mut body = common::Body::new(body);
6591 if !parts.status.is_success() {
6592 let bytes = common::to_bytes(body).await.unwrap_or_default();
6593 let error = serde_json::from_str(&common::to_string(&bytes));
6594 let response = common::to_response(parts, bytes.into());
6595
6596 if let common::Retry::After(d) =
6597 dlg.http_failure(&response, error.as_ref().ok())
6598 {
6599 sleep(d).await;
6600 continue;
6601 }
6602
6603 dlg.finished(false);
6604
6605 return Err(match error {
6606 Ok(value) => common::Error::BadRequest(value),
6607 _ => common::Error::Failure(response),
6608 });
6609 }
6610 let response = {
6611 let bytes = common::to_bytes(body).await.unwrap_or_default();
6612 let encoded = common::to_string(&bytes);
6613 match serde_json::from_str(&encoded) {
6614 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6615 Err(error) => {
6616 dlg.response_json_decode_error(&encoded, &error);
6617 return Err(common::Error::JsonDecodeError(
6618 encoded.to_string(),
6619 error,
6620 ));
6621 }
6622 }
6623 };
6624
6625 dlg.finished(true);
6626 return Ok(response);
6627 }
6628 }
6629 }
6630 }
6631
6632 ///
6633 /// Sets the *request* property to the given value.
6634 ///
6635 /// Even though the property as already been set when instantiating this call,
6636 /// we provide this method for API completeness.
6637 pub fn request(
6638 mut self,
6639 new_value: RestoreInstanceRequest,
6640 ) -> ProjectLocationInstanceRestoreCall<'a, C> {
6641 self._request = new_value;
6642 self
6643 }
6644 /// Required. The resource name of the instance, in the format `projects/{project_number}/locations/{location_id}/instances/{instance_id}`.
6645 ///
6646 /// Sets the *name* path property to the given value.
6647 ///
6648 /// Even though the property as already been set when instantiating this call,
6649 /// we provide this method for API completeness.
6650 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceRestoreCall<'a, C> {
6651 self._name = new_value.to_string();
6652 self
6653 }
6654 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6655 /// while executing the actual API request.
6656 ///
6657 /// ````text
6658 /// It should be used to handle progress information, and to implement a certain level of resilience.
6659 /// ````
6660 ///
6661 /// Sets the *delegate* property to the given value.
6662 pub fn delegate(
6663 mut self,
6664 new_value: &'a mut dyn common::Delegate,
6665 ) -> ProjectLocationInstanceRestoreCall<'a, C> {
6666 self._delegate = Some(new_value);
6667 self
6668 }
6669
6670 /// Set any additional parameter of the query string used in the request.
6671 /// It should be used to set parameters which are not yet available through their own
6672 /// setters.
6673 ///
6674 /// Please note that this method must not be used to set any of the known parameters
6675 /// which have their own setter method. If done anyway, the request will fail.
6676 ///
6677 /// # Additional Parameters
6678 ///
6679 /// * *$.xgafv* (query-string) - V1 error format.
6680 /// * *access_token* (query-string) - OAuth access token.
6681 /// * *alt* (query-string) - Data format for response.
6682 /// * *callback* (query-string) - JSONP
6683 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6684 /// * *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.
6685 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6686 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6687 /// * *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.
6688 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6689 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6690 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceRestoreCall<'a, C>
6691 where
6692 T: AsRef<str>,
6693 {
6694 self._additional_params
6695 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6696 self
6697 }
6698
6699 /// Identifies the authorization scope for the method you are building.
6700 ///
6701 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6702 /// [`Scope::CloudPlatform`].
6703 ///
6704 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6705 /// tokens for more than one scope.
6706 ///
6707 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6708 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6709 /// sufficient, a read-write scope will do as well.
6710 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceRestoreCall<'a, C>
6711 where
6712 St: AsRef<str>,
6713 {
6714 self._scopes.insert(String::from(scope.as_ref()));
6715 self
6716 }
6717 /// Identifies the authorization scope(s) for the method you are building.
6718 ///
6719 /// See [`Self::add_scope()`] for details.
6720 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceRestoreCall<'a, C>
6721 where
6722 I: IntoIterator<Item = St>,
6723 St: AsRef<str>,
6724 {
6725 self._scopes
6726 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6727 self
6728 }
6729
6730 /// Removes all scopes, and no default scope will be used either.
6731 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6732 /// for details).
6733 pub fn clear_scopes(mut self) -> ProjectLocationInstanceRestoreCall<'a, C> {
6734 self._scopes.clear();
6735 self
6736 }
6737}
6738
6739/// Revert an existing instance's file system to a specified snapshot.
6740///
6741/// A builder for the *locations.instances.revert* method supported by a *project* resource.
6742/// It is not used directly, but through a [`ProjectMethods`] instance.
6743///
6744/// # Example
6745///
6746/// Instantiate a resource method builder
6747///
6748/// ```test_harness,no_run
6749/// # extern crate hyper;
6750/// # extern crate hyper_rustls;
6751/// # extern crate google_file1 as file1;
6752/// use file1::api::RevertInstanceRequest;
6753/// # async fn dox() {
6754/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6755///
6756/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6757/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6758/// # secret,
6759/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6760/// # ).build().await.unwrap();
6761///
6762/// # let client = hyper_util::client::legacy::Client::builder(
6763/// # hyper_util::rt::TokioExecutor::new()
6764/// # )
6765/// # .build(
6766/// # hyper_rustls::HttpsConnectorBuilder::new()
6767/// # .with_native_roots()
6768/// # .unwrap()
6769/// # .https_or_http()
6770/// # .enable_http1()
6771/// # .build()
6772/// # );
6773/// # let mut hub = CloudFilestore::new(client, auth);
6774/// // As the method needs a request, you would usually fill it with the desired information
6775/// // into the respective structure. Some of the parts shown here might not be applicable !
6776/// // Values shown here are possibly random and not representative !
6777/// let mut req = RevertInstanceRequest::default();
6778///
6779/// // You can configure optional parameters by calling the respective setters at will, and
6780/// // execute the final call using `doit()`.
6781/// // Values shown here are possibly random and not representative !
6782/// let result = hub.projects().locations_instances_revert(req, "name")
6783/// .doit().await;
6784/// # }
6785/// ```
6786pub struct ProjectLocationInstanceRevertCall<'a, C>
6787where
6788 C: 'a,
6789{
6790 hub: &'a CloudFilestore<C>,
6791 _request: RevertInstanceRequest,
6792 _name: String,
6793 _delegate: Option<&'a mut dyn common::Delegate>,
6794 _additional_params: HashMap<String, String>,
6795 _scopes: BTreeSet<String>,
6796}
6797
6798impl<'a, C> common::CallBuilder for ProjectLocationInstanceRevertCall<'a, C> {}
6799
6800impl<'a, C> ProjectLocationInstanceRevertCall<'a, C>
6801where
6802 C: common::Connector,
6803{
6804 /// Perform the operation you have build so far.
6805 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6806 use std::borrow::Cow;
6807 use std::io::{Read, Seek};
6808
6809 use common::{url::Params, ToParts};
6810 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6811
6812 let mut dd = common::DefaultDelegate;
6813 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6814 dlg.begin(common::MethodInfo {
6815 id: "file.projects.locations.instances.revert",
6816 http_method: hyper::Method::POST,
6817 });
6818
6819 for &field in ["alt", "name"].iter() {
6820 if self._additional_params.contains_key(field) {
6821 dlg.finished(false);
6822 return Err(common::Error::FieldClash(field));
6823 }
6824 }
6825
6826 let mut params = Params::with_capacity(4 + self._additional_params.len());
6827 params.push("name", self._name);
6828
6829 params.extend(self._additional_params.iter());
6830
6831 params.push("alt", "json");
6832 let mut url = self.hub._base_url.clone() + "v1/{+name}:revert";
6833 if self._scopes.is_empty() {
6834 self._scopes
6835 .insert(Scope::CloudPlatform.as_ref().to_string());
6836 }
6837
6838 #[allow(clippy::single_element_loop)]
6839 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6840 url = params.uri_replacement(url, param_name, find_this, true);
6841 }
6842 {
6843 let to_remove = ["name"];
6844 params.remove_params(&to_remove);
6845 }
6846
6847 let url = params.parse_with_url(&url);
6848
6849 let mut json_mime_type = mime::APPLICATION_JSON;
6850 let mut request_value_reader = {
6851 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6852 common::remove_json_null_values(&mut value);
6853 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6854 serde_json::to_writer(&mut dst, &value).unwrap();
6855 dst
6856 };
6857 let request_size = request_value_reader
6858 .seek(std::io::SeekFrom::End(0))
6859 .unwrap();
6860 request_value_reader
6861 .seek(std::io::SeekFrom::Start(0))
6862 .unwrap();
6863
6864 loop {
6865 let token = match self
6866 .hub
6867 .auth
6868 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6869 .await
6870 {
6871 Ok(token) => token,
6872 Err(e) => match dlg.token(e) {
6873 Ok(token) => token,
6874 Err(e) => {
6875 dlg.finished(false);
6876 return Err(common::Error::MissingToken(e));
6877 }
6878 },
6879 };
6880 request_value_reader
6881 .seek(std::io::SeekFrom::Start(0))
6882 .unwrap();
6883 let mut req_result = {
6884 let client = &self.hub.client;
6885 dlg.pre_request();
6886 let mut req_builder = hyper::Request::builder()
6887 .method(hyper::Method::POST)
6888 .uri(url.as_str())
6889 .header(USER_AGENT, self.hub._user_agent.clone());
6890
6891 if let Some(token) = token.as_ref() {
6892 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6893 }
6894
6895 let request = req_builder
6896 .header(CONTENT_TYPE, json_mime_type.to_string())
6897 .header(CONTENT_LENGTH, request_size as u64)
6898 .body(common::to_body(
6899 request_value_reader.get_ref().clone().into(),
6900 ));
6901
6902 client.request(request.unwrap()).await
6903 };
6904
6905 match req_result {
6906 Err(err) => {
6907 if let common::Retry::After(d) = dlg.http_error(&err) {
6908 sleep(d).await;
6909 continue;
6910 }
6911 dlg.finished(false);
6912 return Err(common::Error::HttpError(err));
6913 }
6914 Ok(res) => {
6915 let (mut parts, body) = res.into_parts();
6916 let mut body = common::Body::new(body);
6917 if !parts.status.is_success() {
6918 let bytes = common::to_bytes(body).await.unwrap_or_default();
6919 let error = serde_json::from_str(&common::to_string(&bytes));
6920 let response = common::to_response(parts, bytes.into());
6921
6922 if let common::Retry::After(d) =
6923 dlg.http_failure(&response, error.as_ref().ok())
6924 {
6925 sleep(d).await;
6926 continue;
6927 }
6928
6929 dlg.finished(false);
6930
6931 return Err(match error {
6932 Ok(value) => common::Error::BadRequest(value),
6933 _ => common::Error::Failure(response),
6934 });
6935 }
6936 let response = {
6937 let bytes = common::to_bytes(body).await.unwrap_or_default();
6938 let encoded = common::to_string(&bytes);
6939 match serde_json::from_str(&encoded) {
6940 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6941 Err(error) => {
6942 dlg.response_json_decode_error(&encoded, &error);
6943 return Err(common::Error::JsonDecodeError(
6944 encoded.to_string(),
6945 error,
6946 ));
6947 }
6948 }
6949 };
6950
6951 dlg.finished(true);
6952 return Ok(response);
6953 }
6954 }
6955 }
6956 }
6957
6958 ///
6959 /// Sets the *request* property to the given value.
6960 ///
6961 /// Even though the property as already been set when instantiating this call,
6962 /// we provide this method for API completeness.
6963 pub fn request(
6964 mut self,
6965 new_value: RevertInstanceRequest,
6966 ) -> ProjectLocationInstanceRevertCall<'a, C> {
6967 self._request = new_value;
6968 self
6969 }
6970 /// Required. The resource name of the instance, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}`.
6971 ///
6972 /// Sets the *name* path property to the given value.
6973 ///
6974 /// Even though the property as already been set when instantiating this call,
6975 /// we provide this method for API completeness.
6976 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceRevertCall<'a, C> {
6977 self._name = new_value.to_string();
6978 self
6979 }
6980 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6981 /// while executing the actual API request.
6982 ///
6983 /// ````text
6984 /// It should be used to handle progress information, and to implement a certain level of resilience.
6985 /// ````
6986 ///
6987 /// Sets the *delegate* property to the given value.
6988 pub fn delegate(
6989 mut self,
6990 new_value: &'a mut dyn common::Delegate,
6991 ) -> ProjectLocationInstanceRevertCall<'a, C> {
6992 self._delegate = Some(new_value);
6993 self
6994 }
6995
6996 /// Set any additional parameter of the query string used in the request.
6997 /// It should be used to set parameters which are not yet available through their own
6998 /// setters.
6999 ///
7000 /// Please note that this method must not be used to set any of the known parameters
7001 /// which have their own setter method. If done anyway, the request will fail.
7002 ///
7003 /// # Additional Parameters
7004 ///
7005 /// * *$.xgafv* (query-string) - V1 error format.
7006 /// * *access_token* (query-string) - OAuth access token.
7007 /// * *alt* (query-string) - Data format for response.
7008 /// * *callback* (query-string) - JSONP
7009 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7010 /// * *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.
7011 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7012 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7013 /// * *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.
7014 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7015 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7016 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceRevertCall<'a, C>
7017 where
7018 T: AsRef<str>,
7019 {
7020 self._additional_params
7021 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7022 self
7023 }
7024
7025 /// Identifies the authorization scope for the method you are building.
7026 ///
7027 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7028 /// [`Scope::CloudPlatform`].
7029 ///
7030 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7031 /// tokens for more than one scope.
7032 ///
7033 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7034 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7035 /// sufficient, a read-write scope will do as well.
7036 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceRevertCall<'a, C>
7037 where
7038 St: AsRef<str>,
7039 {
7040 self._scopes.insert(String::from(scope.as_ref()));
7041 self
7042 }
7043 /// Identifies the authorization scope(s) for the method you are building.
7044 ///
7045 /// See [`Self::add_scope()`] for details.
7046 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceRevertCall<'a, C>
7047 where
7048 I: IntoIterator<Item = St>,
7049 St: AsRef<str>,
7050 {
7051 self._scopes
7052 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7053 self
7054 }
7055
7056 /// Removes all scopes, and no default scope will be used either.
7057 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7058 /// for details).
7059 pub fn clear_scopes(mut self) -> ProjectLocationInstanceRevertCall<'a, C> {
7060 self._scopes.clear();
7061 self
7062 }
7063}
7064
7065/// 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`.
7066///
7067/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
7068/// It is not used directly, but through a [`ProjectMethods`] instance.
7069///
7070/// # Example
7071///
7072/// Instantiate a resource method builder
7073///
7074/// ```test_harness,no_run
7075/// # extern crate hyper;
7076/// # extern crate hyper_rustls;
7077/// # extern crate google_file1 as file1;
7078/// use file1::api::CancelOperationRequest;
7079/// # async fn dox() {
7080/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7081///
7082/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7083/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7084/// # secret,
7085/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7086/// # ).build().await.unwrap();
7087///
7088/// # let client = hyper_util::client::legacy::Client::builder(
7089/// # hyper_util::rt::TokioExecutor::new()
7090/// # )
7091/// # .build(
7092/// # hyper_rustls::HttpsConnectorBuilder::new()
7093/// # .with_native_roots()
7094/// # .unwrap()
7095/// # .https_or_http()
7096/// # .enable_http1()
7097/// # .build()
7098/// # );
7099/// # let mut hub = CloudFilestore::new(client, auth);
7100/// // As the method needs a request, you would usually fill it with the desired information
7101/// // into the respective structure. Some of the parts shown here might not be applicable !
7102/// // Values shown here are possibly random and not representative !
7103/// let mut req = CancelOperationRequest::default();
7104///
7105/// // You can configure optional parameters by calling the respective setters at will, and
7106/// // execute the final call using `doit()`.
7107/// // Values shown here are possibly random and not representative !
7108/// let result = hub.projects().locations_operations_cancel(req, "name")
7109/// .doit().await;
7110/// # }
7111/// ```
7112pub struct ProjectLocationOperationCancelCall<'a, C>
7113where
7114 C: 'a,
7115{
7116 hub: &'a CloudFilestore<C>,
7117 _request: CancelOperationRequest,
7118 _name: String,
7119 _delegate: Option<&'a mut dyn common::Delegate>,
7120 _additional_params: HashMap<String, String>,
7121 _scopes: BTreeSet<String>,
7122}
7123
7124impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
7125
7126impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
7127where
7128 C: common::Connector,
7129{
7130 /// Perform the operation you have build so far.
7131 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
7132 use std::borrow::Cow;
7133 use std::io::{Read, Seek};
7134
7135 use common::{url::Params, ToParts};
7136 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7137
7138 let mut dd = common::DefaultDelegate;
7139 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7140 dlg.begin(common::MethodInfo {
7141 id: "file.projects.locations.operations.cancel",
7142 http_method: hyper::Method::POST,
7143 });
7144
7145 for &field in ["alt", "name"].iter() {
7146 if self._additional_params.contains_key(field) {
7147 dlg.finished(false);
7148 return Err(common::Error::FieldClash(field));
7149 }
7150 }
7151
7152 let mut params = Params::with_capacity(4 + self._additional_params.len());
7153 params.push("name", self._name);
7154
7155 params.extend(self._additional_params.iter());
7156
7157 params.push("alt", "json");
7158 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
7159 if self._scopes.is_empty() {
7160 self._scopes
7161 .insert(Scope::CloudPlatform.as_ref().to_string());
7162 }
7163
7164 #[allow(clippy::single_element_loop)]
7165 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7166 url = params.uri_replacement(url, param_name, find_this, true);
7167 }
7168 {
7169 let to_remove = ["name"];
7170 params.remove_params(&to_remove);
7171 }
7172
7173 let url = params.parse_with_url(&url);
7174
7175 let mut json_mime_type = mime::APPLICATION_JSON;
7176 let mut request_value_reader = {
7177 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7178 common::remove_json_null_values(&mut value);
7179 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7180 serde_json::to_writer(&mut dst, &value).unwrap();
7181 dst
7182 };
7183 let request_size = request_value_reader
7184 .seek(std::io::SeekFrom::End(0))
7185 .unwrap();
7186 request_value_reader
7187 .seek(std::io::SeekFrom::Start(0))
7188 .unwrap();
7189
7190 loop {
7191 let token = match self
7192 .hub
7193 .auth
7194 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7195 .await
7196 {
7197 Ok(token) => token,
7198 Err(e) => match dlg.token(e) {
7199 Ok(token) => token,
7200 Err(e) => {
7201 dlg.finished(false);
7202 return Err(common::Error::MissingToken(e));
7203 }
7204 },
7205 };
7206 request_value_reader
7207 .seek(std::io::SeekFrom::Start(0))
7208 .unwrap();
7209 let mut req_result = {
7210 let client = &self.hub.client;
7211 dlg.pre_request();
7212 let mut req_builder = hyper::Request::builder()
7213 .method(hyper::Method::POST)
7214 .uri(url.as_str())
7215 .header(USER_AGENT, self.hub._user_agent.clone());
7216
7217 if let Some(token) = token.as_ref() {
7218 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7219 }
7220
7221 let request = req_builder
7222 .header(CONTENT_TYPE, json_mime_type.to_string())
7223 .header(CONTENT_LENGTH, request_size as u64)
7224 .body(common::to_body(
7225 request_value_reader.get_ref().clone().into(),
7226 ));
7227
7228 client.request(request.unwrap()).await
7229 };
7230
7231 match req_result {
7232 Err(err) => {
7233 if let common::Retry::After(d) = dlg.http_error(&err) {
7234 sleep(d).await;
7235 continue;
7236 }
7237 dlg.finished(false);
7238 return Err(common::Error::HttpError(err));
7239 }
7240 Ok(res) => {
7241 let (mut parts, body) = res.into_parts();
7242 let mut body = common::Body::new(body);
7243 if !parts.status.is_success() {
7244 let bytes = common::to_bytes(body).await.unwrap_or_default();
7245 let error = serde_json::from_str(&common::to_string(&bytes));
7246 let response = common::to_response(parts, bytes.into());
7247
7248 if let common::Retry::After(d) =
7249 dlg.http_failure(&response, error.as_ref().ok())
7250 {
7251 sleep(d).await;
7252 continue;
7253 }
7254
7255 dlg.finished(false);
7256
7257 return Err(match error {
7258 Ok(value) => common::Error::BadRequest(value),
7259 _ => common::Error::Failure(response),
7260 });
7261 }
7262 let response = {
7263 let bytes = common::to_bytes(body).await.unwrap_or_default();
7264 let encoded = common::to_string(&bytes);
7265 match serde_json::from_str(&encoded) {
7266 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7267 Err(error) => {
7268 dlg.response_json_decode_error(&encoded, &error);
7269 return Err(common::Error::JsonDecodeError(
7270 encoded.to_string(),
7271 error,
7272 ));
7273 }
7274 }
7275 };
7276
7277 dlg.finished(true);
7278 return Ok(response);
7279 }
7280 }
7281 }
7282 }
7283
7284 ///
7285 /// Sets the *request* property to the given value.
7286 ///
7287 /// Even though the property as already been set when instantiating this call,
7288 /// we provide this method for API completeness.
7289 pub fn request(
7290 mut self,
7291 new_value: CancelOperationRequest,
7292 ) -> ProjectLocationOperationCancelCall<'a, C> {
7293 self._request = new_value;
7294 self
7295 }
7296 /// The name of the operation resource to be cancelled.
7297 ///
7298 /// Sets the *name* path property to the given value.
7299 ///
7300 /// Even though the property as already been set when instantiating this call,
7301 /// we provide this method for API completeness.
7302 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
7303 self._name = new_value.to_string();
7304 self
7305 }
7306 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7307 /// while executing the actual API request.
7308 ///
7309 /// ````text
7310 /// It should be used to handle progress information, and to implement a certain level of resilience.
7311 /// ````
7312 ///
7313 /// Sets the *delegate* property to the given value.
7314 pub fn delegate(
7315 mut self,
7316 new_value: &'a mut dyn common::Delegate,
7317 ) -> ProjectLocationOperationCancelCall<'a, C> {
7318 self._delegate = Some(new_value);
7319 self
7320 }
7321
7322 /// Set any additional parameter of the query string used in the request.
7323 /// It should be used to set parameters which are not yet available through their own
7324 /// setters.
7325 ///
7326 /// Please note that this method must not be used to set any of the known parameters
7327 /// which have their own setter method. If done anyway, the request will fail.
7328 ///
7329 /// # Additional Parameters
7330 ///
7331 /// * *$.xgafv* (query-string) - V1 error format.
7332 /// * *access_token* (query-string) - OAuth access token.
7333 /// * *alt* (query-string) - Data format for response.
7334 /// * *callback* (query-string) - JSONP
7335 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7336 /// * *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.
7337 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7338 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7339 /// * *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.
7340 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7341 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7342 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
7343 where
7344 T: AsRef<str>,
7345 {
7346 self._additional_params
7347 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7348 self
7349 }
7350
7351 /// Identifies the authorization scope for the method you are building.
7352 ///
7353 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7354 /// [`Scope::CloudPlatform`].
7355 ///
7356 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7357 /// tokens for more than one scope.
7358 ///
7359 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7360 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7361 /// sufficient, a read-write scope will do as well.
7362 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
7363 where
7364 St: AsRef<str>,
7365 {
7366 self._scopes.insert(String::from(scope.as_ref()));
7367 self
7368 }
7369 /// Identifies the authorization scope(s) for the method you are building.
7370 ///
7371 /// See [`Self::add_scope()`] for details.
7372 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
7373 where
7374 I: IntoIterator<Item = St>,
7375 St: AsRef<str>,
7376 {
7377 self._scopes
7378 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7379 self
7380 }
7381
7382 /// Removes all scopes, and no default scope will be used either.
7383 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7384 /// for details).
7385 pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
7386 self._scopes.clear();
7387 self
7388 }
7389}
7390
7391/// 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`.
7392///
7393/// A builder for the *locations.operations.delete* method supported by a *project* resource.
7394/// It is not used directly, but through a [`ProjectMethods`] instance.
7395///
7396/// # Example
7397///
7398/// Instantiate a resource method builder
7399///
7400/// ```test_harness,no_run
7401/// # extern crate hyper;
7402/// # extern crate hyper_rustls;
7403/// # extern crate google_file1 as file1;
7404/// # async fn dox() {
7405/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7406///
7407/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7408/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7409/// # secret,
7410/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7411/// # ).build().await.unwrap();
7412///
7413/// # let client = hyper_util::client::legacy::Client::builder(
7414/// # hyper_util::rt::TokioExecutor::new()
7415/// # )
7416/// # .build(
7417/// # hyper_rustls::HttpsConnectorBuilder::new()
7418/// # .with_native_roots()
7419/// # .unwrap()
7420/// # .https_or_http()
7421/// # .enable_http1()
7422/// # .build()
7423/// # );
7424/// # let mut hub = CloudFilestore::new(client, auth);
7425/// // You can configure optional parameters by calling the respective setters at will, and
7426/// // execute the final call using `doit()`.
7427/// // Values shown here are possibly random and not representative !
7428/// let result = hub.projects().locations_operations_delete("name")
7429/// .doit().await;
7430/// # }
7431/// ```
7432pub struct ProjectLocationOperationDeleteCall<'a, C>
7433where
7434 C: 'a,
7435{
7436 hub: &'a CloudFilestore<C>,
7437 _name: String,
7438 _delegate: Option<&'a mut dyn common::Delegate>,
7439 _additional_params: HashMap<String, String>,
7440 _scopes: BTreeSet<String>,
7441}
7442
7443impl<'a, C> common::CallBuilder for ProjectLocationOperationDeleteCall<'a, C> {}
7444
7445impl<'a, C> ProjectLocationOperationDeleteCall<'a, C>
7446where
7447 C: common::Connector,
7448{
7449 /// Perform the operation you have build so far.
7450 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
7451 use std::borrow::Cow;
7452 use std::io::{Read, Seek};
7453
7454 use common::{url::Params, ToParts};
7455 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7456
7457 let mut dd = common::DefaultDelegate;
7458 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7459 dlg.begin(common::MethodInfo {
7460 id: "file.projects.locations.operations.delete",
7461 http_method: hyper::Method::DELETE,
7462 });
7463
7464 for &field in ["alt", "name"].iter() {
7465 if self._additional_params.contains_key(field) {
7466 dlg.finished(false);
7467 return Err(common::Error::FieldClash(field));
7468 }
7469 }
7470
7471 let mut params = Params::with_capacity(3 + self._additional_params.len());
7472 params.push("name", self._name);
7473
7474 params.extend(self._additional_params.iter());
7475
7476 params.push("alt", "json");
7477 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7478 if self._scopes.is_empty() {
7479 self._scopes
7480 .insert(Scope::CloudPlatform.as_ref().to_string());
7481 }
7482
7483 #[allow(clippy::single_element_loop)]
7484 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7485 url = params.uri_replacement(url, param_name, find_this, true);
7486 }
7487 {
7488 let to_remove = ["name"];
7489 params.remove_params(&to_remove);
7490 }
7491
7492 let url = params.parse_with_url(&url);
7493
7494 loop {
7495 let token = match self
7496 .hub
7497 .auth
7498 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7499 .await
7500 {
7501 Ok(token) => token,
7502 Err(e) => match dlg.token(e) {
7503 Ok(token) => token,
7504 Err(e) => {
7505 dlg.finished(false);
7506 return Err(common::Error::MissingToken(e));
7507 }
7508 },
7509 };
7510 let mut req_result = {
7511 let client = &self.hub.client;
7512 dlg.pre_request();
7513 let mut req_builder = hyper::Request::builder()
7514 .method(hyper::Method::DELETE)
7515 .uri(url.as_str())
7516 .header(USER_AGENT, self.hub._user_agent.clone());
7517
7518 if let Some(token) = token.as_ref() {
7519 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7520 }
7521
7522 let request = req_builder
7523 .header(CONTENT_LENGTH, 0_u64)
7524 .body(common::to_body::<String>(None));
7525
7526 client.request(request.unwrap()).await
7527 };
7528
7529 match req_result {
7530 Err(err) => {
7531 if let common::Retry::After(d) = dlg.http_error(&err) {
7532 sleep(d).await;
7533 continue;
7534 }
7535 dlg.finished(false);
7536 return Err(common::Error::HttpError(err));
7537 }
7538 Ok(res) => {
7539 let (mut parts, body) = res.into_parts();
7540 let mut body = common::Body::new(body);
7541 if !parts.status.is_success() {
7542 let bytes = common::to_bytes(body).await.unwrap_or_default();
7543 let error = serde_json::from_str(&common::to_string(&bytes));
7544 let response = common::to_response(parts, bytes.into());
7545
7546 if let common::Retry::After(d) =
7547 dlg.http_failure(&response, error.as_ref().ok())
7548 {
7549 sleep(d).await;
7550 continue;
7551 }
7552
7553 dlg.finished(false);
7554
7555 return Err(match error {
7556 Ok(value) => common::Error::BadRequest(value),
7557 _ => common::Error::Failure(response),
7558 });
7559 }
7560 let response = {
7561 let bytes = common::to_bytes(body).await.unwrap_or_default();
7562 let encoded = common::to_string(&bytes);
7563 match serde_json::from_str(&encoded) {
7564 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7565 Err(error) => {
7566 dlg.response_json_decode_error(&encoded, &error);
7567 return Err(common::Error::JsonDecodeError(
7568 encoded.to_string(),
7569 error,
7570 ));
7571 }
7572 }
7573 };
7574
7575 dlg.finished(true);
7576 return Ok(response);
7577 }
7578 }
7579 }
7580 }
7581
7582 /// The name of the operation resource to be deleted.
7583 ///
7584 /// Sets the *name* path property to the given value.
7585 ///
7586 /// Even though the property as already been set when instantiating this call,
7587 /// we provide this method for API completeness.
7588 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationDeleteCall<'a, C> {
7589 self._name = new_value.to_string();
7590 self
7591 }
7592 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7593 /// while executing the actual API request.
7594 ///
7595 /// ````text
7596 /// It should be used to handle progress information, and to implement a certain level of resilience.
7597 /// ````
7598 ///
7599 /// Sets the *delegate* property to the given value.
7600 pub fn delegate(
7601 mut self,
7602 new_value: &'a mut dyn common::Delegate,
7603 ) -> ProjectLocationOperationDeleteCall<'a, C> {
7604 self._delegate = Some(new_value);
7605 self
7606 }
7607
7608 /// Set any additional parameter of the query string used in the request.
7609 /// It should be used to set parameters which are not yet available through their own
7610 /// setters.
7611 ///
7612 /// Please note that this method must not be used to set any of the known parameters
7613 /// which have their own setter method. If done anyway, the request will fail.
7614 ///
7615 /// # Additional Parameters
7616 ///
7617 /// * *$.xgafv* (query-string) - V1 error format.
7618 /// * *access_token* (query-string) - OAuth access token.
7619 /// * *alt* (query-string) - Data format for response.
7620 /// * *callback* (query-string) - JSONP
7621 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7622 /// * *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.
7623 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7624 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7625 /// * *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.
7626 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7627 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7628 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationDeleteCall<'a, C>
7629 where
7630 T: AsRef<str>,
7631 {
7632 self._additional_params
7633 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7634 self
7635 }
7636
7637 /// Identifies the authorization scope for the method you are building.
7638 ///
7639 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7640 /// [`Scope::CloudPlatform`].
7641 ///
7642 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7643 /// tokens for more than one scope.
7644 ///
7645 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7646 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7647 /// sufficient, a read-write scope will do as well.
7648 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationDeleteCall<'a, C>
7649 where
7650 St: AsRef<str>,
7651 {
7652 self._scopes.insert(String::from(scope.as_ref()));
7653 self
7654 }
7655 /// Identifies the authorization scope(s) for the method you are building.
7656 ///
7657 /// See [`Self::add_scope()`] for details.
7658 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationDeleteCall<'a, C>
7659 where
7660 I: IntoIterator<Item = St>,
7661 St: AsRef<str>,
7662 {
7663 self._scopes
7664 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7665 self
7666 }
7667
7668 /// Removes all scopes, and no default scope will be used either.
7669 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7670 /// for details).
7671 pub fn clear_scopes(mut self) -> ProjectLocationOperationDeleteCall<'a, C> {
7672 self._scopes.clear();
7673 self
7674 }
7675}
7676
7677/// 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.
7678///
7679/// A builder for the *locations.operations.get* method supported by a *project* resource.
7680/// It is not used directly, but through a [`ProjectMethods`] instance.
7681///
7682/// # Example
7683///
7684/// Instantiate a resource method builder
7685///
7686/// ```test_harness,no_run
7687/// # extern crate hyper;
7688/// # extern crate hyper_rustls;
7689/// # extern crate google_file1 as file1;
7690/// # async fn dox() {
7691/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7692///
7693/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7694/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7695/// # secret,
7696/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7697/// # ).build().await.unwrap();
7698///
7699/// # let client = hyper_util::client::legacy::Client::builder(
7700/// # hyper_util::rt::TokioExecutor::new()
7701/// # )
7702/// # .build(
7703/// # hyper_rustls::HttpsConnectorBuilder::new()
7704/// # .with_native_roots()
7705/// # .unwrap()
7706/// # .https_or_http()
7707/// # .enable_http1()
7708/// # .build()
7709/// # );
7710/// # let mut hub = CloudFilestore::new(client, auth);
7711/// // You can configure optional parameters by calling the respective setters at will, and
7712/// // execute the final call using `doit()`.
7713/// // Values shown here are possibly random and not representative !
7714/// let result = hub.projects().locations_operations_get("name")
7715/// .doit().await;
7716/// # }
7717/// ```
7718pub struct ProjectLocationOperationGetCall<'a, C>
7719where
7720 C: 'a,
7721{
7722 hub: &'a CloudFilestore<C>,
7723 _name: String,
7724 _delegate: Option<&'a mut dyn common::Delegate>,
7725 _additional_params: HashMap<String, String>,
7726 _scopes: BTreeSet<String>,
7727}
7728
7729impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
7730
7731impl<'a, C> ProjectLocationOperationGetCall<'a, C>
7732where
7733 C: common::Connector,
7734{
7735 /// Perform the operation you have build so far.
7736 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7737 use std::borrow::Cow;
7738 use std::io::{Read, Seek};
7739
7740 use common::{url::Params, ToParts};
7741 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7742
7743 let mut dd = common::DefaultDelegate;
7744 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7745 dlg.begin(common::MethodInfo {
7746 id: "file.projects.locations.operations.get",
7747 http_method: hyper::Method::GET,
7748 });
7749
7750 for &field in ["alt", "name"].iter() {
7751 if self._additional_params.contains_key(field) {
7752 dlg.finished(false);
7753 return Err(common::Error::FieldClash(field));
7754 }
7755 }
7756
7757 let mut params = Params::with_capacity(3 + self._additional_params.len());
7758 params.push("name", self._name);
7759
7760 params.extend(self._additional_params.iter());
7761
7762 params.push("alt", "json");
7763 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7764 if self._scopes.is_empty() {
7765 self._scopes
7766 .insert(Scope::CloudPlatform.as_ref().to_string());
7767 }
7768
7769 #[allow(clippy::single_element_loop)]
7770 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7771 url = params.uri_replacement(url, param_name, find_this, true);
7772 }
7773 {
7774 let to_remove = ["name"];
7775 params.remove_params(&to_remove);
7776 }
7777
7778 let url = params.parse_with_url(&url);
7779
7780 loop {
7781 let token = match self
7782 .hub
7783 .auth
7784 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7785 .await
7786 {
7787 Ok(token) => token,
7788 Err(e) => match dlg.token(e) {
7789 Ok(token) => token,
7790 Err(e) => {
7791 dlg.finished(false);
7792 return Err(common::Error::MissingToken(e));
7793 }
7794 },
7795 };
7796 let mut req_result = {
7797 let client = &self.hub.client;
7798 dlg.pre_request();
7799 let mut req_builder = hyper::Request::builder()
7800 .method(hyper::Method::GET)
7801 .uri(url.as_str())
7802 .header(USER_AGENT, self.hub._user_agent.clone());
7803
7804 if let Some(token) = token.as_ref() {
7805 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7806 }
7807
7808 let request = req_builder
7809 .header(CONTENT_LENGTH, 0_u64)
7810 .body(common::to_body::<String>(None));
7811
7812 client.request(request.unwrap()).await
7813 };
7814
7815 match req_result {
7816 Err(err) => {
7817 if let common::Retry::After(d) = dlg.http_error(&err) {
7818 sleep(d).await;
7819 continue;
7820 }
7821 dlg.finished(false);
7822 return Err(common::Error::HttpError(err));
7823 }
7824 Ok(res) => {
7825 let (mut parts, body) = res.into_parts();
7826 let mut body = common::Body::new(body);
7827 if !parts.status.is_success() {
7828 let bytes = common::to_bytes(body).await.unwrap_or_default();
7829 let error = serde_json::from_str(&common::to_string(&bytes));
7830 let response = common::to_response(parts, bytes.into());
7831
7832 if let common::Retry::After(d) =
7833 dlg.http_failure(&response, error.as_ref().ok())
7834 {
7835 sleep(d).await;
7836 continue;
7837 }
7838
7839 dlg.finished(false);
7840
7841 return Err(match error {
7842 Ok(value) => common::Error::BadRequest(value),
7843 _ => common::Error::Failure(response),
7844 });
7845 }
7846 let response = {
7847 let bytes = common::to_bytes(body).await.unwrap_or_default();
7848 let encoded = common::to_string(&bytes);
7849 match serde_json::from_str(&encoded) {
7850 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7851 Err(error) => {
7852 dlg.response_json_decode_error(&encoded, &error);
7853 return Err(common::Error::JsonDecodeError(
7854 encoded.to_string(),
7855 error,
7856 ));
7857 }
7858 }
7859 };
7860
7861 dlg.finished(true);
7862 return Ok(response);
7863 }
7864 }
7865 }
7866 }
7867
7868 /// The name of the operation resource.
7869 ///
7870 /// Sets the *name* path property to the given value.
7871 ///
7872 /// Even though the property as already been set when instantiating this call,
7873 /// we provide this method for API completeness.
7874 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
7875 self._name = new_value.to_string();
7876 self
7877 }
7878 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7879 /// while executing the actual API request.
7880 ///
7881 /// ````text
7882 /// It should be used to handle progress information, and to implement a certain level of resilience.
7883 /// ````
7884 ///
7885 /// Sets the *delegate* property to the given value.
7886 pub fn delegate(
7887 mut self,
7888 new_value: &'a mut dyn common::Delegate,
7889 ) -> ProjectLocationOperationGetCall<'a, C> {
7890 self._delegate = Some(new_value);
7891 self
7892 }
7893
7894 /// Set any additional parameter of the query string used in the request.
7895 /// It should be used to set parameters which are not yet available through their own
7896 /// setters.
7897 ///
7898 /// Please note that this method must not be used to set any of the known parameters
7899 /// which have their own setter method. If done anyway, the request will fail.
7900 ///
7901 /// # Additional Parameters
7902 ///
7903 /// * *$.xgafv* (query-string) - V1 error format.
7904 /// * *access_token* (query-string) - OAuth access token.
7905 /// * *alt* (query-string) - Data format for response.
7906 /// * *callback* (query-string) - JSONP
7907 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7908 /// * *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.
7909 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7910 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7911 /// * *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.
7912 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7913 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7914 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
7915 where
7916 T: AsRef<str>,
7917 {
7918 self._additional_params
7919 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7920 self
7921 }
7922
7923 /// Identifies the authorization scope for the method you are building.
7924 ///
7925 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7926 /// [`Scope::CloudPlatform`].
7927 ///
7928 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7929 /// tokens for more than one scope.
7930 ///
7931 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7932 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7933 /// sufficient, a read-write scope will do as well.
7934 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
7935 where
7936 St: AsRef<str>,
7937 {
7938 self._scopes.insert(String::from(scope.as_ref()));
7939 self
7940 }
7941 /// Identifies the authorization scope(s) for the method you are building.
7942 ///
7943 /// See [`Self::add_scope()`] for details.
7944 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
7945 where
7946 I: IntoIterator<Item = St>,
7947 St: AsRef<str>,
7948 {
7949 self._scopes
7950 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7951 self
7952 }
7953
7954 /// Removes all scopes, and no default scope will be used either.
7955 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7956 /// for details).
7957 pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
7958 self._scopes.clear();
7959 self
7960 }
7961}
7962
7963/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
7964///
7965/// A builder for the *locations.operations.list* method supported by a *project* resource.
7966/// It is not used directly, but through a [`ProjectMethods`] instance.
7967///
7968/// # Example
7969///
7970/// Instantiate a resource method builder
7971///
7972/// ```test_harness,no_run
7973/// # extern crate hyper;
7974/// # extern crate hyper_rustls;
7975/// # extern crate google_file1 as file1;
7976/// # async fn dox() {
7977/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7978///
7979/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7980/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7981/// # secret,
7982/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7983/// # ).build().await.unwrap();
7984///
7985/// # let client = hyper_util::client::legacy::Client::builder(
7986/// # hyper_util::rt::TokioExecutor::new()
7987/// # )
7988/// # .build(
7989/// # hyper_rustls::HttpsConnectorBuilder::new()
7990/// # .with_native_roots()
7991/// # .unwrap()
7992/// # .https_or_http()
7993/// # .enable_http1()
7994/// # .build()
7995/// # );
7996/// # let mut hub = CloudFilestore::new(client, auth);
7997/// // You can configure optional parameters by calling the respective setters at will, and
7998/// // execute the final call using `doit()`.
7999/// // Values shown here are possibly random and not representative !
8000/// let result = hub.projects().locations_operations_list("name")
8001/// .page_token("et")
8002/// .page_size(-43)
8003/// .filter("et")
8004/// .doit().await;
8005/// # }
8006/// ```
8007pub struct ProjectLocationOperationListCall<'a, C>
8008where
8009 C: 'a,
8010{
8011 hub: &'a CloudFilestore<C>,
8012 _name: String,
8013 _page_token: Option<String>,
8014 _page_size: Option<i32>,
8015 _filter: Option<String>,
8016 _delegate: Option<&'a mut dyn common::Delegate>,
8017 _additional_params: HashMap<String, String>,
8018 _scopes: BTreeSet<String>,
8019}
8020
8021impl<'a, C> common::CallBuilder for ProjectLocationOperationListCall<'a, C> {}
8022
8023impl<'a, C> ProjectLocationOperationListCall<'a, C>
8024where
8025 C: common::Connector,
8026{
8027 /// Perform the operation you have build so far.
8028 pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
8029 use std::borrow::Cow;
8030 use std::io::{Read, Seek};
8031
8032 use common::{url::Params, ToParts};
8033 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8034
8035 let mut dd = common::DefaultDelegate;
8036 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8037 dlg.begin(common::MethodInfo {
8038 id: "file.projects.locations.operations.list",
8039 http_method: hyper::Method::GET,
8040 });
8041
8042 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
8043 if self._additional_params.contains_key(field) {
8044 dlg.finished(false);
8045 return Err(common::Error::FieldClash(field));
8046 }
8047 }
8048
8049 let mut params = Params::with_capacity(6 + self._additional_params.len());
8050 params.push("name", self._name);
8051 if let Some(value) = self._page_token.as_ref() {
8052 params.push("pageToken", value);
8053 }
8054 if let Some(value) = self._page_size.as_ref() {
8055 params.push("pageSize", value.to_string());
8056 }
8057 if let Some(value) = self._filter.as_ref() {
8058 params.push("filter", value);
8059 }
8060
8061 params.extend(self._additional_params.iter());
8062
8063 params.push("alt", "json");
8064 let mut url = self.hub._base_url.clone() + "v1/{+name}/operations";
8065 if self._scopes.is_empty() {
8066 self._scopes
8067 .insert(Scope::CloudPlatform.as_ref().to_string());
8068 }
8069
8070 #[allow(clippy::single_element_loop)]
8071 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8072 url = params.uri_replacement(url, param_name, find_this, true);
8073 }
8074 {
8075 let to_remove = ["name"];
8076 params.remove_params(&to_remove);
8077 }
8078
8079 let url = params.parse_with_url(&url);
8080
8081 loop {
8082 let token = match self
8083 .hub
8084 .auth
8085 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8086 .await
8087 {
8088 Ok(token) => token,
8089 Err(e) => match dlg.token(e) {
8090 Ok(token) => token,
8091 Err(e) => {
8092 dlg.finished(false);
8093 return Err(common::Error::MissingToken(e));
8094 }
8095 },
8096 };
8097 let mut req_result = {
8098 let client = &self.hub.client;
8099 dlg.pre_request();
8100 let mut req_builder = hyper::Request::builder()
8101 .method(hyper::Method::GET)
8102 .uri(url.as_str())
8103 .header(USER_AGENT, self.hub._user_agent.clone());
8104
8105 if let Some(token) = token.as_ref() {
8106 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8107 }
8108
8109 let request = req_builder
8110 .header(CONTENT_LENGTH, 0_u64)
8111 .body(common::to_body::<String>(None));
8112
8113 client.request(request.unwrap()).await
8114 };
8115
8116 match req_result {
8117 Err(err) => {
8118 if let common::Retry::After(d) = dlg.http_error(&err) {
8119 sleep(d).await;
8120 continue;
8121 }
8122 dlg.finished(false);
8123 return Err(common::Error::HttpError(err));
8124 }
8125 Ok(res) => {
8126 let (mut parts, body) = res.into_parts();
8127 let mut body = common::Body::new(body);
8128 if !parts.status.is_success() {
8129 let bytes = common::to_bytes(body).await.unwrap_or_default();
8130 let error = serde_json::from_str(&common::to_string(&bytes));
8131 let response = common::to_response(parts, bytes.into());
8132
8133 if let common::Retry::After(d) =
8134 dlg.http_failure(&response, error.as_ref().ok())
8135 {
8136 sleep(d).await;
8137 continue;
8138 }
8139
8140 dlg.finished(false);
8141
8142 return Err(match error {
8143 Ok(value) => common::Error::BadRequest(value),
8144 _ => common::Error::Failure(response),
8145 });
8146 }
8147 let response = {
8148 let bytes = common::to_bytes(body).await.unwrap_or_default();
8149 let encoded = common::to_string(&bytes);
8150 match serde_json::from_str(&encoded) {
8151 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8152 Err(error) => {
8153 dlg.response_json_decode_error(&encoded, &error);
8154 return Err(common::Error::JsonDecodeError(
8155 encoded.to_string(),
8156 error,
8157 ));
8158 }
8159 }
8160 };
8161
8162 dlg.finished(true);
8163 return Ok(response);
8164 }
8165 }
8166 }
8167 }
8168
8169 /// The name of the operation's parent resource.
8170 ///
8171 /// Sets the *name* path property to the given value.
8172 ///
8173 /// Even though the property as already been set when instantiating this call,
8174 /// we provide this method for API completeness.
8175 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
8176 self._name = new_value.to_string();
8177 self
8178 }
8179 /// The standard list page token.
8180 ///
8181 /// Sets the *page token* query property to the given value.
8182 pub fn page_token(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
8183 self._page_token = Some(new_value.to_string());
8184 self
8185 }
8186 /// The standard list page size.
8187 ///
8188 /// Sets the *page size* query property to the given value.
8189 pub fn page_size(mut self, new_value: i32) -> ProjectLocationOperationListCall<'a, C> {
8190 self._page_size = Some(new_value);
8191 self
8192 }
8193 /// The standard list filter.
8194 ///
8195 /// Sets the *filter* query property to the given value.
8196 pub fn filter(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
8197 self._filter = Some(new_value.to_string());
8198 self
8199 }
8200 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8201 /// while executing the actual API request.
8202 ///
8203 /// ````text
8204 /// It should be used to handle progress information, and to implement a certain level of resilience.
8205 /// ````
8206 ///
8207 /// Sets the *delegate* property to the given value.
8208 pub fn delegate(
8209 mut self,
8210 new_value: &'a mut dyn common::Delegate,
8211 ) -> ProjectLocationOperationListCall<'a, C> {
8212 self._delegate = Some(new_value);
8213 self
8214 }
8215
8216 /// Set any additional parameter of the query string used in the request.
8217 /// It should be used to set parameters which are not yet available through their own
8218 /// setters.
8219 ///
8220 /// Please note that this method must not be used to set any of the known parameters
8221 /// which have their own setter method. If done anyway, the request will fail.
8222 ///
8223 /// # Additional Parameters
8224 ///
8225 /// * *$.xgafv* (query-string) - V1 error format.
8226 /// * *access_token* (query-string) - OAuth access token.
8227 /// * *alt* (query-string) - Data format for response.
8228 /// * *callback* (query-string) - JSONP
8229 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8230 /// * *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.
8231 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8232 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8233 /// * *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.
8234 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8235 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8236 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationListCall<'a, C>
8237 where
8238 T: AsRef<str>,
8239 {
8240 self._additional_params
8241 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8242 self
8243 }
8244
8245 /// Identifies the authorization scope for the method you are building.
8246 ///
8247 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8248 /// [`Scope::CloudPlatform`].
8249 ///
8250 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8251 /// tokens for more than one scope.
8252 ///
8253 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8254 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8255 /// sufficient, a read-write scope will do as well.
8256 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationListCall<'a, C>
8257 where
8258 St: AsRef<str>,
8259 {
8260 self._scopes.insert(String::from(scope.as_ref()));
8261 self
8262 }
8263 /// Identifies the authorization scope(s) for the method you are building.
8264 ///
8265 /// See [`Self::add_scope()`] for details.
8266 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationListCall<'a, C>
8267 where
8268 I: IntoIterator<Item = St>,
8269 St: AsRef<str>,
8270 {
8271 self._scopes
8272 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8273 self
8274 }
8275
8276 /// Removes all scopes, and no default scope will be used either.
8277 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8278 /// for details).
8279 pub fn clear_scopes(mut self) -> ProjectLocationOperationListCall<'a, C> {
8280 self._scopes.clear();
8281 self
8282 }
8283}
8284
8285/// Gets information about a location.
8286///
8287/// A builder for the *locations.get* method supported by a *project* resource.
8288/// It is not used directly, but through a [`ProjectMethods`] instance.
8289///
8290/// # Example
8291///
8292/// Instantiate a resource method builder
8293///
8294/// ```test_harness,no_run
8295/// # extern crate hyper;
8296/// # extern crate hyper_rustls;
8297/// # extern crate google_file1 as file1;
8298/// # async fn dox() {
8299/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8300///
8301/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8302/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8303/// # secret,
8304/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8305/// # ).build().await.unwrap();
8306///
8307/// # let client = hyper_util::client::legacy::Client::builder(
8308/// # hyper_util::rt::TokioExecutor::new()
8309/// # )
8310/// # .build(
8311/// # hyper_rustls::HttpsConnectorBuilder::new()
8312/// # .with_native_roots()
8313/// # .unwrap()
8314/// # .https_or_http()
8315/// # .enable_http1()
8316/// # .build()
8317/// # );
8318/// # let mut hub = CloudFilestore::new(client, auth);
8319/// // You can configure optional parameters by calling the respective setters at will, and
8320/// // execute the final call using `doit()`.
8321/// // Values shown here are possibly random and not representative !
8322/// let result = hub.projects().locations_get("name")
8323/// .doit().await;
8324/// # }
8325/// ```
8326pub struct ProjectLocationGetCall<'a, C>
8327where
8328 C: 'a,
8329{
8330 hub: &'a CloudFilestore<C>,
8331 _name: String,
8332 _delegate: Option<&'a mut dyn common::Delegate>,
8333 _additional_params: HashMap<String, String>,
8334 _scopes: BTreeSet<String>,
8335}
8336
8337impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
8338
8339impl<'a, C> ProjectLocationGetCall<'a, C>
8340where
8341 C: common::Connector,
8342{
8343 /// Perform the operation you have build so far.
8344 pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
8345 use std::borrow::Cow;
8346 use std::io::{Read, Seek};
8347
8348 use common::{url::Params, ToParts};
8349 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8350
8351 let mut dd = common::DefaultDelegate;
8352 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8353 dlg.begin(common::MethodInfo {
8354 id: "file.projects.locations.get",
8355 http_method: hyper::Method::GET,
8356 });
8357
8358 for &field in ["alt", "name"].iter() {
8359 if self._additional_params.contains_key(field) {
8360 dlg.finished(false);
8361 return Err(common::Error::FieldClash(field));
8362 }
8363 }
8364
8365 let mut params = Params::with_capacity(3 + self._additional_params.len());
8366 params.push("name", self._name);
8367
8368 params.extend(self._additional_params.iter());
8369
8370 params.push("alt", "json");
8371 let mut url = self.hub._base_url.clone() + "v1/{+name}";
8372 if self._scopes.is_empty() {
8373 self._scopes
8374 .insert(Scope::CloudPlatform.as_ref().to_string());
8375 }
8376
8377 #[allow(clippy::single_element_loop)]
8378 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8379 url = params.uri_replacement(url, param_name, find_this, true);
8380 }
8381 {
8382 let to_remove = ["name"];
8383 params.remove_params(&to_remove);
8384 }
8385
8386 let url = params.parse_with_url(&url);
8387
8388 loop {
8389 let token = match self
8390 .hub
8391 .auth
8392 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8393 .await
8394 {
8395 Ok(token) => token,
8396 Err(e) => match dlg.token(e) {
8397 Ok(token) => token,
8398 Err(e) => {
8399 dlg.finished(false);
8400 return Err(common::Error::MissingToken(e));
8401 }
8402 },
8403 };
8404 let mut req_result = {
8405 let client = &self.hub.client;
8406 dlg.pre_request();
8407 let mut req_builder = hyper::Request::builder()
8408 .method(hyper::Method::GET)
8409 .uri(url.as_str())
8410 .header(USER_AGENT, self.hub._user_agent.clone());
8411
8412 if let Some(token) = token.as_ref() {
8413 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8414 }
8415
8416 let request = req_builder
8417 .header(CONTENT_LENGTH, 0_u64)
8418 .body(common::to_body::<String>(None));
8419
8420 client.request(request.unwrap()).await
8421 };
8422
8423 match req_result {
8424 Err(err) => {
8425 if let common::Retry::After(d) = dlg.http_error(&err) {
8426 sleep(d).await;
8427 continue;
8428 }
8429 dlg.finished(false);
8430 return Err(common::Error::HttpError(err));
8431 }
8432 Ok(res) => {
8433 let (mut parts, body) = res.into_parts();
8434 let mut body = common::Body::new(body);
8435 if !parts.status.is_success() {
8436 let bytes = common::to_bytes(body).await.unwrap_or_default();
8437 let error = serde_json::from_str(&common::to_string(&bytes));
8438 let response = common::to_response(parts, bytes.into());
8439
8440 if let common::Retry::After(d) =
8441 dlg.http_failure(&response, error.as_ref().ok())
8442 {
8443 sleep(d).await;
8444 continue;
8445 }
8446
8447 dlg.finished(false);
8448
8449 return Err(match error {
8450 Ok(value) => common::Error::BadRequest(value),
8451 _ => common::Error::Failure(response),
8452 });
8453 }
8454 let response = {
8455 let bytes = common::to_bytes(body).await.unwrap_or_default();
8456 let encoded = common::to_string(&bytes);
8457 match serde_json::from_str(&encoded) {
8458 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8459 Err(error) => {
8460 dlg.response_json_decode_error(&encoded, &error);
8461 return Err(common::Error::JsonDecodeError(
8462 encoded.to_string(),
8463 error,
8464 ));
8465 }
8466 }
8467 };
8468
8469 dlg.finished(true);
8470 return Ok(response);
8471 }
8472 }
8473 }
8474 }
8475
8476 /// Resource name for the location.
8477 ///
8478 /// Sets the *name* path property to the given value.
8479 ///
8480 /// Even though the property as already been set when instantiating this call,
8481 /// we provide this method for API completeness.
8482 pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
8483 self._name = new_value.to_string();
8484 self
8485 }
8486 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8487 /// while executing the actual API request.
8488 ///
8489 /// ````text
8490 /// It should be used to handle progress information, and to implement a certain level of resilience.
8491 /// ````
8492 ///
8493 /// Sets the *delegate* property to the given value.
8494 pub fn delegate(
8495 mut self,
8496 new_value: &'a mut dyn common::Delegate,
8497 ) -> ProjectLocationGetCall<'a, C> {
8498 self._delegate = Some(new_value);
8499 self
8500 }
8501
8502 /// Set any additional parameter of the query string used in the request.
8503 /// It should be used to set parameters which are not yet available through their own
8504 /// setters.
8505 ///
8506 /// Please note that this method must not be used to set any of the known parameters
8507 /// which have their own setter method. If done anyway, the request will fail.
8508 ///
8509 /// # Additional Parameters
8510 ///
8511 /// * *$.xgafv* (query-string) - V1 error format.
8512 /// * *access_token* (query-string) - OAuth access token.
8513 /// * *alt* (query-string) - Data format for response.
8514 /// * *callback* (query-string) - JSONP
8515 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8516 /// * *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.
8517 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8518 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8519 /// * *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.
8520 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8521 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8522 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
8523 where
8524 T: AsRef<str>,
8525 {
8526 self._additional_params
8527 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8528 self
8529 }
8530
8531 /// Identifies the authorization scope for the method you are building.
8532 ///
8533 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8534 /// [`Scope::CloudPlatform`].
8535 ///
8536 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8537 /// tokens for more than one scope.
8538 ///
8539 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8540 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8541 /// sufficient, a read-write scope will do as well.
8542 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
8543 where
8544 St: AsRef<str>,
8545 {
8546 self._scopes.insert(String::from(scope.as_ref()));
8547 self
8548 }
8549 /// Identifies the authorization scope(s) for the method you are building.
8550 ///
8551 /// See [`Self::add_scope()`] for details.
8552 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
8553 where
8554 I: IntoIterator<Item = St>,
8555 St: AsRef<str>,
8556 {
8557 self._scopes
8558 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8559 self
8560 }
8561
8562 /// Removes all scopes, and no default scope will be used either.
8563 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8564 /// for details).
8565 pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
8566 self._scopes.clear();
8567 self
8568 }
8569}
8570
8571/// Lists information about the supported locations for this service.
8572///
8573/// A builder for the *locations.list* method supported by a *project* resource.
8574/// It is not used directly, but through a [`ProjectMethods`] instance.
8575///
8576/// # Example
8577///
8578/// Instantiate a resource method builder
8579///
8580/// ```test_harness,no_run
8581/// # extern crate hyper;
8582/// # extern crate hyper_rustls;
8583/// # extern crate google_file1 as file1;
8584/// # async fn dox() {
8585/// # use file1::{CloudFilestore, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8586///
8587/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8588/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8589/// # secret,
8590/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8591/// # ).build().await.unwrap();
8592///
8593/// # let client = hyper_util::client::legacy::Client::builder(
8594/// # hyper_util::rt::TokioExecutor::new()
8595/// # )
8596/// # .build(
8597/// # hyper_rustls::HttpsConnectorBuilder::new()
8598/// # .with_native_roots()
8599/// # .unwrap()
8600/// # .https_or_http()
8601/// # .enable_http1()
8602/// # .build()
8603/// # );
8604/// # let mut hub = CloudFilestore::new(client, auth);
8605/// // You can configure optional parameters by calling the respective setters at will, and
8606/// // execute the final call using `doit()`.
8607/// // Values shown here are possibly random and not representative !
8608/// let result = hub.projects().locations_list("name")
8609/// .page_token("erat")
8610/// .page_size(-93)
8611/// .include_unrevealed_locations(false)
8612/// .filter("diam")
8613/// .doit().await;
8614/// # }
8615/// ```
8616pub struct ProjectLocationListCall<'a, C>
8617where
8618 C: 'a,
8619{
8620 hub: &'a CloudFilestore<C>,
8621 _name: String,
8622 _page_token: Option<String>,
8623 _page_size: Option<i32>,
8624 _include_unrevealed_locations: Option<bool>,
8625 _filter: Option<String>,
8626 _delegate: Option<&'a mut dyn common::Delegate>,
8627 _additional_params: HashMap<String, String>,
8628 _scopes: BTreeSet<String>,
8629}
8630
8631impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
8632
8633impl<'a, C> ProjectLocationListCall<'a, C>
8634where
8635 C: common::Connector,
8636{
8637 /// Perform the operation you have build so far.
8638 pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
8639 use std::borrow::Cow;
8640 use std::io::{Read, Seek};
8641
8642 use common::{url::Params, ToParts};
8643 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8644
8645 let mut dd = common::DefaultDelegate;
8646 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8647 dlg.begin(common::MethodInfo {
8648 id: "file.projects.locations.list",
8649 http_method: hyper::Method::GET,
8650 });
8651
8652 for &field in [
8653 "alt",
8654 "name",
8655 "pageToken",
8656 "pageSize",
8657 "includeUnrevealedLocations",
8658 "filter",
8659 ]
8660 .iter()
8661 {
8662 if self._additional_params.contains_key(field) {
8663 dlg.finished(false);
8664 return Err(common::Error::FieldClash(field));
8665 }
8666 }
8667
8668 let mut params = Params::with_capacity(7 + self._additional_params.len());
8669 params.push("name", self._name);
8670 if let Some(value) = self._page_token.as_ref() {
8671 params.push("pageToken", value);
8672 }
8673 if let Some(value) = self._page_size.as_ref() {
8674 params.push("pageSize", value.to_string());
8675 }
8676 if let Some(value) = self._include_unrevealed_locations.as_ref() {
8677 params.push("includeUnrevealedLocations", value.to_string());
8678 }
8679 if let Some(value) = self._filter.as_ref() {
8680 params.push("filter", value);
8681 }
8682
8683 params.extend(self._additional_params.iter());
8684
8685 params.push("alt", "json");
8686 let mut url = self.hub._base_url.clone() + "v1/{+name}/locations";
8687 if self._scopes.is_empty() {
8688 self._scopes
8689 .insert(Scope::CloudPlatform.as_ref().to_string());
8690 }
8691
8692 #[allow(clippy::single_element_loop)]
8693 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8694 url = params.uri_replacement(url, param_name, find_this, true);
8695 }
8696 {
8697 let to_remove = ["name"];
8698 params.remove_params(&to_remove);
8699 }
8700
8701 let url = params.parse_with_url(&url);
8702
8703 loop {
8704 let token = match self
8705 .hub
8706 .auth
8707 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8708 .await
8709 {
8710 Ok(token) => token,
8711 Err(e) => match dlg.token(e) {
8712 Ok(token) => token,
8713 Err(e) => {
8714 dlg.finished(false);
8715 return Err(common::Error::MissingToken(e));
8716 }
8717 },
8718 };
8719 let mut req_result = {
8720 let client = &self.hub.client;
8721 dlg.pre_request();
8722 let mut req_builder = hyper::Request::builder()
8723 .method(hyper::Method::GET)
8724 .uri(url.as_str())
8725 .header(USER_AGENT, self.hub._user_agent.clone());
8726
8727 if let Some(token) = token.as_ref() {
8728 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8729 }
8730
8731 let request = req_builder
8732 .header(CONTENT_LENGTH, 0_u64)
8733 .body(common::to_body::<String>(None));
8734
8735 client.request(request.unwrap()).await
8736 };
8737
8738 match req_result {
8739 Err(err) => {
8740 if let common::Retry::After(d) = dlg.http_error(&err) {
8741 sleep(d).await;
8742 continue;
8743 }
8744 dlg.finished(false);
8745 return Err(common::Error::HttpError(err));
8746 }
8747 Ok(res) => {
8748 let (mut parts, body) = res.into_parts();
8749 let mut body = common::Body::new(body);
8750 if !parts.status.is_success() {
8751 let bytes = common::to_bytes(body).await.unwrap_or_default();
8752 let error = serde_json::from_str(&common::to_string(&bytes));
8753 let response = common::to_response(parts, bytes.into());
8754
8755 if let common::Retry::After(d) =
8756 dlg.http_failure(&response, error.as_ref().ok())
8757 {
8758 sleep(d).await;
8759 continue;
8760 }
8761
8762 dlg.finished(false);
8763
8764 return Err(match error {
8765 Ok(value) => common::Error::BadRequest(value),
8766 _ => common::Error::Failure(response),
8767 });
8768 }
8769 let response = {
8770 let bytes = common::to_bytes(body).await.unwrap_or_default();
8771 let encoded = common::to_string(&bytes);
8772 match serde_json::from_str(&encoded) {
8773 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8774 Err(error) => {
8775 dlg.response_json_decode_error(&encoded, &error);
8776 return Err(common::Error::JsonDecodeError(
8777 encoded.to_string(),
8778 error,
8779 ));
8780 }
8781 }
8782 };
8783
8784 dlg.finished(true);
8785 return Ok(response);
8786 }
8787 }
8788 }
8789 }
8790
8791 /// The resource that owns the locations collection, if applicable.
8792 ///
8793 /// Sets the *name* path property to the given value.
8794 ///
8795 /// Even though the property as already been set when instantiating this call,
8796 /// we provide this method for API completeness.
8797 pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
8798 self._name = new_value.to_string();
8799 self
8800 }
8801 /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
8802 ///
8803 /// Sets the *page token* query property to the given value.
8804 pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
8805 self._page_token = Some(new_value.to_string());
8806 self
8807 }
8808 /// The maximum number of results to return. If not set, the service selects a default.
8809 ///
8810 /// Sets the *page size* query property to the given value.
8811 pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
8812 self._page_size = Some(new_value);
8813 self
8814 }
8815 /// If true, the returned list will include locations which are not yet revealed.
8816 ///
8817 /// Sets the *include unrevealed locations* query property to the given value.
8818 pub fn include_unrevealed_locations(
8819 mut self,
8820 new_value: bool,
8821 ) -> ProjectLocationListCall<'a, C> {
8822 self._include_unrevealed_locations = Some(new_value);
8823 self
8824 }
8825 /// 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).
8826 ///
8827 /// Sets the *filter* query property to the given value.
8828 pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
8829 self._filter = Some(new_value.to_string());
8830 self
8831 }
8832 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8833 /// while executing the actual API request.
8834 ///
8835 /// ````text
8836 /// It should be used to handle progress information, and to implement a certain level of resilience.
8837 /// ````
8838 ///
8839 /// Sets the *delegate* property to the given value.
8840 pub fn delegate(
8841 mut self,
8842 new_value: &'a mut dyn common::Delegate,
8843 ) -> ProjectLocationListCall<'a, C> {
8844 self._delegate = Some(new_value);
8845 self
8846 }
8847
8848 /// Set any additional parameter of the query string used in the request.
8849 /// It should be used to set parameters which are not yet available through their own
8850 /// setters.
8851 ///
8852 /// Please note that this method must not be used to set any of the known parameters
8853 /// which have their own setter method. If done anyway, the request will fail.
8854 ///
8855 /// # Additional Parameters
8856 ///
8857 /// * *$.xgafv* (query-string) - V1 error format.
8858 /// * *access_token* (query-string) - OAuth access token.
8859 /// * *alt* (query-string) - Data format for response.
8860 /// * *callback* (query-string) - JSONP
8861 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8862 /// * *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.
8863 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8864 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8865 /// * *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.
8866 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8867 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8868 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
8869 where
8870 T: AsRef<str>,
8871 {
8872 self._additional_params
8873 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8874 self
8875 }
8876
8877 /// Identifies the authorization scope for the method you are building.
8878 ///
8879 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8880 /// [`Scope::CloudPlatform`].
8881 ///
8882 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8883 /// tokens for more than one scope.
8884 ///
8885 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8886 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8887 /// sufficient, a read-write scope will do as well.
8888 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
8889 where
8890 St: AsRef<str>,
8891 {
8892 self._scopes.insert(String::from(scope.as_ref()));
8893 self
8894 }
8895 /// Identifies the authorization scope(s) for the method you are building.
8896 ///
8897 /// See [`Self::add_scope()`] for details.
8898 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
8899 where
8900 I: IntoIterator<Item = St>,
8901 St: AsRef<str>,
8902 {
8903 self._scopes
8904 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8905 self
8906 }
8907
8908 /// Removes all scopes, and no default scope will be used either.
8909 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8910 /// for details).
8911 pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
8912 self._scopes.clear();
8913 self
8914 }
8915}