google_baremetalsolution2/
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 Baremetalsolution 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_baremetalsolution2 as baremetalsolution2;
49/// use baremetalsolution2::api::Instance;
50/// use baremetalsolution2::{Result, Error};
51/// # async fn dox() {
52/// use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace  `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
63///     .with_native_roots()
64///     .unwrap()
65///     .https_only()
66///     .enable_http2()
67///     .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71///     secret,
72///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73///     yup_oauth2::client::CustomHyperClientBuilder::from(
74///         hyper_util::client::legacy::Client::builder(executor).build(connector),
75///     ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79///     hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82///     hyper_rustls::HttpsConnectorBuilder::new()
83///         .with_native_roots()
84///         .unwrap()
85///         .https_or_http()
86///         .enable_http2()
87///         .build()
88/// );
89/// let mut hub = Baremetalsolution::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = Instance::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.projects().locations_instances_patch(req, "name")
99///              .update_mask(FieldMask::new::<&str>(&[]))
100///              .doit().await;
101///
102/// match result {
103///     Err(e) => match e {
104///         // The Error enum provides details about what exactly happened.
105///         // You can also just use its `Debug`, `Display` or `Error` traits
106///          Error::HttpError(_)
107///         |Error::Io(_)
108///         |Error::MissingAPIKey
109///         |Error::MissingToken(_)
110///         |Error::Cancelled
111///         |Error::UploadSizeLimitExceeded(_, _)
112///         |Error::Failure(_)
113///         |Error::BadRequest(_)
114///         |Error::FieldClash(_)
115///         |Error::JsonDecodeError(_, _) => println!("{}", e),
116///     },
117///     Ok(res) => println!("Success: {:?}", res),
118/// }
119/// # }
120/// ```
121#[derive(Clone)]
122pub struct Baremetalsolution<C> {
123    pub client: common::Client<C>,
124    pub auth: Box<dyn common::GetToken>,
125    _user_agent: String,
126    _base_url: String,
127    _root_url: String,
128}
129
130impl<C> common::Hub for Baremetalsolution<C> {}
131
132impl<'a, C> Baremetalsolution<C> {
133    pub fn new<A: 'static + common::GetToken>(
134        client: common::Client<C>,
135        auth: A,
136    ) -> Baremetalsolution<C> {
137        Baremetalsolution {
138            client,
139            auth: Box::new(auth),
140            _user_agent: "google-api-rust-client/7.0.0".to_string(),
141            _base_url: "https://baremetalsolution.googleapis.com/".to_string(),
142            _root_url: "https://baremetalsolution.googleapis.com/".to_string(),
143        }
144    }
145
146    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
147        ProjectMethods { hub: self }
148    }
149
150    /// Set the user-agent header field to use in all requests to the server.
151    /// It defaults to `google-api-rust-client/7.0.0`.
152    ///
153    /// Returns the previously set user-agent.
154    pub fn user_agent(&mut self, agent_name: String) -> String {
155        std::mem::replace(&mut self._user_agent, agent_name)
156    }
157
158    /// Set the base url to use in all requests to the server.
159    /// It defaults to `https://baremetalsolution.googleapis.com/`.
160    ///
161    /// Returns the previously set base url.
162    pub fn base_url(&mut self, new_base_url: String) -> String {
163        std::mem::replace(&mut self._base_url, new_base_url)
164    }
165
166    /// Set the root url to use in all requests to the server.
167    /// It defaults to `https://baremetalsolution.googleapis.com/`.
168    ///
169    /// Returns the previously set root url.
170    pub fn root_url(&mut self, new_root_url: String) -> String {
171        std::mem::replace(&mut self._root_url, new_root_url)
172    }
173}
174
175// ############
176// SCHEMAS ###
177// ##########
178/// Represents an 'access point' for the share.
179///
180/// This type is not used in any activity, and only used as *part* of another schema.
181///
182#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
183#[serde_with::serde_as]
184#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
185pub struct AllowedClient {
186    /// Allow dev flag. Which controls whether to allow creation of devices.
187    #[serde(rename = "allowDev")]
188    pub allow_dev: Option<bool>,
189    /// Allow the setuid flag.
190    #[serde(rename = "allowSuid")]
191    pub allow_suid: Option<bool>,
192    /// The subnet of IP addresses permitted to access the share.
193    #[serde(rename = "allowedClientsCidr")]
194    pub allowed_clients_cidr: Option<String>,
195    /// Mount permissions.
196    #[serde(rename = "mountPermissions")]
197    pub mount_permissions: Option<String>,
198    /// The network the access point sits on.
199    pub network: Option<String>,
200    /// Output only. The path to access NFS, in format shareIP:/InstanceID InstanceID is the generated ID instead of customer provided name. example like "10.0.0.0:/g123456789-nfs001"
201    #[serde(rename = "nfsPath")]
202    pub nfs_path: Option<String>,
203    /// Disable root squashing, which is a feature of NFS. Root squash is a special mapping of the remote superuser (root) identity when using identity authentication.
204    #[serde(rename = "noRootSquash")]
205    pub no_root_squash: Option<bool>,
206    /// Output only. The IP address of the share on this network. Assigned automatically during provisioning based on the network's services_cidr.
207    #[serde(rename = "shareIp")]
208    pub share_ip: Option<String>,
209}
210
211impl common::Part for AllowedClient {}
212
213/// Message for detach specific LUN from an Instance.
214///
215/// # Activities
216///
217/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
218/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
219///
220/// * [locations instances detach lun projects](ProjectLocationInstanceDetachLunCall) (request)
221#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
222#[serde_with::serde_as]
223#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
224pub struct DetachLunRequest {
225    /// Required. Name of the Lun to detach.
226    pub lun: Option<String>,
227    /// If true, performs lun unmapping without instance reboot.
228    #[serde(rename = "skipReboot")]
229    pub skip_reboot: Option<bool>,
230}
231
232impl common::RequestValue for DetachLunRequest {}
233
234/// Message requesting to perform disable hyperthreading operation on a server.
235///
236/// # Activities
237///
238/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
239/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
240///
241/// * [locations instances disable hyperthreading projects](ProjectLocationInstanceDisableHyperthreadingCall) (request)
242#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
243#[serde_with::serde_as]
244#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
245pub struct DisableHyperthreadingRequest {
246    _never_set: Option<bool>,
247}
248
249impl common::RequestValue for DisableHyperthreadingRequest {}
250
251/// Message for disabling the interactive serial console on an instance.
252///
253/// # Activities
254///
255/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
256/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
257///
258/// * [locations instances disable interactive serial console projects](ProjectLocationInstanceDisableInteractiveSerialConsoleCall) (request)
259#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
260#[serde_with::serde_as]
261#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
262pub struct DisableInteractiveSerialConsoleRequest {
263    _never_set: Option<bool>,
264}
265
266impl common::RequestValue for DisableInteractiveSerialConsoleRequest {}
267
268/// 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); }
269///
270/// # Activities
271///
272/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
273/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
274///
275/// * [locations ssh keys delete projects](ProjectLocationSshKeyDeleteCall) (response)
276/// * [locations volumes snapshots delete projects](ProjectLocationVolumeSnapshotDeleteCall) (response)
277#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
278#[serde_with::serde_as]
279#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
280pub struct Empty {
281    _never_set: Option<bool>,
282}
283
284impl common::ResponseResult for Empty {}
285
286/// Message requesting to perform enable hyperthreading operation on a server.
287///
288/// # Activities
289///
290/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
291/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
292///
293/// * [locations instances enable hyperthreading projects](ProjectLocationInstanceEnableHyperthreadingCall) (request)
294#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
295#[serde_with::serde_as]
296#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
297pub struct EnableHyperthreadingRequest {
298    _never_set: Option<bool>,
299}
300
301impl common::RequestValue for EnableHyperthreadingRequest {}
302
303/// Message for enabling the interactive serial console on an instance.
304///
305/// # Activities
306///
307/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
308/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
309///
310/// * [locations instances enable interactive serial console projects](ProjectLocationInstanceEnableInteractiveSerialConsoleCall) (request)
311#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
312#[serde_with::serde_as]
313#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
314pub struct EnableInteractiveSerialConsoleRequest {
315    _never_set: Option<bool>,
316}
317
318impl common::RequestValue for EnableInteractiveSerialConsoleRequest {}
319
320/// Request for skip lun cooloff and delete it.
321///
322/// # Activities
323///
324/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
325/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
326///
327/// * [locations volumes luns evict projects](ProjectLocationVolumeLunEvictCall) (request)
328#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
329#[serde_with::serde_as]
330#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
331pub struct EvictLunRequest {
332    _never_set: Option<bool>,
333}
334
335impl common::RequestValue for EvictLunRequest {}
336
337/// Request for skip volume cooloff and delete it.
338///
339/// # Activities
340///
341/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
342/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
343///
344/// * [locations volumes evict projects](ProjectLocationVolumeEvictCall) (request)
345#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
346#[serde_with::serde_as]
347#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
348pub struct EvictVolumeRequest {
349    _never_set: Option<bool>,
350}
351
352impl common::RequestValue for EvictVolumeRequest {}
353
354/// Each logical interface represents a logical abstraction of the underlying physical interface (for eg. bond, nic) of the instance. Each logical interface can effectively map to multiple network-IP pairs and still be mapped to one underlying physical interface.
355///
356/// This type is not used in any activity, and only used as *part* of another schema.
357///
358#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
359#[serde_with::serde_as]
360#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
361pub struct GoogleCloudBaremetalsolutionV2LogicalInterface {
362    /// The index of the logical interface mapping to the index of the hardware bond or nic on the chosen network template. This field is deprecated.
363    #[serde(rename = "interfaceIndex")]
364    pub interface_index: Option<i32>,
365    /// List of logical network interfaces within a logical interface.
366    #[serde(rename = "logicalNetworkInterfaces")]
367    pub logical_network_interfaces: Option<Vec<LogicalNetworkInterface>>,
368    /// Interface name. This is of syntax or and forms part of the network template name.
369    pub name: Option<String>,
370}
371
372impl common::Part for GoogleCloudBaremetalsolutionV2LogicalInterface {}
373
374/// A server.
375///
376/// # Activities
377///
378/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
379/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
380///
381/// * [locations instances get projects](ProjectLocationInstanceGetCall) (response)
382/// * [locations instances patch projects](ProjectLocationInstancePatchCall) (request)
383/// * [locations instances rename projects](ProjectLocationInstanceRenameCall) (response)
384#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
385#[serde_with::serde_as]
386#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
387pub struct Instance {
388    /// Output only. Create a time stamp.
389    #[serde(rename = "createTime")]
390    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
391    /// Output only. The firmware version for the instance.
392    #[serde(rename = "firmwareVersion")]
393    pub firmware_version: Option<String>,
394    /// True if you enable hyperthreading for the server, otherwise false. The default value is false.
395    #[serde(rename = "hyperthreadingEnabled")]
396    pub hyperthreading_enabled: Option<bool>,
397    /// Output only. An identifier for the `Instance`, generated by the backend.
398    pub id: Option<String>,
399    /// Output only. True if the interactive serial console feature is enabled for the instance, false otherwise. The default value is false.
400    #[serde(rename = "interactiveSerialConsoleEnabled")]
401    pub interactive_serial_console_enabled: Option<bool>,
402    /// Optional. Name of the KMS crypto key version used to encrypt the initial passwords. The key has to have ASYMMETRIC_DECRYPT purpose. Format is `projects/{project}/locations/{location}/keyRings/{keyring}/cryptoKeys/{key}/cryptoKeyVersions/{version}`.
403    #[serde(rename = "kmsKeyVersion")]
404    pub kms_key_version: Option<String>,
405    /// Labels as key value pairs.
406    pub labels: Option<HashMap<String, String>>,
407    /// List of logical interfaces for the instance. The number of logical interfaces will be the same as number of hardware bond/nic on the chosen network template. For the non-multivlan configurations (for eg, existing servers) that use existing default network template (bondaa-bondaa), both the Instance.networks field and the Instance.logical_interfaces fields will be filled to ensure backward compatibility. For the others, only Instance.logical_interfaces will be filled.
408    #[serde(rename = "logicalInterfaces")]
409    pub logical_interfaces: Option<Vec<GoogleCloudBaremetalsolutionV2LogicalInterface>>,
410    /// Output only. Text field about info for logging in.
411    #[serde(rename = "loginInfo")]
412    pub login_info: Option<String>,
413    /// Immutable. List of LUNs associated with this server.
414    pub luns: Option<Vec<Lun>>,
415    /// Immutable. The server type. [Available server types](https://cloud.google.com/bare-metal/docs/bms-planning#server_configurations)
416    #[serde(rename = "machineType")]
417    pub machine_type: Option<String>,
418    /// Immutable. The resource name of this `Instance`. Resource names are schemeless URIs that follow the conventions in https://cloud.google.com/apis/design/resource_names. Format: `projects/{project}/locations/{location}/instances/{instance}`
419    pub name: Option<String>,
420    /// Instance network template name. For eg, bondaa-bondaa, bondab-nic, etc. Generally, the template name follows the syntax of "bond" or "nic".
421    #[serde(rename = "networkTemplate")]
422    pub network_template: Option<String>,
423    /// Output only. List of networks associated with this server.
424    pub networks: Option<Vec<Network>>,
425    /// The OS image currently installed on the server.
426    #[serde(rename = "osImage")]
427    pub os_image: Option<String>,
428    /// Immutable. Pod name. Pod is an independent part of infrastructure. Instance can only be connected to the assets (networks, volumes) allocated in the same pod.
429    pub pod: Option<String>,
430    /// Optional. List of SSH Keys used during instance provisioning.
431    #[serde(rename = "sshKeys")]
432    pub ssh_keys: Option<Vec<String>>,
433    /// Output only. The state of the server.
434    pub state: Option<String>,
435    /// Output only. Update a time stamp.
436    #[serde(rename = "updateTime")]
437    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
438    /// Input only. List of Volumes to attach to this Instance on creation. This field won't be populated in Get/List responses.
439    pub volumes: Option<Vec<Volume>>,
440    /// The workload profile for the instance.
441    #[serde(rename = "workloadProfile")]
442    pub workload_profile: Option<String>,
443}
444
445impl common::RequestValue for Instance {}
446impl common::ResponseResult for Instance {}
447
448/// Configuration parameters for a new instance.
449///
450/// This type is not used in any activity, and only used as *part* of another schema.
451///
452#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
453#[serde_with::serde_as]
454#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
455pub struct InstanceConfig {
456    /// If true networks can be from different projects of the same vendor account.
457    #[serde(rename = "accountNetworksEnabled")]
458    pub account_networks_enabled: Option<bool>,
459    /// Client network address. Filled if InstanceConfig.multivlan_config is false.
460    #[serde(rename = "clientNetwork")]
461    pub client_network: Option<NetworkAddress>,
462    /// Whether the instance should be provisioned with Hyperthreading enabled.
463    pub hyperthreading: Option<bool>,
464    /// A transient unique identifier to identify an instance within an ProvisioningConfig request.
465    pub id: Option<String>,
466    /// Instance type. [Available types](https://cloud.google.com/bare-metal/docs/bms-planning#server_configurations)
467    #[serde(rename = "instanceType")]
468    pub instance_type: Option<String>,
469    /// Name of the KMS crypto key version used to encrypt the initial passwords. The key has to have ASYMMETRIC_DECRYPT purpose.
470    #[serde(rename = "kmsKeyVersion")]
471    pub kms_key_version: Option<String>,
472    /// List of logical interfaces for the instance. The number of logical interfaces will be the same as number of hardware bond/nic on the chosen network template. Filled if InstanceConfig.multivlan_config is true.
473    #[serde(rename = "logicalInterfaces")]
474    pub logical_interfaces: Option<Vec<GoogleCloudBaremetalsolutionV2LogicalInterface>>,
475    /// The name of the instance config.
476    pub name: Option<String>,
477    /// The type of network configuration on the instance.
478    #[serde(rename = "networkConfig")]
479    pub network_config: Option<String>,
480    /// Server network template name. Filled if InstanceConfig.multivlan_config is true.
481    #[serde(rename = "networkTemplate")]
482    pub network_template: Option<String>,
483    /// OS image to initialize the instance. [Available images](https://cloud.google.com/bare-metal/docs/bms-planning#server_configurations)
484    #[serde(rename = "osImage")]
485    pub os_image: Option<String>,
486    /// Private network address, if any. Filled if InstanceConfig.multivlan_config is false.
487    #[serde(rename = "privateNetwork")]
488    pub private_network: Option<NetworkAddress>,
489    /// Optional. List of names of ssh keys used to provision the instance.
490    #[serde(rename = "sshKeyNames")]
491    pub ssh_key_names: Option<Vec<String>>,
492    /// User note field, it can be used by customers to add additional information for the BMS Ops team .
493    #[serde(rename = "userNote")]
494    pub user_note: Option<String>,
495}
496
497impl common::Part for InstanceConfig {}
498
499/// A resource budget.
500///
501/// This type is not used in any activity, and only used as *part* of another schema.
502///
503#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
504#[serde_with::serde_as]
505#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
506pub struct InstanceQuota {
507    /// Number of machines than can be created for the given location and instance_type.
508    #[serde(rename = "availableMachineCount")]
509    pub available_machine_count: Option<i32>,
510    /// The gcp service of the provisioning quota.
511    #[serde(rename = "gcpService")]
512    pub gcp_service: Option<String>,
513    /// Instance type. Deprecated: use gcp_service.
514    #[serde(rename = "instanceType")]
515    pub instance_type: Option<String>,
516    /// Location where the quota applies.
517    pub location: Option<String>,
518    /// Output only. The name of the instance quota.
519    pub name: Option<String>,
520}
521
522impl common::Part for InstanceQuota {}
523
524/// A GCP vlan attachment.
525///
526/// This type is not used in any activity, and only used as *part* of another schema.
527///
528#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
529#[serde_with::serde_as]
530#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
531pub struct IntakeVlanAttachment {
532    /// Identifier of the VLAN attachment.
533    pub id: Option<String>,
534    /// Attachment pairing key.
535    #[serde(rename = "pairingKey")]
536    pub pairing_key: Option<String>,
537}
538
539impl common::Part for IntakeVlanAttachment {}
540
541/// Response message for the list of servers.
542///
543/// # Activities
544///
545/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
546/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
547///
548/// * [locations instances list projects](ProjectLocationInstanceListCall) (response)
549#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
550#[serde_with::serde_as]
551#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
552pub struct ListInstancesResponse {
553    /// The list of servers.
554    pub instances: Option<Vec<Instance>>,
555    /// A token identifying a page of results from the server.
556    #[serde(rename = "nextPageToken")]
557    pub next_page_token: Option<String>,
558    /// Locations that could not be reached.
559    pub unreachable: Option<Vec<String>>,
560}
561
562impl common::ResponseResult for ListInstancesResponse {}
563
564/// The response message for Locations.ListLocations.
565///
566/// # Activities
567///
568/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
569/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
570///
571/// * [locations list projects](ProjectLocationListCall) (response)
572#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
573#[serde_with::serde_as]
574#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
575pub struct ListLocationsResponse {
576    /// A list of locations that matches the specified filter in the request.
577    pub locations: Option<Vec<Location>>,
578    /// The standard List next-page token.
579    #[serde(rename = "nextPageToken")]
580    pub next_page_token: Option<String>,
581}
582
583impl common::ResponseResult for ListLocationsResponse {}
584
585/// Response message containing the list of storage volume luns.
586///
587/// # Activities
588///
589/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
590/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
591///
592/// * [locations volumes luns list projects](ProjectLocationVolumeLunListCall) (response)
593#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
594#[serde_with::serde_as]
595#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
596pub struct ListLunsResponse {
597    /// The list of luns.
598    pub luns: Option<Vec<Lun>>,
599    /// A token identifying a page of results from the server.
600    #[serde(rename = "nextPageToken")]
601    pub next_page_token: Option<String>,
602    /// Locations that could not be reached.
603    pub unreachable: Option<Vec<String>>,
604}
605
606impl common::ResponseResult for ListLunsResponse {}
607
608/// Response with Networks with IPs
609///
610/// # Activities
611///
612/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
613/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
614///
615/// * [locations networks list network usage projects](ProjectLocationNetworkListNetworkUsageCall) (response)
616#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
617#[serde_with::serde_as]
618#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
619pub struct ListNetworkUsageResponse {
620    /// Networks with IPs.
621    pub networks: Option<Vec<NetworkUsage>>,
622}
623
624impl common::ResponseResult for ListNetworkUsageResponse {}
625
626/// Response message containing the list of networks.
627///
628/// # Activities
629///
630/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
631/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
632///
633/// * [locations networks list projects](ProjectLocationNetworkListCall) (response)
634#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
635#[serde_with::serde_as]
636#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
637pub struct ListNetworksResponse {
638    /// The list of networks.
639    pub networks: Option<Vec<Network>>,
640    /// A token identifying a page of results from the server.
641    #[serde(rename = "nextPageToken")]
642    pub next_page_token: Option<String>,
643    /// Locations that could not be reached.
644    pub unreachable: Option<Vec<String>>,
645}
646
647impl common::ResponseResult for ListNetworksResponse {}
648
649/// Response message containing the list of NFS shares.
650///
651/// # Activities
652///
653/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
654/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
655///
656/// * [locations nfs shares list projects](ProjectLocationNfsShareListCall) (response)
657#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
658#[serde_with::serde_as]
659#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
660pub struct ListNfsSharesResponse {
661    /// A token identifying a page of results from the server.
662    #[serde(rename = "nextPageToken")]
663    pub next_page_token: Option<String>,
664    /// The list of NFS shares.
665    #[serde(rename = "nfsShares")]
666    pub nfs_shares: Option<Vec<NfsShare>>,
667    /// Locations that could not be reached.
668    pub unreachable: Option<Vec<String>>,
669}
670
671impl common::ResponseResult for ListNfsSharesResponse {}
672
673/// Request for getting all available OS images.
674///
675/// # Activities
676///
677/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
678/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
679///
680/// * [locations os images list projects](ProjectLocationOsImageListCall) (response)
681#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
682#[serde_with::serde_as]
683#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
684pub struct ListOSImagesResponse {
685    /// Token to retrieve the next page of results, or empty if there are no more results in the list.
686    #[serde(rename = "nextPageToken")]
687    pub next_page_token: Option<String>,
688    /// The OS images available.
689    #[serde(rename = "osImages")]
690    pub os_images: Option<Vec<OSImage>>,
691}
692
693impl common::ResponseResult for ListOSImagesResponse {}
694
695/// Response message for the list of provisioning quotas.
696///
697/// # Activities
698///
699/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
700/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
701///
702/// * [locations provisioning quotas list projects](ProjectLocationProvisioningQuotaListCall) (response)
703#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
704#[serde_with::serde_as]
705#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
706pub struct ListProvisioningQuotasResponse {
707    /// Token to retrieve the next page of results, or empty if there are no more results in the list.
708    #[serde(rename = "nextPageToken")]
709    pub next_page_token: Option<String>,
710    /// The provisioning quotas registered in this project.
711    #[serde(rename = "provisioningQuotas")]
712    pub provisioning_quotas: Option<Vec<ProvisioningQuota>>,
713}
714
715impl common::ResponseResult for ListProvisioningQuotasResponse {}
716
717/// Message for response of ListSSHKeys.
718///
719/// # Activities
720///
721/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
722/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
723///
724/// * [locations ssh keys list projects](ProjectLocationSshKeyListCall) (response)
725#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
726#[serde_with::serde_as]
727#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
728pub struct ListSSHKeysResponse {
729    /// Token to retrieve the next page of results, or empty if there are no more results in the list.
730    #[serde(rename = "nextPageToken")]
731    pub next_page_token: Option<String>,
732    /// The SSH keys registered in the project.
733    #[serde(rename = "sshKeys")]
734    pub ssh_keys: Option<Vec<SSHKey>>,
735}
736
737impl common::ResponseResult for ListSSHKeysResponse {}
738
739/// Response message containing the list of volume snapshots.
740///
741/// # Activities
742///
743/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
744/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
745///
746/// * [locations volumes snapshots list projects](ProjectLocationVolumeSnapshotListCall) (response)
747#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
748#[serde_with::serde_as]
749#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
750pub struct ListVolumeSnapshotsResponse {
751    /// A token identifying a page of results from the server.
752    #[serde(rename = "nextPageToken")]
753    pub next_page_token: Option<String>,
754    /// Locations that could not be reached.
755    pub unreachable: Option<Vec<String>>,
756    /// The list of snapshots.
757    #[serde(rename = "volumeSnapshots")]
758    pub volume_snapshots: Option<Vec<VolumeSnapshot>>,
759}
760
761impl common::ResponseResult for ListVolumeSnapshotsResponse {}
762
763/// Response message containing the list of storage volumes.
764///
765/// # Activities
766///
767/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
768/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
769///
770/// * [locations volumes list projects](ProjectLocationVolumeListCall) (response)
771#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
772#[serde_with::serde_as]
773#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
774pub struct ListVolumesResponse {
775    /// A token identifying a page of results from the server.
776    #[serde(rename = "nextPageToken")]
777    pub next_page_token: Option<String>,
778    /// Locations that could not be reached.
779    pub unreachable: Option<Vec<String>>,
780    /// The list of storage volumes.
781    pub volumes: Option<Vec<Volume>>,
782}
783
784impl common::ResponseResult for ListVolumesResponse {}
785
786/// Response for LoadInstanceAuthInfo.
787///
788/// # Activities
789///
790/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
791/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
792///
793/// * [locations instances load auth info projects](ProjectLocationInstanceLoadAuthInfoCall) (response)
794#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
795#[serde_with::serde_as]
796#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
797pub struct LoadInstanceAuthInfoResponse {
798    /// List of ssh keys.
799    #[serde(rename = "sshKeys")]
800    pub ssh_keys: Option<Vec<SSHKey>>,
801    /// Map of username to the user account info.
802    #[serde(rename = "userAccounts")]
803    pub user_accounts: Option<HashMap<String, UserAccount>>,
804}
805
806impl common::ResponseResult for LoadInstanceAuthInfoResponse {}
807
808/// A resource that represents a Google Cloud location.
809///
810/// # Activities
811///
812/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
813/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
814///
815/// * [locations get projects](ProjectLocationGetCall) (response)
816#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
817#[serde_with::serde_as]
818#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
819pub struct Location {
820    /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
821    #[serde(rename = "displayName")]
822    pub display_name: Option<String>,
823    /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
824    pub labels: Option<HashMap<String, String>>,
825    /// The canonical id for this location. For example: `"us-east1"`.
826    #[serde(rename = "locationId")]
827    pub location_id: Option<String>,
828    /// Service-specific metadata. For example the available capacity at the given location.
829    pub metadata: Option<HashMap<String, serde_json::Value>>,
830    /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
831    pub name: Option<String>,
832}
833
834impl common::ResponseResult for Location {}
835
836/// Each logical network interface is effectively a network and IP pair.
837///
838/// This type is not used in any activity, and only used as *part* of another schema.
839///
840#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
841#[serde_with::serde_as]
842#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
843pub struct LogicalNetworkInterface {
844    /// Whether this interface is the default gateway for the instance. Only one interface can be the default gateway for the instance.
845    #[serde(rename = "defaultGateway")]
846    pub default_gateway: Option<bool>,
847    /// An identifier for the `Network`, generated by the backend.
848    pub id: Option<String>,
849    /// IP address in the network
850    #[serde(rename = "ipAddress")]
851    pub ip_address: Option<String>,
852    /// Name of the network
853    pub network: Option<String>,
854    /// Type of network.
855    #[serde(rename = "networkType")]
856    pub network_type: Option<String>,
857}
858
859impl common::Part for LogicalNetworkInterface {}
860
861/// A storage volume logical unit number (LUN).
862///
863/// # Activities
864///
865/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
866/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
867///
868/// * [locations volumes luns get projects](ProjectLocationVolumeLunGetCall) (response)
869#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
870#[serde_with::serde_as]
871#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
872pub struct Lun {
873    /// Display if this LUN is a boot LUN.
874    #[serde(rename = "bootLun")]
875    pub boot_lun: Option<bool>,
876    /// Output only. Time after which LUN will be fully deleted. It is filled only for LUNs in COOL_OFF state.
877    #[serde(rename = "expireTime")]
878    pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
879    /// An identifier for the LUN, generated by the backend.
880    pub id: Option<String>,
881    /// Output only. Instances this Lun is attached to.
882    pub instances: Option<Vec<String>>,
883    /// The LUN multiprotocol type ensures the characteristics of the LUN are optimized for each operating system.
884    #[serde(rename = "multiprotocolType")]
885    pub multiprotocol_type: Option<String>,
886    /// Output only. The name of the LUN.
887    pub name: Option<String>,
888    /// Display if this LUN can be shared between multiple physical servers.
889    pub shareable: Option<bool>,
890    /// The size of this LUN, in GiB.
891    #[serde(rename = "sizeGb")]
892    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
893    pub size_gb: Option<i64>,
894    /// The state of this storage volume.
895    pub state: Option<String>,
896    /// The storage type for this LUN.
897    #[serde(rename = "storageType")]
898    pub storage_type: Option<String>,
899    /// Display the storage volume for this LUN.
900    #[serde(rename = "storageVolume")]
901    pub storage_volume: Option<String>,
902    /// The WWID for this LUN.
903    pub wwid: Option<String>,
904}
905
906impl common::ResponseResult for Lun {}
907
908/// A LUN(Logical Unit Number) range.
909///
910/// This type is not used in any activity, and only used as *part* of another schema.
911///
912#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
913#[serde_with::serde_as]
914#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
915pub struct LunRange {
916    /// Number of LUNs to create.
917    pub quantity: Option<i32>,
918    /// The requested size of each LUN, in GB.
919    #[serde(rename = "sizeGb")]
920    pub size_gb: Option<i32>,
921}
922
923impl common::Part for LunRange {}
924
925/// A Network.
926///
927/// # Activities
928///
929/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
930/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
931///
932/// * [locations networks get projects](ProjectLocationNetworkGetCall) (response)
933/// * [locations networks patch projects](ProjectLocationNetworkPatchCall) (request)
934/// * [locations networks rename projects](ProjectLocationNetworkRenameCall) (response)
935#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
936#[serde_with::serde_as]
937#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
938pub struct Network {
939    /// The cidr of the Network.
940    pub cidr: Option<String>,
941    /// Output only. Gateway ip address.
942    #[serde(rename = "gatewayIp")]
943    pub gateway_ip: Option<String>,
944    /// An identifier for the `Network`, generated by the backend.
945    pub id: Option<String>,
946    /// IP address configured.
947    #[serde(rename = "ipAddress")]
948    pub ip_address: Option<String>,
949    /// Whether network uses standard frames or jumbo ones.
950    #[serde(rename = "jumboFramesEnabled")]
951    pub jumbo_frames_enabled: Option<bool>,
952    /// Labels as key value pairs.
953    pub labels: Option<HashMap<String, String>>,
954    /// List of physical interfaces.
955    #[serde(rename = "macAddress")]
956    pub mac_address: Option<Vec<String>>,
957    /// Input only. List of mount points to attach the network to.
958    #[serde(rename = "mountPoints")]
959    pub mount_points: Option<Vec<NetworkMountPoint>>,
960    /// Output only. The resource name of this `Network`. Resource names are schemeless URIs that follow the conventions in https://cloud.google.com/apis/design/resource_names. Format: `projects/{project}/locations/{location}/networks/{network}`
961    pub name: Option<String>,
962    /// Immutable. Pod name. Pod is an independent part of infrastructure. Network can only be connected to the assets (instances, nfsshares) allocated in the same pod.
963    pub pod: Option<String>,
964    /// List of IP address reservations in this network. When updating this field, an error will be generated if a reservation conflicts with an IP address already allocated to a physical server.
965    pub reservations: Option<Vec<NetworkAddressReservation>>,
966    /// IP range for reserved for services (e.g. NFS).
967    #[serde(rename = "servicesCidr")]
968    pub services_cidr: Option<String>,
969    /// The Network state.
970    pub state: Option<String>,
971    /// The type of this network.
972    #[serde(rename = "type")]
973    pub type_: Option<String>,
974    /// The vlan id of the Network.
975    #[serde(rename = "vlanId")]
976    pub vlan_id: Option<String>,
977    /// The Vrf for the Network. Use this only if a new Vrf needs to be created.
978    pub vrf: Option<VRF>,
979    /// Optional. The name of a pre-existing Vrf that the network should be attached to. Format is `vrfs/{vrf}`.
980    #[serde(rename = "vrfAttachment")]
981    pub vrf_attachment: Option<String>,
982}
983
984impl common::RequestValue for Network {}
985impl common::ResponseResult for Network {}
986
987/// A network.
988///
989/// This type is not used in any activity, and only used as *part* of another schema.
990///
991#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
992#[serde_with::serde_as]
993#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
994pub struct NetworkAddress {
995    /// IPv4 address to be assigned to the server.
996    pub address: Option<String>,
997    /// Name of the existing network to use.
998    #[serde(rename = "existingNetworkId")]
999    pub existing_network_id: Option<String>,
1000    /// Id of the network to use, within the same ProvisioningConfig request.
1001    #[serde(rename = "networkId")]
1002    pub network_id: Option<String>,
1003}
1004
1005impl common::Part for NetworkAddress {}
1006
1007/// A reservation of one or more addresses in a network.
1008///
1009/// This type is not used in any activity, and only used as *part* of another schema.
1010///
1011#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1012#[serde_with::serde_as]
1013#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1014pub struct NetworkAddressReservation {
1015    /// The last address of this reservation block, inclusive. I.e., for cases when reservations are only single addresses, end_address and start_address will be the same. Must be specified as a single IPv4 address, e.g. 10.1.2.2.
1016    #[serde(rename = "endAddress")]
1017    pub end_address: Option<String>,
1018    /// A note about this reservation, intended for human consumption.
1019    pub note: Option<String>,
1020    /// The first address of this reservation block. Must be specified as a single IPv4 address, e.g. 10.1.2.2.
1021    #[serde(rename = "startAddress")]
1022    pub start_address: Option<String>,
1023}
1024
1025impl common::Part for NetworkAddressReservation {}
1026
1027/// Configuration parameters for a new network.
1028///
1029/// This type is not used in any activity, and only used as *part* of another schema.
1030///
1031#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1032#[serde_with::serde_as]
1033#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1034pub struct NetworkConfig {
1035    /// Interconnect bandwidth. Set only when type is CLIENT.
1036    pub bandwidth: Option<String>,
1037    /// CIDR range of the network.
1038    pub cidr: Option<String>,
1039    /// The GCP service of the network. Available gcp_service are in https://cloud.google.com/bare-metal/docs/bms-planning.
1040    #[serde(rename = "gcpService")]
1041    pub gcp_service: Option<String>,
1042    /// A transient unique identifier to identify a volume within an ProvisioningConfig request.
1043    pub id: Option<String>,
1044    /// The JumboFramesEnabled option for customer to set.
1045    #[serde(rename = "jumboFramesEnabled")]
1046    pub jumbo_frames_enabled: Option<bool>,
1047    /// Output only. The name of the network config.
1048    pub name: Option<String>,
1049    /// Service CIDR, if any.
1050    #[serde(rename = "serviceCidr")]
1051    pub service_cidr: Option<String>,
1052    /// The type of this network, either Client or Private.
1053    #[serde(rename = "type")]
1054    pub type_: Option<String>,
1055    /// User note field, it can be used by customers to add additional information for the BMS Ops team .
1056    #[serde(rename = "userNote")]
1057    pub user_note: Option<String>,
1058    /// List of VLAN attachments. As of now there are always 2 attachments, but it is going to change in the future (multi vlan). Use only one of vlan_attachments or vrf
1059    #[serde(rename = "vlanAttachments")]
1060    pub vlan_attachments: Option<Vec<IntakeVlanAttachment>>,
1061    /// Whether the VLAN attachment pair is located in the same project.
1062    #[serde(rename = "vlanSameProject")]
1063    pub vlan_same_project: Option<bool>,
1064    /// Optional. The name of a pre-existing Vrf that the network should be attached to. Format is `vrfs/{vrf}`. If vrf is specified, vlan_attachments must be empty.
1065    pub vrf: Option<String>,
1066}
1067
1068impl common::Part for NetworkConfig {}
1069
1070/// Mount point for a network.
1071///
1072/// This type is not used in any activity, and only used as *part* of another schema.
1073///
1074#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1075#[serde_with::serde_as]
1076#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1077pub struct NetworkMountPoint {
1078    /// Network should be a default gateway.
1079    #[serde(rename = "defaultGateway")]
1080    pub default_gateway: Option<bool>,
1081    /// Instance to attach network to.
1082    pub instance: Option<String>,
1083    /// Ip address of the server.
1084    #[serde(rename = "ipAddress")]
1085    pub ip_address: Option<String>,
1086    /// Logical interface to detach from.
1087    #[serde(rename = "logicalInterface")]
1088    pub logical_interface: Option<String>,
1089}
1090
1091impl common::Part for NetworkMountPoint {}
1092
1093/// Network with all used IP addresses.
1094///
1095/// This type is not used in any activity, and only used as *part* of another schema.
1096///
1097#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1098#[serde_with::serde_as]
1099#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1100pub struct NetworkUsage {
1101    /// Network.
1102    pub network: Option<Network>,
1103    /// All used IP addresses in this network.
1104    #[serde(rename = "usedIps")]
1105    pub used_ips: Option<Vec<String>>,
1106}
1107
1108impl common::Part for NetworkUsage {}
1109
1110/// A NFS export entry.
1111///
1112/// This type is not used in any activity, and only used as *part* of another schema.
1113///
1114#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1115#[serde_with::serde_as]
1116#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1117pub struct NfsExport {
1118    /// Allow dev flag in NfsShare AllowedClientsRequest.
1119    #[serde(rename = "allowDev")]
1120    pub allow_dev: Option<bool>,
1121    /// Allow the setuid flag.
1122    #[serde(rename = "allowSuid")]
1123    pub allow_suid: Option<bool>,
1124    /// A CIDR range.
1125    pub cidr: Option<String>,
1126    /// Either a single machine, identified by an ID, or a comma-separated list of machine IDs.
1127    #[serde(rename = "machineId")]
1128    pub machine_id: Option<String>,
1129    /// Network to use to publish the export.
1130    #[serde(rename = "networkId")]
1131    pub network_id: Option<String>,
1132    /// Disable root squashing, which is a feature of NFS. Root squash is a special mapping of the remote superuser (root) identity when using identity authentication.
1133    #[serde(rename = "noRootSquash")]
1134    pub no_root_squash: Option<bool>,
1135    /// Export permissions.
1136    pub permissions: Option<String>,
1137}
1138
1139impl common::Part for NfsExport {}
1140
1141/// An NFS share.
1142///
1143/// # Activities
1144///
1145/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1146/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1147///
1148/// * [locations nfs shares create projects](ProjectLocationNfsShareCreateCall) (request)
1149/// * [locations nfs shares get projects](ProjectLocationNfsShareGetCall) (response)
1150/// * [locations nfs shares patch projects](ProjectLocationNfsSharePatchCall) (request)
1151/// * [locations nfs shares rename projects](ProjectLocationNfsShareRenameCall) (response)
1152#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1153#[serde_with::serde_as]
1154#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1155pub struct NfsShare {
1156    /// List of allowed access points.
1157    #[serde(rename = "allowedClients")]
1158    pub allowed_clients: Option<Vec<AllowedClient>>,
1159    /// Output only. An identifier for the NFS share, generated by the backend. This is the same value as nfs_share_id and will replace it in the future.
1160    pub id: Option<String>,
1161    /// Labels as key value pairs.
1162    pub labels: Option<HashMap<String, String>>,
1163    /// Immutable. The name of the NFS share.
1164    pub name: Option<String>,
1165    /// Output only. An identifier for the NFS share, generated by the backend. This field will be deprecated in the future, use `id` instead.
1166    #[serde(rename = "nfsShareId")]
1167    pub nfs_share_id: Option<String>,
1168    /// Immutable. Pod name. Pod is an independent part of infrastructure. NFSShare can only be connected to the assets (networks, instances) allocated in the same pod.
1169    pub pod: Option<String>,
1170    /// The requested size, in GiB.
1171    #[serde(rename = "requestedSizeGib")]
1172    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1173    pub requested_size_gib: Option<i64>,
1174    /// Output only. The state of the NFS share.
1175    pub state: Option<String>,
1176    /// Immutable. The storage type of the underlying volume.
1177    #[serde(rename = "storageType")]
1178    pub storage_type: Option<String>,
1179    /// Output only. The underlying volume of the share. Created automatically during provisioning.
1180    pub volume: Option<String>,
1181}
1182
1183impl common::RequestValue for NfsShare {}
1184impl common::ResponseResult for NfsShare {}
1185
1186/// Operation System image.
1187///
1188/// # Activities
1189///
1190/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1191/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1192///
1193/// * [locations os images get projects](ProjectLocationOsImageGetCall) (response)
1194#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1195#[serde_with::serde_as]
1196#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1197pub struct OSImage {
1198    /// Instance types this image is applicable to. [Available types](https://cloud.google.com/bare-metal/docs/bms-planning#server_configurations)
1199    #[serde(rename = "applicableInstanceTypes")]
1200    pub applicable_instance_types: Option<Vec<String>>,
1201    /// OS Image code.
1202    pub code: Option<String>,
1203    /// OS Image description.
1204    pub description: Option<String>,
1205    /// Output only. OS Image's unique name.
1206    pub name: Option<String>,
1207    /// Network templates that can be used with this OS Image.
1208    #[serde(rename = "supportedNetworkTemplates")]
1209    pub supported_network_templates: Option<Vec<String>>,
1210}
1211
1212impl common::ResponseResult for OSImage {}
1213
1214/// This resource represents a long-running operation that is the result of a network API call.
1215///
1216/// # Activities
1217///
1218/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1219/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1220///
1221/// * [locations instances detach lun projects](ProjectLocationInstanceDetachLunCall) (response)
1222/// * [locations instances disable hyperthreading projects](ProjectLocationInstanceDisableHyperthreadingCall) (response)
1223/// * [locations instances disable interactive serial console projects](ProjectLocationInstanceDisableInteractiveSerialConsoleCall) (response)
1224/// * [locations instances enable hyperthreading projects](ProjectLocationInstanceEnableHyperthreadingCall) (response)
1225/// * [locations instances enable interactive serial console projects](ProjectLocationInstanceEnableInteractiveSerialConsoleCall) (response)
1226/// * [locations instances patch projects](ProjectLocationInstancePatchCall) (response)
1227/// * [locations instances reimage projects](ProjectLocationInstanceReimageCall) (response)
1228/// * [locations instances reset projects](ProjectLocationInstanceResetCall) (response)
1229/// * [locations instances start projects](ProjectLocationInstanceStartCall) (response)
1230/// * [locations instances stop projects](ProjectLocationInstanceStopCall) (response)
1231/// * [locations networks patch projects](ProjectLocationNetworkPatchCall) (response)
1232/// * [locations nfs shares create projects](ProjectLocationNfsShareCreateCall) (response)
1233/// * [locations nfs shares delete projects](ProjectLocationNfsShareDeleteCall) (response)
1234/// * [locations nfs shares patch projects](ProjectLocationNfsSharePatchCall) (response)
1235/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
1236/// * [locations volumes luns evict projects](ProjectLocationVolumeLunEvictCall) (response)
1237/// * [locations volumes snapshots restore volume snapshot projects](ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall) (response)
1238/// * [locations volumes evict projects](ProjectLocationVolumeEvictCall) (response)
1239/// * [locations volumes patch projects](ProjectLocationVolumePatchCall) (response)
1240/// * [locations volumes resize projects](ProjectLocationVolumeResizeCall) (response)
1241#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1242#[serde_with::serde_as]
1243#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1244pub struct Operation {
1245    /// 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.
1246    pub done: Option<bool>,
1247    /// The error result of the operation in case of failure or cancellation.
1248    pub error: Option<Status>,
1249    /// 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.
1250    pub metadata: Option<HashMap<String, serde_json::Value>>,
1251    /// 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}`.
1252    pub name: Option<String>,
1253    /// 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`.
1254    pub response: Option<HashMap<String, serde_json::Value>>,
1255}
1256
1257impl common::ResponseResult for Operation {}
1258
1259/// A provisioning configuration.
1260///
1261/// # Activities
1262///
1263/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1264/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1265///
1266/// * [locations provisioning configs create projects](ProjectLocationProvisioningConfigCreateCall) (request|response)
1267/// * [locations provisioning configs get projects](ProjectLocationProvisioningConfigGetCall) (response)
1268/// * [locations provisioning configs patch projects](ProjectLocationProvisioningConfigPatchCall) (request|response)
1269#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1270#[serde_with::serde_as]
1271#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1272pub struct ProvisioningConfig {
1273    /// Output only. URI to Cloud Console UI view of this provisioning config.
1274    #[serde(rename = "cloudConsoleUri")]
1275    pub cloud_console_uri: Option<String>,
1276    /// Optional. The user-defined identifier of the provisioning config.
1277    #[serde(rename = "customId")]
1278    pub custom_id: Option<String>,
1279    /// Email provided to send a confirmation with provisioning config to. Deprecated in favour of email field in request messages.
1280    pub email: Option<String>,
1281    /// A service account to enable customers to access instance credentials upon handover.
1282    #[serde(rename = "handoverServiceAccount")]
1283    pub handover_service_account: Option<String>,
1284    /// Instances to be created.
1285    pub instances: Option<Vec<InstanceConfig>>,
1286    /// Optional. Location name of this ProvisioningConfig. It is optional only for Intake UI transition period.
1287    pub location: Option<String>,
1288    /// Output only. The system-generated name of the provisioning config. This follows the UUID format.
1289    pub name: Option<String>,
1290    /// Networks to be created.
1291    pub networks: Option<Vec<NetworkConfig>>,
1292    /// Optional. Pod name. Pod is an independent part of infrastructure. Instance can be connected to the assets (networks, volumes, nfsshares) allocated in the same pod only.
1293    pub pod: Option<String>,
1294    /// Output only. State of ProvisioningConfig.
1295    pub state: Option<String>,
1296    /// Optional status messages associated with the FAILED state.
1297    #[serde(rename = "statusMessage")]
1298    pub status_message: Option<String>,
1299    /// A generated ticket id to track provisioning request.
1300    #[serde(rename = "ticketId")]
1301    pub ticket_id: Option<String>,
1302    /// Output only. Last update timestamp.
1303    #[serde(rename = "updateTime")]
1304    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1305    /// Volumes to be created.
1306    pub volumes: Option<Vec<VolumeConfig>>,
1307    /// If true, VPC SC is enabled for the cluster.
1308    #[serde(rename = "vpcScEnabled")]
1309    pub vpc_sc_enabled: Option<bool>,
1310}
1311
1312impl common::RequestValue for ProvisioningConfig {}
1313impl common::ResponseResult for ProvisioningConfig {}
1314
1315/// A provisioning quota for a given project.
1316///
1317/// This type is not used in any activity, and only used as *part* of another schema.
1318///
1319#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1320#[serde_with::serde_as]
1321#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1322pub struct ProvisioningQuota {
1323    /// The asset type of this provisioning quota.
1324    #[serde(rename = "assetType")]
1325    pub asset_type: Option<String>,
1326    /// The available count of the provisioning quota.
1327    #[serde(rename = "availableCount")]
1328    pub available_count: Option<i32>,
1329    /// The gcp service of the provisioning quota.
1330    #[serde(rename = "gcpService")]
1331    pub gcp_service: Option<String>,
1332    /// Instance quota.
1333    #[serde(rename = "instanceQuota")]
1334    pub instance_quota: Option<InstanceQuota>,
1335    /// The specific location of the provisioining quota.
1336    pub location: Option<String>,
1337    /// Output only. The name of the provisioning quota.
1338    pub name: Option<String>,
1339    /// Network bandwidth, Gbps
1340    #[serde(rename = "networkBandwidth")]
1341    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1342    pub network_bandwidth: Option<i64>,
1343    /// Server count.
1344    #[serde(rename = "serverCount")]
1345    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1346    pub server_count: Option<i64>,
1347    /// Storage size (GB).
1348    #[serde(rename = "storageGib")]
1349    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1350    pub storage_gib: Option<i64>,
1351}
1352
1353impl common::Part for ProvisioningQuota {}
1354
1355/// QOS policy parameters.
1356///
1357/// This type is not used in any activity, and only used as *part* of another schema.
1358///
1359#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1360#[serde_with::serde_as]
1361#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1362pub struct QosPolicy {
1363    /// The bandwidth permitted by the QOS policy, in gbps.
1364    #[serde(rename = "bandwidthGbps")]
1365    pub bandwidth_gbps: Option<f64>,
1366}
1367
1368impl common::Part for QosPolicy {}
1369
1370/// Message requesting to perform reimage operation on a server.
1371///
1372/// # Activities
1373///
1374/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1375/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1376///
1377/// * [locations instances reimage projects](ProjectLocationInstanceReimageCall) (request)
1378#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1379#[serde_with::serde_as]
1380#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1381pub struct ReimageInstanceRequest {
1382    /// Optional. Name of the KMS crypto key version used to encrypt the initial passwords. The key has to have ASYMMETRIC_DECRYPT purpose. Format is `projects/{project}/locations/{location}/keyRings/{keyring}/cryptoKeys/{key}/cryptoKeyVersions/{version}`.
1383    #[serde(rename = "kmsKeyVersion")]
1384    pub kms_key_version: Option<String>,
1385    /// Required. The OS image code of the image which will be used in the reimage operation.
1386    #[serde(rename = "osImage")]
1387    pub os_image: Option<String>,
1388    /// Optional. List of SSH Keys used during reimaging an instance.
1389    #[serde(rename = "sshKeys")]
1390    pub ssh_keys: Option<Vec<String>>,
1391}
1392
1393impl common::RequestValue for ReimageInstanceRequest {}
1394
1395/// Message requesting rename of a server.
1396///
1397/// # Activities
1398///
1399/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1400/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1401///
1402/// * [locations instances rename projects](ProjectLocationInstanceRenameCall) (request)
1403#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1404#[serde_with::serde_as]
1405#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1406pub struct RenameInstanceRequest {
1407    /// Required. The new `id` of the instance.
1408    #[serde(rename = "newInstanceId")]
1409    pub new_instance_id: Option<String>,
1410}
1411
1412impl common::RequestValue for RenameInstanceRequest {}
1413
1414/// Message requesting rename of a server.
1415///
1416/// # Activities
1417///
1418/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1419/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1420///
1421/// * [locations networks rename projects](ProjectLocationNetworkRenameCall) (request)
1422#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1423#[serde_with::serde_as]
1424#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1425pub struct RenameNetworkRequest {
1426    /// Required. The new `id` of the network.
1427    #[serde(rename = "newNetworkId")]
1428    pub new_network_id: Option<String>,
1429}
1430
1431impl common::RequestValue for RenameNetworkRequest {}
1432
1433/// Message requesting rename of a server.
1434///
1435/// # Activities
1436///
1437/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1438/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1439///
1440/// * [locations nfs shares rename projects](ProjectLocationNfsShareRenameCall) (request)
1441#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1442#[serde_with::serde_as]
1443#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1444pub struct RenameNfsShareRequest {
1445    /// Required. The new `id` of the nfsshare.
1446    #[serde(rename = "newNfsshareId")]
1447    pub new_nfsshare_id: Option<String>,
1448}
1449
1450impl common::RequestValue for RenameNfsShareRequest {}
1451
1452/// Message requesting rename of a server.
1453///
1454/// # Activities
1455///
1456/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1457/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1458///
1459/// * [locations volumes rename projects](ProjectLocationVolumeRenameCall) (request)
1460#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1461#[serde_with::serde_as]
1462#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1463pub struct RenameVolumeRequest {
1464    /// Required. The new `id` of the volume.
1465    #[serde(rename = "newVolumeId")]
1466    pub new_volume_id: Option<String>,
1467}
1468
1469impl common::RequestValue for RenameVolumeRequest {}
1470
1471/// Message requesting to reset a server.
1472///
1473/// # Activities
1474///
1475/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1476/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1477///
1478/// * [locations instances reset projects](ProjectLocationInstanceResetCall) (request)
1479#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1480#[serde_with::serde_as]
1481#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1482pub struct ResetInstanceRequest {
1483    _never_set: Option<bool>,
1484}
1485
1486impl common::RequestValue for ResetInstanceRequest {}
1487
1488/// Request for emergency resize Volume.
1489///
1490/// # Activities
1491///
1492/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1493/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1494///
1495/// * [locations volumes resize projects](ProjectLocationVolumeResizeCall) (request)
1496#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1497#[serde_with::serde_as]
1498#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1499pub struct ResizeVolumeRequest {
1500    /// New Volume size, in GiB.
1501    #[serde(rename = "sizeGib")]
1502    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1503    pub size_gib: Option<i64>,
1504}
1505
1506impl common::RequestValue for ResizeVolumeRequest {}
1507
1508/// Message for restoring a volume snapshot.
1509///
1510/// # Activities
1511///
1512/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1513/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1514///
1515/// * [locations volumes snapshots restore volume snapshot projects](ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall) (request)
1516#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1517#[serde_with::serde_as]
1518#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1519pub struct RestoreVolumeSnapshotRequest {
1520    _never_set: Option<bool>,
1521}
1522
1523impl common::RequestValue for RestoreVolumeSnapshotRequest {}
1524
1525/// An SSH key, used for authorizing with the interactive serial console feature.
1526///
1527/// # Activities
1528///
1529/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1530/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1531///
1532/// * [locations ssh keys create projects](ProjectLocationSshKeyCreateCall) (request|response)
1533#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1534#[serde_with::serde_as]
1535#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1536pub struct SSHKey {
1537    /// Output only. The name of this SSH key. Currently, the only valid value for the location is "global".
1538    pub name: Option<String>,
1539    /// The public SSH key. This must be in OpenSSH .authorized_keys format.
1540    #[serde(rename = "publicKey")]
1541    pub public_key: Option<String>,
1542}
1543
1544impl common::RequestValue for SSHKey {}
1545impl common::ResponseResult for SSHKey {}
1546
1547/// Details about snapshot space reservation and usage on the storage volume.
1548///
1549/// This type is not used in any activity, and only used as *part* of another schema.
1550///
1551#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1552#[serde_with::serde_as]
1553#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1554pub struct SnapshotReservationDetail {
1555    /// The space on this storage volume reserved for snapshots, shown in GiB.
1556    #[serde(rename = "reservedSpaceGib")]
1557    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1558    pub reserved_space_gib: Option<i64>,
1559    /// Percent of the total Volume size reserved for snapshot copies. Enabling snapshots requires reserving 20% or more of the storage volume space for snapshots. Maximum reserved space for snapshots is 40%. Setting this field will effectively set snapshot_enabled to true.
1560    #[serde(rename = "reservedSpacePercent")]
1561    pub reserved_space_percent: Option<i32>,
1562    /// The amount, in GiB, of available space in this storage volume's reserved snapshot space.
1563    #[serde(rename = "reservedSpaceRemainingGib")]
1564    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1565    pub reserved_space_remaining_gib: Option<i64>,
1566    /// The percent of snapshot space on this storage volume actually being used by the snapshot copies. This value might be higher than 100% if the snapshot copies have overflowed into the data portion of the storage volume.
1567    #[serde(rename = "reservedSpaceUsedPercent")]
1568    pub reserved_space_used_percent: Option<i32>,
1569}
1570
1571impl common::Part for SnapshotReservationDetail {}
1572
1573/// Message requesting to start a server.
1574///
1575/// # Activities
1576///
1577/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1578/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1579///
1580/// * [locations instances start projects](ProjectLocationInstanceStartCall) (request)
1581#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1582#[serde_with::serde_as]
1583#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1584pub struct StartInstanceRequest {
1585    _never_set: Option<bool>,
1586}
1587
1588impl common::RequestValue for StartInstanceRequest {}
1589
1590/// 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).
1591///
1592/// This type is not used in any activity, and only used as *part* of another schema.
1593///
1594#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1595#[serde_with::serde_as]
1596#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1597pub struct Status {
1598    /// The status code, which should be an enum value of google.rpc.Code.
1599    pub code: Option<i32>,
1600    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1601    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1602    /// 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.
1603    pub message: Option<String>,
1604}
1605
1606impl common::Part for Status {}
1607
1608/// Message requesting to stop a server.
1609///
1610/// # Activities
1611///
1612/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1613/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1614///
1615/// * [locations instances stop projects](ProjectLocationInstanceStopCall) (request)
1616#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1617#[serde_with::serde_as]
1618#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1619pub struct StopInstanceRequest {
1620    _never_set: Option<bool>,
1621}
1622
1623impl common::RequestValue for StopInstanceRequest {}
1624
1625/// Request for SubmitProvisioningConfig.
1626///
1627/// # Activities
1628///
1629/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1630/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1631///
1632/// * [locations provisioning configs submit projects](ProjectLocationProvisioningConfigSubmitCall) (request)
1633#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1634#[serde_with::serde_as]
1635#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1636pub struct SubmitProvisioningConfigRequest {
1637    /// Optional. Email provided to send a confirmation with provisioning config to.
1638    pub email: Option<String>,
1639    /// Required. The ProvisioningConfig to create.
1640    #[serde(rename = "provisioningConfig")]
1641    pub provisioning_config: Option<ProvisioningConfig>,
1642}
1643
1644impl common::RequestValue for SubmitProvisioningConfigRequest {}
1645
1646/// Response for SubmitProvisioningConfig.
1647///
1648/// # Activities
1649///
1650/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1651/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1652///
1653/// * [locations provisioning configs submit projects](ProjectLocationProvisioningConfigSubmitCall) (response)
1654#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1655#[serde_with::serde_as]
1656#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1657pub struct SubmitProvisioningConfigResponse {
1658    /// The submitted provisioning config.
1659    #[serde(rename = "provisioningConfig")]
1660    pub provisioning_config: Option<ProvisioningConfig>,
1661}
1662
1663impl common::ResponseResult for SubmitProvisioningConfigResponse {}
1664
1665/// User account provisioned for the customer.
1666///
1667/// This type is not used in any activity, and only used as *part* of another schema.
1668///
1669#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1670#[serde_with::serde_as]
1671#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1672pub struct UserAccount {
1673    /// Encrypted initial password value.
1674    #[serde(rename = "encryptedPassword")]
1675    pub encrypted_password: Option<String>,
1676    /// KMS CryptoKey Version used to encrypt the password.
1677    #[serde(rename = "kmsKeyVersion")]
1678    pub kms_key_version: Option<String>,
1679}
1680
1681impl common::Part for UserAccount {}
1682
1683/// A network VRF.
1684///
1685/// This type is not used in any activity, and only used as *part* of another schema.
1686///
1687#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1688#[serde_with::serde_as]
1689#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1690pub struct VRF {
1691    /// The name of the VRF.
1692    pub name: Option<String>,
1693    /// The QOS policy applied to this VRF. The value is only meaningful when all the vlan attachments have the same QoS. This field should not be used for new integrations, use vlan attachment level qos instead. The field is left for backward-compatibility.
1694    #[serde(rename = "qosPolicy")]
1695    pub qos_policy: Option<QosPolicy>,
1696    /// The possible state of VRF.
1697    pub state: Option<String>,
1698    /// The list of VLAN attachments for the VRF.
1699    #[serde(rename = "vlanAttachments")]
1700    pub vlan_attachments: Option<Vec<VlanAttachment>>,
1701}
1702
1703impl common::Part for VRF {}
1704
1705/// VLAN attachment details.
1706///
1707/// This type is not used in any activity, and only used as *part* of another schema.
1708///
1709#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1710#[serde_with::serde_as]
1711#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1712pub struct VlanAttachment {
1713    /// Immutable. The identifier of the attachment within vrf.
1714    pub id: Option<String>,
1715    /// Optional. The name of the vlan attachment within vrf. This is of the form projects/{project_number}/regions/{region}/interconnectAttachments/{interconnect_attachment}
1716    #[serde(rename = "interconnectAttachment")]
1717    pub interconnect_attachment: Option<String>,
1718    /// Input only. Pairing key.
1719    #[serde(rename = "pairingKey")]
1720    pub pairing_key: Option<String>,
1721    /// The peer IP of the attachment.
1722    #[serde(rename = "peerIp")]
1723    pub peer_ip: Option<String>,
1724    /// The peer vlan ID of the attachment.
1725    #[serde(rename = "peerVlanId")]
1726    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1727    pub peer_vlan_id: Option<i64>,
1728    /// The QOS policy applied to this VLAN attachment. This value should be preferred to using qos at vrf level.
1729    #[serde(rename = "qosPolicy")]
1730    pub qos_policy: Option<QosPolicy>,
1731    /// The router IP of the attachment.
1732    #[serde(rename = "routerIp")]
1733    pub router_ip: Option<String>,
1734}
1735
1736impl common::Part for VlanAttachment {}
1737
1738/// A storage volume.
1739///
1740/// # Activities
1741///
1742/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1743/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1744///
1745/// * [locations volumes get projects](ProjectLocationVolumeGetCall) (response)
1746/// * [locations volumes patch projects](ProjectLocationVolumePatchCall) (request)
1747/// * [locations volumes rename projects](ProjectLocationVolumeRenameCall) (response)
1748#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1749#[serde_with::serde_as]
1750#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1751pub struct Volume {
1752    /// Output only. Is the Volume attached at at least one instance. This field is a lightweight counterpart of `instances` field. It is filled in List responses as well.
1753    pub attached: Option<bool>,
1754    /// The size, in GiB, that this storage volume has expanded as a result of an auto grow policy. In the absence of auto-grow, the value is 0.
1755    #[serde(rename = "autoGrownSizeGib")]
1756    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1757    pub auto_grown_size_gib: Option<i64>,
1758    /// Output only. Whether this volume is a boot volume. A boot volume is one which contains a boot LUN.
1759    #[serde(rename = "bootVolume")]
1760    pub boot_volume: Option<bool>,
1761    /// The current size of this storage volume, in GiB, including space reserved for snapshots. This size might be different than the requested size if the storage volume has been configured with auto grow or auto shrink.
1762    #[serde(rename = "currentSizeGib")]
1763    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1764    pub current_size_gib: Option<i64>,
1765    /// Additional emergency size that was requested for this Volume, in GiB. current_size_gib includes this value.
1766    #[serde(rename = "emergencySizeGib")]
1767    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1768    pub emergency_size_gib: Option<i64>,
1769    /// Output only. Time after which volume will be fully deleted. It is filled only for volumes in COOLOFF state.
1770    #[serde(rename = "expireTime")]
1771    pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1772    /// An identifier for the `Volume`, generated by the backend.
1773    pub id: Option<String>,
1774    /// Output only. Instances this Volume is attached to. This field is set only in Get requests.
1775    pub instances: Option<Vec<String>>,
1776    /// Labels as key value pairs.
1777    pub labels: Option<HashMap<String, String>>,
1778    /// Maximum size volume can be expanded to in case of evergency, in GiB.
1779    #[serde(rename = "maxSizeGib")]
1780    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1781    pub max_size_gib: Option<i64>,
1782    /// Output only. The resource name of this `Volume`. Resource names are schemeless URIs that follow the conventions in https://cloud.google.com/apis/design/resource_names. Format: `projects/{project}/locations/{location}/volumes/{volume}`
1783    pub name: Option<String>,
1784    /// Input only. User-specified notes for new Volume. Used to provision Volumes that require manual intervention.
1785    pub notes: Option<String>,
1786    /// Originally requested size, in GiB.
1787    #[serde(rename = "originallyRequestedSizeGib")]
1788    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1789    pub originally_requested_size_gib: Option<i64>,
1790    /// Immutable. Performance tier of the Volume. Default is SHARED.
1791    #[serde(rename = "performanceTier")]
1792    pub performance_tier: Option<String>,
1793    /// Immutable. Pod name. Pod is an independent part of infrastructure. Volume can only be connected to the instances allocated in the same pod.
1794    pub pod: Option<String>,
1795    /// Output only. Storage protocol for the Volume.
1796    pub protocol: Option<String>,
1797    /// The space remaining in the storage volume for new LUNs, in GiB, excluding space reserved for snapshots.
1798    #[serde(rename = "remainingSpaceGib")]
1799    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1800    pub remaining_space_gib: Option<i64>,
1801    /// The requested size of this storage volume, in GiB.
1802    #[serde(rename = "requestedSizeGib")]
1803    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1804    pub requested_size_gib: Option<i64>,
1805    /// The behavior to use when snapshot reserved space is full.
1806    #[serde(rename = "snapshotAutoDeleteBehavior")]
1807    pub snapshot_auto_delete_behavior: Option<String>,
1808    /// Whether snapshots are enabled.
1809    #[serde(rename = "snapshotEnabled")]
1810    pub snapshot_enabled: Option<bool>,
1811    /// Details about snapshot space reservation and usage on the storage volume.
1812    #[serde(rename = "snapshotReservationDetail")]
1813    pub snapshot_reservation_detail: Option<SnapshotReservationDetail>,
1814    /// The state of this storage volume.
1815    pub state: Option<String>,
1816    /// The storage type for this volume.
1817    #[serde(rename = "storageType")]
1818    pub storage_type: Option<String>,
1819    /// The workload profile for the volume.
1820    #[serde(rename = "workloadProfile")]
1821    pub workload_profile: Option<String>,
1822}
1823
1824impl common::RequestValue for Volume {}
1825impl common::ResponseResult for Volume {}
1826
1827/// Configuration parameters for a new volume.
1828///
1829/// This type is not used in any activity, and only used as *part* of another schema.
1830///
1831#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1832#[serde_with::serde_as]
1833#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1834pub struct VolumeConfig {
1835    /// The GCP service of the storage volume. Available gcp_service are in https://cloud.google.com/bare-metal/docs/bms-planning.
1836    #[serde(rename = "gcpService")]
1837    pub gcp_service: Option<String>,
1838    /// A transient unique identifier to identify a volume within an ProvisioningConfig request.
1839    pub id: Option<String>,
1840    /// LUN ranges to be configured. Set only when protocol is PROTOCOL_FC.
1841    #[serde(rename = "lunRanges")]
1842    pub lun_ranges: Option<Vec<LunRange>>,
1843    /// Machine ids connected to this volume. Set only when protocol is PROTOCOL_FC.
1844    #[serde(rename = "machineIds")]
1845    pub machine_ids: Option<Vec<String>>,
1846    /// Output only. The name of the volume config.
1847    pub name: Option<String>,
1848    /// NFS exports. Set only when protocol is PROTOCOL_NFS.
1849    #[serde(rename = "nfsExports")]
1850    pub nfs_exports: Option<Vec<NfsExport>>,
1851    /// Performance tier of the Volume. Default is SHARED.
1852    #[serde(rename = "performanceTier")]
1853    pub performance_tier: Option<String>,
1854    /// Volume protocol.
1855    pub protocol: Option<String>,
1856    /// The requested size of this volume, in GB.
1857    #[serde(rename = "sizeGb")]
1858    pub size_gb: Option<i32>,
1859    /// Whether snapshots should be enabled.
1860    #[serde(rename = "snapshotsEnabled")]
1861    pub snapshots_enabled: Option<bool>,
1862    /// The type of this Volume.
1863    #[serde(rename = "type")]
1864    pub type_: Option<String>,
1865    /// User note field, it can be used by customers to add additional information for the BMS Ops team .
1866    #[serde(rename = "userNote")]
1867    pub user_note: Option<String>,
1868}
1869
1870impl common::Part for VolumeConfig {}
1871
1872/// A snapshot of a volume. Only boot volumes can have snapshots.
1873///
1874/// # Activities
1875///
1876/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1877/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1878///
1879/// * [locations volumes snapshots create projects](ProjectLocationVolumeSnapshotCreateCall) (request|response)
1880/// * [locations volumes snapshots get projects](ProjectLocationVolumeSnapshotGetCall) (response)
1881#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1882#[serde_with::serde_as]
1883#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1884pub struct VolumeSnapshot {
1885    /// Output only. The creation time of the snapshot.
1886    #[serde(rename = "createTime")]
1887    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1888    /// The description of the snapshot.
1889    pub description: Option<String>,
1890    /// Output only. An identifier for the snapshot, generated by the backend.
1891    pub id: Option<String>,
1892    /// The name of the snapshot.
1893    pub name: Option<String>,
1894    /// Output only. The name of the volume which this snapshot belongs to.
1895    #[serde(rename = "storageVolume")]
1896    pub storage_volume: Option<String>,
1897    /// Output only. The type of the snapshot which indicates whether it was scheduled or manual/ad-hoc.
1898    #[serde(rename = "type")]
1899    pub type_: Option<String>,
1900}
1901
1902impl common::RequestValue for VolumeSnapshot {}
1903impl common::ResponseResult for VolumeSnapshot {}
1904
1905// ###################
1906// MethodBuilders ###
1907// #################
1908
1909/// A builder providing access to all methods supported on *project* resources.
1910/// It is not used directly, but through the [`Baremetalsolution`] hub.
1911///
1912/// # Example
1913///
1914/// Instantiate a resource builder
1915///
1916/// ```test_harness,no_run
1917/// extern crate hyper;
1918/// extern crate hyper_rustls;
1919/// extern crate google_baremetalsolution2 as baremetalsolution2;
1920///
1921/// # async fn dox() {
1922/// use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1923///
1924/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1925/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1926///     .with_native_roots()
1927///     .unwrap()
1928///     .https_only()
1929///     .enable_http2()
1930///     .build();
1931///
1932/// let executor = hyper_util::rt::TokioExecutor::new();
1933/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1934///     secret,
1935///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1936///     yup_oauth2::client::CustomHyperClientBuilder::from(
1937///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1938///     ),
1939/// ).build().await.unwrap();
1940///
1941/// let client = hyper_util::client::legacy::Client::builder(
1942///     hyper_util::rt::TokioExecutor::new()
1943/// )
1944/// .build(
1945///     hyper_rustls::HttpsConnectorBuilder::new()
1946///         .with_native_roots()
1947///         .unwrap()
1948///         .https_or_http()
1949///         .enable_http2()
1950///         .build()
1951/// );
1952/// let mut hub = Baremetalsolution::new(client, auth);
1953/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1954/// // like `locations_get(...)`, `locations_instances_detach_lun(...)`, `locations_instances_disable_hyperthreading(...)`, `locations_instances_disable_interactive_serial_console(...)`, `locations_instances_enable_hyperthreading(...)`, `locations_instances_enable_interactive_serial_console(...)`, `locations_instances_get(...)`, `locations_instances_list(...)`, `locations_instances_load_auth_info(...)`, `locations_instances_patch(...)`, `locations_instances_reimage(...)`, `locations_instances_rename(...)`, `locations_instances_reset(...)`, `locations_instances_start(...)`, `locations_instances_stop(...)`, `locations_list(...)`, `locations_networks_get(...)`, `locations_networks_list(...)`, `locations_networks_list_network_usage(...)`, `locations_networks_patch(...)`, `locations_networks_rename(...)`, `locations_nfs_shares_create(...)`, `locations_nfs_shares_delete(...)`, `locations_nfs_shares_get(...)`, `locations_nfs_shares_list(...)`, `locations_nfs_shares_patch(...)`, `locations_nfs_shares_rename(...)`, `locations_operations_get(...)`, `locations_os_images_get(...)`, `locations_os_images_list(...)`, `locations_provisioning_configs_create(...)`, `locations_provisioning_configs_get(...)`, `locations_provisioning_configs_patch(...)`, `locations_provisioning_configs_submit(...)`, `locations_provisioning_quotas_list(...)`, `locations_ssh_keys_create(...)`, `locations_ssh_keys_delete(...)`, `locations_ssh_keys_list(...)`, `locations_volumes_evict(...)`, `locations_volumes_get(...)`, `locations_volumes_list(...)`, `locations_volumes_luns_evict(...)`, `locations_volumes_luns_get(...)`, `locations_volumes_luns_list(...)`, `locations_volumes_patch(...)`, `locations_volumes_rename(...)`, `locations_volumes_resize(...)`, `locations_volumes_snapshots_create(...)`, `locations_volumes_snapshots_delete(...)`, `locations_volumes_snapshots_get(...)`, `locations_volumes_snapshots_list(...)` and `locations_volumes_snapshots_restore_volume_snapshot(...)`
1955/// // to build up your call.
1956/// let rb = hub.projects();
1957/// # }
1958/// ```
1959pub struct ProjectMethods<'a, C>
1960where
1961    C: 'a,
1962{
1963    hub: &'a Baremetalsolution<C>,
1964}
1965
1966impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1967
1968impl<'a, C> ProjectMethods<'a, C> {
1969    /// Create a builder to help you perform the following task:
1970    ///
1971    /// Detach LUN from Instance.
1972    ///
1973    /// # Arguments
1974    ///
1975    /// * `request` - No description provided.
1976    /// * `instance` - Required. Name of the instance.
1977    pub fn locations_instances_detach_lun(
1978        &self,
1979        request: DetachLunRequest,
1980        instance: &str,
1981    ) -> ProjectLocationInstanceDetachLunCall<'a, C> {
1982        ProjectLocationInstanceDetachLunCall {
1983            hub: self.hub,
1984            _request: request,
1985            _instance: instance.to_string(),
1986            _delegate: Default::default(),
1987            _additional_params: Default::default(),
1988            _scopes: Default::default(),
1989        }
1990    }
1991
1992    /// Create a builder to help you perform the following task:
1993    ///
1994    /// Perform disable hyperthreading operation on a single server.
1995    ///
1996    /// # Arguments
1997    ///
1998    /// * `request` - No description provided.
1999    /// * `name` - Required. The `name` field is used to identify the instance. Format: projects/{project}/locations/{location}/instances/{instance}
2000    pub fn locations_instances_disable_hyperthreading(
2001        &self,
2002        request: DisableHyperthreadingRequest,
2003        name: &str,
2004    ) -> ProjectLocationInstanceDisableHyperthreadingCall<'a, C> {
2005        ProjectLocationInstanceDisableHyperthreadingCall {
2006            hub: self.hub,
2007            _request: request,
2008            _name: name.to_string(),
2009            _delegate: Default::default(),
2010            _additional_params: Default::default(),
2011            _scopes: Default::default(),
2012        }
2013    }
2014
2015    /// Create a builder to help you perform the following task:
2016    ///
2017    /// Disable the interactive serial console feature on an instance.
2018    ///
2019    /// # Arguments
2020    ///
2021    /// * `request` - No description provided.
2022    /// * `name` - Required. Name of the resource.
2023    pub fn locations_instances_disable_interactive_serial_console(
2024        &self,
2025        request: DisableInteractiveSerialConsoleRequest,
2026        name: &str,
2027    ) -> ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C> {
2028        ProjectLocationInstanceDisableInteractiveSerialConsoleCall {
2029            hub: self.hub,
2030            _request: request,
2031            _name: name.to_string(),
2032            _delegate: Default::default(),
2033            _additional_params: Default::default(),
2034            _scopes: Default::default(),
2035        }
2036    }
2037
2038    /// Create a builder to help you perform the following task:
2039    ///
2040    /// Perform enable hyperthreading operation on a single server.
2041    ///
2042    /// # Arguments
2043    ///
2044    /// * `request` - No description provided.
2045    /// * `name` - Required. The `name` field is used to identify the instance. Format: projects/{project}/locations/{location}/instances/{instance}
2046    pub fn locations_instances_enable_hyperthreading(
2047        &self,
2048        request: EnableHyperthreadingRequest,
2049        name: &str,
2050    ) -> ProjectLocationInstanceEnableHyperthreadingCall<'a, C> {
2051        ProjectLocationInstanceEnableHyperthreadingCall {
2052            hub: self.hub,
2053            _request: request,
2054            _name: name.to_string(),
2055            _delegate: Default::default(),
2056            _additional_params: Default::default(),
2057            _scopes: Default::default(),
2058        }
2059    }
2060
2061    /// Create a builder to help you perform the following task:
2062    ///
2063    /// Enable the interactive serial console feature on an instance.
2064    ///
2065    /// # Arguments
2066    ///
2067    /// * `request` - No description provided.
2068    /// * `name` - Required. Name of the resource.
2069    pub fn locations_instances_enable_interactive_serial_console(
2070        &self,
2071        request: EnableInteractiveSerialConsoleRequest,
2072        name: &str,
2073    ) -> ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'a, C> {
2074        ProjectLocationInstanceEnableInteractiveSerialConsoleCall {
2075            hub: self.hub,
2076            _request: request,
2077            _name: name.to_string(),
2078            _delegate: Default::default(),
2079            _additional_params: Default::default(),
2080            _scopes: Default::default(),
2081        }
2082    }
2083
2084    /// Create a builder to help you perform the following task:
2085    ///
2086    /// Get details about a single server.
2087    ///
2088    /// # Arguments
2089    ///
2090    /// * `name` - Required. Name of the resource.
2091    pub fn locations_instances_get(&self, name: &str) -> ProjectLocationInstanceGetCall<'a, C> {
2092        ProjectLocationInstanceGetCall {
2093            hub: self.hub,
2094            _name: name.to_string(),
2095            _delegate: Default::default(),
2096            _additional_params: Default::default(),
2097            _scopes: Default::default(),
2098        }
2099    }
2100
2101    /// Create a builder to help you perform the following task:
2102    ///
2103    /// List servers in a given project and location.
2104    ///
2105    /// # Arguments
2106    ///
2107    /// * `parent` - Required. Parent value for ListInstancesRequest.
2108    pub fn locations_instances_list(&self, parent: &str) -> ProjectLocationInstanceListCall<'a, C> {
2109        ProjectLocationInstanceListCall {
2110            hub: self.hub,
2111            _parent: parent.to_string(),
2112            _page_token: Default::default(),
2113            _page_size: Default::default(),
2114            _filter: Default::default(),
2115            _delegate: Default::default(),
2116            _additional_params: Default::default(),
2117            _scopes: Default::default(),
2118        }
2119    }
2120
2121    /// Create a builder to help you perform the following task:
2122    ///
2123    /// Load auth info for a server.
2124    ///
2125    /// # Arguments
2126    ///
2127    /// * `name` - Required. Name of the server.
2128    pub fn locations_instances_load_auth_info(
2129        &self,
2130        name: &str,
2131    ) -> ProjectLocationInstanceLoadAuthInfoCall<'a, C> {
2132        ProjectLocationInstanceLoadAuthInfoCall {
2133            hub: self.hub,
2134            _name: name.to_string(),
2135            _delegate: Default::default(),
2136            _additional_params: Default::default(),
2137            _scopes: Default::default(),
2138        }
2139    }
2140
2141    /// Create a builder to help you perform the following task:
2142    ///
2143    /// Update details of a single server.
2144    ///
2145    /// # Arguments
2146    ///
2147    /// * `request` - No description provided.
2148    /// * `name` - Immutable. The resource name of this `Instance`. Resource names are schemeless URIs that follow the conventions in https://cloud.google.com/apis/design/resource_names. Format: `projects/{project}/locations/{location}/instances/{instance}`
2149    pub fn locations_instances_patch(
2150        &self,
2151        request: Instance,
2152        name: &str,
2153    ) -> ProjectLocationInstancePatchCall<'a, C> {
2154        ProjectLocationInstancePatchCall {
2155            hub: self.hub,
2156            _request: request,
2157            _name: name.to_string(),
2158            _update_mask: Default::default(),
2159            _delegate: Default::default(),
2160            _additional_params: Default::default(),
2161            _scopes: Default::default(),
2162        }
2163    }
2164
2165    /// Create a builder to help you perform the following task:
2166    ///
2167    /// Perform reimage operation on a single server.
2168    ///
2169    /// # Arguments
2170    ///
2171    /// * `request` - No description provided.
2172    /// * `name` - Required. The `name` field is used to identify the instance. Format: projects/{project}/locations/{location}/instances/{instance}
2173    pub fn locations_instances_reimage(
2174        &self,
2175        request: ReimageInstanceRequest,
2176        name: &str,
2177    ) -> ProjectLocationInstanceReimageCall<'a, C> {
2178        ProjectLocationInstanceReimageCall {
2179            hub: self.hub,
2180            _request: request,
2181            _name: name.to_string(),
2182            _delegate: Default::default(),
2183            _additional_params: Default::default(),
2184            _scopes: Default::default(),
2185        }
2186    }
2187
2188    /// Create a builder to help you perform the following task:
2189    ///
2190    /// RenameInstance sets a new name for an instance. Use with caution, previous names become immediately invalidated.
2191    ///
2192    /// # Arguments
2193    ///
2194    /// * `request` - No description provided.
2195    /// * `name` - Required. The `name` field is used to identify the instance. Format: projects/{project}/locations/{location}/instances/{instance}
2196    pub fn locations_instances_rename(
2197        &self,
2198        request: RenameInstanceRequest,
2199        name: &str,
2200    ) -> ProjectLocationInstanceRenameCall<'a, C> {
2201        ProjectLocationInstanceRenameCall {
2202            hub: self.hub,
2203            _request: request,
2204            _name: name.to_string(),
2205            _delegate: Default::default(),
2206            _additional_params: Default::default(),
2207            _scopes: Default::default(),
2208        }
2209    }
2210
2211    /// Create a builder to help you perform the following task:
2212    ///
2213    /// Perform an ungraceful, hard reset on a server. Equivalent to shutting the power off and then turning it back on.
2214    ///
2215    /// # Arguments
2216    ///
2217    /// * `request` - No description provided.
2218    /// * `name` - Required. Name of the resource.
2219    pub fn locations_instances_reset(
2220        &self,
2221        request: ResetInstanceRequest,
2222        name: &str,
2223    ) -> ProjectLocationInstanceResetCall<'a, C> {
2224        ProjectLocationInstanceResetCall {
2225            hub: self.hub,
2226            _request: request,
2227            _name: name.to_string(),
2228            _delegate: Default::default(),
2229            _additional_params: Default::default(),
2230            _scopes: Default::default(),
2231        }
2232    }
2233
2234    /// Create a builder to help you perform the following task:
2235    ///
2236    /// Starts a server that was shutdown.
2237    ///
2238    /// # Arguments
2239    ///
2240    /// * `request` - No description provided.
2241    /// * `name` - Required. Name of the resource.
2242    pub fn locations_instances_start(
2243        &self,
2244        request: StartInstanceRequest,
2245        name: &str,
2246    ) -> ProjectLocationInstanceStartCall<'a, C> {
2247        ProjectLocationInstanceStartCall {
2248            hub: self.hub,
2249            _request: request,
2250            _name: name.to_string(),
2251            _delegate: Default::default(),
2252            _additional_params: Default::default(),
2253            _scopes: Default::default(),
2254        }
2255    }
2256
2257    /// Create a builder to help you perform the following task:
2258    ///
2259    /// Stop a running server.
2260    ///
2261    /// # Arguments
2262    ///
2263    /// * `request` - No description provided.
2264    /// * `name` - Required. Name of the resource.
2265    pub fn locations_instances_stop(
2266        &self,
2267        request: StopInstanceRequest,
2268        name: &str,
2269    ) -> ProjectLocationInstanceStopCall<'a, C> {
2270        ProjectLocationInstanceStopCall {
2271            hub: self.hub,
2272            _request: request,
2273            _name: name.to_string(),
2274            _delegate: Default::default(),
2275            _additional_params: Default::default(),
2276            _scopes: Default::default(),
2277        }
2278    }
2279
2280    /// Create a builder to help you perform the following task:
2281    ///
2282    /// Get details of a single network.
2283    ///
2284    /// # Arguments
2285    ///
2286    /// * `name` - Required. Name of the resource.
2287    pub fn locations_networks_get(&self, name: &str) -> ProjectLocationNetworkGetCall<'a, C> {
2288        ProjectLocationNetworkGetCall {
2289            hub: self.hub,
2290            _name: name.to_string(),
2291            _delegate: Default::default(),
2292            _additional_params: Default::default(),
2293            _scopes: Default::default(),
2294        }
2295    }
2296
2297    /// Create a builder to help you perform the following task:
2298    ///
2299    /// List network in a given project and location.
2300    ///
2301    /// # Arguments
2302    ///
2303    /// * `parent` - Required. Parent value for ListNetworksRequest.
2304    pub fn locations_networks_list(&self, parent: &str) -> ProjectLocationNetworkListCall<'a, C> {
2305        ProjectLocationNetworkListCall {
2306            hub: self.hub,
2307            _parent: parent.to_string(),
2308            _page_token: Default::default(),
2309            _page_size: Default::default(),
2310            _filter: Default::default(),
2311            _delegate: Default::default(),
2312            _additional_params: Default::default(),
2313            _scopes: Default::default(),
2314        }
2315    }
2316
2317    /// Create a builder to help you perform the following task:
2318    ///
2319    /// List all Networks (and used IPs for each Network) in the vendor account associated with the specified project.
2320    ///
2321    /// # Arguments
2322    ///
2323    /// * `location` - Required. Parent value (project and location).
2324    pub fn locations_networks_list_network_usage(
2325        &self,
2326        location: &str,
2327    ) -> ProjectLocationNetworkListNetworkUsageCall<'a, C> {
2328        ProjectLocationNetworkListNetworkUsageCall {
2329            hub: self.hub,
2330            _location: location.to_string(),
2331            _delegate: Default::default(),
2332            _additional_params: Default::default(),
2333            _scopes: Default::default(),
2334        }
2335    }
2336
2337    /// Create a builder to help you perform the following task:
2338    ///
2339    /// Update details of a single network.
2340    ///
2341    /// # Arguments
2342    ///
2343    /// * `request` - No description provided.
2344    /// * `name` - Output only. The resource name of this `Network`. Resource names are schemeless URIs that follow the conventions in https://cloud.google.com/apis/design/resource_names. Format: `projects/{project}/locations/{location}/networks/{network}`
2345    pub fn locations_networks_patch(
2346        &self,
2347        request: Network,
2348        name: &str,
2349    ) -> ProjectLocationNetworkPatchCall<'a, C> {
2350        ProjectLocationNetworkPatchCall {
2351            hub: self.hub,
2352            _request: request,
2353            _name: name.to_string(),
2354            _update_mask: Default::default(),
2355            _delegate: Default::default(),
2356            _additional_params: Default::default(),
2357            _scopes: Default::default(),
2358        }
2359    }
2360
2361    /// Create a builder to help you perform the following task:
2362    ///
2363    /// RenameNetwork sets a new name for a network. Use with caution, previous names become immediately invalidated.
2364    ///
2365    /// # Arguments
2366    ///
2367    /// * `request` - No description provided.
2368    /// * `name` - Required. The `name` field is used to identify the network. Format: projects/{project}/locations/{location}/networks/{network}
2369    pub fn locations_networks_rename(
2370        &self,
2371        request: RenameNetworkRequest,
2372        name: &str,
2373    ) -> ProjectLocationNetworkRenameCall<'a, C> {
2374        ProjectLocationNetworkRenameCall {
2375            hub: self.hub,
2376            _request: request,
2377            _name: name.to_string(),
2378            _delegate: Default::default(),
2379            _additional_params: Default::default(),
2380            _scopes: Default::default(),
2381        }
2382    }
2383
2384    /// Create a builder to help you perform the following task:
2385    ///
2386    /// Create an NFS share.
2387    ///
2388    /// # Arguments
2389    ///
2390    /// * `request` - No description provided.
2391    /// * `parent` - Required. The parent project and location.
2392    pub fn locations_nfs_shares_create(
2393        &self,
2394        request: NfsShare,
2395        parent: &str,
2396    ) -> ProjectLocationNfsShareCreateCall<'a, C> {
2397        ProjectLocationNfsShareCreateCall {
2398            hub: self.hub,
2399            _request: request,
2400            _parent: parent.to_string(),
2401            _delegate: Default::default(),
2402            _additional_params: Default::default(),
2403            _scopes: Default::default(),
2404        }
2405    }
2406
2407    /// Create a builder to help you perform the following task:
2408    ///
2409    /// Delete an NFS share. The underlying volume is automatically deleted.
2410    ///
2411    /// # Arguments
2412    ///
2413    /// * `name` - Required. The name of the NFS share to delete.
2414    pub fn locations_nfs_shares_delete(
2415        &self,
2416        name: &str,
2417    ) -> ProjectLocationNfsShareDeleteCall<'a, C> {
2418        ProjectLocationNfsShareDeleteCall {
2419            hub: self.hub,
2420            _name: name.to_string(),
2421            _delegate: Default::default(),
2422            _additional_params: Default::default(),
2423            _scopes: Default::default(),
2424        }
2425    }
2426
2427    /// Create a builder to help you perform the following task:
2428    ///
2429    /// Get details of a single NFS share.
2430    ///
2431    /// # Arguments
2432    ///
2433    /// * `name` - Required. Name of the resource.
2434    pub fn locations_nfs_shares_get(&self, name: &str) -> ProjectLocationNfsShareGetCall<'a, C> {
2435        ProjectLocationNfsShareGetCall {
2436            hub: self.hub,
2437            _name: name.to_string(),
2438            _delegate: Default::default(),
2439            _additional_params: Default::default(),
2440            _scopes: Default::default(),
2441        }
2442    }
2443
2444    /// Create a builder to help you perform the following task:
2445    ///
2446    /// List NFS shares.
2447    ///
2448    /// # Arguments
2449    ///
2450    /// * `parent` - Required. Parent value for ListNfsSharesRequest.
2451    pub fn locations_nfs_shares_list(
2452        &self,
2453        parent: &str,
2454    ) -> ProjectLocationNfsShareListCall<'a, C> {
2455        ProjectLocationNfsShareListCall {
2456            hub: self.hub,
2457            _parent: parent.to_string(),
2458            _page_token: Default::default(),
2459            _page_size: Default::default(),
2460            _filter: Default::default(),
2461            _delegate: Default::default(),
2462            _additional_params: Default::default(),
2463            _scopes: Default::default(),
2464        }
2465    }
2466
2467    /// Create a builder to help you perform the following task:
2468    ///
2469    /// Update details of a single NFS share.
2470    ///
2471    /// # Arguments
2472    ///
2473    /// * `request` - No description provided.
2474    /// * `name` - Immutable. The name of the NFS share.
2475    pub fn locations_nfs_shares_patch(
2476        &self,
2477        request: NfsShare,
2478        name: &str,
2479    ) -> ProjectLocationNfsSharePatchCall<'a, C> {
2480        ProjectLocationNfsSharePatchCall {
2481            hub: self.hub,
2482            _request: request,
2483            _name: name.to_string(),
2484            _update_mask: Default::default(),
2485            _delegate: Default::default(),
2486            _additional_params: Default::default(),
2487            _scopes: Default::default(),
2488        }
2489    }
2490
2491    /// Create a builder to help you perform the following task:
2492    ///
2493    /// RenameNfsShare sets a new name for an nfsshare. Use with caution, previous names become immediately invalidated.
2494    ///
2495    /// # Arguments
2496    ///
2497    /// * `request` - No description provided.
2498    /// * `name` - Required. The `name` field is used to identify the nfsshare. Format: projects/{project}/locations/{location}/nfsshares/{nfsshare}
2499    pub fn locations_nfs_shares_rename(
2500        &self,
2501        request: RenameNfsShareRequest,
2502        name: &str,
2503    ) -> ProjectLocationNfsShareRenameCall<'a, C> {
2504        ProjectLocationNfsShareRenameCall {
2505            hub: self.hub,
2506            _request: request,
2507            _name: name.to_string(),
2508            _delegate: Default::default(),
2509            _additional_params: Default::default(),
2510            _scopes: Default::default(),
2511        }
2512    }
2513
2514    /// Create a builder to help you perform the following task:
2515    ///
2516    /// Get details about an operation.
2517    ///
2518    /// # Arguments
2519    ///
2520    /// * `name` - The name of the operation resource.
2521    pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
2522        ProjectLocationOperationGetCall {
2523            hub: self.hub,
2524            _name: name.to_string(),
2525            _delegate: Default::default(),
2526            _additional_params: Default::default(),
2527            _scopes: Default::default(),
2528        }
2529    }
2530
2531    /// Create a builder to help you perform the following task:
2532    ///
2533    /// Get details of a single OS image.
2534    ///
2535    /// # Arguments
2536    ///
2537    /// * `name` - Required. Name of the OS image.
2538    pub fn locations_os_images_get(&self, name: &str) -> ProjectLocationOsImageGetCall<'a, C> {
2539        ProjectLocationOsImageGetCall {
2540            hub: self.hub,
2541            _name: name.to_string(),
2542            _delegate: Default::default(),
2543            _additional_params: Default::default(),
2544            _scopes: Default::default(),
2545        }
2546    }
2547
2548    /// Create a builder to help you perform the following task:
2549    ///
2550    /// Retrieves the list of OS images which are currently approved.
2551    ///
2552    /// # Arguments
2553    ///
2554    /// * `parent` - Required. Parent value for ListOSImagesRequest.
2555    pub fn locations_os_images_list(&self, parent: &str) -> ProjectLocationOsImageListCall<'a, C> {
2556        ProjectLocationOsImageListCall {
2557            hub: self.hub,
2558            _parent: parent.to_string(),
2559            _page_token: Default::default(),
2560            _page_size: Default::default(),
2561            _delegate: Default::default(),
2562            _additional_params: Default::default(),
2563            _scopes: Default::default(),
2564        }
2565    }
2566
2567    /// Create a builder to help you perform the following task:
2568    ///
2569    /// Create new ProvisioningConfig.
2570    ///
2571    /// # Arguments
2572    ///
2573    /// * `request` - No description provided.
2574    /// * `parent` - Required. The parent project and location containing the ProvisioningConfig.
2575    pub fn locations_provisioning_configs_create(
2576        &self,
2577        request: ProvisioningConfig,
2578        parent: &str,
2579    ) -> ProjectLocationProvisioningConfigCreateCall<'a, C> {
2580        ProjectLocationProvisioningConfigCreateCall {
2581            hub: self.hub,
2582            _request: request,
2583            _parent: parent.to_string(),
2584            _email: Default::default(),
2585            _delegate: Default::default(),
2586            _additional_params: Default::default(),
2587            _scopes: Default::default(),
2588        }
2589    }
2590
2591    /// Create a builder to help you perform the following task:
2592    ///
2593    /// Get ProvisioningConfig by name.
2594    ///
2595    /// # Arguments
2596    ///
2597    /// * `name` - Required. Name of the ProvisioningConfig.
2598    pub fn locations_provisioning_configs_get(
2599        &self,
2600        name: &str,
2601    ) -> ProjectLocationProvisioningConfigGetCall<'a, C> {
2602        ProjectLocationProvisioningConfigGetCall {
2603            hub: self.hub,
2604            _name: name.to_string(),
2605            _delegate: Default::default(),
2606            _additional_params: Default::default(),
2607            _scopes: Default::default(),
2608        }
2609    }
2610
2611    /// Create a builder to help you perform the following task:
2612    ///
2613    /// Update existing ProvisioningConfig.
2614    ///
2615    /// # Arguments
2616    ///
2617    /// * `request` - No description provided.
2618    /// * `name` - Output only. The system-generated name of the provisioning config. This follows the UUID format.
2619    pub fn locations_provisioning_configs_patch(
2620        &self,
2621        request: ProvisioningConfig,
2622        name: &str,
2623    ) -> ProjectLocationProvisioningConfigPatchCall<'a, C> {
2624        ProjectLocationProvisioningConfigPatchCall {
2625            hub: self.hub,
2626            _request: request,
2627            _name: name.to_string(),
2628            _update_mask: Default::default(),
2629            _email: Default::default(),
2630            _delegate: Default::default(),
2631            _additional_params: Default::default(),
2632            _scopes: Default::default(),
2633        }
2634    }
2635
2636    /// Create a builder to help you perform the following task:
2637    ///
2638    /// Submit a provisioning configuration for a given project.
2639    ///
2640    /// # Arguments
2641    ///
2642    /// * `request` - No description provided.
2643    /// * `parent` - Required. The parent project and location containing the ProvisioningConfig.
2644    pub fn locations_provisioning_configs_submit(
2645        &self,
2646        request: SubmitProvisioningConfigRequest,
2647        parent: &str,
2648    ) -> ProjectLocationProvisioningConfigSubmitCall<'a, C> {
2649        ProjectLocationProvisioningConfigSubmitCall {
2650            hub: self.hub,
2651            _request: request,
2652            _parent: parent.to_string(),
2653            _delegate: Default::default(),
2654            _additional_params: Default::default(),
2655            _scopes: Default::default(),
2656        }
2657    }
2658
2659    /// Create a builder to help you perform the following task:
2660    ///
2661    /// List the budget details to provision resources on a given project.
2662    ///
2663    /// # Arguments
2664    ///
2665    /// * `parent` - Required. Parent value for ListProvisioningQuotasRequest.
2666    pub fn locations_provisioning_quotas_list(
2667        &self,
2668        parent: &str,
2669    ) -> ProjectLocationProvisioningQuotaListCall<'a, C> {
2670        ProjectLocationProvisioningQuotaListCall {
2671            hub: self.hub,
2672            _parent: parent.to_string(),
2673            _page_token: Default::default(),
2674            _page_size: Default::default(),
2675            _delegate: Default::default(),
2676            _additional_params: Default::default(),
2677            _scopes: Default::default(),
2678        }
2679    }
2680
2681    /// Create a builder to help you perform the following task:
2682    ///
2683    /// Register a public SSH key in the specified project for use with the interactive serial console feature.
2684    ///
2685    /// # Arguments
2686    ///
2687    /// * `request` - No description provided.
2688    /// * `parent` - Required. The parent containing the SSH keys.
2689    pub fn locations_ssh_keys_create(
2690        &self,
2691        request: SSHKey,
2692        parent: &str,
2693    ) -> ProjectLocationSshKeyCreateCall<'a, C> {
2694        ProjectLocationSshKeyCreateCall {
2695            hub: self.hub,
2696            _request: request,
2697            _parent: parent.to_string(),
2698            _ssh_key_id: Default::default(),
2699            _delegate: Default::default(),
2700            _additional_params: Default::default(),
2701            _scopes: Default::default(),
2702        }
2703    }
2704
2705    /// Create a builder to help you perform the following task:
2706    ///
2707    /// Deletes a public SSH key registered in the specified project.
2708    ///
2709    /// # Arguments
2710    ///
2711    /// * `name` - Required. The name of the SSH key to delete. Currently, the only valid value for the location is "global".
2712    pub fn locations_ssh_keys_delete(&self, name: &str) -> ProjectLocationSshKeyDeleteCall<'a, C> {
2713        ProjectLocationSshKeyDeleteCall {
2714            hub: self.hub,
2715            _name: name.to_string(),
2716            _delegate: Default::default(),
2717            _additional_params: Default::default(),
2718            _scopes: Default::default(),
2719        }
2720    }
2721
2722    /// Create a builder to help you perform the following task:
2723    ///
2724    /// Lists the public SSH keys registered for the specified project. These SSH keys are used only for the interactive serial console feature.
2725    ///
2726    /// # Arguments
2727    ///
2728    /// * `parent` - Required. The parent containing the SSH keys. Currently, the only valid value for the location is "global".
2729    pub fn locations_ssh_keys_list(&self, parent: &str) -> ProjectLocationSshKeyListCall<'a, C> {
2730        ProjectLocationSshKeyListCall {
2731            hub: self.hub,
2732            _parent: parent.to_string(),
2733            _page_token: Default::default(),
2734            _page_size: Default::default(),
2735            _delegate: Default::default(),
2736            _additional_params: Default::default(),
2737            _scopes: Default::default(),
2738        }
2739    }
2740
2741    /// Create a builder to help you perform the following task:
2742    ///
2743    /// Skips lun's cooloff and deletes it now. Lun must be in cooloff state.
2744    ///
2745    /// # Arguments
2746    ///
2747    /// * `request` - No description provided.
2748    /// * `name` - Required. The name of the lun.
2749    pub fn locations_volumes_luns_evict(
2750        &self,
2751        request: EvictLunRequest,
2752        name: &str,
2753    ) -> ProjectLocationVolumeLunEvictCall<'a, C> {
2754        ProjectLocationVolumeLunEvictCall {
2755            hub: self.hub,
2756            _request: request,
2757            _name: name.to_string(),
2758            _delegate: Default::default(),
2759            _additional_params: Default::default(),
2760            _scopes: Default::default(),
2761        }
2762    }
2763
2764    /// Create a builder to help you perform the following task:
2765    ///
2766    /// Get details of a single storage logical unit number(LUN).
2767    ///
2768    /// # Arguments
2769    ///
2770    /// * `name` - Required. Name of the resource.
2771    pub fn locations_volumes_luns_get(&self, name: &str) -> ProjectLocationVolumeLunGetCall<'a, C> {
2772        ProjectLocationVolumeLunGetCall {
2773            hub: self.hub,
2774            _name: name.to_string(),
2775            _delegate: Default::default(),
2776            _additional_params: Default::default(),
2777            _scopes: Default::default(),
2778        }
2779    }
2780
2781    /// Create a builder to help you perform the following task:
2782    ///
2783    /// List storage volume luns for given storage volume.
2784    ///
2785    /// # Arguments
2786    ///
2787    /// * `parent` - Required. Parent value for ListLunsRequest.
2788    pub fn locations_volumes_luns_list(
2789        &self,
2790        parent: &str,
2791    ) -> ProjectLocationVolumeLunListCall<'a, C> {
2792        ProjectLocationVolumeLunListCall {
2793            hub: self.hub,
2794            _parent: parent.to_string(),
2795            _page_token: Default::default(),
2796            _page_size: Default::default(),
2797            _delegate: Default::default(),
2798            _additional_params: Default::default(),
2799            _scopes: Default::default(),
2800        }
2801    }
2802
2803    /// Create a builder to help you perform the following task:
2804    ///
2805    /// Takes a snapshot of a boot volume. Returns INVALID_ARGUMENT if called for a non-boot volume.
2806    ///
2807    /// # Arguments
2808    ///
2809    /// * `request` - No description provided.
2810    /// * `parent` - Required. The volume to snapshot.
2811    pub fn locations_volumes_snapshots_create(
2812        &self,
2813        request: VolumeSnapshot,
2814        parent: &str,
2815    ) -> ProjectLocationVolumeSnapshotCreateCall<'a, C> {
2816        ProjectLocationVolumeSnapshotCreateCall {
2817            hub: self.hub,
2818            _request: request,
2819            _parent: parent.to_string(),
2820            _delegate: Default::default(),
2821            _additional_params: Default::default(),
2822            _scopes: Default::default(),
2823        }
2824    }
2825
2826    /// Create a builder to help you perform the following task:
2827    ///
2828    /// Deletes a volume snapshot. Returns INVALID_ARGUMENT if called for a non-boot volume.
2829    ///
2830    /// # Arguments
2831    ///
2832    /// * `name` - Required. The name of the snapshot to delete.
2833    pub fn locations_volumes_snapshots_delete(
2834        &self,
2835        name: &str,
2836    ) -> ProjectLocationVolumeSnapshotDeleteCall<'a, C> {
2837        ProjectLocationVolumeSnapshotDeleteCall {
2838            hub: self.hub,
2839            _name: name.to_string(),
2840            _delegate: Default::default(),
2841            _additional_params: Default::default(),
2842            _scopes: Default::default(),
2843        }
2844    }
2845
2846    /// Create a builder to help you perform the following task:
2847    ///
2848    /// Returns the specified snapshot resource. Returns INVALID_ARGUMENT if called for a non-boot volume.
2849    ///
2850    /// # Arguments
2851    ///
2852    /// * `name` - Required. The name of the snapshot.
2853    pub fn locations_volumes_snapshots_get(
2854        &self,
2855        name: &str,
2856    ) -> ProjectLocationVolumeSnapshotGetCall<'a, C> {
2857        ProjectLocationVolumeSnapshotGetCall {
2858            hub: self.hub,
2859            _name: name.to_string(),
2860            _delegate: Default::default(),
2861            _additional_params: Default::default(),
2862            _scopes: Default::default(),
2863        }
2864    }
2865
2866    /// Create a builder to help you perform the following task:
2867    ///
2868    /// Retrieves the list of snapshots for the specified volume. Returns a response with an empty list of snapshots if called for a non-boot volume.
2869    ///
2870    /// # Arguments
2871    ///
2872    /// * `parent` - Required. Parent value for ListVolumesRequest.
2873    pub fn locations_volumes_snapshots_list(
2874        &self,
2875        parent: &str,
2876    ) -> ProjectLocationVolumeSnapshotListCall<'a, C> {
2877        ProjectLocationVolumeSnapshotListCall {
2878            hub: self.hub,
2879            _parent: parent.to_string(),
2880            _page_token: Default::default(),
2881            _page_size: Default::default(),
2882            _delegate: Default::default(),
2883            _additional_params: Default::default(),
2884            _scopes: Default::default(),
2885        }
2886    }
2887
2888    /// Create a builder to help you perform the following task:
2889    ///
2890    /// Uses the specified snapshot to restore its parent volume. Returns INVALID_ARGUMENT if called for a non-boot volume.
2891    ///
2892    /// # Arguments
2893    ///
2894    /// * `request` - No description provided.
2895    /// * `volumeSnapshot` - Required. Name of the snapshot which will be used to restore its parent volume.
2896    pub fn locations_volumes_snapshots_restore_volume_snapshot(
2897        &self,
2898        request: RestoreVolumeSnapshotRequest,
2899        volume_snapshot: &str,
2900    ) -> ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C> {
2901        ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall {
2902            hub: self.hub,
2903            _request: request,
2904            _volume_snapshot: volume_snapshot.to_string(),
2905            _delegate: Default::default(),
2906            _additional_params: Default::default(),
2907            _scopes: Default::default(),
2908        }
2909    }
2910
2911    /// Create a builder to help you perform the following task:
2912    ///
2913    /// Skips volume's cooloff and deletes it now. Volume must be in cooloff state.
2914    ///
2915    /// # Arguments
2916    ///
2917    /// * `request` - No description provided.
2918    /// * `name` - Required. The name of the Volume.
2919    pub fn locations_volumes_evict(
2920        &self,
2921        request: EvictVolumeRequest,
2922        name: &str,
2923    ) -> ProjectLocationVolumeEvictCall<'a, C> {
2924        ProjectLocationVolumeEvictCall {
2925            hub: self.hub,
2926            _request: request,
2927            _name: name.to_string(),
2928            _delegate: Default::default(),
2929            _additional_params: Default::default(),
2930            _scopes: Default::default(),
2931        }
2932    }
2933
2934    /// Create a builder to help you perform the following task:
2935    ///
2936    /// Get details of a single storage volume.
2937    ///
2938    /// # Arguments
2939    ///
2940    /// * `name` - Required. Name of the resource.
2941    pub fn locations_volumes_get(&self, name: &str) -> ProjectLocationVolumeGetCall<'a, C> {
2942        ProjectLocationVolumeGetCall {
2943            hub: self.hub,
2944            _name: name.to_string(),
2945            _delegate: Default::default(),
2946            _additional_params: Default::default(),
2947            _scopes: Default::default(),
2948        }
2949    }
2950
2951    /// Create a builder to help you perform the following task:
2952    ///
2953    /// List storage volumes in a given project and location.
2954    ///
2955    /// # Arguments
2956    ///
2957    /// * `parent` - Required. Parent value for ListVolumesRequest.
2958    pub fn locations_volumes_list(&self, parent: &str) -> ProjectLocationVolumeListCall<'a, C> {
2959        ProjectLocationVolumeListCall {
2960            hub: self.hub,
2961            _parent: parent.to_string(),
2962            _page_token: Default::default(),
2963            _page_size: Default::default(),
2964            _filter: Default::default(),
2965            _delegate: Default::default(),
2966            _additional_params: Default::default(),
2967            _scopes: Default::default(),
2968        }
2969    }
2970
2971    /// Create a builder to help you perform the following task:
2972    ///
2973    /// Update details of a single storage volume.
2974    ///
2975    /// # Arguments
2976    ///
2977    /// * `request` - No description provided.
2978    /// * `name` - Output only. The resource name of this `Volume`. Resource names are schemeless URIs that follow the conventions in https://cloud.google.com/apis/design/resource_names. Format: `projects/{project}/locations/{location}/volumes/{volume}`
2979    pub fn locations_volumes_patch(
2980        &self,
2981        request: Volume,
2982        name: &str,
2983    ) -> ProjectLocationVolumePatchCall<'a, C> {
2984        ProjectLocationVolumePatchCall {
2985            hub: self.hub,
2986            _request: request,
2987            _name: name.to_string(),
2988            _update_mask: Default::default(),
2989            _delegate: Default::default(),
2990            _additional_params: Default::default(),
2991            _scopes: Default::default(),
2992        }
2993    }
2994
2995    /// Create a builder to help you perform the following task:
2996    ///
2997    /// RenameVolume sets a new name for a volume. Use with caution, previous names become immediately invalidated.
2998    ///
2999    /// # Arguments
3000    ///
3001    /// * `request` - No description provided.
3002    /// * `name` - Required. The `name` field is used to identify the volume. Format: projects/{project}/locations/{location}/volumes/{volume}
3003    pub fn locations_volumes_rename(
3004        &self,
3005        request: RenameVolumeRequest,
3006        name: &str,
3007    ) -> ProjectLocationVolumeRenameCall<'a, C> {
3008        ProjectLocationVolumeRenameCall {
3009            hub: self.hub,
3010            _request: request,
3011            _name: name.to_string(),
3012            _delegate: Default::default(),
3013            _additional_params: Default::default(),
3014            _scopes: Default::default(),
3015        }
3016    }
3017
3018    /// Create a builder to help you perform the following task:
3019    ///
3020    /// Emergency Volume resize.
3021    ///
3022    /// # Arguments
3023    ///
3024    /// * `request` - No description provided.
3025    /// * `volume` - Required. Volume to resize.
3026    pub fn locations_volumes_resize(
3027        &self,
3028        request: ResizeVolumeRequest,
3029        volume: &str,
3030    ) -> ProjectLocationVolumeResizeCall<'a, C> {
3031        ProjectLocationVolumeResizeCall {
3032            hub: self.hub,
3033            _request: request,
3034            _volume: volume.to_string(),
3035            _delegate: Default::default(),
3036            _additional_params: Default::default(),
3037            _scopes: Default::default(),
3038        }
3039    }
3040
3041    /// Create a builder to help you perform the following task:
3042    ///
3043    /// Gets information about a location.
3044    ///
3045    /// # Arguments
3046    ///
3047    /// * `name` - Resource name for the location.
3048    pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
3049        ProjectLocationGetCall {
3050            hub: self.hub,
3051            _name: name.to_string(),
3052            _delegate: Default::default(),
3053            _additional_params: Default::default(),
3054            _scopes: Default::default(),
3055        }
3056    }
3057
3058    /// Create a builder to help you perform the following task:
3059    ///
3060    /// Lists information about the supported locations for this service.
3061    ///
3062    /// # Arguments
3063    ///
3064    /// * `name` - The resource that owns the locations collection, if applicable.
3065    pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
3066        ProjectLocationListCall {
3067            hub: self.hub,
3068            _name: name.to_string(),
3069            _page_token: Default::default(),
3070            _page_size: Default::default(),
3071            _filter: Default::default(),
3072            _extra_location_types: Default::default(),
3073            _delegate: Default::default(),
3074            _additional_params: Default::default(),
3075            _scopes: Default::default(),
3076        }
3077    }
3078}
3079
3080// ###################
3081// CallBuilders   ###
3082// #################
3083
3084/// Detach LUN from Instance.
3085///
3086/// A builder for the *locations.instances.detachLun* method supported by a *project* resource.
3087/// It is not used directly, but through a [`ProjectMethods`] instance.
3088///
3089/// # Example
3090///
3091/// Instantiate a resource method builder
3092///
3093/// ```test_harness,no_run
3094/// # extern crate hyper;
3095/// # extern crate hyper_rustls;
3096/// # extern crate google_baremetalsolution2 as baremetalsolution2;
3097/// use baremetalsolution2::api::DetachLunRequest;
3098/// # async fn dox() {
3099/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3100///
3101/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3102/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3103/// #     .with_native_roots()
3104/// #     .unwrap()
3105/// #     .https_only()
3106/// #     .enable_http2()
3107/// #     .build();
3108///
3109/// # let executor = hyper_util::rt::TokioExecutor::new();
3110/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3111/// #     secret,
3112/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3113/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3114/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3115/// #     ),
3116/// # ).build().await.unwrap();
3117///
3118/// # let client = hyper_util::client::legacy::Client::builder(
3119/// #     hyper_util::rt::TokioExecutor::new()
3120/// # )
3121/// # .build(
3122/// #     hyper_rustls::HttpsConnectorBuilder::new()
3123/// #         .with_native_roots()
3124/// #         .unwrap()
3125/// #         .https_or_http()
3126/// #         .enable_http2()
3127/// #         .build()
3128/// # );
3129/// # let mut hub = Baremetalsolution::new(client, auth);
3130/// // As the method needs a request, you would usually fill it with the desired information
3131/// // into the respective structure. Some of the parts shown here might not be applicable !
3132/// // Values shown here are possibly random and not representative !
3133/// let mut req = DetachLunRequest::default();
3134///
3135/// // You can configure optional parameters by calling the respective setters at will, and
3136/// // execute the final call using `doit()`.
3137/// // Values shown here are possibly random and not representative !
3138/// let result = hub.projects().locations_instances_detach_lun(req, "instance")
3139///              .doit().await;
3140/// # }
3141/// ```
3142pub struct ProjectLocationInstanceDetachLunCall<'a, C>
3143where
3144    C: 'a,
3145{
3146    hub: &'a Baremetalsolution<C>,
3147    _request: DetachLunRequest,
3148    _instance: String,
3149    _delegate: Option<&'a mut dyn common::Delegate>,
3150    _additional_params: HashMap<String, String>,
3151    _scopes: BTreeSet<String>,
3152}
3153
3154impl<'a, C> common::CallBuilder for ProjectLocationInstanceDetachLunCall<'a, C> {}
3155
3156impl<'a, C> ProjectLocationInstanceDetachLunCall<'a, C>
3157where
3158    C: common::Connector,
3159{
3160    /// Perform the operation you have build so far.
3161    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3162        use std::borrow::Cow;
3163        use std::io::{Read, Seek};
3164
3165        use common::{url::Params, ToParts};
3166        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3167
3168        let mut dd = common::DefaultDelegate;
3169        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3170        dlg.begin(common::MethodInfo {
3171            id: "baremetalsolution.projects.locations.instances.detachLun",
3172            http_method: hyper::Method::POST,
3173        });
3174
3175        for &field in ["alt", "instance"].iter() {
3176            if self._additional_params.contains_key(field) {
3177                dlg.finished(false);
3178                return Err(common::Error::FieldClash(field));
3179            }
3180        }
3181
3182        let mut params = Params::with_capacity(4 + self._additional_params.len());
3183        params.push("instance", self._instance);
3184
3185        params.extend(self._additional_params.iter());
3186
3187        params.push("alt", "json");
3188        let mut url = self.hub._base_url.clone() + "v2/{+instance}:detachLun";
3189        if self._scopes.is_empty() {
3190            self._scopes
3191                .insert(Scope::CloudPlatform.as_ref().to_string());
3192        }
3193
3194        #[allow(clippy::single_element_loop)]
3195        for &(find_this, param_name) in [("{+instance}", "instance")].iter() {
3196            url = params.uri_replacement(url, param_name, find_this, true);
3197        }
3198        {
3199            let to_remove = ["instance"];
3200            params.remove_params(&to_remove);
3201        }
3202
3203        let url = params.parse_with_url(&url);
3204
3205        let mut json_mime_type = mime::APPLICATION_JSON;
3206        let mut request_value_reader = {
3207            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3208            common::remove_json_null_values(&mut value);
3209            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3210            serde_json::to_writer(&mut dst, &value).unwrap();
3211            dst
3212        };
3213        let request_size = request_value_reader
3214            .seek(std::io::SeekFrom::End(0))
3215            .unwrap();
3216        request_value_reader
3217            .seek(std::io::SeekFrom::Start(0))
3218            .unwrap();
3219
3220        loop {
3221            let token = match self
3222                .hub
3223                .auth
3224                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3225                .await
3226            {
3227                Ok(token) => token,
3228                Err(e) => match dlg.token(e) {
3229                    Ok(token) => token,
3230                    Err(e) => {
3231                        dlg.finished(false);
3232                        return Err(common::Error::MissingToken(e));
3233                    }
3234                },
3235            };
3236            request_value_reader
3237                .seek(std::io::SeekFrom::Start(0))
3238                .unwrap();
3239            let mut req_result = {
3240                let client = &self.hub.client;
3241                dlg.pre_request();
3242                let mut req_builder = hyper::Request::builder()
3243                    .method(hyper::Method::POST)
3244                    .uri(url.as_str())
3245                    .header(USER_AGENT, self.hub._user_agent.clone());
3246
3247                if let Some(token) = token.as_ref() {
3248                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3249                }
3250
3251                let request = req_builder
3252                    .header(CONTENT_TYPE, json_mime_type.to_string())
3253                    .header(CONTENT_LENGTH, request_size as u64)
3254                    .body(common::to_body(
3255                        request_value_reader.get_ref().clone().into(),
3256                    ));
3257
3258                client.request(request.unwrap()).await
3259            };
3260
3261            match req_result {
3262                Err(err) => {
3263                    if let common::Retry::After(d) = dlg.http_error(&err) {
3264                        sleep(d).await;
3265                        continue;
3266                    }
3267                    dlg.finished(false);
3268                    return Err(common::Error::HttpError(err));
3269                }
3270                Ok(res) => {
3271                    let (mut parts, body) = res.into_parts();
3272                    let mut body = common::Body::new(body);
3273                    if !parts.status.is_success() {
3274                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3275                        let error = serde_json::from_str(&common::to_string(&bytes));
3276                        let response = common::to_response(parts, bytes.into());
3277
3278                        if let common::Retry::After(d) =
3279                            dlg.http_failure(&response, error.as_ref().ok())
3280                        {
3281                            sleep(d).await;
3282                            continue;
3283                        }
3284
3285                        dlg.finished(false);
3286
3287                        return Err(match error {
3288                            Ok(value) => common::Error::BadRequest(value),
3289                            _ => common::Error::Failure(response),
3290                        });
3291                    }
3292                    let response = {
3293                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3294                        let encoded = common::to_string(&bytes);
3295                        match serde_json::from_str(&encoded) {
3296                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3297                            Err(error) => {
3298                                dlg.response_json_decode_error(&encoded, &error);
3299                                return Err(common::Error::JsonDecodeError(
3300                                    encoded.to_string(),
3301                                    error,
3302                                ));
3303                            }
3304                        }
3305                    };
3306
3307                    dlg.finished(true);
3308                    return Ok(response);
3309                }
3310            }
3311        }
3312    }
3313
3314    ///
3315    /// Sets the *request* property to the given value.
3316    ///
3317    /// Even though the property as already been set when instantiating this call,
3318    /// we provide this method for API completeness.
3319    pub fn request(
3320        mut self,
3321        new_value: DetachLunRequest,
3322    ) -> ProjectLocationInstanceDetachLunCall<'a, C> {
3323        self._request = new_value;
3324        self
3325    }
3326    /// Required. Name of the instance.
3327    ///
3328    /// Sets the *instance* path property to the given value.
3329    ///
3330    /// Even though the property as already been set when instantiating this call,
3331    /// we provide this method for API completeness.
3332    pub fn instance(mut self, new_value: &str) -> ProjectLocationInstanceDetachLunCall<'a, C> {
3333        self._instance = new_value.to_string();
3334        self
3335    }
3336    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3337    /// while executing the actual API request.
3338    ///
3339    /// ````text
3340    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3341    /// ````
3342    ///
3343    /// Sets the *delegate* property to the given value.
3344    pub fn delegate(
3345        mut self,
3346        new_value: &'a mut dyn common::Delegate,
3347    ) -> ProjectLocationInstanceDetachLunCall<'a, C> {
3348        self._delegate = Some(new_value);
3349        self
3350    }
3351
3352    /// Set any additional parameter of the query string used in the request.
3353    /// It should be used to set parameters which are not yet available through their own
3354    /// setters.
3355    ///
3356    /// Please note that this method must not be used to set any of the known parameters
3357    /// which have their own setter method. If done anyway, the request will fail.
3358    ///
3359    /// # Additional Parameters
3360    ///
3361    /// * *$.xgafv* (query-string) - V1 error format.
3362    /// * *access_token* (query-string) - OAuth access token.
3363    /// * *alt* (query-string) - Data format for response.
3364    /// * *callback* (query-string) - JSONP
3365    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3366    /// * *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.
3367    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3368    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3369    /// * *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.
3370    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3371    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3372    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceDetachLunCall<'a, C>
3373    where
3374        T: AsRef<str>,
3375    {
3376        self._additional_params
3377            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3378        self
3379    }
3380
3381    /// Identifies the authorization scope for the method you are building.
3382    ///
3383    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3384    /// [`Scope::CloudPlatform`].
3385    ///
3386    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3387    /// tokens for more than one scope.
3388    ///
3389    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3390    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3391    /// sufficient, a read-write scope will do as well.
3392    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceDetachLunCall<'a, C>
3393    where
3394        St: AsRef<str>,
3395    {
3396        self._scopes.insert(String::from(scope.as_ref()));
3397        self
3398    }
3399    /// Identifies the authorization scope(s) for the method you are building.
3400    ///
3401    /// See [`Self::add_scope()`] for details.
3402    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceDetachLunCall<'a, C>
3403    where
3404        I: IntoIterator<Item = St>,
3405        St: AsRef<str>,
3406    {
3407        self._scopes
3408            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3409        self
3410    }
3411
3412    /// Removes all scopes, and no default scope will be used either.
3413    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3414    /// for details).
3415    pub fn clear_scopes(mut self) -> ProjectLocationInstanceDetachLunCall<'a, C> {
3416        self._scopes.clear();
3417        self
3418    }
3419}
3420
3421/// Perform disable hyperthreading operation on a single server.
3422///
3423/// A builder for the *locations.instances.disableHyperthreading* method supported by a *project* resource.
3424/// It is not used directly, but through a [`ProjectMethods`] instance.
3425///
3426/// # Example
3427///
3428/// Instantiate a resource method builder
3429///
3430/// ```test_harness,no_run
3431/// # extern crate hyper;
3432/// # extern crate hyper_rustls;
3433/// # extern crate google_baremetalsolution2 as baremetalsolution2;
3434/// use baremetalsolution2::api::DisableHyperthreadingRequest;
3435/// # async fn dox() {
3436/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3437///
3438/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3439/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3440/// #     .with_native_roots()
3441/// #     .unwrap()
3442/// #     .https_only()
3443/// #     .enable_http2()
3444/// #     .build();
3445///
3446/// # let executor = hyper_util::rt::TokioExecutor::new();
3447/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3448/// #     secret,
3449/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3450/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3451/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3452/// #     ),
3453/// # ).build().await.unwrap();
3454///
3455/// # let client = hyper_util::client::legacy::Client::builder(
3456/// #     hyper_util::rt::TokioExecutor::new()
3457/// # )
3458/// # .build(
3459/// #     hyper_rustls::HttpsConnectorBuilder::new()
3460/// #         .with_native_roots()
3461/// #         .unwrap()
3462/// #         .https_or_http()
3463/// #         .enable_http2()
3464/// #         .build()
3465/// # );
3466/// # let mut hub = Baremetalsolution::new(client, auth);
3467/// // As the method needs a request, you would usually fill it with the desired information
3468/// // into the respective structure. Some of the parts shown here might not be applicable !
3469/// // Values shown here are possibly random and not representative !
3470/// let mut req = DisableHyperthreadingRequest::default();
3471///
3472/// // You can configure optional parameters by calling the respective setters at will, and
3473/// // execute the final call using `doit()`.
3474/// // Values shown here are possibly random and not representative !
3475/// let result = hub.projects().locations_instances_disable_hyperthreading(req, "name")
3476///              .doit().await;
3477/// # }
3478/// ```
3479pub struct ProjectLocationInstanceDisableHyperthreadingCall<'a, C>
3480where
3481    C: 'a,
3482{
3483    hub: &'a Baremetalsolution<C>,
3484    _request: DisableHyperthreadingRequest,
3485    _name: String,
3486    _delegate: Option<&'a mut dyn common::Delegate>,
3487    _additional_params: HashMap<String, String>,
3488    _scopes: BTreeSet<String>,
3489}
3490
3491impl<'a, C> common::CallBuilder for ProjectLocationInstanceDisableHyperthreadingCall<'a, C> {}
3492
3493impl<'a, C> ProjectLocationInstanceDisableHyperthreadingCall<'a, C>
3494where
3495    C: common::Connector,
3496{
3497    /// Perform the operation you have build so far.
3498    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3499        use std::borrow::Cow;
3500        use std::io::{Read, Seek};
3501
3502        use common::{url::Params, ToParts};
3503        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3504
3505        let mut dd = common::DefaultDelegate;
3506        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3507        dlg.begin(common::MethodInfo {
3508            id: "baremetalsolution.projects.locations.instances.disableHyperthreading",
3509            http_method: hyper::Method::POST,
3510        });
3511
3512        for &field in ["alt", "name"].iter() {
3513            if self._additional_params.contains_key(field) {
3514                dlg.finished(false);
3515                return Err(common::Error::FieldClash(field));
3516            }
3517        }
3518
3519        let mut params = Params::with_capacity(4 + self._additional_params.len());
3520        params.push("name", self._name);
3521
3522        params.extend(self._additional_params.iter());
3523
3524        params.push("alt", "json");
3525        let mut url = self.hub._base_url.clone() + "v2/{+name}:disableHyperthreading";
3526        if self._scopes.is_empty() {
3527            self._scopes
3528                .insert(Scope::CloudPlatform.as_ref().to_string());
3529        }
3530
3531        #[allow(clippy::single_element_loop)]
3532        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3533            url = params.uri_replacement(url, param_name, find_this, true);
3534        }
3535        {
3536            let to_remove = ["name"];
3537            params.remove_params(&to_remove);
3538        }
3539
3540        let url = params.parse_with_url(&url);
3541
3542        let mut json_mime_type = mime::APPLICATION_JSON;
3543        let mut request_value_reader = {
3544            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3545            common::remove_json_null_values(&mut value);
3546            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3547            serde_json::to_writer(&mut dst, &value).unwrap();
3548            dst
3549        };
3550        let request_size = request_value_reader
3551            .seek(std::io::SeekFrom::End(0))
3552            .unwrap();
3553        request_value_reader
3554            .seek(std::io::SeekFrom::Start(0))
3555            .unwrap();
3556
3557        loop {
3558            let token = match self
3559                .hub
3560                .auth
3561                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3562                .await
3563            {
3564                Ok(token) => token,
3565                Err(e) => match dlg.token(e) {
3566                    Ok(token) => token,
3567                    Err(e) => {
3568                        dlg.finished(false);
3569                        return Err(common::Error::MissingToken(e));
3570                    }
3571                },
3572            };
3573            request_value_reader
3574                .seek(std::io::SeekFrom::Start(0))
3575                .unwrap();
3576            let mut req_result = {
3577                let client = &self.hub.client;
3578                dlg.pre_request();
3579                let mut req_builder = hyper::Request::builder()
3580                    .method(hyper::Method::POST)
3581                    .uri(url.as_str())
3582                    .header(USER_AGENT, self.hub._user_agent.clone());
3583
3584                if let Some(token) = token.as_ref() {
3585                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3586                }
3587
3588                let request = req_builder
3589                    .header(CONTENT_TYPE, json_mime_type.to_string())
3590                    .header(CONTENT_LENGTH, request_size as u64)
3591                    .body(common::to_body(
3592                        request_value_reader.get_ref().clone().into(),
3593                    ));
3594
3595                client.request(request.unwrap()).await
3596            };
3597
3598            match req_result {
3599                Err(err) => {
3600                    if let common::Retry::After(d) = dlg.http_error(&err) {
3601                        sleep(d).await;
3602                        continue;
3603                    }
3604                    dlg.finished(false);
3605                    return Err(common::Error::HttpError(err));
3606                }
3607                Ok(res) => {
3608                    let (mut parts, body) = res.into_parts();
3609                    let mut body = common::Body::new(body);
3610                    if !parts.status.is_success() {
3611                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3612                        let error = serde_json::from_str(&common::to_string(&bytes));
3613                        let response = common::to_response(parts, bytes.into());
3614
3615                        if let common::Retry::After(d) =
3616                            dlg.http_failure(&response, error.as_ref().ok())
3617                        {
3618                            sleep(d).await;
3619                            continue;
3620                        }
3621
3622                        dlg.finished(false);
3623
3624                        return Err(match error {
3625                            Ok(value) => common::Error::BadRequest(value),
3626                            _ => common::Error::Failure(response),
3627                        });
3628                    }
3629                    let response = {
3630                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3631                        let encoded = common::to_string(&bytes);
3632                        match serde_json::from_str(&encoded) {
3633                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3634                            Err(error) => {
3635                                dlg.response_json_decode_error(&encoded, &error);
3636                                return Err(common::Error::JsonDecodeError(
3637                                    encoded.to_string(),
3638                                    error,
3639                                ));
3640                            }
3641                        }
3642                    };
3643
3644                    dlg.finished(true);
3645                    return Ok(response);
3646                }
3647            }
3648        }
3649    }
3650
3651    ///
3652    /// Sets the *request* property to the given value.
3653    ///
3654    /// Even though the property as already been set when instantiating this call,
3655    /// we provide this method for API completeness.
3656    pub fn request(
3657        mut self,
3658        new_value: DisableHyperthreadingRequest,
3659    ) -> ProjectLocationInstanceDisableHyperthreadingCall<'a, C> {
3660        self._request = new_value;
3661        self
3662    }
3663    /// Required. The `name` field is used to identify the instance. Format: projects/{project}/locations/{location}/instances/{instance}
3664    ///
3665    /// Sets the *name* path property to the given value.
3666    ///
3667    /// Even though the property as already been set when instantiating this call,
3668    /// we provide this method for API completeness.
3669    pub fn name(
3670        mut self,
3671        new_value: &str,
3672    ) -> ProjectLocationInstanceDisableHyperthreadingCall<'a, C> {
3673        self._name = new_value.to_string();
3674        self
3675    }
3676    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3677    /// while executing the actual API request.
3678    ///
3679    /// ````text
3680    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3681    /// ````
3682    ///
3683    /// Sets the *delegate* property to the given value.
3684    pub fn delegate(
3685        mut self,
3686        new_value: &'a mut dyn common::Delegate,
3687    ) -> ProjectLocationInstanceDisableHyperthreadingCall<'a, C> {
3688        self._delegate = Some(new_value);
3689        self
3690    }
3691
3692    /// Set any additional parameter of the query string used in the request.
3693    /// It should be used to set parameters which are not yet available through their own
3694    /// setters.
3695    ///
3696    /// Please note that this method must not be used to set any of the known parameters
3697    /// which have their own setter method. If done anyway, the request will fail.
3698    ///
3699    /// # Additional Parameters
3700    ///
3701    /// * *$.xgafv* (query-string) - V1 error format.
3702    /// * *access_token* (query-string) - OAuth access token.
3703    /// * *alt* (query-string) - Data format for response.
3704    /// * *callback* (query-string) - JSONP
3705    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3706    /// * *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.
3707    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3708    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3709    /// * *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.
3710    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3711    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3712    pub fn param<T>(
3713        mut self,
3714        name: T,
3715        value: T,
3716    ) -> ProjectLocationInstanceDisableHyperthreadingCall<'a, C>
3717    where
3718        T: AsRef<str>,
3719    {
3720        self._additional_params
3721            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3722        self
3723    }
3724
3725    /// Identifies the authorization scope for the method you are building.
3726    ///
3727    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3728    /// [`Scope::CloudPlatform`].
3729    ///
3730    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3731    /// tokens for more than one scope.
3732    ///
3733    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3734    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3735    /// sufficient, a read-write scope will do as well.
3736    pub fn add_scope<St>(
3737        mut self,
3738        scope: St,
3739    ) -> ProjectLocationInstanceDisableHyperthreadingCall<'a, C>
3740    where
3741        St: AsRef<str>,
3742    {
3743        self._scopes.insert(String::from(scope.as_ref()));
3744        self
3745    }
3746    /// Identifies the authorization scope(s) for the method you are building.
3747    ///
3748    /// See [`Self::add_scope()`] for details.
3749    pub fn add_scopes<I, St>(
3750        mut self,
3751        scopes: I,
3752    ) -> ProjectLocationInstanceDisableHyperthreadingCall<'a, C>
3753    where
3754        I: IntoIterator<Item = St>,
3755        St: AsRef<str>,
3756    {
3757        self._scopes
3758            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3759        self
3760    }
3761
3762    /// Removes all scopes, and no default scope will be used either.
3763    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3764    /// for details).
3765    pub fn clear_scopes(mut self) -> ProjectLocationInstanceDisableHyperthreadingCall<'a, C> {
3766        self._scopes.clear();
3767        self
3768    }
3769}
3770
3771/// Disable the interactive serial console feature on an instance.
3772///
3773/// A builder for the *locations.instances.disableInteractiveSerialConsole* method supported by a *project* resource.
3774/// It is not used directly, but through a [`ProjectMethods`] instance.
3775///
3776/// # Example
3777///
3778/// Instantiate a resource method builder
3779///
3780/// ```test_harness,no_run
3781/// # extern crate hyper;
3782/// # extern crate hyper_rustls;
3783/// # extern crate google_baremetalsolution2 as baremetalsolution2;
3784/// use baremetalsolution2::api::DisableInteractiveSerialConsoleRequest;
3785/// # async fn dox() {
3786/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3787///
3788/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3789/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3790/// #     .with_native_roots()
3791/// #     .unwrap()
3792/// #     .https_only()
3793/// #     .enable_http2()
3794/// #     .build();
3795///
3796/// # let executor = hyper_util::rt::TokioExecutor::new();
3797/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3798/// #     secret,
3799/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3800/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3801/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3802/// #     ),
3803/// # ).build().await.unwrap();
3804///
3805/// # let client = hyper_util::client::legacy::Client::builder(
3806/// #     hyper_util::rt::TokioExecutor::new()
3807/// # )
3808/// # .build(
3809/// #     hyper_rustls::HttpsConnectorBuilder::new()
3810/// #         .with_native_roots()
3811/// #         .unwrap()
3812/// #         .https_or_http()
3813/// #         .enable_http2()
3814/// #         .build()
3815/// # );
3816/// # let mut hub = Baremetalsolution::new(client, auth);
3817/// // As the method needs a request, you would usually fill it with the desired information
3818/// // into the respective structure. Some of the parts shown here might not be applicable !
3819/// // Values shown here are possibly random and not representative !
3820/// let mut req = DisableInteractiveSerialConsoleRequest::default();
3821///
3822/// // You can configure optional parameters by calling the respective setters at will, and
3823/// // execute the final call using `doit()`.
3824/// // Values shown here are possibly random and not representative !
3825/// let result = hub.projects().locations_instances_disable_interactive_serial_console(req, "name")
3826///              .doit().await;
3827/// # }
3828/// ```
3829pub struct ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C>
3830where
3831    C: 'a,
3832{
3833    hub: &'a Baremetalsolution<C>,
3834    _request: DisableInteractiveSerialConsoleRequest,
3835    _name: String,
3836    _delegate: Option<&'a mut dyn common::Delegate>,
3837    _additional_params: HashMap<String, String>,
3838    _scopes: BTreeSet<String>,
3839}
3840
3841impl<'a, C> common::CallBuilder
3842    for ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C>
3843{
3844}
3845
3846impl<'a, C> ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C>
3847where
3848    C: common::Connector,
3849{
3850    /// Perform the operation you have build so far.
3851    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3852        use std::borrow::Cow;
3853        use std::io::{Read, Seek};
3854
3855        use common::{url::Params, ToParts};
3856        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3857
3858        let mut dd = common::DefaultDelegate;
3859        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3860        dlg.begin(common::MethodInfo {
3861            id: "baremetalsolution.projects.locations.instances.disableInteractiveSerialConsole",
3862            http_method: hyper::Method::POST,
3863        });
3864
3865        for &field in ["alt", "name"].iter() {
3866            if self._additional_params.contains_key(field) {
3867                dlg.finished(false);
3868                return Err(common::Error::FieldClash(field));
3869            }
3870        }
3871
3872        let mut params = Params::with_capacity(4 + self._additional_params.len());
3873        params.push("name", self._name);
3874
3875        params.extend(self._additional_params.iter());
3876
3877        params.push("alt", "json");
3878        let mut url = self.hub._base_url.clone() + "v2/{+name}:disableInteractiveSerialConsole";
3879        if self._scopes.is_empty() {
3880            self._scopes
3881                .insert(Scope::CloudPlatform.as_ref().to_string());
3882        }
3883
3884        #[allow(clippy::single_element_loop)]
3885        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3886            url = params.uri_replacement(url, param_name, find_this, true);
3887        }
3888        {
3889            let to_remove = ["name"];
3890            params.remove_params(&to_remove);
3891        }
3892
3893        let url = params.parse_with_url(&url);
3894
3895        let mut json_mime_type = mime::APPLICATION_JSON;
3896        let mut request_value_reader = {
3897            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3898            common::remove_json_null_values(&mut value);
3899            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3900            serde_json::to_writer(&mut dst, &value).unwrap();
3901            dst
3902        };
3903        let request_size = request_value_reader
3904            .seek(std::io::SeekFrom::End(0))
3905            .unwrap();
3906        request_value_reader
3907            .seek(std::io::SeekFrom::Start(0))
3908            .unwrap();
3909
3910        loop {
3911            let token = match self
3912                .hub
3913                .auth
3914                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3915                .await
3916            {
3917                Ok(token) => token,
3918                Err(e) => match dlg.token(e) {
3919                    Ok(token) => token,
3920                    Err(e) => {
3921                        dlg.finished(false);
3922                        return Err(common::Error::MissingToken(e));
3923                    }
3924                },
3925            };
3926            request_value_reader
3927                .seek(std::io::SeekFrom::Start(0))
3928                .unwrap();
3929            let mut req_result = {
3930                let client = &self.hub.client;
3931                dlg.pre_request();
3932                let mut req_builder = hyper::Request::builder()
3933                    .method(hyper::Method::POST)
3934                    .uri(url.as_str())
3935                    .header(USER_AGENT, self.hub._user_agent.clone());
3936
3937                if let Some(token) = token.as_ref() {
3938                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3939                }
3940
3941                let request = req_builder
3942                    .header(CONTENT_TYPE, json_mime_type.to_string())
3943                    .header(CONTENT_LENGTH, request_size as u64)
3944                    .body(common::to_body(
3945                        request_value_reader.get_ref().clone().into(),
3946                    ));
3947
3948                client.request(request.unwrap()).await
3949            };
3950
3951            match req_result {
3952                Err(err) => {
3953                    if let common::Retry::After(d) = dlg.http_error(&err) {
3954                        sleep(d).await;
3955                        continue;
3956                    }
3957                    dlg.finished(false);
3958                    return Err(common::Error::HttpError(err));
3959                }
3960                Ok(res) => {
3961                    let (mut parts, body) = res.into_parts();
3962                    let mut body = common::Body::new(body);
3963                    if !parts.status.is_success() {
3964                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3965                        let error = serde_json::from_str(&common::to_string(&bytes));
3966                        let response = common::to_response(parts, bytes.into());
3967
3968                        if let common::Retry::After(d) =
3969                            dlg.http_failure(&response, error.as_ref().ok())
3970                        {
3971                            sleep(d).await;
3972                            continue;
3973                        }
3974
3975                        dlg.finished(false);
3976
3977                        return Err(match error {
3978                            Ok(value) => common::Error::BadRequest(value),
3979                            _ => common::Error::Failure(response),
3980                        });
3981                    }
3982                    let response = {
3983                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3984                        let encoded = common::to_string(&bytes);
3985                        match serde_json::from_str(&encoded) {
3986                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3987                            Err(error) => {
3988                                dlg.response_json_decode_error(&encoded, &error);
3989                                return Err(common::Error::JsonDecodeError(
3990                                    encoded.to_string(),
3991                                    error,
3992                                ));
3993                            }
3994                        }
3995                    };
3996
3997                    dlg.finished(true);
3998                    return Ok(response);
3999                }
4000            }
4001        }
4002    }
4003
4004    ///
4005    /// Sets the *request* property to the given value.
4006    ///
4007    /// Even though the property as already been set when instantiating this call,
4008    /// we provide this method for API completeness.
4009    pub fn request(
4010        mut self,
4011        new_value: DisableInteractiveSerialConsoleRequest,
4012    ) -> ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C> {
4013        self._request = new_value;
4014        self
4015    }
4016    /// Required. Name of the resource.
4017    ///
4018    /// Sets the *name* path property to the given value.
4019    ///
4020    /// Even though the property as already been set when instantiating this call,
4021    /// we provide this method for API completeness.
4022    pub fn name(
4023        mut self,
4024        new_value: &str,
4025    ) -> ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C> {
4026        self._name = new_value.to_string();
4027        self
4028    }
4029    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4030    /// while executing the actual API request.
4031    ///
4032    /// ````text
4033    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4034    /// ````
4035    ///
4036    /// Sets the *delegate* property to the given value.
4037    pub fn delegate(
4038        mut self,
4039        new_value: &'a mut dyn common::Delegate,
4040    ) -> ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C> {
4041        self._delegate = Some(new_value);
4042        self
4043    }
4044
4045    /// Set any additional parameter of the query string used in the request.
4046    /// It should be used to set parameters which are not yet available through their own
4047    /// setters.
4048    ///
4049    /// Please note that this method must not be used to set any of the known parameters
4050    /// which have their own setter method. If done anyway, the request will fail.
4051    ///
4052    /// # Additional Parameters
4053    ///
4054    /// * *$.xgafv* (query-string) - V1 error format.
4055    /// * *access_token* (query-string) - OAuth access token.
4056    /// * *alt* (query-string) - Data format for response.
4057    /// * *callback* (query-string) - JSONP
4058    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4059    /// * *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.
4060    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4061    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4062    /// * *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.
4063    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4064    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4065    pub fn param<T>(
4066        mut self,
4067        name: T,
4068        value: T,
4069    ) -> ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C>
4070    where
4071        T: AsRef<str>,
4072    {
4073        self._additional_params
4074            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4075        self
4076    }
4077
4078    /// Identifies the authorization scope for the method you are building.
4079    ///
4080    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4081    /// [`Scope::CloudPlatform`].
4082    ///
4083    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4084    /// tokens for more than one scope.
4085    ///
4086    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4087    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4088    /// sufficient, a read-write scope will do as well.
4089    pub fn add_scope<St>(
4090        mut self,
4091        scope: St,
4092    ) -> ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C>
4093    where
4094        St: AsRef<str>,
4095    {
4096        self._scopes.insert(String::from(scope.as_ref()));
4097        self
4098    }
4099    /// Identifies the authorization scope(s) for the method you are building.
4100    ///
4101    /// See [`Self::add_scope()`] for details.
4102    pub fn add_scopes<I, St>(
4103        mut self,
4104        scopes: I,
4105    ) -> ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C>
4106    where
4107        I: IntoIterator<Item = St>,
4108        St: AsRef<str>,
4109    {
4110        self._scopes
4111            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4112        self
4113    }
4114
4115    /// Removes all scopes, and no default scope will be used either.
4116    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4117    /// for details).
4118    pub fn clear_scopes(
4119        mut self,
4120    ) -> ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C> {
4121        self._scopes.clear();
4122        self
4123    }
4124}
4125
4126/// Perform enable hyperthreading operation on a single server.
4127///
4128/// A builder for the *locations.instances.enableHyperthreading* method supported by a *project* resource.
4129/// It is not used directly, but through a [`ProjectMethods`] instance.
4130///
4131/// # Example
4132///
4133/// Instantiate a resource method builder
4134///
4135/// ```test_harness,no_run
4136/// # extern crate hyper;
4137/// # extern crate hyper_rustls;
4138/// # extern crate google_baremetalsolution2 as baremetalsolution2;
4139/// use baremetalsolution2::api::EnableHyperthreadingRequest;
4140/// # async fn dox() {
4141/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4142///
4143/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4144/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4145/// #     .with_native_roots()
4146/// #     .unwrap()
4147/// #     .https_only()
4148/// #     .enable_http2()
4149/// #     .build();
4150///
4151/// # let executor = hyper_util::rt::TokioExecutor::new();
4152/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4153/// #     secret,
4154/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4155/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4156/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4157/// #     ),
4158/// # ).build().await.unwrap();
4159///
4160/// # let client = hyper_util::client::legacy::Client::builder(
4161/// #     hyper_util::rt::TokioExecutor::new()
4162/// # )
4163/// # .build(
4164/// #     hyper_rustls::HttpsConnectorBuilder::new()
4165/// #         .with_native_roots()
4166/// #         .unwrap()
4167/// #         .https_or_http()
4168/// #         .enable_http2()
4169/// #         .build()
4170/// # );
4171/// # let mut hub = Baremetalsolution::new(client, auth);
4172/// // As the method needs a request, you would usually fill it with the desired information
4173/// // into the respective structure. Some of the parts shown here might not be applicable !
4174/// // Values shown here are possibly random and not representative !
4175/// let mut req = EnableHyperthreadingRequest::default();
4176///
4177/// // You can configure optional parameters by calling the respective setters at will, and
4178/// // execute the final call using `doit()`.
4179/// // Values shown here are possibly random and not representative !
4180/// let result = hub.projects().locations_instances_enable_hyperthreading(req, "name")
4181///              .doit().await;
4182/// # }
4183/// ```
4184pub struct ProjectLocationInstanceEnableHyperthreadingCall<'a, C>
4185where
4186    C: 'a,
4187{
4188    hub: &'a Baremetalsolution<C>,
4189    _request: EnableHyperthreadingRequest,
4190    _name: String,
4191    _delegate: Option<&'a mut dyn common::Delegate>,
4192    _additional_params: HashMap<String, String>,
4193    _scopes: BTreeSet<String>,
4194}
4195
4196impl<'a, C> common::CallBuilder for ProjectLocationInstanceEnableHyperthreadingCall<'a, C> {}
4197
4198impl<'a, C> ProjectLocationInstanceEnableHyperthreadingCall<'a, C>
4199where
4200    C: common::Connector,
4201{
4202    /// Perform the operation you have build so far.
4203    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4204        use std::borrow::Cow;
4205        use std::io::{Read, Seek};
4206
4207        use common::{url::Params, ToParts};
4208        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4209
4210        let mut dd = common::DefaultDelegate;
4211        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4212        dlg.begin(common::MethodInfo {
4213            id: "baremetalsolution.projects.locations.instances.enableHyperthreading",
4214            http_method: hyper::Method::POST,
4215        });
4216
4217        for &field in ["alt", "name"].iter() {
4218            if self._additional_params.contains_key(field) {
4219                dlg.finished(false);
4220                return Err(common::Error::FieldClash(field));
4221            }
4222        }
4223
4224        let mut params = Params::with_capacity(4 + self._additional_params.len());
4225        params.push("name", self._name);
4226
4227        params.extend(self._additional_params.iter());
4228
4229        params.push("alt", "json");
4230        let mut url = self.hub._base_url.clone() + "v2/{+name}:enableHyperthreading";
4231        if self._scopes.is_empty() {
4232            self._scopes
4233                .insert(Scope::CloudPlatform.as_ref().to_string());
4234        }
4235
4236        #[allow(clippy::single_element_loop)]
4237        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4238            url = params.uri_replacement(url, param_name, find_this, true);
4239        }
4240        {
4241            let to_remove = ["name"];
4242            params.remove_params(&to_remove);
4243        }
4244
4245        let url = params.parse_with_url(&url);
4246
4247        let mut json_mime_type = mime::APPLICATION_JSON;
4248        let mut request_value_reader = {
4249            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4250            common::remove_json_null_values(&mut value);
4251            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4252            serde_json::to_writer(&mut dst, &value).unwrap();
4253            dst
4254        };
4255        let request_size = request_value_reader
4256            .seek(std::io::SeekFrom::End(0))
4257            .unwrap();
4258        request_value_reader
4259            .seek(std::io::SeekFrom::Start(0))
4260            .unwrap();
4261
4262        loop {
4263            let token = match self
4264                .hub
4265                .auth
4266                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4267                .await
4268            {
4269                Ok(token) => token,
4270                Err(e) => match dlg.token(e) {
4271                    Ok(token) => token,
4272                    Err(e) => {
4273                        dlg.finished(false);
4274                        return Err(common::Error::MissingToken(e));
4275                    }
4276                },
4277            };
4278            request_value_reader
4279                .seek(std::io::SeekFrom::Start(0))
4280                .unwrap();
4281            let mut req_result = {
4282                let client = &self.hub.client;
4283                dlg.pre_request();
4284                let mut req_builder = hyper::Request::builder()
4285                    .method(hyper::Method::POST)
4286                    .uri(url.as_str())
4287                    .header(USER_AGENT, self.hub._user_agent.clone());
4288
4289                if let Some(token) = token.as_ref() {
4290                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4291                }
4292
4293                let request = req_builder
4294                    .header(CONTENT_TYPE, json_mime_type.to_string())
4295                    .header(CONTENT_LENGTH, request_size as u64)
4296                    .body(common::to_body(
4297                        request_value_reader.get_ref().clone().into(),
4298                    ));
4299
4300                client.request(request.unwrap()).await
4301            };
4302
4303            match req_result {
4304                Err(err) => {
4305                    if let common::Retry::After(d) = dlg.http_error(&err) {
4306                        sleep(d).await;
4307                        continue;
4308                    }
4309                    dlg.finished(false);
4310                    return Err(common::Error::HttpError(err));
4311                }
4312                Ok(res) => {
4313                    let (mut parts, body) = res.into_parts();
4314                    let mut body = common::Body::new(body);
4315                    if !parts.status.is_success() {
4316                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4317                        let error = serde_json::from_str(&common::to_string(&bytes));
4318                        let response = common::to_response(parts, bytes.into());
4319
4320                        if let common::Retry::After(d) =
4321                            dlg.http_failure(&response, error.as_ref().ok())
4322                        {
4323                            sleep(d).await;
4324                            continue;
4325                        }
4326
4327                        dlg.finished(false);
4328
4329                        return Err(match error {
4330                            Ok(value) => common::Error::BadRequest(value),
4331                            _ => common::Error::Failure(response),
4332                        });
4333                    }
4334                    let response = {
4335                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4336                        let encoded = common::to_string(&bytes);
4337                        match serde_json::from_str(&encoded) {
4338                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4339                            Err(error) => {
4340                                dlg.response_json_decode_error(&encoded, &error);
4341                                return Err(common::Error::JsonDecodeError(
4342                                    encoded.to_string(),
4343                                    error,
4344                                ));
4345                            }
4346                        }
4347                    };
4348
4349                    dlg.finished(true);
4350                    return Ok(response);
4351                }
4352            }
4353        }
4354    }
4355
4356    ///
4357    /// Sets the *request* property to the given value.
4358    ///
4359    /// Even though the property as already been set when instantiating this call,
4360    /// we provide this method for API completeness.
4361    pub fn request(
4362        mut self,
4363        new_value: EnableHyperthreadingRequest,
4364    ) -> ProjectLocationInstanceEnableHyperthreadingCall<'a, C> {
4365        self._request = new_value;
4366        self
4367    }
4368    /// Required. The `name` field is used to identify the instance. Format: projects/{project}/locations/{location}/instances/{instance}
4369    ///
4370    /// Sets the *name* path property to the given value.
4371    ///
4372    /// Even though the property as already been set when instantiating this call,
4373    /// we provide this method for API completeness.
4374    pub fn name(
4375        mut self,
4376        new_value: &str,
4377    ) -> ProjectLocationInstanceEnableHyperthreadingCall<'a, C> {
4378        self._name = new_value.to_string();
4379        self
4380    }
4381    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4382    /// while executing the actual API request.
4383    ///
4384    /// ````text
4385    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4386    /// ````
4387    ///
4388    /// Sets the *delegate* property to the given value.
4389    pub fn delegate(
4390        mut self,
4391        new_value: &'a mut dyn common::Delegate,
4392    ) -> ProjectLocationInstanceEnableHyperthreadingCall<'a, C> {
4393        self._delegate = Some(new_value);
4394        self
4395    }
4396
4397    /// Set any additional parameter of the query string used in the request.
4398    /// It should be used to set parameters which are not yet available through their own
4399    /// setters.
4400    ///
4401    /// Please note that this method must not be used to set any of the known parameters
4402    /// which have their own setter method. If done anyway, the request will fail.
4403    ///
4404    /// # Additional Parameters
4405    ///
4406    /// * *$.xgafv* (query-string) - V1 error format.
4407    /// * *access_token* (query-string) - OAuth access token.
4408    /// * *alt* (query-string) - Data format for response.
4409    /// * *callback* (query-string) - JSONP
4410    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4411    /// * *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.
4412    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4413    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4414    /// * *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.
4415    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4416    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4417    pub fn param<T>(
4418        mut self,
4419        name: T,
4420        value: T,
4421    ) -> ProjectLocationInstanceEnableHyperthreadingCall<'a, C>
4422    where
4423        T: AsRef<str>,
4424    {
4425        self._additional_params
4426            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4427        self
4428    }
4429
4430    /// Identifies the authorization scope for the method you are building.
4431    ///
4432    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4433    /// [`Scope::CloudPlatform`].
4434    ///
4435    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4436    /// tokens for more than one scope.
4437    ///
4438    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4439    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4440    /// sufficient, a read-write scope will do as well.
4441    pub fn add_scope<St>(
4442        mut self,
4443        scope: St,
4444    ) -> ProjectLocationInstanceEnableHyperthreadingCall<'a, C>
4445    where
4446        St: AsRef<str>,
4447    {
4448        self._scopes.insert(String::from(scope.as_ref()));
4449        self
4450    }
4451    /// Identifies the authorization scope(s) for the method you are building.
4452    ///
4453    /// See [`Self::add_scope()`] for details.
4454    pub fn add_scopes<I, St>(
4455        mut self,
4456        scopes: I,
4457    ) -> ProjectLocationInstanceEnableHyperthreadingCall<'a, C>
4458    where
4459        I: IntoIterator<Item = St>,
4460        St: AsRef<str>,
4461    {
4462        self._scopes
4463            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4464        self
4465    }
4466
4467    /// Removes all scopes, and no default scope will be used either.
4468    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4469    /// for details).
4470    pub fn clear_scopes(mut self) -> ProjectLocationInstanceEnableHyperthreadingCall<'a, C> {
4471        self._scopes.clear();
4472        self
4473    }
4474}
4475
4476/// Enable the interactive serial console feature on an instance.
4477///
4478/// A builder for the *locations.instances.enableInteractiveSerialConsole* method supported by a *project* resource.
4479/// It is not used directly, but through a [`ProjectMethods`] instance.
4480///
4481/// # Example
4482///
4483/// Instantiate a resource method builder
4484///
4485/// ```test_harness,no_run
4486/// # extern crate hyper;
4487/// # extern crate hyper_rustls;
4488/// # extern crate google_baremetalsolution2 as baremetalsolution2;
4489/// use baremetalsolution2::api::EnableInteractiveSerialConsoleRequest;
4490/// # async fn dox() {
4491/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4492///
4493/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4494/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4495/// #     .with_native_roots()
4496/// #     .unwrap()
4497/// #     .https_only()
4498/// #     .enable_http2()
4499/// #     .build();
4500///
4501/// # let executor = hyper_util::rt::TokioExecutor::new();
4502/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4503/// #     secret,
4504/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4505/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4506/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4507/// #     ),
4508/// # ).build().await.unwrap();
4509///
4510/// # let client = hyper_util::client::legacy::Client::builder(
4511/// #     hyper_util::rt::TokioExecutor::new()
4512/// # )
4513/// # .build(
4514/// #     hyper_rustls::HttpsConnectorBuilder::new()
4515/// #         .with_native_roots()
4516/// #         .unwrap()
4517/// #         .https_or_http()
4518/// #         .enable_http2()
4519/// #         .build()
4520/// # );
4521/// # let mut hub = Baremetalsolution::new(client, auth);
4522/// // As the method needs a request, you would usually fill it with the desired information
4523/// // into the respective structure. Some of the parts shown here might not be applicable !
4524/// // Values shown here are possibly random and not representative !
4525/// let mut req = EnableInteractiveSerialConsoleRequest::default();
4526///
4527/// // You can configure optional parameters by calling the respective setters at will, and
4528/// // execute the final call using `doit()`.
4529/// // Values shown here are possibly random and not representative !
4530/// let result = hub.projects().locations_instances_enable_interactive_serial_console(req, "name")
4531///              .doit().await;
4532/// # }
4533/// ```
4534pub struct ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'a, C>
4535where
4536    C: 'a,
4537{
4538    hub: &'a Baremetalsolution<C>,
4539    _request: EnableInteractiveSerialConsoleRequest,
4540    _name: String,
4541    _delegate: Option<&'a mut dyn common::Delegate>,
4542    _additional_params: HashMap<String, String>,
4543    _scopes: BTreeSet<String>,
4544}
4545
4546impl<'a, C> common::CallBuilder
4547    for ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'a, C>
4548{
4549}
4550
4551impl<'a, C> ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'a, C>
4552where
4553    C: common::Connector,
4554{
4555    /// Perform the operation you have build so far.
4556    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4557        use std::borrow::Cow;
4558        use std::io::{Read, Seek};
4559
4560        use common::{url::Params, ToParts};
4561        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4562
4563        let mut dd = common::DefaultDelegate;
4564        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4565        dlg.begin(common::MethodInfo {
4566            id: "baremetalsolution.projects.locations.instances.enableInteractiveSerialConsole",
4567            http_method: hyper::Method::POST,
4568        });
4569
4570        for &field in ["alt", "name"].iter() {
4571            if self._additional_params.contains_key(field) {
4572                dlg.finished(false);
4573                return Err(common::Error::FieldClash(field));
4574            }
4575        }
4576
4577        let mut params = Params::with_capacity(4 + self._additional_params.len());
4578        params.push("name", self._name);
4579
4580        params.extend(self._additional_params.iter());
4581
4582        params.push("alt", "json");
4583        let mut url = self.hub._base_url.clone() + "v2/{+name}:enableInteractiveSerialConsole";
4584        if self._scopes.is_empty() {
4585            self._scopes
4586                .insert(Scope::CloudPlatform.as_ref().to_string());
4587        }
4588
4589        #[allow(clippy::single_element_loop)]
4590        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4591            url = params.uri_replacement(url, param_name, find_this, true);
4592        }
4593        {
4594            let to_remove = ["name"];
4595            params.remove_params(&to_remove);
4596        }
4597
4598        let url = params.parse_with_url(&url);
4599
4600        let mut json_mime_type = mime::APPLICATION_JSON;
4601        let mut request_value_reader = {
4602            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4603            common::remove_json_null_values(&mut value);
4604            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4605            serde_json::to_writer(&mut dst, &value).unwrap();
4606            dst
4607        };
4608        let request_size = request_value_reader
4609            .seek(std::io::SeekFrom::End(0))
4610            .unwrap();
4611        request_value_reader
4612            .seek(std::io::SeekFrom::Start(0))
4613            .unwrap();
4614
4615        loop {
4616            let token = match self
4617                .hub
4618                .auth
4619                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4620                .await
4621            {
4622                Ok(token) => token,
4623                Err(e) => match dlg.token(e) {
4624                    Ok(token) => token,
4625                    Err(e) => {
4626                        dlg.finished(false);
4627                        return Err(common::Error::MissingToken(e));
4628                    }
4629                },
4630            };
4631            request_value_reader
4632                .seek(std::io::SeekFrom::Start(0))
4633                .unwrap();
4634            let mut req_result = {
4635                let client = &self.hub.client;
4636                dlg.pre_request();
4637                let mut req_builder = hyper::Request::builder()
4638                    .method(hyper::Method::POST)
4639                    .uri(url.as_str())
4640                    .header(USER_AGENT, self.hub._user_agent.clone());
4641
4642                if let Some(token) = token.as_ref() {
4643                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4644                }
4645
4646                let request = req_builder
4647                    .header(CONTENT_TYPE, json_mime_type.to_string())
4648                    .header(CONTENT_LENGTH, request_size as u64)
4649                    .body(common::to_body(
4650                        request_value_reader.get_ref().clone().into(),
4651                    ));
4652
4653                client.request(request.unwrap()).await
4654            };
4655
4656            match req_result {
4657                Err(err) => {
4658                    if let common::Retry::After(d) = dlg.http_error(&err) {
4659                        sleep(d).await;
4660                        continue;
4661                    }
4662                    dlg.finished(false);
4663                    return Err(common::Error::HttpError(err));
4664                }
4665                Ok(res) => {
4666                    let (mut parts, body) = res.into_parts();
4667                    let mut body = common::Body::new(body);
4668                    if !parts.status.is_success() {
4669                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4670                        let error = serde_json::from_str(&common::to_string(&bytes));
4671                        let response = common::to_response(parts, bytes.into());
4672
4673                        if let common::Retry::After(d) =
4674                            dlg.http_failure(&response, error.as_ref().ok())
4675                        {
4676                            sleep(d).await;
4677                            continue;
4678                        }
4679
4680                        dlg.finished(false);
4681
4682                        return Err(match error {
4683                            Ok(value) => common::Error::BadRequest(value),
4684                            _ => common::Error::Failure(response),
4685                        });
4686                    }
4687                    let response = {
4688                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4689                        let encoded = common::to_string(&bytes);
4690                        match serde_json::from_str(&encoded) {
4691                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4692                            Err(error) => {
4693                                dlg.response_json_decode_error(&encoded, &error);
4694                                return Err(common::Error::JsonDecodeError(
4695                                    encoded.to_string(),
4696                                    error,
4697                                ));
4698                            }
4699                        }
4700                    };
4701
4702                    dlg.finished(true);
4703                    return Ok(response);
4704                }
4705            }
4706        }
4707    }
4708
4709    ///
4710    /// Sets the *request* property to the given value.
4711    ///
4712    /// Even though the property as already been set when instantiating this call,
4713    /// we provide this method for API completeness.
4714    pub fn request(
4715        mut self,
4716        new_value: EnableInteractiveSerialConsoleRequest,
4717    ) -> ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'a, C> {
4718        self._request = new_value;
4719        self
4720    }
4721    /// Required. Name of the resource.
4722    ///
4723    /// Sets the *name* path property to the given value.
4724    ///
4725    /// Even though the property as already been set when instantiating this call,
4726    /// we provide this method for API completeness.
4727    pub fn name(
4728        mut self,
4729        new_value: &str,
4730    ) -> ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'a, C> {
4731        self._name = 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    ) -> ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'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>(
4771        mut self,
4772        name: T,
4773        value: T,
4774    ) -> ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'a, C>
4775    where
4776        T: AsRef<str>,
4777    {
4778        self._additional_params
4779            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4780        self
4781    }
4782
4783    /// Identifies the authorization scope for the method you are building.
4784    ///
4785    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4786    /// [`Scope::CloudPlatform`].
4787    ///
4788    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4789    /// tokens for more than one scope.
4790    ///
4791    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4792    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4793    /// sufficient, a read-write scope will do as well.
4794    pub fn add_scope<St>(
4795        mut self,
4796        scope: St,
4797    ) -> ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'a, C>
4798    where
4799        St: AsRef<str>,
4800    {
4801        self._scopes.insert(String::from(scope.as_ref()));
4802        self
4803    }
4804    /// Identifies the authorization scope(s) for the method you are building.
4805    ///
4806    /// See [`Self::add_scope()`] for details.
4807    pub fn add_scopes<I, St>(
4808        mut self,
4809        scopes: I,
4810    ) -> ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'a, C>
4811    where
4812        I: IntoIterator<Item = St>,
4813        St: AsRef<str>,
4814    {
4815        self._scopes
4816            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4817        self
4818    }
4819
4820    /// Removes all scopes, and no default scope will be used either.
4821    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4822    /// for details).
4823    pub fn clear_scopes(
4824        mut self,
4825    ) -> ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'a, C> {
4826        self._scopes.clear();
4827        self
4828    }
4829}
4830
4831/// Get details about a single server.
4832///
4833/// A builder for the *locations.instances.get* method supported by a *project* resource.
4834/// It is not used directly, but through a [`ProjectMethods`] instance.
4835///
4836/// # Example
4837///
4838/// Instantiate a resource method builder
4839///
4840/// ```test_harness,no_run
4841/// # extern crate hyper;
4842/// # extern crate hyper_rustls;
4843/// # extern crate google_baremetalsolution2 as baremetalsolution2;
4844/// # async fn dox() {
4845/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4846///
4847/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4848/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4849/// #     .with_native_roots()
4850/// #     .unwrap()
4851/// #     .https_only()
4852/// #     .enable_http2()
4853/// #     .build();
4854///
4855/// # let executor = hyper_util::rt::TokioExecutor::new();
4856/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4857/// #     secret,
4858/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4859/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4860/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4861/// #     ),
4862/// # ).build().await.unwrap();
4863///
4864/// # let client = hyper_util::client::legacy::Client::builder(
4865/// #     hyper_util::rt::TokioExecutor::new()
4866/// # )
4867/// # .build(
4868/// #     hyper_rustls::HttpsConnectorBuilder::new()
4869/// #         .with_native_roots()
4870/// #         .unwrap()
4871/// #         .https_or_http()
4872/// #         .enable_http2()
4873/// #         .build()
4874/// # );
4875/// # let mut hub = Baremetalsolution::new(client, auth);
4876/// // You can configure optional parameters by calling the respective setters at will, and
4877/// // execute the final call using `doit()`.
4878/// // Values shown here are possibly random and not representative !
4879/// let result = hub.projects().locations_instances_get("name")
4880///              .doit().await;
4881/// # }
4882/// ```
4883pub struct ProjectLocationInstanceGetCall<'a, C>
4884where
4885    C: 'a,
4886{
4887    hub: &'a Baremetalsolution<C>,
4888    _name: String,
4889    _delegate: Option<&'a mut dyn common::Delegate>,
4890    _additional_params: HashMap<String, String>,
4891    _scopes: BTreeSet<String>,
4892}
4893
4894impl<'a, C> common::CallBuilder for ProjectLocationInstanceGetCall<'a, C> {}
4895
4896impl<'a, C> ProjectLocationInstanceGetCall<'a, C>
4897where
4898    C: common::Connector,
4899{
4900    /// Perform the operation you have build so far.
4901    pub async fn doit(mut self) -> common::Result<(common::Response, Instance)> {
4902        use std::borrow::Cow;
4903        use std::io::{Read, Seek};
4904
4905        use common::{url::Params, ToParts};
4906        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4907
4908        let mut dd = common::DefaultDelegate;
4909        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4910        dlg.begin(common::MethodInfo {
4911            id: "baremetalsolution.projects.locations.instances.get",
4912            http_method: hyper::Method::GET,
4913        });
4914
4915        for &field in ["alt", "name"].iter() {
4916            if self._additional_params.contains_key(field) {
4917                dlg.finished(false);
4918                return Err(common::Error::FieldClash(field));
4919            }
4920        }
4921
4922        let mut params = Params::with_capacity(3 + self._additional_params.len());
4923        params.push("name", self._name);
4924
4925        params.extend(self._additional_params.iter());
4926
4927        params.push("alt", "json");
4928        let mut url = self.hub._base_url.clone() + "v2/{+name}";
4929        if self._scopes.is_empty() {
4930            self._scopes
4931                .insert(Scope::CloudPlatform.as_ref().to_string());
4932        }
4933
4934        #[allow(clippy::single_element_loop)]
4935        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4936            url = params.uri_replacement(url, param_name, find_this, true);
4937        }
4938        {
4939            let to_remove = ["name"];
4940            params.remove_params(&to_remove);
4941        }
4942
4943        let url = params.parse_with_url(&url);
4944
4945        loop {
4946            let token = match self
4947                .hub
4948                .auth
4949                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4950                .await
4951            {
4952                Ok(token) => token,
4953                Err(e) => match dlg.token(e) {
4954                    Ok(token) => token,
4955                    Err(e) => {
4956                        dlg.finished(false);
4957                        return Err(common::Error::MissingToken(e));
4958                    }
4959                },
4960            };
4961            let mut req_result = {
4962                let client = &self.hub.client;
4963                dlg.pre_request();
4964                let mut req_builder = hyper::Request::builder()
4965                    .method(hyper::Method::GET)
4966                    .uri(url.as_str())
4967                    .header(USER_AGENT, self.hub._user_agent.clone());
4968
4969                if let Some(token) = token.as_ref() {
4970                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4971                }
4972
4973                let request = req_builder
4974                    .header(CONTENT_LENGTH, 0_u64)
4975                    .body(common::to_body::<String>(None));
4976
4977                client.request(request.unwrap()).await
4978            };
4979
4980            match req_result {
4981                Err(err) => {
4982                    if let common::Retry::After(d) = dlg.http_error(&err) {
4983                        sleep(d).await;
4984                        continue;
4985                    }
4986                    dlg.finished(false);
4987                    return Err(common::Error::HttpError(err));
4988                }
4989                Ok(res) => {
4990                    let (mut parts, body) = res.into_parts();
4991                    let mut body = common::Body::new(body);
4992                    if !parts.status.is_success() {
4993                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4994                        let error = serde_json::from_str(&common::to_string(&bytes));
4995                        let response = common::to_response(parts, bytes.into());
4996
4997                        if let common::Retry::After(d) =
4998                            dlg.http_failure(&response, error.as_ref().ok())
4999                        {
5000                            sleep(d).await;
5001                            continue;
5002                        }
5003
5004                        dlg.finished(false);
5005
5006                        return Err(match error {
5007                            Ok(value) => common::Error::BadRequest(value),
5008                            _ => common::Error::Failure(response),
5009                        });
5010                    }
5011                    let response = {
5012                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5013                        let encoded = common::to_string(&bytes);
5014                        match serde_json::from_str(&encoded) {
5015                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5016                            Err(error) => {
5017                                dlg.response_json_decode_error(&encoded, &error);
5018                                return Err(common::Error::JsonDecodeError(
5019                                    encoded.to_string(),
5020                                    error,
5021                                ));
5022                            }
5023                        }
5024                    };
5025
5026                    dlg.finished(true);
5027                    return Ok(response);
5028                }
5029            }
5030        }
5031    }
5032
5033    /// Required. Name of the resource.
5034    ///
5035    /// Sets the *name* path property to the given value.
5036    ///
5037    /// Even though the property as already been set when instantiating this call,
5038    /// we provide this method for API completeness.
5039    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceGetCall<'a, C> {
5040        self._name = new_value.to_string();
5041        self
5042    }
5043    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5044    /// while executing the actual API request.
5045    ///
5046    /// ````text
5047    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5048    /// ````
5049    ///
5050    /// Sets the *delegate* property to the given value.
5051    pub fn delegate(
5052        mut self,
5053        new_value: &'a mut dyn common::Delegate,
5054    ) -> ProjectLocationInstanceGetCall<'a, C> {
5055        self._delegate = Some(new_value);
5056        self
5057    }
5058
5059    /// Set any additional parameter of the query string used in the request.
5060    /// It should be used to set parameters which are not yet available through their own
5061    /// setters.
5062    ///
5063    /// Please note that this method must not be used to set any of the known parameters
5064    /// which have their own setter method. If done anyway, the request will fail.
5065    ///
5066    /// # Additional Parameters
5067    ///
5068    /// * *$.xgafv* (query-string) - V1 error format.
5069    /// * *access_token* (query-string) - OAuth access token.
5070    /// * *alt* (query-string) - Data format for response.
5071    /// * *callback* (query-string) - JSONP
5072    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5073    /// * *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.
5074    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5075    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5076    /// * *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.
5077    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5078    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5079    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceGetCall<'a, C>
5080    where
5081        T: AsRef<str>,
5082    {
5083        self._additional_params
5084            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5085        self
5086    }
5087
5088    /// Identifies the authorization scope for the method you are building.
5089    ///
5090    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5091    /// [`Scope::CloudPlatform`].
5092    ///
5093    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5094    /// tokens for more than one scope.
5095    ///
5096    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5097    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5098    /// sufficient, a read-write scope will do as well.
5099    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceGetCall<'a, C>
5100    where
5101        St: AsRef<str>,
5102    {
5103        self._scopes.insert(String::from(scope.as_ref()));
5104        self
5105    }
5106    /// Identifies the authorization scope(s) for the method you are building.
5107    ///
5108    /// See [`Self::add_scope()`] for details.
5109    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceGetCall<'a, C>
5110    where
5111        I: IntoIterator<Item = St>,
5112        St: AsRef<str>,
5113    {
5114        self._scopes
5115            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5116        self
5117    }
5118
5119    /// Removes all scopes, and no default scope will be used either.
5120    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5121    /// for details).
5122    pub fn clear_scopes(mut self) -> ProjectLocationInstanceGetCall<'a, C> {
5123        self._scopes.clear();
5124        self
5125    }
5126}
5127
5128/// List servers in a given project and location.
5129///
5130/// A builder for the *locations.instances.list* method supported by a *project* resource.
5131/// It is not used directly, but through a [`ProjectMethods`] instance.
5132///
5133/// # Example
5134///
5135/// Instantiate a resource method builder
5136///
5137/// ```test_harness,no_run
5138/// # extern crate hyper;
5139/// # extern crate hyper_rustls;
5140/// # extern crate google_baremetalsolution2 as baremetalsolution2;
5141/// # async fn dox() {
5142/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5143///
5144/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5145/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5146/// #     .with_native_roots()
5147/// #     .unwrap()
5148/// #     .https_only()
5149/// #     .enable_http2()
5150/// #     .build();
5151///
5152/// # let executor = hyper_util::rt::TokioExecutor::new();
5153/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5154/// #     secret,
5155/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5156/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5157/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5158/// #     ),
5159/// # ).build().await.unwrap();
5160///
5161/// # let client = hyper_util::client::legacy::Client::builder(
5162/// #     hyper_util::rt::TokioExecutor::new()
5163/// # )
5164/// # .build(
5165/// #     hyper_rustls::HttpsConnectorBuilder::new()
5166/// #         .with_native_roots()
5167/// #         .unwrap()
5168/// #         .https_or_http()
5169/// #         .enable_http2()
5170/// #         .build()
5171/// # );
5172/// # let mut hub = Baremetalsolution::new(client, auth);
5173/// // You can configure optional parameters by calling the respective setters at will, and
5174/// // execute the final call using `doit()`.
5175/// // Values shown here are possibly random and not representative !
5176/// let result = hub.projects().locations_instances_list("parent")
5177///              .page_token("amet.")
5178///              .page_size(-20)
5179///              .filter("ipsum")
5180///              .doit().await;
5181/// # }
5182/// ```
5183pub struct ProjectLocationInstanceListCall<'a, C>
5184where
5185    C: 'a,
5186{
5187    hub: &'a Baremetalsolution<C>,
5188    _parent: String,
5189    _page_token: Option<String>,
5190    _page_size: Option<i32>,
5191    _filter: Option<String>,
5192    _delegate: Option<&'a mut dyn common::Delegate>,
5193    _additional_params: HashMap<String, String>,
5194    _scopes: BTreeSet<String>,
5195}
5196
5197impl<'a, C> common::CallBuilder for ProjectLocationInstanceListCall<'a, C> {}
5198
5199impl<'a, C> ProjectLocationInstanceListCall<'a, C>
5200where
5201    C: common::Connector,
5202{
5203    /// Perform the operation you have build so far.
5204    pub async fn doit(mut self) -> common::Result<(common::Response, ListInstancesResponse)> {
5205        use std::borrow::Cow;
5206        use std::io::{Read, Seek};
5207
5208        use common::{url::Params, ToParts};
5209        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5210
5211        let mut dd = common::DefaultDelegate;
5212        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5213        dlg.begin(common::MethodInfo {
5214            id: "baremetalsolution.projects.locations.instances.list",
5215            http_method: hyper::Method::GET,
5216        });
5217
5218        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
5219            if self._additional_params.contains_key(field) {
5220                dlg.finished(false);
5221                return Err(common::Error::FieldClash(field));
5222            }
5223        }
5224
5225        let mut params = Params::with_capacity(6 + self._additional_params.len());
5226        params.push("parent", self._parent);
5227        if let Some(value) = self._page_token.as_ref() {
5228            params.push("pageToken", value);
5229        }
5230        if let Some(value) = self._page_size.as_ref() {
5231            params.push("pageSize", value.to_string());
5232        }
5233        if let Some(value) = self._filter.as_ref() {
5234            params.push("filter", value);
5235        }
5236
5237        params.extend(self._additional_params.iter());
5238
5239        params.push("alt", "json");
5240        let mut url = self.hub._base_url.clone() + "v2/{+parent}/instances";
5241        if self._scopes.is_empty() {
5242            self._scopes
5243                .insert(Scope::CloudPlatform.as_ref().to_string());
5244        }
5245
5246        #[allow(clippy::single_element_loop)]
5247        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5248            url = params.uri_replacement(url, param_name, find_this, true);
5249        }
5250        {
5251            let to_remove = ["parent"];
5252            params.remove_params(&to_remove);
5253        }
5254
5255        let url = params.parse_with_url(&url);
5256
5257        loop {
5258            let token = match self
5259                .hub
5260                .auth
5261                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5262                .await
5263            {
5264                Ok(token) => token,
5265                Err(e) => match dlg.token(e) {
5266                    Ok(token) => token,
5267                    Err(e) => {
5268                        dlg.finished(false);
5269                        return Err(common::Error::MissingToken(e));
5270                    }
5271                },
5272            };
5273            let mut req_result = {
5274                let client = &self.hub.client;
5275                dlg.pre_request();
5276                let mut req_builder = hyper::Request::builder()
5277                    .method(hyper::Method::GET)
5278                    .uri(url.as_str())
5279                    .header(USER_AGENT, self.hub._user_agent.clone());
5280
5281                if let Some(token) = token.as_ref() {
5282                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5283                }
5284
5285                let request = req_builder
5286                    .header(CONTENT_LENGTH, 0_u64)
5287                    .body(common::to_body::<String>(None));
5288
5289                client.request(request.unwrap()).await
5290            };
5291
5292            match req_result {
5293                Err(err) => {
5294                    if let common::Retry::After(d) = dlg.http_error(&err) {
5295                        sleep(d).await;
5296                        continue;
5297                    }
5298                    dlg.finished(false);
5299                    return Err(common::Error::HttpError(err));
5300                }
5301                Ok(res) => {
5302                    let (mut parts, body) = res.into_parts();
5303                    let mut body = common::Body::new(body);
5304                    if !parts.status.is_success() {
5305                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5306                        let error = serde_json::from_str(&common::to_string(&bytes));
5307                        let response = common::to_response(parts, bytes.into());
5308
5309                        if let common::Retry::After(d) =
5310                            dlg.http_failure(&response, error.as_ref().ok())
5311                        {
5312                            sleep(d).await;
5313                            continue;
5314                        }
5315
5316                        dlg.finished(false);
5317
5318                        return Err(match error {
5319                            Ok(value) => common::Error::BadRequest(value),
5320                            _ => common::Error::Failure(response),
5321                        });
5322                    }
5323                    let response = {
5324                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5325                        let encoded = common::to_string(&bytes);
5326                        match serde_json::from_str(&encoded) {
5327                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5328                            Err(error) => {
5329                                dlg.response_json_decode_error(&encoded, &error);
5330                                return Err(common::Error::JsonDecodeError(
5331                                    encoded.to_string(),
5332                                    error,
5333                                ));
5334                            }
5335                        }
5336                    };
5337
5338                    dlg.finished(true);
5339                    return Ok(response);
5340                }
5341            }
5342        }
5343    }
5344
5345    /// Required. Parent value for ListInstancesRequest.
5346    ///
5347    /// Sets the *parent* path property to the given value.
5348    ///
5349    /// Even though the property as already been set when instantiating this call,
5350    /// we provide this method for API completeness.
5351    pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
5352        self._parent = new_value.to_string();
5353        self
5354    }
5355    /// A token identifying a page of results from the server.
5356    ///
5357    /// Sets the *page token* query property to the given value.
5358    pub fn page_token(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
5359        self._page_token = Some(new_value.to_string());
5360        self
5361    }
5362    /// Requested page size. Server may return fewer items than requested. If unspecified, the server will pick an appropriate default.
5363    ///
5364    /// Sets the *page size* query property to the given value.
5365    pub fn page_size(mut self, new_value: i32) -> ProjectLocationInstanceListCall<'a, C> {
5366        self._page_size = Some(new_value);
5367        self
5368    }
5369    /// List filter.
5370    ///
5371    /// Sets the *filter* query property to the given value.
5372    pub fn filter(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
5373        self._filter = Some(new_value.to_string());
5374        self
5375    }
5376    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5377    /// while executing the actual API request.
5378    ///
5379    /// ````text
5380    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5381    /// ````
5382    ///
5383    /// Sets the *delegate* property to the given value.
5384    pub fn delegate(
5385        mut self,
5386        new_value: &'a mut dyn common::Delegate,
5387    ) -> ProjectLocationInstanceListCall<'a, C> {
5388        self._delegate = Some(new_value);
5389        self
5390    }
5391
5392    /// Set any additional parameter of the query string used in the request.
5393    /// It should be used to set parameters which are not yet available through their own
5394    /// setters.
5395    ///
5396    /// Please note that this method must not be used to set any of the known parameters
5397    /// which have their own setter method. If done anyway, the request will fail.
5398    ///
5399    /// # Additional Parameters
5400    ///
5401    /// * *$.xgafv* (query-string) - V1 error format.
5402    /// * *access_token* (query-string) - OAuth access token.
5403    /// * *alt* (query-string) - Data format for response.
5404    /// * *callback* (query-string) - JSONP
5405    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5406    /// * *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.
5407    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5408    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5409    /// * *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.
5410    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5411    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5412    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceListCall<'a, C>
5413    where
5414        T: AsRef<str>,
5415    {
5416        self._additional_params
5417            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5418        self
5419    }
5420
5421    /// Identifies the authorization scope for the method you are building.
5422    ///
5423    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5424    /// [`Scope::CloudPlatform`].
5425    ///
5426    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5427    /// tokens for more than one scope.
5428    ///
5429    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5430    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5431    /// sufficient, a read-write scope will do as well.
5432    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceListCall<'a, C>
5433    where
5434        St: AsRef<str>,
5435    {
5436        self._scopes.insert(String::from(scope.as_ref()));
5437        self
5438    }
5439    /// Identifies the authorization scope(s) for the method you are building.
5440    ///
5441    /// See [`Self::add_scope()`] for details.
5442    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceListCall<'a, C>
5443    where
5444        I: IntoIterator<Item = St>,
5445        St: AsRef<str>,
5446    {
5447        self._scopes
5448            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5449        self
5450    }
5451
5452    /// Removes all scopes, and no default scope will be used either.
5453    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5454    /// for details).
5455    pub fn clear_scopes(mut self) -> ProjectLocationInstanceListCall<'a, C> {
5456        self._scopes.clear();
5457        self
5458    }
5459}
5460
5461/// Load auth info for a server.
5462///
5463/// A builder for the *locations.instances.loadAuthInfo* method supported by a *project* resource.
5464/// It is not used directly, but through a [`ProjectMethods`] instance.
5465///
5466/// # Example
5467///
5468/// Instantiate a resource method builder
5469///
5470/// ```test_harness,no_run
5471/// # extern crate hyper;
5472/// # extern crate hyper_rustls;
5473/// # extern crate google_baremetalsolution2 as baremetalsolution2;
5474/// # async fn dox() {
5475/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5476///
5477/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5478/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5479/// #     .with_native_roots()
5480/// #     .unwrap()
5481/// #     .https_only()
5482/// #     .enable_http2()
5483/// #     .build();
5484///
5485/// # let executor = hyper_util::rt::TokioExecutor::new();
5486/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5487/// #     secret,
5488/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5489/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5490/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5491/// #     ),
5492/// # ).build().await.unwrap();
5493///
5494/// # let client = hyper_util::client::legacy::Client::builder(
5495/// #     hyper_util::rt::TokioExecutor::new()
5496/// # )
5497/// # .build(
5498/// #     hyper_rustls::HttpsConnectorBuilder::new()
5499/// #         .with_native_roots()
5500/// #         .unwrap()
5501/// #         .https_or_http()
5502/// #         .enable_http2()
5503/// #         .build()
5504/// # );
5505/// # let mut hub = Baremetalsolution::new(client, auth);
5506/// // You can configure optional parameters by calling the respective setters at will, and
5507/// // execute the final call using `doit()`.
5508/// // Values shown here are possibly random and not representative !
5509/// let result = hub.projects().locations_instances_load_auth_info("name")
5510///              .doit().await;
5511/// # }
5512/// ```
5513pub struct ProjectLocationInstanceLoadAuthInfoCall<'a, C>
5514where
5515    C: 'a,
5516{
5517    hub: &'a Baremetalsolution<C>,
5518    _name: String,
5519    _delegate: Option<&'a mut dyn common::Delegate>,
5520    _additional_params: HashMap<String, String>,
5521    _scopes: BTreeSet<String>,
5522}
5523
5524impl<'a, C> common::CallBuilder for ProjectLocationInstanceLoadAuthInfoCall<'a, C> {}
5525
5526impl<'a, C> ProjectLocationInstanceLoadAuthInfoCall<'a, C>
5527where
5528    C: common::Connector,
5529{
5530    /// Perform the operation you have build so far.
5531    pub async fn doit(
5532        mut self,
5533    ) -> common::Result<(common::Response, LoadInstanceAuthInfoResponse)> {
5534        use std::borrow::Cow;
5535        use std::io::{Read, Seek};
5536
5537        use common::{url::Params, ToParts};
5538        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5539
5540        let mut dd = common::DefaultDelegate;
5541        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5542        dlg.begin(common::MethodInfo {
5543            id: "baremetalsolution.projects.locations.instances.loadAuthInfo",
5544            http_method: hyper::Method::GET,
5545        });
5546
5547        for &field in ["alt", "name"].iter() {
5548            if self._additional_params.contains_key(field) {
5549                dlg.finished(false);
5550                return Err(common::Error::FieldClash(field));
5551            }
5552        }
5553
5554        let mut params = Params::with_capacity(3 + self._additional_params.len());
5555        params.push("name", self._name);
5556
5557        params.extend(self._additional_params.iter());
5558
5559        params.push("alt", "json");
5560        let mut url = self.hub._base_url.clone() + "v2/{+name}:loadAuthInfo";
5561        if self._scopes.is_empty() {
5562            self._scopes
5563                .insert(Scope::CloudPlatform.as_ref().to_string());
5564        }
5565
5566        #[allow(clippy::single_element_loop)]
5567        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5568            url = params.uri_replacement(url, param_name, find_this, true);
5569        }
5570        {
5571            let to_remove = ["name"];
5572            params.remove_params(&to_remove);
5573        }
5574
5575        let url = params.parse_with_url(&url);
5576
5577        loop {
5578            let token = match self
5579                .hub
5580                .auth
5581                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5582                .await
5583            {
5584                Ok(token) => token,
5585                Err(e) => match dlg.token(e) {
5586                    Ok(token) => token,
5587                    Err(e) => {
5588                        dlg.finished(false);
5589                        return Err(common::Error::MissingToken(e));
5590                    }
5591                },
5592            };
5593            let mut req_result = {
5594                let client = &self.hub.client;
5595                dlg.pre_request();
5596                let mut req_builder = hyper::Request::builder()
5597                    .method(hyper::Method::GET)
5598                    .uri(url.as_str())
5599                    .header(USER_AGENT, self.hub._user_agent.clone());
5600
5601                if let Some(token) = token.as_ref() {
5602                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5603                }
5604
5605                let request = req_builder
5606                    .header(CONTENT_LENGTH, 0_u64)
5607                    .body(common::to_body::<String>(None));
5608
5609                client.request(request.unwrap()).await
5610            };
5611
5612            match req_result {
5613                Err(err) => {
5614                    if let common::Retry::After(d) = dlg.http_error(&err) {
5615                        sleep(d).await;
5616                        continue;
5617                    }
5618                    dlg.finished(false);
5619                    return Err(common::Error::HttpError(err));
5620                }
5621                Ok(res) => {
5622                    let (mut parts, body) = res.into_parts();
5623                    let mut body = common::Body::new(body);
5624                    if !parts.status.is_success() {
5625                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5626                        let error = serde_json::from_str(&common::to_string(&bytes));
5627                        let response = common::to_response(parts, bytes.into());
5628
5629                        if let common::Retry::After(d) =
5630                            dlg.http_failure(&response, error.as_ref().ok())
5631                        {
5632                            sleep(d).await;
5633                            continue;
5634                        }
5635
5636                        dlg.finished(false);
5637
5638                        return Err(match error {
5639                            Ok(value) => common::Error::BadRequest(value),
5640                            _ => common::Error::Failure(response),
5641                        });
5642                    }
5643                    let response = {
5644                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5645                        let encoded = common::to_string(&bytes);
5646                        match serde_json::from_str(&encoded) {
5647                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5648                            Err(error) => {
5649                                dlg.response_json_decode_error(&encoded, &error);
5650                                return Err(common::Error::JsonDecodeError(
5651                                    encoded.to_string(),
5652                                    error,
5653                                ));
5654                            }
5655                        }
5656                    };
5657
5658                    dlg.finished(true);
5659                    return Ok(response);
5660                }
5661            }
5662        }
5663    }
5664
5665    /// Required. Name of the server.
5666    ///
5667    /// Sets the *name* path property to the given value.
5668    ///
5669    /// Even though the property as already been set when instantiating this call,
5670    /// we provide this method for API completeness.
5671    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceLoadAuthInfoCall<'a, C> {
5672        self._name = new_value.to_string();
5673        self
5674    }
5675    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5676    /// while executing the actual API request.
5677    ///
5678    /// ````text
5679    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5680    /// ````
5681    ///
5682    /// Sets the *delegate* property to the given value.
5683    pub fn delegate(
5684        mut self,
5685        new_value: &'a mut dyn common::Delegate,
5686    ) -> ProjectLocationInstanceLoadAuthInfoCall<'a, C> {
5687        self._delegate = Some(new_value);
5688        self
5689    }
5690
5691    /// Set any additional parameter of the query string used in the request.
5692    /// It should be used to set parameters which are not yet available through their own
5693    /// setters.
5694    ///
5695    /// Please note that this method must not be used to set any of the known parameters
5696    /// which have their own setter method. If done anyway, the request will fail.
5697    ///
5698    /// # Additional Parameters
5699    ///
5700    /// * *$.xgafv* (query-string) - V1 error format.
5701    /// * *access_token* (query-string) - OAuth access token.
5702    /// * *alt* (query-string) - Data format for response.
5703    /// * *callback* (query-string) - JSONP
5704    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5705    /// * *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.
5706    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5707    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5708    /// * *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.
5709    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5710    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5711    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceLoadAuthInfoCall<'a, C>
5712    where
5713        T: AsRef<str>,
5714    {
5715        self._additional_params
5716            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5717        self
5718    }
5719
5720    /// Identifies the authorization scope for the method you are building.
5721    ///
5722    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5723    /// [`Scope::CloudPlatform`].
5724    ///
5725    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5726    /// tokens for more than one scope.
5727    ///
5728    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5729    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5730    /// sufficient, a read-write scope will do as well.
5731    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceLoadAuthInfoCall<'a, C>
5732    where
5733        St: AsRef<str>,
5734    {
5735        self._scopes.insert(String::from(scope.as_ref()));
5736        self
5737    }
5738    /// Identifies the authorization scope(s) for the method you are building.
5739    ///
5740    /// See [`Self::add_scope()`] for details.
5741    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceLoadAuthInfoCall<'a, C>
5742    where
5743        I: IntoIterator<Item = St>,
5744        St: AsRef<str>,
5745    {
5746        self._scopes
5747            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5748        self
5749    }
5750
5751    /// Removes all scopes, and no default scope will be used either.
5752    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5753    /// for details).
5754    pub fn clear_scopes(mut self) -> ProjectLocationInstanceLoadAuthInfoCall<'a, C> {
5755        self._scopes.clear();
5756        self
5757    }
5758}
5759
5760/// Update details of a single server.
5761///
5762/// A builder for the *locations.instances.patch* method supported by a *project* resource.
5763/// It is not used directly, but through a [`ProjectMethods`] instance.
5764///
5765/// # Example
5766///
5767/// Instantiate a resource method builder
5768///
5769/// ```test_harness,no_run
5770/// # extern crate hyper;
5771/// # extern crate hyper_rustls;
5772/// # extern crate google_baremetalsolution2 as baremetalsolution2;
5773/// use baremetalsolution2::api::Instance;
5774/// # async fn dox() {
5775/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5776///
5777/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5778/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5779/// #     .with_native_roots()
5780/// #     .unwrap()
5781/// #     .https_only()
5782/// #     .enable_http2()
5783/// #     .build();
5784///
5785/// # let executor = hyper_util::rt::TokioExecutor::new();
5786/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5787/// #     secret,
5788/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5789/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5790/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5791/// #     ),
5792/// # ).build().await.unwrap();
5793///
5794/// # let client = hyper_util::client::legacy::Client::builder(
5795/// #     hyper_util::rt::TokioExecutor::new()
5796/// # )
5797/// # .build(
5798/// #     hyper_rustls::HttpsConnectorBuilder::new()
5799/// #         .with_native_roots()
5800/// #         .unwrap()
5801/// #         .https_or_http()
5802/// #         .enable_http2()
5803/// #         .build()
5804/// # );
5805/// # let mut hub = Baremetalsolution::new(client, auth);
5806/// // As the method needs a request, you would usually fill it with the desired information
5807/// // into the respective structure. Some of the parts shown here might not be applicable !
5808/// // Values shown here are possibly random and not representative !
5809/// let mut req = Instance::default();
5810///
5811/// // You can configure optional parameters by calling the respective setters at will, and
5812/// // execute the final call using `doit()`.
5813/// // Values shown here are possibly random and not representative !
5814/// let result = hub.projects().locations_instances_patch(req, "name")
5815///              .update_mask(FieldMask::new::<&str>(&[]))
5816///              .doit().await;
5817/// # }
5818/// ```
5819pub struct ProjectLocationInstancePatchCall<'a, C>
5820where
5821    C: 'a,
5822{
5823    hub: &'a Baremetalsolution<C>,
5824    _request: Instance,
5825    _name: String,
5826    _update_mask: Option<common::FieldMask>,
5827    _delegate: Option<&'a mut dyn common::Delegate>,
5828    _additional_params: HashMap<String, String>,
5829    _scopes: BTreeSet<String>,
5830}
5831
5832impl<'a, C> common::CallBuilder for ProjectLocationInstancePatchCall<'a, C> {}
5833
5834impl<'a, C> ProjectLocationInstancePatchCall<'a, C>
5835where
5836    C: common::Connector,
5837{
5838    /// Perform the operation you have build so far.
5839    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5840        use std::borrow::Cow;
5841        use std::io::{Read, Seek};
5842
5843        use common::{url::Params, ToParts};
5844        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5845
5846        let mut dd = common::DefaultDelegate;
5847        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5848        dlg.begin(common::MethodInfo {
5849            id: "baremetalsolution.projects.locations.instances.patch",
5850            http_method: hyper::Method::PATCH,
5851        });
5852
5853        for &field in ["alt", "name", "updateMask"].iter() {
5854            if self._additional_params.contains_key(field) {
5855                dlg.finished(false);
5856                return Err(common::Error::FieldClash(field));
5857            }
5858        }
5859
5860        let mut params = Params::with_capacity(5 + self._additional_params.len());
5861        params.push("name", self._name);
5862        if let Some(value) = self._update_mask.as_ref() {
5863            params.push("updateMask", value.to_string());
5864        }
5865
5866        params.extend(self._additional_params.iter());
5867
5868        params.push("alt", "json");
5869        let mut url = self.hub._base_url.clone() + "v2/{+name}";
5870        if self._scopes.is_empty() {
5871            self._scopes
5872                .insert(Scope::CloudPlatform.as_ref().to_string());
5873        }
5874
5875        #[allow(clippy::single_element_loop)]
5876        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5877            url = params.uri_replacement(url, param_name, find_this, true);
5878        }
5879        {
5880            let to_remove = ["name"];
5881            params.remove_params(&to_remove);
5882        }
5883
5884        let url = params.parse_with_url(&url);
5885
5886        let mut json_mime_type = mime::APPLICATION_JSON;
5887        let mut request_value_reader = {
5888            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5889            common::remove_json_null_values(&mut value);
5890            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5891            serde_json::to_writer(&mut dst, &value).unwrap();
5892            dst
5893        };
5894        let request_size = request_value_reader
5895            .seek(std::io::SeekFrom::End(0))
5896            .unwrap();
5897        request_value_reader
5898            .seek(std::io::SeekFrom::Start(0))
5899            .unwrap();
5900
5901        loop {
5902            let token = match self
5903                .hub
5904                .auth
5905                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5906                .await
5907            {
5908                Ok(token) => token,
5909                Err(e) => match dlg.token(e) {
5910                    Ok(token) => token,
5911                    Err(e) => {
5912                        dlg.finished(false);
5913                        return Err(common::Error::MissingToken(e));
5914                    }
5915                },
5916            };
5917            request_value_reader
5918                .seek(std::io::SeekFrom::Start(0))
5919                .unwrap();
5920            let mut req_result = {
5921                let client = &self.hub.client;
5922                dlg.pre_request();
5923                let mut req_builder = hyper::Request::builder()
5924                    .method(hyper::Method::PATCH)
5925                    .uri(url.as_str())
5926                    .header(USER_AGENT, self.hub._user_agent.clone());
5927
5928                if let Some(token) = token.as_ref() {
5929                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5930                }
5931
5932                let request = req_builder
5933                    .header(CONTENT_TYPE, json_mime_type.to_string())
5934                    .header(CONTENT_LENGTH, request_size as u64)
5935                    .body(common::to_body(
5936                        request_value_reader.get_ref().clone().into(),
5937                    ));
5938
5939                client.request(request.unwrap()).await
5940            };
5941
5942            match req_result {
5943                Err(err) => {
5944                    if let common::Retry::After(d) = dlg.http_error(&err) {
5945                        sleep(d).await;
5946                        continue;
5947                    }
5948                    dlg.finished(false);
5949                    return Err(common::Error::HttpError(err));
5950                }
5951                Ok(res) => {
5952                    let (mut parts, body) = res.into_parts();
5953                    let mut body = common::Body::new(body);
5954                    if !parts.status.is_success() {
5955                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5956                        let error = serde_json::from_str(&common::to_string(&bytes));
5957                        let response = common::to_response(parts, bytes.into());
5958
5959                        if let common::Retry::After(d) =
5960                            dlg.http_failure(&response, error.as_ref().ok())
5961                        {
5962                            sleep(d).await;
5963                            continue;
5964                        }
5965
5966                        dlg.finished(false);
5967
5968                        return Err(match error {
5969                            Ok(value) => common::Error::BadRequest(value),
5970                            _ => common::Error::Failure(response),
5971                        });
5972                    }
5973                    let response = {
5974                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5975                        let encoded = common::to_string(&bytes);
5976                        match serde_json::from_str(&encoded) {
5977                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5978                            Err(error) => {
5979                                dlg.response_json_decode_error(&encoded, &error);
5980                                return Err(common::Error::JsonDecodeError(
5981                                    encoded.to_string(),
5982                                    error,
5983                                ));
5984                            }
5985                        }
5986                    };
5987
5988                    dlg.finished(true);
5989                    return Ok(response);
5990                }
5991            }
5992        }
5993    }
5994
5995    ///
5996    /// Sets the *request* property to the given value.
5997    ///
5998    /// Even though the property as already been set when instantiating this call,
5999    /// we provide this method for API completeness.
6000    pub fn request(mut self, new_value: Instance) -> ProjectLocationInstancePatchCall<'a, C> {
6001        self._request = new_value;
6002        self
6003    }
6004    /// Immutable. The resource name of this `Instance`. Resource names are schemeless URIs that follow the conventions in https://cloud.google.com/apis/design/resource_names. Format: `projects/{project}/locations/{location}/instances/{instance}`
6005    ///
6006    /// Sets the *name* path property to the given value.
6007    ///
6008    /// Even though the property as already been set when instantiating this call,
6009    /// we provide this method for API completeness.
6010    pub fn name(mut self, new_value: &str) -> ProjectLocationInstancePatchCall<'a, C> {
6011        self._name = new_value.to_string();
6012        self
6013    }
6014    /// The list of fields to update. The currently supported fields are: `labels` `hyperthreading_enabled` `os_image` `ssh_keys` `kms_key_version`
6015    ///
6016    /// Sets the *update mask* query property to the given value.
6017    pub fn update_mask(
6018        mut self,
6019        new_value: common::FieldMask,
6020    ) -> ProjectLocationInstancePatchCall<'a, C> {
6021        self._update_mask = Some(new_value);
6022        self
6023    }
6024    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6025    /// while executing the actual API request.
6026    ///
6027    /// ````text
6028    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6029    /// ````
6030    ///
6031    /// Sets the *delegate* property to the given value.
6032    pub fn delegate(
6033        mut self,
6034        new_value: &'a mut dyn common::Delegate,
6035    ) -> ProjectLocationInstancePatchCall<'a, C> {
6036        self._delegate = Some(new_value);
6037        self
6038    }
6039
6040    /// Set any additional parameter of the query string used in the request.
6041    /// It should be used to set parameters which are not yet available through their own
6042    /// setters.
6043    ///
6044    /// Please note that this method must not be used to set any of the known parameters
6045    /// which have their own setter method. If done anyway, the request will fail.
6046    ///
6047    /// # Additional Parameters
6048    ///
6049    /// * *$.xgafv* (query-string) - V1 error format.
6050    /// * *access_token* (query-string) - OAuth access token.
6051    /// * *alt* (query-string) - Data format for response.
6052    /// * *callback* (query-string) - JSONP
6053    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6054    /// * *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.
6055    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6056    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6057    /// * *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.
6058    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6059    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6060    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstancePatchCall<'a, C>
6061    where
6062        T: AsRef<str>,
6063    {
6064        self._additional_params
6065            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6066        self
6067    }
6068
6069    /// Identifies the authorization scope for the method you are building.
6070    ///
6071    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6072    /// [`Scope::CloudPlatform`].
6073    ///
6074    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6075    /// tokens for more than one scope.
6076    ///
6077    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6078    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6079    /// sufficient, a read-write scope will do as well.
6080    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstancePatchCall<'a, C>
6081    where
6082        St: AsRef<str>,
6083    {
6084        self._scopes.insert(String::from(scope.as_ref()));
6085        self
6086    }
6087    /// Identifies the authorization scope(s) for the method you are building.
6088    ///
6089    /// See [`Self::add_scope()`] for details.
6090    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstancePatchCall<'a, C>
6091    where
6092        I: IntoIterator<Item = St>,
6093        St: AsRef<str>,
6094    {
6095        self._scopes
6096            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6097        self
6098    }
6099
6100    /// Removes all scopes, and no default scope will be used either.
6101    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6102    /// for details).
6103    pub fn clear_scopes(mut self) -> ProjectLocationInstancePatchCall<'a, C> {
6104        self._scopes.clear();
6105        self
6106    }
6107}
6108
6109/// Perform reimage operation on a single server.
6110///
6111/// A builder for the *locations.instances.reimage* method supported by a *project* resource.
6112/// It is not used directly, but through a [`ProjectMethods`] instance.
6113///
6114/// # Example
6115///
6116/// Instantiate a resource method builder
6117///
6118/// ```test_harness,no_run
6119/// # extern crate hyper;
6120/// # extern crate hyper_rustls;
6121/// # extern crate google_baremetalsolution2 as baremetalsolution2;
6122/// use baremetalsolution2::api::ReimageInstanceRequest;
6123/// # async fn dox() {
6124/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6125///
6126/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6127/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6128/// #     .with_native_roots()
6129/// #     .unwrap()
6130/// #     .https_only()
6131/// #     .enable_http2()
6132/// #     .build();
6133///
6134/// # let executor = hyper_util::rt::TokioExecutor::new();
6135/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6136/// #     secret,
6137/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6138/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6139/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6140/// #     ),
6141/// # ).build().await.unwrap();
6142///
6143/// # let client = hyper_util::client::legacy::Client::builder(
6144/// #     hyper_util::rt::TokioExecutor::new()
6145/// # )
6146/// # .build(
6147/// #     hyper_rustls::HttpsConnectorBuilder::new()
6148/// #         .with_native_roots()
6149/// #         .unwrap()
6150/// #         .https_or_http()
6151/// #         .enable_http2()
6152/// #         .build()
6153/// # );
6154/// # let mut hub = Baremetalsolution::new(client, auth);
6155/// // As the method needs a request, you would usually fill it with the desired information
6156/// // into the respective structure. Some of the parts shown here might not be applicable !
6157/// // Values shown here are possibly random and not representative !
6158/// let mut req = ReimageInstanceRequest::default();
6159///
6160/// // You can configure optional parameters by calling the respective setters at will, and
6161/// // execute the final call using `doit()`.
6162/// // Values shown here are possibly random and not representative !
6163/// let result = hub.projects().locations_instances_reimage(req, "name")
6164///              .doit().await;
6165/// # }
6166/// ```
6167pub struct ProjectLocationInstanceReimageCall<'a, C>
6168where
6169    C: 'a,
6170{
6171    hub: &'a Baremetalsolution<C>,
6172    _request: ReimageInstanceRequest,
6173    _name: String,
6174    _delegate: Option<&'a mut dyn common::Delegate>,
6175    _additional_params: HashMap<String, String>,
6176    _scopes: BTreeSet<String>,
6177}
6178
6179impl<'a, C> common::CallBuilder for ProjectLocationInstanceReimageCall<'a, C> {}
6180
6181impl<'a, C> ProjectLocationInstanceReimageCall<'a, C>
6182where
6183    C: common::Connector,
6184{
6185    /// Perform the operation you have build so far.
6186    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6187        use std::borrow::Cow;
6188        use std::io::{Read, Seek};
6189
6190        use common::{url::Params, ToParts};
6191        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6192
6193        let mut dd = common::DefaultDelegate;
6194        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6195        dlg.begin(common::MethodInfo {
6196            id: "baremetalsolution.projects.locations.instances.reimage",
6197            http_method: hyper::Method::POST,
6198        });
6199
6200        for &field in ["alt", "name"].iter() {
6201            if self._additional_params.contains_key(field) {
6202                dlg.finished(false);
6203                return Err(common::Error::FieldClash(field));
6204            }
6205        }
6206
6207        let mut params = Params::with_capacity(4 + self._additional_params.len());
6208        params.push("name", self._name);
6209
6210        params.extend(self._additional_params.iter());
6211
6212        params.push("alt", "json");
6213        let mut url = self.hub._base_url.clone() + "v2/{+name}:reimage";
6214        if self._scopes.is_empty() {
6215            self._scopes
6216                .insert(Scope::CloudPlatform.as_ref().to_string());
6217        }
6218
6219        #[allow(clippy::single_element_loop)]
6220        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6221            url = params.uri_replacement(url, param_name, find_this, true);
6222        }
6223        {
6224            let to_remove = ["name"];
6225            params.remove_params(&to_remove);
6226        }
6227
6228        let url = params.parse_with_url(&url);
6229
6230        let mut json_mime_type = mime::APPLICATION_JSON;
6231        let mut request_value_reader = {
6232            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6233            common::remove_json_null_values(&mut value);
6234            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6235            serde_json::to_writer(&mut dst, &value).unwrap();
6236            dst
6237        };
6238        let request_size = request_value_reader
6239            .seek(std::io::SeekFrom::End(0))
6240            .unwrap();
6241        request_value_reader
6242            .seek(std::io::SeekFrom::Start(0))
6243            .unwrap();
6244
6245        loop {
6246            let token = match self
6247                .hub
6248                .auth
6249                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6250                .await
6251            {
6252                Ok(token) => token,
6253                Err(e) => match dlg.token(e) {
6254                    Ok(token) => token,
6255                    Err(e) => {
6256                        dlg.finished(false);
6257                        return Err(common::Error::MissingToken(e));
6258                    }
6259                },
6260            };
6261            request_value_reader
6262                .seek(std::io::SeekFrom::Start(0))
6263                .unwrap();
6264            let mut req_result = {
6265                let client = &self.hub.client;
6266                dlg.pre_request();
6267                let mut req_builder = hyper::Request::builder()
6268                    .method(hyper::Method::POST)
6269                    .uri(url.as_str())
6270                    .header(USER_AGENT, self.hub._user_agent.clone());
6271
6272                if let Some(token) = token.as_ref() {
6273                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6274                }
6275
6276                let request = req_builder
6277                    .header(CONTENT_TYPE, json_mime_type.to_string())
6278                    .header(CONTENT_LENGTH, request_size as u64)
6279                    .body(common::to_body(
6280                        request_value_reader.get_ref().clone().into(),
6281                    ));
6282
6283                client.request(request.unwrap()).await
6284            };
6285
6286            match req_result {
6287                Err(err) => {
6288                    if let common::Retry::After(d) = dlg.http_error(&err) {
6289                        sleep(d).await;
6290                        continue;
6291                    }
6292                    dlg.finished(false);
6293                    return Err(common::Error::HttpError(err));
6294                }
6295                Ok(res) => {
6296                    let (mut parts, body) = res.into_parts();
6297                    let mut body = common::Body::new(body);
6298                    if !parts.status.is_success() {
6299                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6300                        let error = serde_json::from_str(&common::to_string(&bytes));
6301                        let response = common::to_response(parts, bytes.into());
6302
6303                        if let common::Retry::After(d) =
6304                            dlg.http_failure(&response, error.as_ref().ok())
6305                        {
6306                            sleep(d).await;
6307                            continue;
6308                        }
6309
6310                        dlg.finished(false);
6311
6312                        return Err(match error {
6313                            Ok(value) => common::Error::BadRequest(value),
6314                            _ => common::Error::Failure(response),
6315                        });
6316                    }
6317                    let response = {
6318                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6319                        let encoded = common::to_string(&bytes);
6320                        match serde_json::from_str(&encoded) {
6321                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6322                            Err(error) => {
6323                                dlg.response_json_decode_error(&encoded, &error);
6324                                return Err(common::Error::JsonDecodeError(
6325                                    encoded.to_string(),
6326                                    error,
6327                                ));
6328                            }
6329                        }
6330                    };
6331
6332                    dlg.finished(true);
6333                    return Ok(response);
6334                }
6335            }
6336        }
6337    }
6338
6339    ///
6340    /// Sets the *request* property to the given value.
6341    ///
6342    /// Even though the property as already been set when instantiating this call,
6343    /// we provide this method for API completeness.
6344    pub fn request(
6345        mut self,
6346        new_value: ReimageInstanceRequest,
6347    ) -> ProjectLocationInstanceReimageCall<'a, C> {
6348        self._request = new_value;
6349        self
6350    }
6351    /// Required. The `name` field is used to identify the instance. Format: projects/{project}/locations/{location}/instances/{instance}
6352    ///
6353    /// Sets the *name* path property to the given value.
6354    ///
6355    /// Even though the property as already been set when instantiating this call,
6356    /// we provide this method for API completeness.
6357    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceReimageCall<'a, C> {
6358        self._name = new_value.to_string();
6359        self
6360    }
6361    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6362    /// while executing the actual API request.
6363    ///
6364    /// ````text
6365    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6366    /// ````
6367    ///
6368    /// Sets the *delegate* property to the given value.
6369    pub fn delegate(
6370        mut self,
6371        new_value: &'a mut dyn common::Delegate,
6372    ) -> ProjectLocationInstanceReimageCall<'a, C> {
6373        self._delegate = Some(new_value);
6374        self
6375    }
6376
6377    /// Set any additional parameter of the query string used in the request.
6378    /// It should be used to set parameters which are not yet available through their own
6379    /// setters.
6380    ///
6381    /// Please note that this method must not be used to set any of the known parameters
6382    /// which have their own setter method. If done anyway, the request will fail.
6383    ///
6384    /// # Additional Parameters
6385    ///
6386    /// * *$.xgafv* (query-string) - V1 error format.
6387    /// * *access_token* (query-string) - OAuth access token.
6388    /// * *alt* (query-string) - Data format for response.
6389    /// * *callback* (query-string) - JSONP
6390    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6391    /// * *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.
6392    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6393    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6394    /// * *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.
6395    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6396    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6397    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceReimageCall<'a, C>
6398    where
6399        T: AsRef<str>,
6400    {
6401        self._additional_params
6402            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6403        self
6404    }
6405
6406    /// Identifies the authorization scope for the method you are building.
6407    ///
6408    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6409    /// [`Scope::CloudPlatform`].
6410    ///
6411    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6412    /// tokens for more than one scope.
6413    ///
6414    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6415    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6416    /// sufficient, a read-write scope will do as well.
6417    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceReimageCall<'a, C>
6418    where
6419        St: AsRef<str>,
6420    {
6421        self._scopes.insert(String::from(scope.as_ref()));
6422        self
6423    }
6424    /// Identifies the authorization scope(s) for the method you are building.
6425    ///
6426    /// See [`Self::add_scope()`] for details.
6427    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceReimageCall<'a, C>
6428    where
6429        I: IntoIterator<Item = St>,
6430        St: AsRef<str>,
6431    {
6432        self._scopes
6433            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6434        self
6435    }
6436
6437    /// Removes all scopes, and no default scope will be used either.
6438    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6439    /// for details).
6440    pub fn clear_scopes(mut self) -> ProjectLocationInstanceReimageCall<'a, C> {
6441        self._scopes.clear();
6442        self
6443    }
6444}
6445
6446/// RenameInstance sets a new name for an instance. Use with caution, previous names become immediately invalidated.
6447///
6448/// A builder for the *locations.instances.rename* method supported by a *project* resource.
6449/// It is not used directly, but through a [`ProjectMethods`] instance.
6450///
6451/// # Example
6452///
6453/// Instantiate a resource method builder
6454///
6455/// ```test_harness,no_run
6456/// # extern crate hyper;
6457/// # extern crate hyper_rustls;
6458/// # extern crate google_baremetalsolution2 as baremetalsolution2;
6459/// use baremetalsolution2::api::RenameInstanceRequest;
6460/// # async fn dox() {
6461/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6462///
6463/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6464/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6465/// #     .with_native_roots()
6466/// #     .unwrap()
6467/// #     .https_only()
6468/// #     .enable_http2()
6469/// #     .build();
6470///
6471/// # let executor = hyper_util::rt::TokioExecutor::new();
6472/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6473/// #     secret,
6474/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6475/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6476/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6477/// #     ),
6478/// # ).build().await.unwrap();
6479///
6480/// # let client = hyper_util::client::legacy::Client::builder(
6481/// #     hyper_util::rt::TokioExecutor::new()
6482/// # )
6483/// # .build(
6484/// #     hyper_rustls::HttpsConnectorBuilder::new()
6485/// #         .with_native_roots()
6486/// #         .unwrap()
6487/// #         .https_or_http()
6488/// #         .enable_http2()
6489/// #         .build()
6490/// # );
6491/// # let mut hub = Baremetalsolution::new(client, auth);
6492/// // As the method needs a request, you would usually fill it with the desired information
6493/// // into the respective structure. Some of the parts shown here might not be applicable !
6494/// // Values shown here are possibly random and not representative !
6495/// let mut req = RenameInstanceRequest::default();
6496///
6497/// // You can configure optional parameters by calling the respective setters at will, and
6498/// // execute the final call using `doit()`.
6499/// // Values shown here are possibly random and not representative !
6500/// let result = hub.projects().locations_instances_rename(req, "name")
6501///              .doit().await;
6502/// # }
6503/// ```
6504pub struct ProjectLocationInstanceRenameCall<'a, C>
6505where
6506    C: 'a,
6507{
6508    hub: &'a Baremetalsolution<C>,
6509    _request: RenameInstanceRequest,
6510    _name: String,
6511    _delegate: Option<&'a mut dyn common::Delegate>,
6512    _additional_params: HashMap<String, String>,
6513    _scopes: BTreeSet<String>,
6514}
6515
6516impl<'a, C> common::CallBuilder for ProjectLocationInstanceRenameCall<'a, C> {}
6517
6518impl<'a, C> ProjectLocationInstanceRenameCall<'a, C>
6519where
6520    C: common::Connector,
6521{
6522    /// Perform the operation you have build so far.
6523    pub async fn doit(mut self) -> common::Result<(common::Response, Instance)> {
6524        use std::borrow::Cow;
6525        use std::io::{Read, Seek};
6526
6527        use common::{url::Params, ToParts};
6528        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6529
6530        let mut dd = common::DefaultDelegate;
6531        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6532        dlg.begin(common::MethodInfo {
6533            id: "baremetalsolution.projects.locations.instances.rename",
6534            http_method: hyper::Method::POST,
6535        });
6536
6537        for &field in ["alt", "name"].iter() {
6538            if self._additional_params.contains_key(field) {
6539                dlg.finished(false);
6540                return Err(common::Error::FieldClash(field));
6541            }
6542        }
6543
6544        let mut params = Params::with_capacity(4 + self._additional_params.len());
6545        params.push("name", self._name);
6546
6547        params.extend(self._additional_params.iter());
6548
6549        params.push("alt", "json");
6550        let mut url = self.hub._base_url.clone() + "v2/{+name}:rename";
6551        if self._scopes.is_empty() {
6552            self._scopes
6553                .insert(Scope::CloudPlatform.as_ref().to_string());
6554        }
6555
6556        #[allow(clippy::single_element_loop)]
6557        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6558            url = params.uri_replacement(url, param_name, find_this, true);
6559        }
6560        {
6561            let to_remove = ["name"];
6562            params.remove_params(&to_remove);
6563        }
6564
6565        let url = params.parse_with_url(&url);
6566
6567        let mut json_mime_type = mime::APPLICATION_JSON;
6568        let mut request_value_reader = {
6569            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6570            common::remove_json_null_values(&mut value);
6571            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6572            serde_json::to_writer(&mut dst, &value).unwrap();
6573            dst
6574        };
6575        let request_size = request_value_reader
6576            .seek(std::io::SeekFrom::End(0))
6577            .unwrap();
6578        request_value_reader
6579            .seek(std::io::SeekFrom::Start(0))
6580            .unwrap();
6581
6582        loop {
6583            let token = match self
6584                .hub
6585                .auth
6586                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6587                .await
6588            {
6589                Ok(token) => token,
6590                Err(e) => match dlg.token(e) {
6591                    Ok(token) => token,
6592                    Err(e) => {
6593                        dlg.finished(false);
6594                        return Err(common::Error::MissingToken(e));
6595                    }
6596                },
6597            };
6598            request_value_reader
6599                .seek(std::io::SeekFrom::Start(0))
6600                .unwrap();
6601            let mut req_result = {
6602                let client = &self.hub.client;
6603                dlg.pre_request();
6604                let mut req_builder = hyper::Request::builder()
6605                    .method(hyper::Method::POST)
6606                    .uri(url.as_str())
6607                    .header(USER_AGENT, self.hub._user_agent.clone());
6608
6609                if let Some(token) = token.as_ref() {
6610                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6611                }
6612
6613                let request = req_builder
6614                    .header(CONTENT_TYPE, json_mime_type.to_string())
6615                    .header(CONTENT_LENGTH, request_size as u64)
6616                    .body(common::to_body(
6617                        request_value_reader.get_ref().clone().into(),
6618                    ));
6619
6620                client.request(request.unwrap()).await
6621            };
6622
6623            match req_result {
6624                Err(err) => {
6625                    if let common::Retry::After(d) = dlg.http_error(&err) {
6626                        sleep(d).await;
6627                        continue;
6628                    }
6629                    dlg.finished(false);
6630                    return Err(common::Error::HttpError(err));
6631                }
6632                Ok(res) => {
6633                    let (mut parts, body) = res.into_parts();
6634                    let mut body = common::Body::new(body);
6635                    if !parts.status.is_success() {
6636                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6637                        let error = serde_json::from_str(&common::to_string(&bytes));
6638                        let response = common::to_response(parts, bytes.into());
6639
6640                        if let common::Retry::After(d) =
6641                            dlg.http_failure(&response, error.as_ref().ok())
6642                        {
6643                            sleep(d).await;
6644                            continue;
6645                        }
6646
6647                        dlg.finished(false);
6648
6649                        return Err(match error {
6650                            Ok(value) => common::Error::BadRequest(value),
6651                            _ => common::Error::Failure(response),
6652                        });
6653                    }
6654                    let response = {
6655                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6656                        let encoded = common::to_string(&bytes);
6657                        match serde_json::from_str(&encoded) {
6658                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6659                            Err(error) => {
6660                                dlg.response_json_decode_error(&encoded, &error);
6661                                return Err(common::Error::JsonDecodeError(
6662                                    encoded.to_string(),
6663                                    error,
6664                                ));
6665                            }
6666                        }
6667                    };
6668
6669                    dlg.finished(true);
6670                    return Ok(response);
6671                }
6672            }
6673        }
6674    }
6675
6676    ///
6677    /// Sets the *request* property to the given value.
6678    ///
6679    /// Even though the property as already been set when instantiating this call,
6680    /// we provide this method for API completeness.
6681    pub fn request(
6682        mut self,
6683        new_value: RenameInstanceRequest,
6684    ) -> ProjectLocationInstanceRenameCall<'a, C> {
6685        self._request = new_value;
6686        self
6687    }
6688    /// Required. The `name` field is used to identify the instance. Format: projects/{project}/locations/{location}/instances/{instance}
6689    ///
6690    /// Sets the *name* path property to the given value.
6691    ///
6692    /// Even though the property as already been set when instantiating this call,
6693    /// we provide this method for API completeness.
6694    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceRenameCall<'a, C> {
6695        self._name = new_value.to_string();
6696        self
6697    }
6698    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6699    /// while executing the actual API request.
6700    ///
6701    /// ````text
6702    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6703    /// ````
6704    ///
6705    /// Sets the *delegate* property to the given value.
6706    pub fn delegate(
6707        mut self,
6708        new_value: &'a mut dyn common::Delegate,
6709    ) -> ProjectLocationInstanceRenameCall<'a, C> {
6710        self._delegate = Some(new_value);
6711        self
6712    }
6713
6714    /// Set any additional parameter of the query string used in the request.
6715    /// It should be used to set parameters which are not yet available through their own
6716    /// setters.
6717    ///
6718    /// Please note that this method must not be used to set any of the known parameters
6719    /// which have their own setter method. If done anyway, the request will fail.
6720    ///
6721    /// # Additional Parameters
6722    ///
6723    /// * *$.xgafv* (query-string) - V1 error format.
6724    /// * *access_token* (query-string) - OAuth access token.
6725    /// * *alt* (query-string) - Data format for response.
6726    /// * *callback* (query-string) - JSONP
6727    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6728    /// * *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.
6729    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6730    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6731    /// * *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.
6732    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6733    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6734    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceRenameCall<'a, C>
6735    where
6736        T: AsRef<str>,
6737    {
6738        self._additional_params
6739            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6740        self
6741    }
6742
6743    /// Identifies the authorization scope for the method you are building.
6744    ///
6745    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6746    /// [`Scope::CloudPlatform`].
6747    ///
6748    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6749    /// tokens for more than one scope.
6750    ///
6751    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6752    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6753    /// sufficient, a read-write scope will do as well.
6754    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceRenameCall<'a, C>
6755    where
6756        St: AsRef<str>,
6757    {
6758        self._scopes.insert(String::from(scope.as_ref()));
6759        self
6760    }
6761    /// Identifies the authorization scope(s) for the method you are building.
6762    ///
6763    /// See [`Self::add_scope()`] for details.
6764    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceRenameCall<'a, C>
6765    where
6766        I: IntoIterator<Item = St>,
6767        St: AsRef<str>,
6768    {
6769        self._scopes
6770            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6771        self
6772    }
6773
6774    /// Removes all scopes, and no default scope will be used either.
6775    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6776    /// for details).
6777    pub fn clear_scopes(mut self) -> ProjectLocationInstanceRenameCall<'a, C> {
6778        self._scopes.clear();
6779        self
6780    }
6781}
6782
6783/// Perform an ungraceful, hard reset on a server. Equivalent to shutting the power off and then turning it back on.
6784///
6785/// A builder for the *locations.instances.reset* method supported by a *project* resource.
6786/// It is not used directly, but through a [`ProjectMethods`] instance.
6787///
6788/// # Example
6789///
6790/// Instantiate a resource method builder
6791///
6792/// ```test_harness,no_run
6793/// # extern crate hyper;
6794/// # extern crate hyper_rustls;
6795/// # extern crate google_baremetalsolution2 as baremetalsolution2;
6796/// use baremetalsolution2::api::ResetInstanceRequest;
6797/// # async fn dox() {
6798/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6799///
6800/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6801/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6802/// #     .with_native_roots()
6803/// #     .unwrap()
6804/// #     .https_only()
6805/// #     .enable_http2()
6806/// #     .build();
6807///
6808/// # let executor = hyper_util::rt::TokioExecutor::new();
6809/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6810/// #     secret,
6811/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6812/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6813/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6814/// #     ),
6815/// # ).build().await.unwrap();
6816///
6817/// # let client = hyper_util::client::legacy::Client::builder(
6818/// #     hyper_util::rt::TokioExecutor::new()
6819/// # )
6820/// # .build(
6821/// #     hyper_rustls::HttpsConnectorBuilder::new()
6822/// #         .with_native_roots()
6823/// #         .unwrap()
6824/// #         .https_or_http()
6825/// #         .enable_http2()
6826/// #         .build()
6827/// # );
6828/// # let mut hub = Baremetalsolution::new(client, auth);
6829/// // As the method needs a request, you would usually fill it with the desired information
6830/// // into the respective structure. Some of the parts shown here might not be applicable !
6831/// // Values shown here are possibly random and not representative !
6832/// let mut req = ResetInstanceRequest::default();
6833///
6834/// // You can configure optional parameters by calling the respective setters at will, and
6835/// // execute the final call using `doit()`.
6836/// // Values shown here are possibly random and not representative !
6837/// let result = hub.projects().locations_instances_reset(req, "name")
6838///              .doit().await;
6839/// # }
6840/// ```
6841pub struct ProjectLocationInstanceResetCall<'a, C>
6842where
6843    C: 'a,
6844{
6845    hub: &'a Baremetalsolution<C>,
6846    _request: ResetInstanceRequest,
6847    _name: String,
6848    _delegate: Option<&'a mut dyn common::Delegate>,
6849    _additional_params: HashMap<String, String>,
6850    _scopes: BTreeSet<String>,
6851}
6852
6853impl<'a, C> common::CallBuilder for ProjectLocationInstanceResetCall<'a, C> {}
6854
6855impl<'a, C> ProjectLocationInstanceResetCall<'a, C>
6856where
6857    C: common::Connector,
6858{
6859    /// Perform the operation you have build so far.
6860    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6861        use std::borrow::Cow;
6862        use std::io::{Read, Seek};
6863
6864        use common::{url::Params, ToParts};
6865        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6866
6867        let mut dd = common::DefaultDelegate;
6868        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6869        dlg.begin(common::MethodInfo {
6870            id: "baremetalsolution.projects.locations.instances.reset",
6871            http_method: hyper::Method::POST,
6872        });
6873
6874        for &field in ["alt", "name"].iter() {
6875            if self._additional_params.contains_key(field) {
6876                dlg.finished(false);
6877                return Err(common::Error::FieldClash(field));
6878            }
6879        }
6880
6881        let mut params = Params::with_capacity(4 + self._additional_params.len());
6882        params.push("name", self._name);
6883
6884        params.extend(self._additional_params.iter());
6885
6886        params.push("alt", "json");
6887        let mut url = self.hub._base_url.clone() + "v2/{+name}:reset";
6888        if self._scopes.is_empty() {
6889            self._scopes
6890                .insert(Scope::CloudPlatform.as_ref().to_string());
6891        }
6892
6893        #[allow(clippy::single_element_loop)]
6894        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6895            url = params.uri_replacement(url, param_name, find_this, true);
6896        }
6897        {
6898            let to_remove = ["name"];
6899            params.remove_params(&to_remove);
6900        }
6901
6902        let url = params.parse_with_url(&url);
6903
6904        let mut json_mime_type = mime::APPLICATION_JSON;
6905        let mut request_value_reader = {
6906            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6907            common::remove_json_null_values(&mut value);
6908            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6909            serde_json::to_writer(&mut dst, &value).unwrap();
6910            dst
6911        };
6912        let request_size = request_value_reader
6913            .seek(std::io::SeekFrom::End(0))
6914            .unwrap();
6915        request_value_reader
6916            .seek(std::io::SeekFrom::Start(0))
6917            .unwrap();
6918
6919        loop {
6920            let token = match self
6921                .hub
6922                .auth
6923                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6924                .await
6925            {
6926                Ok(token) => token,
6927                Err(e) => match dlg.token(e) {
6928                    Ok(token) => token,
6929                    Err(e) => {
6930                        dlg.finished(false);
6931                        return Err(common::Error::MissingToken(e));
6932                    }
6933                },
6934            };
6935            request_value_reader
6936                .seek(std::io::SeekFrom::Start(0))
6937                .unwrap();
6938            let mut req_result = {
6939                let client = &self.hub.client;
6940                dlg.pre_request();
6941                let mut req_builder = hyper::Request::builder()
6942                    .method(hyper::Method::POST)
6943                    .uri(url.as_str())
6944                    .header(USER_AGENT, self.hub._user_agent.clone());
6945
6946                if let Some(token) = token.as_ref() {
6947                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6948                }
6949
6950                let request = req_builder
6951                    .header(CONTENT_TYPE, json_mime_type.to_string())
6952                    .header(CONTENT_LENGTH, request_size as u64)
6953                    .body(common::to_body(
6954                        request_value_reader.get_ref().clone().into(),
6955                    ));
6956
6957                client.request(request.unwrap()).await
6958            };
6959
6960            match req_result {
6961                Err(err) => {
6962                    if let common::Retry::After(d) = dlg.http_error(&err) {
6963                        sleep(d).await;
6964                        continue;
6965                    }
6966                    dlg.finished(false);
6967                    return Err(common::Error::HttpError(err));
6968                }
6969                Ok(res) => {
6970                    let (mut parts, body) = res.into_parts();
6971                    let mut body = common::Body::new(body);
6972                    if !parts.status.is_success() {
6973                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6974                        let error = serde_json::from_str(&common::to_string(&bytes));
6975                        let response = common::to_response(parts, bytes.into());
6976
6977                        if let common::Retry::After(d) =
6978                            dlg.http_failure(&response, error.as_ref().ok())
6979                        {
6980                            sleep(d).await;
6981                            continue;
6982                        }
6983
6984                        dlg.finished(false);
6985
6986                        return Err(match error {
6987                            Ok(value) => common::Error::BadRequest(value),
6988                            _ => common::Error::Failure(response),
6989                        });
6990                    }
6991                    let response = {
6992                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6993                        let encoded = common::to_string(&bytes);
6994                        match serde_json::from_str(&encoded) {
6995                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6996                            Err(error) => {
6997                                dlg.response_json_decode_error(&encoded, &error);
6998                                return Err(common::Error::JsonDecodeError(
6999                                    encoded.to_string(),
7000                                    error,
7001                                ));
7002                            }
7003                        }
7004                    };
7005
7006                    dlg.finished(true);
7007                    return Ok(response);
7008                }
7009            }
7010        }
7011    }
7012
7013    ///
7014    /// Sets the *request* property to the given value.
7015    ///
7016    /// Even though the property as already been set when instantiating this call,
7017    /// we provide this method for API completeness.
7018    pub fn request(
7019        mut self,
7020        new_value: ResetInstanceRequest,
7021    ) -> ProjectLocationInstanceResetCall<'a, C> {
7022        self._request = new_value;
7023        self
7024    }
7025    /// Required. Name of the resource.
7026    ///
7027    /// Sets the *name* path property to the given value.
7028    ///
7029    /// Even though the property as already been set when instantiating this call,
7030    /// we provide this method for API completeness.
7031    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceResetCall<'a, C> {
7032        self._name = new_value.to_string();
7033        self
7034    }
7035    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7036    /// while executing the actual API request.
7037    ///
7038    /// ````text
7039    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7040    /// ````
7041    ///
7042    /// Sets the *delegate* property to the given value.
7043    pub fn delegate(
7044        mut self,
7045        new_value: &'a mut dyn common::Delegate,
7046    ) -> ProjectLocationInstanceResetCall<'a, C> {
7047        self._delegate = Some(new_value);
7048        self
7049    }
7050
7051    /// Set any additional parameter of the query string used in the request.
7052    /// It should be used to set parameters which are not yet available through their own
7053    /// setters.
7054    ///
7055    /// Please note that this method must not be used to set any of the known parameters
7056    /// which have their own setter method. If done anyway, the request will fail.
7057    ///
7058    /// # Additional Parameters
7059    ///
7060    /// * *$.xgafv* (query-string) - V1 error format.
7061    /// * *access_token* (query-string) - OAuth access token.
7062    /// * *alt* (query-string) - Data format for response.
7063    /// * *callback* (query-string) - JSONP
7064    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7065    /// * *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.
7066    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7067    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7068    /// * *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.
7069    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7070    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7071    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceResetCall<'a, C>
7072    where
7073        T: AsRef<str>,
7074    {
7075        self._additional_params
7076            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7077        self
7078    }
7079
7080    /// Identifies the authorization scope for the method you are building.
7081    ///
7082    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7083    /// [`Scope::CloudPlatform`].
7084    ///
7085    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7086    /// tokens for more than one scope.
7087    ///
7088    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7089    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7090    /// sufficient, a read-write scope will do as well.
7091    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceResetCall<'a, C>
7092    where
7093        St: AsRef<str>,
7094    {
7095        self._scopes.insert(String::from(scope.as_ref()));
7096        self
7097    }
7098    /// Identifies the authorization scope(s) for the method you are building.
7099    ///
7100    /// See [`Self::add_scope()`] for details.
7101    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceResetCall<'a, C>
7102    where
7103        I: IntoIterator<Item = St>,
7104        St: AsRef<str>,
7105    {
7106        self._scopes
7107            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7108        self
7109    }
7110
7111    /// Removes all scopes, and no default scope will be used either.
7112    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7113    /// for details).
7114    pub fn clear_scopes(mut self) -> ProjectLocationInstanceResetCall<'a, C> {
7115        self._scopes.clear();
7116        self
7117    }
7118}
7119
7120/// Starts a server that was shutdown.
7121///
7122/// A builder for the *locations.instances.start* method supported by a *project* resource.
7123/// It is not used directly, but through a [`ProjectMethods`] instance.
7124///
7125/// # Example
7126///
7127/// Instantiate a resource method builder
7128///
7129/// ```test_harness,no_run
7130/// # extern crate hyper;
7131/// # extern crate hyper_rustls;
7132/// # extern crate google_baremetalsolution2 as baremetalsolution2;
7133/// use baremetalsolution2::api::StartInstanceRequest;
7134/// # async fn dox() {
7135/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7136///
7137/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7138/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7139/// #     .with_native_roots()
7140/// #     .unwrap()
7141/// #     .https_only()
7142/// #     .enable_http2()
7143/// #     .build();
7144///
7145/// # let executor = hyper_util::rt::TokioExecutor::new();
7146/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7147/// #     secret,
7148/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7149/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7150/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7151/// #     ),
7152/// # ).build().await.unwrap();
7153///
7154/// # let client = hyper_util::client::legacy::Client::builder(
7155/// #     hyper_util::rt::TokioExecutor::new()
7156/// # )
7157/// # .build(
7158/// #     hyper_rustls::HttpsConnectorBuilder::new()
7159/// #         .with_native_roots()
7160/// #         .unwrap()
7161/// #         .https_or_http()
7162/// #         .enable_http2()
7163/// #         .build()
7164/// # );
7165/// # let mut hub = Baremetalsolution::new(client, auth);
7166/// // As the method needs a request, you would usually fill it with the desired information
7167/// // into the respective structure. Some of the parts shown here might not be applicable !
7168/// // Values shown here are possibly random and not representative !
7169/// let mut req = StartInstanceRequest::default();
7170///
7171/// // You can configure optional parameters by calling the respective setters at will, and
7172/// // execute the final call using `doit()`.
7173/// // Values shown here are possibly random and not representative !
7174/// let result = hub.projects().locations_instances_start(req, "name")
7175///              .doit().await;
7176/// # }
7177/// ```
7178pub struct ProjectLocationInstanceStartCall<'a, C>
7179where
7180    C: 'a,
7181{
7182    hub: &'a Baremetalsolution<C>,
7183    _request: StartInstanceRequest,
7184    _name: String,
7185    _delegate: Option<&'a mut dyn common::Delegate>,
7186    _additional_params: HashMap<String, String>,
7187    _scopes: BTreeSet<String>,
7188}
7189
7190impl<'a, C> common::CallBuilder for ProjectLocationInstanceStartCall<'a, C> {}
7191
7192impl<'a, C> ProjectLocationInstanceStartCall<'a, C>
7193where
7194    C: common::Connector,
7195{
7196    /// Perform the operation you have build so far.
7197    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7198        use std::borrow::Cow;
7199        use std::io::{Read, Seek};
7200
7201        use common::{url::Params, ToParts};
7202        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7203
7204        let mut dd = common::DefaultDelegate;
7205        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7206        dlg.begin(common::MethodInfo {
7207            id: "baremetalsolution.projects.locations.instances.start",
7208            http_method: hyper::Method::POST,
7209        });
7210
7211        for &field in ["alt", "name"].iter() {
7212            if self._additional_params.contains_key(field) {
7213                dlg.finished(false);
7214                return Err(common::Error::FieldClash(field));
7215            }
7216        }
7217
7218        let mut params = Params::with_capacity(4 + self._additional_params.len());
7219        params.push("name", self._name);
7220
7221        params.extend(self._additional_params.iter());
7222
7223        params.push("alt", "json");
7224        let mut url = self.hub._base_url.clone() + "v2/{+name}:start";
7225        if self._scopes.is_empty() {
7226            self._scopes
7227                .insert(Scope::CloudPlatform.as_ref().to_string());
7228        }
7229
7230        #[allow(clippy::single_element_loop)]
7231        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7232            url = params.uri_replacement(url, param_name, find_this, true);
7233        }
7234        {
7235            let to_remove = ["name"];
7236            params.remove_params(&to_remove);
7237        }
7238
7239        let url = params.parse_with_url(&url);
7240
7241        let mut json_mime_type = mime::APPLICATION_JSON;
7242        let mut request_value_reader = {
7243            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7244            common::remove_json_null_values(&mut value);
7245            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7246            serde_json::to_writer(&mut dst, &value).unwrap();
7247            dst
7248        };
7249        let request_size = request_value_reader
7250            .seek(std::io::SeekFrom::End(0))
7251            .unwrap();
7252        request_value_reader
7253            .seek(std::io::SeekFrom::Start(0))
7254            .unwrap();
7255
7256        loop {
7257            let token = match self
7258                .hub
7259                .auth
7260                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7261                .await
7262            {
7263                Ok(token) => token,
7264                Err(e) => match dlg.token(e) {
7265                    Ok(token) => token,
7266                    Err(e) => {
7267                        dlg.finished(false);
7268                        return Err(common::Error::MissingToken(e));
7269                    }
7270                },
7271            };
7272            request_value_reader
7273                .seek(std::io::SeekFrom::Start(0))
7274                .unwrap();
7275            let mut req_result = {
7276                let client = &self.hub.client;
7277                dlg.pre_request();
7278                let mut req_builder = hyper::Request::builder()
7279                    .method(hyper::Method::POST)
7280                    .uri(url.as_str())
7281                    .header(USER_AGENT, self.hub._user_agent.clone());
7282
7283                if let Some(token) = token.as_ref() {
7284                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7285                }
7286
7287                let request = req_builder
7288                    .header(CONTENT_TYPE, json_mime_type.to_string())
7289                    .header(CONTENT_LENGTH, request_size as u64)
7290                    .body(common::to_body(
7291                        request_value_reader.get_ref().clone().into(),
7292                    ));
7293
7294                client.request(request.unwrap()).await
7295            };
7296
7297            match req_result {
7298                Err(err) => {
7299                    if let common::Retry::After(d) = dlg.http_error(&err) {
7300                        sleep(d).await;
7301                        continue;
7302                    }
7303                    dlg.finished(false);
7304                    return Err(common::Error::HttpError(err));
7305                }
7306                Ok(res) => {
7307                    let (mut parts, body) = res.into_parts();
7308                    let mut body = common::Body::new(body);
7309                    if !parts.status.is_success() {
7310                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7311                        let error = serde_json::from_str(&common::to_string(&bytes));
7312                        let response = common::to_response(parts, bytes.into());
7313
7314                        if let common::Retry::After(d) =
7315                            dlg.http_failure(&response, error.as_ref().ok())
7316                        {
7317                            sleep(d).await;
7318                            continue;
7319                        }
7320
7321                        dlg.finished(false);
7322
7323                        return Err(match error {
7324                            Ok(value) => common::Error::BadRequest(value),
7325                            _ => common::Error::Failure(response),
7326                        });
7327                    }
7328                    let response = {
7329                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7330                        let encoded = common::to_string(&bytes);
7331                        match serde_json::from_str(&encoded) {
7332                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7333                            Err(error) => {
7334                                dlg.response_json_decode_error(&encoded, &error);
7335                                return Err(common::Error::JsonDecodeError(
7336                                    encoded.to_string(),
7337                                    error,
7338                                ));
7339                            }
7340                        }
7341                    };
7342
7343                    dlg.finished(true);
7344                    return Ok(response);
7345                }
7346            }
7347        }
7348    }
7349
7350    ///
7351    /// Sets the *request* property to the given value.
7352    ///
7353    /// Even though the property as already been set when instantiating this call,
7354    /// we provide this method for API completeness.
7355    pub fn request(
7356        mut self,
7357        new_value: StartInstanceRequest,
7358    ) -> ProjectLocationInstanceStartCall<'a, C> {
7359        self._request = new_value;
7360        self
7361    }
7362    /// Required. Name of the resource.
7363    ///
7364    /// Sets the *name* path property to the given value.
7365    ///
7366    /// Even though the property as already been set when instantiating this call,
7367    /// we provide this method for API completeness.
7368    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceStartCall<'a, C> {
7369        self._name = new_value.to_string();
7370        self
7371    }
7372    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7373    /// while executing the actual API request.
7374    ///
7375    /// ````text
7376    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7377    /// ````
7378    ///
7379    /// Sets the *delegate* property to the given value.
7380    pub fn delegate(
7381        mut self,
7382        new_value: &'a mut dyn common::Delegate,
7383    ) -> ProjectLocationInstanceStartCall<'a, C> {
7384        self._delegate = Some(new_value);
7385        self
7386    }
7387
7388    /// Set any additional parameter of the query string used in the request.
7389    /// It should be used to set parameters which are not yet available through their own
7390    /// setters.
7391    ///
7392    /// Please note that this method must not be used to set any of the known parameters
7393    /// which have their own setter method. If done anyway, the request will fail.
7394    ///
7395    /// # Additional Parameters
7396    ///
7397    /// * *$.xgafv* (query-string) - V1 error format.
7398    /// * *access_token* (query-string) - OAuth access token.
7399    /// * *alt* (query-string) - Data format for response.
7400    /// * *callback* (query-string) - JSONP
7401    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7402    /// * *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.
7403    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7404    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7405    /// * *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.
7406    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7407    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7408    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceStartCall<'a, C>
7409    where
7410        T: AsRef<str>,
7411    {
7412        self._additional_params
7413            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7414        self
7415    }
7416
7417    /// Identifies the authorization scope for the method you are building.
7418    ///
7419    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7420    /// [`Scope::CloudPlatform`].
7421    ///
7422    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7423    /// tokens for more than one scope.
7424    ///
7425    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7426    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7427    /// sufficient, a read-write scope will do as well.
7428    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceStartCall<'a, C>
7429    where
7430        St: AsRef<str>,
7431    {
7432        self._scopes.insert(String::from(scope.as_ref()));
7433        self
7434    }
7435    /// Identifies the authorization scope(s) for the method you are building.
7436    ///
7437    /// See [`Self::add_scope()`] for details.
7438    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceStartCall<'a, C>
7439    where
7440        I: IntoIterator<Item = St>,
7441        St: AsRef<str>,
7442    {
7443        self._scopes
7444            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7445        self
7446    }
7447
7448    /// Removes all scopes, and no default scope will be used either.
7449    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7450    /// for details).
7451    pub fn clear_scopes(mut self) -> ProjectLocationInstanceStartCall<'a, C> {
7452        self._scopes.clear();
7453        self
7454    }
7455}
7456
7457/// Stop a running server.
7458///
7459/// A builder for the *locations.instances.stop* method supported by a *project* resource.
7460/// It is not used directly, but through a [`ProjectMethods`] instance.
7461///
7462/// # Example
7463///
7464/// Instantiate a resource method builder
7465///
7466/// ```test_harness,no_run
7467/// # extern crate hyper;
7468/// # extern crate hyper_rustls;
7469/// # extern crate google_baremetalsolution2 as baremetalsolution2;
7470/// use baremetalsolution2::api::StopInstanceRequest;
7471/// # async fn dox() {
7472/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7473///
7474/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7475/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7476/// #     .with_native_roots()
7477/// #     .unwrap()
7478/// #     .https_only()
7479/// #     .enable_http2()
7480/// #     .build();
7481///
7482/// # let executor = hyper_util::rt::TokioExecutor::new();
7483/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7484/// #     secret,
7485/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7486/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7487/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7488/// #     ),
7489/// # ).build().await.unwrap();
7490///
7491/// # let client = hyper_util::client::legacy::Client::builder(
7492/// #     hyper_util::rt::TokioExecutor::new()
7493/// # )
7494/// # .build(
7495/// #     hyper_rustls::HttpsConnectorBuilder::new()
7496/// #         .with_native_roots()
7497/// #         .unwrap()
7498/// #         .https_or_http()
7499/// #         .enable_http2()
7500/// #         .build()
7501/// # );
7502/// # let mut hub = Baremetalsolution::new(client, auth);
7503/// // As the method needs a request, you would usually fill it with the desired information
7504/// // into the respective structure. Some of the parts shown here might not be applicable !
7505/// // Values shown here are possibly random and not representative !
7506/// let mut req = StopInstanceRequest::default();
7507///
7508/// // You can configure optional parameters by calling the respective setters at will, and
7509/// // execute the final call using `doit()`.
7510/// // Values shown here are possibly random and not representative !
7511/// let result = hub.projects().locations_instances_stop(req, "name")
7512///              .doit().await;
7513/// # }
7514/// ```
7515pub struct ProjectLocationInstanceStopCall<'a, C>
7516where
7517    C: 'a,
7518{
7519    hub: &'a Baremetalsolution<C>,
7520    _request: StopInstanceRequest,
7521    _name: String,
7522    _delegate: Option<&'a mut dyn common::Delegate>,
7523    _additional_params: HashMap<String, String>,
7524    _scopes: BTreeSet<String>,
7525}
7526
7527impl<'a, C> common::CallBuilder for ProjectLocationInstanceStopCall<'a, C> {}
7528
7529impl<'a, C> ProjectLocationInstanceStopCall<'a, C>
7530where
7531    C: common::Connector,
7532{
7533    /// Perform the operation you have build so far.
7534    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7535        use std::borrow::Cow;
7536        use std::io::{Read, Seek};
7537
7538        use common::{url::Params, ToParts};
7539        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7540
7541        let mut dd = common::DefaultDelegate;
7542        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7543        dlg.begin(common::MethodInfo {
7544            id: "baremetalsolution.projects.locations.instances.stop",
7545            http_method: hyper::Method::POST,
7546        });
7547
7548        for &field in ["alt", "name"].iter() {
7549            if self._additional_params.contains_key(field) {
7550                dlg.finished(false);
7551                return Err(common::Error::FieldClash(field));
7552            }
7553        }
7554
7555        let mut params = Params::with_capacity(4 + self._additional_params.len());
7556        params.push("name", self._name);
7557
7558        params.extend(self._additional_params.iter());
7559
7560        params.push("alt", "json");
7561        let mut url = self.hub._base_url.clone() + "v2/{+name}:stop";
7562        if self._scopes.is_empty() {
7563            self._scopes
7564                .insert(Scope::CloudPlatform.as_ref().to_string());
7565        }
7566
7567        #[allow(clippy::single_element_loop)]
7568        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7569            url = params.uri_replacement(url, param_name, find_this, true);
7570        }
7571        {
7572            let to_remove = ["name"];
7573            params.remove_params(&to_remove);
7574        }
7575
7576        let url = params.parse_with_url(&url);
7577
7578        let mut json_mime_type = mime::APPLICATION_JSON;
7579        let mut request_value_reader = {
7580            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7581            common::remove_json_null_values(&mut value);
7582            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7583            serde_json::to_writer(&mut dst, &value).unwrap();
7584            dst
7585        };
7586        let request_size = request_value_reader
7587            .seek(std::io::SeekFrom::End(0))
7588            .unwrap();
7589        request_value_reader
7590            .seek(std::io::SeekFrom::Start(0))
7591            .unwrap();
7592
7593        loop {
7594            let token = match self
7595                .hub
7596                .auth
7597                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7598                .await
7599            {
7600                Ok(token) => token,
7601                Err(e) => match dlg.token(e) {
7602                    Ok(token) => token,
7603                    Err(e) => {
7604                        dlg.finished(false);
7605                        return Err(common::Error::MissingToken(e));
7606                    }
7607                },
7608            };
7609            request_value_reader
7610                .seek(std::io::SeekFrom::Start(0))
7611                .unwrap();
7612            let mut req_result = {
7613                let client = &self.hub.client;
7614                dlg.pre_request();
7615                let mut req_builder = hyper::Request::builder()
7616                    .method(hyper::Method::POST)
7617                    .uri(url.as_str())
7618                    .header(USER_AGENT, self.hub._user_agent.clone());
7619
7620                if let Some(token) = token.as_ref() {
7621                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7622                }
7623
7624                let request = req_builder
7625                    .header(CONTENT_TYPE, json_mime_type.to_string())
7626                    .header(CONTENT_LENGTH, request_size as u64)
7627                    .body(common::to_body(
7628                        request_value_reader.get_ref().clone().into(),
7629                    ));
7630
7631                client.request(request.unwrap()).await
7632            };
7633
7634            match req_result {
7635                Err(err) => {
7636                    if let common::Retry::After(d) = dlg.http_error(&err) {
7637                        sleep(d).await;
7638                        continue;
7639                    }
7640                    dlg.finished(false);
7641                    return Err(common::Error::HttpError(err));
7642                }
7643                Ok(res) => {
7644                    let (mut parts, body) = res.into_parts();
7645                    let mut body = common::Body::new(body);
7646                    if !parts.status.is_success() {
7647                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7648                        let error = serde_json::from_str(&common::to_string(&bytes));
7649                        let response = common::to_response(parts, bytes.into());
7650
7651                        if let common::Retry::After(d) =
7652                            dlg.http_failure(&response, error.as_ref().ok())
7653                        {
7654                            sleep(d).await;
7655                            continue;
7656                        }
7657
7658                        dlg.finished(false);
7659
7660                        return Err(match error {
7661                            Ok(value) => common::Error::BadRequest(value),
7662                            _ => common::Error::Failure(response),
7663                        });
7664                    }
7665                    let response = {
7666                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7667                        let encoded = common::to_string(&bytes);
7668                        match serde_json::from_str(&encoded) {
7669                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7670                            Err(error) => {
7671                                dlg.response_json_decode_error(&encoded, &error);
7672                                return Err(common::Error::JsonDecodeError(
7673                                    encoded.to_string(),
7674                                    error,
7675                                ));
7676                            }
7677                        }
7678                    };
7679
7680                    dlg.finished(true);
7681                    return Ok(response);
7682                }
7683            }
7684        }
7685    }
7686
7687    ///
7688    /// Sets the *request* property to the given value.
7689    ///
7690    /// Even though the property as already been set when instantiating this call,
7691    /// we provide this method for API completeness.
7692    pub fn request(
7693        mut self,
7694        new_value: StopInstanceRequest,
7695    ) -> ProjectLocationInstanceStopCall<'a, C> {
7696        self._request = new_value;
7697        self
7698    }
7699    /// Required. Name of the resource.
7700    ///
7701    /// Sets the *name* path property to the given value.
7702    ///
7703    /// Even though the property as already been set when instantiating this call,
7704    /// we provide this method for API completeness.
7705    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceStopCall<'a, C> {
7706        self._name = new_value.to_string();
7707        self
7708    }
7709    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7710    /// while executing the actual API request.
7711    ///
7712    /// ````text
7713    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7714    /// ````
7715    ///
7716    /// Sets the *delegate* property to the given value.
7717    pub fn delegate(
7718        mut self,
7719        new_value: &'a mut dyn common::Delegate,
7720    ) -> ProjectLocationInstanceStopCall<'a, C> {
7721        self._delegate = Some(new_value);
7722        self
7723    }
7724
7725    /// Set any additional parameter of the query string used in the request.
7726    /// It should be used to set parameters which are not yet available through their own
7727    /// setters.
7728    ///
7729    /// Please note that this method must not be used to set any of the known parameters
7730    /// which have their own setter method. If done anyway, the request will fail.
7731    ///
7732    /// # Additional Parameters
7733    ///
7734    /// * *$.xgafv* (query-string) - V1 error format.
7735    /// * *access_token* (query-string) - OAuth access token.
7736    /// * *alt* (query-string) - Data format for response.
7737    /// * *callback* (query-string) - JSONP
7738    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7739    /// * *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.
7740    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7741    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7742    /// * *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.
7743    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7744    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7745    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceStopCall<'a, C>
7746    where
7747        T: AsRef<str>,
7748    {
7749        self._additional_params
7750            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7751        self
7752    }
7753
7754    /// Identifies the authorization scope for the method you are building.
7755    ///
7756    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7757    /// [`Scope::CloudPlatform`].
7758    ///
7759    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7760    /// tokens for more than one scope.
7761    ///
7762    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7763    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7764    /// sufficient, a read-write scope will do as well.
7765    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceStopCall<'a, C>
7766    where
7767        St: AsRef<str>,
7768    {
7769        self._scopes.insert(String::from(scope.as_ref()));
7770        self
7771    }
7772    /// Identifies the authorization scope(s) for the method you are building.
7773    ///
7774    /// See [`Self::add_scope()`] for details.
7775    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceStopCall<'a, C>
7776    where
7777        I: IntoIterator<Item = St>,
7778        St: AsRef<str>,
7779    {
7780        self._scopes
7781            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7782        self
7783    }
7784
7785    /// Removes all scopes, and no default scope will be used either.
7786    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7787    /// for details).
7788    pub fn clear_scopes(mut self) -> ProjectLocationInstanceStopCall<'a, C> {
7789        self._scopes.clear();
7790        self
7791    }
7792}
7793
7794/// Get details of a single network.
7795///
7796/// A builder for the *locations.networks.get* method supported by a *project* resource.
7797/// It is not used directly, but through a [`ProjectMethods`] instance.
7798///
7799/// # Example
7800///
7801/// Instantiate a resource method builder
7802///
7803/// ```test_harness,no_run
7804/// # extern crate hyper;
7805/// # extern crate hyper_rustls;
7806/// # extern crate google_baremetalsolution2 as baremetalsolution2;
7807/// # async fn dox() {
7808/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7809///
7810/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7811/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7812/// #     .with_native_roots()
7813/// #     .unwrap()
7814/// #     .https_only()
7815/// #     .enable_http2()
7816/// #     .build();
7817///
7818/// # let executor = hyper_util::rt::TokioExecutor::new();
7819/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7820/// #     secret,
7821/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7822/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7823/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7824/// #     ),
7825/// # ).build().await.unwrap();
7826///
7827/// # let client = hyper_util::client::legacy::Client::builder(
7828/// #     hyper_util::rt::TokioExecutor::new()
7829/// # )
7830/// # .build(
7831/// #     hyper_rustls::HttpsConnectorBuilder::new()
7832/// #         .with_native_roots()
7833/// #         .unwrap()
7834/// #         .https_or_http()
7835/// #         .enable_http2()
7836/// #         .build()
7837/// # );
7838/// # let mut hub = Baremetalsolution::new(client, auth);
7839/// // You can configure optional parameters by calling the respective setters at will, and
7840/// // execute the final call using `doit()`.
7841/// // Values shown here are possibly random and not representative !
7842/// let result = hub.projects().locations_networks_get("name")
7843///              .doit().await;
7844/// # }
7845/// ```
7846pub struct ProjectLocationNetworkGetCall<'a, C>
7847where
7848    C: 'a,
7849{
7850    hub: &'a Baremetalsolution<C>,
7851    _name: String,
7852    _delegate: Option<&'a mut dyn common::Delegate>,
7853    _additional_params: HashMap<String, String>,
7854    _scopes: BTreeSet<String>,
7855}
7856
7857impl<'a, C> common::CallBuilder for ProjectLocationNetworkGetCall<'a, C> {}
7858
7859impl<'a, C> ProjectLocationNetworkGetCall<'a, C>
7860where
7861    C: common::Connector,
7862{
7863    /// Perform the operation you have build so far.
7864    pub async fn doit(mut self) -> common::Result<(common::Response, Network)> {
7865        use std::borrow::Cow;
7866        use std::io::{Read, Seek};
7867
7868        use common::{url::Params, ToParts};
7869        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7870
7871        let mut dd = common::DefaultDelegate;
7872        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7873        dlg.begin(common::MethodInfo {
7874            id: "baremetalsolution.projects.locations.networks.get",
7875            http_method: hyper::Method::GET,
7876        });
7877
7878        for &field in ["alt", "name"].iter() {
7879            if self._additional_params.contains_key(field) {
7880                dlg.finished(false);
7881                return Err(common::Error::FieldClash(field));
7882            }
7883        }
7884
7885        let mut params = Params::with_capacity(3 + self._additional_params.len());
7886        params.push("name", self._name);
7887
7888        params.extend(self._additional_params.iter());
7889
7890        params.push("alt", "json");
7891        let mut url = self.hub._base_url.clone() + "v2/{+name}";
7892        if self._scopes.is_empty() {
7893            self._scopes
7894                .insert(Scope::CloudPlatform.as_ref().to_string());
7895        }
7896
7897        #[allow(clippy::single_element_loop)]
7898        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7899            url = params.uri_replacement(url, param_name, find_this, true);
7900        }
7901        {
7902            let to_remove = ["name"];
7903            params.remove_params(&to_remove);
7904        }
7905
7906        let url = params.parse_with_url(&url);
7907
7908        loop {
7909            let token = match self
7910                .hub
7911                .auth
7912                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7913                .await
7914            {
7915                Ok(token) => token,
7916                Err(e) => match dlg.token(e) {
7917                    Ok(token) => token,
7918                    Err(e) => {
7919                        dlg.finished(false);
7920                        return Err(common::Error::MissingToken(e));
7921                    }
7922                },
7923            };
7924            let mut req_result = {
7925                let client = &self.hub.client;
7926                dlg.pre_request();
7927                let mut req_builder = hyper::Request::builder()
7928                    .method(hyper::Method::GET)
7929                    .uri(url.as_str())
7930                    .header(USER_AGENT, self.hub._user_agent.clone());
7931
7932                if let Some(token) = token.as_ref() {
7933                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7934                }
7935
7936                let request = req_builder
7937                    .header(CONTENT_LENGTH, 0_u64)
7938                    .body(common::to_body::<String>(None));
7939
7940                client.request(request.unwrap()).await
7941            };
7942
7943            match req_result {
7944                Err(err) => {
7945                    if let common::Retry::After(d) = dlg.http_error(&err) {
7946                        sleep(d).await;
7947                        continue;
7948                    }
7949                    dlg.finished(false);
7950                    return Err(common::Error::HttpError(err));
7951                }
7952                Ok(res) => {
7953                    let (mut parts, body) = res.into_parts();
7954                    let mut body = common::Body::new(body);
7955                    if !parts.status.is_success() {
7956                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7957                        let error = serde_json::from_str(&common::to_string(&bytes));
7958                        let response = common::to_response(parts, bytes.into());
7959
7960                        if let common::Retry::After(d) =
7961                            dlg.http_failure(&response, error.as_ref().ok())
7962                        {
7963                            sleep(d).await;
7964                            continue;
7965                        }
7966
7967                        dlg.finished(false);
7968
7969                        return Err(match error {
7970                            Ok(value) => common::Error::BadRequest(value),
7971                            _ => common::Error::Failure(response),
7972                        });
7973                    }
7974                    let response = {
7975                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7976                        let encoded = common::to_string(&bytes);
7977                        match serde_json::from_str(&encoded) {
7978                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7979                            Err(error) => {
7980                                dlg.response_json_decode_error(&encoded, &error);
7981                                return Err(common::Error::JsonDecodeError(
7982                                    encoded.to_string(),
7983                                    error,
7984                                ));
7985                            }
7986                        }
7987                    };
7988
7989                    dlg.finished(true);
7990                    return Ok(response);
7991                }
7992            }
7993        }
7994    }
7995
7996    /// Required. Name of the resource.
7997    ///
7998    /// Sets the *name* path property to the given value.
7999    ///
8000    /// Even though the property as already been set when instantiating this call,
8001    /// we provide this method for API completeness.
8002    pub fn name(mut self, new_value: &str) -> ProjectLocationNetworkGetCall<'a, C> {
8003        self._name = new_value.to_string();
8004        self
8005    }
8006    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8007    /// while executing the actual API request.
8008    ///
8009    /// ````text
8010    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8011    /// ````
8012    ///
8013    /// Sets the *delegate* property to the given value.
8014    pub fn delegate(
8015        mut self,
8016        new_value: &'a mut dyn common::Delegate,
8017    ) -> ProjectLocationNetworkGetCall<'a, C> {
8018        self._delegate = Some(new_value);
8019        self
8020    }
8021
8022    /// Set any additional parameter of the query string used in the request.
8023    /// It should be used to set parameters which are not yet available through their own
8024    /// setters.
8025    ///
8026    /// Please note that this method must not be used to set any of the known parameters
8027    /// which have their own setter method. If done anyway, the request will fail.
8028    ///
8029    /// # Additional Parameters
8030    ///
8031    /// * *$.xgafv* (query-string) - V1 error format.
8032    /// * *access_token* (query-string) - OAuth access token.
8033    /// * *alt* (query-string) - Data format for response.
8034    /// * *callback* (query-string) - JSONP
8035    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8036    /// * *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.
8037    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8038    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8039    /// * *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.
8040    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8041    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8042    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNetworkGetCall<'a, C>
8043    where
8044        T: AsRef<str>,
8045    {
8046        self._additional_params
8047            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8048        self
8049    }
8050
8051    /// Identifies the authorization scope for the method you are building.
8052    ///
8053    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8054    /// [`Scope::CloudPlatform`].
8055    ///
8056    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8057    /// tokens for more than one scope.
8058    ///
8059    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8060    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8061    /// sufficient, a read-write scope will do as well.
8062    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNetworkGetCall<'a, C>
8063    where
8064        St: AsRef<str>,
8065    {
8066        self._scopes.insert(String::from(scope.as_ref()));
8067        self
8068    }
8069    /// Identifies the authorization scope(s) for the method you are building.
8070    ///
8071    /// See [`Self::add_scope()`] for details.
8072    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNetworkGetCall<'a, C>
8073    where
8074        I: IntoIterator<Item = St>,
8075        St: AsRef<str>,
8076    {
8077        self._scopes
8078            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8079        self
8080    }
8081
8082    /// Removes all scopes, and no default scope will be used either.
8083    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8084    /// for details).
8085    pub fn clear_scopes(mut self) -> ProjectLocationNetworkGetCall<'a, C> {
8086        self._scopes.clear();
8087        self
8088    }
8089}
8090
8091/// List network in a given project and location.
8092///
8093/// A builder for the *locations.networks.list* method supported by a *project* resource.
8094/// It is not used directly, but through a [`ProjectMethods`] instance.
8095///
8096/// # Example
8097///
8098/// Instantiate a resource method builder
8099///
8100/// ```test_harness,no_run
8101/// # extern crate hyper;
8102/// # extern crate hyper_rustls;
8103/// # extern crate google_baremetalsolution2 as baremetalsolution2;
8104/// # async fn dox() {
8105/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8106///
8107/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8108/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8109/// #     .with_native_roots()
8110/// #     .unwrap()
8111/// #     .https_only()
8112/// #     .enable_http2()
8113/// #     .build();
8114///
8115/// # let executor = hyper_util::rt::TokioExecutor::new();
8116/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8117/// #     secret,
8118/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8119/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8120/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8121/// #     ),
8122/// # ).build().await.unwrap();
8123///
8124/// # let client = hyper_util::client::legacy::Client::builder(
8125/// #     hyper_util::rt::TokioExecutor::new()
8126/// # )
8127/// # .build(
8128/// #     hyper_rustls::HttpsConnectorBuilder::new()
8129/// #         .with_native_roots()
8130/// #         .unwrap()
8131/// #         .https_or_http()
8132/// #         .enable_http2()
8133/// #         .build()
8134/// # );
8135/// # let mut hub = Baremetalsolution::new(client, auth);
8136/// // You can configure optional parameters by calling the respective setters at will, and
8137/// // execute the final call using `doit()`.
8138/// // Values shown here are possibly random and not representative !
8139/// let result = hub.projects().locations_networks_list("parent")
8140///              .page_token("duo")
8141///              .page_size(-50)
8142///              .filter("sed")
8143///              .doit().await;
8144/// # }
8145/// ```
8146pub struct ProjectLocationNetworkListCall<'a, C>
8147where
8148    C: 'a,
8149{
8150    hub: &'a Baremetalsolution<C>,
8151    _parent: String,
8152    _page_token: Option<String>,
8153    _page_size: Option<i32>,
8154    _filter: Option<String>,
8155    _delegate: Option<&'a mut dyn common::Delegate>,
8156    _additional_params: HashMap<String, String>,
8157    _scopes: BTreeSet<String>,
8158}
8159
8160impl<'a, C> common::CallBuilder for ProjectLocationNetworkListCall<'a, C> {}
8161
8162impl<'a, C> ProjectLocationNetworkListCall<'a, C>
8163where
8164    C: common::Connector,
8165{
8166    /// Perform the operation you have build so far.
8167    pub async fn doit(mut self) -> common::Result<(common::Response, ListNetworksResponse)> {
8168        use std::borrow::Cow;
8169        use std::io::{Read, Seek};
8170
8171        use common::{url::Params, ToParts};
8172        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8173
8174        let mut dd = common::DefaultDelegate;
8175        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8176        dlg.begin(common::MethodInfo {
8177            id: "baremetalsolution.projects.locations.networks.list",
8178            http_method: hyper::Method::GET,
8179        });
8180
8181        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
8182            if self._additional_params.contains_key(field) {
8183                dlg.finished(false);
8184                return Err(common::Error::FieldClash(field));
8185            }
8186        }
8187
8188        let mut params = Params::with_capacity(6 + self._additional_params.len());
8189        params.push("parent", self._parent);
8190        if let Some(value) = self._page_token.as_ref() {
8191            params.push("pageToken", value);
8192        }
8193        if let Some(value) = self._page_size.as_ref() {
8194            params.push("pageSize", value.to_string());
8195        }
8196        if let Some(value) = self._filter.as_ref() {
8197            params.push("filter", value);
8198        }
8199
8200        params.extend(self._additional_params.iter());
8201
8202        params.push("alt", "json");
8203        let mut url = self.hub._base_url.clone() + "v2/{+parent}/networks";
8204        if self._scopes.is_empty() {
8205            self._scopes
8206                .insert(Scope::CloudPlatform.as_ref().to_string());
8207        }
8208
8209        #[allow(clippy::single_element_loop)]
8210        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8211            url = params.uri_replacement(url, param_name, find_this, true);
8212        }
8213        {
8214            let to_remove = ["parent"];
8215            params.remove_params(&to_remove);
8216        }
8217
8218        let url = params.parse_with_url(&url);
8219
8220        loop {
8221            let token = match self
8222                .hub
8223                .auth
8224                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8225                .await
8226            {
8227                Ok(token) => token,
8228                Err(e) => match dlg.token(e) {
8229                    Ok(token) => token,
8230                    Err(e) => {
8231                        dlg.finished(false);
8232                        return Err(common::Error::MissingToken(e));
8233                    }
8234                },
8235            };
8236            let mut req_result = {
8237                let client = &self.hub.client;
8238                dlg.pre_request();
8239                let mut req_builder = hyper::Request::builder()
8240                    .method(hyper::Method::GET)
8241                    .uri(url.as_str())
8242                    .header(USER_AGENT, self.hub._user_agent.clone());
8243
8244                if let Some(token) = token.as_ref() {
8245                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8246                }
8247
8248                let request = req_builder
8249                    .header(CONTENT_LENGTH, 0_u64)
8250                    .body(common::to_body::<String>(None));
8251
8252                client.request(request.unwrap()).await
8253            };
8254
8255            match req_result {
8256                Err(err) => {
8257                    if let common::Retry::After(d) = dlg.http_error(&err) {
8258                        sleep(d).await;
8259                        continue;
8260                    }
8261                    dlg.finished(false);
8262                    return Err(common::Error::HttpError(err));
8263                }
8264                Ok(res) => {
8265                    let (mut parts, body) = res.into_parts();
8266                    let mut body = common::Body::new(body);
8267                    if !parts.status.is_success() {
8268                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8269                        let error = serde_json::from_str(&common::to_string(&bytes));
8270                        let response = common::to_response(parts, bytes.into());
8271
8272                        if let common::Retry::After(d) =
8273                            dlg.http_failure(&response, error.as_ref().ok())
8274                        {
8275                            sleep(d).await;
8276                            continue;
8277                        }
8278
8279                        dlg.finished(false);
8280
8281                        return Err(match error {
8282                            Ok(value) => common::Error::BadRequest(value),
8283                            _ => common::Error::Failure(response),
8284                        });
8285                    }
8286                    let response = {
8287                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8288                        let encoded = common::to_string(&bytes);
8289                        match serde_json::from_str(&encoded) {
8290                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8291                            Err(error) => {
8292                                dlg.response_json_decode_error(&encoded, &error);
8293                                return Err(common::Error::JsonDecodeError(
8294                                    encoded.to_string(),
8295                                    error,
8296                                ));
8297                            }
8298                        }
8299                    };
8300
8301                    dlg.finished(true);
8302                    return Ok(response);
8303                }
8304            }
8305        }
8306    }
8307
8308    /// Required. Parent value for ListNetworksRequest.
8309    ///
8310    /// Sets the *parent* path property to the given value.
8311    ///
8312    /// Even though the property as already been set when instantiating this call,
8313    /// we provide this method for API completeness.
8314    pub fn parent(mut self, new_value: &str) -> ProjectLocationNetworkListCall<'a, C> {
8315        self._parent = new_value.to_string();
8316        self
8317    }
8318    /// A token identifying a page of results from the server.
8319    ///
8320    /// Sets the *page token* query property to the given value.
8321    pub fn page_token(mut self, new_value: &str) -> ProjectLocationNetworkListCall<'a, C> {
8322        self._page_token = Some(new_value.to_string());
8323        self
8324    }
8325    /// Requested page size. The server might return fewer items than requested. If unspecified, server will pick an appropriate default.
8326    ///
8327    /// Sets the *page size* query property to the given value.
8328    pub fn page_size(mut self, new_value: i32) -> ProjectLocationNetworkListCall<'a, C> {
8329        self._page_size = Some(new_value);
8330        self
8331    }
8332    /// List filter.
8333    ///
8334    /// Sets the *filter* query property to the given value.
8335    pub fn filter(mut self, new_value: &str) -> ProjectLocationNetworkListCall<'a, C> {
8336        self._filter = Some(new_value.to_string());
8337        self
8338    }
8339    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8340    /// while executing the actual API request.
8341    ///
8342    /// ````text
8343    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8344    /// ````
8345    ///
8346    /// Sets the *delegate* property to the given value.
8347    pub fn delegate(
8348        mut self,
8349        new_value: &'a mut dyn common::Delegate,
8350    ) -> ProjectLocationNetworkListCall<'a, C> {
8351        self._delegate = Some(new_value);
8352        self
8353    }
8354
8355    /// Set any additional parameter of the query string used in the request.
8356    /// It should be used to set parameters which are not yet available through their own
8357    /// setters.
8358    ///
8359    /// Please note that this method must not be used to set any of the known parameters
8360    /// which have their own setter method. If done anyway, the request will fail.
8361    ///
8362    /// # Additional Parameters
8363    ///
8364    /// * *$.xgafv* (query-string) - V1 error format.
8365    /// * *access_token* (query-string) - OAuth access token.
8366    /// * *alt* (query-string) - Data format for response.
8367    /// * *callback* (query-string) - JSONP
8368    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8369    /// * *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.
8370    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8371    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8372    /// * *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.
8373    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8374    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8375    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNetworkListCall<'a, C>
8376    where
8377        T: AsRef<str>,
8378    {
8379        self._additional_params
8380            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8381        self
8382    }
8383
8384    /// Identifies the authorization scope for the method you are building.
8385    ///
8386    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8387    /// [`Scope::CloudPlatform`].
8388    ///
8389    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8390    /// tokens for more than one scope.
8391    ///
8392    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8393    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8394    /// sufficient, a read-write scope will do as well.
8395    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNetworkListCall<'a, C>
8396    where
8397        St: AsRef<str>,
8398    {
8399        self._scopes.insert(String::from(scope.as_ref()));
8400        self
8401    }
8402    /// Identifies the authorization scope(s) for the method you are building.
8403    ///
8404    /// See [`Self::add_scope()`] for details.
8405    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNetworkListCall<'a, C>
8406    where
8407        I: IntoIterator<Item = St>,
8408        St: AsRef<str>,
8409    {
8410        self._scopes
8411            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8412        self
8413    }
8414
8415    /// Removes all scopes, and no default scope will be used either.
8416    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8417    /// for details).
8418    pub fn clear_scopes(mut self) -> ProjectLocationNetworkListCall<'a, C> {
8419        self._scopes.clear();
8420        self
8421    }
8422}
8423
8424/// List all Networks (and used IPs for each Network) in the vendor account associated with the specified project.
8425///
8426/// A builder for the *locations.networks.listNetworkUsage* method supported by a *project* resource.
8427/// It is not used directly, but through a [`ProjectMethods`] instance.
8428///
8429/// # Example
8430///
8431/// Instantiate a resource method builder
8432///
8433/// ```test_harness,no_run
8434/// # extern crate hyper;
8435/// # extern crate hyper_rustls;
8436/// # extern crate google_baremetalsolution2 as baremetalsolution2;
8437/// # async fn dox() {
8438/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8439///
8440/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8441/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8442/// #     .with_native_roots()
8443/// #     .unwrap()
8444/// #     .https_only()
8445/// #     .enable_http2()
8446/// #     .build();
8447///
8448/// # let executor = hyper_util::rt::TokioExecutor::new();
8449/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8450/// #     secret,
8451/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8452/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8453/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8454/// #     ),
8455/// # ).build().await.unwrap();
8456///
8457/// # let client = hyper_util::client::legacy::Client::builder(
8458/// #     hyper_util::rt::TokioExecutor::new()
8459/// # )
8460/// # .build(
8461/// #     hyper_rustls::HttpsConnectorBuilder::new()
8462/// #         .with_native_roots()
8463/// #         .unwrap()
8464/// #         .https_or_http()
8465/// #         .enable_http2()
8466/// #         .build()
8467/// # );
8468/// # let mut hub = Baremetalsolution::new(client, auth);
8469/// // You can configure optional parameters by calling the respective setters at will, and
8470/// // execute the final call using `doit()`.
8471/// // Values shown here are possibly random and not representative !
8472/// let result = hub.projects().locations_networks_list_network_usage("location")
8473///              .doit().await;
8474/// # }
8475/// ```
8476pub struct ProjectLocationNetworkListNetworkUsageCall<'a, C>
8477where
8478    C: 'a,
8479{
8480    hub: &'a Baremetalsolution<C>,
8481    _location: String,
8482    _delegate: Option<&'a mut dyn common::Delegate>,
8483    _additional_params: HashMap<String, String>,
8484    _scopes: BTreeSet<String>,
8485}
8486
8487impl<'a, C> common::CallBuilder for ProjectLocationNetworkListNetworkUsageCall<'a, C> {}
8488
8489impl<'a, C> ProjectLocationNetworkListNetworkUsageCall<'a, C>
8490where
8491    C: common::Connector,
8492{
8493    /// Perform the operation you have build so far.
8494    pub async fn doit(mut self) -> common::Result<(common::Response, ListNetworkUsageResponse)> {
8495        use std::borrow::Cow;
8496        use std::io::{Read, Seek};
8497
8498        use common::{url::Params, ToParts};
8499        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8500
8501        let mut dd = common::DefaultDelegate;
8502        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8503        dlg.begin(common::MethodInfo {
8504            id: "baremetalsolution.projects.locations.networks.listNetworkUsage",
8505            http_method: hyper::Method::GET,
8506        });
8507
8508        for &field in ["alt", "location"].iter() {
8509            if self._additional_params.contains_key(field) {
8510                dlg.finished(false);
8511                return Err(common::Error::FieldClash(field));
8512            }
8513        }
8514
8515        let mut params = Params::with_capacity(3 + self._additional_params.len());
8516        params.push("location", self._location);
8517
8518        params.extend(self._additional_params.iter());
8519
8520        params.push("alt", "json");
8521        let mut url = self.hub._base_url.clone() + "v2/{+location}/networks:listNetworkUsage";
8522        if self._scopes.is_empty() {
8523            self._scopes
8524                .insert(Scope::CloudPlatform.as_ref().to_string());
8525        }
8526
8527        #[allow(clippy::single_element_loop)]
8528        for &(find_this, param_name) in [("{+location}", "location")].iter() {
8529            url = params.uri_replacement(url, param_name, find_this, true);
8530        }
8531        {
8532            let to_remove = ["location"];
8533            params.remove_params(&to_remove);
8534        }
8535
8536        let url = params.parse_with_url(&url);
8537
8538        loop {
8539            let token = match self
8540                .hub
8541                .auth
8542                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8543                .await
8544            {
8545                Ok(token) => token,
8546                Err(e) => match dlg.token(e) {
8547                    Ok(token) => token,
8548                    Err(e) => {
8549                        dlg.finished(false);
8550                        return Err(common::Error::MissingToken(e));
8551                    }
8552                },
8553            };
8554            let mut req_result = {
8555                let client = &self.hub.client;
8556                dlg.pre_request();
8557                let mut req_builder = hyper::Request::builder()
8558                    .method(hyper::Method::GET)
8559                    .uri(url.as_str())
8560                    .header(USER_AGENT, self.hub._user_agent.clone());
8561
8562                if let Some(token) = token.as_ref() {
8563                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8564                }
8565
8566                let request = req_builder
8567                    .header(CONTENT_LENGTH, 0_u64)
8568                    .body(common::to_body::<String>(None));
8569
8570                client.request(request.unwrap()).await
8571            };
8572
8573            match req_result {
8574                Err(err) => {
8575                    if let common::Retry::After(d) = dlg.http_error(&err) {
8576                        sleep(d).await;
8577                        continue;
8578                    }
8579                    dlg.finished(false);
8580                    return Err(common::Error::HttpError(err));
8581                }
8582                Ok(res) => {
8583                    let (mut parts, body) = res.into_parts();
8584                    let mut body = common::Body::new(body);
8585                    if !parts.status.is_success() {
8586                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8587                        let error = serde_json::from_str(&common::to_string(&bytes));
8588                        let response = common::to_response(parts, bytes.into());
8589
8590                        if let common::Retry::After(d) =
8591                            dlg.http_failure(&response, error.as_ref().ok())
8592                        {
8593                            sleep(d).await;
8594                            continue;
8595                        }
8596
8597                        dlg.finished(false);
8598
8599                        return Err(match error {
8600                            Ok(value) => common::Error::BadRequest(value),
8601                            _ => common::Error::Failure(response),
8602                        });
8603                    }
8604                    let response = {
8605                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8606                        let encoded = common::to_string(&bytes);
8607                        match serde_json::from_str(&encoded) {
8608                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8609                            Err(error) => {
8610                                dlg.response_json_decode_error(&encoded, &error);
8611                                return Err(common::Error::JsonDecodeError(
8612                                    encoded.to_string(),
8613                                    error,
8614                                ));
8615                            }
8616                        }
8617                    };
8618
8619                    dlg.finished(true);
8620                    return Ok(response);
8621                }
8622            }
8623        }
8624    }
8625
8626    /// Required. Parent value (project and location).
8627    ///
8628    /// Sets the *location* path property to the given value.
8629    ///
8630    /// Even though the property as already been set when instantiating this call,
8631    /// we provide this method for API completeness.
8632    pub fn location(
8633        mut self,
8634        new_value: &str,
8635    ) -> ProjectLocationNetworkListNetworkUsageCall<'a, C> {
8636        self._location = new_value.to_string();
8637        self
8638    }
8639    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8640    /// while executing the actual API request.
8641    ///
8642    /// ````text
8643    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8644    /// ````
8645    ///
8646    /// Sets the *delegate* property to the given value.
8647    pub fn delegate(
8648        mut self,
8649        new_value: &'a mut dyn common::Delegate,
8650    ) -> ProjectLocationNetworkListNetworkUsageCall<'a, C> {
8651        self._delegate = Some(new_value);
8652        self
8653    }
8654
8655    /// Set any additional parameter of the query string used in the request.
8656    /// It should be used to set parameters which are not yet available through their own
8657    /// setters.
8658    ///
8659    /// Please note that this method must not be used to set any of the known parameters
8660    /// which have their own setter method. If done anyway, the request will fail.
8661    ///
8662    /// # Additional Parameters
8663    ///
8664    /// * *$.xgafv* (query-string) - V1 error format.
8665    /// * *access_token* (query-string) - OAuth access token.
8666    /// * *alt* (query-string) - Data format for response.
8667    /// * *callback* (query-string) - JSONP
8668    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8669    /// * *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.
8670    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8671    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8672    /// * *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.
8673    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8674    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8675    pub fn param<T>(
8676        mut self,
8677        name: T,
8678        value: T,
8679    ) -> ProjectLocationNetworkListNetworkUsageCall<'a, C>
8680    where
8681        T: AsRef<str>,
8682    {
8683        self._additional_params
8684            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8685        self
8686    }
8687
8688    /// Identifies the authorization scope for the method you are building.
8689    ///
8690    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8691    /// [`Scope::CloudPlatform`].
8692    ///
8693    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8694    /// tokens for more than one scope.
8695    ///
8696    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8697    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8698    /// sufficient, a read-write scope will do as well.
8699    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNetworkListNetworkUsageCall<'a, C>
8700    where
8701        St: AsRef<str>,
8702    {
8703        self._scopes.insert(String::from(scope.as_ref()));
8704        self
8705    }
8706    /// Identifies the authorization scope(s) for the method you are building.
8707    ///
8708    /// See [`Self::add_scope()`] for details.
8709    pub fn add_scopes<I, St>(
8710        mut self,
8711        scopes: I,
8712    ) -> ProjectLocationNetworkListNetworkUsageCall<'a, C>
8713    where
8714        I: IntoIterator<Item = St>,
8715        St: AsRef<str>,
8716    {
8717        self._scopes
8718            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8719        self
8720    }
8721
8722    /// Removes all scopes, and no default scope will be used either.
8723    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8724    /// for details).
8725    pub fn clear_scopes(mut self) -> ProjectLocationNetworkListNetworkUsageCall<'a, C> {
8726        self._scopes.clear();
8727        self
8728    }
8729}
8730
8731/// Update details of a single network.
8732///
8733/// A builder for the *locations.networks.patch* method supported by a *project* resource.
8734/// It is not used directly, but through a [`ProjectMethods`] instance.
8735///
8736/// # Example
8737///
8738/// Instantiate a resource method builder
8739///
8740/// ```test_harness,no_run
8741/// # extern crate hyper;
8742/// # extern crate hyper_rustls;
8743/// # extern crate google_baremetalsolution2 as baremetalsolution2;
8744/// use baremetalsolution2::api::Network;
8745/// # async fn dox() {
8746/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8747///
8748/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8749/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8750/// #     .with_native_roots()
8751/// #     .unwrap()
8752/// #     .https_only()
8753/// #     .enable_http2()
8754/// #     .build();
8755///
8756/// # let executor = hyper_util::rt::TokioExecutor::new();
8757/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8758/// #     secret,
8759/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8760/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8761/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8762/// #     ),
8763/// # ).build().await.unwrap();
8764///
8765/// # let client = hyper_util::client::legacy::Client::builder(
8766/// #     hyper_util::rt::TokioExecutor::new()
8767/// # )
8768/// # .build(
8769/// #     hyper_rustls::HttpsConnectorBuilder::new()
8770/// #         .with_native_roots()
8771/// #         .unwrap()
8772/// #         .https_or_http()
8773/// #         .enable_http2()
8774/// #         .build()
8775/// # );
8776/// # let mut hub = Baremetalsolution::new(client, auth);
8777/// // As the method needs a request, you would usually fill it with the desired information
8778/// // into the respective structure. Some of the parts shown here might not be applicable !
8779/// // Values shown here are possibly random and not representative !
8780/// let mut req = Network::default();
8781///
8782/// // You can configure optional parameters by calling the respective setters at will, and
8783/// // execute the final call using `doit()`.
8784/// // Values shown here are possibly random and not representative !
8785/// let result = hub.projects().locations_networks_patch(req, "name")
8786///              .update_mask(FieldMask::new::<&str>(&[]))
8787///              .doit().await;
8788/// # }
8789/// ```
8790pub struct ProjectLocationNetworkPatchCall<'a, C>
8791where
8792    C: 'a,
8793{
8794    hub: &'a Baremetalsolution<C>,
8795    _request: Network,
8796    _name: String,
8797    _update_mask: Option<common::FieldMask>,
8798    _delegate: Option<&'a mut dyn common::Delegate>,
8799    _additional_params: HashMap<String, String>,
8800    _scopes: BTreeSet<String>,
8801}
8802
8803impl<'a, C> common::CallBuilder for ProjectLocationNetworkPatchCall<'a, C> {}
8804
8805impl<'a, C> ProjectLocationNetworkPatchCall<'a, C>
8806where
8807    C: common::Connector,
8808{
8809    /// Perform the operation you have build so far.
8810    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8811        use std::borrow::Cow;
8812        use std::io::{Read, Seek};
8813
8814        use common::{url::Params, ToParts};
8815        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8816
8817        let mut dd = common::DefaultDelegate;
8818        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8819        dlg.begin(common::MethodInfo {
8820            id: "baremetalsolution.projects.locations.networks.patch",
8821            http_method: hyper::Method::PATCH,
8822        });
8823
8824        for &field in ["alt", "name", "updateMask"].iter() {
8825            if self._additional_params.contains_key(field) {
8826                dlg.finished(false);
8827                return Err(common::Error::FieldClash(field));
8828            }
8829        }
8830
8831        let mut params = Params::with_capacity(5 + self._additional_params.len());
8832        params.push("name", self._name);
8833        if let Some(value) = self._update_mask.as_ref() {
8834            params.push("updateMask", value.to_string());
8835        }
8836
8837        params.extend(self._additional_params.iter());
8838
8839        params.push("alt", "json");
8840        let mut url = self.hub._base_url.clone() + "v2/{+name}";
8841        if self._scopes.is_empty() {
8842            self._scopes
8843                .insert(Scope::CloudPlatform.as_ref().to_string());
8844        }
8845
8846        #[allow(clippy::single_element_loop)]
8847        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8848            url = params.uri_replacement(url, param_name, find_this, true);
8849        }
8850        {
8851            let to_remove = ["name"];
8852            params.remove_params(&to_remove);
8853        }
8854
8855        let url = params.parse_with_url(&url);
8856
8857        let mut json_mime_type = mime::APPLICATION_JSON;
8858        let mut request_value_reader = {
8859            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8860            common::remove_json_null_values(&mut value);
8861            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8862            serde_json::to_writer(&mut dst, &value).unwrap();
8863            dst
8864        };
8865        let request_size = request_value_reader
8866            .seek(std::io::SeekFrom::End(0))
8867            .unwrap();
8868        request_value_reader
8869            .seek(std::io::SeekFrom::Start(0))
8870            .unwrap();
8871
8872        loop {
8873            let token = match self
8874                .hub
8875                .auth
8876                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8877                .await
8878            {
8879                Ok(token) => token,
8880                Err(e) => match dlg.token(e) {
8881                    Ok(token) => token,
8882                    Err(e) => {
8883                        dlg.finished(false);
8884                        return Err(common::Error::MissingToken(e));
8885                    }
8886                },
8887            };
8888            request_value_reader
8889                .seek(std::io::SeekFrom::Start(0))
8890                .unwrap();
8891            let mut req_result = {
8892                let client = &self.hub.client;
8893                dlg.pre_request();
8894                let mut req_builder = hyper::Request::builder()
8895                    .method(hyper::Method::PATCH)
8896                    .uri(url.as_str())
8897                    .header(USER_AGENT, self.hub._user_agent.clone());
8898
8899                if let Some(token) = token.as_ref() {
8900                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8901                }
8902
8903                let request = req_builder
8904                    .header(CONTENT_TYPE, json_mime_type.to_string())
8905                    .header(CONTENT_LENGTH, request_size as u64)
8906                    .body(common::to_body(
8907                        request_value_reader.get_ref().clone().into(),
8908                    ));
8909
8910                client.request(request.unwrap()).await
8911            };
8912
8913            match req_result {
8914                Err(err) => {
8915                    if let common::Retry::After(d) = dlg.http_error(&err) {
8916                        sleep(d).await;
8917                        continue;
8918                    }
8919                    dlg.finished(false);
8920                    return Err(common::Error::HttpError(err));
8921                }
8922                Ok(res) => {
8923                    let (mut parts, body) = res.into_parts();
8924                    let mut body = common::Body::new(body);
8925                    if !parts.status.is_success() {
8926                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8927                        let error = serde_json::from_str(&common::to_string(&bytes));
8928                        let response = common::to_response(parts, bytes.into());
8929
8930                        if let common::Retry::After(d) =
8931                            dlg.http_failure(&response, error.as_ref().ok())
8932                        {
8933                            sleep(d).await;
8934                            continue;
8935                        }
8936
8937                        dlg.finished(false);
8938
8939                        return Err(match error {
8940                            Ok(value) => common::Error::BadRequest(value),
8941                            _ => common::Error::Failure(response),
8942                        });
8943                    }
8944                    let response = {
8945                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8946                        let encoded = common::to_string(&bytes);
8947                        match serde_json::from_str(&encoded) {
8948                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8949                            Err(error) => {
8950                                dlg.response_json_decode_error(&encoded, &error);
8951                                return Err(common::Error::JsonDecodeError(
8952                                    encoded.to_string(),
8953                                    error,
8954                                ));
8955                            }
8956                        }
8957                    };
8958
8959                    dlg.finished(true);
8960                    return Ok(response);
8961                }
8962            }
8963        }
8964    }
8965
8966    ///
8967    /// Sets the *request* property to the given value.
8968    ///
8969    /// Even though the property as already been set when instantiating this call,
8970    /// we provide this method for API completeness.
8971    pub fn request(mut self, new_value: Network) -> ProjectLocationNetworkPatchCall<'a, C> {
8972        self._request = new_value;
8973        self
8974    }
8975    /// Output only. The resource name of this `Network`. Resource names are schemeless URIs that follow the conventions in https://cloud.google.com/apis/design/resource_names. Format: `projects/{project}/locations/{location}/networks/{network}`
8976    ///
8977    /// Sets the *name* path property to the given value.
8978    ///
8979    /// Even though the property as already been set when instantiating this call,
8980    /// we provide this method for API completeness.
8981    pub fn name(mut self, new_value: &str) -> ProjectLocationNetworkPatchCall<'a, C> {
8982        self._name = new_value.to_string();
8983        self
8984    }
8985    /// The list of fields to update. The only currently supported fields are: `labels`, `reservations`, `vrf.vlan_attachments`
8986    ///
8987    /// Sets the *update mask* query property to the given value.
8988    pub fn update_mask(
8989        mut self,
8990        new_value: common::FieldMask,
8991    ) -> ProjectLocationNetworkPatchCall<'a, C> {
8992        self._update_mask = Some(new_value);
8993        self
8994    }
8995    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8996    /// while executing the actual API request.
8997    ///
8998    /// ````text
8999    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9000    /// ````
9001    ///
9002    /// Sets the *delegate* property to the given value.
9003    pub fn delegate(
9004        mut self,
9005        new_value: &'a mut dyn common::Delegate,
9006    ) -> ProjectLocationNetworkPatchCall<'a, C> {
9007        self._delegate = Some(new_value);
9008        self
9009    }
9010
9011    /// Set any additional parameter of the query string used in the request.
9012    /// It should be used to set parameters which are not yet available through their own
9013    /// setters.
9014    ///
9015    /// Please note that this method must not be used to set any of the known parameters
9016    /// which have their own setter method. If done anyway, the request will fail.
9017    ///
9018    /// # Additional Parameters
9019    ///
9020    /// * *$.xgafv* (query-string) - V1 error format.
9021    /// * *access_token* (query-string) - OAuth access token.
9022    /// * *alt* (query-string) - Data format for response.
9023    /// * *callback* (query-string) - JSONP
9024    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9025    /// * *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.
9026    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9027    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9028    /// * *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.
9029    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9030    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9031    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNetworkPatchCall<'a, C>
9032    where
9033        T: AsRef<str>,
9034    {
9035        self._additional_params
9036            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9037        self
9038    }
9039
9040    /// Identifies the authorization scope for the method you are building.
9041    ///
9042    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9043    /// [`Scope::CloudPlatform`].
9044    ///
9045    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9046    /// tokens for more than one scope.
9047    ///
9048    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9049    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9050    /// sufficient, a read-write scope will do as well.
9051    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNetworkPatchCall<'a, C>
9052    where
9053        St: AsRef<str>,
9054    {
9055        self._scopes.insert(String::from(scope.as_ref()));
9056        self
9057    }
9058    /// Identifies the authorization scope(s) for the method you are building.
9059    ///
9060    /// See [`Self::add_scope()`] for details.
9061    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNetworkPatchCall<'a, C>
9062    where
9063        I: IntoIterator<Item = St>,
9064        St: AsRef<str>,
9065    {
9066        self._scopes
9067            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9068        self
9069    }
9070
9071    /// Removes all scopes, and no default scope will be used either.
9072    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9073    /// for details).
9074    pub fn clear_scopes(mut self) -> ProjectLocationNetworkPatchCall<'a, C> {
9075        self._scopes.clear();
9076        self
9077    }
9078}
9079
9080/// RenameNetwork sets a new name for a network. Use with caution, previous names become immediately invalidated.
9081///
9082/// A builder for the *locations.networks.rename* method supported by a *project* resource.
9083/// It is not used directly, but through a [`ProjectMethods`] instance.
9084///
9085/// # Example
9086///
9087/// Instantiate a resource method builder
9088///
9089/// ```test_harness,no_run
9090/// # extern crate hyper;
9091/// # extern crate hyper_rustls;
9092/// # extern crate google_baremetalsolution2 as baremetalsolution2;
9093/// use baremetalsolution2::api::RenameNetworkRequest;
9094/// # async fn dox() {
9095/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9096///
9097/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9098/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9099/// #     .with_native_roots()
9100/// #     .unwrap()
9101/// #     .https_only()
9102/// #     .enable_http2()
9103/// #     .build();
9104///
9105/// # let executor = hyper_util::rt::TokioExecutor::new();
9106/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9107/// #     secret,
9108/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9109/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9110/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9111/// #     ),
9112/// # ).build().await.unwrap();
9113///
9114/// # let client = hyper_util::client::legacy::Client::builder(
9115/// #     hyper_util::rt::TokioExecutor::new()
9116/// # )
9117/// # .build(
9118/// #     hyper_rustls::HttpsConnectorBuilder::new()
9119/// #         .with_native_roots()
9120/// #         .unwrap()
9121/// #         .https_or_http()
9122/// #         .enable_http2()
9123/// #         .build()
9124/// # );
9125/// # let mut hub = Baremetalsolution::new(client, auth);
9126/// // As the method needs a request, you would usually fill it with the desired information
9127/// // into the respective structure. Some of the parts shown here might not be applicable !
9128/// // Values shown here are possibly random and not representative !
9129/// let mut req = RenameNetworkRequest::default();
9130///
9131/// // You can configure optional parameters by calling the respective setters at will, and
9132/// // execute the final call using `doit()`.
9133/// // Values shown here are possibly random and not representative !
9134/// let result = hub.projects().locations_networks_rename(req, "name")
9135///              .doit().await;
9136/// # }
9137/// ```
9138pub struct ProjectLocationNetworkRenameCall<'a, C>
9139where
9140    C: 'a,
9141{
9142    hub: &'a Baremetalsolution<C>,
9143    _request: RenameNetworkRequest,
9144    _name: String,
9145    _delegate: Option<&'a mut dyn common::Delegate>,
9146    _additional_params: HashMap<String, String>,
9147    _scopes: BTreeSet<String>,
9148}
9149
9150impl<'a, C> common::CallBuilder for ProjectLocationNetworkRenameCall<'a, C> {}
9151
9152impl<'a, C> ProjectLocationNetworkRenameCall<'a, C>
9153where
9154    C: common::Connector,
9155{
9156    /// Perform the operation you have build so far.
9157    pub async fn doit(mut self) -> common::Result<(common::Response, Network)> {
9158        use std::borrow::Cow;
9159        use std::io::{Read, Seek};
9160
9161        use common::{url::Params, ToParts};
9162        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9163
9164        let mut dd = common::DefaultDelegate;
9165        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9166        dlg.begin(common::MethodInfo {
9167            id: "baremetalsolution.projects.locations.networks.rename",
9168            http_method: hyper::Method::POST,
9169        });
9170
9171        for &field in ["alt", "name"].iter() {
9172            if self._additional_params.contains_key(field) {
9173                dlg.finished(false);
9174                return Err(common::Error::FieldClash(field));
9175            }
9176        }
9177
9178        let mut params = Params::with_capacity(4 + self._additional_params.len());
9179        params.push("name", self._name);
9180
9181        params.extend(self._additional_params.iter());
9182
9183        params.push("alt", "json");
9184        let mut url = self.hub._base_url.clone() + "v2/{+name}:rename";
9185        if self._scopes.is_empty() {
9186            self._scopes
9187                .insert(Scope::CloudPlatform.as_ref().to_string());
9188        }
9189
9190        #[allow(clippy::single_element_loop)]
9191        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9192            url = params.uri_replacement(url, param_name, find_this, true);
9193        }
9194        {
9195            let to_remove = ["name"];
9196            params.remove_params(&to_remove);
9197        }
9198
9199        let url = params.parse_with_url(&url);
9200
9201        let mut json_mime_type = mime::APPLICATION_JSON;
9202        let mut request_value_reader = {
9203            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9204            common::remove_json_null_values(&mut value);
9205            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9206            serde_json::to_writer(&mut dst, &value).unwrap();
9207            dst
9208        };
9209        let request_size = request_value_reader
9210            .seek(std::io::SeekFrom::End(0))
9211            .unwrap();
9212        request_value_reader
9213            .seek(std::io::SeekFrom::Start(0))
9214            .unwrap();
9215
9216        loop {
9217            let token = match self
9218                .hub
9219                .auth
9220                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9221                .await
9222            {
9223                Ok(token) => token,
9224                Err(e) => match dlg.token(e) {
9225                    Ok(token) => token,
9226                    Err(e) => {
9227                        dlg.finished(false);
9228                        return Err(common::Error::MissingToken(e));
9229                    }
9230                },
9231            };
9232            request_value_reader
9233                .seek(std::io::SeekFrom::Start(0))
9234                .unwrap();
9235            let mut req_result = {
9236                let client = &self.hub.client;
9237                dlg.pre_request();
9238                let mut req_builder = hyper::Request::builder()
9239                    .method(hyper::Method::POST)
9240                    .uri(url.as_str())
9241                    .header(USER_AGENT, self.hub._user_agent.clone());
9242
9243                if let Some(token) = token.as_ref() {
9244                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9245                }
9246
9247                let request = req_builder
9248                    .header(CONTENT_TYPE, json_mime_type.to_string())
9249                    .header(CONTENT_LENGTH, request_size as u64)
9250                    .body(common::to_body(
9251                        request_value_reader.get_ref().clone().into(),
9252                    ));
9253
9254                client.request(request.unwrap()).await
9255            };
9256
9257            match req_result {
9258                Err(err) => {
9259                    if let common::Retry::After(d) = dlg.http_error(&err) {
9260                        sleep(d).await;
9261                        continue;
9262                    }
9263                    dlg.finished(false);
9264                    return Err(common::Error::HttpError(err));
9265                }
9266                Ok(res) => {
9267                    let (mut parts, body) = res.into_parts();
9268                    let mut body = common::Body::new(body);
9269                    if !parts.status.is_success() {
9270                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9271                        let error = serde_json::from_str(&common::to_string(&bytes));
9272                        let response = common::to_response(parts, bytes.into());
9273
9274                        if let common::Retry::After(d) =
9275                            dlg.http_failure(&response, error.as_ref().ok())
9276                        {
9277                            sleep(d).await;
9278                            continue;
9279                        }
9280
9281                        dlg.finished(false);
9282
9283                        return Err(match error {
9284                            Ok(value) => common::Error::BadRequest(value),
9285                            _ => common::Error::Failure(response),
9286                        });
9287                    }
9288                    let response = {
9289                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9290                        let encoded = common::to_string(&bytes);
9291                        match serde_json::from_str(&encoded) {
9292                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9293                            Err(error) => {
9294                                dlg.response_json_decode_error(&encoded, &error);
9295                                return Err(common::Error::JsonDecodeError(
9296                                    encoded.to_string(),
9297                                    error,
9298                                ));
9299                            }
9300                        }
9301                    };
9302
9303                    dlg.finished(true);
9304                    return Ok(response);
9305                }
9306            }
9307        }
9308    }
9309
9310    ///
9311    /// Sets the *request* property to the given value.
9312    ///
9313    /// Even though the property as already been set when instantiating this call,
9314    /// we provide this method for API completeness.
9315    pub fn request(
9316        mut self,
9317        new_value: RenameNetworkRequest,
9318    ) -> ProjectLocationNetworkRenameCall<'a, C> {
9319        self._request = new_value;
9320        self
9321    }
9322    /// Required. The `name` field is used to identify the network. Format: projects/{project}/locations/{location}/networks/{network}
9323    ///
9324    /// Sets the *name* path property to the given value.
9325    ///
9326    /// Even though the property as already been set when instantiating this call,
9327    /// we provide this method for API completeness.
9328    pub fn name(mut self, new_value: &str) -> ProjectLocationNetworkRenameCall<'a, C> {
9329        self._name = new_value.to_string();
9330        self
9331    }
9332    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9333    /// while executing the actual API request.
9334    ///
9335    /// ````text
9336    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9337    /// ````
9338    ///
9339    /// Sets the *delegate* property to the given value.
9340    pub fn delegate(
9341        mut self,
9342        new_value: &'a mut dyn common::Delegate,
9343    ) -> ProjectLocationNetworkRenameCall<'a, C> {
9344        self._delegate = Some(new_value);
9345        self
9346    }
9347
9348    /// Set any additional parameter of the query string used in the request.
9349    /// It should be used to set parameters which are not yet available through their own
9350    /// setters.
9351    ///
9352    /// Please note that this method must not be used to set any of the known parameters
9353    /// which have their own setter method. If done anyway, the request will fail.
9354    ///
9355    /// # Additional Parameters
9356    ///
9357    /// * *$.xgafv* (query-string) - V1 error format.
9358    /// * *access_token* (query-string) - OAuth access token.
9359    /// * *alt* (query-string) - Data format for response.
9360    /// * *callback* (query-string) - JSONP
9361    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9362    /// * *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.
9363    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9364    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9365    /// * *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.
9366    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9367    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9368    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNetworkRenameCall<'a, C>
9369    where
9370        T: AsRef<str>,
9371    {
9372        self._additional_params
9373            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9374        self
9375    }
9376
9377    /// Identifies the authorization scope for the method you are building.
9378    ///
9379    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9380    /// [`Scope::CloudPlatform`].
9381    ///
9382    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9383    /// tokens for more than one scope.
9384    ///
9385    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9386    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9387    /// sufficient, a read-write scope will do as well.
9388    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNetworkRenameCall<'a, C>
9389    where
9390        St: AsRef<str>,
9391    {
9392        self._scopes.insert(String::from(scope.as_ref()));
9393        self
9394    }
9395    /// Identifies the authorization scope(s) for the method you are building.
9396    ///
9397    /// See [`Self::add_scope()`] for details.
9398    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNetworkRenameCall<'a, C>
9399    where
9400        I: IntoIterator<Item = St>,
9401        St: AsRef<str>,
9402    {
9403        self._scopes
9404            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9405        self
9406    }
9407
9408    /// Removes all scopes, and no default scope will be used either.
9409    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9410    /// for details).
9411    pub fn clear_scopes(mut self) -> ProjectLocationNetworkRenameCall<'a, C> {
9412        self._scopes.clear();
9413        self
9414    }
9415}
9416
9417/// Create an NFS share.
9418///
9419/// A builder for the *locations.nfsShares.create* method supported by a *project* resource.
9420/// It is not used directly, but through a [`ProjectMethods`] instance.
9421///
9422/// # Example
9423///
9424/// Instantiate a resource method builder
9425///
9426/// ```test_harness,no_run
9427/// # extern crate hyper;
9428/// # extern crate hyper_rustls;
9429/// # extern crate google_baremetalsolution2 as baremetalsolution2;
9430/// use baremetalsolution2::api::NfsShare;
9431/// # async fn dox() {
9432/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9433///
9434/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9435/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9436/// #     .with_native_roots()
9437/// #     .unwrap()
9438/// #     .https_only()
9439/// #     .enable_http2()
9440/// #     .build();
9441///
9442/// # let executor = hyper_util::rt::TokioExecutor::new();
9443/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9444/// #     secret,
9445/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9446/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9447/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9448/// #     ),
9449/// # ).build().await.unwrap();
9450///
9451/// # let client = hyper_util::client::legacy::Client::builder(
9452/// #     hyper_util::rt::TokioExecutor::new()
9453/// # )
9454/// # .build(
9455/// #     hyper_rustls::HttpsConnectorBuilder::new()
9456/// #         .with_native_roots()
9457/// #         .unwrap()
9458/// #         .https_or_http()
9459/// #         .enable_http2()
9460/// #         .build()
9461/// # );
9462/// # let mut hub = Baremetalsolution::new(client, auth);
9463/// // As the method needs a request, you would usually fill it with the desired information
9464/// // into the respective structure. Some of the parts shown here might not be applicable !
9465/// // Values shown here are possibly random and not representative !
9466/// let mut req = NfsShare::default();
9467///
9468/// // You can configure optional parameters by calling the respective setters at will, and
9469/// // execute the final call using `doit()`.
9470/// // Values shown here are possibly random and not representative !
9471/// let result = hub.projects().locations_nfs_shares_create(req, "parent")
9472///              .doit().await;
9473/// # }
9474/// ```
9475pub struct ProjectLocationNfsShareCreateCall<'a, C>
9476where
9477    C: 'a,
9478{
9479    hub: &'a Baremetalsolution<C>,
9480    _request: NfsShare,
9481    _parent: String,
9482    _delegate: Option<&'a mut dyn common::Delegate>,
9483    _additional_params: HashMap<String, String>,
9484    _scopes: BTreeSet<String>,
9485}
9486
9487impl<'a, C> common::CallBuilder for ProjectLocationNfsShareCreateCall<'a, C> {}
9488
9489impl<'a, C> ProjectLocationNfsShareCreateCall<'a, C>
9490where
9491    C: common::Connector,
9492{
9493    /// Perform the operation you have build so far.
9494    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9495        use std::borrow::Cow;
9496        use std::io::{Read, Seek};
9497
9498        use common::{url::Params, ToParts};
9499        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9500
9501        let mut dd = common::DefaultDelegate;
9502        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9503        dlg.begin(common::MethodInfo {
9504            id: "baremetalsolution.projects.locations.nfsShares.create",
9505            http_method: hyper::Method::POST,
9506        });
9507
9508        for &field in ["alt", "parent"].iter() {
9509            if self._additional_params.contains_key(field) {
9510                dlg.finished(false);
9511                return Err(common::Error::FieldClash(field));
9512            }
9513        }
9514
9515        let mut params = Params::with_capacity(4 + self._additional_params.len());
9516        params.push("parent", self._parent);
9517
9518        params.extend(self._additional_params.iter());
9519
9520        params.push("alt", "json");
9521        let mut url = self.hub._base_url.clone() + "v2/{+parent}/nfsShares";
9522        if self._scopes.is_empty() {
9523            self._scopes
9524                .insert(Scope::CloudPlatform.as_ref().to_string());
9525        }
9526
9527        #[allow(clippy::single_element_loop)]
9528        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9529            url = params.uri_replacement(url, param_name, find_this, true);
9530        }
9531        {
9532            let to_remove = ["parent"];
9533            params.remove_params(&to_remove);
9534        }
9535
9536        let url = params.parse_with_url(&url);
9537
9538        let mut json_mime_type = mime::APPLICATION_JSON;
9539        let mut request_value_reader = {
9540            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9541            common::remove_json_null_values(&mut value);
9542            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9543            serde_json::to_writer(&mut dst, &value).unwrap();
9544            dst
9545        };
9546        let request_size = request_value_reader
9547            .seek(std::io::SeekFrom::End(0))
9548            .unwrap();
9549        request_value_reader
9550            .seek(std::io::SeekFrom::Start(0))
9551            .unwrap();
9552
9553        loop {
9554            let token = match self
9555                .hub
9556                .auth
9557                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9558                .await
9559            {
9560                Ok(token) => token,
9561                Err(e) => match dlg.token(e) {
9562                    Ok(token) => token,
9563                    Err(e) => {
9564                        dlg.finished(false);
9565                        return Err(common::Error::MissingToken(e));
9566                    }
9567                },
9568            };
9569            request_value_reader
9570                .seek(std::io::SeekFrom::Start(0))
9571                .unwrap();
9572            let mut req_result = {
9573                let client = &self.hub.client;
9574                dlg.pre_request();
9575                let mut req_builder = hyper::Request::builder()
9576                    .method(hyper::Method::POST)
9577                    .uri(url.as_str())
9578                    .header(USER_AGENT, self.hub._user_agent.clone());
9579
9580                if let Some(token) = token.as_ref() {
9581                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9582                }
9583
9584                let request = req_builder
9585                    .header(CONTENT_TYPE, json_mime_type.to_string())
9586                    .header(CONTENT_LENGTH, request_size as u64)
9587                    .body(common::to_body(
9588                        request_value_reader.get_ref().clone().into(),
9589                    ));
9590
9591                client.request(request.unwrap()).await
9592            };
9593
9594            match req_result {
9595                Err(err) => {
9596                    if let common::Retry::After(d) = dlg.http_error(&err) {
9597                        sleep(d).await;
9598                        continue;
9599                    }
9600                    dlg.finished(false);
9601                    return Err(common::Error::HttpError(err));
9602                }
9603                Ok(res) => {
9604                    let (mut parts, body) = res.into_parts();
9605                    let mut body = common::Body::new(body);
9606                    if !parts.status.is_success() {
9607                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9608                        let error = serde_json::from_str(&common::to_string(&bytes));
9609                        let response = common::to_response(parts, bytes.into());
9610
9611                        if let common::Retry::After(d) =
9612                            dlg.http_failure(&response, error.as_ref().ok())
9613                        {
9614                            sleep(d).await;
9615                            continue;
9616                        }
9617
9618                        dlg.finished(false);
9619
9620                        return Err(match error {
9621                            Ok(value) => common::Error::BadRequest(value),
9622                            _ => common::Error::Failure(response),
9623                        });
9624                    }
9625                    let response = {
9626                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9627                        let encoded = common::to_string(&bytes);
9628                        match serde_json::from_str(&encoded) {
9629                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9630                            Err(error) => {
9631                                dlg.response_json_decode_error(&encoded, &error);
9632                                return Err(common::Error::JsonDecodeError(
9633                                    encoded.to_string(),
9634                                    error,
9635                                ));
9636                            }
9637                        }
9638                    };
9639
9640                    dlg.finished(true);
9641                    return Ok(response);
9642                }
9643            }
9644        }
9645    }
9646
9647    ///
9648    /// Sets the *request* property to the given value.
9649    ///
9650    /// Even though the property as already been set when instantiating this call,
9651    /// we provide this method for API completeness.
9652    pub fn request(mut self, new_value: NfsShare) -> ProjectLocationNfsShareCreateCall<'a, C> {
9653        self._request = new_value;
9654        self
9655    }
9656    /// Required. The parent project and location.
9657    ///
9658    /// Sets the *parent* path property to the given value.
9659    ///
9660    /// Even though the property as already been set when instantiating this call,
9661    /// we provide this method for API completeness.
9662    pub fn parent(mut self, new_value: &str) -> ProjectLocationNfsShareCreateCall<'a, C> {
9663        self._parent = new_value.to_string();
9664        self
9665    }
9666    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9667    /// while executing the actual API request.
9668    ///
9669    /// ````text
9670    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9671    /// ````
9672    ///
9673    /// Sets the *delegate* property to the given value.
9674    pub fn delegate(
9675        mut self,
9676        new_value: &'a mut dyn common::Delegate,
9677    ) -> ProjectLocationNfsShareCreateCall<'a, C> {
9678        self._delegate = Some(new_value);
9679        self
9680    }
9681
9682    /// Set any additional parameter of the query string used in the request.
9683    /// It should be used to set parameters which are not yet available through their own
9684    /// setters.
9685    ///
9686    /// Please note that this method must not be used to set any of the known parameters
9687    /// which have their own setter method. If done anyway, the request will fail.
9688    ///
9689    /// # Additional Parameters
9690    ///
9691    /// * *$.xgafv* (query-string) - V1 error format.
9692    /// * *access_token* (query-string) - OAuth access token.
9693    /// * *alt* (query-string) - Data format for response.
9694    /// * *callback* (query-string) - JSONP
9695    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9696    /// * *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.
9697    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9698    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9699    /// * *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.
9700    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9701    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9702    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNfsShareCreateCall<'a, C>
9703    where
9704        T: AsRef<str>,
9705    {
9706        self._additional_params
9707            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9708        self
9709    }
9710
9711    /// Identifies the authorization scope for the method you are building.
9712    ///
9713    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9714    /// [`Scope::CloudPlatform`].
9715    ///
9716    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9717    /// tokens for more than one scope.
9718    ///
9719    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9720    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9721    /// sufficient, a read-write scope will do as well.
9722    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNfsShareCreateCall<'a, C>
9723    where
9724        St: AsRef<str>,
9725    {
9726        self._scopes.insert(String::from(scope.as_ref()));
9727        self
9728    }
9729    /// Identifies the authorization scope(s) for the method you are building.
9730    ///
9731    /// See [`Self::add_scope()`] for details.
9732    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNfsShareCreateCall<'a, C>
9733    where
9734        I: IntoIterator<Item = St>,
9735        St: AsRef<str>,
9736    {
9737        self._scopes
9738            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9739        self
9740    }
9741
9742    /// Removes all scopes, and no default scope will be used either.
9743    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9744    /// for details).
9745    pub fn clear_scopes(mut self) -> ProjectLocationNfsShareCreateCall<'a, C> {
9746        self._scopes.clear();
9747        self
9748    }
9749}
9750
9751/// Delete an NFS share. The underlying volume is automatically deleted.
9752///
9753/// A builder for the *locations.nfsShares.delete* method supported by a *project* resource.
9754/// It is not used directly, but through a [`ProjectMethods`] instance.
9755///
9756/// # Example
9757///
9758/// Instantiate a resource method builder
9759///
9760/// ```test_harness,no_run
9761/// # extern crate hyper;
9762/// # extern crate hyper_rustls;
9763/// # extern crate google_baremetalsolution2 as baremetalsolution2;
9764/// # async fn dox() {
9765/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9766///
9767/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9768/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9769/// #     .with_native_roots()
9770/// #     .unwrap()
9771/// #     .https_only()
9772/// #     .enable_http2()
9773/// #     .build();
9774///
9775/// # let executor = hyper_util::rt::TokioExecutor::new();
9776/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9777/// #     secret,
9778/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9779/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9780/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9781/// #     ),
9782/// # ).build().await.unwrap();
9783///
9784/// # let client = hyper_util::client::legacy::Client::builder(
9785/// #     hyper_util::rt::TokioExecutor::new()
9786/// # )
9787/// # .build(
9788/// #     hyper_rustls::HttpsConnectorBuilder::new()
9789/// #         .with_native_roots()
9790/// #         .unwrap()
9791/// #         .https_or_http()
9792/// #         .enable_http2()
9793/// #         .build()
9794/// # );
9795/// # let mut hub = Baremetalsolution::new(client, auth);
9796/// // You can configure optional parameters by calling the respective setters at will, and
9797/// // execute the final call using `doit()`.
9798/// // Values shown here are possibly random and not representative !
9799/// let result = hub.projects().locations_nfs_shares_delete("name")
9800///              .doit().await;
9801/// # }
9802/// ```
9803pub struct ProjectLocationNfsShareDeleteCall<'a, C>
9804where
9805    C: 'a,
9806{
9807    hub: &'a Baremetalsolution<C>,
9808    _name: String,
9809    _delegate: Option<&'a mut dyn common::Delegate>,
9810    _additional_params: HashMap<String, String>,
9811    _scopes: BTreeSet<String>,
9812}
9813
9814impl<'a, C> common::CallBuilder for ProjectLocationNfsShareDeleteCall<'a, C> {}
9815
9816impl<'a, C> ProjectLocationNfsShareDeleteCall<'a, C>
9817where
9818    C: common::Connector,
9819{
9820    /// Perform the operation you have build so far.
9821    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9822        use std::borrow::Cow;
9823        use std::io::{Read, Seek};
9824
9825        use common::{url::Params, ToParts};
9826        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9827
9828        let mut dd = common::DefaultDelegate;
9829        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9830        dlg.begin(common::MethodInfo {
9831            id: "baremetalsolution.projects.locations.nfsShares.delete",
9832            http_method: hyper::Method::DELETE,
9833        });
9834
9835        for &field in ["alt", "name"].iter() {
9836            if self._additional_params.contains_key(field) {
9837                dlg.finished(false);
9838                return Err(common::Error::FieldClash(field));
9839            }
9840        }
9841
9842        let mut params = Params::with_capacity(3 + self._additional_params.len());
9843        params.push("name", self._name);
9844
9845        params.extend(self._additional_params.iter());
9846
9847        params.push("alt", "json");
9848        let mut url = self.hub._base_url.clone() + "v2/{+name}";
9849        if self._scopes.is_empty() {
9850            self._scopes
9851                .insert(Scope::CloudPlatform.as_ref().to_string());
9852        }
9853
9854        #[allow(clippy::single_element_loop)]
9855        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9856            url = params.uri_replacement(url, param_name, find_this, true);
9857        }
9858        {
9859            let to_remove = ["name"];
9860            params.remove_params(&to_remove);
9861        }
9862
9863        let url = params.parse_with_url(&url);
9864
9865        loop {
9866            let token = match self
9867                .hub
9868                .auth
9869                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9870                .await
9871            {
9872                Ok(token) => token,
9873                Err(e) => match dlg.token(e) {
9874                    Ok(token) => token,
9875                    Err(e) => {
9876                        dlg.finished(false);
9877                        return Err(common::Error::MissingToken(e));
9878                    }
9879                },
9880            };
9881            let mut req_result = {
9882                let client = &self.hub.client;
9883                dlg.pre_request();
9884                let mut req_builder = hyper::Request::builder()
9885                    .method(hyper::Method::DELETE)
9886                    .uri(url.as_str())
9887                    .header(USER_AGENT, self.hub._user_agent.clone());
9888
9889                if let Some(token) = token.as_ref() {
9890                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9891                }
9892
9893                let request = req_builder
9894                    .header(CONTENT_LENGTH, 0_u64)
9895                    .body(common::to_body::<String>(None));
9896
9897                client.request(request.unwrap()).await
9898            };
9899
9900            match req_result {
9901                Err(err) => {
9902                    if let common::Retry::After(d) = dlg.http_error(&err) {
9903                        sleep(d).await;
9904                        continue;
9905                    }
9906                    dlg.finished(false);
9907                    return Err(common::Error::HttpError(err));
9908                }
9909                Ok(res) => {
9910                    let (mut parts, body) = res.into_parts();
9911                    let mut body = common::Body::new(body);
9912                    if !parts.status.is_success() {
9913                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9914                        let error = serde_json::from_str(&common::to_string(&bytes));
9915                        let response = common::to_response(parts, bytes.into());
9916
9917                        if let common::Retry::After(d) =
9918                            dlg.http_failure(&response, error.as_ref().ok())
9919                        {
9920                            sleep(d).await;
9921                            continue;
9922                        }
9923
9924                        dlg.finished(false);
9925
9926                        return Err(match error {
9927                            Ok(value) => common::Error::BadRequest(value),
9928                            _ => common::Error::Failure(response),
9929                        });
9930                    }
9931                    let response = {
9932                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9933                        let encoded = common::to_string(&bytes);
9934                        match serde_json::from_str(&encoded) {
9935                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9936                            Err(error) => {
9937                                dlg.response_json_decode_error(&encoded, &error);
9938                                return Err(common::Error::JsonDecodeError(
9939                                    encoded.to_string(),
9940                                    error,
9941                                ));
9942                            }
9943                        }
9944                    };
9945
9946                    dlg.finished(true);
9947                    return Ok(response);
9948                }
9949            }
9950        }
9951    }
9952
9953    /// Required. The name of the NFS share to delete.
9954    ///
9955    /// Sets the *name* path property to the given value.
9956    ///
9957    /// Even though the property as already been set when instantiating this call,
9958    /// we provide this method for API completeness.
9959    pub fn name(mut self, new_value: &str) -> ProjectLocationNfsShareDeleteCall<'a, C> {
9960        self._name = new_value.to_string();
9961        self
9962    }
9963    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9964    /// while executing the actual API request.
9965    ///
9966    /// ````text
9967    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9968    /// ````
9969    ///
9970    /// Sets the *delegate* property to the given value.
9971    pub fn delegate(
9972        mut self,
9973        new_value: &'a mut dyn common::Delegate,
9974    ) -> ProjectLocationNfsShareDeleteCall<'a, C> {
9975        self._delegate = Some(new_value);
9976        self
9977    }
9978
9979    /// Set any additional parameter of the query string used in the request.
9980    /// It should be used to set parameters which are not yet available through their own
9981    /// setters.
9982    ///
9983    /// Please note that this method must not be used to set any of the known parameters
9984    /// which have their own setter method. If done anyway, the request will fail.
9985    ///
9986    /// # Additional Parameters
9987    ///
9988    /// * *$.xgafv* (query-string) - V1 error format.
9989    /// * *access_token* (query-string) - OAuth access token.
9990    /// * *alt* (query-string) - Data format for response.
9991    /// * *callback* (query-string) - JSONP
9992    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9993    /// * *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.
9994    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9995    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9996    /// * *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.
9997    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9998    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9999    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNfsShareDeleteCall<'a, C>
10000    where
10001        T: AsRef<str>,
10002    {
10003        self._additional_params
10004            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10005        self
10006    }
10007
10008    /// Identifies the authorization scope for the method you are building.
10009    ///
10010    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10011    /// [`Scope::CloudPlatform`].
10012    ///
10013    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10014    /// tokens for more than one scope.
10015    ///
10016    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10017    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10018    /// sufficient, a read-write scope will do as well.
10019    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNfsShareDeleteCall<'a, C>
10020    where
10021        St: AsRef<str>,
10022    {
10023        self._scopes.insert(String::from(scope.as_ref()));
10024        self
10025    }
10026    /// Identifies the authorization scope(s) for the method you are building.
10027    ///
10028    /// See [`Self::add_scope()`] for details.
10029    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNfsShareDeleteCall<'a, C>
10030    where
10031        I: IntoIterator<Item = St>,
10032        St: AsRef<str>,
10033    {
10034        self._scopes
10035            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10036        self
10037    }
10038
10039    /// Removes all scopes, and no default scope will be used either.
10040    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10041    /// for details).
10042    pub fn clear_scopes(mut self) -> ProjectLocationNfsShareDeleteCall<'a, C> {
10043        self._scopes.clear();
10044        self
10045    }
10046}
10047
10048/// Get details of a single NFS share.
10049///
10050/// A builder for the *locations.nfsShares.get* method supported by a *project* resource.
10051/// It is not used directly, but through a [`ProjectMethods`] instance.
10052///
10053/// # Example
10054///
10055/// Instantiate a resource method builder
10056///
10057/// ```test_harness,no_run
10058/// # extern crate hyper;
10059/// # extern crate hyper_rustls;
10060/// # extern crate google_baremetalsolution2 as baremetalsolution2;
10061/// # async fn dox() {
10062/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10063///
10064/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10065/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10066/// #     .with_native_roots()
10067/// #     .unwrap()
10068/// #     .https_only()
10069/// #     .enable_http2()
10070/// #     .build();
10071///
10072/// # let executor = hyper_util::rt::TokioExecutor::new();
10073/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10074/// #     secret,
10075/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10076/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10077/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10078/// #     ),
10079/// # ).build().await.unwrap();
10080///
10081/// # let client = hyper_util::client::legacy::Client::builder(
10082/// #     hyper_util::rt::TokioExecutor::new()
10083/// # )
10084/// # .build(
10085/// #     hyper_rustls::HttpsConnectorBuilder::new()
10086/// #         .with_native_roots()
10087/// #         .unwrap()
10088/// #         .https_or_http()
10089/// #         .enable_http2()
10090/// #         .build()
10091/// # );
10092/// # let mut hub = Baremetalsolution::new(client, auth);
10093/// // You can configure optional parameters by calling the respective setters at will, and
10094/// // execute the final call using `doit()`.
10095/// // Values shown here are possibly random and not representative !
10096/// let result = hub.projects().locations_nfs_shares_get("name")
10097///              .doit().await;
10098/// # }
10099/// ```
10100pub struct ProjectLocationNfsShareGetCall<'a, C>
10101where
10102    C: 'a,
10103{
10104    hub: &'a Baremetalsolution<C>,
10105    _name: String,
10106    _delegate: Option<&'a mut dyn common::Delegate>,
10107    _additional_params: HashMap<String, String>,
10108    _scopes: BTreeSet<String>,
10109}
10110
10111impl<'a, C> common::CallBuilder for ProjectLocationNfsShareGetCall<'a, C> {}
10112
10113impl<'a, C> ProjectLocationNfsShareGetCall<'a, C>
10114where
10115    C: common::Connector,
10116{
10117    /// Perform the operation you have build so far.
10118    pub async fn doit(mut self) -> common::Result<(common::Response, NfsShare)> {
10119        use std::borrow::Cow;
10120        use std::io::{Read, Seek};
10121
10122        use common::{url::Params, ToParts};
10123        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10124
10125        let mut dd = common::DefaultDelegate;
10126        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10127        dlg.begin(common::MethodInfo {
10128            id: "baremetalsolution.projects.locations.nfsShares.get",
10129            http_method: hyper::Method::GET,
10130        });
10131
10132        for &field in ["alt", "name"].iter() {
10133            if self._additional_params.contains_key(field) {
10134                dlg.finished(false);
10135                return Err(common::Error::FieldClash(field));
10136            }
10137        }
10138
10139        let mut params = Params::with_capacity(3 + self._additional_params.len());
10140        params.push("name", self._name);
10141
10142        params.extend(self._additional_params.iter());
10143
10144        params.push("alt", "json");
10145        let mut url = self.hub._base_url.clone() + "v2/{+name}";
10146        if self._scopes.is_empty() {
10147            self._scopes
10148                .insert(Scope::CloudPlatform.as_ref().to_string());
10149        }
10150
10151        #[allow(clippy::single_element_loop)]
10152        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10153            url = params.uri_replacement(url, param_name, find_this, true);
10154        }
10155        {
10156            let to_remove = ["name"];
10157            params.remove_params(&to_remove);
10158        }
10159
10160        let url = params.parse_with_url(&url);
10161
10162        loop {
10163            let token = match self
10164                .hub
10165                .auth
10166                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10167                .await
10168            {
10169                Ok(token) => token,
10170                Err(e) => match dlg.token(e) {
10171                    Ok(token) => token,
10172                    Err(e) => {
10173                        dlg.finished(false);
10174                        return Err(common::Error::MissingToken(e));
10175                    }
10176                },
10177            };
10178            let mut req_result = {
10179                let client = &self.hub.client;
10180                dlg.pre_request();
10181                let mut req_builder = hyper::Request::builder()
10182                    .method(hyper::Method::GET)
10183                    .uri(url.as_str())
10184                    .header(USER_AGENT, self.hub._user_agent.clone());
10185
10186                if let Some(token) = token.as_ref() {
10187                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10188                }
10189
10190                let request = req_builder
10191                    .header(CONTENT_LENGTH, 0_u64)
10192                    .body(common::to_body::<String>(None));
10193
10194                client.request(request.unwrap()).await
10195            };
10196
10197            match req_result {
10198                Err(err) => {
10199                    if let common::Retry::After(d) = dlg.http_error(&err) {
10200                        sleep(d).await;
10201                        continue;
10202                    }
10203                    dlg.finished(false);
10204                    return Err(common::Error::HttpError(err));
10205                }
10206                Ok(res) => {
10207                    let (mut parts, body) = res.into_parts();
10208                    let mut body = common::Body::new(body);
10209                    if !parts.status.is_success() {
10210                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10211                        let error = serde_json::from_str(&common::to_string(&bytes));
10212                        let response = common::to_response(parts, bytes.into());
10213
10214                        if let common::Retry::After(d) =
10215                            dlg.http_failure(&response, error.as_ref().ok())
10216                        {
10217                            sleep(d).await;
10218                            continue;
10219                        }
10220
10221                        dlg.finished(false);
10222
10223                        return Err(match error {
10224                            Ok(value) => common::Error::BadRequest(value),
10225                            _ => common::Error::Failure(response),
10226                        });
10227                    }
10228                    let response = {
10229                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10230                        let encoded = common::to_string(&bytes);
10231                        match serde_json::from_str(&encoded) {
10232                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10233                            Err(error) => {
10234                                dlg.response_json_decode_error(&encoded, &error);
10235                                return Err(common::Error::JsonDecodeError(
10236                                    encoded.to_string(),
10237                                    error,
10238                                ));
10239                            }
10240                        }
10241                    };
10242
10243                    dlg.finished(true);
10244                    return Ok(response);
10245                }
10246            }
10247        }
10248    }
10249
10250    /// Required. Name of the resource.
10251    ///
10252    /// Sets the *name* path property to the given value.
10253    ///
10254    /// Even though the property as already been set when instantiating this call,
10255    /// we provide this method for API completeness.
10256    pub fn name(mut self, new_value: &str) -> ProjectLocationNfsShareGetCall<'a, C> {
10257        self._name = new_value.to_string();
10258        self
10259    }
10260    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10261    /// while executing the actual API request.
10262    ///
10263    /// ````text
10264    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10265    /// ````
10266    ///
10267    /// Sets the *delegate* property to the given value.
10268    pub fn delegate(
10269        mut self,
10270        new_value: &'a mut dyn common::Delegate,
10271    ) -> ProjectLocationNfsShareGetCall<'a, C> {
10272        self._delegate = Some(new_value);
10273        self
10274    }
10275
10276    /// Set any additional parameter of the query string used in the request.
10277    /// It should be used to set parameters which are not yet available through their own
10278    /// setters.
10279    ///
10280    /// Please note that this method must not be used to set any of the known parameters
10281    /// which have their own setter method. If done anyway, the request will fail.
10282    ///
10283    /// # Additional Parameters
10284    ///
10285    /// * *$.xgafv* (query-string) - V1 error format.
10286    /// * *access_token* (query-string) - OAuth access token.
10287    /// * *alt* (query-string) - Data format for response.
10288    /// * *callback* (query-string) - JSONP
10289    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10290    /// * *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.
10291    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10292    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10293    /// * *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.
10294    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10295    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10296    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNfsShareGetCall<'a, C>
10297    where
10298        T: AsRef<str>,
10299    {
10300        self._additional_params
10301            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10302        self
10303    }
10304
10305    /// Identifies the authorization scope for the method you are building.
10306    ///
10307    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10308    /// [`Scope::CloudPlatform`].
10309    ///
10310    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10311    /// tokens for more than one scope.
10312    ///
10313    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10314    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10315    /// sufficient, a read-write scope will do as well.
10316    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNfsShareGetCall<'a, C>
10317    where
10318        St: AsRef<str>,
10319    {
10320        self._scopes.insert(String::from(scope.as_ref()));
10321        self
10322    }
10323    /// Identifies the authorization scope(s) for the method you are building.
10324    ///
10325    /// See [`Self::add_scope()`] for details.
10326    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNfsShareGetCall<'a, C>
10327    where
10328        I: IntoIterator<Item = St>,
10329        St: AsRef<str>,
10330    {
10331        self._scopes
10332            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10333        self
10334    }
10335
10336    /// Removes all scopes, and no default scope will be used either.
10337    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10338    /// for details).
10339    pub fn clear_scopes(mut self) -> ProjectLocationNfsShareGetCall<'a, C> {
10340        self._scopes.clear();
10341        self
10342    }
10343}
10344
10345/// List NFS shares.
10346///
10347/// A builder for the *locations.nfsShares.list* method supported by a *project* resource.
10348/// It is not used directly, but through a [`ProjectMethods`] instance.
10349///
10350/// # Example
10351///
10352/// Instantiate a resource method builder
10353///
10354/// ```test_harness,no_run
10355/// # extern crate hyper;
10356/// # extern crate hyper_rustls;
10357/// # extern crate google_baremetalsolution2 as baremetalsolution2;
10358/// # async fn dox() {
10359/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10360///
10361/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10362/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10363/// #     .with_native_roots()
10364/// #     .unwrap()
10365/// #     .https_only()
10366/// #     .enable_http2()
10367/// #     .build();
10368///
10369/// # let executor = hyper_util::rt::TokioExecutor::new();
10370/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10371/// #     secret,
10372/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10373/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10374/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10375/// #     ),
10376/// # ).build().await.unwrap();
10377///
10378/// # let client = hyper_util::client::legacy::Client::builder(
10379/// #     hyper_util::rt::TokioExecutor::new()
10380/// # )
10381/// # .build(
10382/// #     hyper_rustls::HttpsConnectorBuilder::new()
10383/// #         .with_native_roots()
10384/// #         .unwrap()
10385/// #         .https_or_http()
10386/// #         .enable_http2()
10387/// #         .build()
10388/// # );
10389/// # let mut hub = Baremetalsolution::new(client, auth);
10390/// // You can configure optional parameters by calling the respective setters at will, and
10391/// // execute the final call using `doit()`.
10392/// // Values shown here are possibly random and not representative !
10393/// let result = hub.projects().locations_nfs_shares_list("parent")
10394///              .page_token("gubergren")
10395///              .page_size(-17)
10396///              .filter("dolor")
10397///              .doit().await;
10398/// # }
10399/// ```
10400pub struct ProjectLocationNfsShareListCall<'a, C>
10401where
10402    C: 'a,
10403{
10404    hub: &'a Baremetalsolution<C>,
10405    _parent: String,
10406    _page_token: Option<String>,
10407    _page_size: Option<i32>,
10408    _filter: Option<String>,
10409    _delegate: Option<&'a mut dyn common::Delegate>,
10410    _additional_params: HashMap<String, String>,
10411    _scopes: BTreeSet<String>,
10412}
10413
10414impl<'a, C> common::CallBuilder for ProjectLocationNfsShareListCall<'a, C> {}
10415
10416impl<'a, C> ProjectLocationNfsShareListCall<'a, C>
10417where
10418    C: common::Connector,
10419{
10420    /// Perform the operation you have build so far.
10421    pub async fn doit(mut self) -> common::Result<(common::Response, ListNfsSharesResponse)> {
10422        use std::borrow::Cow;
10423        use std::io::{Read, Seek};
10424
10425        use common::{url::Params, ToParts};
10426        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10427
10428        let mut dd = common::DefaultDelegate;
10429        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10430        dlg.begin(common::MethodInfo {
10431            id: "baremetalsolution.projects.locations.nfsShares.list",
10432            http_method: hyper::Method::GET,
10433        });
10434
10435        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
10436            if self._additional_params.contains_key(field) {
10437                dlg.finished(false);
10438                return Err(common::Error::FieldClash(field));
10439            }
10440        }
10441
10442        let mut params = Params::with_capacity(6 + self._additional_params.len());
10443        params.push("parent", self._parent);
10444        if let Some(value) = self._page_token.as_ref() {
10445            params.push("pageToken", value);
10446        }
10447        if let Some(value) = self._page_size.as_ref() {
10448            params.push("pageSize", value.to_string());
10449        }
10450        if let Some(value) = self._filter.as_ref() {
10451            params.push("filter", value);
10452        }
10453
10454        params.extend(self._additional_params.iter());
10455
10456        params.push("alt", "json");
10457        let mut url = self.hub._base_url.clone() + "v2/{+parent}/nfsShares";
10458        if self._scopes.is_empty() {
10459            self._scopes
10460                .insert(Scope::CloudPlatform.as_ref().to_string());
10461        }
10462
10463        #[allow(clippy::single_element_loop)]
10464        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10465            url = params.uri_replacement(url, param_name, find_this, true);
10466        }
10467        {
10468            let to_remove = ["parent"];
10469            params.remove_params(&to_remove);
10470        }
10471
10472        let url = params.parse_with_url(&url);
10473
10474        loop {
10475            let token = match self
10476                .hub
10477                .auth
10478                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10479                .await
10480            {
10481                Ok(token) => token,
10482                Err(e) => match dlg.token(e) {
10483                    Ok(token) => token,
10484                    Err(e) => {
10485                        dlg.finished(false);
10486                        return Err(common::Error::MissingToken(e));
10487                    }
10488                },
10489            };
10490            let mut req_result = {
10491                let client = &self.hub.client;
10492                dlg.pre_request();
10493                let mut req_builder = hyper::Request::builder()
10494                    .method(hyper::Method::GET)
10495                    .uri(url.as_str())
10496                    .header(USER_AGENT, self.hub._user_agent.clone());
10497
10498                if let Some(token) = token.as_ref() {
10499                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10500                }
10501
10502                let request = req_builder
10503                    .header(CONTENT_LENGTH, 0_u64)
10504                    .body(common::to_body::<String>(None));
10505
10506                client.request(request.unwrap()).await
10507            };
10508
10509            match req_result {
10510                Err(err) => {
10511                    if let common::Retry::After(d) = dlg.http_error(&err) {
10512                        sleep(d).await;
10513                        continue;
10514                    }
10515                    dlg.finished(false);
10516                    return Err(common::Error::HttpError(err));
10517                }
10518                Ok(res) => {
10519                    let (mut parts, body) = res.into_parts();
10520                    let mut body = common::Body::new(body);
10521                    if !parts.status.is_success() {
10522                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10523                        let error = serde_json::from_str(&common::to_string(&bytes));
10524                        let response = common::to_response(parts, bytes.into());
10525
10526                        if let common::Retry::After(d) =
10527                            dlg.http_failure(&response, error.as_ref().ok())
10528                        {
10529                            sleep(d).await;
10530                            continue;
10531                        }
10532
10533                        dlg.finished(false);
10534
10535                        return Err(match error {
10536                            Ok(value) => common::Error::BadRequest(value),
10537                            _ => common::Error::Failure(response),
10538                        });
10539                    }
10540                    let response = {
10541                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10542                        let encoded = common::to_string(&bytes);
10543                        match serde_json::from_str(&encoded) {
10544                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10545                            Err(error) => {
10546                                dlg.response_json_decode_error(&encoded, &error);
10547                                return Err(common::Error::JsonDecodeError(
10548                                    encoded.to_string(),
10549                                    error,
10550                                ));
10551                            }
10552                        }
10553                    };
10554
10555                    dlg.finished(true);
10556                    return Ok(response);
10557                }
10558            }
10559        }
10560    }
10561
10562    /// Required. Parent value for ListNfsSharesRequest.
10563    ///
10564    /// Sets the *parent* path property to the given value.
10565    ///
10566    /// Even though the property as already been set when instantiating this call,
10567    /// we provide this method for API completeness.
10568    pub fn parent(mut self, new_value: &str) -> ProjectLocationNfsShareListCall<'a, C> {
10569        self._parent = new_value.to_string();
10570        self
10571    }
10572    /// A token identifying a page of results from the server.
10573    ///
10574    /// Sets the *page token* query property to the given value.
10575    pub fn page_token(mut self, new_value: &str) -> ProjectLocationNfsShareListCall<'a, C> {
10576        self._page_token = Some(new_value.to_string());
10577        self
10578    }
10579    /// Requested page size. The server might return fewer items than requested. If unspecified, server will pick an appropriate default.
10580    ///
10581    /// Sets the *page size* query property to the given value.
10582    pub fn page_size(mut self, new_value: i32) -> ProjectLocationNfsShareListCall<'a, C> {
10583        self._page_size = Some(new_value);
10584        self
10585    }
10586    /// List filter.
10587    ///
10588    /// Sets the *filter* query property to the given value.
10589    pub fn filter(mut self, new_value: &str) -> ProjectLocationNfsShareListCall<'a, C> {
10590        self._filter = Some(new_value.to_string());
10591        self
10592    }
10593    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10594    /// while executing the actual API request.
10595    ///
10596    /// ````text
10597    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10598    /// ````
10599    ///
10600    /// Sets the *delegate* property to the given value.
10601    pub fn delegate(
10602        mut self,
10603        new_value: &'a mut dyn common::Delegate,
10604    ) -> ProjectLocationNfsShareListCall<'a, C> {
10605        self._delegate = Some(new_value);
10606        self
10607    }
10608
10609    /// Set any additional parameter of the query string used in the request.
10610    /// It should be used to set parameters which are not yet available through their own
10611    /// setters.
10612    ///
10613    /// Please note that this method must not be used to set any of the known parameters
10614    /// which have their own setter method. If done anyway, the request will fail.
10615    ///
10616    /// # Additional Parameters
10617    ///
10618    /// * *$.xgafv* (query-string) - V1 error format.
10619    /// * *access_token* (query-string) - OAuth access token.
10620    /// * *alt* (query-string) - Data format for response.
10621    /// * *callback* (query-string) - JSONP
10622    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10623    /// * *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.
10624    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10625    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10626    /// * *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.
10627    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10628    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10629    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNfsShareListCall<'a, C>
10630    where
10631        T: AsRef<str>,
10632    {
10633        self._additional_params
10634            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10635        self
10636    }
10637
10638    /// Identifies the authorization scope for the method you are building.
10639    ///
10640    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10641    /// [`Scope::CloudPlatform`].
10642    ///
10643    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10644    /// tokens for more than one scope.
10645    ///
10646    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10647    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10648    /// sufficient, a read-write scope will do as well.
10649    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNfsShareListCall<'a, C>
10650    where
10651        St: AsRef<str>,
10652    {
10653        self._scopes.insert(String::from(scope.as_ref()));
10654        self
10655    }
10656    /// Identifies the authorization scope(s) for the method you are building.
10657    ///
10658    /// See [`Self::add_scope()`] for details.
10659    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNfsShareListCall<'a, C>
10660    where
10661        I: IntoIterator<Item = St>,
10662        St: AsRef<str>,
10663    {
10664        self._scopes
10665            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10666        self
10667    }
10668
10669    /// Removes all scopes, and no default scope will be used either.
10670    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10671    /// for details).
10672    pub fn clear_scopes(mut self) -> ProjectLocationNfsShareListCall<'a, C> {
10673        self._scopes.clear();
10674        self
10675    }
10676}
10677
10678/// Update details of a single NFS share.
10679///
10680/// A builder for the *locations.nfsShares.patch* method supported by a *project* resource.
10681/// It is not used directly, but through a [`ProjectMethods`] instance.
10682///
10683/// # Example
10684///
10685/// Instantiate a resource method builder
10686///
10687/// ```test_harness,no_run
10688/// # extern crate hyper;
10689/// # extern crate hyper_rustls;
10690/// # extern crate google_baremetalsolution2 as baremetalsolution2;
10691/// use baremetalsolution2::api::NfsShare;
10692/// # async fn dox() {
10693/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10694///
10695/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10696/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10697/// #     .with_native_roots()
10698/// #     .unwrap()
10699/// #     .https_only()
10700/// #     .enable_http2()
10701/// #     .build();
10702///
10703/// # let executor = hyper_util::rt::TokioExecutor::new();
10704/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10705/// #     secret,
10706/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10707/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10708/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10709/// #     ),
10710/// # ).build().await.unwrap();
10711///
10712/// # let client = hyper_util::client::legacy::Client::builder(
10713/// #     hyper_util::rt::TokioExecutor::new()
10714/// # )
10715/// # .build(
10716/// #     hyper_rustls::HttpsConnectorBuilder::new()
10717/// #         .with_native_roots()
10718/// #         .unwrap()
10719/// #         .https_or_http()
10720/// #         .enable_http2()
10721/// #         .build()
10722/// # );
10723/// # let mut hub = Baremetalsolution::new(client, auth);
10724/// // As the method needs a request, you would usually fill it with the desired information
10725/// // into the respective structure. Some of the parts shown here might not be applicable !
10726/// // Values shown here are possibly random and not representative !
10727/// let mut req = NfsShare::default();
10728///
10729/// // You can configure optional parameters by calling the respective setters at will, and
10730/// // execute the final call using `doit()`.
10731/// // Values shown here are possibly random and not representative !
10732/// let result = hub.projects().locations_nfs_shares_patch(req, "name")
10733///              .update_mask(FieldMask::new::<&str>(&[]))
10734///              .doit().await;
10735/// # }
10736/// ```
10737pub struct ProjectLocationNfsSharePatchCall<'a, C>
10738where
10739    C: 'a,
10740{
10741    hub: &'a Baremetalsolution<C>,
10742    _request: NfsShare,
10743    _name: String,
10744    _update_mask: Option<common::FieldMask>,
10745    _delegate: Option<&'a mut dyn common::Delegate>,
10746    _additional_params: HashMap<String, String>,
10747    _scopes: BTreeSet<String>,
10748}
10749
10750impl<'a, C> common::CallBuilder for ProjectLocationNfsSharePatchCall<'a, C> {}
10751
10752impl<'a, C> ProjectLocationNfsSharePatchCall<'a, C>
10753where
10754    C: common::Connector,
10755{
10756    /// Perform the operation you have build so far.
10757    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10758        use std::borrow::Cow;
10759        use std::io::{Read, Seek};
10760
10761        use common::{url::Params, ToParts};
10762        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10763
10764        let mut dd = common::DefaultDelegate;
10765        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10766        dlg.begin(common::MethodInfo {
10767            id: "baremetalsolution.projects.locations.nfsShares.patch",
10768            http_method: hyper::Method::PATCH,
10769        });
10770
10771        for &field in ["alt", "name", "updateMask"].iter() {
10772            if self._additional_params.contains_key(field) {
10773                dlg.finished(false);
10774                return Err(common::Error::FieldClash(field));
10775            }
10776        }
10777
10778        let mut params = Params::with_capacity(5 + self._additional_params.len());
10779        params.push("name", self._name);
10780        if let Some(value) = self._update_mask.as_ref() {
10781            params.push("updateMask", value.to_string());
10782        }
10783
10784        params.extend(self._additional_params.iter());
10785
10786        params.push("alt", "json");
10787        let mut url = self.hub._base_url.clone() + "v2/{+name}";
10788        if self._scopes.is_empty() {
10789            self._scopes
10790                .insert(Scope::CloudPlatform.as_ref().to_string());
10791        }
10792
10793        #[allow(clippy::single_element_loop)]
10794        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10795            url = params.uri_replacement(url, param_name, find_this, true);
10796        }
10797        {
10798            let to_remove = ["name"];
10799            params.remove_params(&to_remove);
10800        }
10801
10802        let url = params.parse_with_url(&url);
10803
10804        let mut json_mime_type = mime::APPLICATION_JSON;
10805        let mut request_value_reader = {
10806            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10807            common::remove_json_null_values(&mut value);
10808            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10809            serde_json::to_writer(&mut dst, &value).unwrap();
10810            dst
10811        };
10812        let request_size = request_value_reader
10813            .seek(std::io::SeekFrom::End(0))
10814            .unwrap();
10815        request_value_reader
10816            .seek(std::io::SeekFrom::Start(0))
10817            .unwrap();
10818
10819        loop {
10820            let token = match self
10821                .hub
10822                .auth
10823                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10824                .await
10825            {
10826                Ok(token) => token,
10827                Err(e) => match dlg.token(e) {
10828                    Ok(token) => token,
10829                    Err(e) => {
10830                        dlg.finished(false);
10831                        return Err(common::Error::MissingToken(e));
10832                    }
10833                },
10834            };
10835            request_value_reader
10836                .seek(std::io::SeekFrom::Start(0))
10837                .unwrap();
10838            let mut req_result = {
10839                let client = &self.hub.client;
10840                dlg.pre_request();
10841                let mut req_builder = hyper::Request::builder()
10842                    .method(hyper::Method::PATCH)
10843                    .uri(url.as_str())
10844                    .header(USER_AGENT, self.hub._user_agent.clone());
10845
10846                if let Some(token) = token.as_ref() {
10847                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10848                }
10849
10850                let request = req_builder
10851                    .header(CONTENT_TYPE, json_mime_type.to_string())
10852                    .header(CONTENT_LENGTH, request_size as u64)
10853                    .body(common::to_body(
10854                        request_value_reader.get_ref().clone().into(),
10855                    ));
10856
10857                client.request(request.unwrap()).await
10858            };
10859
10860            match req_result {
10861                Err(err) => {
10862                    if let common::Retry::After(d) = dlg.http_error(&err) {
10863                        sleep(d).await;
10864                        continue;
10865                    }
10866                    dlg.finished(false);
10867                    return Err(common::Error::HttpError(err));
10868                }
10869                Ok(res) => {
10870                    let (mut parts, body) = res.into_parts();
10871                    let mut body = common::Body::new(body);
10872                    if !parts.status.is_success() {
10873                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10874                        let error = serde_json::from_str(&common::to_string(&bytes));
10875                        let response = common::to_response(parts, bytes.into());
10876
10877                        if let common::Retry::After(d) =
10878                            dlg.http_failure(&response, error.as_ref().ok())
10879                        {
10880                            sleep(d).await;
10881                            continue;
10882                        }
10883
10884                        dlg.finished(false);
10885
10886                        return Err(match error {
10887                            Ok(value) => common::Error::BadRequest(value),
10888                            _ => common::Error::Failure(response),
10889                        });
10890                    }
10891                    let response = {
10892                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10893                        let encoded = common::to_string(&bytes);
10894                        match serde_json::from_str(&encoded) {
10895                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10896                            Err(error) => {
10897                                dlg.response_json_decode_error(&encoded, &error);
10898                                return Err(common::Error::JsonDecodeError(
10899                                    encoded.to_string(),
10900                                    error,
10901                                ));
10902                            }
10903                        }
10904                    };
10905
10906                    dlg.finished(true);
10907                    return Ok(response);
10908                }
10909            }
10910        }
10911    }
10912
10913    ///
10914    /// Sets the *request* property to the given value.
10915    ///
10916    /// Even though the property as already been set when instantiating this call,
10917    /// we provide this method for API completeness.
10918    pub fn request(mut self, new_value: NfsShare) -> ProjectLocationNfsSharePatchCall<'a, C> {
10919        self._request = new_value;
10920        self
10921    }
10922    /// Immutable. The name of the NFS share.
10923    ///
10924    /// Sets the *name* path property to the given value.
10925    ///
10926    /// Even though the property as already been set when instantiating this call,
10927    /// we provide this method for API completeness.
10928    pub fn name(mut self, new_value: &str) -> ProjectLocationNfsSharePatchCall<'a, C> {
10929        self._name = new_value.to_string();
10930        self
10931    }
10932    /// The list of fields to update. The only currently supported fields are: `labels` `allowed_clients`
10933    ///
10934    /// Sets the *update mask* query property to the given value.
10935    pub fn update_mask(
10936        mut self,
10937        new_value: common::FieldMask,
10938    ) -> ProjectLocationNfsSharePatchCall<'a, C> {
10939        self._update_mask = Some(new_value);
10940        self
10941    }
10942    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10943    /// while executing the actual API request.
10944    ///
10945    /// ````text
10946    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10947    /// ````
10948    ///
10949    /// Sets the *delegate* property to the given value.
10950    pub fn delegate(
10951        mut self,
10952        new_value: &'a mut dyn common::Delegate,
10953    ) -> ProjectLocationNfsSharePatchCall<'a, C> {
10954        self._delegate = Some(new_value);
10955        self
10956    }
10957
10958    /// Set any additional parameter of the query string used in the request.
10959    /// It should be used to set parameters which are not yet available through their own
10960    /// setters.
10961    ///
10962    /// Please note that this method must not be used to set any of the known parameters
10963    /// which have their own setter method. If done anyway, the request will fail.
10964    ///
10965    /// # Additional Parameters
10966    ///
10967    /// * *$.xgafv* (query-string) - V1 error format.
10968    /// * *access_token* (query-string) - OAuth access token.
10969    /// * *alt* (query-string) - Data format for response.
10970    /// * *callback* (query-string) - JSONP
10971    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10972    /// * *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.
10973    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10974    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10975    /// * *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.
10976    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10977    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10978    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNfsSharePatchCall<'a, C>
10979    where
10980        T: AsRef<str>,
10981    {
10982        self._additional_params
10983            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10984        self
10985    }
10986
10987    /// Identifies the authorization scope for the method you are building.
10988    ///
10989    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10990    /// [`Scope::CloudPlatform`].
10991    ///
10992    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10993    /// tokens for more than one scope.
10994    ///
10995    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10996    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10997    /// sufficient, a read-write scope will do as well.
10998    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNfsSharePatchCall<'a, C>
10999    where
11000        St: AsRef<str>,
11001    {
11002        self._scopes.insert(String::from(scope.as_ref()));
11003        self
11004    }
11005    /// Identifies the authorization scope(s) for the method you are building.
11006    ///
11007    /// See [`Self::add_scope()`] for details.
11008    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNfsSharePatchCall<'a, C>
11009    where
11010        I: IntoIterator<Item = St>,
11011        St: AsRef<str>,
11012    {
11013        self._scopes
11014            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11015        self
11016    }
11017
11018    /// Removes all scopes, and no default scope will be used either.
11019    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11020    /// for details).
11021    pub fn clear_scopes(mut self) -> ProjectLocationNfsSharePatchCall<'a, C> {
11022        self._scopes.clear();
11023        self
11024    }
11025}
11026
11027/// RenameNfsShare sets a new name for an nfsshare. Use with caution, previous names become immediately invalidated.
11028///
11029/// A builder for the *locations.nfsShares.rename* method supported by a *project* resource.
11030/// It is not used directly, but through a [`ProjectMethods`] instance.
11031///
11032/// # Example
11033///
11034/// Instantiate a resource method builder
11035///
11036/// ```test_harness,no_run
11037/// # extern crate hyper;
11038/// # extern crate hyper_rustls;
11039/// # extern crate google_baremetalsolution2 as baremetalsolution2;
11040/// use baremetalsolution2::api::RenameNfsShareRequest;
11041/// # async fn dox() {
11042/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11043///
11044/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11045/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11046/// #     .with_native_roots()
11047/// #     .unwrap()
11048/// #     .https_only()
11049/// #     .enable_http2()
11050/// #     .build();
11051///
11052/// # let executor = hyper_util::rt::TokioExecutor::new();
11053/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11054/// #     secret,
11055/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11056/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11057/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11058/// #     ),
11059/// # ).build().await.unwrap();
11060///
11061/// # let client = hyper_util::client::legacy::Client::builder(
11062/// #     hyper_util::rt::TokioExecutor::new()
11063/// # )
11064/// # .build(
11065/// #     hyper_rustls::HttpsConnectorBuilder::new()
11066/// #         .with_native_roots()
11067/// #         .unwrap()
11068/// #         .https_or_http()
11069/// #         .enable_http2()
11070/// #         .build()
11071/// # );
11072/// # let mut hub = Baremetalsolution::new(client, auth);
11073/// // As the method needs a request, you would usually fill it with the desired information
11074/// // into the respective structure. Some of the parts shown here might not be applicable !
11075/// // Values shown here are possibly random and not representative !
11076/// let mut req = RenameNfsShareRequest::default();
11077///
11078/// // You can configure optional parameters by calling the respective setters at will, and
11079/// // execute the final call using `doit()`.
11080/// // Values shown here are possibly random and not representative !
11081/// let result = hub.projects().locations_nfs_shares_rename(req, "name")
11082///              .doit().await;
11083/// # }
11084/// ```
11085pub struct ProjectLocationNfsShareRenameCall<'a, C>
11086where
11087    C: 'a,
11088{
11089    hub: &'a Baremetalsolution<C>,
11090    _request: RenameNfsShareRequest,
11091    _name: String,
11092    _delegate: Option<&'a mut dyn common::Delegate>,
11093    _additional_params: HashMap<String, String>,
11094    _scopes: BTreeSet<String>,
11095}
11096
11097impl<'a, C> common::CallBuilder for ProjectLocationNfsShareRenameCall<'a, C> {}
11098
11099impl<'a, C> ProjectLocationNfsShareRenameCall<'a, C>
11100where
11101    C: common::Connector,
11102{
11103    /// Perform the operation you have build so far.
11104    pub async fn doit(mut self) -> common::Result<(common::Response, NfsShare)> {
11105        use std::borrow::Cow;
11106        use std::io::{Read, Seek};
11107
11108        use common::{url::Params, ToParts};
11109        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11110
11111        let mut dd = common::DefaultDelegate;
11112        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11113        dlg.begin(common::MethodInfo {
11114            id: "baremetalsolution.projects.locations.nfsShares.rename",
11115            http_method: hyper::Method::POST,
11116        });
11117
11118        for &field in ["alt", "name"].iter() {
11119            if self._additional_params.contains_key(field) {
11120                dlg.finished(false);
11121                return Err(common::Error::FieldClash(field));
11122            }
11123        }
11124
11125        let mut params = Params::with_capacity(4 + self._additional_params.len());
11126        params.push("name", self._name);
11127
11128        params.extend(self._additional_params.iter());
11129
11130        params.push("alt", "json");
11131        let mut url = self.hub._base_url.clone() + "v2/{+name}:rename";
11132        if self._scopes.is_empty() {
11133            self._scopes
11134                .insert(Scope::CloudPlatform.as_ref().to_string());
11135        }
11136
11137        #[allow(clippy::single_element_loop)]
11138        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11139            url = params.uri_replacement(url, param_name, find_this, true);
11140        }
11141        {
11142            let to_remove = ["name"];
11143            params.remove_params(&to_remove);
11144        }
11145
11146        let url = params.parse_with_url(&url);
11147
11148        let mut json_mime_type = mime::APPLICATION_JSON;
11149        let mut request_value_reader = {
11150            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11151            common::remove_json_null_values(&mut value);
11152            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11153            serde_json::to_writer(&mut dst, &value).unwrap();
11154            dst
11155        };
11156        let request_size = request_value_reader
11157            .seek(std::io::SeekFrom::End(0))
11158            .unwrap();
11159        request_value_reader
11160            .seek(std::io::SeekFrom::Start(0))
11161            .unwrap();
11162
11163        loop {
11164            let token = match self
11165                .hub
11166                .auth
11167                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11168                .await
11169            {
11170                Ok(token) => token,
11171                Err(e) => match dlg.token(e) {
11172                    Ok(token) => token,
11173                    Err(e) => {
11174                        dlg.finished(false);
11175                        return Err(common::Error::MissingToken(e));
11176                    }
11177                },
11178            };
11179            request_value_reader
11180                .seek(std::io::SeekFrom::Start(0))
11181                .unwrap();
11182            let mut req_result = {
11183                let client = &self.hub.client;
11184                dlg.pre_request();
11185                let mut req_builder = hyper::Request::builder()
11186                    .method(hyper::Method::POST)
11187                    .uri(url.as_str())
11188                    .header(USER_AGENT, self.hub._user_agent.clone());
11189
11190                if let Some(token) = token.as_ref() {
11191                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11192                }
11193
11194                let request = req_builder
11195                    .header(CONTENT_TYPE, json_mime_type.to_string())
11196                    .header(CONTENT_LENGTH, request_size as u64)
11197                    .body(common::to_body(
11198                        request_value_reader.get_ref().clone().into(),
11199                    ));
11200
11201                client.request(request.unwrap()).await
11202            };
11203
11204            match req_result {
11205                Err(err) => {
11206                    if let common::Retry::After(d) = dlg.http_error(&err) {
11207                        sleep(d).await;
11208                        continue;
11209                    }
11210                    dlg.finished(false);
11211                    return Err(common::Error::HttpError(err));
11212                }
11213                Ok(res) => {
11214                    let (mut parts, body) = res.into_parts();
11215                    let mut body = common::Body::new(body);
11216                    if !parts.status.is_success() {
11217                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11218                        let error = serde_json::from_str(&common::to_string(&bytes));
11219                        let response = common::to_response(parts, bytes.into());
11220
11221                        if let common::Retry::After(d) =
11222                            dlg.http_failure(&response, error.as_ref().ok())
11223                        {
11224                            sleep(d).await;
11225                            continue;
11226                        }
11227
11228                        dlg.finished(false);
11229
11230                        return Err(match error {
11231                            Ok(value) => common::Error::BadRequest(value),
11232                            _ => common::Error::Failure(response),
11233                        });
11234                    }
11235                    let response = {
11236                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11237                        let encoded = common::to_string(&bytes);
11238                        match serde_json::from_str(&encoded) {
11239                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11240                            Err(error) => {
11241                                dlg.response_json_decode_error(&encoded, &error);
11242                                return Err(common::Error::JsonDecodeError(
11243                                    encoded.to_string(),
11244                                    error,
11245                                ));
11246                            }
11247                        }
11248                    };
11249
11250                    dlg.finished(true);
11251                    return Ok(response);
11252                }
11253            }
11254        }
11255    }
11256
11257    ///
11258    /// Sets the *request* property to the given value.
11259    ///
11260    /// Even though the property as already been set when instantiating this call,
11261    /// we provide this method for API completeness.
11262    pub fn request(
11263        mut self,
11264        new_value: RenameNfsShareRequest,
11265    ) -> ProjectLocationNfsShareRenameCall<'a, C> {
11266        self._request = new_value;
11267        self
11268    }
11269    /// Required. The `name` field is used to identify the nfsshare. Format: projects/{project}/locations/{location}/nfsshares/{nfsshare}
11270    ///
11271    /// Sets the *name* path property to the given value.
11272    ///
11273    /// Even though the property as already been set when instantiating this call,
11274    /// we provide this method for API completeness.
11275    pub fn name(mut self, new_value: &str) -> ProjectLocationNfsShareRenameCall<'a, C> {
11276        self._name = new_value.to_string();
11277        self
11278    }
11279    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11280    /// while executing the actual API request.
11281    ///
11282    /// ````text
11283    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11284    /// ````
11285    ///
11286    /// Sets the *delegate* property to the given value.
11287    pub fn delegate(
11288        mut self,
11289        new_value: &'a mut dyn common::Delegate,
11290    ) -> ProjectLocationNfsShareRenameCall<'a, C> {
11291        self._delegate = Some(new_value);
11292        self
11293    }
11294
11295    /// Set any additional parameter of the query string used in the request.
11296    /// It should be used to set parameters which are not yet available through their own
11297    /// setters.
11298    ///
11299    /// Please note that this method must not be used to set any of the known parameters
11300    /// which have their own setter method. If done anyway, the request will fail.
11301    ///
11302    /// # Additional Parameters
11303    ///
11304    /// * *$.xgafv* (query-string) - V1 error format.
11305    /// * *access_token* (query-string) - OAuth access token.
11306    /// * *alt* (query-string) - Data format for response.
11307    /// * *callback* (query-string) - JSONP
11308    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11309    /// * *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.
11310    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11311    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11312    /// * *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.
11313    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11314    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11315    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNfsShareRenameCall<'a, C>
11316    where
11317        T: AsRef<str>,
11318    {
11319        self._additional_params
11320            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11321        self
11322    }
11323
11324    /// Identifies the authorization scope for the method you are building.
11325    ///
11326    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11327    /// [`Scope::CloudPlatform`].
11328    ///
11329    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11330    /// tokens for more than one scope.
11331    ///
11332    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11333    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11334    /// sufficient, a read-write scope will do as well.
11335    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNfsShareRenameCall<'a, C>
11336    where
11337        St: AsRef<str>,
11338    {
11339        self._scopes.insert(String::from(scope.as_ref()));
11340        self
11341    }
11342    /// Identifies the authorization scope(s) for the method you are building.
11343    ///
11344    /// See [`Self::add_scope()`] for details.
11345    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNfsShareRenameCall<'a, C>
11346    where
11347        I: IntoIterator<Item = St>,
11348        St: AsRef<str>,
11349    {
11350        self._scopes
11351            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11352        self
11353    }
11354
11355    /// Removes all scopes, and no default scope will be used either.
11356    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11357    /// for details).
11358    pub fn clear_scopes(mut self) -> ProjectLocationNfsShareRenameCall<'a, C> {
11359        self._scopes.clear();
11360        self
11361    }
11362}
11363
11364/// Get details about an operation.
11365///
11366/// A builder for the *locations.operations.get* method supported by a *project* resource.
11367/// It is not used directly, but through a [`ProjectMethods`] instance.
11368///
11369/// # Example
11370///
11371/// Instantiate a resource method builder
11372///
11373/// ```test_harness,no_run
11374/// # extern crate hyper;
11375/// # extern crate hyper_rustls;
11376/// # extern crate google_baremetalsolution2 as baremetalsolution2;
11377/// # async fn dox() {
11378/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11379///
11380/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11381/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11382/// #     .with_native_roots()
11383/// #     .unwrap()
11384/// #     .https_only()
11385/// #     .enable_http2()
11386/// #     .build();
11387///
11388/// # let executor = hyper_util::rt::TokioExecutor::new();
11389/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11390/// #     secret,
11391/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11392/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11393/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11394/// #     ),
11395/// # ).build().await.unwrap();
11396///
11397/// # let client = hyper_util::client::legacy::Client::builder(
11398/// #     hyper_util::rt::TokioExecutor::new()
11399/// # )
11400/// # .build(
11401/// #     hyper_rustls::HttpsConnectorBuilder::new()
11402/// #         .with_native_roots()
11403/// #         .unwrap()
11404/// #         .https_or_http()
11405/// #         .enable_http2()
11406/// #         .build()
11407/// # );
11408/// # let mut hub = Baremetalsolution::new(client, auth);
11409/// // You can configure optional parameters by calling the respective setters at will, and
11410/// // execute the final call using `doit()`.
11411/// // Values shown here are possibly random and not representative !
11412/// let result = hub.projects().locations_operations_get("name")
11413///              .doit().await;
11414/// # }
11415/// ```
11416pub struct ProjectLocationOperationGetCall<'a, C>
11417where
11418    C: 'a,
11419{
11420    hub: &'a Baremetalsolution<C>,
11421    _name: String,
11422    _delegate: Option<&'a mut dyn common::Delegate>,
11423    _additional_params: HashMap<String, String>,
11424    _scopes: BTreeSet<String>,
11425}
11426
11427impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
11428
11429impl<'a, C> ProjectLocationOperationGetCall<'a, C>
11430where
11431    C: common::Connector,
11432{
11433    /// Perform the operation you have build so far.
11434    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11435        use std::borrow::Cow;
11436        use std::io::{Read, Seek};
11437
11438        use common::{url::Params, ToParts};
11439        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11440
11441        let mut dd = common::DefaultDelegate;
11442        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11443        dlg.begin(common::MethodInfo {
11444            id: "baremetalsolution.projects.locations.operations.get",
11445            http_method: hyper::Method::GET,
11446        });
11447
11448        for &field in ["alt", "name"].iter() {
11449            if self._additional_params.contains_key(field) {
11450                dlg.finished(false);
11451                return Err(common::Error::FieldClash(field));
11452            }
11453        }
11454
11455        let mut params = Params::with_capacity(3 + self._additional_params.len());
11456        params.push("name", self._name);
11457
11458        params.extend(self._additional_params.iter());
11459
11460        params.push("alt", "json");
11461        let mut url = self.hub._base_url.clone() + "v2/{+name}";
11462        if self._scopes.is_empty() {
11463            self._scopes
11464                .insert(Scope::CloudPlatform.as_ref().to_string());
11465        }
11466
11467        #[allow(clippy::single_element_loop)]
11468        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11469            url = params.uri_replacement(url, param_name, find_this, true);
11470        }
11471        {
11472            let to_remove = ["name"];
11473            params.remove_params(&to_remove);
11474        }
11475
11476        let url = params.parse_with_url(&url);
11477
11478        loop {
11479            let token = match self
11480                .hub
11481                .auth
11482                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11483                .await
11484            {
11485                Ok(token) => token,
11486                Err(e) => match dlg.token(e) {
11487                    Ok(token) => token,
11488                    Err(e) => {
11489                        dlg.finished(false);
11490                        return Err(common::Error::MissingToken(e));
11491                    }
11492                },
11493            };
11494            let mut req_result = {
11495                let client = &self.hub.client;
11496                dlg.pre_request();
11497                let mut req_builder = hyper::Request::builder()
11498                    .method(hyper::Method::GET)
11499                    .uri(url.as_str())
11500                    .header(USER_AGENT, self.hub._user_agent.clone());
11501
11502                if let Some(token) = token.as_ref() {
11503                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11504                }
11505
11506                let request = req_builder
11507                    .header(CONTENT_LENGTH, 0_u64)
11508                    .body(common::to_body::<String>(None));
11509
11510                client.request(request.unwrap()).await
11511            };
11512
11513            match req_result {
11514                Err(err) => {
11515                    if let common::Retry::After(d) = dlg.http_error(&err) {
11516                        sleep(d).await;
11517                        continue;
11518                    }
11519                    dlg.finished(false);
11520                    return Err(common::Error::HttpError(err));
11521                }
11522                Ok(res) => {
11523                    let (mut parts, body) = res.into_parts();
11524                    let mut body = common::Body::new(body);
11525                    if !parts.status.is_success() {
11526                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11527                        let error = serde_json::from_str(&common::to_string(&bytes));
11528                        let response = common::to_response(parts, bytes.into());
11529
11530                        if let common::Retry::After(d) =
11531                            dlg.http_failure(&response, error.as_ref().ok())
11532                        {
11533                            sleep(d).await;
11534                            continue;
11535                        }
11536
11537                        dlg.finished(false);
11538
11539                        return Err(match error {
11540                            Ok(value) => common::Error::BadRequest(value),
11541                            _ => common::Error::Failure(response),
11542                        });
11543                    }
11544                    let response = {
11545                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11546                        let encoded = common::to_string(&bytes);
11547                        match serde_json::from_str(&encoded) {
11548                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11549                            Err(error) => {
11550                                dlg.response_json_decode_error(&encoded, &error);
11551                                return Err(common::Error::JsonDecodeError(
11552                                    encoded.to_string(),
11553                                    error,
11554                                ));
11555                            }
11556                        }
11557                    };
11558
11559                    dlg.finished(true);
11560                    return Ok(response);
11561                }
11562            }
11563        }
11564    }
11565
11566    /// The name of the operation resource.
11567    ///
11568    /// Sets the *name* path property to the given value.
11569    ///
11570    /// Even though the property as already been set when instantiating this call,
11571    /// we provide this method for API completeness.
11572    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
11573        self._name = new_value.to_string();
11574        self
11575    }
11576    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11577    /// while executing the actual API request.
11578    ///
11579    /// ````text
11580    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11581    /// ````
11582    ///
11583    /// Sets the *delegate* property to the given value.
11584    pub fn delegate(
11585        mut self,
11586        new_value: &'a mut dyn common::Delegate,
11587    ) -> ProjectLocationOperationGetCall<'a, C> {
11588        self._delegate = Some(new_value);
11589        self
11590    }
11591
11592    /// Set any additional parameter of the query string used in the request.
11593    /// It should be used to set parameters which are not yet available through their own
11594    /// setters.
11595    ///
11596    /// Please note that this method must not be used to set any of the known parameters
11597    /// which have their own setter method. If done anyway, the request will fail.
11598    ///
11599    /// # Additional Parameters
11600    ///
11601    /// * *$.xgafv* (query-string) - V1 error format.
11602    /// * *access_token* (query-string) - OAuth access token.
11603    /// * *alt* (query-string) - Data format for response.
11604    /// * *callback* (query-string) - JSONP
11605    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11606    /// * *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.
11607    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11608    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11609    /// * *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.
11610    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11611    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11612    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
11613    where
11614        T: AsRef<str>,
11615    {
11616        self._additional_params
11617            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11618        self
11619    }
11620
11621    /// Identifies the authorization scope for the method you are building.
11622    ///
11623    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11624    /// [`Scope::CloudPlatform`].
11625    ///
11626    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11627    /// tokens for more than one scope.
11628    ///
11629    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11630    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11631    /// sufficient, a read-write scope will do as well.
11632    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
11633    where
11634        St: AsRef<str>,
11635    {
11636        self._scopes.insert(String::from(scope.as_ref()));
11637        self
11638    }
11639    /// Identifies the authorization scope(s) for the method you are building.
11640    ///
11641    /// See [`Self::add_scope()`] for details.
11642    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
11643    where
11644        I: IntoIterator<Item = St>,
11645        St: AsRef<str>,
11646    {
11647        self._scopes
11648            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11649        self
11650    }
11651
11652    /// Removes all scopes, and no default scope will be used either.
11653    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11654    /// for details).
11655    pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
11656        self._scopes.clear();
11657        self
11658    }
11659}
11660
11661/// Get details of a single OS image.
11662///
11663/// A builder for the *locations.osImages.get* method supported by a *project* resource.
11664/// It is not used directly, but through a [`ProjectMethods`] instance.
11665///
11666/// # Example
11667///
11668/// Instantiate a resource method builder
11669///
11670/// ```test_harness,no_run
11671/// # extern crate hyper;
11672/// # extern crate hyper_rustls;
11673/// # extern crate google_baremetalsolution2 as baremetalsolution2;
11674/// # async fn dox() {
11675/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11676///
11677/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11678/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11679/// #     .with_native_roots()
11680/// #     .unwrap()
11681/// #     .https_only()
11682/// #     .enable_http2()
11683/// #     .build();
11684///
11685/// # let executor = hyper_util::rt::TokioExecutor::new();
11686/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11687/// #     secret,
11688/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11689/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11690/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11691/// #     ),
11692/// # ).build().await.unwrap();
11693///
11694/// # let client = hyper_util::client::legacy::Client::builder(
11695/// #     hyper_util::rt::TokioExecutor::new()
11696/// # )
11697/// # .build(
11698/// #     hyper_rustls::HttpsConnectorBuilder::new()
11699/// #         .with_native_roots()
11700/// #         .unwrap()
11701/// #         .https_or_http()
11702/// #         .enable_http2()
11703/// #         .build()
11704/// # );
11705/// # let mut hub = Baremetalsolution::new(client, auth);
11706/// // You can configure optional parameters by calling the respective setters at will, and
11707/// // execute the final call using `doit()`.
11708/// // Values shown here are possibly random and not representative !
11709/// let result = hub.projects().locations_os_images_get("name")
11710///              .doit().await;
11711/// # }
11712/// ```
11713pub struct ProjectLocationOsImageGetCall<'a, C>
11714where
11715    C: 'a,
11716{
11717    hub: &'a Baremetalsolution<C>,
11718    _name: String,
11719    _delegate: Option<&'a mut dyn common::Delegate>,
11720    _additional_params: HashMap<String, String>,
11721    _scopes: BTreeSet<String>,
11722}
11723
11724impl<'a, C> common::CallBuilder for ProjectLocationOsImageGetCall<'a, C> {}
11725
11726impl<'a, C> ProjectLocationOsImageGetCall<'a, C>
11727where
11728    C: common::Connector,
11729{
11730    /// Perform the operation you have build so far.
11731    pub async fn doit(mut self) -> common::Result<(common::Response, OSImage)> {
11732        use std::borrow::Cow;
11733        use std::io::{Read, Seek};
11734
11735        use common::{url::Params, ToParts};
11736        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11737
11738        let mut dd = common::DefaultDelegate;
11739        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11740        dlg.begin(common::MethodInfo {
11741            id: "baremetalsolution.projects.locations.osImages.get",
11742            http_method: hyper::Method::GET,
11743        });
11744
11745        for &field in ["alt", "name"].iter() {
11746            if self._additional_params.contains_key(field) {
11747                dlg.finished(false);
11748                return Err(common::Error::FieldClash(field));
11749            }
11750        }
11751
11752        let mut params = Params::with_capacity(3 + self._additional_params.len());
11753        params.push("name", self._name);
11754
11755        params.extend(self._additional_params.iter());
11756
11757        params.push("alt", "json");
11758        let mut url = self.hub._base_url.clone() + "v2/{+name}";
11759        if self._scopes.is_empty() {
11760            self._scopes
11761                .insert(Scope::CloudPlatform.as_ref().to_string());
11762        }
11763
11764        #[allow(clippy::single_element_loop)]
11765        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11766            url = params.uri_replacement(url, param_name, find_this, true);
11767        }
11768        {
11769            let to_remove = ["name"];
11770            params.remove_params(&to_remove);
11771        }
11772
11773        let url = params.parse_with_url(&url);
11774
11775        loop {
11776            let token = match self
11777                .hub
11778                .auth
11779                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11780                .await
11781            {
11782                Ok(token) => token,
11783                Err(e) => match dlg.token(e) {
11784                    Ok(token) => token,
11785                    Err(e) => {
11786                        dlg.finished(false);
11787                        return Err(common::Error::MissingToken(e));
11788                    }
11789                },
11790            };
11791            let mut req_result = {
11792                let client = &self.hub.client;
11793                dlg.pre_request();
11794                let mut req_builder = hyper::Request::builder()
11795                    .method(hyper::Method::GET)
11796                    .uri(url.as_str())
11797                    .header(USER_AGENT, self.hub._user_agent.clone());
11798
11799                if let Some(token) = token.as_ref() {
11800                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11801                }
11802
11803                let request = req_builder
11804                    .header(CONTENT_LENGTH, 0_u64)
11805                    .body(common::to_body::<String>(None));
11806
11807                client.request(request.unwrap()).await
11808            };
11809
11810            match req_result {
11811                Err(err) => {
11812                    if let common::Retry::After(d) = dlg.http_error(&err) {
11813                        sleep(d).await;
11814                        continue;
11815                    }
11816                    dlg.finished(false);
11817                    return Err(common::Error::HttpError(err));
11818                }
11819                Ok(res) => {
11820                    let (mut parts, body) = res.into_parts();
11821                    let mut body = common::Body::new(body);
11822                    if !parts.status.is_success() {
11823                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11824                        let error = serde_json::from_str(&common::to_string(&bytes));
11825                        let response = common::to_response(parts, bytes.into());
11826
11827                        if let common::Retry::After(d) =
11828                            dlg.http_failure(&response, error.as_ref().ok())
11829                        {
11830                            sleep(d).await;
11831                            continue;
11832                        }
11833
11834                        dlg.finished(false);
11835
11836                        return Err(match error {
11837                            Ok(value) => common::Error::BadRequest(value),
11838                            _ => common::Error::Failure(response),
11839                        });
11840                    }
11841                    let response = {
11842                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11843                        let encoded = common::to_string(&bytes);
11844                        match serde_json::from_str(&encoded) {
11845                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11846                            Err(error) => {
11847                                dlg.response_json_decode_error(&encoded, &error);
11848                                return Err(common::Error::JsonDecodeError(
11849                                    encoded.to_string(),
11850                                    error,
11851                                ));
11852                            }
11853                        }
11854                    };
11855
11856                    dlg.finished(true);
11857                    return Ok(response);
11858                }
11859            }
11860        }
11861    }
11862
11863    /// Required. Name of the OS image.
11864    ///
11865    /// Sets the *name* path property to the given value.
11866    ///
11867    /// Even though the property as already been set when instantiating this call,
11868    /// we provide this method for API completeness.
11869    pub fn name(mut self, new_value: &str) -> ProjectLocationOsImageGetCall<'a, C> {
11870        self._name = new_value.to_string();
11871        self
11872    }
11873    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11874    /// while executing the actual API request.
11875    ///
11876    /// ````text
11877    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11878    /// ````
11879    ///
11880    /// Sets the *delegate* property to the given value.
11881    pub fn delegate(
11882        mut self,
11883        new_value: &'a mut dyn common::Delegate,
11884    ) -> ProjectLocationOsImageGetCall<'a, C> {
11885        self._delegate = Some(new_value);
11886        self
11887    }
11888
11889    /// Set any additional parameter of the query string used in the request.
11890    /// It should be used to set parameters which are not yet available through their own
11891    /// setters.
11892    ///
11893    /// Please note that this method must not be used to set any of the known parameters
11894    /// which have their own setter method. If done anyway, the request will fail.
11895    ///
11896    /// # Additional Parameters
11897    ///
11898    /// * *$.xgafv* (query-string) - V1 error format.
11899    /// * *access_token* (query-string) - OAuth access token.
11900    /// * *alt* (query-string) - Data format for response.
11901    /// * *callback* (query-string) - JSONP
11902    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11903    /// * *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.
11904    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11905    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11906    /// * *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.
11907    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11908    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11909    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOsImageGetCall<'a, C>
11910    where
11911        T: AsRef<str>,
11912    {
11913        self._additional_params
11914            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11915        self
11916    }
11917
11918    /// Identifies the authorization scope for the method you are building.
11919    ///
11920    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11921    /// [`Scope::CloudPlatform`].
11922    ///
11923    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11924    /// tokens for more than one scope.
11925    ///
11926    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11927    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11928    /// sufficient, a read-write scope will do as well.
11929    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOsImageGetCall<'a, C>
11930    where
11931        St: AsRef<str>,
11932    {
11933        self._scopes.insert(String::from(scope.as_ref()));
11934        self
11935    }
11936    /// Identifies the authorization scope(s) for the method you are building.
11937    ///
11938    /// See [`Self::add_scope()`] for details.
11939    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOsImageGetCall<'a, C>
11940    where
11941        I: IntoIterator<Item = St>,
11942        St: AsRef<str>,
11943    {
11944        self._scopes
11945            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11946        self
11947    }
11948
11949    /// Removes all scopes, and no default scope will be used either.
11950    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11951    /// for details).
11952    pub fn clear_scopes(mut self) -> ProjectLocationOsImageGetCall<'a, C> {
11953        self._scopes.clear();
11954        self
11955    }
11956}
11957
11958/// Retrieves the list of OS images which are currently approved.
11959///
11960/// A builder for the *locations.osImages.list* method supported by a *project* resource.
11961/// It is not used directly, but through a [`ProjectMethods`] instance.
11962///
11963/// # Example
11964///
11965/// Instantiate a resource method builder
11966///
11967/// ```test_harness,no_run
11968/// # extern crate hyper;
11969/// # extern crate hyper_rustls;
11970/// # extern crate google_baremetalsolution2 as baremetalsolution2;
11971/// # async fn dox() {
11972/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11973///
11974/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11975/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11976/// #     .with_native_roots()
11977/// #     .unwrap()
11978/// #     .https_only()
11979/// #     .enable_http2()
11980/// #     .build();
11981///
11982/// # let executor = hyper_util::rt::TokioExecutor::new();
11983/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11984/// #     secret,
11985/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11986/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11987/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11988/// #     ),
11989/// # ).build().await.unwrap();
11990///
11991/// # let client = hyper_util::client::legacy::Client::builder(
11992/// #     hyper_util::rt::TokioExecutor::new()
11993/// # )
11994/// # .build(
11995/// #     hyper_rustls::HttpsConnectorBuilder::new()
11996/// #         .with_native_roots()
11997/// #         .unwrap()
11998/// #         .https_or_http()
11999/// #         .enable_http2()
12000/// #         .build()
12001/// # );
12002/// # let mut hub = Baremetalsolution::new(client, auth);
12003/// // You can configure optional parameters by calling the respective setters at will, and
12004/// // execute the final call using `doit()`.
12005/// // Values shown here are possibly random and not representative !
12006/// let result = hub.projects().locations_os_images_list("parent")
12007///              .page_token("sed")
12008///              .page_size(-61)
12009///              .doit().await;
12010/// # }
12011/// ```
12012pub struct ProjectLocationOsImageListCall<'a, C>
12013where
12014    C: 'a,
12015{
12016    hub: &'a Baremetalsolution<C>,
12017    _parent: String,
12018    _page_token: Option<String>,
12019    _page_size: Option<i32>,
12020    _delegate: Option<&'a mut dyn common::Delegate>,
12021    _additional_params: HashMap<String, String>,
12022    _scopes: BTreeSet<String>,
12023}
12024
12025impl<'a, C> common::CallBuilder for ProjectLocationOsImageListCall<'a, C> {}
12026
12027impl<'a, C> ProjectLocationOsImageListCall<'a, C>
12028where
12029    C: common::Connector,
12030{
12031    /// Perform the operation you have build so far.
12032    pub async fn doit(mut self) -> common::Result<(common::Response, ListOSImagesResponse)> {
12033        use std::borrow::Cow;
12034        use std::io::{Read, Seek};
12035
12036        use common::{url::Params, ToParts};
12037        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12038
12039        let mut dd = common::DefaultDelegate;
12040        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12041        dlg.begin(common::MethodInfo {
12042            id: "baremetalsolution.projects.locations.osImages.list",
12043            http_method: hyper::Method::GET,
12044        });
12045
12046        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
12047            if self._additional_params.contains_key(field) {
12048                dlg.finished(false);
12049                return Err(common::Error::FieldClash(field));
12050            }
12051        }
12052
12053        let mut params = Params::with_capacity(5 + self._additional_params.len());
12054        params.push("parent", self._parent);
12055        if let Some(value) = self._page_token.as_ref() {
12056            params.push("pageToken", value);
12057        }
12058        if let Some(value) = self._page_size.as_ref() {
12059            params.push("pageSize", value.to_string());
12060        }
12061
12062        params.extend(self._additional_params.iter());
12063
12064        params.push("alt", "json");
12065        let mut url = self.hub._base_url.clone() + "v2/{+parent}/osImages";
12066        if self._scopes.is_empty() {
12067            self._scopes
12068                .insert(Scope::CloudPlatform.as_ref().to_string());
12069        }
12070
12071        #[allow(clippy::single_element_loop)]
12072        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12073            url = params.uri_replacement(url, param_name, find_this, true);
12074        }
12075        {
12076            let to_remove = ["parent"];
12077            params.remove_params(&to_remove);
12078        }
12079
12080        let url = params.parse_with_url(&url);
12081
12082        loop {
12083            let token = match self
12084                .hub
12085                .auth
12086                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12087                .await
12088            {
12089                Ok(token) => token,
12090                Err(e) => match dlg.token(e) {
12091                    Ok(token) => token,
12092                    Err(e) => {
12093                        dlg.finished(false);
12094                        return Err(common::Error::MissingToken(e));
12095                    }
12096                },
12097            };
12098            let mut req_result = {
12099                let client = &self.hub.client;
12100                dlg.pre_request();
12101                let mut req_builder = hyper::Request::builder()
12102                    .method(hyper::Method::GET)
12103                    .uri(url.as_str())
12104                    .header(USER_AGENT, self.hub._user_agent.clone());
12105
12106                if let Some(token) = token.as_ref() {
12107                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12108                }
12109
12110                let request = req_builder
12111                    .header(CONTENT_LENGTH, 0_u64)
12112                    .body(common::to_body::<String>(None));
12113
12114                client.request(request.unwrap()).await
12115            };
12116
12117            match req_result {
12118                Err(err) => {
12119                    if let common::Retry::After(d) = dlg.http_error(&err) {
12120                        sleep(d).await;
12121                        continue;
12122                    }
12123                    dlg.finished(false);
12124                    return Err(common::Error::HttpError(err));
12125                }
12126                Ok(res) => {
12127                    let (mut parts, body) = res.into_parts();
12128                    let mut body = common::Body::new(body);
12129                    if !parts.status.is_success() {
12130                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12131                        let error = serde_json::from_str(&common::to_string(&bytes));
12132                        let response = common::to_response(parts, bytes.into());
12133
12134                        if let common::Retry::After(d) =
12135                            dlg.http_failure(&response, error.as_ref().ok())
12136                        {
12137                            sleep(d).await;
12138                            continue;
12139                        }
12140
12141                        dlg.finished(false);
12142
12143                        return Err(match error {
12144                            Ok(value) => common::Error::BadRequest(value),
12145                            _ => common::Error::Failure(response),
12146                        });
12147                    }
12148                    let response = {
12149                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12150                        let encoded = common::to_string(&bytes);
12151                        match serde_json::from_str(&encoded) {
12152                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12153                            Err(error) => {
12154                                dlg.response_json_decode_error(&encoded, &error);
12155                                return Err(common::Error::JsonDecodeError(
12156                                    encoded.to_string(),
12157                                    error,
12158                                ));
12159                            }
12160                        }
12161                    };
12162
12163                    dlg.finished(true);
12164                    return Ok(response);
12165                }
12166            }
12167        }
12168    }
12169
12170    /// Required. Parent value for ListOSImagesRequest.
12171    ///
12172    /// Sets the *parent* path property to the given value.
12173    ///
12174    /// Even though the property as already been set when instantiating this call,
12175    /// we provide this method for API completeness.
12176    pub fn parent(mut self, new_value: &str) -> ProjectLocationOsImageListCall<'a, C> {
12177        self._parent = new_value.to_string();
12178        self
12179    }
12180    /// A token identifying a page of results from the server.
12181    ///
12182    /// Sets the *page token* query property to the given value.
12183    pub fn page_token(mut self, new_value: &str) -> ProjectLocationOsImageListCall<'a, C> {
12184        self._page_token = Some(new_value.to_string());
12185        self
12186    }
12187    /// Requested page size. The server might return fewer items than requested. If unspecified, server will pick an appropriate default. Notice that page_size field is not supported and won't be respected in the API request for now, will be updated when pagination is supported.
12188    ///
12189    /// Sets the *page size* query property to the given value.
12190    pub fn page_size(mut self, new_value: i32) -> ProjectLocationOsImageListCall<'a, C> {
12191        self._page_size = Some(new_value);
12192        self
12193    }
12194    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12195    /// while executing the actual API request.
12196    ///
12197    /// ````text
12198    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12199    /// ````
12200    ///
12201    /// Sets the *delegate* property to the given value.
12202    pub fn delegate(
12203        mut self,
12204        new_value: &'a mut dyn common::Delegate,
12205    ) -> ProjectLocationOsImageListCall<'a, C> {
12206        self._delegate = Some(new_value);
12207        self
12208    }
12209
12210    /// Set any additional parameter of the query string used in the request.
12211    /// It should be used to set parameters which are not yet available through their own
12212    /// setters.
12213    ///
12214    /// Please note that this method must not be used to set any of the known parameters
12215    /// which have their own setter method. If done anyway, the request will fail.
12216    ///
12217    /// # Additional Parameters
12218    ///
12219    /// * *$.xgafv* (query-string) - V1 error format.
12220    /// * *access_token* (query-string) - OAuth access token.
12221    /// * *alt* (query-string) - Data format for response.
12222    /// * *callback* (query-string) - JSONP
12223    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12224    /// * *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.
12225    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12226    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12227    /// * *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.
12228    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12229    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12230    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOsImageListCall<'a, C>
12231    where
12232        T: AsRef<str>,
12233    {
12234        self._additional_params
12235            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12236        self
12237    }
12238
12239    /// Identifies the authorization scope for the method you are building.
12240    ///
12241    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12242    /// [`Scope::CloudPlatform`].
12243    ///
12244    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12245    /// tokens for more than one scope.
12246    ///
12247    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12248    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12249    /// sufficient, a read-write scope will do as well.
12250    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOsImageListCall<'a, C>
12251    where
12252        St: AsRef<str>,
12253    {
12254        self._scopes.insert(String::from(scope.as_ref()));
12255        self
12256    }
12257    /// Identifies the authorization scope(s) for the method you are building.
12258    ///
12259    /// See [`Self::add_scope()`] for details.
12260    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOsImageListCall<'a, C>
12261    where
12262        I: IntoIterator<Item = St>,
12263        St: AsRef<str>,
12264    {
12265        self._scopes
12266            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12267        self
12268    }
12269
12270    /// Removes all scopes, and no default scope will be used either.
12271    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12272    /// for details).
12273    pub fn clear_scopes(mut self) -> ProjectLocationOsImageListCall<'a, C> {
12274        self._scopes.clear();
12275        self
12276    }
12277}
12278
12279/// Create new ProvisioningConfig.
12280///
12281/// A builder for the *locations.provisioningConfigs.create* method supported by a *project* resource.
12282/// It is not used directly, but through a [`ProjectMethods`] instance.
12283///
12284/// # Example
12285///
12286/// Instantiate a resource method builder
12287///
12288/// ```test_harness,no_run
12289/// # extern crate hyper;
12290/// # extern crate hyper_rustls;
12291/// # extern crate google_baremetalsolution2 as baremetalsolution2;
12292/// use baremetalsolution2::api::ProvisioningConfig;
12293/// # async fn dox() {
12294/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12295///
12296/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12297/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12298/// #     .with_native_roots()
12299/// #     .unwrap()
12300/// #     .https_only()
12301/// #     .enable_http2()
12302/// #     .build();
12303///
12304/// # let executor = hyper_util::rt::TokioExecutor::new();
12305/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12306/// #     secret,
12307/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12308/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12309/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12310/// #     ),
12311/// # ).build().await.unwrap();
12312///
12313/// # let client = hyper_util::client::legacy::Client::builder(
12314/// #     hyper_util::rt::TokioExecutor::new()
12315/// # )
12316/// # .build(
12317/// #     hyper_rustls::HttpsConnectorBuilder::new()
12318/// #         .with_native_roots()
12319/// #         .unwrap()
12320/// #         .https_or_http()
12321/// #         .enable_http2()
12322/// #         .build()
12323/// # );
12324/// # let mut hub = Baremetalsolution::new(client, auth);
12325/// // As the method needs a request, you would usually fill it with the desired information
12326/// // into the respective structure. Some of the parts shown here might not be applicable !
12327/// // Values shown here are possibly random and not representative !
12328/// let mut req = ProvisioningConfig::default();
12329///
12330/// // You can configure optional parameters by calling the respective setters at will, and
12331/// // execute the final call using `doit()`.
12332/// // Values shown here are possibly random and not representative !
12333/// let result = hub.projects().locations_provisioning_configs_create(req, "parent")
12334///              .email("kasd")
12335///              .doit().await;
12336/// # }
12337/// ```
12338pub struct ProjectLocationProvisioningConfigCreateCall<'a, C>
12339where
12340    C: 'a,
12341{
12342    hub: &'a Baremetalsolution<C>,
12343    _request: ProvisioningConfig,
12344    _parent: String,
12345    _email: Option<String>,
12346    _delegate: Option<&'a mut dyn common::Delegate>,
12347    _additional_params: HashMap<String, String>,
12348    _scopes: BTreeSet<String>,
12349}
12350
12351impl<'a, C> common::CallBuilder for ProjectLocationProvisioningConfigCreateCall<'a, C> {}
12352
12353impl<'a, C> ProjectLocationProvisioningConfigCreateCall<'a, C>
12354where
12355    C: common::Connector,
12356{
12357    /// Perform the operation you have build so far.
12358    pub async fn doit(mut self) -> common::Result<(common::Response, ProvisioningConfig)> {
12359        use std::borrow::Cow;
12360        use std::io::{Read, Seek};
12361
12362        use common::{url::Params, ToParts};
12363        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12364
12365        let mut dd = common::DefaultDelegate;
12366        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12367        dlg.begin(common::MethodInfo {
12368            id: "baremetalsolution.projects.locations.provisioningConfigs.create",
12369            http_method: hyper::Method::POST,
12370        });
12371
12372        for &field in ["alt", "parent", "email"].iter() {
12373            if self._additional_params.contains_key(field) {
12374                dlg.finished(false);
12375                return Err(common::Error::FieldClash(field));
12376            }
12377        }
12378
12379        let mut params = Params::with_capacity(5 + self._additional_params.len());
12380        params.push("parent", self._parent);
12381        if let Some(value) = self._email.as_ref() {
12382            params.push("email", value);
12383        }
12384
12385        params.extend(self._additional_params.iter());
12386
12387        params.push("alt", "json");
12388        let mut url = self.hub._base_url.clone() + "v2/{+parent}/provisioningConfigs";
12389        if self._scopes.is_empty() {
12390            self._scopes
12391                .insert(Scope::CloudPlatform.as_ref().to_string());
12392        }
12393
12394        #[allow(clippy::single_element_loop)]
12395        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12396            url = params.uri_replacement(url, param_name, find_this, true);
12397        }
12398        {
12399            let to_remove = ["parent"];
12400            params.remove_params(&to_remove);
12401        }
12402
12403        let url = params.parse_with_url(&url);
12404
12405        let mut json_mime_type = mime::APPLICATION_JSON;
12406        let mut request_value_reader = {
12407            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12408            common::remove_json_null_values(&mut value);
12409            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12410            serde_json::to_writer(&mut dst, &value).unwrap();
12411            dst
12412        };
12413        let request_size = request_value_reader
12414            .seek(std::io::SeekFrom::End(0))
12415            .unwrap();
12416        request_value_reader
12417            .seek(std::io::SeekFrom::Start(0))
12418            .unwrap();
12419
12420        loop {
12421            let token = match self
12422                .hub
12423                .auth
12424                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12425                .await
12426            {
12427                Ok(token) => token,
12428                Err(e) => match dlg.token(e) {
12429                    Ok(token) => token,
12430                    Err(e) => {
12431                        dlg.finished(false);
12432                        return Err(common::Error::MissingToken(e));
12433                    }
12434                },
12435            };
12436            request_value_reader
12437                .seek(std::io::SeekFrom::Start(0))
12438                .unwrap();
12439            let mut req_result = {
12440                let client = &self.hub.client;
12441                dlg.pre_request();
12442                let mut req_builder = hyper::Request::builder()
12443                    .method(hyper::Method::POST)
12444                    .uri(url.as_str())
12445                    .header(USER_AGENT, self.hub._user_agent.clone());
12446
12447                if let Some(token) = token.as_ref() {
12448                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12449                }
12450
12451                let request = req_builder
12452                    .header(CONTENT_TYPE, json_mime_type.to_string())
12453                    .header(CONTENT_LENGTH, request_size as u64)
12454                    .body(common::to_body(
12455                        request_value_reader.get_ref().clone().into(),
12456                    ));
12457
12458                client.request(request.unwrap()).await
12459            };
12460
12461            match req_result {
12462                Err(err) => {
12463                    if let common::Retry::After(d) = dlg.http_error(&err) {
12464                        sleep(d).await;
12465                        continue;
12466                    }
12467                    dlg.finished(false);
12468                    return Err(common::Error::HttpError(err));
12469                }
12470                Ok(res) => {
12471                    let (mut parts, body) = res.into_parts();
12472                    let mut body = common::Body::new(body);
12473                    if !parts.status.is_success() {
12474                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12475                        let error = serde_json::from_str(&common::to_string(&bytes));
12476                        let response = common::to_response(parts, bytes.into());
12477
12478                        if let common::Retry::After(d) =
12479                            dlg.http_failure(&response, error.as_ref().ok())
12480                        {
12481                            sleep(d).await;
12482                            continue;
12483                        }
12484
12485                        dlg.finished(false);
12486
12487                        return Err(match error {
12488                            Ok(value) => common::Error::BadRequest(value),
12489                            _ => common::Error::Failure(response),
12490                        });
12491                    }
12492                    let response = {
12493                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12494                        let encoded = common::to_string(&bytes);
12495                        match serde_json::from_str(&encoded) {
12496                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12497                            Err(error) => {
12498                                dlg.response_json_decode_error(&encoded, &error);
12499                                return Err(common::Error::JsonDecodeError(
12500                                    encoded.to_string(),
12501                                    error,
12502                                ));
12503                            }
12504                        }
12505                    };
12506
12507                    dlg.finished(true);
12508                    return Ok(response);
12509                }
12510            }
12511        }
12512    }
12513
12514    ///
12515    /// Sets the *request* property to the given value.
12516    ///
12517    /// Even though the property as already been set when instantiating this call,
12518    /// we provide this method for API completeness.
12519    pub fn request(
12520        mut self,
12521        new_value: ProvisioningConfig,
12522    ) -> ProjectLocationProvisioningConfigCreateCall<'a, C> {
12523        self._request = new_value;
12524        self
12525    }
12526    /// Required. The parent project and location containing the ProvisioningConfig.
12527    ///
12528    /// Sets the *parent* path property to the given value.
12529    ///
12530    /// Even though the property as already been set when instantiating this call,
12531    /// we provide this method for API completeness.
12532    pub fn parent(mut self, new_value: &str) -> ProjectLocationProvisioningConfigCreateCall<'a, C> {
12533        self._parent = new_value.to_string();
12534        self
12535    }
12536    /// Optional. Email provided to send a confirmation with provisioning config to.
12537    ///
12538    /// Sets the *email* query property to the given value.
12539    pub fn email(mut self, new_value: &str) -> ProjectLocationProvisioningConfigCreateCall<'a, C> {
12540        self._email = Some(new_value.to_string());
12541        self
12542    }
12543    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12544    /// while executing the actual API request.
12545    ///
12546    /// ````text
12547    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12548    /// ````
12549    ///
12550    /// Sets the *delegate* property to the given value.
12551    pub fn delegate(
12552        mut self,
12553        new_value: &'a mut dyn common::Delegate,
12554    ) -> ProjectLocationProvisioningConfigCreateCall<'a, C> {
12555        self._delegate = Some(new_value);
12556        self
12557    }
12558
12559    /// Set any additional parameter of the query string used in the request.
12560    /// It should be used to set parameters which are not yet available through their own
12561    /// setters.
12562    ///
12563    /// Please note that this method must not be used to set any of the known parameters
12564    /// which have their own setter method. If done anyway, the request will fail.
12565    ///
12566    /// # Additional Parameters
12567    ///
12568    /// * *$.xgafv* (query-string) - V1 error format.
12569    /// * *access_token* (query-string) - OAuth access token.
12570    /// * *alt* (query-string) - Data format for response.
12571    /// * *callback* (query-string) - JSONP
12572    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12573    /// * *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.
12574    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12575    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12576    /// * *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.
12577    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12578    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12579    pub fn param<T>(
12580        mut self,
12581        name: T,
12582        value: T,
12583    ) -> ProjectLocationProvisioningConfigCreateCall<'a, C>
12584    where
12585        T: AsRef<str>,
12586    {
12587        self._additional_params
12588            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12589        self
12590    }
12591
12592    /// Identifies the authorization scope for the method you are building.
12593    ///
12594    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12595    /// [`Scope::CloudPlatform`].
12596    ///
12597    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12598    /// tokens for more than one scope.
12599    ///
12600    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12601    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12602    /// sufficient, a read-write scope will do as well.
12603    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProvisioningConfigCreateCall<'a, C>
12604    where
12605        St: AsRef<str>,
12606    {
12607        self._scopes.insert(String::from(scope.as_ref()));
12608        self
12609    }
12610    /// Identifies the authorization scope(s) for the method you are building.
12611    ///
12612    /// See [`Self::add_scope()`] for details.
12613    pub fn add_scopes<I, St>(
12614        mut self,
12615        scopes: I,
12616    ) -> ProjectLocationProvisioningConfigCreateCall<'a, C>
12617    where
12618        I: IntoIterator<Item = St>,
12619        St: AsRef<str>,
12620    {
12621        self._scopes
12622            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12623        self
12624    }
12625
12626    /// Removes all scopes, and no default scope will be used either.
12627    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12628    /// for details).
12629    pub fn clear_scopes(mut self) -> ProjectLocationProvisioningConfigCreateCall<'a, C> {
12630        self._scopes.clear();
12631        self
12632    }
12633}
12634
12635/// Get ProvisioningConfig by name.
12636///
12637/// A builder for the *locations.provisioningConfigs.get* method supported by a *project* resource.
12638/// It is not used directly, but through a [`ProjectMethods`] instance.
12639///
12640/// # Example
12641///
12642/// Instantiate a resource method builder
12643///
12644/// ```test_harness,no_run
12645/// # extern crate hyper;
12646/// # extern crate hyper_rustls;
12647/// # extern crate google_baremetalsolution2 as baremetalsolution2;
12648/// # async fn dox() {
12649/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12650///
12651/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12652/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12653/// #     .with_native_roots()
12654/// #     .unwrap()
12655/// #     .https_only()
12656/// #     .enable_http2()
12657/// #     .build();
12658///
12659/// # let executor = hyper_util::rt::TokioExecutor::new();
12660/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12661/// #     secret,
12662/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12663/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12664/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12665/// #     ),
12666/// # ).build().await.unwrap();
12667///
12668/// # let client = hyper_util::client::legacy::Client::builder(
12669/// #     hyper_util::rt::TokioExecutor::new()
12670/// # )
12671/// # .build(
12672/// #     hyper_rustls::HttpsConnectorBuilder::new()
12673/// #         .with_native_roots()
12674/// #         .unwrap()
12675/// #         .https_or_http()
12676/// #         .enable_http2()
12677/// #         .build()
12678/// # );
12679/// # let mut hub = Baremetalsolution::new(client, auth);
12680/// // You can configure optional parameters by calling the respective setters at will, and
12681/// // execute the final call using `doit()`.
12682/// // Values shown here are possibly random and not representative !
12683/// let result = hub.projects().locations_provisioning_configs_get("name")
12684///              .doit().await;
12685/// # }
12686/// ```
12687pub struct ProjectLocationProvisioningConfigGetCall<'a, C>
12688where
12689    C: 'a,
12690{
12691    hub: &'a Baremetalsolution<C>,
12692    _name: String,
12693    _delegate: Option<&'a mut dyn common::Delegate>,
12694    _additional_params: HashMap<String, String>,
12695    _scopes: BTreeSet<String>,
12696}
12697
12698impl<'a, C> common::CallBuilder for ProjectLocationProvisioningConfigGetCall<'a, C> {}
12699
12700impl<'a, C> ProjectLocationProvisioningConfigGetCall<'a, C>
12701where
12702    C: common::Connector,
12703{
12704    /// Perform the operation you have build so far.
12705    pub async fn doit(mut self) -> common::Result<(common::Response, ProvisioningConfig)> {
12706        use std::borrow::Cow;
12707        use std::io::{Read, Seek};
12708
12709        use common::{url::Params, ToParts};
12710        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12711
12712        let mut dd = common::DefaultDelegate;
12713        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12714        dlg.begin(common::MethodInfo {
12715            id: "baremetalsolution.projects.locations.provisioningConfigs.get",
12716            http_method: hyper::Method::GET,
12717        });
12718
12719        for &field in ["alt", "name"].iter() {
12720            if self._additional_params.contains_key(field) {
12721                dlg.finished(false);
12722                return Err(common::Error::FieldClash(field));
12723            }
12724        }
12725
12726        let mut params = Params::with_capacity(3 + self._additional_params.len());
12727        params.push("name", self._name);
12728
12729        params.extend(self._additional_params.iter());
12730
12731        params.push("alt", "json");
12732        let mut url = self.hub._base_url.clone() + "v2/{+name}";
12733        if self._scopes.is_empty() {
12734            self._scopes
12735                .insert(Scope::CloudPlatform.as_ref().to_string());
12736        }
12737
12738        #[allow(clippy::single_element_loop)]
12739        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12740            url = params.uri_replacement(url, param_name, find_this, true);
12741        }
12742        {
12743            let to_remove = ["name"];
12744            params.remove_params(&to_remove);
12745        }
12746
12747        let url = params.parse_with_url(&url);
12748
12749        loop {
12750            let token = match self
12751                .hub
12752                .auth
12753                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12754                .await
12755            {
12756                Ok(token) => token,
12757                Err(e) => match dlg.token(e) {
12758                    Ok(token) => token,
12759                    Err(e) => {
12760                        dlg.finished(false);
12761                        return Err(common::Error::MissingToken(e));
12762                    }
12763                },
12764            };
12765            let mut req_result = {
12766                let client = &self.hub.client;
12767                dlg.pre_request();
12768                let mut req_builder = hyper::Request::builder()
12769                    .method(hyper::Method::GET)
12770                    .uri(url.as_str())
12771                    .header(USER_AGENT, self.hub._user_agent.clone());
12772
12773                if let Some(token) = token.as_ref() {
12774                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12775                }
12776
12777                let request = req_builder
12778                    .header(CONTENT_LENGTH, 0_u64)
12779                    .body(common::to_body::<String>(None));
12780
12781                client.request(request.unwrap()).await
12782            };
12783
12784            match req_result {
12785                Err(err) => {
12786                    if let common::Retry::After(d) = dlg.http_error(&err) {
12787                        sleep(d).await;
12788                        continue;
12789                    }
12790                    dlg.finished(false);
12791                    return Err(common::Error::HttpError(err));
12792                }
12793                Ok(res) => {
12794                    let (mut parts, body) = res.into_parts();
12795                    let mut body = common::Body::new(body);
12796                    if !parts.status.is_success() {
12797                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12798                        let error = serde_json::from_str(&common::to_string(&bytes));
12799                        let response = common::to_response(parts, bytes.into());
12800
12801                        if let common::Retry::After(d) =
12802                            dlg.http_failure(&response, error.as_ref().ok())
12803                        {
12804                            sleep(d).await;
12805                            continue;
12806                        }
12807
12808                        dlg.finished(false);
12809
12810                        return Err(match error {
12811                            Ok(value) => common::Error::BadRequest(value),
12812                            _ => common::Error::Failure(response),
12813                        });
12814                    }
12815                    let response = {
12816                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12817                        let encoded = common::to_string(&bytes);
12818                        match serde_json::from_str(&encoded) {
12819                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12820                            Err(error) => {
12821                                dlg.response_json_decode_error(&encoded, &error);
12822                                return Err(common::Error::JsonDecodeError(
12823                                    encoded.to_string(),
12824                                    error,
12825                                ));
12826                            }
12827                        }
12828                    };
12829
12830                    dlg.finished(true);
12831                    return Ok(response);
12832                }
12833            }
12834        }
12835    }
12836
12837    /// Required. Name of the ProvisioningConfig.
12838    ///
12839    /// Sets the *name* path property to the given value.
12840    ///
12841    /// Even though the property as already been set when instantiating this call,
12842    /// we provide this method for API completeness.
12843    pub fn name(mut self, new_value: &str) -> ProjectLocationProvisioningConfigGetCall<'a, C> {
12844        self._name = new_value.to_string();
12845        self
12846    }
12847    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12848    /// while executing the actual API request.
12849    ///
12850    /// ````text
12851    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12852    /// ````
12853    ///
12854    /// Sets the *delegate* property to the given value.
12855    pub fn delegate(
12856        mut self,
12857        new_value: &'a mut dyn common::Delegate,
12858    ) -> ProjectLocationProvisioningConfigGetCall<'a, C> {
12859        self._delegate = Some(new_value);
12860        self
12861    }
12862
12863    /// Set any additional parameter of the query string used in the request.
12864    /// It should be used to set parameters which are not yet available through their own
12865    /// setters.
12866    ///
12867    /// Please note that this method must not be used to set any of the known parameters
12868    /// which have their own setter method. If done anyway, the request will fail.
12869    ///
12870    /// # Additional Parameters
12871    ///
12872    /// * *$.xgafv* (query-string) - V1 error format.
12873    /// * *access_token* (query-string) - OAuth access token.
12874    /// * *alt* (query-string) - Data format for response.
12875    /// * *callback* (query-string) - JSONP
12876    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12877    /// * *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.
12878    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12879    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12880    /// * *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.
12881    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12882    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12883    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProvisioningConfigGetCall<'a, C>
12884    where
12885        T: AsRef<str>,
12886    {
12887        self._additional_params
12888            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12889        self
12890    }
12891
12892    /// Identifies the authorization scope for the method you are building.
12893    ///
12894    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12895    /// [`Scope::CloudPlatform`].
12896    ///
12897    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12898    /// tokens for more than one scope.
12899    ///
12900    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12901    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12902    /// sufficient, a read-write scope will do as well.
12903    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProvisioningConfigGetCall<'a, C>
12904    where
12905        St: AsRef<str>,
12906    {
12907        self._scopes.insert(String::from(scope.as_ref()));
12908        self
12909    }
12910    /// Identifies the authorization scope(s) for the method you are building.
12911    ///
12912    /// See [`Self::add_scope()`] for details.
12913    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProvisioningConfigGetCall<'a, C>
12914    where
12915        I: IntoIterator<Item = St>,
12916        St: AsRef<str>,
12917    {
12918        self._scopes
12919            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12920        self
12921    }
12922
12923    /// Removes all scopes, and no default scope will be used either.
12924    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12925    /// for details).
12926    pub fn clear_scopes(mut self) -> ProjectLocationProvisioningConfigGetCall<'a, C> {
12927        self._scopes.clear();
12928        self
12929    }
12930}
12931
12932/// Update existing ProvisioningConfig.
12933///
12934/// A builder for the *locations.provisioningConfigs.patch* method supported by a *project* resource.
12935/// It is not used directly, but through a [`ProjectMethods`] instance.
12936///
12937/// # Example
12938///
12939/// Instantiate a resource method builder
12940///
12941/// ```test_harness,no_run
12942/// # extern crate hyper;
12943/// # extern crate hyper_rustls;
12944/// # extern crate google_baremetalsolution2 as baremetalsolution2;
12945/// use baremetalsolution2::api::ProvisioningConfig;
12946/// # async fn dox() {
12947/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12948///
12949/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12950/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12951/// #     .with_native_roots()
12952/// #     .unwrap()
12953/// #     .https_only()
12954/// #     .enable_http2()
12955/// #     .build();
12956///
12957/// # let executor = hyper_util::rt::TokioExecutor::new();
12958/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12959/// #     secret,
12960/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12961/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12962/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12963/// #     ),
12964/// # ).build().await.unwrap();
12965///
12966/// # let client = hyper_util::client::legacy::Client::builder(
12967/// #     hyper_util::rt::TokioExecutor::new()
12968/// # )
12969/// # .build(
12970/// #     hyper_rustls::HttpsConnectorBuilder::new()
12971/// #         .with_native_roots()
12972/// #         .unwrap()
12973/// #         .https_or_http()
12974/// #         .enable_http2()
12975/// #         .build()
12976/// # );
12977/// # let mut hub = Baremetalsolution::new(client, auth);
12978/// // As the method needs a request, you would usually fill it with the desired information
12979/// // into the respective structure. Some of the parts shown here might not be applicable !
12980/// // Values shown here are possibly random and not representative !
12981/// let mut req = ProvisioningConfig::default();
12982///
12983/// // You can configure optional parameters by calling the respective setters at will, and
12984/// // execute the final call using `doit()`.
12985/// // Values shown here are possibly random and not representative !
12986/// let result = hub.projects().locations_provisioning_configs_patch(req, "name")
12987///              .update_mask(FieldMask::new::<&str>(&[]))
12988///              .email("et")
12989///              .doit().await;
12990/// # }
12991/// ```
12992pub struct ProjectLocationProvisioningConfigPatchCall<'a, C>
12993where
12994    C: 'a,
12995{
12996    hub: &'a Baremetalsolution<C>,
12997    _request: ProvisioningConfig,
12998    _name: String,
12999    _update_mask: Option<common::FieldMask>,
13000    _email: Option<String>,
13001    _delegate: Option<&'a mut dyn common::Delegate>,
13002    _additional_params: HashMap<String, String>,
13003    _scopes: BTreeSet<String>,
13004}
13005
13006impl<'a, C> common::CallBuilder for ProjectLocationProvisioningConfigPatchCall<'a, C> {}
13007
13008impl<'a, C> ProjectLocationProvisioningConfigPatchCall<'a, C>
13009where
13010    C: common::Connector,
13011{
13012    /// Perform the operation you have build so far.
13013    pub async fn doit(mut self) -> common::Result<(common::Response, ProvisioningConfig)> {
13014        use std::borrow::Cow;
13015        use std::io::{Read, Seek};
13016
13017        use common::{url::Params, ToParts};
13018        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13019
13020        let mut dd = common::DefaultDelegate;
13021        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13022        dlg.begin(common::MethodInfo {
13023            id: "baremetalsolution.projects.locations.provisioningConfigs.patch",
13024            http_method: hyper::Method::PATCH,
13025        });
13026
13027        for &field in ["alt", "name", "updateMask", "email"].iter() {
13028            if self._additional_params.contains_key(field) {
13029                dlg.finished(false);
13030                return Err(common::Error::FieldClash(field));
13031            }
13032        }
13033
13034        let mut params = Params::with_capacity(6 + self._additional_params.len());
13035        params.push("name", self._name);
13036        if let Some(value) = self._update_mask.as_ref() {
13037            params.push("updateMask", value.to_string());
13038        }
13039        if let Some(value) = self._email.as_ref() {
13040            params.push("email", value);
13041        }
13042
13043        params.extend(self._additional_params.iter());
13044
13045        params.push("alt", "json");
13046        let mut url = self.hub._base_url.clone() + "v2/{+name}";
13047        if self._scopes.is_empty() {
13048            self._scopes
13049                .insert(Scope::CloudPlatform.as_ref().to_string());
13050        }
13051
13052        #[allow(clippy::single_element_loop)]
13053        for &(find_this, param_name) in [("{+name}", "name")].iter() {
13054            url = params.uri_replacement(url, param_name, find_this, true);
13055        }
13056        {
13057            let to_remove = ["name"];
13058            params.remove_params(&to_remove);
13059        }
13060
13061        let url = params.parse_with_url(&url);
13062
13063        let mut json_mime_type = mime::APPLICATION_JSON;
13064        let mut request_value_reader = {
13065            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13066            common::remove_json_null_values(&mut value);
13067            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13068            serde_json::to_writer(&mut dst, &value).unwrap();
13069            dst
13070        };
13071        let request_size = request_value_reader
13072            .seek(std::io::SeekFrom::End(0))
13073            .unwrap();
13074        request_value_reader
13075            .seek(std::io::SeekFrom::Start(0))
13076            .unwrap();
13077
13078        loop {
13079            let token = match self
13080                .hub
13081                .auth
13082                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13083                .await
13084            {
13085                Ok(token) => token,
13086                Err(e) => match dlg.token(e) {
13087                    Ok(token) => token,
13088                    Err(e) => {
13089                        dlg.finished(false);
13090                        return Err(common::Error::MissingToken(e));
13091                    }
13092                },
13093            };
13094            request_value_reader
13095                .seek(std::io::SeekFrom::Start(0))
13096                .unwrap();
13097            let mut req_result = {
13098                let client = &self.hub.client;
13099                dlg.pre_request();
13100                let mut req_builder = hyper::Request::builder()
13101                    .method(hyper::Method::PATCH)
13102                    .uri(url.as_str())
13103                    .header(USER_AGENT, self.hub._user_agent.clone());
13104
13105                if let Some(token) = token.as_ref() {
13106                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13107                }
13108
13109                let request = req_builder
13110                    .header(CONTENT_TYPE, json_mime_type.to_string())
13111                    .header(CONTENT_LENGTH, request_size as u64)
13112                    .body(common::to_body(
13113                        request_value_reader.get_ref().clone().into(),
13114                    ));
13115
13116                client.request(request.unwrap()).await
13117            };
13118
13119            match req_result {
13120                Err(err) => {
13121                    if let common::Retry::After(d) = dlg.http_error(&err) {
13122                        sleep(d).await;
13123                        continue;
13124                    }
13125                    dlg.finished(false);
13126                    return Err(common::Error::HttpError(err));
13127                }
13128                Ok(res) => {
13129                    let (mut parts, body) = res.into_parts();
13130                    let mut body = common::Body::new(body);
13131                    if !parts.status.is_success() {
13132                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13133                        let error = serde_json::from_str(&common::to_string(&bytes));
13134                        let response = common::to_response(parts, bytes.into());
13135
13136                        if let common::Retry::After(d) =
13137                            dlg.http_failure(&response, error.as_ref().ok())
13138                        {
13139                            sleep(d).await;
13140                            continue;
13141                        }
13142
13143                        dlg.finished(false);
13144
13145                        return Err(match error {
13146                            Ok(value) => common::Error::BadRequest(value),
13147                            _ => common::Error::Failure(response),
13148                        });
13149                    }
13150                    let response = {
13151                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13152                        let encoded = common::to_string(&bytes);
13153                        match serde_json::from_str(&encoded) {
13154                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13155                            Err(error) => {
13156                                dlg.response_json_decode_error(&encoded, &error);
13157                                return Err(common::Error::JsonDecodeError(
13158                                    encoded.to_string(),
13159                                    error,
13160                                ));
13161                            }
13162                        }
13163                    };
13164
13165                    dlg.finished(true);
13166                    return Ok(response);
13167                }
13168            }
13169        }
13170    }
13171
13172    ///
13173    /// Sets the *request* property to the given value.
13174    ///
13175    /// Even though the property as already been set when instantiating this call,
13176    /// we provide this method for API completeness.
13177    pub fn request(
13178        mut self,
13179        new_value: ProvisioningConfig,
13180    ) -> ProjectLocationProvisioningConfigPatchCall<'a, C> {
13181        self._request = new_value;
13182        self
13183    }
13184    /// Output only. The system-generated name of the provisioning config. This follows the UUID format.
13185    ///
13186    /// Sets the *name* path property to the given value.
13187    ///
13188    /// Even though the property as already been set when instantiating this call,
13189    /// we provide this method for API completeness.
13190    pub fn name(mut self, new_value: &str) -> ProjectLocationProvisioningConfigPatchCall<'a, C> {
13191        self._name = new_value.to_string();
13192        self
13193    }
13194    /// Required. The list of fields to update.
13195    ///
13196    /// Sets the *update mask* query property to the given value.
13197    pub fn update_mask(
13198        mut self,
13199        new_value: common::FieldMask,
13200    ) -> ProjectLocationProvisioningConfigPatchCall<'a, C> {
13201        self._update_mask = Some(new_value);
13202        self
13203    }
13204    /// Optional. Email provided to send a confirmation with provisioning config to.
13205    ///
13206    /// Sets the *email* query property to the given value.
13207    pub fn email(mut self, new_value: &str) -> ProjectLocationProvisioningConfigPatchCall<'a, C> {
13208        self._email = Some(new_value.to_string());
13209        self
13210    }
13211    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13212    /// while executing the actual API request.
13213    ///
13214    /// ````text
13215    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13216    /// ````
13217    ///
13218    /// Sets the *delegate* property to the given value.
13219    pub fn delegate(
13220        mut self,
13221        new_value: &'a mut dyn common::Delegate,
13222    ) -> ProjectLocationProvisioningConfigPatchCall<'a, C> {
13223        self._delegate = Some(new_value);
13224        self
13225    }
13226
13227    /// Set any additional parameter of the query string used in the request.
13228    /// It should be used to set parameters which are not yet available through their own
13229    /// setters.
13230    ///
13231    /// Please note that this method must not be used to set any of the known parameters
13232    /// which have their own setter method. If done anyway, the request will fail.
13233    ///
13234    /// # Additional Parameters
13235    ///
13236    /// * *$.xgafv* (query-string) - V1 error format.
13237    /// * *access_token* (query-string) - OAuth access token.
13238    /// * *alt* (query-string) - Data format for response.
13239    /// * *callback* (query-string) - JSONP
13240    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13241    /// * *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.
13242    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13243    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13244    /// * *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.
13245    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13246    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13247    pub fn param<T>(
13248        mut self,
13249        name: T,
13250        value: T,
13251    ) -> ProjectLocationProvisioningConfigPatchCall<'a, C>
13252    where
13253        T: AsRef<str>,
13254    {
13255        self._additional_params
13256            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13257        self
13258    }
13259
13260    /// Identifies the authorization scope for the method you are building.
13261    ///
13262    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13263    /// [`Scope::CloudPlatform`].
13264    ///
13265    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13266    /// tokens for more than one scope.
13267    ///
13268    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13269    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13270    /// sufficient, a read-write scope will do as well.
13271    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProvisioningConfigPatchCall<'a, C>
13272    where
13273        St: AsRef<str>,
13274    {
13275        self._scopes.insert(String::from(scope.as_ref()));
13276        self
13277    }
13278    /// Identifies the authorization scope(s) for the method you are building.
13279    ///
13280    /// See [`Self::add_scope()`] for details.
13281    pub fn add_scopes<I, St>(
13282        mut self,
13283        scopes: I,
13284    ) -> ProjectLocationProvisioningConfigPatchCall<'a, C>
13285    where
13286        I: IntoIterator<Item = St>,
13287        St: AsRef<str>,
13288    {
13289        self._scopes
13290            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13291        self
13292    }
13293
13294    /// Removes all scopes, and no default scope will be used either.
13295    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13296    /// for details).
13297    pub fn clear_scopes(mut self) -> ProjectLocationProvisioningConfigPatchCall<'a, C> {
13298        self._scopes.clear();
13299        self
13300    }
13301}
13302
13303/// Submit a provisioning configuration for a given project.
13304///
13305/// A builder for the *locations.provisioningConfigs.submit* method supported by a *project* resource.
13306/// It is not used directly, but through a [`ProjectMethods`] instance.
13307///
13308/// # Example
13309///
13310/// Instantiate a resource method builder
13311///
13312/// ```test_harness,no_run
13313/// # extern crate hyper;
13314/// # extern crate hyper_rustls;
13315/// # extern crate google_baremetalsolution2 as baremetalsolution2;
13316/// use baremetalsolution2::api::SubmitProvisioningConfigRequest;
13317/// # async fn dox() {
13318/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13319///
13320/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13321/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13322/// #     .with_native_roots()
13323/// #     .unwrap()
13324/// #     .https_only()
13325/// #     .enable_http2()
13326/// #     .build();
13327///
13328/// # let executor = hyper_util::rt::TokioExecutor::new();
13329/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13330/// #     secret,
13331/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13332/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13333/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13334/// #     ),
13335/// # ).build().await.unwrap();
13336///
13337/// # let client = hyper_util::client::legacy::Client::builder(
13338/// #     hyper_util::rt::TokioExecutor::new()
13339/// # )
13340/// # .build(
13341/// #     hyper_rustls::HttpsConnectorBuilder::new()
13342/// #         .with_native_roots()
13343/// #         .unwrap()
13344/// #         .https_or_http()
13345/// #         .enable_http2()
13346/// #         .build()
13347/// # );
13348/// # let mut hub = Baremetalsolution::new(client, auth);
13349/// // As the method needs a request, you would usually fill it with the desired information
13350/// // into the respective structure. Some of the parts shown here might not be applicable !
13351/// // Values shown here are possibly random and not representative !
13352/// let mut req = SubmitProvisioningConfigRequest::default();
13353///
13354/// // You can configure optional parameters by calling the respective setters at will, and
13355/// // execute the final call using `doit()`.
13356/// // Values shown here are possibly random and not representative !
13357/// let result = hub.projects().locations_provisioning_configs_submit(req, "parent")
13358///              .doit().await;
13359/// # }
13360/// ```
13361pub struct ProjectLocationProvisioningConfigSubmitCall<'a, C>
13362where
13363    C: 'a,
13364{
13365    hub: &'a Baremetalsolution<C>,
13366    _request: SubmitProvisioningConfigRequest,
13367    _parent: String,
13368    _delegate: Option<&'a mut dyn common::Delegate>,
13369    _additional_params: HashMap<String, String>,
13370    _scopes: BTreeSet<String>,
13371}
13372
13373impl<'a, C> common::CallBuilder for ProjectLocationProvisioningConfigSubmitCall<'a, C> {}
13374
13375impl<'a, C> ProjectLocationProvisioningConfigSubmitCall<'a, C>
13376where
13377    C: common::Connector,
13378{
13379    /// Perform the operation you have build so far.
13380    pub async fn doit(
13381        mut self,
13382    ) -> common::Result<(common::Response, SubmitProvisioningConfigResponse)> {
13383        use std::borrow::Cow;
13384        use std::io::{Read, Seek};
13385
13386        use common::{url::Params, ToParts};
13387        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13388
13389        let mut dd = common::DefaultDelegate;
13390        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13391        dlg.begin(common::MethodInfo {
13392            id: "baremetalsolution.projects.locations.provisioningConfigs.submit",
13393            http_method: hyper::Method::POST,
13394        });
13395
13396        for &field in ["alt", "parent"].iter() {
13397            if self._additional_params.contains_key(field) {
13398                dlg.finished(false);
13399                return Err(common::Error::FieldClash(field));
13400            }
13401        }
13402
13403        let mut params = Params::with_capacity(4 + self._additional_params.len());
13404        params.push("parent", self._parent);
13405
13406        params.extend(self._additional_params.iter());
13407
13408        params.push("alt", "json");
13409        let mut url = self.hub._base_url.clone() + "v2/{+parent}/provisioningConfigs:submit";
13410        if self._scopes.is_empty() {
13411            self._scopes
13412                .insert(Scope::CloudPlatform.as_ref().to_string());
13413        }
13414
13415        #[allow(clippy::single_element_loop)]
13416        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13417            url = params.uri_replacement(url, param_name, find_this, true);
13418        }
13419        {
13420            let to_remove = ["parent"];
13421            params.remove_params(&to_remove);
13422        }
13423
13424        let url = params.parse_with_url(&url);
13425
13426        let mut json_mime_type = mime::APPLICATION_JSON;
13427        let mut request_value_reader = {
13428            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13429            common::remove_json_null_values(&mut value);
13430            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13431            serde_json::to_writer(&mut dst, &value).unwrap();
13432            dst
13433        };
13434        let request_size = request_value_reader
13435            .seek(std::io::SeekFrom::End(0))
13436            .unwrap();
13437        request_value_reader
13438            .seek(std::io::SeekFrom::Start(0))
13439            .unwrap();
13440
13441        loop {
13442            let token = match self
13443                .hub
13444                .auth
13445                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13446                .await
13447            {
13448                Ok(token) => token,
13449                Err(e) => match dlg.token(e) {
13450                    Ok(token) => token,
13451                    Err(e) => {
13452                        dlg.finished(false);
13453                        return Err(common::Error::MissingToken(e));
13454                    }
13455                },
13456            };
13457            request_value_reader
13458                .seek(std::io::SeekFrom::Start(0))
13459                .unwrap();
13460            let mut req_result = {
13461                let client = &self.hub.client;
13462                dlg.pre_request();
13463                let mut req_builder = hyper::Request::builder()
13464                    .method(hyper::Method::POST)
13465                    .uri(url.as_str())
13466                    .header(USER_AGENT, self.hub._user_agent.clone());
13467
13468                if let Some(token) = token.as_ref() {
13469                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13470                }
13471
13472                let request = req_builder
13473                    .header(CONTENT_TYPE, json_mime_type.to_string())
13474                    .header(CONTENT_LENGTH, request_size as u64)
13475                    .body(common::to_body(
13476                        request_value_reader.get_ref().clone().into(),
13477                    ));
13478
13479                client.request(request.unwrap()).await
13480            };
13481
13482            match req_result {
13483                Err(err) => {
13484                    if let common::Retry::After(d) = dlg.http_error(&err) {
13485                        sleep(d).await;
13486                        continue;
13487                    }
13488                    dlg.finished(false);
13489                    return Err(common::Error::HttpError(err));
13490                }
13491                Ok(res) => {
13492                    let (mut parts, body) = res.into_parts();
13493                    let mut body = common::Body::new(body);
13494                    if !parts.status.is_success() {
13495                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13496                        let error = serde_json::from_str(&common::to_string(&bytes));
13497                        let response = common::to_response(parts, bytes.into());
13498
13499                        if let common::Retry::After(d) =
13500                            dlg.http_failure(&response, error.as_ref().ok())
13501                        {
13502                            sleep(d).await;
13503                            continue;
13504                        }
13505
13506                        dlg.finished(false);
13507
13508                        return Err(match error {
13509                            Ok(value) => common::Error::BadRequest(value),
13510                            _ => common::Error::Failure(response),
13511                        });
13512                    }
13513                    let response = {
13514                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13515                        let encoded = common::to_string(&bytes);
13516                        match serde_json::from_str(&encoded) {
13517                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13518                            Err(error) => {
13519                                dlg.response_json_decode_error(&encoded, &error);
13520                                return Err(common::Error::JsonDecodeError(
13521                                    encoded.to_string(),
13522                                    error,
13523                                ));
13524                            }
13525                        }
13526                    };
13527
13528                    dlg.finished(true);
13529                    return Ok(response);
13530                }
13531            }
13532        }
13533    }
13534
13535    ///
13536    /// Sets the *request* property to the given value.
13537    ///
13538    /// Even though the property as already been set when instantiating this call,
13539    /// we provide this method for API completeness.
13540    pub fn request(
13541        mut self,
13542        new_value: SubmitProvisioningConfigRequest,
13543    ) -> ProjectLocationProvisioningConfigSubmitCall<'a, C> {
13544        self._request = new_value;
13545        self
13546    }
13547    /// Required. The parent project and location containing the ProvisioningConfig.
13548    ///
13549    /// Sets the *parent* path property to the given value.
13550    ///
13551    /// Even though the property as already been set when instantiating this call,
13552    /// we provide this method for API completeness.
13553    pub fn parent(mut self, new_value: &str) -> ProjectLocationProvisioningConfigSubmitCall<'a, C> {
13554        self._parent = new_value.to_string();
13555        self
13556    }
13557    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13558    /// while executing the actual API request.
13559    ///
13560    /// ````text
13561    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13562    /// ````
13563    ///
13564    /// Sets the *delegate* property to the given value.
13565    pub fn delegate(
13566        mut self,
13567        new_value: &'a mut dyn common::Delegate,
13568    ) -> ProjectLocationProvisioningConfigSubmitCall<'a, C> {
13569        self._delegate = Some(new_value);
13570        self
13571    }
13572
13573    /// Set any additional parameter of the query string used in the request.
13574    /// It should be used to set parameters which are not yet available through their own
13575    /// setters.
13576    ///
13577    /// Please note that this method must not be used to set any of the known parameters
13578    /// which have their own setter method. If done anyway, the request will fail.
13579    ///
13580    /// # Additional Parameters
13581    ///
13582    /// * *$.xgafv* (query-string) - V1 error format.
13583    /// * *access_token* (query-string) - OAuth access token.
13584    /// * *alt* (query-string) - Data format for response.
13585    /// * *callback* (query-string) - JSONP
13586    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13587    /// * *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.
13588    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13589    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13590    /// * *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.
13591    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13592    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13593    pub fn param<T>(
13594        mut self,
13595        name: T,
13596        value: T,
13597    ) -> ProjectLocationProvisioningConfigSubmitCall<'a, C>
13598    where
13599        T: AsRef<str>,
13600    {
13601        self._additional_params
13602            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13603        self
13604    }
13605
13606    /// Identifies the authorization scope for the method you are building.
13607    ///
13608    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13609    /// [`Scope::CloudPlatform`].
13610    ///
13611    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13612    /// tokens for more than one scope.
13613    ///
13614    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13615    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13616    /// sufficient, a read-write scope will do as well.
13617    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProvisioningConfigSubmitCall<'a, C>
13618    where
13619        St: AsRef<str>,
13620    {
13621        self._scopes.insert(String::from(scope.as_ref()));
13622        self
13623    }
13624    /// Identifies the authorization scope(s) for the method you are building.
13625    ///
13626    /// See [`Self::add_scope()`] for details.
13627    pub fn add_scopes<I, St>(
13628        mut self,
13629        scopes: I,
13630    ) -> ProjectLocationProvisioningConfigSubmitCall<'a, C>
13631    where
13632        I: IntoIterator<Item = St>,
13633        St: AsRef<str>,
13634    {
13635        self._scopes
13636            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13637        self
13638    }
13639
13640    /// Removes all scopes, and no default scope will be used either.
13641    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13642    /// for details).
13643    pub fn clear_scopes(mut self) -> ProjectLocationProvisioningConfigSubmitCall<'a, C> {
13644        self._scopes.clear();
13645        self
13646    }
13647}
13648
13649/// List the budget details to provision resources on a given project.
13650///
13651/// A builder for the *locations.provisioningQuotas.list* method supported by a *project* resource.
13652/// It is not used directly, but through a [`ProjectMethods`] instance.
13653///
13654/// # Example
13655///
13656/// Instantiate a resource method builder
13657///
13658/// ```test_harness,no_run
13659/// # extern crate hyper;
13660/// # extern crate hyper_rustls;
13661/// # extern crate google_baremetalsolution2 as baremetalsolution2;
13662/// # async fn dox() {
13663/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13664///
13665/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13666/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13667/// #     .with_native_roots()
13668/// #     .unwrap()
13669/// #     .https_only()
13670/// #     .enable_http2()
13671/// #     .build();
13672///
13673/// # let executor = hyper_util::rt::TokioExecutor::new();
13674/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13675/// #     secret,
13676/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13677/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13678/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13679/// #     ),
13680/// # ).build().await.unwrap();
13681///
13682/// # let client = hyper_util::client::legacy::Client::builder(
13683/// #     hyper_util::rt::TokioExecutor::new()
13684/// # )
13685/// # .build(
13686/// #     hyper_rustls::HttpsConnectorBuilder::new()
13687/// #         .with_native_roots()
13688/// #         .unwrap()
13689/// #         .https_or_http()
13690/// #         .enable_http2()
13691/// #         .build()
13692/// # );
13693/// # let mut hub = Baremetalsolution::new(client, auth);
13694/// // You can configure optional parameters by calling the respective setters at will, and
13695/// // execute the final call using `doit()`.
13696/// // Values shown here are possibly random and not representative !
13697/// let result = hub.projects().locations_provisioning_quotas_list("parent")
13698///              .page_token("erat")
13699///              .page_size(-93)
13700///              .doit().await;
13701/// # }
13702/// ```
13703pub struct ProjectLocationProvisioningQuotaListCall<'a, C>
13704where
13705    C: 'a,
13706{
13707    hub: &'a Baremetalsolution<C>,
13708    _parent: String,
13709    _page_token: Option<String>,
13710    _page_size: Option<i32>,
13711    _delegate: Option<&'a mut dyn common::Delegate>,
13712    _additional_params: HashMap<String, String>,
13713    _scopes: BTreeSet<String>,
13714}
13715
13716impl<'a, C> common::CallBuilder for ProjectLocationProvisioningQuotaListCall<'a, C> {}
13717
13718impl<'a, C> ProjectLocationProvisioningQuotaListCall<'a, C>
13719where
13720    C: common::Connector,
13721{
13722    /// Perform the operation you have build so far.
13723    pub async fn doit(
13724        mut self,
13725    ) -> common::Result<(common::Response, ListProvisioningQuotasResponse)> {
13726        use std::borrow::Cow;
13727        use std::io::{Read, Seek};
13728
13729        use common::{url::Params, ToParts};
13730        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13731
13732        let mut dd = common::DefaultDelegate;
13733        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13734        dlg.begin(common::MethodInfo {
13735            id: "baremetalsolution.projects.locations.provisioningQuotas.list",
13736            http_method: hyper::Method::GET,
13737        });
13738
13739        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
13740            if self._additional_params.contains_key(field) {
13741                dlg.finished(false);
13742                return Err(common::Error::FieldClash(field));
13743            }
13744        }
13745
13746        let mut params = Params::with_capacity(5 + self._additional_params.len());
13747        params.push("parent", self._parent);
13748        if let Some(value) = self._page_token.as_ref() {
13749            params.push("pageToken", value);
13750        }
13751        if let Some(value) = self._page_size.as_ref() {
13752            params.push("pageSize", value.to_string());
13753        }
13754
13755        params.extend(self._additional_params.iter());
13756
13757        params.push("alt", "json");
13758        let mut url = self.hub._base_url.clone() + "v2/{+parent}/provisioningQuotas";
13759        if self._scopes.is_empty() {
13760            self._scopes
13761                .insert(Scope::CloudPlatform.as_ref().to_string());
13762        }
13763
13764        #[allow(clippy::single_element_loop)]
13765        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13766            url = params.uri_replacement(url, param_name, find_this, true);
13767        }
13768        {
13769            let to_remove = ["parent"];
13770            params.remove_params(&to_remove);
13771        }
13772
13773        let url = params.parse_with_url(&url);
13774
13775        loop {
13776            let token = match self
13777                .hub
13778                .auth
13779                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13780                .await
13781            {
13782                Ok(token) => token,
13783                Err(e) => match dlg.token(e) {
13784                    Ok(token) => token,
13785                    Err(e) => {
13786                        dlg.finished(false);
13787                        return Err(common::Error::MissingToken(e));
13788                    }
13789                },
13790            };
13791            let mut req_result = {
13792                let client = &self.hub.client;
13793                dlg.pre_request();
13794                let mut req_builder = hyper::Request::builder()
13795                    .method(hyper::Method::GET)
13796                    .uri(url.as_str())
13797                    .header(USER_AGENT, self.hub._user_agent.clone());
13798
13799                if let Some(token) = token.as_ref() {
13800                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13801                }
13802
13803                let request = req_builder
13804                    .header(CONTENT_LENGTH, 0_u64)
13805                    .body(common::to_body::<String>(None));
13806
13807                client.request(request.unwrap()).await
13808            };
13809
13810            match req_result {
13811                Err(err) => {
13812                    if let common::Retry::After(d) = dlg.http_error(&err) {
13813                        sleep(d).await;
13814                        continue;
13815                    }
13816                    dlg.finished(false);
13817                    return Err(common::Error::HttpError(err));
13818                }
13819                Ok(res) => {
13820                    let (mut parts, body) = res.into_parts();
13821                    let mut body = common::Body::new(body);
13822                    if !parts.status.is_success() {
13823                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13824                        let error = serde_json::from_str(&common::to_string(&bytes));
13825                        let response = common::to_response(parts, bytes.into());
13826
13827                        if let common::Retry::After(d) =
13828                            dlg.http_failure(&response, error.as_ref().ok())
13829                        {
13830                            sleep(d).await;
13831                            continue;
13832                        }
13833
13834                        dlg.finished(false);
13835
13836                        return Err(match error {
13837                            Ok(value) => common::Error::BadRequest(value),
13838                            _ => common::Error::Failure(response),
13839                        });
13840                    }
13841                    let response = {
13842                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13843                        let encoded = common::to_string(&bytes);
13844                        match serde_json::from_str(&encoded) {
13845                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13846                            Err(error) => {
13847                                dlg.response_json_decode_error(&encoded, &error);
13848                                return Err(common::Error::JsonDecodeError(
13849                                    encoded.to_string(),
13850                                    error,
13851                                ));
13852                            }
13853                        }
13854                    };
13855
13856                    dlg.finished(true);
13857                    return Ok(response);
13858                }
13859            }
13860        }
13861    }
13862
13863    /// Required. Parent value for ListProvisioningQuotasRequest.
13864    ///
13865    /// Sets the *parent* path property to the given value.
13866    ///
13867    /// Even though the property as already been set when instantiating this call,
13868    /// we provide this method for API completeness.
13869    pub fn parent(mut self, new_value: &str) -> ProjectLocationProvisioningQuotaListCall<'a, C> {
13870        self._parent = new_value.to_string();
13871        self
13872    }
13873    /// A token identifying a page of results from the server.
13874    ///
13875    /// Sets the *page token* query property to the given value.
13876    pub fn page_token(
13877        mut self,
13878        new_value: &str,
13879    ) -> ProjectLocationProvisioningQuotaListCall<'a, C> {
13880        self._page_token = Some(new_value.to_string());
13881        self
13882    }
13883    /// Requested page size. The server might return fewer items than requested. If unspecified, server will pick an appropriate default. Notice that page_size field is not supported and won't be respected in the API request for now, will be updated when pagination is supported.
13884    ///
13885    /// Sets the *page size* query property to the given value.
13886    pub fn page_size(mut self, new_value: i32) -> ProjectLocationProvisioningQuotaListCall<'a, C> {
13887        self._page_size = Some(new_value);
13888        self
13889    }
13890    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13891    /// while executing the actual API request.
13892    ///
13893    /// ````text
13894    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13895    /// ````
13896    ///
13897    /// Sets the *delegate* property to the given value.
13898    pub fn delegate(
13899        mut self,
13900        new_value: &'a mut dyn common::Delegate,
13901    ) -> ProjectLocationProvisioningQuotaListCall<'a, C> {
13902        self._delegate = Some(new_value);
13903        self
13904    }
13905
13906    /// Set any additional parameter of the query string used in the request.
13907    /// It should be used to set parameters which are not yet available through their own
13908    /// setters.
13909    ///
13910    /// Please note that this method must not be used to set any of the known parameters
13911    /// which have their own setter method. If done anyway, the request will fail.
13912    ///
13913    /// # Additional Parameters
13914    ///
13915    /// * *$.xgafv* (query-string) - V1 error format.
13916    /// * *access_token* (query-string) - OAuth access token.
13917    /// * *alt* (query-string) - Data format for response.
13918    /// * *callback* (query-string) - JSONP
13919    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13920    /// * *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.
13921    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13922    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13923    /// * *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.
13924    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13925    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13926    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProvisioningQuotaListCall<'a, C>
13927    where
13928        T: AsRef<str>,
13929    {
13930        self._additional_params
13931            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13932        self
13933    }
13934
13935    /// Identifies the authorization scope for the method you are building.
13936    ///
13937    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13938    /// [`Scope::CloudPlatform`].
13939    ///
13940    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13941    /// tokens for more than one scope.
13942    ///
13943    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13944    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13945    /// sufficient, a read-write scope will do as well.
13946    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProvisioningQuotaListCall<'a, C>
13947    where
13948        St: AsRef<str>,
13949    {
13950        self._scopes.insert(String::from(scope.as_ref()));
13951        self
13952    }
13953    /// Identifies the authorization scope(s) for the method you are building.
13954    ///
13955    /// See [`Self::add_scope()`] for details.
13956    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProvisioningQuotaListCall<'a, C>
13957    where
13958        I: IntoIterator<Item = St>,
13959        St: AsRef<str>,
13960    {
13961        self._scopes
13962            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13963        self
13964    }
13965
13966    /// Removes all scopes, and no default scope will be used either.
13967    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13968    /// for details).
13969    pub fn clear_scopes(mut self) -> ProjectLocationProvisioningQuotaListCall<'a, C> {
13970        self._scopes.clear();
13971        self
13972    }
13973}
13974
13975/// Register a public SSH key in the specified project for use with the interactive serial console feature.
13976///
13977/// A builder for the *locations.sshKeys.create* method supported by a *project* resource.
13978/// It is not used directly, but through a [`ProjectMethods`] instance.
13979///
13980/// # Example
13981///
13982/// Instantiate a resource method builder
13983///
13984/// ```test_harness,no_run
13985/// # extern crate hyper;
13986/// # extern crate hyper_rustls;
13987/// # extern crate google_baremetalsolution2 as baremetalsolution2;
13988/// use baremetalsolution2::api::SSHKey;
13989/// # async fn dox() {
13990/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13991///
13992/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13993/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13994/// #     .with_native_roots()
13995/// #     .unwrap()
13996/// #     .https_only()
13997/// #     .enable_http2()
13998/// #     .build();
13999///
14000/// # let executor = hyper_util::rt::TokioExecutor::new();
14001/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14002/// #     secret,
14003/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14004/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14005/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14006/// #     ),
14007/// # ).build().await.unwrap();
14008///
14009/// # let client = hyper_util::client::legacy::Client::builder(
14010/// #     hyper_util::rt::TokioExecutor::new()
14011/// # )
14012/// # .build(
14013/// #     hyper_rustls::HttpsConnectorBuilder::new()
14014/// #         .with_native_roots()
14015/// #         .unwrap()
14016/// #         .https_or_http()
14017/// #         .enable_http2()
14018/// #         .build()
14019/// # );
14020/// # let mut hub = Baremetalsolution::new(client, auth);
14021/// // As the method needs a request, you would usually fill it with the desired information
14022/// // into the respective structure. Some of the parts shown here might not be applicable !
14023/// // Values shown here are possibly random and not representative !
14024/// let mut req = SSHKey::default();
14025///
14026/// // You can configure optional parameters by calling the respective setters at will, and
14027/// // execute the final call using `doit()`.
14028/// // Values shown here are possibly random and not representative !
14029/// let result = hub.projects().locations_ssh_keys_create(req, "parent")
14030///              .ssh_key_id("dolore")
14031///              .doit().await;
14032/// # }
14033/// ```
14034pub struct ProjectLocationSshKeyCreateCall<'a, C>
14035where
14036    C: 'a,
14037{
14038    hub: &'a Baremetalsolution<C>,
14039    _request: SSHKey,
14040    _parent: String,
14041    _ssh_key_id: Option<String>,
14042    _delegate: Option<&'a mut dyn common::Delegate>,
14043    _additional_params: HashMap<String, String>,
14044    _scopes: BTreeSet<String>,
14045}
14046
14047impl<'a, C> common::CallBuilder for ProjectLocationSshKeyCreateCall<'a, C> {}
14048
14049impl<'a, C> ProjectLocationSshKeyCreateCall<'a, C>
14050where
14051    C: common::Connector,
14052{
14053    /// Perform the operation you have build so far.
14054    pub async fn doit(mut self) -> common::Result<(common::Response, SSHKey)> {
14055        use std::borrow::Cow;
14056        use std::io::{Read, Seek};
14057
14058        use common::{url::Params, ToParts};
14059        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14060
14061        let mut dd = common::DefaultDelegate;
14062        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14063        dlg.begin(common::MethodInfo {
14064            id: "baremetalsolution.projects.locations.sshKeys.create",
14065            http_method: hyper::Method::POST,
14066        });
14067
14068        for &field in ["alt", "parent", "sshKeyId"].iter() {
14069            if self._additional_params.contains_key(field) {
14070                dlg.finished(false);
14071                return Err(common::Error::FieldClash(field));
14072            }
14073        }
14074
14075        let mut params = Params::with_capacity(5 + self._additional_params.len());
14076        params.push("parent", self._parent);
14077        if let Some(value) = self._ssh_key_id.as_ref() {
14078            params.push("sshKeyId", value);
14079        }
14080
14081        params.extend(self._additional_params.iter());
14082
14083        params.push("alt", "json");
14084        let mut url = self.hub._base_url.clone() + "v2/{+parent}/sshKeys";
14085        if self._scopes.is_empty() {
14086            self._scopes
14087                .insert(Scope::CloudPlatform.as_ref().to_string());
14088        }
14089
14090        #[allow(clippy::single_element_loop)]
14091        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14092            url = params.uri_replacement(url, param_name, find_this, true);
14093        }
14094        {
14095            let to_remove = ["parent"];
14096            params.remove_params(&to_remove);
14097        }
14098
14099        let url = params.parse_with_url(&url);
14100
14101        let mut json_mime_type = mime::APPLICATION_JSON;
14102        let mut request_value_reader = {
14103            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14104            common::remove_json_null_values(&mut value);
14105            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14106            serde_json::to_writer(&mut dst, &value).unwrap();
14107            dst
14108        };
14109        let request_size = request_value_reader
14110            .seek(std::io::SeekFrom::End(0))
14111            .unwrap();
14112        request_value_reader
14113            .seek(std::io::SeekFrom::Start(0))
14114            .unwrap();
14115
14116        loop {
14117            let token = match self
14118                .hub
14119                .auth
14120                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14121                .await
14122            {
14123                Ok(token) => token,
14124                Err(e) => match dlg.token(e) {
14125                    Ok(token) => token,
14126                    Err(e) => {
14127                        dlg.finished(false);
14128                        return Err(common::Error::MissingToken(e));
14129                    }
14130                },
14131            };
14132            request_value_reader
14133                .seek(std::io::SeekFrom::Start(0))
14134                .unwrap();
14135            let mut req_result = {
14136                let client = &self.hub.client;
14137                dlg.pre_request();
14138                let mut req_builder = hyper::Request::builder()
14139                    .method(hyper::Method::POST)
14140                    .uri(url.as_str())
14141                    .header(USER_AGENT, self.hub._user_agent.clone());
14142
14143                if let Some(token) = token.as_ref() {
14144                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14145                }
14146
14147                let request = req_builder
14148                    .header(CONTENT_TYPE, json_mime_type.to_string())
14149                    .header(CONTENT_LENGTH, request_size as u64)
14150                    .body(common::to_body(
14151                        request_value_reader.get_ref().clone().into(),
14152                    ));
14153
14154                client.request(request.unwrap()).await
14155            };
14156
14157            match req_result {
14158                Err(err) => {
14159                    if let common::Retry::After(d) = dlg.http_error(&err) {
14160                        sleep(d).await;
14161                        continue;
14162                    }
14163                    dlg.finished(false);
14164                    return Err(common::Error::HttpError(err));
14165                }
14166                Ok(res) => {
14167                    let (mut parts, body) = res.into_parts();
14168                    let mut body = common::Body::new(body);
14169                    if !parts.status.is_success() {
14170                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14171                        let error = serde_json::from_str(&common::to_string(&bytes));
14172                        let response = common::to_response(parts, bytes.into());
14173
14174                        if let common::Retry::After(d) =
14175                            dlg.http_failure(&response, error.as_ref().ok())
14176                        {
14177                            sleep(d).await;
14178                            continue;
14179                        }
14180
14181                        dlg.finished(false);
14182
14183                        return Err(match error {
14184                            Ok(value) => common::Error::BadRequest(value),
14185                            _ => common::Error::Failure(response),
14186                        });
14187                    }
14188                    let response = {
14189                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14190                        let encoded = common::to_string(&bytes);
14191                        match serde_json::from_str(&encoded) {
14192                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14193                            Err(error) => {
14194                                dlg.response_json_decode_error(&encoded, &error);
14195                                return Err(common::Error::JsonDecodeError(
14196                                    encoded.to_string(),
14197                                    error,
14198                                ));
14199                            }
14200                        }
14201                    };
14202
14203                    dlg.finished(true);
14204                    return Ok(response);
14205                }
14206            }
14207        }
14208    }
14209
14210    ///
14211    /// Sets the *request* property to the given value.
14212    ///
14213    /// Even though the property as already been set when instantiating this call,
14214    /// we provide this method for API completeness.
14215    pub fn request(mut self, new_value: SSHKey) -> ProjectLocationSshKeyCreateCall<'a, C> {
14216        self._request = new_value;
14217        self
14218    }
14219    /// Required. The parent containing the SSH keys.
14220    ///
14221    /// Sets the *parent* path property to the given value.
14222    ///
14223    /// Even though the property as already been set when instantiating this call,
14224    /// we provide this method for API completeness.
14225    pub fn parent(mut self, new_value: &str) -> ProjectLocationSshKeyCreateCall<'a, C> {
14226        self._parent = new_value.to_string();
14227        self
14228    }
14229    /// Required. The ID to use for the key, which will become the final component of the key's resource name. This value must match the regex: [a-zA-Z0-9@.\-_]{1,64}
14230    ///
14231    /// Sets the *ssh key id* query property to the given value.
14232    pub fn ssh_key_id(mut self, new_value: &str) -> ProjectLocationSshKeyCreateCall<'a, C> {
14233        self._ssh_key_id = Some(new_value.to_string());
14234        self
14235    }
14236    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14237    /// while executing the actual API request.
14238    ///
14239    /// ````text
14240    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14241    /// ````
14242    ///
14243    /// Sets the *delegate* property to the given value.
14244    pub fn delegate(
14245        mut self,
14246        new_value: &'a mut dyn common::Delegate,
14247    ) -> ProjectLocationSshKeyCreateCall<'a, C> {
14248        self._delegate = Some(new_value);
14249        self
14250    }
14251
14252    /// Set any additional parameter of the query string used in the request.
14253    /// It should be used to set parameters which are not yet available through their own
14254    /// setters.
14255    ///
14256    /// Please note that this method must not be used to set any of the known parameters
14257    /// which have their own setter method. If done anyway, the request will fail.
14258    ///
14259    /// # Additional Parameters
14260    ///
14261    /// * *$.xgafv* (query-string) - V1 error format.
14262    /// * *access_token* (query-string) - OAuth access token.
14263    /// * *alt* (query-string) - Data format for response.
14264    /// * *callback* (query-string) - JSONP
14265    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14266    /// * *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.
14267    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14268    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14269    /// * *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.
14270    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14271    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14272    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSshKeyCreateCall<'a, C>
14273    where
14274        T: AsRef<str>,
14275    {
14276        self._additional_params
14277            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14278        self
14279    }
14280
14281    /// Identifies the authorization scope for the method you are building.
14282    ///
14283    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14284    /// [`Scope::CloudPlatform`].
14285    ///
14286    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14287    /// tokens for more than one scope.
14288    ///
14289    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14290    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14291    /// sufficient, a read-write scope will do as well.
14292    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSshKeyCreateCall<'a, C>
14293    where
14294        St: AsRef<str>,
14295    {
14296        self._scopes.insert(String::from(scope.as_ref()));
14297        self
14298    }
14299    /// Identifies the authorization scope(s) for the method you are building.
14300    ///
14301    /// See [`Self::add_scope()`] for details.
14302    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSshKeyCreateCall<'a, C>
14303    where
14304        I: IntoIterator<Item = St>,
14305        St: AsRef<str>,
14306    {
14307        self._scopes
14308            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14309        self
14310    }
14311
14312    /// Removes all scopes, and no default scope will be used either.
14313    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14314    /// for details).
14315    pub fn clear_scopes(mut self) -> ProjectLocationSshKeyCreateCall<'a, C> {
14316        self._scopes.clear();
14317        self
14318    }
14319}
14320
14321/// Deletes a public SSH key registered in the specified project.
14322///
14323/// A builder for the *locations.sshKeys.delete* method supported by a *project* resource.
14324/// It is not used directly, but through a [`ProjectMethods`] instance.
14325///
14326/// # Example
14327///
14328/// Instantiate a resource method builder
14329///
14330/// ```test_harness,no_run
14331/// # extern crate hyper;
14332/// # extern crate hyper_rustls;
14333/// # extern crate google_baremetalsolution2 as baremetalsolution2;
14334/// # async fn dox() {
14335/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14336///
14337/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14338/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14339/// #     .with_native_roots()
14340/// #     .unwrap()
14341/// #     .https_only()
14342/// #     .enable_http2()
14343/// #     .build();
14344///
14345/// # let executor = hyper_util::rt::TokioExecutor::new();
14346/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14347/// #     secret,
14348/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14349/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14350/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14351/// #     ),
14352/// # ).build().await.unwrap();
14353///
14354/// # let client = hyper_util::client::legacy::Client::builder(
14355/// #     hyper_util::rt::TokioExecutor::new()
14356/// # )
14357/// # .build(
14358/// #     hyper_rustls::HttpsConnectorBuilder::new()
14359/// #         .with_native_roots()
14360/// #         .unwrap()
14361/// #         .https_or_http()
14362/// #         .enable_http2()
14363/// #         .build()
14364/// # );
14365/// # let mut hub = Baremetalsolution::new(client, auth);
14366/// // You can configure optional parameters by calling the respective setters at will, and
14367/// // execute the final call using `doit()`.
14368/// // Values shown here are possibly random and not representative !
14369/// let result = hub.projects().locations_ssh_keys_delete("name")
14370///              .doit().await;
14371/// # }
14372/// ```
14373pub struct ProjectLocationSshKeyDeleteCall<'a, C>
14374where
14375    C: 'a,
14376{
14377    hub: &'a Baremetalsolution<C>,
14378    _name: String,
14379    _delegate: Option<&'a mut dyn common::Delegate>,
14380    _additional_params: HashMap<String, String>,
14381    _scopes: BTreeSet<String>,
14382}
14383
14384impl<'a, C> common::CallBuilder for ProjectLocationSshKeyDeleteCall<'a, C> {}
14385
14386impl<'a, C> ProjectLocationSshKeyDeleteCall<'a, C>
14387where
14388    C: common::Connector,
14389{
14390    /// Perform the operation you have build so far.
14391    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
14392        use std::borrow::Cow;
14393        use std::io::{Read, Seek};
14394
14395        use common::{url::Params, ToParts};
14396        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14397
14398        let mut dd = common::DefaultDelegate;
14399        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14400        dlg.begin(common::MethodInfo {
14401            id: "baremetalsolution.projects.locations.sshKeys.delete",
14402            http_method: hyper::Method::DELETE,
14403        });
14404
14405        for &field in ["alt", "name"].iter() {
14406            if self._additional_params.contains_key(field) {
14407                dlg.finished(false);
14408                return Err(common::Error::FieldClash(field));
14409            }
14410        }
14411
14412        let mut params = Params::with_capacity(3 + self._additional_params.len());
14413        params.push("name", self._name);
14414
14415        params.extend(self._additional_params.iter());
14416
14417        params.push("alt", "json");
14418        let mut url = self.hub._base_url.clone() + "v2/{+name}";
14419        if self._scopes.is_empty() {
14420            self._scopes
14421                .insert(Scope::CloudPlatform.as_ref().to_string());
14422        }
14423
14424        #[allow(clippy::single_element_loop)]
14425        for &(find_this, param_name) in [("{+name}", "name")].iter() {
14426            url = params.uri_replacement(url, param_name, find_this, true);
14427        }
14428        {
14429            let to_remove = ["name"];
14430            params.remove_params(&to_remove);
14431        }
14432
14433        let url = params.parse_with_url(&url);
14434
14435        loop {
14436            let token = match self
14437                .hub
14438                .auth
14439                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14440                .await
14441            {
14442                Ok(token) => token,
14443                Err(e) => match dlg.token(e) {
14444                    Ok(token) => token,
14445                    Err(e) => {
14446                        dlg.finished(false);
14447                        return Err(common::Error::MissingToken(e));
14448                    }
14449                },
14450            };
14451            let mut req_result = {
14452                let client = &self.hub.client;
14453                dlg.pre_request();
14454                let mut req_builder = hyper::Request::builder()
14455                    .method(hyper::Method::DELETE)
14456                    .uri(url.as_str())
14457                    .header(USER_AGENT, self.hub._user_agent.clone());
14458
14459                if let Some(token) = token.as_ref() {
14460                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14461                }
14462
14463                let request = req_builder
14464                    .header(CONTENT_LENGTH, 0_u64)
14465                    .body(common::to_body::<String>(None));
14466
14467                client.request(request.unwrap()).await
14468            };
14469
14470            match req_result {
14471                Err(err) => {
14472                    if let common::Retry::After(d) = dlg.http_error(&err) {
14473                        sleep(d).await;
14474                        continue;
14475                    }
14476                    dlg.finished(false);
14477                    return Err(common::Error::HttpError(err));
14478                }
14479                Ok(res) => {
14480                    let (mut parts, body) = res.into_parts();
14481                    let mut body = common::Body::new(body);
14482                    if !parts.status.is_success() {
14483                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14484                        let error = serde_json::from_str(&common::to_string(&bytes));
14485                        let response = common::to_response(parts, bytes.into());
14486
14487                        if let common::Retry::After(d) =
14488                            dlg.http_failure(&response, error.as_ref().ok())
14489                        {
14490                            sleep(d).await;
14491                            continue;
14492                        }
14493
14494                        dlg.finished(false);
14495
14496                        return Err(match error {
14497                            Ok(value) => common::Error::BadRequest(value),
14498                            _ => common::Error::Failure(response),
14499                        });
14500                    }
14501                    let response = {
14502                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14503                        let encoded = common::to_string(&bytes);
14504                        match serde_json::from_str(&encoded) {
14505                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14506                            Err(error) => {
14507                                dlg.response_json_decode_error(&encoded, &error);
14508                                return Err(common::Error::JsonDecodeError(
14509                                    encoded.to_string(),
14510                                    error,
14511                                ));
14512                            }
14513                        }
14514                    };
14515
14516                    dlg.finished(true);
14517                    return Ok(response);
14518                }
14519            }
14520        }
14521    }
14522
14523    /// Required. The name of the SSH key to delete. Currently, the only valid value for the location is "global".
14524    ///
14525    /// Sets the *name* path property to the given value.
14526    ///
14527    /// Even though the property as already been set when instantiating this call,
14528    /// we provide this method for API completeness.
14529    pub fn name(mut self, new_value: &str) -> ProjectLocationSshKeyDeleteCall<'a, C> {
14530        self._name = new_value.to_string();
14531        self
14532    }
14533    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14534    /// while executing the actual API request.
14535    ///
14536    /// ````text
14537    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14538    /// ````
14539    ///
14540    /// Sets the *delegate* property to the given value.
14541    pub fn delegate(
14542        mut self,
14543        new_value: &'a mut dyn common::Delegate,
14544    ) -> ProjectLocationSshKeyDeleteCall<'a, C> {
14545        self._delegate = Some(new_value);
14546        self
14547    }
14548
14549    /// Set any additional parameter of the query string used in the request.
14550    /// It should be used to set parameters which are not yet available through their own
14551    /// setters.
14552    ///
14553    /// Please note that this method must not be used to set any of the known parameters
14554    /// which have their own setter method. If done anyway, the request will fail.
14555    ///
14556    /// # Additional Parameters
14557    ///
14558    /// * *$.xgafv* (query-string) - V1 error format.
14559    /// * *access_token* (query-string) - OAuth access token.
14560    /// * *alt* (query-string) - Data format for response.
14561    /// * *callback* (query-string) - JSONP
14562    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14563    /// * *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.
14564    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14565    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14566    /// * *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.
14567    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14568    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14569    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSshKeyDeleteCall<'a, C>
14570    where
14571        T: AsRef<str>,
14572    {
14573        self._additional_params
14574            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14575        self
14576    }
14577
14578    /// Identifies the authorization scope for the method you are building.
14579    ///
14580    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14581    /// [`Scope::CloudPlatform`].
14582    ///
14583    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14584    /// tokens for more than one scope.
14585    ///
14586    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14587    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14588    /// sufficient, a read-write scope will do as well.
14589    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSshKeyDeleteCall<'a, C>
14590    where
14591        St: AsRef<str>,
14592    {
14593        self._scopes.insert(String::from(scope.as_ref()));
14594        self
14595    }
14596    /// Identifies the authorization scope(s) for the method you are building.
14597    ///
14598    /// See [`Self::add_scope()`] for details.
14599    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSshKeyDeleteCall<'a, C>
14600    where
14601        I: IntoIterator<Item = St>,
14602        St: AsRef<str>,
14603    {
14604        self._scopes
14605            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14606        self
14607    }
14608
14609    /// Removes all scopes, and no default scope will be used either.
14610    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14611    /// for details).
14612    pub fn clear_scopes(mut self) -> ProjectLocationSshKeyDeleteCall<'a, C> {
14613        self._scopes.clear();
14614        self
14615    }
14616}
14617
14618/// Lists the public SSH keys registered for the specified project. These SSH keys are used only for the interactive serial console feature.
14619///
14620/// A builder for the *locations.sshKeys.list* method supported by a *project* resource.
14621/// It is not used directly, but through a [`ProjectMethods`] instance.
14622///
14623/// # Example
14624///
14625/// Instantiate a resource method builder
14626///
14627/// ```test_harness,no_run
14628/// # extern crate hyper;
14629/// # extern crate hyper_rustls;
14630/// # extern crate google_baremetalsolution2 as baremetalsolution2;
14631/// # async fn dox() {
14632/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14633///
14634/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14635/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14636/// #     .with_native_roots()
14637/// #     .unwrap()
14638/// #     .https_only()
14639/// #     .enable_http2()
14640/// #     .build();
14641///
14642/// # let executor = hyper_util::rt::TokioExecutor::new();
14643/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14644/// #     secret,
14645/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14646/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14647/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14648/// #     ),
14649/// # ).build().await.unwrap();
14650///
14651/// # let client = hyper_util::client::legacy::Client::builder(
14652/// #     hyper_util::rt::TokioExecutor::new()
14653/// # )
14654/// # .build(
14655/// #     hyper_rustls::HttpsConnectorBuilder::new()
14656/// #         .with_native_roots()
14657/// #         .unwrap()
14658/// #         .https_or_http()
14659/// #         .enable_http2()
14660/// #         .build()
14661/// # );
14662/// # let mut hub = Baremetalsolution::new(client, auth);
14663/// // You can configure optional parameters by calling the respective setters at will, and
14664/// // execute the final call using `doit()`.
14665/// // Values shown here are possibly random and not representative !
14666/// let result = hub.projects().locations_ssh_keys_list("parent")
14667///              .page_token("amet.")
14668///              .page_size(-96)
14669///              .doit().await;
14670/// # }
14671/// ```
14672pub struct ProjectLocationSshKeyListCall<'a, C>
14673where
14674    C: 'a,
14675{
14676    hub: &'a Baremetalsolution<C>,
14677    _parent: String,
14678    _page_token: Option<String>,
14679    _page_size: Option<i32>,
14680    _delegate: Option<&'a mut dyn common::Delegate>,
14681    _additional_params: HashMap<String, String>,
14682    _scopes: BTreeSet<String>,
14683}
14684
14685impl<'a, C> common::CallBuilder for ProjectLocationSshKeyListCall<'a, C> {}
14686
14687impl<'a, C> ProjectLocationSshKeyListCall<'a, C>
14688where
14689    C: common::Connector,
14690{
14691    /// Perform the operation you have build so far.
14692    pub async fn doit(mut self) -> common::Result<(common::Response, ListSSHKeysResponse)> {
14693        use std::borrow::Cow;
14694        use std::io::{Read, Seek};
14695
14696        use common::{url::Params, ToParts};
14697        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14698
14699        let mut dd = common::DefaultDelegate;
14700        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14701        dlg.begin(common::MethodInfo {
14702            id: "baremetalsolution.projects.locations.sshKeys.list",
14703            http_method: hyper::Method::GET,
14704        });
14705
14706        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
14707            if self._additional_params.contains_key(field) {
14708                dlg.finished(false);
14709                return Err(common::Error::FieldClash(field));
14710            }
14711        }
14712
14713        let mut params = Params::with_capacity(5 + self._additional_params.len());
14714        params.push("parent", self._parent);
14715        if let Some(value) = self._page_token.as_ref() {
14716            params.push("pageToken", value);
14717        }
14718        if let Some(value) = self._page_size.as_ref() {
14719            params.push("pageSize", value.to_string());
14720        }
14721
14722        params.extend(self._additional_params.iter());
14723
14724        params.push("alt", "json");
14725        let mut url = self.hub._base_url.clone() + "v2/{+parent}/sshKeys";
14726        if self._scopes.is_empty() {
14727            self._scopes
14728                .insert(Scope::CloudPlatform.as_ref().to_string());
14729        }
14730
14731        #[allow(clippy::single_element_loop)]
14732        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14733            url = params.uri_replacement(url, param_name, find_this, true);
14734        }
14735        {
14736            let to_remove = ["parent"];
14737            params.remove_params(&to_remove);
14738        }
14739
14740        let url = params.parse_with_url(&url);
14741
14742        loop {
14743            let token = match self
14744                .hub
14745                .auth
14746                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14747                .await
14748            {
14749                Ok(token) => token,
14750                Err(e) => match dlg.token(e) {
14751                    Ok(token) => token,
14752                    Err(e) => {
14753                        dlg.finished(false);
14754                        return Err(common::Error::MissingToken(e));
14755                    }
14756                },
14757            };
14758            let mut req_result = {
14759                let client = &self.hub.client;
14760                dlg.pre_request();
14761                let mut req_builder = hyper::Request::builder()
14762                    .method(hyper::Method::GET)
14763                    .uri(url.as_str())
14764                    .header(USER_AGENT, self.hub._user_agent.clone());
14765
14766                if let Some(token) = token.as_ref() {
14767                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14768                }
14769
14770                let request = req_builder
14771                    .header(CONTENT_LENGTH, 0_u64)
14772                    .body(common::to_body::<String>(None));
14773
14774                client.request(request.unwrap()).await
14775            };
14776
14777            match req_result {
14778                Err(err) => {
14779                    if let common::Retry::After(d) = dlg.http_error(&err) {
14780                        sleep(d).await;
14781                        continue;
14782                    }
14783                    dlg.finished(false);
14784                    return Err(common::Error::HttpError(err));
14785                }
14786                Ok(res) => {
14787                    let (mut parts, body) = res.into_parts();
14788                    let mut body = common::Body::new(body);
14789                    if !parts.status.is_success() {
14790                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14791                        let error = serde_json::from_str(&common::to_string(&bytes));
14792                        let response = common::to_response(parts, bytes.into());
14793
14794                        if let common::Retry::After(d) =
14795                            dlg.http_failure(&response, error.as_ref().ok())
14796                        {
14797                            sleep(d).await;
14798                            continue;
14799                        }
14800
14801                        dlg.finished(false);
14802
14803                        return Err(match error {
14804                            Ok(value) => common::Error::BadRequest(value),
14805                            _ => common::Error::Failure(response),
14806                        });
14807                    }
14808                    let response = {
14809                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14810                        let encoded = common::to_string(&bytes);
14811                        match serde_json::from_str(&encoded) {
14812                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14813                            Err(error) => {
14814                                dlg.response_json_decode_error(&encoded, &error);
14815                                return Err(common::Error::JsonDecodeError(
14816                                    encoded.to_string(),
14817                                    error,
14818                                ));
14819                            }
14820                        }
14821                    };
14822
14823                    dlg.finished(true);
14824                    return Ok(response);
14825                }
14826            }
14827        }
14828    }
14829
14830    /// Required. The parent containing the SSH keys. Currently, the only valid value for the location is "global".
14831    ///
14832    /// Sets the *parent* path property to the given value.
14833    ///
14834    /// Even though the property as already been set when instantiating this call,
14835    /// we provide this method for API completeness.
14836    pub fn parent(mut self, new_value: &str) -> ProjectLocationSshKeyListCall<'a, C> {
14837        self._parent = new_value.to_string();
14838        self
14839    }
14840    /// The next_page_token value returned from a previous List request, if any.
14841    ///
14842    /// Sets the *page token* query property to the given value.
14843    pub fn page_token(mut self, new_value: &str) -> ProjectLocationSshKeyListCall<'a, C> {
14844        self._page_token = Some(new_value.to_string());
14845        self
14846    }
14847    /// The maximum number of items to return.
14848    ///
14849    /// Sets the *page size* query property to the given value.
14850    pub fn page_size(mut self, new_value: i32) -> ProjectLocationSshKeyListCall<'a, C> {
14851        self._page_size = Some(new_value);
14852        self
14853    }
14854    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14855    /// while executing the actual API request.
14856    ///
14857    /// ````text
14858    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14859    /// ````
14860    ///
14861    /// Sets the *delegate* property to the given value.
14862    pub fn delegate(
14863        mut self,
14864        new_value: &'a mut dyn common::Delegate,
14865    ) -> ProjectLocationSshKeyListCall<'a, C> {
14866        self._delegate = Some(new_value);
14867        self
14868    }
14869
14870    /// Set any additional parameter of the query string used in the request.
14871    /// It should be used to set parameters which are not yet available through their own
14872    /// setters.
14873    ///
14874    /// Please note that this method must not be used to set any of the known parameters
14875    /// which have their own setter method. If done anyway, the request will fail.
14876    ///
14877    /// # Additional Parameters
14878    ///
14879    /// * *$.xgafv* (query-string) - V1 error format.
14880    /// * *access_token* (query-string) - OAuth access token.
14881    /// * *alt* (query-string) - Data format for response.
14882    /// * *callback* (query-string) - JSONP
14883    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14884    /// * *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.
14885    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14886    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14887    /// * *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.
14888    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14889    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14890    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSshKeyListCall<'a, C>
14891    where
14892        T: AsRef<str>,
14893    {
14894        self._additional_params
14895            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14896        self
14897    }
14898
14899    /// Identifies the authorization scope for the method you are building.
14900    ///
14901    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14902    /// [`Scope::CloudPlatform`].
14903    ///
14904    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14905    /// tokens for more than one scope.
14906    ///
14907    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14908    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14909    /// sufficient, a read-write scope will do as well.
14910    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSshKeyListCall<'a, C>
14911    where
14912        St: AsRef<str>,
14913    {
14914        self._scopes.insert(String::from(scope.as_ref()));
14915        self
14916    }
14917    /// Identifies the authorization scope(s) for the method you are building.
14918    ///
14919    /// See [`Self::add_scope()`] for details.
14920    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSshKeyListCall<'a, C>
14921    where
14922        I: IntoIterator<Item = St>,
14923        St: AsRef<str>,
14924    {
14925        self._scopes
14926            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14927        self
14928    }
14929
14930    /// Removes all scopes, and no default scope will be used either.
14931    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14932    /// for details).
14933    pub fn clear_scopes(mut self) -> ProjectLocationSshKeyListCall<'a, C> {
14934        self._scopes.clear();
14935        self
14936    }
14937}
14938
14939/// Skips lun's cooloff and deletes it now. Lun must be in cooloff state.
14940///
14941/// A builder for the *locations.volumes.luns.evict* method supported by a *project* resource.
14942/// It is not used directly, but through a [`ProjectMethods`] instance.
14943///
14944/// # Example
14945///
14946/// Instantiate a resource method builder
14947///
14948/// ```test_harness,no_run
14949/// # extern crate hyper;
14950/// # extern crate hyper_rustls;
14951/// # extern crate google_baremetalsolution2 as baremetalsolution2;
14952/// use baremetalsolution2::api::EvictLunRequest;
14953/// # async fn dox() {
14954/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14955///
14956/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14957/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14958/// #     .with_native_roots()
14959/// #     .unwrap()
14960/// #     .https_only()
14961/// #     .enable_http2()
14962/// #     .build();
14963///
14964/// # let executor = hyper_util::rt::TokioExecutor::new();
14965/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14966/// #     secret,
14967/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14968/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14969/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14970/// #     ),
14971/// # ).build().await.unwrap();
14972///
14973/// # let client = hyper_util::client::legacy::Client::builder(
14974/// #     hyper_util::rt::TokioExecutor::new()
14975/// # )
14976/// # .build(
14977/// #     hyper_rustls::HttpsConnectorBuilder::new()
14978/// #         .with_native_roots()
14979/// #         .unwrap()
14980/// #         .https_or_http()
14981/// #         .enable_http2()
14982/// #         .build()
14983/// # );
14984/// # let mut hub = Baremetalsolution::new(client, auth);
14985/// // As the method needs a request, you would usually fill it with the desired information
14986/// // into the respective structure. Some of the parts shown here might not be applicable !
14987/// // Values shown here are possibly random and not representative !
14988/// let mut req = EvictLunRequest::default();
14989///
14990/// // You can configure optional parameters by calling the respective setters at will, and
14991/// // execute the final call using `doit()`.
14992/// // Values shown here are possibly random and not representative !
14993/// let result = hub.projects().locations_volumes_luns_evict(req, "name")
14994///              .doit().await;
14995/// # }
14996/// ```
14997pub struct ProjectLocationVolumeLunEvictCall<'a, C>
14998where
14999    C: 'a,
15000{
15001    hub: &'a Baremetalsolution<C>,
15002    _request: EvictLunRequest,
15003    _name: String,
15004    _delegate: Option<&'a mut dyn common::Delegate>,
15005    _additional_params: HashMap<String, String>,
15006    _scopes: BTreeSet<String>,
15007}
15008
15009impl<'a, C> common::CallBuilder for ProjectLocationVolumeLunEvictCall<'a, C> {}
15010
15011impl<'a, C> ProjectLocationVolumeLunEvictCall<'a, C>
15012where
15013    C: common::Connector,
15014{
15015    /// Perform the operation you have build so far.
15016    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15017        use std::borrow::Cow;
15018        use std::io::{Read, Seek};
15019
15020        use common::{url::Params, ToParts};
15021        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15022
15023        let mut dd = common::DefaultDelegate;
15024        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15025        dlg.begin(common::MethodInfo {
15026            id: "baremetalsolution.projects.locations.volumes.luns.evict",
15027            http_method: hyper::Method::POST,
15028        });
15029
15030        for &field in ["alt", "name"].iter() {
15031            if self._additional_params.contains_key(field) {
15032                dlg.finished(false);
15033                return Err(common::Error::FieldClash(field));
15034            }
15035        }
15036
15037        let mut params = Params::with_capacity(4 + self._additional_params.len());
15038        params.push("name", self._name);
15039
15040        params.extend(self._additional_params.iter());
15041
15042        params.push("alt", "json");
15043        let mut url = self.hub._base_url.clone() + "v2/{+name}:evict";
15044        if self._scopes.is_empty() {
15045            self._scopes
15046                .insert(Scope::CloudPlatform.as_ref().to_string());
15047        }
15048
15049        #[allow(clippy::single_element_loop)]
15050        for &(find_this, param_name) in [("{+name}", "name")].iter() {
15051            url = params.uri_replacement(url, param_name, find_this, true);
15052        }
15053        {
15054            let to_remove = ["name"];
15055            params.remove_params(&to_remove);
15056        }
15057
15058        let url = params.parse_with_url(&url);
15059
15060        let mut json_mime_type = mime::APPLICATION_JSON;
15061        let mut request_value_reader = {
15062            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15063            common::remove_json_null_values(&mut value);
15064            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15065            serde_json::to_writer(&mut dst, &value).unwrap();
15066            dst
15067        };
15068        let request_size = request_value_reader
15069            .seek(std::io::SeekFrom::End(0))
15070            .unwrap();
15071        request_value_reader
15072            .seek(std::io::SeekFrom::Start(0))
15073            .unwrap();
15074
15075        loop {
15076            let token = match self
15077                .hub
15078                .auth
15079                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15080                .await
15081            {
15082                Ok(token) => token,
15083                Err(e) => match dlg.token(e) {
15084                    Ok(token) => token,
15085                    Err(e) => {
15086                        dlg.finished(false);
15087                        return Err(common::Error::MissingToken(e));
15088                    }
15089                },
15090            };
15091            request_value_reader
15092                .seek(std::io::SeekFrom::Start(0))
15093                .unwrap();
15094            let mut req_result = {
15095                let client = &self.hub.client;
15096                dlg.pre_request();
15097                let mut req_builder = hyper::Request::builder()
15098                    .method(hyper::Method::POST)
15099                    .uri(url.as_str())
15100                    .header(USER_AGENT, self.hub._user_agent.clone());
15101
15102                if let Some(token) = token.as_ref() {
15103                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15104                }
15105
15106                let request = req_builder
15107                    .header(CONTENT_TYPE, json_mime_type.to_string())
15108                    .header(CONTENT_LENGTH, request_size as u64)
15109                    .body(common::to_body(
15110                        request_value_reader.get_ref().clone().into(),
15111                    ));
15112
15113                client.request(request.unwrap()).await
15114            };
15115
15116            match req_result {
15117                Err(err) => {
15118                    if let common::Retry::After(d) = dlg.http_error(&err) {
15119                        sleep(d).await;
15120                        continue;
15121                    }
15122                    dlg.finished(false);
15123                    return Err(common::Error::HttpError(err));
15124                }
15125                Ok(res) => {
15126                    let (mut parts, body) = res.into_parts();
15127                    let mut body = common::Body::new(body);
15128                    if !parts.status.is_success() {
15129                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15130                        let error = serde_json::from_str(&common::to_string(&bytes));
15131                        let response = common::to_response(parts, bytes.into());
15132
15133                        if let common::Retry::After(d) =
15134                            dlg.http_failure(&response, error.as_ref().ok())
15135                        {
15136                            sleep(d).await;
15137                            continue;
15138                        }
15139
15140                        dlg.finished(false);
15141
15142                        return Err(match error {
15143                            Ok(value) => common::Error::BadRequest(value),
15144                            _ => common::Error::Failure(response),
15145                        });
15146                    }
15147                    let response = {
15148                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15149                        let encoded = common::to_string(&bytes);
15150                        match serde_json::from_str(&encoded) {
15151                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15152                            Err(error) => {
15153                                dlg.response_json_decode_error(&encoded, &error);
15154                                return Err(common::Error::JsonDecodeError(
15155                                    encoded.to_string(),
15156                                    error,
15157                                ));
15158                            }
15159                        }
15160                    };
15161
15162                    dlg.finished(true);
15163                    return Ok(response);
15164                }
15165            }
15166        }
15167    }
15168
15169    ///
15170    /// Sets the *request* property to the given value.
15171    ///
15172    /// Even though the property as already been set when instantiating this call,
15173    /// we provide this method for API completeness.
15174    pub fn request(
15175        mut self,
15176        new_value: EvictLunRequest,
15177    ) -> ProjectLocationVolumeLunEvictCall<'a, C> {
15178        self._request = new_value;
15179        self
15180    }
15181    /// Required. The name of the lun.
15182    ///
15183    /// Sets the *name* path property to the given value.
15184    ///
15185    /// Even though the property as already been set when instantiating this call,
15186    /// we provide this method for API completeness.
15187    pub fn name(mut self, new_value: &str) -> ProjectLocationVolumeLunEvictCall<'a, C> {
15188        self._name = new_value.to_string();
15189        self
15190    }
15191    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15192    /// while executing the actual API request.
15193    ///
15194    /// ````text
15195    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15196    /// ````
15197    ///
15198    /// Sets the *delegate* property to the given value.
15199    pub fn delegate(
15200        mut self,
15201        new_value: &'a mut dyn common::Delegate,
15202    ) -> ProjectLocationVolumeLunEvictCall<'a, C> {
15203        self._delegate = Some(new_value);
15204        self
15205    }
15206
15207    /// Set any additional parameter of the query string used in the request.
15208    /// It should be used to set parameters which are not yet available through their own
15209    /// setters.
15210    ///
15211    /// Please note that this method must not be used to set any of the known parameters
15212    /// which have their own setter method. If done anyway, the request will fail.
15213    ///
15214    /// # Additional Parameters
15215    ///
15216    /// * *$.xgafv* (query-string) - V1 error format.
15217    /// * *access_token* (query-string) - OAuth access token.
15218    /// * *alt* (query-string) - Data format for response.
15219    /// * *callback* (query-string) - JSONP
15220    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15221    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15222    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15223    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15224    /// * *quotaUser* (query-string) - 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.
15225    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15226    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15227    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeLunEvictCall<'a, C>
15228    where
15229        T: AsRef<str>,
15230    {
15231        self._additional_params
15232            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15233        self
15234    }
15235
15236    /// Identifies the authorization scope for the method you are building.
15237    ///
15238    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15239    /// [`Scope::CloudPlatform`].
15240    ///
15241    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15242    /// tokens for more than one scope.
15243    ///
15244    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15245    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15246    /// sufficient, a read-write scope will do as well.
15247    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeLunEvictCall<'a, C>
15248    where
15249        St: AsRef<str>,
15250    {
15251        self._scopes.insert(String::from(scope.as_ref()));
15252        self
15253    }
15254    /// Identifies the authorization scope(s) for the method you are building.
15255    ///
15256    /// See [`Self::add_scope()`] for details.
15257    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeLunEvictCall<'a, C>
15258    where
15259        I: IntoIterator<Item = St>,
15260        St: AsRef<str>,
15261    {
15262        self._scopes
15263            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15264        self
15265    }
15266
15267    /// Removes all scopes, and no default scope will be used either.
15268    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15269    /// for details).
15270    pub fn clear_scopes(mut self) -> ProjectLocationVolumeLunEvictCall<'a, C> {
15271        self._scopes.clear();
15272        self
15273    }
15274}
15275
15276/// Get details of a single storage logical unit number(LUN).
15277///
15278/// A builder for the *locations.volumes.luns.get* method supported by a *project* resource.
15279/// It is not used directly, but through a [`ProjectMethods`] instance.
15280///
15281/// # Example
15282///
15283/// Instantiate a resource method builder
15284///
15285/// ```test_harness,no_run
15286/// # extern crate hyper;
15287/// # extern crate hyper_rustls;
15288/// # extern crate google_baremetalsolution2 as baremetalsolution2;
15289/// # async fn dox() {
15290/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15291///
15292/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15293/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15294/// #     .with_native_roots()
15295/// #     .unwrap()
15296/// #     .https_only()
15297/// #     .enable_http2()
15298/// #     .build();
15299///
15300/// # let executor = hyper_util::rt::TokioExecutor::new();
15301/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15302/// #     secret,
15303/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15304/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15305/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15306/// #     ),
15307/// # ).build().await.unwrap();
15308///
15309/// # let client = hyper_util::client::legacy::Client::builder(
15310/// #     hyper_util::rt::TokioExecutor::new()
15311/// # )
15312/// # .build(
15313/// #     hyper_rustls::HttpsConnectorBuilder::new()
15314/// #         .with_native_roots()
15315/// #         .unwrap()
15316/// #         .https_or_http()
15317/// #         .enable_http2()
15318/// #         .build()
15319/// # );
15320/// # let mut hub = Baremetalsolution::new(client, auth);
15321/// // You can configure optional parameters by calling the respective setters at will, and
15322/// // execute the final call using `doit()`.
15323/// // Values shown here are possibly random and not representative !
15324/// let result = hub.projects().locations_volumes_luns_get("name")
15325///              .doit().await;
15326/// # }
15327/// ```
15328pub struct ProjectLocationVolumeLunGetCall<'a, C>
15329where
15330    C: 'a,
15331{
15332    hub: &'a Baremetalsolution<C>,
15333    _name: String,
15334    _delegate: Option<&'a mut dyn common::Delegate>,
15335    _additional_params: HashMap<String, String>,
15336    _scopes: BTreeSet<String>,
15337}
15338
15339impl<'a, C> common::CallBuilder for ProjectLocationVolumeLunGetCall<'a, C> {}
15340
15341impl<'a, C> ProjectLocationVolumeLunGetCall<'a, C>
15342where
15343    C: common::Connector,
15344{
15345    /// Perform the operation you have build so far.
15346    pub async fn doit(mut self) -> common::Result<(common::Response, Lun)> {
15347        use std::borrow::Cow;
15348        use std::io::{Read, Seek};
15349
15350        use common::{url::Params, ToParts};
15351        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15352
15353        let mut dd = common::DefaultDelegate;
15354        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15355        dlg.begin(common::MethodInfo {
15356            id: "baremetalsolution.projects.locations.volumes.luns.get",
15357            http_method: hyper::Method::GET,
15358        });
15359
15360        for &field in ["alt", "name"].iter() {
15361            if self._additional_params.contains_key(field) {
15362                dlg.finished(false);
15363                return Err(common::Error::FieldClash(field));
15364            }
15365        }
15366
15367        let mut params = Params::with_capacity(3 + self._additional_params.len());
15368        params.push("name", self._name);
15369
15370        params.extend(self._additional_params.iter());
15371
15372        params.push("alt", "json");
15373        let mut url = self.hub._base_url.clone() + "v2/{+name}";
15374        if self._scopes.is_empty() {
15375            self._scopes
15376                .insert(Scope::CloudPlatform.as_ref().to_string());
15377        }
15378
15379        #[allow(clippy::single_element_loop)]
15380        for &(find_this, param_name) in [("{+name}", "name")].iter() {
15381            url = params.uri_replacement(url, param_name, find_this, true);
15382        }
15383        {
15384            let to_remove = ["name"];
15385            params.remove_params(&to_remove);
15386        }
15387
15388        let url = params.parse_with_url(&url);
15389
15390        loop {
15391            let token = match self
15392                .hub
15393                .auth
15394                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15395                .await
15396            {
15397                Ok(token) => token,
15398                Err(e) => match dlg.token(e) {
15399                    Ok(token) => token,
15400                    Err(e) => {
15401                        dlg.finished(false);
15402                        return Err(common::Error::MissingToken(e));
15403                    }
15404                },
15405            };
15406            let mut req_result = {
15407                let client = &self.hub.client;
15408                dlg.pre_request();
15409                let mut req_builder = hyper::Request::builder()
15410                    .method(hyper::Method::GET)
15411                    .uri(url.as_str())
15412                    .header(USER_AGENT, self.hub._user_agent.clone());
15413
15414                if let Some(token) = token.as_ref() {
15415                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15416                }
15417
15418                let request = req_builder
15419                    .header(CONTENT_LENGTH, 0_u64)
15420                    .body(common::to_body::<String>(None));
15421
15422                client.request(request.unwrap()).await
15423            };
15424
15425            match req_result {
15426                Err(err) => {
15427                    if let common::Retry::After(d) = dlg.http_error(&err) {
15428                        sleep(d).await;
15429                        continue;
15430                    }
15431                    dlg.finished(false);
15432                    return Err(common::Error::HttpError(err));
15433                }
15434                Ok(res) => {
15435                    let (mut parts, body) = res.into_parts();
15436                    let mut body = common::Body::new(body);
15437                    if !parts.status.is_success() {
15438                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15439                        let error = serde_json::from_str(&common::to_string(&bytes));
15440                        let response = common::to_response(parts, bytes.into());
15441
15442                        if let common::Retry::After(d) =
15443                            dlg.http_failure(&response, error.as_ref().ok())
15444                        {
15445                            sleep(d).await;
15446                            continue;
15447                        }
15448
15449                        dlg.finished(false);
15450
15451                        return Err(match error {
15452                            Ok(value) => common::Error::BadRequest(value),
15453                            _ => common::Error::Failure(response),
15454                        });
15455                    }
15456                    let response = {
15457                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15458                        let encoded = common::to_string(&bytes);
15459                        match serde_json::from_str(&encoded) {
15460                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15461                            Err(error) => {
15462                                dlg.response_json_decode_error(&encoded, &error);
15463                                return Err(common::Error::JsonDecodeError(
15464                                    encoded.to_string(),
15465                                    error,
15466                                ));
15467                            }
15468                        }
15469                    };
15470
15471                    dlg.finished(true);
15472                    return Ok(response);
15473                }
15474            }
15475        }
15476    }
15477
15478    /// Required. Name of the resource.
15479    ///
15480    /// Sets the *name* path property to the given value.
15481    ///
15482    /// Even though the property as already been set when instantiating this call,
15483    /// we provide this method for API completeness.
15484    pub fn name(mut self, new_value: &str) -> ProjectLocationVolumeLunGetCall<'a, C> {
15485        self._name = new_value.to_string();
15486        self
15487    }
15488    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15489    /// while executing the actual API request.
15490    ///
15491    /// ````text
15492    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15493    /// ````
15494    ///
15495    /// Sets the *delegate* property to the given value.
15496    pub fn delegate(
15497        mut self,
15498        new_value: &'a mut dyn common::Delegate,
15499    ) -> ProjectLocationVolumeLunGetCall<'a, C> {
15500        self._delegate = Some(new_value);
15501        self
15502    }
15503
15504    /// Set any additional parameter of the query string used in the request.
15505    /// It should be used to set parameters which are not yet available through their own
15506    /// setters.
15507    ///
15508    /// Please note that this method must not be used to set any of the known parameters
15509    /// which have their own setter method. If done anyway, the request will fail.
15510    ///
15511    /// # Additional Parameters
15512    ///
15513    /// * *$.xgafv* (query-string) - V1 error format.
15514    /// * *access_token* (query-string) - OAuth access token.
15515    /// * *alt* (query-string) - Data format for response.
15516    /// * *callback* (query-string) - JSONP
15517    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15518    /// * *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.
15519    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15520    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15521    /// * *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.
15522    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15523    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15524    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeLunGetCall<'a, C>
15525    where
15526        T: AsRef<str>,
15527    {
15528        self._additional_params
15529            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15530        self
15531    }
15532
15533    /// Identifies the authorization scope for the method you are building.
15534    ///
15535    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15536    /// [`Scope::CloudPlatform`].
15537    ///
15538    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15539    /// tokens for more than one scope.
15540    ///
15541    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15542    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15543    /// sufficient, a read-write scope will do as well.
15544    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeLunGetCall<'a, C>
15545    where
15546        St: AsRef<str>,
15547    {
15548        self._scopes.insert(String::from(scope.as_ref()));
15549        self
15550    }
15551    /// Identifies the authorization scope(s) for the method you are building.
15552    ///
15553    /// See [`Self::add_scope()`] for details.
15554    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeLunGetCall<'a, C>
15555    where
15556        I: IntoIterator<Item = St>,
15557        St: AsRef<str>,
15558    {
15559        self._scopes
15560            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15561        self
15562    }
15563
15564    /// Removes all scopes, and no default scope will be used either.
15565    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15566    /// for details).
15567    pub fn clear_scopes(mut self) -> ProjectLocationVolumeLunGetCall<'a, C> {
15568        self._scopes.clear();
15569        self
15570    }
15571}
15572
15573/// List storage volume luns for given storage volume.
15574///
15575/// A builder for the *locations.volumes.luns.list* method supported by a *project* resource.
15576/// It is not used directly, but through a [`ProjectMethods`] instance.
15577///
15578/// # Example
15579///
15580/// Instantiate a resource method builder
15581///
15582/// ```test_harness,no_run
15583/// # extern crate hyper;
15584/// # extern crate hyper_rustls;
15585/// # extern crate google_baremetalsolution2 as baremetalsolution2;
15586/// # async fn dox() {
15587/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15588///
15589/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15590/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15591/// #     .with_native_roots()
15592/// #     .unwrap()
15593/// #     .https_only()
15594/// #     .enable_http2()
15595/// #     .build();
15596///
15597/// # let executor = hyper_util::rt::TokioExecutor::new();
15598/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15599/// #     secret,
15600/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15601/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15602/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15603/// #     ),
15604/// # ).build().await.unwrap();
15605///
15606/// # let client = hyper_util::client::legacy::Client::builder(
15607/// #     hyper_util::rt::TokioExecutor::new()
15608/// # )
15609/// # .build(
15610/// #     hyper_rustls::HttpsConnectorBuilder::new()
15611/// #         .with_native_roots()
15612/// #         .unwrap()
15613/// #         .https_or_http()
15614/// #         .enable_http2()
15615/// #         .build()
15616/// # );
15617/// # let mut hub = Baremetalsolution::new(client, auth);
15618/// // You can configure optional parameters by calling the respective setters at will, and
15619/// // execute the final call using `doit()`.
15620/// // Values shown here are possibly random and not representative !
15621/// let result = hub.projects().locations_volumes_luns_list("parent")
15622///              .page_token("et")
15623///              .page_size(-95)
15624///              .doit().await;
15625/// # }
15626/// ```
15627pub struct ProjectLocationVolumeLunListCall<'a, C>
15628where
15629    C: 'a,
15630{
15631    hub: &'a Baremetalsolution<C>,
15632    _parent: String,
15633    _page_token: Option<String>,
15634    _page_size: Option<i32>,
15635    _delegate: Option<&'a mut dyn common::Delegate>,
15636    _additional_params: HashMap<String, String>,
15637    _scopes: BTreeSet<String>,
15638}
15639
15640impl<'a, C> common::CallBuilder for ProjectLocationVolumeLunListCall<'a, C> {}
15641
15642impl<'a, C> ProjectLocationVolumeLunListCall<'a, C>
15643where
15644    C: common::Connector,
15645{
15646    /// Perform the operation you have build so far.
15647    pub async fn doit(mut self) -> common::Result<(common::Response, ListLunsResponse)> {
15648        use std::borrow::Cow;
15649        use std::io::{Read, Seek};
15650
15651        use common::{url::Params, ToParts};
15652        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15653
15654        let mut dd = common::DefaultDelegate;
15655        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15656        dlg.begin(common::MethodInfo {
15657            id: "baremetalsolution.projects.locations.volumes.luns.list",
15658            http_method: hyper::Method::GET,
15659        });
15660
15661        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
15662            if self._additional_params.contains_key(field) {
15663                dlg.finished(false);
15664                return Err(common::Error::FieldClash(field));
15665            }
15666        }
15667
15668        let mut params = Params::with_capacity(5 + self._additional_params.len());
15669        params.push("parent", self._parent);
15670        if let Some(value) = self._page_token.as_ref() {
15671            params.push("pageToken", value);
15672        }
15673        if let Some(value) = self._page_size.as_ref() {
15674            params.push("pageSize", value.to_string());
15675        }
15676
15677        params.extend(self._additional_params.iter());
15678
15679        params.push("alt", "json");
15680        let mut url = self.hub._base_url.clone() + "v2/{+parent}/luns";
15681        if self._scopes.is_empty() {
15682            self._scopes
15683                .insert(Scope::CloudPlatform.as_ref().to_string());
15684        }
15685
15686        #[allow(clippy::single_element_loop)]
15687        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
15688            url = params.uri_replacement(url, param_name, find_this, true);
15689        }
15690        {
15691            let to_remove = ["parent"];
15692            params.remove_params(&to_remove);
15693        }
15694
15695        let url = params.parse_with_url(&url);
15696
15697        loop {
15698            let token = match self
15699                .hub
15700                .auth
15701                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15702                .await
15703            {
15704                Ok(token) => token,
15705                Err(e) => match dlg.token(e) {
15706                    Ok(token) => token,
15707                    Err(e) => {
15708                        dlg.finished(false);
15709                        return Err(common::Error::MissingToken(e));
15710                    }
15711                },
15712            };
15713            let mut req_result = {
15714                let client = &self.hub.client;
15715                dlg.pre_request();
15716                let mut req_builder = hyper::Request::builder()
15717                    .method(hyper::Method::GET)
15718                    .uri(url.as_str())
15719                    .header(USER_AGENT, self.hub._user_agent.clone());
15720
15721                if let Some(token) = token.as_ref() {
15722                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15723                }
15724
15725                let request = req_builder
15726                    .header(CONTENT_LENGTH, 0_u64)
15727                    .body(common::to_body::<String>(None));
15728
15729                client.request(request.unwrap()).await
15730            };
15731
15732            match req_result {
15733                Err(err) => {
15734                    if let common::Retry::After(d) = dlg.http_error(&err) {
15735                        sleep(d).await;
15736                        continue;
15737                    }
15738                    dlg.finished(false);
15739                    return Err(common::Error::HttpError(err));
15740                }
15741                Ok(res) => {
15742                    let (mut parts, body) = res.into_parts();
15743                    let mut body = common::Body::new(body);
15744                    if !parts.status.is_success() {
15745                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15746                        let error = serde_json::from_str(&common::to_string(&bytes));
15747                        let response = common::to_response(parts, bytes.into());
15748
15749                        if let common::Retry::After(d) =
15750                            dlg.http_failure(&response, error.as_ref().ok())
15751                        {
15752                            sleep(d).await;
15753                            continue;
15754                        }
15755
15756                        dlg.finished(false);
15757
15758                        return Err(match error {
15759                            Ok(value) => common::Error::BadRequest(value),
15760                            _ => common::Error::Failure(response),
15761                        });
15762                    }
15763                    let response = {
15764                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15765                        let encoded = common::to_string(&bytes);
15766                        match serde_json::from_str(&encoded) {
15767                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15768                            Err(error) => {
15769                                dlg.response_json_decode_error(&encoded, &error);
15770                                return Err(common::Error::JsonDecodeError(
15771                                    encoded.to_string(),
15772                                    error,
15773                                ));
15774                            }
15775                        }
15776                    };
15777
15778                    dlg.finished(true);
15779                    return Ok(response);
15780                }
15781            }
15782        }
15783    }
15784
15785    /// Required. Parent value for ListLunsRequest.
15786    ///
15787    /// Sets the *parent* path property to the given value.
15788    ///
15789    /// Even though the property as already been set when instantiating this call,
15790    /// we provide this method for API completeness.
15791    pub fn parent(mut self, new_value: &str) -> ProjectLocationVolumeLunListCall<'a, C> {
15792        self._parent = new_value.to_string();
15793        self
15794    }
15795    /// A token identifying a page of results from the server.
15796    ///
15797    /// Sets the *page token* query property to the given value.
15798    pub fn page_token(mut self, new_value: &str) -> ProjectLocationVolumeLunListCall<'a, C> {
15799        self._page_token = Some(new_value.to_string());
15800        self
15801    }
15802    /// Requested page size. The server might return fewer items than requested. If unspecified, server will pick an appropriate default.
15803    ///
15804    /// Sets the *page size* query property to the given value.
15805    pub fn page_size(mut self, new_value: i32) -> ProjectLocationVolumeLunListCall<'a, C> {
15806        self._page_size = Some(new_value);
15807        self
15808    }
15809    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15810    /// while executing the actual API request.
15811    ///
15812    /// ````text
15813    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15814    /// ````
15815    ///
15816    /// Sets the *delegate* property to the given value.
15817    pub fn delegate(
15818        mut self,
15819        new_value: &'a mut dyn common::Delegate,
15820    ) -> ProjectLocationVolumeLunListCall<'a, C> {
15821        self._delegate = Some(new_value);
15822        self
15823    }
15824
15825    /// Set any additional parameter of the query string used in the request.
15826    /// It should be used to set parameters which are not yet available through their own
15827    /// setters.
15828    ///
15829    /// Please note that this method must not be used to set any of the known parameters
15830    /// which have their own setter method. If done anyway, the request will fail.
15831    ///
15832    /// # Additional Parameters
15833    ///
15834    /// * *$.xgafv* (query-string) - V1 error format.
15835    /// * *access_token* (query-string) - OAuth access token.
15836    /// * *alt* (query-string) - Data format for response.
15837    /// * *callback* (query-string) - JSONP
15838    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15839    /// * *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.
15840    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15841    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15842    /// * *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.
15843    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15844    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15845    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeLunListCall<'a, C>
15846    where
15847        T: AsRef<str>,
15848    {
15849        self._additional_params
15850            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15851        self
15852    }
15853
15854    /// Identifies the authorization scope for the method you are building.
15855    ///
15856    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15857    /// [`Scope::CloudPlatform`].
15858    ///
15859    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15860    /// tokens for more than one scope.
15861    ///
15862    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15863    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15864    /// sufficient, a read-write scope will do as well.
15865    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeLunListCall<'a, C>
15866    where
15867        St: AsRef<str>,
15868    {
15869        self._scopes.insert(String::from(scope.as_ref()));
15870        self
15871    }
15872    /// Identifies the authorization scope(s) for the method you are building.
15873    ///
15874    /// See [`Self::add_scope()`] for details.
15875    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeLunListCall<'a, C>
15876    where
15877        I: IntoIterator<Item = St>,
15878        St: AsRef<str>,
15879    {
15880        self._scopes
15881            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15882        self
15883    }
15884
15885    /// Removes all scopes, and no default scope will be used either.
15886    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15887    /// for details).
15888    pub fn clear_scopes(mut self) -> ProjectLocationVolumeLunListCall<'a, C> {
15889        self._scopes.clear();
15890        self
15891    }
15892}
15893
15894/// Takes a snapshot of a boot volume. Returns INVALID_ARGUMENT if called for a non-boot volume.
15895///
15896/// A builder for the *locations.volumes.snapshots.create* method supported by a *project* resource.
15897/// It is not used directly, but through a [`ProjectMethods`] instance.
15898///
15899/// # Example
15900///
15901/// Instantiate a resource method builder
15902///
15903/// ```test_harness,no_run
15904/// # extern crate hyper;
15905/// # extern crate hyper_rustls;
15906/// # extern crate google_baremetalsolution2 as baremetalsolution2;
15907/// use baremetalsolution2::api::VolumeSnapshot;
15908/// # async fn dox() {
15909/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15910///
15911/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15912/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15913/// #     .with_native_roots()
15914/// #     .unwrap()
15915/// #     .https_only()
15916/// #     .enable_http2()
15917/// #     .build();
15918///
15919/// # let executor = hyper_util::rt::TokioExecutor::new();
15920/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15921/// #     secret,
15922/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15923/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15924/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15925/// #     ),
15926/// # ).build().await.unwrap();
15927///
15928/// # let client = hyper_util::client::legacy::Client::builder(
15929/// #     hyper_util::rt::TokioExecutor::new()
15930/// # )
15931/// # .build(
15932/// #     hyper_rustls::HttpsConnectorBuilder::new()
15933/// #         .with_native_roots()
15934/// #         .unwrap()
15935/// #         .https_or_http()
15936/// #         .enable_http2()
15937/// #         .build()
15938/// # );
15939/// # let mut hub = Baremetalsolution::new(client, auth);
15940/// // As the method needs a request, you would usually fill it with the desired information
15941/// // into the respective structure. Some of the parts shown here might not be applicable !
15942/// // Values shown here are possibly random and not representative !
15943/// let mut req = VolumeSnapshot::default();
15944///
15945/// // You can configure optional parameters by calling the respective setters at will, and
15946/// // execute the final call using `doit()`.
15947/// // Values shown here are possibly random and not representative !
15948/// let result = hub.projects().locations_volumes_snapshots_create(req, "parent")
15949///              .doit().await;
15950/// # }
15951/// ```
15952pub struct ProjectLocationVolumeSnapshotCreateCall<'a, C>
15953where
15954    C: 'a,
15955{
15956    hub: &'a Baremetalsolution<C>,
15957    _request: VolumeSnapshot,
15958    _parent: String,
15959    _delegate: Option<&'a mut dyn common::Delegate>,
15960    _additional_params: HashMap<String, String>,
15961    _scopes: BTreeSet<String>,
15962}
15963
15964impl<'a, C> common::CallBuilder for ProjectLocationVolumeSnapshotCreateCall<'a, C> {}
15965
15966impl<'a, C> ProjectLocationVolumeSnapshotCreateCall<'a, C>
15967where
15968    C: common::Connector,
15969{
15970    /// Perform the operation you have build so far.
15971    pub async fn doit(mut self) -> common::Result<(common::Response, VolumeSnapshot)> {
15972        use std::borrow::Cow;
15973        use std::io::{Read, Seek};
15974
15975        use common::{url::Params, ToParts};
15976        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15977
15978        let mut dd = common::DefaultDelegate;
15979        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15980        dlg.begin(common::MethodInfo {
15981            id: "baremetalsolution.projects.locations.volumes.snapshots.create",
15982            http_method: hyper::Method::POST,
15983        });
15984
15985        for &field in ["alt", "parent"].iter() {
15986            if self._additional_params.contains_key(field) {
15987                dlg.finished(false);
15988                return Err(common::Error::FieldClash(field));
15989            }
15990        }
15991
15992        let mut params = Params::with_capacity(4 + self._additional_params.len());
15993        params.push("parent", self._parent);
15994
15995        params.extend(self._additional_params.iter());
15996
15997        params.push("alt", "json");
15998        let mut url = self.hub._base_url.clone() + "v2/{+parent}/snapshots";
15999        if self._scopes.is_empty() {
16000            self._scopes
16001                .insert(Scope::CloudPlatform.as_ref().to_string());
16002        }
16003
16004        #[allow(clippy::single_element_loop)]
16005        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
16006            url = params.uri_replacement(url, param_name, find_this, true);
16007        }
16008        {
16009            let to_remove = ["parent"];
16010            params.remove_params(&to_remove);
16011        }
16012
16013        let url = params.parse_with_url(&url);
16014
16015        let mut json_mime_type = mime::APPLICATION_JSON;
16016        let mut request_value_reader = {
16017            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16018            common::remove_json_null_values(&mut value);
16019            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16020            serde_json::to_writer(&mut dst, &value).unwrap();
16021            dst
16022        };
16023        let request_size = request_value_reader
16024            .seek(std::io::SeekFrom::End(0))
16025            .unwrap();
16026        request_value_reader
16027            .seek(std::io::SeekFrom::Start(0))
16028            .unwrap();
16029
16030        loop {
16031            let token = match self
16032                .hub
16033                .auth
16034                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16035                .await
16036            {
16037                Ok(token) => token,
16038                Err(e) => match dlg.token(e) {
16039                    Ok(token) => token,
16040                    Err(e) => {
16041                        dlg.finished(false);
16042                        return Err(common::Error::MissingToken(e));
16043                    }
16044                },
16045            };
16046            request_value_reader
16047                .seek(std::io::SeekFrom::Start(0))
16048                .unwrap();
16049            let mut req_result = {
16050                let client = &self.hub.client;
16051                dlg.pre_request();
16052                let mut req_builder = hyper::Request::builder()
16053                    .method(hyper::Method::POST)
16054                    .uri(url.as_str())
16055                    .header(USER_AGENT, self.hub._user_agent.clone());
16056
16057                if let Some(token) = token.as_ref() {
16058                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16059                }
16060
16061                let request = req_builder
16062                    .header(CONTENT_TYPE, json_mime_type.to_string())
16063                    .header(CONTENT_LENGTH, request_size as u64)
16064                    .body(common::to_body(
16065                        request_value_reader.get_ref().clone().into(),
16066                    ));
16067
16068                client.request(request.unwrap()).await
16069            };
16070
16071            match req_result {
16072                Err(err) => {
16073                    if let common::Retry::After(d) = dlg.http_error(&err) {
16074                        sleep(d).await;
16075                        continue;
16076                    }
16077                    dlg.finished(false);
16078                    return Err(common::Error::HttpError(err));
16079                }
16080                Ok(res) => {
16081                    let (mut parts, body) = res.into_parts();
16082                    let mut body = common::Body::new(body);
16083                    if !parts.status.is_success() {
16084                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16085                        let error = serde_json::from_str(&common::to_string(&bytes));
16086                        let response = common::to_response(parts, bytes.into());
16087
16088                        if let common::Retry::After(d) =
16089                            dlg.http_failure(&response, error.as_ref().ok())
16090                        {
16091                            sleep(d).await;
16092                            continue;
16093                        }
16094
16095                        dlg.finished(false);
16096
16097                        return Err(match error {
16098                            Ok(value) => common::Error::BadRequest(value),
16099                            _ => common::Error::Failure(response),
16100                        });
16101                    }
16102                    let response = {
16103                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16104                        let encoded = common::to_string(&bytes);
16105                        match serde_json::from_str(&encoded) {
16106                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16107                            Err(error) => {
16108                                dlg.response_json_decode_error(&encoded, &error);
16109                                return Err(common::Error::JsonDecodeError(
16110                                    encoded.to_string(),
16111                                    error,
16112                                ));
16113                            }
16114                        }
16115                    };
16116
16117                    dlg.finished(true);
16118                    return Ok(response);
16119                }
16120            }
16121        }
16122    }
16123
16124    ///
16125    /// Sets the *request* property to the given value.
16126    ///
16127    /// Even though the property as already been set when instantiating this call,
16128    /// we provide this method for API completeness.
16129    pub fn request(
16130        mut self,
16131        new_value: VolumeSnapshot,
16132    ) -> ProjectLocationVolumeSnapshotCreateCall<'a, C> {
16133        self._request = new_value;
16134        self
16135    }
16136    /// Required. The volume to snapshot.
16137    ///
16138    /// Sets the *parent* path property to the given value.
16139    ///
16140    /// Even though the property as already been set when instantiating this call,
16141    /// we provide this method for API completeness.
16142    pub fn parent(mut self, new_value: &str) -> ProjectLocationVolumeSnapshotCreateCall<'a, C> {
16143        self._parent = new_value.to_string();
16144        self
16145    }
16146    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16147    /// while executing the actual API request.
16148    ///
16149    /// ````text
16150    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16151    /// ````
16152    ///
16153    /// Sets the *delegate* property to the given value.
16154    pub fn delegate(
16155        mut self,
16156        new_value: &'a mut dyn common::Delegate,
16157    ) -> ProjectLocationVolumeSnapshotCreateCall<'a, C> {
16158        self._delegate = Some(new_value);
16159        self
16160    }
16161
16162    /// Set any additional parameter of the query string used in the request.
16163    /// It should be used to set parameters which are not yet available through their own
16164    /// setters.
16165    ///
16166    /// Please note that this method must not be used to set any of the known parameters
16167    /// which have their own setter method. If done anyway, the request will fail.
16168    ///
16169    /// # Additional Parameters
16170    ///
16171    /// * *$.xgafv* (query-string) - V1 error format.
16172    /// * *access_token* (query-string) - OAuth access token.
16173    /// * *alt* (query-string) - Data format for response.
16174    /// * *callback* (query-string) - JSONP
16175    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16176    /// * *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.
16177    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16178    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16179    /// * *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.
16180    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16181    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16182    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeSnapshotCreateCall<'a, C>
16183    where
16184        T: AsRef<str>,
16185    {
16186        self._additional_params
16187            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16188        self
16189    }
16190
16191    /// Identifies the authorization scope for the method you are building.
16192    ///
16193    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16194    /// [`Scope::CloudPlatform`].
16195    ///
16196    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16197    /// tokens for more than one scope.
16198    ///
16199    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16200    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16201    /// sufficient, a read-write scope will do as well.
16202    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeSnapshotCreateCall<'a, C>
16203    where
16204        St: AsRef<str>,
16205    {
16206        self._scopes.insert(String::from(scope.as_ref()));
16207        self
16208    }
16209    /// Identifies the authorization scope(s) for the method you are building.
16210    ///
16211    /// See [`Self::add_scope()`] for details.
16212    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeSnapshotCreateCall<'a, C>
16213    where
16214        I: IntoIterator<Item = St>,
16215        St: AsRef<str>,
16216    {
16217        self._scopes
16218            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16219        self
16220    }
16221
16222    /// Removes all scopes, and no default scope will be used either.
16223    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16224    /// for details).
16225    pub fn clear_scopes(mut self) -> ProjectLocationVolumeSnapshotCreateCall<'a, C> {
16226        self._scopes.clear();
16227        self
16228    }
16229}
16230
16231/// Deletes a volume snapshot. Returns INVALID_ARGUMENT if called for a non-boot volume.
16232///
16233/// A builder for the *locations.volumes.snapshots.delete* method supported by a *project* resource.
16234/// It is not used directly, but through a [`ProjectMethods`] instance.
16235///
16236/// # Example
16237///
16238/// Instantiate a resource method builder
16239///
16240/// ```test_harness,no_run
16241/// # extern crate hyper;
16242/// # extern crate hyper_rustls;
16243/// # extern crate google_baremetalsolution2 as baremetalsolution2;
16244/// # async fn dox() {
16245/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16246///
16247/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16248/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16249/// #     .with_native_roots()
16250/// #     .unwrap()
16251/// #     .https_only()
16252/// #     .enable_http2()
16253/// #     .build();
16254///
16255/// # let executor = hyper_util::rt::TokioExecutor::new();
16256/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16257/// #     secret,
16258/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16259/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16260/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16261/// #     ),
16262/// # ).build().await.unwrap();
16263///
16264/// # let client = hyper_util::client::legacy::Client::builder(
16265/// #     hyper_util::rt::TokioExecutor::new()
16266/// # )
16267/// # .build(
16268/// #     hyper_rustls::HttpsConnectorBuilder::new()
16269/// #         .with_native_roots()
16270/// #         .unwrap()
16271/// #         .https_or_http()
16272/// #         .enable_http2()
16273/// #         .build()
16274/// # );
16275/// # let mut hub = Baremetalsolution::new(client, auth);
16276/// // You can configure optional parameters by calling the respective setters at will, and
16277/// // execute the final call using `doit()`.
16278/// // Values shown here are possibly random and not representative !
16279/// let result = hub.projects().locations_volumes_snapshots_delete("name")
16280///              .doit().await;
16281/// # }
16282/// ```
16283pub struct ProjectLocationVolumeSnapshotDeleteCall<'a, C>
16284where
16285    C: 'a,
16286{
16287    hub: &'a Baremetalsolution<C>,
16288    _name: String,
16289    _delegate: Option<&'a mut dyn common::Delegate>,
16290    _additional_params: HashMap<String, String>,
16291    _scopes: BTreeSet<String>,
16292}
16293
16294impl<'a, C> common::CallBuilder for ProjectLocationVolumeSnapshotDeleteCall<'a, C> {}
16295
16296impl<'a, C> ProjectLocationVolumeSnapshotDeleteCall<'a, C>
16297where
16298    C: common::Connector,
16299{
16300    /// Perform the operation you have build so far.
16301    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
16302        use std::borrow::Cow;
16303        use std::io::{Read, Seek};
16304
16305        use common::{url::Params, ToParts};
16306        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16307
16308        let mut dd = common::DefaultDelegate;
16309        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16310        dlg.begin(common::MethodInfo {
16311            id: "baremetalsolution.projects.locations.volumes.snapshots.delete",
16312            http_method: hyper::Method::DELETE,
16313        });
16314
16315        for &field in ["alt", "name"].iter() {
16316            if self._additional_params.contains_key(field) {
16317                dlg.finished(false);
16318                return Err(common::Error::FieldClash(field));
16319            }
16320        }
16321
16322        let mut params = Params::with_capacity(3 + self._additional_params.len());
16323        params.push("name", self._name);
16324
16325        params.extend(self._additional_params.iter());
16326
16327        params.push("alt", "json");
16328        let mut url = self.hub._base_url.clone() + "v2/{+name}";
16329        if self._scopes.is_empty() {
16330            self._scopes
16331                .insert(Scope::CloudPlatform.as_ref().to_string());
16332        }
16333
16334        #[allow(clippy::single_element_loop)]
16335        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16336            url = params.uri_replacement(url, param_name, find_this, true);
16337        }
16338        {
16339            let to_remove = ["name"];
16340            params.remove_params(&to_remove);
16341        }
16342
16343        let url = params.parse_with_url(&url);
16344
16345        loop {
16346            let token = match self
16347                .hub
16348                .auth
16349                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16350                .await
16351            {
16352                Ok(token) => token,
16353                Err(e) => match dlg.token(e) {
16354                    Ok(token) => token,
16355                    Err(e) => {
16356                        dlg.finished(false);
16357                        return Err(common::Error::MissingToken(e));
16358                    }
16359                },
16360            };
16361            let mut req_result = {
16362                let client = &self.hub.client;
16363                dlg.pre_request();
16364                let mut req_builder = hyper::Request::builder()
16365                    .method(hyper::Method::DELETE)
16366                    .uri(url.as_str())
16367                    .header(USER_AGENT, self.hub._user_agent.clone());
16368
16369                if let Some(token) = token.as_ref() {
16370                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16371                }
16372
16373                let request = req_builder
16374                    .header(CONTENT_LENGTH, 0_u64)
16375                    .body(common::to_body::<String>(None));
16376
16377                client.request(request.unwrap()).await
16378            };
16379
16380            match req_result {
16381                Err(err) => {
16382                    if let common::Retry::After(d) = dlg.http_error(&err) {
16383                        sleep(d).await;
16384                        continue;
16385                    }
16386                    dlg.finished(false);
16387                    return Err(common::Error::HttpError(err));
16388                }
16389                Ok(res) => {
16390                    let (mut parts, body) = res.into_parts();
16391                    let mut body = common::Body::new(body);
16392                    if !parts.status.is_success() {
16393                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16394                        let error = serde_json::from_str(&common::to_string(&bytes));
16395                        let response = common::to_response(parts, bytes.into());
16396
16397                        if let common::Retry::After(d) =
16398                            dlg.http_failure(&response, error.as_ref().ok())
16399                        {
16400                            sleep(d).await;
16401                            continue;
16402                        }
16403
16404                        dlg.finished(false);
16405
16406                        return Err(match error {
16407                            Ok(value) => common::Error::BadRequest(value),
16408                            _ => common::Error::Failure(response),
16409                        });
16410                    }
16411                    let response = {
16412                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16413                        let encoded = common::to_string(&bytes);
16414                        match serde_json::from_str(&encoded) {
16415                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16416                            Err(error) => {
16417                                dlg.response_json_decode_error(&encoded, &error);
16418                                return Err(common::Error::JsonDecodeError(
16419                                    encoded.to_string(),
16420                                    error,
16421                                ));
16422                            }
16423                        }
16424                    };
16425
16426                    dlg.finished(true);
16427                    return Ok(response);
16428                }
16429            }
16430        }
16431    }
16432
16433    /// Required. The name of the snapshot to delete.
16434    ///
16435    /// Sets the *name* path property to the given value.
16436    ///
16437    /// Even though the property as already been set when instantiating this call,
16438    /// we provide this method for API completeness.
16439    pub fn name(mut self, new_value: &str) -> ProjectLocationVolumeSnapshotDeleteCall<'a, C> {
16440        self._name = new_value.to_string();
16441        self
16442    }
16443    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16444    /// while executing the actual API request.
16445    ///
16446    /// ````text
16447    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16448    /// ````
16449    ///
16450    /// Sets the *delegate* property to the given value.
16451    pub fn delegate(
16452        mut self,
16453        new_value: &'a mut dyn common::Delegate,
16454    ) -> ProjectLocationVolumeSnapshotDeleteCall<'a, C> {
16455        self._delegate = Some(new_value);
16456        self
16457    }
16458
16459    /// Set any additional parameter of the query string used in the request.
16460    /// It should be used to set parameters which are not yet available through their own
16461    /// setters.
16462    ///
16463    /// Please note that this method must not be used to set any of the known parameters
16464    /// which have their own setter method. If done anyway, the request will fail.
16465    ///
16466    /// # Additional Parameters
16467    ///
16468    /// * *$.xgafv* (query-string) - V1 error format.
16469    /// * *access_token* (query-string) - OAuth access token.
16470    /// * *alt* (query-string) - Data format for response.
16471    /// * *callback* (query-string) - JSONP
16472    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16473    /// * *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.
16474    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16475    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16476    /// * *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.
16477    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16478    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16479    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeSnapshotDeleteCall<'a, C>
16480    where
16481        T: AsRef<str>,
16482    {
16483        self._additional_params
16484            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16485        self
16486    }
16487
16488    /// Identifies the authorization scope for the method you are building.
16489    ///
16490    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16491    /// [`Scope::CloudPlatform`].
16492    ///
16493    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16494    /// tokens for more than one scope.
16495    ///
16496    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16497    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16498    /// sufficient, a read-write scope will do as well.
16499    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeSnapshotDeleteCall<'a, C>
16500    where
16501        St: AsRef<str>,
16502    {
16503        self._scopes.insert(String::from(scope.as_ref()));
16504        self
16505    }
16506    /// Identifies the authorization scope(s) for the method you are building.
16507    ///
16508    /// See [`Self::add_scope()`] for details.
16509    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeSnapshotDeleteCall<'a, C>
16510    where
16511        I: IntoIterator<Item = St>,
16512        St: AsRef<str>,
16513    {
16514        self._scopes
16515            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16516        self
16517    }
16518
16519    /// Removes all scopes, and no default scope will be used either.
16520    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16521    /// for details).
16522    pub fn clear_scopes(mut self) -> ProjectLocationVolumeSnapshotDeleteCall<'a, C> {
16523        self._scopes.clear();
16524        self
16525    }
16526}
16527
16528/// Returns the specified snapshot resource. Returns INVALID_ARGUMENT if called for a non-boot volume.
16529///
16530/// A builder for the *locations.volumes.snapshots.get* method supported by a *project* resource.
16531/// It is not used directly, but through a [`ProjectMethods`] instance.
16532///
16533/// # Example
16534///
16535/// Instantiate a resource method builder
16536///
16537/// ```test_harness,no_run
16538/// # extern crate hyper;
16539/// # extern crate hyper_rustls;
16540/// # extern crate google_baremetalsolution2 as baremetalsolution2;
16541/// # async fn dox() {
16542/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16543///
16544/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16545/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16546/// #     .with_native_roots()
16547/// #     .unwrap()
16548/// #     .https_only()
16549/// #     .enable_http2()
16550/// #     .build();
16551///
16552/// # let executor = hyper_util::rt::TokioExecutor::new();
16553/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16554/// #     secret,
16555/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16556/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16557/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16558/// #     ),
16559/// # ).build().await.unwrap();
16560///
16561/// # let client = hyper_util::client::legacy::Client::builder(
16562/// #     hyper_util::rt::TokioExecutor::new()
16563/// # )
16564/// # .build(
16565/// #     hyper_rustls::HttpsConnectorBuilder::new()
16566/// #         .with_native_roots()
16567/// #         .unwrap()
16568/// #         .https_or_http()
16569/// #         .enable_http2()
16570/// #         .build()
16571/// # );
16572/// # let mut hub = Baremetalsolution::new(client, auth);
16573/// // You can configure optional parameters by calling the respective setters at will, and
16574/// // execute the final call using `doit()`.
16575/// // Values shown here are possibly random and not representative !
16576/// let result = hub.projects().locations_volumes_snapshots_get("name")
16577///              .doit().await;
16578/// # }
16579/// ```
16580pub struct ProjectLocationVolumeSnapshotGetCall<'a, C>
16581where
16582    C: 'a,
16583{
16584    hub: &'a Baremetalsolution<C>,
16585    _name: String,
16586    _delegate: Option<&'a mut dyn common::Delegate>,
16587    _additional_params: HashMap<String, String>,
16588    _scopes: BTreeSet<String>,
16589}
16590
16591impl<'a, C> common::CallBuilder for ProjectLocationVolumeSnapshotGetCall<'a, C> {}
16592
16593impl<'a, C> ProjectLocationVolumeSnapshotGetCall<'a, C>
16594where
16595    C: common::Connector,
16596{
16597    /// Perform the operation you have build so far.
16598    pub async fn doit(mut self) -> common::Result<(common::Response, VolumeSnapshot)> {
16599        use std::borrow::Cow;
16600        use std::io::{Read, Seek};
16601
16602        use common::{url::Params, ToParts};
16603        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16604
16605        let mut dd = common::DefaultDelegate;
16606        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16607        dlg.begin(common::MethodInfo {
16608            id: "baremetalsolution.projects.locations.volumes.snapshots.get",
16609            http_method: hyper::Method::GET,
16610        });
16611
16612        for &field in ["alt", "name"].iter() {
16613            if self._additional_params.contains_key(field) {
16614                dlg.finished(false);
16615                return Err(common::Error::FieldClash(field));
16616            }
16617        }
16618
16619        let mut params = Params::with_capacity(3 + self._additional_params.len());
16620        params.push("name", self._name);
16621
16622        params.extend(self._additional_params.iter());
16623
16624        params.push("alt", "json");
16625        let mut url = self.hub._base_url.clone() + "v2/{+name}";
16626        if self._scopes.is_empty() {
16627            self._scopes
16628                .insert(Scope::CloudPlatform.as_ref().to_string());
16629        }
16630
16631        #[allow(clippy::single_element_loop)]
16632        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16633            url = params.uri_replacement(url, param_name, find_this, true);
16634        }
16635        {
16636            let to_remove = ["name"];
16637            params.remove_params(&to_remove);
16638        }
16639
16640        let url = params.parse_with_url(&url);
16641
16642        loop {
16643            let token = match self
16644                .hub
16645                .auth
16646                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16647                .await
16648            {
16649                Ok(token) => token,
16650                Err(e) => match dlg.token(e) {
16651                    Ok(token) => token,
16652                    Err(e) => {
16653                        dlg.finished(false);
16654                        return Err(common::Error::MissingToken(e));
16655                    }
16656                },
16657            };
16658            let mut req_result = {
16659                let client = &self.hub.client;
16660                dlg.pre_request();
16661                let mut req_builder = hyper::Request::builder()
16662                    .method(hyper::Method::GET)
16663                    .uri(url.as_str())
16664                    .header(USER_AGENT, self.hub._user_agent.clone());
16665
16666                if let Some(token) = token.as_ref() {
16667                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16668                }
16669
16670                let request = req_builder
16671                    .header(CONTENT_LENGTH, 0_u64)
16672                    .body(common::to_body::<String>(None));
16673
16674                client.request(request.unwrap()).await
16675            };
16676
16677            match req_result {
16678                Err(err) => {
16679                    if let common::Retry::After(d) = dlg.http_error(&err) {
16680                        sleep(d).await;
16681                        continue;
16682                    }
16683                    dlg.finished(false);
16684                    return Err(common::Error::HttpError(err));
16685                }
16686                Ok(res) => {
16687                    let (mut parts, body) = res.into_parts();
16688                    let mut body = common::Body::new(body);
16689                    if !parts.status.is_success() {
16690                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16691                        let error = serde_json::from_str(&common::to_string(&bytes));
16692                        let response = common::to_response(parts, bytes.into());
16693
16694                        if let common::Retry::After(d) =
16695                            dlg.http_failure(&response, error.as_ref().ok())
16696                        {
16697                            sleep(d).await;
16698                            continue;
16699                        }
16700
16701                        dlg.finished(false);
16702
16703                        return Err(match error {
16704                            Ok(value) => common::Error::BadRequest(value),
16705                            _ => common::Error::Failure(response),
16706                        });
16707                    }
16708                    let response = {
16709                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16710                        let encoded = common::to_string(&bytes);
16711                        match serde_json::from_str(&encoded) {
16712                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16713                            Err(error) => {
16714                                dlg.response_json_decode_error(&encoded, &error);
16715                                return Err(common::Error::JsonDecodeError(
16716                                    encoded.to_string(),
16717                                    error,
16718                                ));
16719                            }
16720                        }
16721                    };
16722
16723                    dlg.finished(true);
16724                    return Ok(response);
16725                }
16726            }
16727        }
16728    }
16729
16730    /// Required. The name of the snapshot.
16731    ///
16732    /// Sets the *name* path property to the given value.
16733    ///
16734    /// Even though the property as already been set when instantiating this call,
16735    /// we provide this method for API completeness.
16736    pub fn name(mut self, new_value: &str) -> ProjectLocationVolumeSnapshotGetCall<'a, C> {
16737        self._name = new_value.to_string();
16738        self
16739    }
16740    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16741    /// while executing the actual API request.
16742    ///
16743    /// ````text
16744    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16745    /// ````
16746    ///
16747    /// Sets the *delegate* property to the given value.
16748    pub fn delegate(
16749        mut self,
16750        new_value: &'a mut dyn common::Delegate,
16751    ) -> ProjectLocationVolumeSnapshotGetCall<'a, C> {
16752        self._delegate = Some(new_value);
16753        self
16754    }
16755
16756    /// Set any additional parameter of the query string used in the request.
16757    /// It should be used to set parameters which are not yet available through their own
16758    /// setters.
16759    ///
16760    /// Please note that this method must not be used to set any of the known parameters
16761    /// which have their own setter method. If done anyway, the request will fail.
16762    ///
16763    /// # Additional Parameters
16764    ///
16765    /// * *$.xgafv* (query-string) - V1 error format.
16766    /// * *access_token* (query-string) - OAuth access token.
16767    /// * *alt* (query-string) - Data format for response.
16768    /// * *callback* (query-string) - JSONP
16769    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16770    /// * *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.
16771    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16772    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16773    /// * *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.
16774    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16775    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16776    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeSnapshotGetCall<'a, C>
16777    where
16778        T: AsRef<str>,
16779    {
16780        self._additional_params
16781            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16782        self
16783    }
16784
16785    /// Identifies the authorization scope for the method you are building.
16786    ///
16787    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16788    /// [`Scope::CloudPlatform`].
16789    ///
16790    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16791    /// tokens for more than one scope.
16792    ///
16793    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16794    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16795    /// sufficient, a read-write scope will do as well.
16796    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeSnapshotGetCall<'a, C>
16797    where
16798        St: AsRef<str>,
16799    {
16800        self._scopes.insert(String::from(scope.as_ref()));
16801        self
16802    }
16803    /// Identifies the authorization scope(s) for the method you are building.
16804    ///
16805    /// See [`Self::add_scope()`] for details.
16806    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeSnapshotGetCall<'a, C>
16807    where
16808        I: IntoIterator<Item = St>,
16809        St: AsRef<str>,
16810    {
16811        self._scopes
16812            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16813        self
16814    }
16815
16816    /// Removes all scopes, and no default scope will be used either.
16817    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16818    /// for details).
16819    pub fn clear_scopes(mut self) -> ProjectLocationVolumeSnapshotGetCall<'a, C> {
16820        self._scopes.clear();
16821        self
16822    }
16823}
16824
16825/// Retrieves the list of snapshots for the specified volume. Returns a response with an empty list of snapshots if called for a non-boot volume.
16826///
16827/// A builder for the *locations.volumes.snapshots.list* method supported by a *project* resource.
16828/// It is not used directly, but through a [`ProjectMethods`] instance.
16829///
16830/// # Example
16831///
16832/// Instantiate a resource method builder
16833///
16834/// ```test_harness,no_run
16835/// # extern crate hyper;
16836/// # extern crate hyper_rustls;
16837/// # extern crate google_baremetalsolution2 as baremetalsolution2;
16838/// # async fn dox() {
16839/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16840///
16841/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16842/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16843/// #     .with_native_roots()
16844/// #     .unwrap()
16845/// #     .https_only()
16846/// #     .enable_http2()
16847/// #     .build();
16848///
16849/// # let executor = hyper_util::rt::TokioExecutor::new();
16850/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16851/// #     secret,
16852/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16853/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16854/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16855/// #     ),
16856/// # ).build().await.unwrap();
16857///
16858/// # let client = hyper_util::client::legacy::Client::builder(
16859/// #     hyper_util::rt::TokioExecutor::new()
16860/// # )
16861/// # .build(
16862/// #     hyper_rustls::HttpsConnectorBuilder::new()
16863/// #         .with_native_roots()
16864/// #         .unwrap()
16865/// #         .https_or_http()
16866/// #         .enable_http2()
16867/// #         .build()
16868/// # );
16869/// # let mut hub = Baremetalsolution::new(client, auth);
16870/// // You can configure optional parameters by calling the respective setters at will, and
16871/// // execute the final call using `doit()`.
16872/// // Values shown here are possibly random and not representative !
16873/// let result = hub.projects().locations_volumes_snapshots_list("parent")
16874///              .page_token("vero")
16875///              .page_size(-88)
16876///              .doit().await;
16877/// # }
16878/// ```
16879pub struct ProjectLocationVolumeSnapshotListCall<'a, C>
16880where
16881    C: 'a,
16882{
16883    hub: &'a Baremetalsolution<C>,
16884    _parent: String,
16885    _page_token: Option<String>,
16886    _page_size: Option<i32>,
16887    _delegate: Option<&'a mut dyn common::Delegate>,
16888    _additional_params: HashMap<String, String>,
16889    _scopes: BTreeSet<String>,
16890}
16891
16892impl<'a, C> common::CallBuilder for ProjectLocationVolumeSnapshotListCall<'a, C> {}
16893
16894impl<'a, C> ProjectLocationVolumeSnapshotListCall<'a, C>
16895where
16896    C: common::Connector,
16897{
16898    /// Perform the operation you have build so far.
16899    pub async fn doit(mut self) -> common::Result<(common::Response, ListVolumeSnapshotsResponse)> {
16900        use std::borrow::Cow;
16901        use std::io::{Read, Seek};
16902
16903        use common::{url::Params, ToParts};
16904        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16905
16906        let mut dd = common::DefaultDelegate;
16907        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16908        dlg.begin(common::MethodInfo {
16909            id: "baremetalsolution.projects.locations.volumes.snapshots.list",
16910            http_method: hyper::Method::GET,
16911        });
16912
16913        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
16914            if self._additional_params.contains_key(field) {
16915                dlg.finished(false);
16916                return Err(common::Error::FieldClash(field));
16917            }
16918        }
16919
16920        let mut params = Params::with_capacity(5 + self._additional_params.len());
16921        params.push("parent", self._parent);
16922        if let Some(value) = self._page_token.as_ref() {
16923            params.push("pageToken", value);
16924        }
16925        if let Some(value) = self._page_size.as_ref() {
16926            params.push("pageSize", value.to_string());
16927        }
16928
16929        params.extend(self._additional_params.iter());
16930
16931        params.push("alt", "json");
16932        let mut url = self.hub._base_url.clone() + "v2/{+parent}/snapshots";
16933        if self._scopes.is_empty() {
16934            self._scopes
16935                .insert(Scope::CloudPlatform.as_ref().to_string());
16936        }
16937
16938        #[allow(clippy::single_element_loop)]
16939        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
16940            url = params.uri_replacement(url, param_name, find_this, true);
16941        }
16942        {
16943            let to_remove = ["parent"];
16944            params.remove_params(&to_remove);
16945        }
16946
16947        let url = params.parse_with_url(&url);
16948
16949        loop {
16950            let token = match self
16951                .hub
16952                .auth
16953                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16954                .await
16955            {
16956                Ok(token) => token,
16957                Err(e) => match dlg.token(e) {
16958                    Ok(token) => token,
16959                    Err(e) => {
16960                        dlg.finished(false);
16961                        return Err(common::Error::MissingToken(e));
16962                    }
16963                },
16964            };
16965            let mut req_result = {
16966                let client = &self.hub.client;
16967                dlg.pre_request();
16968                let mut req_builder = hyper::Request::builder()
16969                    .method(hyper::Method::GET)
16970                    .uri(url.as_str())
16971                    .header(USER_AGENT, self.hub._user_agent.clone());
16972
16973                if let Some(token) = token.as_ref() {
16974                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16975                }
16976
16977                let request = req_builder
16978                    .header(CONTENT_LENGTH, 0_u64)
16979                    .body(common::to_body::<String>(None));
16980
16981                client.request(request.unwrap()).await
16982            };
16983
16984            match req_result {
16985                Err(err) => {
16986                    if let common::Retry::After(d) = dlg.http_error(&err) {
16987                        sleep(d).await;
16988                        continue;
16989                    }
16990                    dlg.finished(false);
16991                    return Err(common::Error::HttpError(err));
16992                }
16993                Ok(res) => {
16994                    let (mut parts, body) = res.into_parts();
16995                    let mut body = common::Body::new(body);
16996                    if !parts.status.is_success() {
16997                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16998                        let error = serde_json::from_str(&common::to_string(&bytes));
16999                        let response = common::to_response(parts, bytes.into());
17000
17001                        if let common::Retry::After(d) =
17002                            dlg.http_failure(&response, error.as_ref().ok())
17003                        {
17004                            sleep(d).await;
17005                            continue;
17006                        }
17007
17008                        dlg.finished(false);
17009
17010                        return Err(match error {
17011                            Ok(value) => common::Error::BadRequest(value),
17012                            _ => common::Error::Failure(response),
17013                        });
17014                    }
17015                    let response = {
17016                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17017                        let encoded = common::to_string(&bytes);
17018                        match serde_json::from_str(&encoded) {
17019                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17020                            Err(error) => {
17021                                dlg.response_json_decode_error(&encoded, &error);
17022                                return Err(common::Error::JsonDecodeError(
17023                                    encoded.to_string(),
17024                                    error,
17025                                ));
17026                            }
17027                        }
17028                    };
17029
17030                    dlg.finished(true);
17031                    return Ok(response);
17032                }
17033            }
17034        }
17035    }
17036
17037    /// Required. Parent value for ListVolumesRequest.
17038    ///
17039    /// Sets the *parent* path property to the given value.
17040    ///
17041    /// Even though the property as already been set when instantiating this call,
17042    /// we provide this method for API completeness.
17043    pub fn parent(mut self, new_value: &str) -> ProjectLocationVolumeSnapshotListCall<'a, C> {
17044        self._parent = new_value.to_string();
17045        self
17046    }
17047    /// A token identifying a page of results from the server.
17048    ///
17049    /// Sets the *page token* query property to the given value.
17050    pub fn page_token(mut self, new_value: &str) -> ProjectLocationVolumeSnapshotListCall<'a, C> {
17051        self._page_token = Some(new_value.to_string());
17052        self
17053    }
17054    /// Requested page size. The server might return fewer items than requested. If unspecified, server will pick an appropriate default.
17055    ///
17056    /// Sets the *page size* query property to the given value.
17057    pub fn page_size(mut self, new_value: i32) -> ProjectLocationVolumeSnapshotListCall<'a, C> {
17058        self._page_size = Some(new_value);
17059        self
17060    }
17061    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17062    /// while executing the actual API request.
17063    ///
17064    /// ````text
17065    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17066    /// ````
17067    ///
17068    /// Sets the *delegate* property to the given value.
17069    pub fn delegate(
17070        mut self,
17071        new_value: &'a mut dyn common::Delegate,
17072    ) -> ProjectLocationVolumeSnapshotListCall<'a, C> {
17073        self._delegate = Some(new_value);
17074        self
17075    }
17076
17077    /// Set any additional parameter of the query string used in the request.
17078    /// It should be used to set parameters which are not yet available through their own
17079    /// setters.
17080    ///
17081    /// Please note that this method must not be used to set any of the known parameters
17082    /// which have their own setter method. If done anyway, the request will fail.
17083    ///
17084    /// # Additional Parameters
17085    ///
17086    /// * *$.xgafv* (query-string) - V1 error format.
17087    /// * *access_token* (query-string) - OAuth access token.
17088    /// * *alt* (query-string) - Data format for response.
17089    /// * *callback* (query-string) - JSONP
17090    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17091    /// * *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.
17092    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17093    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17094    /// * *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.
17095    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17096    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17097    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeSnapshotListCall<'a, C>
17098    where
17099        T: AsRef<str>,
17100    {
17101        self._additional_params
17102            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17103        self
17104    }
17105
17106    /// Identifies the authorization scope for the method you are building.
17107    ///
17108    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17109    /// [`Scope::CloudPlatform`].
17110    ///
17111    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17112    /// tokens for more than one scope.
17113    ///
17114    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17115    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17116    /// sufficient, a read-write scope will do as well.
17117    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeSnapshotListCall<'a, C>
17118    where
17119        St: AsRef<str>,
17120    {
17121        self._scopes.insert(String::from(scope.as_ref()));
17122        self
17123    }
17124    /// Identifies the authorization scope(s) for the method you are building.
17125    ///
17126    /// See [`Self::add_scope()`] for details.
17127    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeSnapshotListCall<'a, C>
17128    where
17129        I: IntoIterator<Item = St>,
17130        St: AsRef<str>,
17131    {
17132        self._scopes
17133            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17134        self
17135    }
17136
17137    /// Removes all scopes, and no default scope will be used either.
17138    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17139    /// for details).
17140    pub fn clear_scopes(mut self) -> ProjectLocationVolumeSnapshotListCall<'a, C> {
17141        self._scopes.clear();
17142        self
17143    }
17144}
17145
17146/// Uses the specified snapshot to restore its parent volume. Returns INVALID_ARGUMENT if called for a non-boot volume.
17147///
17148/// A builder for the *locations.volumes.snapshots.restoreVolumeSnapshot* method supported by a *project* resource.
17149/// It is not used directly, but through a [`ProjectMethods`] instance.
17150///
17151/// # Example
17152///
17153/// Instantiate a resource method builder
17154///
17155/// ```test_harness,no_run
17156/// # extern crate hyper;
17157/// # extern crate hyper_rustls;
17158/// # extern crate google_baremetalsolution2 as baremetalsolution2;
17159/// use baremetalsolution2::api::RestoreVolumeSnapshotRequest;
17160/// # async fn dox() {
17161/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17162///
17163/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17164/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17165/// #     .with_native_roots()
17166/// #     .unwrap()
17167/// #     .https_only()
17168/// #     .enable_http2()
17169/// #     .build();
17170///
17171/// # let executor = hyper_util::rt::TokioExecutor::new();
17172/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17173/// #     secret,
17174/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17175/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17176/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17177/// #     ),
17178/// # ).build().await.unwrap();
17179///
17180/// # let client = hyper_util::client::legacy::Client::builder(
17181/// #     hyper_util::rt::TokioExecutor::new()
17182/// # )
17183/// # .build(
17184/// #     hyper_rustls::HttpsConnectorBuilder::new()
17185/// #         .with_native_roots()
17186/// #         .unwrap()
17187/// #         .https_or_http()
17188/// #         .enable_http2()
17189/// #         .build()
17190/// # );
17191/// # let mut hub = Baremetalsolution::new(client, auth);
17192/// // As the method needs a request, you would usually fill it with the desired information
17193/// // into the respective structure. Some of the parts shown here might not be applicable !
17194/// // Values shown here are possibly random and not representative !
17195/// let mut req = RestoreVolumeSnapshotRequest::default();
17196///
17197/// // You can configure optional parameters by calling the respective setters at will, and
17198/// // execute the final call using `doit()`.
17199/// // Values shown here are possibly random and not representative !
17200/// let result = hub.projects().locations_volumes_snapshots_restore_volume_snapshot(req, "volumeSnapshot")
17201///              .doit().await;
17202/// # }
17203/// ```
17204pub struct ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C>
17205where
17206    C: 'a,
17207{
17208    hub: &'a Baremetalsolution<C>,
17209    _request: RestoreVolumeSnapshotRequest,
17210    _volume_snapshot: String,
17211    _delegate: Option<&'a mut dyn common::Delegate>,
17212    _additional_params: HashMap<String, String>,
17213    _scopes: BTreeSet<String>,
17214}
17215
17216impl<'a, C> common::CallBuilder for ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C> {}
17217
17218impl<'a, C> ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C>
17219where
17220    C: common::Connector,
17221{
17222    /// Perform the operation you have build so far.
17223    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
17224        use std::borrow::Cow;
17225        use std::io::{Read, Seek};
17226
17227        use common::{url::Params, ToParts};
17228        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17229
17230        let mut dd = common::DefaultDelegate;
17231        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17232        dlg.begin(common::MethodInfo {
17233            id: "baremetalsolution.projects.locations.volumes.snapshots.restoreVolumeSnapshot",
17234            http_method: hyper::Method::POST,
17235        });
17236
17237        for &field in ["alt", "volumeSnapshot"].iter() {
17238            if self._additional_params.contains_key(field) {
17239                dlg.finished(false);
17240                return Err(common::Error::FieldClash(field));
17241            }
17242        }
17243
17244        let mut params = Params::with_capacity(4 + self._additional_params.len());
17245        params.push("volumeSnapshot", self._volume_snapshot);
17246
17247        params.extend(self._additional_params.iter());
17248
17249        params.push("alt", "json");
17250        let mut url = self.hub._base_url.clone() + "v2/{+volumeSnapshot}:restoreVolumeSnapshot";
17251        if self._scopes.is_empty() {
17252            self._scopes
17253                .insert(Scope::CloudPlatform.as_ref().to_string());
17254        }
17255
17256        #[allow(clippy::single_element_loop)]
17257        for &(find_this, param_name) in [("{+volumeSnapshot}", "volumeSnapshot")].iter() {
17258            url = params.uri_replacement(url, param_name, find_this, true);
17259        }
17260        {
17261            let to_remove = ["volumeSnapshot"];
17262            params.remove_params(&to_remove);
17263        }
17264
17265        let url = params.parse_with_url(&url);
17266
17267        let mut json_mime_type = mime::APPLICATION_JSON;
17268        let mut request_value_reader = {
17269            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17270            common::remove_json_null_values(&mut value);
17271            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17272            serde_json::to_writer(&mut dst, &value).unwrap();
17273            dst
17274        };
17275        let request_size = request_value_reader
17276            .seek(std::io::SeekFrom::End(0))
17277            .unwrap();
17278        request_value_reader
17279            .seek(std::io::SeekFrom::Start(0))
17280            .unwrap();
17281
17282        loop {
17283            let token = match self
17284                .hub
17285                .auth
17286                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17287                .await
17288            {
17289                Ok(token) => token,
17290                Err(e) => match dlg.token(e) {
17291                    Ok(token) => token,
17292                    Err(e) => {
17293                        dlg.finished(false);
17294                        return Err(common::Error::MissingToken(e));
17295                    }
17296                },
17297            };
17298            request_value_reader
17299                .seek(std::io::SeekFrom::Start(0))
17300                .unwrap();
17301            let mut req_result = {
17302                let client = &self.hub.client;
17303                dlg.pre_request();
17304                let mut req_builder = hyper::Request::builder()
17305                    .method(hyper::Method::POST)
17306                    .uri(url.as_str())
17307                    .header(USER_AGENT, self.hub._user_agent.clone());
17308
17309                if let Some(token) = token.as_ref() {
17310                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17311                }
17312
17313                let request = req_builder
17314                    .header(CONTENT_TYPE, json_mime_type.to_string())
17315                    .header(CONTENT_LENGTH, request_size as u64)
17316                    .body(common::to_body(
17317                        request_value_reader.get_ref().clone().into(),
17318                    ));
17319
17320                client.request(request.unwrap()).await
17321            };
17322
17323            match req_result {
17324                Err(err) => {
17325                    if let common::Retry::After(d) = dlg.http_error(&err) {
17326                        sleep(d).await;
17327                        continue;
17328                    }
17329                    dlg.finished(false);
17330                    return Err(common::Error::HttpError(err));
17331                }
17332                Ok(res) => {
17333                    let (mut parts, body) = res.into_parts();
17334                    let mut body = common::Body::new(body);
17335                    if !parts.status.is_success() {
17336                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17337                        let error = serde_json::from_str(&common::to_string(&bytes));
17338                        let response = common::to_response(parts, bytes.into());
17339
17340                        if let common::Retry::After(d) =
17341                            dlg.http_failure(&response, error.as_ref().ok())
17342                        {
17343                            sleep(d).await;
17344                            continue;
17345                        }
17346
17347                        dlg.finished(false);
17348
17349                        return Err(match error {
17350                            Ok(value) => common::Error::BadRequest(value),
17351                            _ => common::Error::Failure(response),
17352                        });
17353                    }
17354                    let response = {
17355                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17356                        let encoded = common::to_string(&bytes);
17357                        match serde_json::from_str(&encoded) {
17358                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17359                            Err(error) => {
17360                                dlg.response_json_decode_error(&encoded, &error);
17361                                return Err(common::Error::JsonDecodeError(
17362                                    encoded.to_string(),
17363                                    error,
17364                                ));
17365                            }
17366                        }
17367                    };
17368
17369                    dlg.finished(true);
17370                    return Ok(response);
17371                }
17372            }
17373        }
17374    }
17375
17376    ///
17377    /// Sets the *request* property to the given value.
17378    ///
17379    /// Even though the property as already been set when instantiating this call,
17380    /// we provide this method for API completeness.
17381    pub fn request(
17382        mut self,
17383        new_value: RestoreVolumeSnapshotRequest,
17384    ) -> ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C> {
17385        self._request = new_value;
17386        self
17387    }
17388    /// Required. Name of the snapshot which will be used to restore its parent volume.
17389    ///
17390    /// Sets the *volume snapshot* path property to the given value.
17391    ///
17392    /// Even though the property as already been set when instantiating this call,
17393    /// we provide this method for API completeness.
17394    pub fn volume_snapshot(
17395        mut self,
17396        new_value: &str,
17397    ) -> ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C> {
17398        self._volume_snapshot = new_value.to_string();
17399        self
17400    }
17401    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17402    /// while executing the actual API request.
17403    ///
17404    /// ````text
17405    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17406    /// ````
17407    ///
17408    /// Sets the *delegate* property to the given value.
17409    pub fn delegate(
17410        mut self,
17411        new_value: &'a mut dyn common::Delegate,
17412    ) -> ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C> {
17413        self._delegate = Some(new_value);
17414        self
17415    }
17416
17417    /// Set any additional parameter of the query string used in the request.
17418    /// It should be used to set parameters which are not yet available through their own
17419    /// setters.
17420    ///
17421    /// Please note that this method must not be used to set any of the known parameters
17422    /// which have their own setter method. If done anyway, the request will fail.
17423    ///
17424    /// # Additional Parameters
17425    ///
17426    /// * *$.xgafv* (query-string) - V1 error format.
17427    /// * *access_token* (query-string) - OAuth access token.
17428    /// * *alt* (query-string) - Data format for response.
17429    /// * *callback* (query-string) - JSONP
17430    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17431    /// * *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.
17432    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17433    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17434    /// * *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.
17435    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17436    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17437    pub fn param<T>(
17438        mut self,
17439        name: T,
17440        value: T,
17441    ) -> ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C>
17442    where
17443        T: AsRef<str>,
17444    {
17445        self._additional_params
17446            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17447        self
17448    }
17449
17450    /// Identifies the authorization scope for the method you are building.
17451    ///
17452    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17453    /// [`Scope::CloudPlatform`].
17454    ///
17455    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17456    /// tokens for more than one scope.
17457    ///
17458    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17459    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17460    /// sufficient, a read-write scope will do as well.
17461    pub fn add_scope<St>(
17462        mut self,
17463        scope: St,
17464    ) -> ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C>
17465    where
17466        St: AsRef<str>,
17467    {
17468        self._scopes.insert(String::from(scope.as_ref()));
17469        self
17470    }
17471    /// Identifies the authorization scope(s) for the method you are building.
17472    ///
17473    /// See [`Self::add_scope()`] for details.
17474    pub fn add_scopes<I, St>(
17475        mut self,
17476        scopes: I,
17477    ) -> ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C>
17478    where
17479        I: IntoIterator<Item = St>,
17480        St: AsRef<str>,
17481    {
17482        self._scopes
17483            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17484        self
17485    }
17486
17487    /// Removes all scopes, and no default scope will be used either.
17488    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17489    /// for details).
17490    pub fn clear_scopes(mut self) -> ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C> {
17491        self._scopes.clear();
17492        self
17493    }
17494}
17495
17496/// Skips volume's cooloff and deletes it now. Volume must be in cooloff state.
17497///
17498/// A builder for the *locations.volumes.evict* method supported by a *project* resource.
17499/// It is not used directly, but through a [`ProjectMethods`] instance.
17500///
17501/// # Example
17502///
17503/// Instantiate a resource method builder
17504///
17505/// ```test_harness,no_run
17506/// # extern crate hyper;
17507/// # extern crate hyper_rustls;
17508/// # extern crate google_baremetalsolution2 as baremetalsolution2;
17509/// use baremetalsolution2::api::EvictVolumeRequest;
17510/// # async fn dox() {
17511/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17512///
17513/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17514/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17515/// #     .with_native_roots()
17516/// #     .unwrap()
17517/// #     .https_only()
17518/// #     .enable_http2()
17519/// #     .build();
17520///
17521/// # let executor = hyper_util::rt::TokioExecutor::new();
17522/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17523/// #     secret,
17524/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17525/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17526/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17527/// #     ),
17528/// # ).build().await.unwrap();
17529///
17530/// # let client = hyper_util::client::legacy::Client::builder(
17531/// #     hyper_util::rt::TokioExecutor::new()
17532/// # )
17533/// # .build(
17534/// #     hyper_rustls::HttpsConnectorBuilder::new()
17535/// #         .with_native_roots()
17536/// #         .unwrap()
17537/// #         .https_or_http()
17538/// #         .enable_http2()
17539/// #         .build()
17540/// # );
17541/// # let mut hub = Baremetalsolution::new(client, auth);
17542/// // As the method needs a request, you would usually fill it with the desired information
17543/// // into the respective structure. Some of the parts shown here might not be applicable !
17544/// // Values shown here are possibly random and not representative !
17545/// let mut req = EvictVolumeRequest::default();
17546///
17547/// // You can configure optional parameters by calling the respective setters at will, and
17548/// // execute the final call using `doit()`.
17549/// // Values shown here are possibly random and not representative !
17550/// let result = hub.projects().locations_volumes_evict(req, "name")
17551///              .doit().await;
17552/// # }
17553/// ```
17554pub struct ProjectLocationVolumeEvictCall<'a, C>
17555where
17556    C: 'a,
17557{
17558    hub: &'a Baremetalsolution<C>,
17559    _request: EvictVolumeRequest,
17560    _name: String,
17561    _delegate: Option<&'a mut dyn common::Delegate>,
17562    _additional_params: HashMap<String, String>,
17563    _scopes: BTreeSet<String>,
17564}
17565
17566impl<'a, C> common::CallBuilder for ProjectLocationVolumeEvictCall<'a, C> {}
17567
17568impl<'a, C> ProjectLocationVolumeEvictCall<'a, C>
17569where
17570    C: common::Connector,
17571{
17572    /// Perform the operation you have build so far.
17573    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
17574        use std::borrow::Cow;
17575        use std::io::{Read, Seek};
17576
17577        use common::{url::Params, ToParts};
17578        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17579
17580        let mut dd = common::DefaultDelegate;
17581        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17582        dlg.begin(common::MethodInfo {
17583            id: "baremetalsolution.projects.locations.volumes.evict",
17584            http_method: hyper::Method::POST,
17585        });
17586
17587        for &field in ["alt", "name"].iter() {
17588            if self._additional_params.contains_key(field) {
17589                dlg.finished(false);
17590                return Err(common::Error::FieldClash(field));
17591            }
17592        }
17593
17594        let mut params = Params::with_capacity(4 + self._additional_params.len());
17595        params.push("name", self._name);
17596
17597        params.extend(self._additional_params.iter());
17598
17599        params.push("alt", "json");
17600        let mut url = self.hub._base_url.clone() + "v2/{+name}:evict";
17601        if self._scopes.is_empty() {
17602            self._scopes
17603                .insert(Scope::CloudPlatform.as_ref().to_string());
17604        }
17605
17606        #[allow(clippy::single_element_loop)]
17607        for &(find_this, param_name) in [("{+name}", "name")].iter() {
17608            url = params.uri_replacement(url, param_name, find_this, true);
17609        }
17610        {
17611            let to_remove = ["name"];
17612            params.remove_params(&to_remove);
17613        }
17614
17615        let url = params.parse_with_url(&url);
17616
17617        let mut json_mime_type = mime::APPLICATION_JSON;
17618        let mut request_value_reader = {
17619            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17620            common::remove_json_null_values(&mut value);
17621            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17622            serde_json::to_writer(&mut dst, &value).unwrap();
17623            dst
17624        };
17625        let request_size = request_value_reader
17626            .seek(std::io::SeekFrom::End(0))
17627            .unwrap();
17628        request_value_reader
17629            .seek(std::io::SeekFrom::Start(0))
17630            .unwrap();
17631
17632        loop {
17633            let token = match self
17634                .hub
17635                .auth
17636                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17637                .await
17638            {
17639                Ok(token) => token,
17640                Err(e) => match dlg.token(e) {
17641                    Ok(token) => token,
17642                    Err(e) => {
17643                        dlg.finished(false);
17644                        return Err(common::Error::MissingToken(e));
17645                    }
17646                },
17647            };
17648            request_value_reader
17649                .seek(std::io::SeekFrom::Start(0))
17650                .unwrap();
17651            let mut req_result = {
17652                let client = &self.hub.client;
17653                dlg.pre_request();
17654                let mut req_builder = hyper::Request::builder()
17655                    .method(hyper::Method::POST)
17656                    .uri(url.as_str())
17657                    .header(USER_AGENT, self.hub._user_agent.clone());
17658
17659                if let Some(token) = token.as_ref() {
17660                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17661                }
17662
17663                let request = req_builder
17664                    .header(CONTENT_TYPE, json_mime_type.to_string())
17665                    .header(CONTENT_LENGTH, request_size as u64)
17666                    .body(common::to_body(
17667                        request_value_reader.get_ref().clone().into(),
17668                    ));
17669
17670                client.request(request.unwrap()).await
17671            };
17672
17673            match req_result {
17674                Err(err) => {
17675                    if let common::Retry::After(d) = dlg.http_error(&err) {
17676                        sleep(d).await;
17677                        continue;
17678                    }
17679                    dlg.finished(false);
17680                    return Err(common::Error::HttpError(err));
17681                }
17682                Ok(res) => {
17683                    let (mut parts, body) = res.into_parts();
17684                    let mut body = common::Body::new(body);
17685                    if !parts.status.is_success() {
17686                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17687                        let error = serde_json::from_str(&common::to_string(&bytes));
17688                        let response = common::to_response(parts, bytes.into());
17689
17690                        if let common::Retry::After(d) =
17691                            dlg.http_failure(&response, error.as_ref().ok())
17692                        {
17693                            sleep(d).await;
17694                            continue;
17695                        }
17696
17697                        dlg.finished(false);
17698
17699                        return Err(match error {
17700                            Ok(value) => common::Error::BadRequest(value),
17701                            _ => common::Error::Failure(response),
17702                        });
17703                    }
17704                    let response = {
17705                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17706                        let encoded = common::to_string(&bytes);
17707                        match serde_json::from_str(&encoded) {
17708                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17709                            Err(error) => {
17710                                dlg.response_json_decode_error(&encoded, &error);
17711                                return Err(common::Error::JsonDecodeError(
17712                                    encoded.to_string(),
17713                                    error,
17714                                ));
17715                            }
17716                        }
17717                    };
17718
17719                    dlg.finished(true);
17720                    return Ok(response);
17721                }
17722            }
17723        }
17724    }
17725
17726    ///
17727    /// Sets the *request* property to the given value.
17728    ///
17729    /// Even though the property as already been set when instantiating this call,
17730    /// we provide this method for API completeness.
17731    pub fn request(
17732        mut self,
17733        new_value: EvictVolumeRequest,
17734    ) -> ProjectLocationVolumeEvictCall<'a, C> {
17735        self._request = new_value;
17736        self
17737    }
17738    /// Required. The name of the Volume.
17739    ///
17740    /// Sets the *name* path property to the given value.
17741    ///
17742    /// Even though the property as already been set when instantiating this call,
17743    /// we provide this method for API completeness.
17744    pub fn name(mut self, new_value: &str) -> ProjectLocationVolumeEvictCall<'a, C> {
17745        self._name = new_value.to_string();
17746        self
17747    }
17748    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17749    /// while executing the actual API request.
17750    ///
17751    /// ````text
17752    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17753    /// ````
17754    ///
17755    /// Sets the *delegate* property to the given value.
17756    pub fn delegate(
17757        mut self,
17758        new_value: &'a mut dyn common::Delegate,
17759    ) -> ProjectLocationVolumeEvictCall<'a, C> {
17760        self._delegate = Some(new_value);
17761        self
17762    }
17763
17764    /// Set any additional parameter of the query string used in the request.
17765    /// It should be used to set parameters which are not yet available through their own
17766    /// setters.
17767    ///
17768    /// Please note that this method must not be used to set any of the known parameters
17769    /// which have their own setter method. If done anyway, the request will fail.
17770    ///
17771    /// # Additional Parameters
17772    ///
17773    /// * *$.xgafv* (query-string) - V1 error format.
17774    /// * *access_token* (query-string) - OAuth access token.
17775    /// * *alt* (query-string) - Data format for response.
17776    /// * *callback* (query-string) - JSONP
17777    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17778    /// * *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.
17779    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17780    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17781    /// * *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.
17782    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17783    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17784    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeEvictCall<'a, C>
17785    where
17786        T: AsRef<str>,
17787    {
17788        self._additional_params
17789            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17790        self
17791    }
17792
17793    /// Identifies the authorization scope for the method you are building.
17794    ///
17795    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17796    /// [`Scope::CloudPlatform`].
17797    ///
17798    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17799    /// tokens for more than one scope.
17800    ///
17801    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17802    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17803    /// sufficient, a read-write scope will do as well.
17804    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeEvictCall<'a, C>
17805    where
17806        St: AsRef<str>,
17807    {
17808        self._scopes.insert(String::from(scope.as_ref()));
17809        self
17810    }
17811    /// Identifies the authorization scope(s) for the method you are building.
17812    ///
17813    /// See [`Self::add_scope()`] for details.
17814    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeEvictCall<'a, C>
17815    where
17816        I: IntoIterator<Item = St>,
17817        St: AsRef<str>,
17818    {
17819        self._scopes
17820            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17821        self
17822    }
17823
17824    /// Removes all scopes, and no default scope will be used either.
17825    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17826    /// for details).
17827    pub fn clear_scopes(mut self) -> ProjectLocationVolumeEvictCall<'a, C> {
17828        self._scopes.clear();
17829        self
17830    }
17831}
17832
17833/// Get details of a single storage volume.
17834///
17835/// A builder for the *locations.volumes.get* method supported by a *project* resource.
17836/// It is not used directly, but through a [`ProjectMethods`] instance.
17837///
17838/// # Example
17839///
17840/// Instantiate a resource method builder
17841///
17842/// ```test_harness,no_run
17843/// # extern crate hyper;
17844/// # extern crate hyper_rustls;
17845/// # extern crate google_baremetalsolution2 as baremetalsolution2;
17846/// # async fn dox() {
17847/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17848///
17849/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17850/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17851/// #     .with_native_roots()
17852/// #     .unwrap()
17853/// #     .https_only()
17854/// #     .enable_http2()
17855/// #     .build();
17856///
17857/// # let executor = hyper_util::rt::TokioExecutor::new();
17858/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17859/// #     secret,
17860/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17861/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17862/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17863/// #     ),
17864/// # ).build().await.unwrap();
17865///
17866/// # let client = hyper_util::client::legacy::Client::builder(
17867/// #     hyper_util::rt::TokioExecutor::new()
17868/// # )
17869/// # .build(
17870/// #     hyper_rustls::HttpsConnectorBuilder::new()
17871/// #         .with_native_roots()
17872/// #         .unwrap()
17873/// #         .https_or_http()
17874/// #         .enable_http2()
17875/// #         .build()
17876/// # );
17877/// # let mut hub = Baremetalsolution::new(client, auth);
17878/// // You can configure optional parameters by calling the respective setters at will, and
17879/// // execute the final call using `doit()`.
17880/// // Values shown here are possibly random and not representative !
17881/// let result = hub.projects().locations_volumes_get("name")
17882///              .doit().await;
17883/// # }
17884/// ```
17885pub struct ProjectLocationVolumeGetCall<'a, C>
17886where
17887    C: 'a,
17888{
17889    hub: &'a Baremetalsolution<C>,
17890    _name: String,
17891    _delegate: Option<&'a mut dyn common::Delegate>,
17892    _additional_params: HashMap<String, String>,
17893    _scopes: BTreeSet<String>,
17894}
17895
17896impl<'a, C> common::CallBuilder for ProjectLocationVolumeGetCall<'a, C> {}
17897
17898impl<'a, C> ProjectLocationVolumeGetCall<'a, C>
17899where
17900    C: common::Connector,
17901{
17902    /// Perform the operation you have build so far.
17903    pub async fn doit(mut self) -> common::Result<(common::Response, Volume)> {
17904        use std::borrow::Cow;
17905        use std::io::{Read, Seek};
17906
17907        use common::{url::Params, ToParts};
17908        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17909
17910        let mut dd = common::DefaultDelegate;
17911        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17912        dlg.begin(common::MethodInfo {
17913            id: "baremetalsolution.projects.locations.volumes.get",
17914            http_method: hyper::Method::GET,
17915        });
17916
17917        for &field in ["alt", "name"].iter() {
17918            if self._additional_params.contains_key(field) {
17919                dlg.finished(false);
17920                return Err(common::Error::FieldClash(field));
17921            }
17922        }
17923
17924        let mut params = Params::with_capacity(3 + self._additional_params.len());
17925        params.push("name", self._name);
17926
17927        params.extend(self._additional_params.iter());
17928
17929        params.push("alt", "json");
17930        let mut url = self.hub._base_url.clone() + "v2/{+name}";
17931        if self._scopes.is_empty() {
17932            self._scopes
17933                .insert(Scope::CloudPlatform.as_ref().to_string());
17934        }
17935
17936        #[allow(clippy::single_element_loop)]
17937        for &(find_this, param_name) in [("{+name}", "name")].iter() {
17938            url = params.uri_replacement(url, param_name, find_this, true);
17939        }
17940        {
17941            let to_remove = ["name"];
17942            params.remove_params(&to_remove);
17943        }
17944
17945        let url = params.parse_with_url(&url);
17946
17947        loop {
17948            let token = match self
17949                .hub
17950                .auth
17951                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17952                .await
17953            {
17954                Ok(token) => token,
17955                Err(e) => match dlg.token(e) {
17956                    Ok(token) => token,
17957                    Err(e) => {
17958                        dlg.finished(false);
17959                        return Err(common::Error::MissingToken(e));
17960                    }
17961                },
17962            };
17963            let mut req_result = {
17964                let client = &self.hub.client;
17965                dlg.pre_request();
17966                let mut req_builder = hyper::Request::builder()
17967                    .method(hyper::Method::GET)
17968                    .uri(url.as_str())
17969                    .header(USER_AGENT, self.hub._user_agent.clone());
17970
17971                if let Some(token) = token.as_ref() {
17972                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17973                }
17974
17975                let request = req_builder
17976                    .header(CONTENT_LENGTH, 0_u64)
17977                    .body(common::to_body::<String>(None));
17978
17979                client.request(request.unwrap()).await
17980            };
17981
17982            match req_result {
17983                Err(err) => {
17984                    if let common::Retry::After(d) = dlg.http_error(&err) {
17985                        sleep(d).await;
17986                        continue;
17987                    }
17988                    dlg.finished(false);
17989                    return Err(common::Error::HttpError(err));
17990                }
17991                Ok(res) => {
17992                    let (mut parts, body) = res.into_parts();
17993                    let mut body = common::Body::new(body);
17994                    if !parts.status.is_success() {
17995                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17996                        let error = serde_json::from_str(&common::to_string(&bytes));
17997                        let response = common::to_response(parts, bytes.into());
17998
17999                        if let common::Retry::After(d) =
18000                            dlg.http_failure(&response, error.as_ref().ok())
18001                        {
18002                            sleep(d).await;
18003                            continue;
18004                        }
18005
18006                        dlg.finished(false);
18007
18008                        return Err(match error {
18009                            Ok(value) => common::Error::BadRequest(value),
18010                            _ => common::Error::Failure(response),
18011                        });
18012                    }
18013                    let response = {
18014                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18015                        let encoded = common::to_string(&bytes);
18016                        match serde_json::from_str(&encoded) {
18017                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18018                            Err(error) => {
18019                                dlg.response_json_decode_error(&encoded, &error);
18020                                return Err(common::Error::JsonDecodeError(
18021                                    encoded.to_string(),
18022                                    error,
18023                                ));
18024                            }
18025                        }
18026                    };
18027
18028                    dlg.finished(true);
18029                    return Ok(response);
18030                }
18031            }
18032        }
18033    }
18034
18035    /// Required. Name of the resource.
18036    ///
18037    /// Sets the *name* path property to the given value.
18038    ///
18039    /// Even though the property as already been set when instantiating this call,
18040    /// we provide this method for API completeness.
18041    pub fn name(mut self, new_value: &str) -> ProjectLocationVolumeGetCall<'a, C> {
18042        self._name = new_value.to_string();
18043        self
18044    }
18045    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18046    /// while executing the actual API request.
18047    ///
18048    /// ````text
18049    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18050    /// ````
18051    ///
18052    /// Sets the *delegate* property to the given value.
18053    pub fn delegate(
18054        mut self,
18055        new_value: &'a mut dyn common::Delegate,
18056    ) -> ProjectLocationVolumeGetCall<'a, C> {
18057        self._delegate = Some(new_value);
18058        self
18059    }
18060
18061    /// Set any additional parameter of the query string used in the request.
18062    /// It should be used to set parameters which are not yet available through their own
18063    /// setters.
18064    ///
18065    /// Please note that this method must not be used to set any of the known parameters
18066    /// which have their own setter method. If done anyway, the request will fail.
18067    ///
18068    /// # Additional Parameters
18069    ///
18070    /// * *$.xgafv* (query-string) - V1 error format.
18071    /// * *access_token* (query-string) - OAuth access token.
18072    /// * *alt* (query-string) - Data format for response.
18073    /// * *callback* (query-string) - JSONP
18074    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18075    /// * *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.
18076    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18077    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18078    /// * *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.
18079    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18080    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18081    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeGetCall<'a, C>
18082    where
18083        T: AsRef<str>,
18084    {
18085        self._additional_params
18086            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18087        self
18088    }
18089
18090    /// Identifies the authorization scope for the method you are building.
18091    ///
18092    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18093    /// [`Scope::CloudPlatform`].
18094    ///
18095    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18096    /// tokens for more than one scope.
18097    ///
18098    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18099    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18100    /// sufficient, a read-write scope will do as well.
18101    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeGetCall<'a, C>
18102    where
18103        St: AsRef<str>,
18104    {
18105        self._scopes.insert(String::from(scope.as_ref()));
18106        self
18107    }
18108    /// Identifies the authorization scope(s) for the method you are building.
18109    ///
18110    /// See [`Self::add_scope()`] for details.
18111    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeGetCall<'a, C>
18112    where
18113        I: IntoIterator<Item = St>,
18114        St: AsRef<str>,
18115    {
18116        self._scopes
18117            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18118        self
18119    }
18120
18121    /// Removes all scopes, and no default scope will be used either.
18122    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18123    /// for details).
18124    pub fn clear_scopes(mut self) -> ProjectLocationVolumeGetCall<'a, C> {
18125        self._scopes.clear();
18126        self
18127    }
18128}
18129
18130/// List storage volumes in a given project and location.
18131///
18132/// A builder for the *locations.volumes.list* method supported by a *project* resource.
18133/// It is not used directly, but through a [`ProjectMethods`] instance.
18134///
18135/// # Example
18136///
18137/// Instantiate a resource method builder
18138///
18139/// ```test_harness,no_run
18140/// # extern crate hyper;
18141/// # extern crate hyper_rustls;
18142/// # extern crate google_baremetalsolution2 as baremetalsolution2;
18143/// # async fn dox() {
18144/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18145///
18146/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18147/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18148/// #     .with_native_roots()
18149/// #     .unwrap()
18150/// #     .https_only()
18151/// #     .enable_http2()
18152/// #     .build();
18153///
18154/// # let executor = hyper_util::rt::TokioExecutor::new();
18155/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18156/// #     secret,
18157/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18158/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18159/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18160/// #     ),
18161/// # ).build().await.unwrap();
18162///
18163/// # let client = hyper_util::client::legacy::Client::builder(
18164/// #     hyper_util::rt::TokioExecutor::new()
18165/// # )
18166/// # .build(
18167/// #     hyper_rustls::HttpsConnectorBuilder::new()
18168/// #         .with_native_roots()
18169/// #         .unwrap()
18170/// #         .https_or_http()
18171/// #         .enable_http2()
18172/// #         .build()
18173/// # );
18174/// # let mut hub = Baremetalsolution::new(client, auth);
18175/// // You can configure optional parameters by calling the respective setters at will, and
18176/// // execute the final call using `doit()`.
18177/// // Values shown here are possibly random and not representative !
18178/// let result = hub.projects().locations_volumes_list("parent")
18179///              .page_token("diam")
18180///              .page_size(-61)
18181///              .filter("ipsum")
18182///              .doit().await;
18183/// # }
18184/// ```
18185pub struct ProjectLocationVolumeListCall<'a, C>
18186where
18187    C: 'a,
18188{
18189    hub: &'a Baremetalsolution<C>,
18190    _parent: String,
18191    _page_token: Option<String>,
18192    _page_size: Option<i32>,
18193    _filter: Option<String>,
18194    _delegate: Option<&'a mut dyn common::Delegate>,
18195    _additional_params: HashMap<String, String>,
18196    _scopes: BTreeSet<String>,
18197}
18198
18199impl<'a, C> common::CallBuilder for ProjectLocationVolumeListCall<'a, C> {}
18200
18201impl<'a, C> ProjectLocationVolumeListCall<'a, C>
18202where
18203    C: common::Connector,
18204{
18205    /// Perform the operation you have build so far.
18206    pub async fn doit(mut self) -> common::Result<(common::Response, ListVolumesResponse)> {
18207        use std::borrow::Cow;
18208        use std::io::{Read, Seek};
18209
18210        use common::{url::Params, ToParts};
18211        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18212
18213        let mut dd = common::DefaultDelegate;
18214        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18215        dlg.begin(common::MethodInfo {
18216            id: "baremetalsolution.projects.locations.volumes.list",
18217            http_method: hyper::Method::GET,
18218        });
18219
18220        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
18221            if self._additional_params.contains_key(field) {
18222                dlg.finished(false);
18223                return Err(common::Error::FieldClash(field));
18224            }
18225        }
18226
18227        let mut params = Params::with_capacity(6 + self._additional_params.len());
18228        params.push("parent", self._parent);
18229        if let Some(value) = self._page_token.as_ref() {
18230            params.push("pageToken", value);
18231        }
18232        if let Some(value) = self._page_size.as_ref() {
18233            params.push("pageSize", value.to_string());
18234        }
18235        if let Some(value) = self._filter.as_ref() {
18236            params.push("filter", value);
18237        }
18238
18239        params.extend(self._additional_params.iter());
18240
18241        params.push("alt", "json");
18242        let mut url = self.hub._base_url.clone() + "v2/{+parent}/volumes";
18243        if self._scopes.is_empty() {
18244            self._scopes
18245                .insert(Scope::CloudPlatform.as_ref().to_string());
18246        }
18247
18248        #[allow(clippy::single_element_loop)]
18249        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
18250            url = params.uri_replacement(url, param_name, find_this, true);
18251        }
18252        {
18253            let to_remove = ["parent"];
18254            params.remove_params(&to_remove);
18255        }
18256
18257        let url = params.parse_with_url(&url);
18258
18259        loop {
18260            let token = match self
18261                .hub
18262                .auth
18263                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18264                .await
18265            {
18266                Ok(token) => token,
18267                Err(e) => match dlg.token(e) {
18268                    Ok(token) => token,
18269                    Err(e) => {
18270                        dlg.finished(false);
18271                        return Err(common::Error::MissingToken(e));
18272                    }
18273                },
18274            };
18275            let mut req_result = {
18276                let client = &self.hub.client;
18277                dlg.pre_request();
18278                let mut req_builder = hyper::Request::builder()
18279                    .method(hyper::Method::GET)
18280                    .uri(url.as_str())
18281                    .header(USER_AGENT, self.hub._user_agent.clone());
18282
18283                if let Some(token) = token.as_ref() {
18284                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18285                }
18286
18287                let request = req_builder
18288                    .header(CONTENT_LENGTH, 0_u64)
18289                    .body(common::to_body::<String>(None));
18290
18291                client.request(request.unwrap()).await
18292            };
18293
18294            match req_result {
18295                Err(err) => {
18296                    if let common::Retry::After(d) = dlg.http_error(&err) {
18297                        sleep(d).await;
18298                        continue;
18299                    }
18300                    dlg.finished(false);
18301                    return Err(common::Error::HttpError(err));
18302                }
18303                Ok(res) => {
18304                    let (mut parts, body) = res.into_parts();
18305                    let mut body = common::Body::new(body);
18306                    if !parts.status.is_success() {
18307                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18308                        let error = serde_json::from_str(&common::to_string(&bytes));
18309                        let response = common::to_response(parts, bytes.into());
18310
18311                        if let common::Retry::After(d) =
18312                            dlg.http_failure(&response, error.as_ref().ok())
18313                        {
18314                            sleep(d).await;
18315                            continue;
18316                        }
18317
18318                        dlg.finished(false);
18319
18320                        return Err(match error {
18321                            Ok(value) => common::Error::BadRequest(value),
18322                            _ => common::Error::Failure(response),
18323                        });
18324                    }
18325                    let response = {
18326                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18327                        let encoded = common::to_string(&bytes);
18328                        match serde_json::from_str(&encoded) {
18329                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18330                            Err(error) => {
18331                                dlg.response_json_decode_error(&encoded, &error);
18332                                return Err(common::Error::JsonDecodeError(
18333                                    encoded.to_string(),
18334                                    error,
18335                                ));
18336                            }
18337                        }
18338                    };
18339
18340                    dlg.finished(true);
18341                    return Ok(response);
18342                }
18343            }
18344        }
18345    }
18346
18347    /// Required. Parent value for ListVolumesRequest.
18348    ///
18349    /// Sets the *parent* path property to the given value.
18350    ///
18351    /// Even though the property as already been set when instantiating this call,
18352    /// we provide this method for API completeness.
18353    pub fn parent(mut self, new_value: &str) -> ProjectLocationVolumeListCall<'a, C> {
18354        self._parent = new_value.to_string();
18355        self
18356    }
18357    /// A token identifying a page of results from the server.
18358    ///
18359    /// Sets the *page token* query property to the given value.
18360    pub fn page_token(mut self, new_value: &str) -> ProjectLocationVolumeListCall<'a, C> {
18361        self._page_token = Some(new_value.to_string());
18362        self
18363    }
18364    /// Requested page size. The server might return fewer items than requested. If unspecified, server will pick an appropriate default.
18365    ///
18366    /// Sets the *page size* query property to the given value.
18367    pub fn page_size(mut self, new_value: i32) -> ProjectLocationVolumeListCall<'a, C> {
18368        self._page_size = Some(new_value);
18369        self
18370    }
18371    /// List filter.
18372    ///
18373    /// Sets the *filter* query property to the given value.
18374    pub fn filter(mut self, new_value: &str) -> ProjectLocationVolumeListCall<'a, C> {
18375        self._filter = Some(new_value.to_string());
18376        self
18377    }
18378    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18379    /// while executing the actual API request.
18380    ///
18381    /// ````text
18382    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18383    /// ````
18384    ///
18385    /// Sets the *delegate* property to the given value.
18386    pub fn delegate(
18387        mut self,
18388        new_value: &'a mut dyn common::Delegate,
18389    ) -> ProjectLocationVolumeListCall<'a, C> {
18390        self._delegate = Some(new_value);
18391        self
18392    }
18393
18394    /// Set any additional parameter of the query string used in the request.
18395    /// It should be used to set parameters which are not yet available through their own
18396    /// setters.
18397    ///
18398    /// Please note that this method must not be used to set any of the known parameters
18399    /// which have their own setter method. If done anyway, the request will fail.
18400    ///
18401    /// # Additional Parameters
18402    ///
18403    /// * *$.xgafv* (query-string) - V1 error format.
18404    /// * *access_token* (query-string) - OAuth access token.
18405    /// * *alt* (query-string) - Data format for response.
18406    /// * *callback* (query-string) - JSONP
18407    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18408    /// * *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.
18409    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18410    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18411    /// * *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.
18412    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18413    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18414    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeListCall<'a, C>
18415    where
18416        T: AsRef<str>,
18417    {
18418        self._additional_params
18419            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18420        self
18421    }
18422
18423    /// Identifies the authorization scope for the method you are building.
18424    ///
18425    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18426    /// [`Scope::CloudPlatform`].
18427    ///
18428    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18429    /// tokens for more than one scope.
18430    ///
18431    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18432    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18433    /// sufficient, a read-write scope will do as well.
18434    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeListCall<'a, C>
18435    where
18436        St: AsRef<str>,
18437    {
18438        self._scopes.insert(String::from(scope.as_ref()));
18439        self
18440    }
18441    /// Identifies the authorization scope(s) for the method you are building.
18442    ///
18443    /// See [`Self::add_scope()`] for details.
18444    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeListCall<'a, C>
18445    where
18446        I: IntoIterator<Item = St>,
18447        St: AsRef<str>,
18448    {
18449        self._scopes
18450            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18451        self
18452    }
18453
18454    /// Removes all scopes, and no default scope will be used either.
18455    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18456    /// for details).
18457    pub fn clear_scopes(mut self) -> ProjectLocationVolumeListCall<'a, C> {
18458        self._scopes.clear();
18459        self
18460    }
18461}
18462
18463/// Update details of a single storage volume.
18464///
18465/// A builder for the *locations.volumes.patch* method supported by a *project* resource.
18466/// It is not used directly, but through a [`ProjectMethods`] instance.
18467///
18468/// # Example
18469///
18470/// Instantiate a resource method builder
18471///
18472/// ```test_harness,no_run
18473/// # extern crate hyper;
18474/// # extern crate hyper_rustls;
18475/// # extern crate google_baremetalsolution2 as baremetalsolution2;
18476/// use baremetalsolution2::api::Volume;
18477/// # async fn dox() {
18478/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18479///
18480/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18481/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18482/// #     .with_native_roots()
18483/// #     .unwrap()
18484/// #     .https_only()
18485/// #     .enable_http2()
18486/// #     .build();
18487///
18488/// # let executor = hyper_util::rt::TokioExecutor::new();
18489/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18490/// #     secret,
18491/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18492/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18493/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18494/// #     ),
18495/// # ).build().await.unwrap();
18496///
18497/// # let client = hyper_util::client::legacy::Client::builder(
18498/// #     hyper_util::rt::TokioExecutor::new()
18499/// # )
18500/// # .build(
18501/// #     hyper_rustls::HttpsConnectorBuilder::new()
18502/// #         .with_native_roots()
18503/// #         .unwrap()
18504/// #         .https_or_http()
18505/// #         .enable_http2()
18506/// #         .build()
18507/// # );
18508/// # let mut hub = Baremetalsolution::new(client, auth);
18509/// // As the method needs a request, you would usually fill it with the desired information
18510/// // into the respective structure. Some of the parts shown here might not be applicable !
18511/// // Values shown here are possibly random and not representative !
18512/// let mut req = Volume::default();
18513///
18514/// // You can configure optional parameters by calling the respective setters at will, and
18515/// // execute the final call using `doit()`.
18516/// // Values shown here are possibly random and not representative !
18517/// let result = hub.projects().locations_volumes_patch(req, "name")
18518///              .update_mask(FieldMask::new::<&str>(&[]))
18519///              .doit().await;
18520/// # }
18521/// ```
18522pub struct ProjectLocationVolumePatchCall<'a, C>
18523where
18524    C: 'a,
18525{
18526    hub: &'a Baremetalsolution<C>,
18527    _request: Volume,
18528    _name: String,
18529    _update_mask: Option<common::FieldMask>,
18530    _delegate: Option<&'a mut dyn common::Delegate>,
18531    _additional_params: HashMap<String, String>,
18532    _scopes: BTreeSet<String>,
18533}
18534
18535impl<'a, C> common::CallBuilder for ProjectLocationVolumePatchCall<'a, C> {}
18536
18537impl<'a, C> ProjectLocationVolumePatchCall<'a, C>
18538where
18539    C: common::Connector,
18540{
18541    /// Perform the operation you have build so far.
18542    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
18543        use std::borrow::Cow;
18544        use std::io::{Read, Seek};
18545
18546        use common::{url::Params, ToParts};
18547        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18548
18549        let mut dd = common::DefaultDelegate;
18550        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18551        dlg.begin(common::MethodInfo {
18552            id: "baremetalsolution.projects.locations.volumes.patch",
18553            http_method: hyper::Method::PATCH,
18554        });
18555
18556        for &field in ["alt", "name", "updateMask"].iter() {
18557            if self._additional_params.contains_key(field) {
18558                dlg.finished(false);
18559                return Err(common::Error::FieldClash(field));
18560            }
18561        }
18562
18563        let mut params = Params::with_capacity(5 + self._additional_params.len());
18564        params.push("name", self._name);
18565        if let Some(value) = self._update_mask.as_ref() {
18566            params.push("updateMask", value.to_string());
18567        }
18568
18569        params.extend(self._additional_params.iter());
18570
18571        params.push("alt", "json");
18572        let mut url = self.hub._base_url.clone() + "v2/{+name}";
18573        if self._scopes.is_empty() {
18574            self._scopes
18575                .insert(Scope::CloudPlatform.as_ref().to_string());
18576        }
18577
18578        #[allow(clippy::single_element_loop)]
18579        for &(find_this, param_name) in [("{+name}", "name")].iter() {
18580            url = params.uri_replacement(url, param_name, find_this, true);
18581        }
18582        {
18583            let to_remove = ["name"];
18584            params.remove_params(&to_remove);
18585        }
18586
18587        let url = params.parse_with_url(&url);
18588
18589        let mut json_mime_type = mime::APPLICATION_JSON;
18590        let mut request_value_reader = {
18591            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18592            common::remove_json_null_values(&mut value);
18593            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18594            serde_json::to_writer(&mut dst, &value).unwrap();
18595            dst
18596        };
18597        let request_size = request_value_reader
18598            .seek(std::io::SeekFrom::End(0))
18599            .unwrap();
18600        request_value_reader
18601            .seek(std::io::SeekFrom::Start(0))
18602            .unwrap();
18603
18604        loop {
18605            let token = match self
18606                .hub
18607                .auth
18608                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18609                .await
18610            {
18611                Ok(token) => token,
18612                Err(e) => match dlg.token(e) {
18613                    Ok(token) => token,
18614                    Err(e) => {
18615                        dlg.finished(false);
18616                        return Err(common::Error::MissingToken(e));
18617                    }
18618                },
18619            };
18620            request_value_reader
18621                .seek(std::io::SeekFrom::Start(0))
18622                .unwrap();
18623            let mut req_result = {
18624                let client = &self.hub.client;
18625                dlg.pre_request();
18626                let mut req_builder = hyper::Request::builder()
18627                    .method(hyper::Method::PATCH)
18628                    .uri(url.as_str())
18629                    .header(USER_AGENT, self.hub._user_agent.clone());
18630
18631                if let Some(token) = token.as_ref() {
18632                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18633                }
18634
18635                let request = req_builder
18636                    .header(CONTENT_TYPE, json_mime_type.to_string())
18637                    .header(CONTENT_LENGTH, request_size as u64)
18638                    .body(common::to_body(
18639                        request_value_reader.get_ref().clone().into(),
18640                    ));
18641
18642                client.request(request.unwrap()).await
18643            };
18644
18645            match req_result {
18646                Err(err) => {
18647                    if let common::Retry::After(d) = dlg.http_error(&err) {
18648                        sleep(d).await;
18649                        continue;
18650                    }
18651                    dlg.finished(false);
18652                    return Err(common::Error::HttpError(err));
18653                }
18654                Ok(res) => {
18655                    let (mut parts, body) = res.into_parts();
18656                    let mut body = common::Body::new(body);
18657                    if !parts.status.is_success() {
18658                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18659                        let error = serde_json::from_str(&common::to_string(&bytes));
18660                        let response = common::to_response(parts, bytes.into());
18661
18662                        if let common::Retry::After(d) =
18663                            dlg.http_failure(&response, error.as_ref().ok())
18664                        {
18665                            sleep(d).await;
18666                            continue;
18667                        }
18668
18669                        dlg.finished(false);
18670
18671                        return Err(match error {
18672                            Ok(value) => common::Error::BadRequest(value),
18673                            _ => common::Error::Failure(response),
18674                        });
18675                    }
18676                    let response = {
18677                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18678                        let encoded = common::to_string(&bytes);
18679                        match serde_json::from_str(&encoded) {
18680                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18681                            Err(error) => {
18682                                dlg.response_json_decode_error(&encoded, &error);
18683                                return Err(common::Error::JsonDecodeError(
18684                                    encoded.to_string(),
18685                                    error,
18686                                ));
18687                            }
18688                        }
18689                    };
18690
18691                    dlg.finished(true);
18692                    return Ok(response);
18693                }
18694            }
18695        }
18696    }
18697
18698    ///
18699    /// Sets the *request* property to the given value.
18700    ///
18701    /// Even though the property as already been set when instantiating this call,
18702    /// we provide this method for API completeness.
18703    pub fn request(mut self, new_value: Volume) -> ProjectLocationVolumePatchCall<'a, C> {
18704        self._request = new_value;
18705        self
18706    }
18707    /// Output only. The resource name of this `Volume`. Resource names are schemeless URIs that follow the conventions in https://cloud.google.com/apis/design/resource_names. Format: `projects/{project}/locations/{location}/volumes/{volume}`
18708    ///
18709    /// Sets the *name* path property to the given value.
18710    ///
18711    /// Even though the property as already been set when instantiating this call,
18712    /// we provide this method for API completeness.
18713    pub fn name(mut self, new_value: &str) -> ProjectLocationVolumePatchCall<'a, C> {
18714        self._name = new_value.to_string();
18715        self
18716    }
18717    /// The list of fields to update. The only currently supported fields are: 'labels'
18718    ///
18719    /// Sets the *update mask* query property to the given value.
18720    pub fn update_mask(
18721        mut self,
18722        new_value: common::FieldMask,
18723    ) -> ProjectLocationVolumePatchCall<'a, C> {
18724        self._update_mask = Some(new_value);
18725        self
18726    }
18727    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18728    /// while executing the actual API request.
18729    ///
18730    /// ````text
18731    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18732    /// ````
18733    ///
18734    /// Sets the *delegate* property to the given value.
18735    pub fn delegate(
18736        mut self,
18737        new_value: &'a mut dyn common::Delegate,
18738    ) -> ProjectLocationVolumePatchCall<'a, C> {
18739        self._delegate = Some(new_value);
18740        self
18741    }
18742
18743    /// Set any additional parameter of the query string used in the request.
18744    /// It should be used to set parameters which are not yet available through their own
18745    /// setters.
18746    ///
18747    /// Please note that this method must not be used to set any of the known parameters
18748    /// which have their own setter method. If done anyway, the request will fail.
18749    ///
18750    /// # Additional Parameters
18751    ///
18752    /// * *$.xgafv* (query-string) - V1 error format.
18753    /// * *access_token* (query-string) - OAuth access token.
18754    /// * *alt* (query-string) - Data format for response.
18755    /// * *callback* (query-string) - JSONP
18756    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18757    /// * *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.
18758    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18759    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18760    /// * *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.
18761    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18762    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18763    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumePatchCall<'a, C>
18764    where
18765        T: AsRef<str>,
18766    {
18767        self._additional_params
18768            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18769        self
18770    }
18771
18772    /// Identifies the authorization scope for the method you are building.
18773    ///
18774    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18775    /// [`Scope::CloudPlatform`].
18776    ///
18777    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18778    /// tokens for more than one scope.
18779    ///
18780    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18781    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18782    /// sufficient, a read-write scope will do as well.
18783    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumePatchCall<'a, C>
18784    where
18785        St: AsRef<str>,
18786    {
18787        self._scopes.insert(String::from(scope.as_ref()));
18788        self
18789    }
18790    /// Identifies the authorization scope(s) for the method you are building.
18791    ///
18792    /// See [`Self::add_scope()`] for details.
18793    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumePatchCall<'a, C>
18794    where
18795        I: IntoIterator<Item = St>,
18796        St: AsRef<str>,
18797    {
18798        self._scopes
18799            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18800        self
18801    }
18802
18803    /// Removes all scopes, and no default scope will be used either.
18804    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18805    /// for details).
18806    pub fn clear_scopes(mut self) -> ProjectLocationVolumePatchCall<'a, C> {
18807        self._scopes.clear();
18808        self
18809    }
18810}
18811
18812/// RenameVolume sets a new name for a volume. Use with caution, previous names become immediately invalidated.
18813///
18814/// A builder for the *locations.volumes.rename* method supported by a *project* resource.
18815/// It is not used directly, but through a [`ProjectMethods`] instance.
18816///
18817/// # Example
18818///
18819/// Instantiate a resource method builder
18820///
18821/// ```test_harness,no_run
18822/// # extern crate hyper;
18823/// # extern crate hyper_rustls;
18824/// # extern crate google_baremetalsolution2 as baremetalsolution2;
18825/// use baremetalsolution2::api::RenameVolumeRequest;
18826/// # async fn dox() {
18827/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18828///
18829/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18830/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18831/// #     .with_native_roots()
18832/// #     .unwrap()
18833/// #     .https_only()
18834/// #     .enable_http2()
18835/// #     .build();
18836///
18837/// # let executor = hyper_util::rt::TokioExecutor::new();
18838/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18839/// #     secret,
18840/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18841/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18842/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18843/// #     ),
18844/// # ).build().await.unwrap();
18845///
18846/// # let client = hyper_util::client::legacy::Client::builder(
18847/// #     hyper_util::rt::TokioExecutor::new()
18848/// # )
18849/// # .build(
18850/// #     hyper_rustls::HttpsConnectorBuilder::new()
18851/// #         .with_native_roots()
18852/// #         .unwrap()
18853/// #         .https_or_http()
18854/// #         .enable_http2()
18855/// #         .build()
18856/// # );
18857/// # let mut hub = Baremetalsolution::new(client, auth);
18858/// // As the method needs a request, you would usually fill it with the desired information
18859/// // into the respective structure. Some of the parts shown here might not be applicable !
18860/// // Values shown here are possibly random and not representative !
18861/// let mut req = RenameVolumeRequest::default();
18862///
18863/// // You can configure optional parameters by calling the respective setters at will, and
18864/// // execute the final call using `doit()`.
18865/// // Values shown here are possibly random and not representative !
18866/// let result = hub.projects().locations_volumes_rename(req, "name")
18867///              .doit().await;
18868/// # }
18869/// ```
18870pub struct ProjectLocationVolumeRenameCall<'a, C>
18871where
18872    C: 'a,
18873{
18874    hub: &'a Baremetalsolution<C>,
18875    _request: RenameVolumeRequest,
18876    _name: String,
18877    _delegate: Option<&'a mut dyn common::Delegate>,
18878    _additional_params: HashMap<String, String>,
18879    _scopes: BTreeSet<String>,
18880}
18881
18882impl<'a, C> common::CallBuilder for ProjectLocationVolumeRenameCall<'a, C> {}
18883
18884impl<'a, C> ProjectLocationVolumeRenameCall<'a, C>
18885where
18886    C: common::Connector,
18887{
18888    /// Perform the operation you have build so far.
18889    pub async fn doit(mut self) -> common::Result<(common::Response, Volume)> {
18890        use std::borrow::Cow;
18891        use std::io::{Read, Seek};
18892
18893        use common::{url::Params, ToParts};
18894        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18895
18896        let mut dd = common::DefaultDelegate;
18897        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18898        dlg.begin(common::MethodInfo {
18899            id: "baremetalsolution.projects.locations.volumes.rename",
18900            http_method: hyper::Method::POST,
18901        });
18902
18903        for &field in ["alt", "name"].iter() {
18904            if self._additional_params.contains_key(field) {
18905                dlg.finished(false);
18906                return Err(common::Error::FieldClash(field));
18907            }
18908        }
18909
18910        let mut params = Params::with_capacity(4 + self._additional_params.len());
18911        params.push("name", self._name);
18912
18913        params.extend(self._additional_params.iter());
18914
18915        params.push("alt", "json");
18916        let mut url = self.hub._base_url.clone() + "v2/{+name}:rename";
18917        if self._scopes.is_empty() {
18918            self._scopes
18919                .insert(Scope::CloudPlatform.as_ref().to_string());
18920        }
18921
18922        #[allow(clippy::single_element_loop)]
18923        for &(find_this, param_name) in [("{+name}", "name")].iter() {
18924            url = params.uri_replacement(url, param_name, find_this, true);
18925        }
18926        {
18927            let to_remove = ["name"];
18928            params.remove_params(&to_remove);
18929        }
18930
18931        let url = params.parse_with_url(&url);
18932
18933        let mut json_mime_type = mime::APPLICATION_JSON;
18934        let mut request_value_reader = {
18935            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18936            common::remove_json_null_values(&mut value);
18937            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18938            serde_json::to_writer(&mut dst, &value).unwrap();
18939            dst
18940        };
18941        let request_size = request_value_reader
18942            .seek(std::io::SeekFrom::End(0))
18943            .unwrap();
18944        request_value_reader
18945            .seek(std::io::SeekFrom::Start(0))
18946            .unwrap();
18947
18948        loop {
18949            let token = match self
18950                .hub
18951                .auth
18952                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18953                .await
18954            {
18955                Ok(token) => token,
18956                Err(e) => match dlg.token(e) {
18957                    Ok(token) => token,
18958                    Err(e) => {
18959                        dlg.finished(false);
18960                        return Err(common::Error::MissingToken(e));
18961                    }
18962                },
18963            };
18964            request_value_reader
18965                .seek(std::io::SeekFrom::Start(0))
18966                .unwrap();
18967            let mut req_result = {
18968                let client = &self.hub.client;
18969                dlg.pre_request();
18970                let mut req_builder = hyper::Request::builder()
18971                    .method(hyper::Method::POST)
18972                    .uri(url.as_str())
18973                    .header(USER_AGENT, self.hub._user_agent.clone());
18974
18975                if let Some(token) = token.as_ref() {
18976                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18977                }
18978
18979                let request = req_builder
18980                    .header(CONTENT_TYPE, json_mime_type.to_string())
18981                    .header(CONTENT_LENGTH, request_size as u64)
18982                    .body(common::to_body(
18983                        request_value_reader.get_ref().clone().into(),
18984                    ));
18985
18986                client.request(request.unwrap()).await
18987            };
18988
18989            match req_result {
18990                Err(err) => {
18991                    if let common::Retry::After(d) = dlg.http_error(&err) {
18992                        sleep(d).await;
18993                        continue;
18994                    }
18995                    dlg.finished(false);
18996                    return Err(common::Error::HttpError(err));
18997                }
18998                Ok(res) => {
18999                    let (mut parts, body) = res.into_parts();
19000                    let mut body = common::Body::new(body);
19001                    if !parts.status.is_success() {
19002                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19003                        let error = serde_json::from_str(&common::to_string(&bytes));
19004                        let response = common::to_response(parts, bytes.into());
19005
19006                        if let common::Retry::After(d) =
19007                            dlg.http_failure(&response, error.as_ref().ok())
19008                        {
19009                            sleep(d).await;
19010                            continue;
19011                        }
19012
19013                        dlg.finished(false);
19014
19015                        return Err(match error {
19016                            Ok(value) => common::Error::BadRequest(value),
19017                            _ => common::Error::Failure(response),
19018                        });
19019                    }
19020                    let response = {
19021                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19022                        let encoded = common::to_string(&bytes);
19023                        match serde_json::from_str(&encoded) {
19024                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19025                            Err(error) => {
19026                                dlg.response_json_decode_error(&encoded, &error);
19027                                return Err(common::Error::JsonDecodeError(
19028                                    encoded.to_string(),
19029                                    error,
19030                                ));
19031                            }
19032                        }
19033                    };
19034
19035                    dlg.finished(true);
19036                    return Ok(response);
19037                }
19038            }
19039        }
19040    }
19041
19042    ///
19043    /// Sets the *request* property to the given value.
19044    ///
19045    /// Even though the property as already been set when instantiating this call,
19046    /// we provide this method for API completeness.
19047    pub fn request(
19048        mut self,
19049        new_value: RenameVolumeRequest,
19050    ) -> ProjectLocationVolumeRenameCall<'a, C> {
19051        self._request = new_value;
19052        self
19053    }
19054    /// Required. The `name` field is used to identify the volume. Format: projects/{project}/locations/{location}/volumes/{volume}
19055    ///
19056    /// Sets the *name* path property to the given value.
19057    ///
19058    /// Even though the property as already been set when instantiating this call,
19059    /// we provide this method for API completeness.
19060    pub fn name(mut self, new_value: &str) -> ProjectLocationVolumeRenameCall<'a, C> {
19061        self._name = new_value.to_string();
19062        self
19063    }
19064    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19065    /// while executing the actual API request.
19066    ///
19067    /// ````text
19068    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19069    /// ````
19070    ///
19071    /// Sets the *delegate* property to the given value.
19072    pub fn delegate(
19073        mut self,
19074        new_value: &'a mut dyn common::Delegate,
19075    ) -> ProjectLocationVolumeRenameCall<'a, C> {
19076        self._delegate = Some(new_value);
19077        self
19078    }
19079
19080    /// Set any additional parameter of the query string used in the request.
19081    /// It should be used to set parameters which are not yet available through their own
19082    /// setters.
19083    ///
19084    /// Please note that this method must not be used to set any of the known parameters
19085    /// which have their own setter method. If done anyway, the request will fail.
19086    ///
19087    /// # Additional Parameters
19088    ///
19089    /// * *$.xgafv* (query-string) - V1 error format.
19090    /// * *access_token* (query-string) - OAuth access token.
19091    /// * *alt* (query-string) - Data format for response.
19092    /// * *callback* (query-string) - JSONP
19093    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19094    /// * *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.
19095    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19096    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19097    /// * *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.
19098    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19099    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19100    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeRenameCall<'a, C>
19101    where
19102        T: AsRef<str>,
19103    {
19104        self._additional_params
19105            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19106        self
19107    }
19108
19109    /// Identifies the authorization scope for the method you are building.
19110    ///
19111    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19112    /// [`Scope::CloudPlatform`].
19113    ///
19114    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19115    /// tokens for more than one scope.
19116    ///
19117    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19118    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19119    /// sufficient, a read-write scope will do as well.
19120    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeRenameCall<'a, C>
19121    where
19122        St: AsRef<str>,
19123    {
19124        self._scopes.insert(String::from(scope.as_ref()));
19125        self
19126    }
19127    /// Identifies the authorization scope(s) for the method you are building.
19128    ///
19129    /// See [`Self::add_scope()`] for details.
19130    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeRenameCall<'a, C>
19131    where
19132        I: IntoIterator<Item = St>,
19133        St: AsRef<str>,
19134    {
19135        self._scopes
19136            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19137        self
19138    }
19139
19140    /// Removes all scopes, and no default scope will be used either.
19141    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19142    /// for details).
19143    pub fn clear_scopes(mut self) -> ProjectLocationVolumeRenameCall<'a, C> {
19144        self._scopes.clear();
19145        self
19146    }
19147}
19148
19149/// Emergency Volume resize.
19150///
19151/// A builder for the *locations.volumes.resize* method supported by a *project* resource.
19152/// It is not used directly, but through a [`ProjectMethods`] instance.
19153///
19154/// # Example
19155///
19156/// Instantiate a resource method builder
19157///
19158/// ```test_harness,no_run
19159/// # extern crate hyper;
19160/// # extern crate hyper_rustls;
19161/// # extern crate google_baremetalsolution2 as baremetalsolution2;
19162/// use baremetalsolution2::api::ResizeVolumeRequest;
19163/// # async fn dox() {
19164/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19165///
19166/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19167/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19168/// #     .with_native_roots()
19169/// #     .unwrap()
19170/// #     .https_only()
19171/// #     .enable_http2()
19172/// #     .build();
19173///
19174/// # let executor = hyper_util::rt::TokioExecutor::new();
19175/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19176/// #     secret,
19177/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19178/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19179/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19180/// #     ),
19181/// # ).build().await.unwrap();
19182///
19183/// # let client = hyper_util::client::legacy::Client::builder(
19184/// #     hyper_util::rt::TokioExecutor::new()
19185/// # )
19186/// # .build(
19187/// #     hyper_rustls::HttpsConnectorBuilder::new()
19188/// #         .with_native_roots()
19189/// #         .unwrap()
19190/// #         .https_or_http()
19191/// #         .enable_http2()
19192/// #         .build()
19193/// # );
19194/// # let mut hub = Baremetalsolution::new(client, auth);
19195/// // As the method needs a request, you would usually fill it with the desired information
19196/// // into the respective structure. Some of the parts shown here might not be applicable !
19197/// // Values shown here are possibly random and not representative !
19198/// let mut req = ResizeVolumeRequest::default();
19199///
19200/// // You can configure optional parameters by calling the respective setters at will, and
19201/// // execute the final call using `doit()`.
19202/// // Values shown here are possibly random and not representative !
19203/// let result = hub.projects().locations_volumes_resize(req, "volume")
19204///              .doit().await;
19205/// # }
19206/// ```
19207pub struct ProjectLocationVolumeResizeCall<'a, C>
19208where
19209    C: 'a,
19210{
19211    hub: &'a Baremetalsolution<C>,
19212    _request: ResizeVolumeRequest,
19213    _volume: String,
19214    _delegate: Option<&'a mut dyn common::Delegate>,
19215    _additional_params: HashMap<String, String>,
19216    _scopes: BTreeSet<String>,
19217}
19218
19219impl<'a, C> common::CallBuilder for ProjectLocationVolumeResizeCall<'a, C> {}
19220
19221impl<'a, C> ProjectLocationVolumeResizeCall<'a, C>
19222where
19223    C: common::Connector,
19224{
19225    /// Perform the operation you have build so far.
19226    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
19227        use std::borrow::Cow;
19228        use std::io::{Read, Seek};
19229
19230        use common::{url::Params, ToParts};
19231        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19232
19233        let mut dd = common::DefaultDelegate;
19234        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19235        dlg.begin(common::MethodInfo {
19236            id: "baremetalsolution.projects.locations.volumes.resize",
19237            http_method: hyper::Method::POST,
19238        });
19239
19240        for &field in ["alt", "volume"].iter() {
19241            if self._additional_params.contains_key(field) {
19242                dlg.finished(false);
19243                return Err(common::Error::FieldClash(field));
19244            }
19245        }
19246
19247        let mut params = Params::with_capacity(4 + self._additional_params.len());
19248        params.push("volume", self._volume);
19249
19250        params.extend(self._additional_params.iter());
19251
19252        params.push("alt", "json");
19253        let mut url = self.hub._base_url.clone() + "v2/{+volume}:resize";
19254        if self._scopes.is_empty() {
19255            self._scopes
19256                .insert(Scope::CloudPlatform.as_ref().to_string());
19257        }
19258
19259        #[allow(clippy::single_element_loop)]
19260        for &(find_this, param_name) in [("{+volume}", "volume")].iter() {
19261            url = params.uri_replacement(url, param_name, find_this, true);
19262        }
19263        {
19264            let to_remove = ["volume"];
19265            params.remove_params(&to_remove);
19266        }
19267
19268        let url = params.parse_with_url(&url);
19269
19270        let mut json_mime_type = mime::APPLICATION_JSON;
19271        let mut request_value_reader = {
19272            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19273            common::remove_json_null_values(&mut value);
19274            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19275            serde_json::to_writer(&mut dst, &value).unwrap();
19276            dst
19277        };
19278        let request_size = request_value_reader
19279            .seek(std::io::SeekFrom::End(0))
19280            .unwrap();
19281        request_value_reader
19282            .seek(std::io::SeekFrom::Start(0))
19283            .unwrap();
19284
19285        loop {
19286            let token = match self
19287                .hub
19288                .auth
19289                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19290                .await
19291            {
19292                Ok(token) => token,
19293                Err(e) => match dlg.token(e) {
19294                    Ok(token) => token,
19295                    Err(e) => {
19296                        dlg.finished(false);
19297                        return Err(common::Error::MissingToken(e));
19298                    }
19299                },
19300            };
19301            request_value_reader
19302                .seek(std::io::SeekFrom::Start(0))
19303                .unwrap();
19304            let mut req_result = {
19305                let client = &self.hub.client;
19306                dlg.pre_request();
19307                let mut req_builder = hyper::Request::builder()
19308                    .method(hyper::Method::POST)
19309                    .uri(url.as_str())
19310                    .header(USER_AGENT, self.hub._user_agent.clone());
19311
19312                if let Some(token) = token.as_ref() {
19313                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19314                }
19315
19316                let request = req_builder
19317                    .header(CONTENT_TYPE, json_mime_type.to_string())
19318                    .header(CONTENT_LENGTH, request_size as u64)
19319                    .body(common::to_body(
19320                        request_value_reader.get_ref().clone().into(),
19321                    ));
19322
19323                client.request(request.unwrap()).await
19324            };
19325
19326            match req_result {
19327                Err(err) => {
19328                    if let common::Retry::After(d) = dlg.http_error(&err) {
19329                        sleep(d).await;
19330                        continue;
19331                    }
19332                    dlg.finished(false);
19333                    return Err(common::Error::HttpError(err));
19334                }
19335                Ok(res) => {
19336                    let (mut parts, body) = res.into_parts();
19337                    let mut body = common::Body::new(body);
19338                    if !parts.status.is_success() {
19339                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19340                        let error = serde_json::from_str(&common::to_string(&bytes));
19341                        let response = common::to_response(parts, bytes.into());
19342
19343                        if let common::Retry::After(d) =
19344                            dlg.http_failure(&response, error.as_ref().ok())
19345                        {
19346                            sleep(d).await;
19347                            continue;
19348                        }
19349
19350                        dlg.finished(false);
19351
19352                        return Err(match error {
19353                            Ok(value) => common::Error::BadRequest(value),
19354                            _ => common::Error::Failure(response),
19355                        });
19356                    }
19357                    let response = {
19358                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19359                        let encoded = common::to_string(&bytes);
19360                        match serde_json::from_str(&encoded) {
19361                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19362                            Err(error) => {
19363                                dlg.response_json_decode_error(&encoded, &error);
19364                                return Err(common::Error::JsonDecodeError(
19365                                    encoded.to_string(),
19366                                    error,
19367                                ));
19368                            }
19369                        }
19370                    };
19371
19372                    dlg.finished(true);
19373                    return Ok(response);
19374                }
19375            }
19376        }
19377    }
19378
19379    ///
19380    /// Sets the *request* property to the given value.
19381    ///
19382    /// Even though the property as already been set when instantiating this call,
19383    /// we provide this method for API completeness.
19384    pub fn request(
19385        mut self,
19386        new_value: ResizeVolumeRequest,
19387    ) -> ProjectLocationVolumeResizeCall<'a, C> {
19388        self._request = new_value;
19389        self
19390    }
19391    /// Required. Volume to resize.
19392    ///
19393    /// Sets the *volume* path property to the given value.
19394    ///
19395    /// Even though the property as already been set when instantiating this call,
19396    /// we provide this method for API completeness.
19397    pub fn volume(mut self, new_value: &str) -> ProjectLocationVolumeResizeCall<'a, C> {
19398        self._volume = new_value.to_string();
19399        self
19400    }
19401    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19402    /// while executing the actual API request.
19403    ///
19404    /// ````text
19405    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19406    /// ````
19407    ///
19408    /// Sets the *delegate* property to the given value.
19409    pub fn delegate(
19410        mut self,
19411        new_value: &'a mut dyn common::Delegate,
19412    ) -> ProjectLocationVolumeResizeCall<'a, C> {
19413        self._delegate = Some(new_value);
19414        self
19415    }
19416
19417    /// Set any additional parameter of the query string used in the request.
19418    /// It should be used to set parameters which are not yet available through their own
19419    /// setters.
19420    ///
19421    /// Please note that this method must not be used to set any of the known parameters
19422    /// which have their own setter method. If done anyway, the request will fail.
19423    ///
19424    /// # Additional Parameters
19425    ///
19426    /// * *$.xgafv* (query-string) - V1 error format.
19427    /// * *access_token* (query-string) - OAuth access token.
19428    /// * *alt* (query-string) - Data format for response.
19429    /// * *callback* (query-string) - JSONP
19430    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19431    /// * *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.
19432    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19433    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19434    /// * *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.
19435    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19436    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19437    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeResizeCall<'a, C>
19438    where
19439        T: AsRef<str>,
19440    {
19441        self._additional_params
19442            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19443        self
19444    }
19445
19446    /// Identifies the authorization scope for the method you are building.
19447    ///
19448    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19449    /// [`Scope::CloudPlatform`].
19450    ///
19451    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19452    /// tokens for more than one scope.
19453    ///
19454    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19455    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19456    /// sufficient, a read-write scope will do as well.
19457    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeResizeCall<'a, C>
19458    where
19459        St: AsRef<str>,
19460    {
19461        self._scopes.insert(String::from(scope.as_ref()));
19462        self
19463    }
19464    /// Identifies the authorization scope(s) for the method you are building.
19465    ///
19466    /// See [`Self::add_scope()`] for details.
19467    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeResizeCall<'a, C>
19468    where
19469        I: IntoIterator<Item = St>,
19470        St: AsRef<str>,
19471    {
19472        self._scopes
19473            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19474        self
19475    }
19476
19477    /// Removes all scopes, and no default scope will be used either.
19478    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19479    /// for details).
19480    pub fn clear_scopes(mut self) -> ProjectLocationVolumeResizeCall<'a, C> {
19481        self._scopes.clear();
19482        self
19483    }
19484}
19485
19486/// Gets information about a location.
19487///
19488/// A builder for the *locations.get* method supported by a *project* resource.
19489/// It is not used directly, but through a [`ProjectMethods`] instance.
19490///
19491/// # Example
19492///
19493/// Instantiate a resource method builder
19494///
19495/// ```test_harness,no_run
19496/// # extern crate hyper;
19497/// # extern crate hyper_rustls;
19498/// # extern crate google_baremetalsolution2 as baremetalsolution2;
19499/// # async fn dox() {
19500/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19501///
19502/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19503/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19504/// #     .with_native_roots()
19505/// #     .unwrap()
19506/// #     .https_only()
19507/// #     .enable_http2()
19508/// #     .build();
19509///
19510/// # let executor = hyper_util::rt::TokioExecutor::new();
19511/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19512/// #     secret,
19513/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19514/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19515/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19516/// #     ),
19517/// # ).build().await.unwrap();
19518///
19519/// # let client = hyper_util::client::legacy::Client::builder(
19520/// #     hyper_util::rt::TokioExecutor::new()
19521/// # )
19522/// # .build(
19523/// #     hyper_rustls::HttpsConnectorBuilder::new()
19524/// #         .with_native_roots()
19525/// #         .unwrap()
19526/// #         .https_or_http()
19527/// #         .enable_http2()
19528/// #         .build()
19529/// # );
19530/// # let mut hub = Baremetalsolution::new(client, auth);
19531/// // You can configure optional parameters by calling the respective setters at will, and
19532/// // execute the final call using `doit()`.
19533/// // Values shown here are possibly random and not representative !
19534/// let result = hub.projects().locations_get("name")
19535///              .doit().await;
19536/// # }
19537/// ```
19538pub struct ProjectLocationGetCall<'a, C>
19539where
19540    C: 'a,
19541{
19542    hub: &'a Baremetalsolution<C>,
19543    _name: String,
19544    _delegate: Option<&'a mut dyn common::Delegate>,
19545    _additional_params: HashMap<String, String>,
19546    _scopes: BTreeSet<String>,
19547}
19548
19549impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
19550
19551impl<'a, C> ProjectLocationGetCall<'a, C>
19552where
19553    C: common::Connector,
19554{
19555    /// Perform the operation you have build so far.
19556    pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
19557        use std::borrow::Cow;
19558        use std::io::{Read, Seek};
19559
19560        use common::{url::Params, ToParts};
19561        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19562
19563        let mut dd = common::DefaultDelegate;
19564        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19565        dlg.begin(common::MethodInfo {
19566            id: "baremetalsolution.projects.locations.get",
19567            http_method: hyper::Method::GET,
19568        });
19569
19570        for &field in ["alt", "name"].iter() {
19571            if self._additional_params.contains_key(field) {
19572                dlg.finished(false);
19573                return Err(common::Error::FieldClash(field));
19574            }
19575        }
19576
19577        let mut params = Params::with_capacity(3 + self._additional_params.len());
19578        params.push("name", self._name);
19579
19580        params.extend(self._additional_params.iter());
19581
19582        params.push("alt", "json");
19583        let mut url = self.hub._base_url.clone() + "v2/{+name}";
19584        if self._scopes.is_empty() {
19585            self._scopes
19586                .insert(Scope::CloudPlatform.as_ref().to_string());
19587        }
19588
19589        #[allow(clippy::single_element_loop)]
19590        for &(find_this, param_name) in [("{+name}", "name")].iter() {
19591            url = params.uri_replacement(url, param_name, find_this, true);
19592        }
19593        {
19594            let to_remove = ["name"];
19595            params.remove_params(&to_remove);
19596        }
19597
19598        let url = params.parse_with_url(&url);
19599
19600        loop {
19601            let token = match self
19602                .hub
19603                .auth
19604                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19605                .await
19606            {
19607                Ok(token) => token,
19608                Err(e) => match dlg.token(e) {
19609                    Ok(token) => token,
19610                    Err(e) => {
19611                        dlg.finished(false);
19612                        return Err(common::Error::MissingToken(e));
19613                    }
19614                },
19615            };
19616            let mut req_result = {
19617                let client = &self.hub.client;
19618                dlg.pre_request();
19619                let mut req_builder = hyper::Request::builder()
19620                    .method(hyper::Method::GET)
19621                    .uri(url.as_str())
19622                    .header(USER_AGENT, self.hub._user_agent.clone());
19623
19624                if let Some(token) = token.as_ref() {
19625                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19626                }
19627
19628                let request = req_builder
19629                    .header(CONTENT_LENGTH, 0_u64)
19630                    .body(common::to_body::<String>(None));
19631
19632                client.request(request.unwrap()).await
19633            };
19634
19635            match req_result {
19636                Err(err) => {
19637                    if let common::Retry::After(d) = dlg.http_error(&err) {
19638                        sleep(d).await;
19639                        continue;
19640                    }
19641                    dlg.finished(false);
19642                    return Err(common::Error::HttpError(err));
19643                }
19644                Ok(res) => {
19645                    let (mut parts, body) = res.into_parts();
19646                    let mut body = common::Body::new(body);
19647                    if !parts.status.is_success() {
19648                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19649                        let error = serde_json::from_str(&common::to_string(&bytes));
19650                        let response = common::to_response(parts, bytes.into());
19651
19652                        if let common::Retry::After(d) =
19653                            dlg.http_failure(&response, error.as_ref().ok())
19654                        {
19655                            sleep(d).await;
19656                            continue;
19657                        }
19658
19659                        dlg.finished(false);
19660
19661                        return Err(match error {
19662                            Ok(value) => common::Error::BadRequest(value),
19663                            _ => common::Error::Failure(response),
19664                        });
19665                    }
19666                    let response = {
19667                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19668                        let encoded = common::to_string(&bytes);
19669                        match serde_json::from_str(&encoded) {
19670                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19671                            Err(error) => {
19672                                dlg.response_json_decode_error(&encoded, &error);
19673                                return Err(common::Error::JsonDecodeError(
19674                                    encoded.to_string(),
19675                                    error,
19676                                ));
19677                            }
19678                        }
19679                    };
19680
19681                    dlg.finished(true);
19682                    return Ok(response);
19683                }
19684            }
19685        }
19686    }
19687
19688    /// Resource name for the location.
19689    ///
19690    /// Sets the *name* path property to the given value.
19691    ///
19692    /// Even though the property as already been set when instantiating this call,
19693    /// we provide this method for API completeness.
19694    pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
19695        self._name = new_value.to_string();
19696        self
19697    }
19698    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19699    /// while executing the actual API request.
19700    ///
19701    /// ````text
19702    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19703    /// ````
19704    ///
19705    /// Sets the *delegate* property to the given value.
19706    pub fn delegate(
19707        mut self,
19708        new_value: &'a mut dyn common::Delegate,
19709    ) -> ProjectLocationGetCall<'a, C> {
19710        self._delegate = Some(new_value);
19711        self
19712    }
19713
19714    /// Set any additional parameter of the query string used in the request.
19715    /// It should be used to set parameters which are not yet available through their own
19716    /// setters.
19717    ///
19718    /// Please note that this method must not be used to set any of the known parameters
19719    /// which have their own setter method. If done anyway, the request will fail.
19720    ///
19721    /// # Additional Parameters
19722    ///
19723    /// * *$.xgafv* (query-string) - V1 error format.
19724    /// * *access_token* (query-string) - OAuth access token.
19725    /// * *alt* (query-string) - Data format for response.
19726    /// * *callback* (query-string) - JSONP
19727    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19728    /// * *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.
19729    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19730    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19731    /// * *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.
19732    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19733    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19734    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
19735    where
19736        T: AsRef<str>,
19737    {
19738        self._additional_params
19739            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19740        self
19741    }
19742
19743    /// Identifies the authorization scope for the method you are building.
19744    ///
19745    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19746    /// [`Scope::CloudPlatform`].
19747    ///
19748    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19749    /// tokens for more than one scope.
19750    ///
19751    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19752    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19753    /// sufficient, a read-write scope will do as well.
19754    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
19755    where
19756        St: AsRef<str>,
19757    {
19758        self._scopes.insert(String::from(scope.as_ref()));
19759        self
19760    }
19761    /// Identifies the authorization scope(s) for the method you are building.
19762    ///
19763    /// See [`Self::add_scope()`] for details.
19764    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
19765    where
19766        I: IntoIterator<Item = St>,
19767        St: AsRef<str>,
19768    {
19769        self._scopes
19770            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19771        self
19772    }
19773
19774    /// Removes all scopes, and no default scope will be used either.
19775    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19776    /// for details).
19777    pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
19778        self._scopes.clear();
19779        self
19780    }
19781}
19782
19783/// Lists information about the supported locations for this service.
19784///
19785/// A builder for the *locations.list* method supported by a *project* resource.
19786/// It is not used directly, but through a [`ProjectMethods`] instance.
19787///
19788/// # Example
19789///
19790/// Instantiate a resource method builder
19791///
19792/// ```test_harness,no_run
19793/// # extern crate hyper;
19794/// # extern crate hyper_rustls;
19795/// # extern crate google_baremetalsolution2 as baremetalsolution2;
19796/// # async fn dox() {
19797/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19798///
19799/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19800/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19801/// #     .with_native_roots()
19802/// #     .unwrap()
19803/// #     .https_only()
19804/// #     .enable_http2()
19805/// #     .build();
19806///
19807/// # let executor = hyper_util::rt::TokioExecutor::new();
19808/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19809/// #     secret,
19810/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19811/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19812/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19813/// #     ),
19814/// # ).build().await.unwrap();
19815///
19816/// # let client = hyper_util::client::legacy::Client::builder(
19817/// #     hyper_util::rt::TokioExecutor::new()
19818/// # )
19819/// # .build(
19820/// #     hyper_rustls::HttpsConnectorBuilder::new()
19821/// #         .with_native_roots()
19822/// #         .unwrap()
19823/// #         .https_or_http()
19824/// #         .enable_http2()
19825/// #         .build()
19826/// # );
19827/// # let mut hub = Baremetalsolution::new(client, auth);
19828/// // You can configure optional parameters by calling the respective setters at will, and
19829/// // execute the final call using `doit()`.
19830/// // Values shown here are possibly random and not representative !
19831/// let result = hub.projects().locations_list("name")
19832///              .page_token("erat")
19833///              .page_size(-96)
19834///              .filter("amet.")
19835///              .add_extra_location_types("sed")
19836///              .doit().await;
19837/// # }
19838/// ```
19839pub struct ProjectLocationListCall<'a, C>
19840where
19841    C: 'a,
19842{
19843    hub: &'a Baremetalsolution<C>,
19844    _name: String,
19845    _page_token: Option<String>,
19846    _page_size: Option<i32>,
19847    _filter: Option<String>,
19848    _extra_location_types: Vec<String>,
19849    _delegate: Option<&'a mut dyn common::Delegate>,
19850    _additional_params: HashMap<String, String>,
19851    _scopes: BTreeSet<String>,
19852}
19853
19854impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
19855
19856impl<'a, C> ProjectLocationListCall<'a, C>
19857where
19858    C: common::Connector,
19859{
19860    /// Perform the operation you have build so far.
19861    pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
19862        use std::borrow::Cow;
19863        use std::io::{Read, Seek};
19864
19865        use common::{url::Params, ToParts};
19866        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19867
19868        let mut dd = common::DefaultDelegate;
19869        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19870        dlg.begin(common::MethodInfo {
19871            id: "baremetalsolution.projects.locations.list",
19872            http_method: hyper::Method::GET,
19873        });
19874
19875        for &field in [
19876            "alt",
19877            "name",
19878            "pageToken",
19879            "pageSize",
19880            "filter",
19881            "extraLocationTypes",
19882        ]
19883        .iter()
19884        {
19885            if self._additional_params.contains_key(field) {
19886                dlg.finished(false);
19887                return Err(common::Error::FieldClash(field));
19888            }
19889        }
19890
19891        let mut params = Params::with_capacity(7 + self._additional_params.len());
19892        params.push("name", self._name);
19893        if let Some(value) = self._page_token.as_ref() {
19894            params.push("pageToken", value);
19895        }
19896        if let Some(value) = self._page_size.as_ref() {
19897            params.push("pageSize", value.to_string());
19898        }
19899        if let Some(value) = self._filter.as_ref() {
19900            params.push("filter", value);
19901        }
19902        if !self._extra_location_types.is_empty() {
19903            for f in self._extra_location_types.iter() {
19904                params.push("extraLocationTypes", f);
19905            }
19906        }
19907
19908        params.extend(self._additional_params.iter());
19909
19910        params.push("alt", "json");
19911        let mut url = self.hub._base_url.clone() + "v2/{+name}/locations";
19912        if self._scopes.is_empty() {
19913            self._scopes
19914                .insert(Scope::CloudPlatform.as_ref().to_string());
19915        }
19916
19917        #[allow(clippy::single_element_loop)]
19918        for &(find_this, param_name) in [("{+name}", "name")].iter() {
19919            url = params.uri_replacement(url, param_name, find_this, true);
19920        }
19921        {
19922            let to_remove = ["name"];
19923            params.remove_params(&to_remove);
19924        }
19925
19926        let url = params.parse_with_url(&url);
19927
19928        loop {
19929            let token = match self
19930                .hub
19931                .auth
19932                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19933                .await
19934            {
19935                Ok(token) => token,
19936                Err(e) => match dlg.token(e) {
19937                    Ok(token) => token,
19938                    Err(e) => {
19939                        dlg.finished(false);
19940                        return Err(common::Error::MissingToken(e));
19941                    }
19942                },
19943            };
19944            let mut req_result = {
19945                let client = &self.hub.client;
19946                dlg.pre_request();
19947                let mut req_builder = hyper::Request::builder()
19948                    .method(hyper::Method::GET)
19949                    .uri(url.as_str())
19950                    .header(USER_AGENT, self.hub._user_agent.clone());
19951
19952                if let Some(token) = token.as_ref() {
19953                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19954                }
19955
19956                let request = req_builder
19957                    .header(CONTENT_LENGTH, 0_u64)
19958                    .body(common::to_body::<String>(None));
19959
19960                client.request(request.unwrap()).await
19961            };
19962
19963            match req_result {
19964                Err(err) => {
19965                    if let common::Retry::After(d) = dlg.http_error(&err) {
19966                        sleep(d).await;
19967                        continue;
19968                    }
19969                    dlg.finished(false);
19970                    return Err(common::Error::HttpError(err));
19971                }
19972                Ok(res) => {
19973                    let (mut parts, body) = res.into_parts();
19974                    let mut body = common::Body::new(body);
19975                    if !parts.status.is_success() {
19976                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19977                        let error = serde_json::from_str(&common::to_string(&bytes));
19978                        let response = common::to_response(parts, bytes.into());
19979
19980                        if let common::Retry::After(d) =
19981                            dlg.http_failure(&response, error.as_ref().ok())
19982                        {
19983                            sleep(d).await;
19984                            continue;
19985                        }
19986
19987                        dlg.finished(false);
19988
19989                        return Err(match error {
19990                            Ok(value) => common::Error::BadRequest(value),
19991                            _ => common::Error::Failure(response),
19992                        });
19993                    }
19994                    let response = {
19995                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19996                        let encoded = common::to_string(&bytes);
19997                        match serde_json::from_str(&encoded) {
19998                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19999                            Err(error) => {
20000                                dlg.response_json_decode_error(&encoded, &error);
20001                                return Err(common::Error::JsonDecodeError(
20002                                    encoded.to_string(),
20003                                    error,
20004                                ));
20005                            }
20006                        }
20007                    };
20008
20009                    dlg.finished(true);
20010                    return Ok(response);
20011                }
20012            }
20013        }
20014    }
20015
20016    /// The resource that owns the locations collection, if applicable.
20017    ///
20018    /// Sets the *name* path property to the given value.
20019    ///
20020    /// Even though the property as already been set when instantiating this call,
20021    /// we provide this method for API completeness.
20022    pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
20023        self._name = new_value.to_string();
20024        self
20025    }
20026    /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
20027    ///
20028    /// Sets the *page token* query property to the given value.
20029    pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
20030        self._page_token = Some(new_value.to_string());
20031        self
20032    }
20033    /// The maximum number of results to return. If not set, the service selects a default.
20034    ///
20035    /// Sets the *page size* query property to the given value.
20036    pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
20037        self._page_size = Some(new_value);
20038        self
20039    }
20040    /// 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).
20041    ///
20042    /// Sets the *filter* query property to the given value.
20043    pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
20044        self._filter = Some(new_value.to_string());
20045        self
20046    }
20047    /// Optional. Unless explicitly documented otherwise, don't use this unsupported field which is primarily intended for internal usage.
20048    ///
20049    /// Append the given value to the *extra location types* query property.
20050    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
20051    pub fn add_extra_location_types(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
20052        self._extra_location_types.push(new_value.to_string());
20053        self
20054    }
20055    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20056    /// while executing the actual API request.
20057    ///
20058    /// ````text
20059    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20060    /// ````
20061    ///
20062    /// Sets the *delegate* property to the given value.
20063    pub fn delegate(
20064        mut self,
20065        new_value: &'a mut dyn common::Delegate,
20066    ) -> ProjectLocationListCall<'a, C> {
20067        self._delegate = Some(new_value);
20068        self
20069    }
20070
20071    /// Set any additional parameter of the query string used in the request.
20072    /// It should be used to set parameters which are not yet available through their own
20073    /// setters.
20074    ///
20075    /// Please note that this method must not be used to set any of the known parameters
20076    /// which have their own setter method. If done anyway, the request will fail.
20077    ///
20078    /// # Additional Parameters
20079    ///
20080    /// * *$.xgafv* (query-string) - V1 error format.
20081    /// * *access_token* (query-string) - OAuth access token.
20082    /// * *alt* (query-string) - Data format for response.
20083    /// * *callback* (query-string) - JSONP
20084    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20085    /// * *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.
20086    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20087    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20088    /// * *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.
20089    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20090    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20091    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
20092    where
20093        T: AsRef<str>,
20094    {
20095        self._additional_params
20096            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20097        self
20098    }
20099
20100    /// Identifies the authorization scope for the method you are building.
20101    ///
20102    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20103    /// [`Scope::CloudPlatform`].
20104    ///
20105    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20106    /// tokens for more than one scope.
20107    ///
20108    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20109    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20110    /// sufficient, a read-write scope will do as well.
20111    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
20112    where
20113        St: AsRef<str>,
20114    {
20115        self._scopes.insert(String::from(scope.as_ref()));
20116        self
20117    }
20118    /// Identifies the authorization scope(s) for the method you are building.
20119    ///
20120    /// See [`Self::add_scope()`] for details.
20121    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
20122    where
20123        I: IntoIterator<Item = St>,
20124        St: AsRef<str>,
20125    {
20126        self._scopes
20127            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20128        self
20129    }
20130
20131    /// Removes all scopes, and no default scope will be used either.
20132    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20133    /// for details).
20134    pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
20135        self._scopes.clear();
20136        self
20137    }
20138}