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 auth = yup_oauth2::InstalledFlowAuthenticator::builder(
63/// secret,
64/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
65/// ).build().await.unwrap();
66///
67/// let client = hyper_util::client::legacy::Client::builder(
68/// hyper_util::rt::TokioExecutor::new()
69/// )
70/// .build(
71/// hyper_rustls::HttpsConnectorBuilder::new()
72/// .with_native_roots()
73/// .unwrap()
74/// .https_or_http()
75/// .enable_http1()
76/// .build()
77/// );
78/// let mut hub = Baremetalsolution::new(client, auth);
79/// // As the method needs a request, you would usually fill it with the desired information
80/// // into the respective structure. Some of the parts shown here might not be applicable !
81/// // Values shown here are possibly random and not representative !
82/// let mut req = Instance::default();
83///
84/// // You can configure optional parameters by calling the respective setters at will, and
85/// // execute the final call using `doit()`.
86/// // Values shown here are possibly random and not representative !
87/// let result = hub.projects().locations_instances_patch(req, "name")
88/// .update_mask(FieldMask::new::<&str>(&[]))
89/// .doit().await;
90///
91/// match result {
92/// Err(e) => match e {
93/// // The Error enum provides details about what exactly happened.
94/// // You can also just use its `Debug`, `Display` or `Error` traits
95/// Error::HttpError(_)
96/// |Error::Io(_)
97/// |Error::MissingAPIKey
98/// |Error::MissingToken(_)
99/// |Error::Cancelled
100/// |Error::UploadSizeLimitExceeded(_, _)
101/// |Error::Failure(_)
102/// |Error::BadRequest(_)
103/// |Error::FieldClash(_)
104/// |Error::JsonDecodeError(_, _) => println!("{}", e),
105/// },
106/// Ok(res) => println!("Success: {:?}", res),
107/// }
108/// # }
109/// ```
110#[derive(Clone)]
111pub struct Baremetalsolution<C> {
112 pub client: common::Client<C>,
113 pub auth: Box<dyn common::GetToken>,
114 _user_agent: String,
115 _base_url: String,
116 _root_url: String,
117}
118
119impl<C> common::Hub for Baremetalsolution<C> {}
120
121impl<'a, C> Baremetalsolution<C> {
122 pub fn new<A: 'static + common::GetToken>(
123 client: common::Client<C>,
124 auth: A,
125 ) -> Baremetalsolution<C> {
126 Baremetalsolution {
127 client,
128 auth: Box::new(auth),
129 _user_agent: "google-api-rust-client/6.0.0".to_string(),
130 _base_url: "https://baremetalsolution.googleapis.com/".to_string(),
131 _root_url: "https://baremetalsolution.googleapis.com/".to_string(),
132 }
133 }
134
135 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
136 ProjectMethods { hub: self }
137 }
138
139 /// Set the user-agent header field to use in all requests to the server.
140 /// It defaults to `google-api-rust-client/6.0.0`.
141 ///
142 /// Returns the previously set user-agent.
143 pub fn user_agent(&mut self, agent_name: String) -> String {
144 std::mem::replace(&mut self._user_agent, agent_name)
145 }
146
147 /// Set the base url to use in all requests to the server.
148 /// It defaults to `https://baremetalsolution.googleapis.com/`.
149 ///
150 /// Returns the previously set base url.
151 pub fn base_url(&mut self, new_base_url: String) -> String {
152 std::mem::replace(&mut self._base_url, new_base_url)
153 }
154
155 /// Set the root url to use in all requests to the server.
156 /// It defaults to `https://baremetalsolution.googleapis.com/`.
157 ///
158 /// Returns the previously set root url.
159 pub fn root_url(&mut self, new_root_url: String) -> String {
160 std::mem::replace(&mut self._root_url, new_root_url)
161 }
162}
163
164// ############
165// SCHEMAS ###
166// ##########
167/// Represents an 'access point' for the share.
168///
169/// This type is not used in any activity, and only used as *part* of another schema.
170///
171#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
172#[serde_with::serde_as]
173#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
174pub struct AllowedClient {
175 /// Allow dev flag. Which controls whether to allow creation of devices.
176 #[serde(rename = "allowDev")]
177 pub allow_dev: Option<bool>,
178 /// Allow the setuid flag.
179 #[serde(rename = "allowSuid")]
180 pub allow_suid: Option<bool>,
181 /// The subnet of IP addresses permitted to access the share.
182 #[serde(rename = "allowedClientsCidr")]
183 pub allowed_clients_cidr: Option<String>,
184 /// Mount permissions.
185 #[serde(rename = "mountPermissions")]
186 pub mount_permissions: Option<String>,
187 /// The network the access point sits on.
188 pub network: Option<String>,
189 /// 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"
190 #[serde(rename = "nfsPath")]
191 pub nfs_path: Option<String>,
192 /// 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.
193 #[serde(rename = "noRootSquash")]
194 pub no_root_squash: Option<bool>,
195 /// Output only. The IP address of the share on this network. Assigned automatically during provisioning based on the network's services_cidr.
196 #[serde(rename = "shareIp")]
197 pub share_ip: Option<String>,
198}
199
200impl common::Part for AllowedClient {}
201
202/// Message for detach specific LUN from an Instance.
203///
204/// # Activities
205///
206/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
207/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
208///
209/// * [locations instances detach lun projects](ProjectLocationInstanceDetachLunCall) (request)
210#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
211#[serde_with::serde_as]
212#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
213pub struct DetachLunRequest {
214 /// Required. Name of the Lun to detach.
215 pub lun: Option<String>,
216 /// If true, performs lun unmapping without instance reboot.
217 #[serde(rename = "skipReboot")]
218 pub skip_reboot: Option<bool>,
219}
220
221impl common::RequestValue for DetachLunRequest {}
222
223/// Message requesting to perform disable hyperthreading operation on a server.
224///
225/// # Activities
226///
227/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
228/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
229///
230/// * [locations instances disable hyperthreading projects](ProjectLocationInstanceDisableHyperthreadingCall) (request)
231#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
232#[serde_with::serde_as]
233#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
234pub struct DisableHyperthreadingRequest {
235 _never_set: Option<bool>,
236}
237
238impl common::RequestValue for DisableHyperthreadingRequest {}
239
240/// Message for disabling the interactive serial console on an instance.
241///
242/// # Activities
243///
244/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
245/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
246///
247/// * [locations instances disable interactive serial console projects](ProjectLocationInstanceDisableInteractiveSerialConsoleCall) (request)
248#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
249#[serde_with::serde_as]
250#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
251pub struct DisableInteractiveSerialConsoleRequest {
252 _never_set: Option<bool>,
253}
254
255impl common::RequestValue for DisableInteractiveSerialConsoleRequest {}
256
257/// 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); }
258///
259/// # Activities
260///
261/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
262/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
263///
264/// * [locations ssh keys delete projects](ProjectLocationSshKeyDeleteCall) (response)
265/// * [locations volumes snapshots delete projects](ProjectLocationVolumeSnapshotDeleteCall) (response)
266#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
267#[serde_with::serde_as]
268#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
269pub struct Empty {
270 _never_set: Option<bool>,
271}
272
273impl common::ResponseResult for Empty {}
274
275/// Message requesting to perform enable hyperthreading operation on a server.
276///
277/// # Activities
278///
279/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
280/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
281///
282/// * [locations instances enable hyperthreading projects](ProjectLocationInstanceEnableHyperthreadingCall) (request)
283#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
284#[serde_with::serde_as]
285#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
286pub struct EnableHyperthreadingRequest {
287 _never_set: Option<bool>,
288}
289
290impl common::RequestValue for EnableHyperthreadingRequest {}
291
292/// Message for enabling the interactive serial console on an instance.
293///
294/// # Activities
295///
296/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
297/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
298///
299/// * [locations instances enable interactive serial console projects](ProjectLocationInstanceEnableInteractiveSerialConsoleCall) (request)
300#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
301#[serde_with::serde_as]
302#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
303pub struct EnableInteractiveSerialConsoleRequest {
304 _never_set: Option<bool>,
305}
306
307impl common::RequestValue for EnableInteractiveSerialConsoleRequest {}
308
309/// Request for skip lun cooloff and delete it.
310///
311/// # Activities
312///
313/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
314/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
315///
316/// * [locations volumes luns evict projects](ProjectLocationVolumeLunEvictCall) (request)
317#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
318#[serde_with::serde_as]
319#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
320pub struct EvictLunRequest {
321 _never_set: Option<bool>,
322}
323
324impl common::RequestValue for EvictLunRequest {}
325
326/// Request for skip volume cooloff and delete it.
327///
328/// # Activities
329///
330/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
331/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
332///
333/// * [locations volumes evict projects](ProjectLocationVolumeEvictCall) (request)
334#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
335#[serde_with::serde_as]
336#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
337pub struct EvictVolumeRequest {
338 _never_set: Option<bool>,
339}
340
341impl common::RequestValue for EvictVolumeRequest {}
342
343/// 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.
344///
345/// This type is not used in any activity, and only used as *part* of another schema.
346///
347#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
348#[serde_with::serde_as]
349#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
350pub struct GoogleCloudBaremetalsolutionV2LogicalInterface {
351 /// 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.
352 #[serde(rename = "interfaceIndex")]
353 pub interface_index: Option<i32>,
354 /// List of logical network interfaces within a logical interface.
355 #[serde(rename = "logicalNetworkInterfaces")]
356 pub logical_network_interfaces: Option<Vec<LogicalNetworkInterface>>,
357 /// Interface name. This is of syntax or and forms part of the network template name.
358 pub name: Option<String>,
359}
360
361impl common::Part for GoogleCloudBaremetalsolutionV2LogicalInterface {}
362
363/// A server.
364///
365/// # Activities
366///
367/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
368/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
369///
370/// * [locations instances get projects](ProjectLocationInstanceGetCall) (response)
371/// * [locations instances patch projects](ProjectLocationInstancePatchCall) (request)
372/// * [locations instances rename projects](ProjectLocationInstanceRenameCall) (response)
373#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
374#[serde_with::serde_as]
375#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
376pub struct Instance {
377 /// Output only. Create a time stamp.
378 #[serde(rename = "createTime")]
379 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
380 /// Output only. The firmware version for the instance.
381 #[serde(rename = "firmwareVersion")]
382 pub firmware_version: Option<String>,
383 /// True if you enable hyperthreading for the server, otherwise false. The default value is false.
384 #[serde(rename = "hyperthreadingEnabled")]
385 pub hyperthreading_enabled: Option<bool>,
386 /// Output only. An identifier for the `Instance`, generated by the backend.
387 pub id: Option<String>,
388 /// Output only. True if the interactive serial console feature is enabled for the instance, false otherwise. The default value is false.
389 #[serde(rename = "interactiveSerialConsoleEnabled")]
390 pub interactive_serial_console_enabled: Option<bool>,
391 /// 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}`.
392 #[serde(rename = "kmsKeyVersion")]
393 pub kms_key_version: Option<String>,
394 /// Labels as key value pairs.
395 pub labels: Option<HashMap<String, String>>,
396 /// 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.
397 #[serde(rename = "logicalInterfaces")]
398 pub logical_interfaces: Option<Vec<GoogleCloudBaremetalsolutionV2LogicalInterface>>,
399 /// Output only. Text field about info for logging in.
400 #[serde(rename = "loginInfo")]
401 pub login_info: Option<String>,
402 /// Immutable. List of LUNs associated with this server.
403 pub luns: Option<Vec<Lun>>,
404 /// Immutable. The server type. [Available server types](https://cloud.google.com/bare-metal/docs/bms-planning#server_configurations)
405 #[serde(rename = "machineType")]
406 pub machine_type: Option<String>,
407 /// 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}`
408 pub name: Option<String>,
409 /// Instance network template name. For eg, bondaa-bondaa, bondab-nic, etc. Generally, the template name follows the syntax of "bond" or "nic".
410 #[serde(rename = "networkTemplate")]
411 pub network_template: Option<String>,
412 /// Output only. List of networks associated with this server.
413 pub networks: Option<Vec<Network>>,
414 /// The OS image currently installed on the server.
415 #[serde(rename = "osImage")]
416 pub os_image: Option<String>,
417 /// 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.
418 pub pod: Option<String>,
419 /// Optional. List of SSH Keys used during instance provisioning.
420 #[serde(rename = "sshKeys")]
421 pub ssh_keys: Option<Vec<String>>,
422 /// Output only. The state of the server.
423 pub state: Option<String>,
424 /// Output only. Update a time stamp.
425 #[serde(rename = "updateTime")]
426 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
427 /// Input only. List of Volumes to attach to this Instance on creation. This field won't be populated in Get/List responses.
428 pub volumes: Option<Vec<Volume>>,
429 /// The workload profile for the instance.
430 #[serde(rename = "workloadProfile")]
431 pub workload_profile: Option<String>,
432}
433
434impl common::RequestValue for Instance {}
435impl common::ResponseResult for Instance {}
436
437/// Configuration parameters for a new instance.
438///
439/// This type is not used in any activity, and only used as *part* of another schema.
440///
441#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
442#[serde_with::serde_as]
443#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
444pub struct InstanceConfig {
445 /// If true networks can be from different projects of the same vendor account.
446 #[serde(rename = "accountNetworksEnabled")]
447 pub account_networks_enabled: Option<bool>,
448 /// Client network address. Filled if InstanceConfig.multivlan_config is false.
449 #[serde(rename = "clientNetwork")]
450 pub client_network: Option<NetworkAddress>,
451 /// Whether the instance should be provisioned with Hyperthreading enabled.
452 pub hyperthreading: Option<bool>,
453 /// A transient unique identifier to idenfity an instance within an ProvisioningConfig request.
454 pub id: Option<String>,
455 /// Instance type. [Available types](https://cloud.google.com/bare-metal/docs/bms-planning#server_configurations)
456 #[serde(rename = "instanceType")]
457 pub instance_type: Option<String>,
458 /// Name of the KMS crypto key version used to encrypt the initial passwords. The key has to have ASYMMETRIC_DECRYPT purpose.
459 #[serde(rename = "kmsKeyVersion")]
460 pub kms_key_version: Option<String>,
461 /// 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.
462 #[serde(rename = "logicalInterfaces")]
463 pub logical_interfaces: Option<Vec<GoogleCloudBaremetalsolutionV2LogicalInterface>>,
464 /// The name of the instance config.
465 pub name: Option<String>,
466 /// The type of network configuration on the instance.
467 #[serde(rename = "networkConfig")]
468 pub network_config: Option<String>,
469 /// Server network template name. Filled if InstanceConfig.multivlan_config is true.
470 #[serde(rename = "networkTemplate")]
471 pub network_template: Option<String>,
472 /// OS image to initialize the instance. [Available images](https://cloud.google.com/bare-metal/docs/bms-planning#server_configurations)
473 #[serde(rename = "osImage")]
474 pub os_image: Option<String>,
475 /// Private network address, if any. Filled if InstanceConfig.multivlan_config is false.
476 #[serde(rename = "privateNetwork")]
477 pub private_network: Option<NetworkAddress>,
478 /// Optional. List of names of ssh keys used to provision the instance.
479 #[serde(rename = "sshKeyNames")]
480 pub ssh_key_names: Option<Vec<String>>,
481 /// User note field, it can be used by customers to add additional information for the BMS Ops team .
482 #[serde(rename = "userNote")]
483 pub user_note: Option<String>,
484}
485
486impl common::Part for InstanceConfig {}
487
488/// A resource budget.
489///
490/// This type is not used in any activity, and only used as *part* of another schema.
491///
492#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
493#[serde_with::serde_as]
494#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
495pub struct InstanceQuota {
496 /// Number of machines than can be created for the given location and instance_type.
497 #[serde(rename = "availableMachineCount")]
498 pub available_machine_count: Option<i32>,
499 /// The gcp service of the provisioning quota.
500 #[serde(rename = "gcpService")]
501 pub gcp_service: Option<String>,
502 /// Instance type. Deprecated: use gcp_service.
503 #[serde(rename = "instanceType")]
504 pub instance_type: Option<String>,
505 /// Location where the quota applies.
506 pub location: Option<String>,
507 /// Output only. The name of the instance quota.
508 pub name: Option<String>,
509}
510
511impl common::Part for InstanceQuota {}
512
513/// A GCP vlan attachment.
514///
515/// This type is not used in any activity, and only used as *part* of another schema.
516///
517#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
518#[serde_with::serde_as]
519#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
520pub struct IntakeVlanAttachment {
521 /// Identifier of the VLAN attachment.
522 pub id: Option<String>,
523 /// Attachment pairing key.
524 #[serde(rename = "pairingKey")]
525 pub pairing_key: Option<String>,
526}
527
528impl common::Part for IntakeVlanAttachment {}
529
530/// Response message for the list of servers.
531///
532/// # Activities
533///
534/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
535/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
536///
537/// * [locations instances list projects](ProjectLocationInstanceListCall) (response)
538#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
539#[serde_with::serde_as]
540#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
541pub struct ListInstancesResponse {
542 /// The list of servers.
543 pub instances: Option<Vec<Instance>>,
544 /// A token identifying a page of results from the server.
545 #[serde(rename = "nextPageToken")]
546 pub next_page_token: Option<String>,
547 /// Locations that could not be reached.
548 pub unreachable: Option<Vec<String>>,
549}
550
551impl common::ResponseResult for ListInstancesResponse {}
552
553/// The response message for Locations.ListLocations.
554///
555/// # Activities
556///
557/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
558/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
559///
560/// * [locations list projects](ProjectLocationListCall) (response)
561#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
562#[serde_with::serde_as]
563#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
564pub struct ListLocationsResponse {
565 /// A list of locations that matches the specified filter in the request.
566 pub locations: Option<Vec<Location>>,
567 /// The standard List next-page token.
568 #[serde(rename = "nextPageToken")]
569 pub next_page_token: Option<String>,
570}
571
572impl common::ResponseResult for ListLocationsResponse {}
573
574/// Response message containing the list of storage volume luns.
575///
576/// # Activities
577///
578/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
579/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
580///
581/// * [locations volumes luns list projects](ProjectLocationVolumeLunListCall) (response)
582#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
583#[serde_with::serde_as]
584#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
585pub struct ListLunsResponse {
586 /// The list of luns.
587 pub luns: Option<Vec<Lun>>,
588 /// A token identifying a page of results from the server.
589 #[serde(rename = "nextPageToken")]
590 pub next_page_token: Option<String>,
591 /// Locations that could not be reached.
592 pub unreachable: Option<Vec<String>>,
593}
594
595impl common::ResponseResult for ListLunsResponse {}
596
597/// Response with Networks with IPs
598///
599/// # Activities
600///
601/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
602/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
603///
604/// * [locations networks list network usage projects](ProjectLocationNetworkListNetworkUsageCall) (response)
605#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
606#[serde_with::serde_as]
607#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
608pub struct ListNetworkUsageResponse {
609 /// Networks with IPs.
610 pub networks: Option<Vec<NetworkUsage>>,
611}
612
613impl common::ResponseResult for ListNetworkUsageResponse {}
614
615/// Response message containing the list of networks.
616///
617/// # Activities
618///
619/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
620/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
621///
622/// * [locations networks list projects](ProjectLocationNetworkListCall) (response)
623#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
624#[serde_with::serde_as]
625#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
626pub struct ListNetworksResponse {
627 /// The list of networks.
628 pub networks: Option<Vec<Network>>,
629 /// A token identifying a page of results from the server.
630 #[serde(rename = "nextPageToken")]
631 pub next_page_token: Option<String>,
632 /// Locations that could not be reached.
633 pub unreachable: Option<Vec<String>>,
634}
635
636impl common::ResponseResult for ListNetworksResponse {}
637
638/// Response message containing the list of NFS shares.
639///
640/// # Activities
641///
642/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
643/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
644///
645/// * [locations nfs shares list projects](ProjectLocationNfsShareListCall) (response)
646#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
647#[serde_with::serde_as]
648#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
649pub struct ListNfsSharesResponse {
650 /// A token identifying a page of results from the server.
651 #[serde(rename = "nextPageToken")]
652 pub next_page_token: Option<String>,
653 /// The list of NFS shares.
654 #[serde(rename = "nfsShares")]
655 pub nfs_shares: Option<Vec<NfsShare>>,
656 /// Locations that could not be reached.
657 pub unreachable: Option<Vec<String>>,
658}
659
660impl common::ResponseResult for ListNfsSharesResponse {}
661
662/// Request for getting all available OS images.
663///
664/// # Activities
665///
666/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
667/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
668///
669/// * [locations os images list projects](ProjectLocationOsImageListCall) (response)
670#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
671#[serde_with::serde_as]
672#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
673pub struct ListOSImagesResponse {
674 /// Token to retrieve the next page of results, or empty if there are no more results in the list.
675 #[serde(rename = "nextPageToken")]
676 pub next_page_token: Option<String>,
677 /// The OS images available.
678 #[serde(rename = "osImages")]
679 pub os_images: Option<Vec<OSImage>>,
680}
681
682impl common::ResponseResult for ListOSImagesResponse {}
683
684/// Response message for the list of provisioning quotas.
685///
686/// # Activities
687///
688/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
689/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
690///
691/// * [locations provisioning quotas list projects](ProjectLocationProvisioningQuotaListCall) (response)
692#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
693#[serde_with::serde_as]
694#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
695pub struct ListProvisioningQuotasResponse {
696 /// Token to retrieve the next page of results, or empty if there are no more results in the list.
697 #[serde(rename = "nextPageToken")]
698 pub next_page_token: Option<String>,
699 /// The provisioning quotas registered in this project.
700 #[serde(rename = "provisioningQuotas")]
701 pub provisioning_quotas: Option<Vec<ProvisioningQuota>>,
702}
703
704impl common::ResponseResult for ListProvisioningQuotasResponse {}
705
706/// Message for response of ListSSHKeys.
707///
708/// # Activities
709///
710/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
711/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
712///
713/// * [locations ssh keys list projects](ProjectLocationSshKeyListCall) (response)
714#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
715#[serde_with::serde_as]
716#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
717pub struct ListSSHKeysResponse {
718 /// Token to retrieve the next page of results, or empty if there are no more results in the list.
719 #[serde(rename = "nextPageToken")]
720 pub next_page_token: Option<String>,
721 /// The SSH keys registered in the project.
722 #[serde(rename = "sshKeys")]
723 pub ssh_keys: Option<Vec<SSHKey>>,
724}
725
726impl common::ResponseResult for ListSSHKeysResponse {}
727
728/// Response message containing the list of volume snapshots.
729///
730/// # Activities
731///
732/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
733/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
734///
735/// * [locations volumes snapshots list projects](ProjectLocationVolumeSnapshotListCall) (response)
736#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
737#[serde_with::serde_as]
738#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
739pub struct ListVolumeSnapshotsResponse {
740 /// A token identifying a page of results from the server.
741 #[serde(rename = "nextPageToken")]
742 pub next_page_token: Option<String>,
743 /// Locations that could not be reached.
744 pub unreachable: Option<Vec<String>>,
745 /// The list of snapshots.
746 #[serde(rename = "volumeSnapshots")]
747 pub volume_snapshots: Option<Vec<VolumeSnapshot>>,
748}
749
750impl common::ResponseResult for ListVolumeSnapshotsResponse {}
751
752/// Response message containing the list of storage volumes.
753///
754/// # Activities
755///
756/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
757/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
758///
759/// * [locations volumes list projects](ProjectLocationVolumeListCall) (response)
760#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
761#[serde_with::serde_as]
762#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
763pub struct ListVolumesResponse {
764 /// A token identifying a page of results from the server.
765 #[serde(rename = "nextPageToken")]
766 pub next_page_token: Option<String>,
767 /// Locations that could not be reached.
768 pub unreachable: Option<Vec<String>>,
769 /// The list of storage volumes.
770 pub volumes: Option<Vec<Volume>>,
771}
772
773impl common::ResponseResult for ListVolumesResponse {}
774
775/// Response for LoadInstanceAuthInfo.
776///
777/// # Activities
778///
779/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
780/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
781///
782/// * [locations instances load auth info projects](ProjectLocationInstanceLoadAuthInfoCall) (response)
783#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
784#[serde_with::serde_as]
785#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
786pub struct LoadInstanceAuthInfoResponse {
787 /// List of ssh keys.
788 #[serde(rename = "sshKeys")]
789 pub ssh_keys: Option<Vec<SSHKey>>,
790 /// Map of username to the user account info.
791 #[serde(rename = "userAccounts")]
792 pub user_accounts: Option<HashMap<String, UserAccount>>,
793}
794
795impl common::ResponseResult for LoadInstanceAuthInfoResponse {}
796
797/// A resource that represents a Google Cloud location.
798///
799/// # Activities
800///
801/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
802/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
803///
804/// * [locations get projects](ProjectLocationGetCall) (response)
805#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
806#[serde_with::serde_as]
807#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
808pub struct Location {
809 /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
810 #[serde(rename = "displayName")]
811 pub display_name: Option<String>,
812 /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
813 pub labels: Option<HashMap<String, String>>,
814 /// The canonical id for this location. For example: `"us-east1"`.
815 #[serde(rename = "locationId")]
816 pub location_id: Option<String>,
817 /// Service-specific metadata. For example the available capacity at the given location.
818 pub metadata: Option<HashMap<String, serde_json::Value>>,
819 /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
820 pub name: Option<String>,
821}
822
823impl common::ResponseResult for Location {}
824
825/// Each logical network interface is effectively a network and IP pair.
826///
827/// This type is not used in any activity, and only used as *part* of another schema.
828///
829#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
830#[serde_with::serde_as]
831#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
832pub struct LogicalNetworkInterface {
833 /// Whether this interface is the default gateway for the instance. Only one interface can be the default gateway for the instance.
834 #[serde(rename = "defaultGateway")]
835 pub default_gateway: Option<bool>,
836 /// An identifier for the `Network`, generated by the backend.
837 pub id: Option<String>,
838 /// IP address in the network
839 #[serde(rename = "ipAddress")]
840 pub ip_address: Option<String>,
841 /// Name of the network
842 pub network: Option<String>,
843 /// Type of network.
844 #[serde(rename = "networkType")]
845 pub network_type: Option<String>,
846}
847
848impl common::Part for LogicalNetworkInterface {}
849
850/// A storage volume logical unit number (LUN).
851///
852/// # Activities
853///
854/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
855/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
856///
857/// * [locations volumes luns get projects](ProjectLocationVolumeLunGetCall) (response)
858#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
859#[serde_with::serde_as]
860#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
861pub struct Lun {
862 /// Display if this LUN is a boot LUN.
863 #[serde(rename = "bootLun")]
864 pub boot_lun: Option<bool>,
865 /// Output only. Time after which LUN will be fully deleted. It is filled only for LUNs in COOL_OFF state.
866 #[serde(rename = "expireTime")]
867 pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
868 /// An identifier for the LUN, generated by the backend.
869 pub id: Option<String>,
870 /// Output only. Instances this Lun is attached to.
871 pub instances: Option<Vec<String>>,
872 /// The LUN multiprotocol type ensures the characteristics of the LUN are optimized for each operating system.
873 #[serde(rename = "multiprotocolType")]
874 pub multiprotocol_type: Option<String>,
875 /// Output only. The name of the LUN.
876 pub name: Option<String>,
877 /// Display if this LUN can be shared between multiple physical servers.
878 pub shareable: Option<bool>,
879 /// The size of this LUN, in GiB.
880 #[serde(rename = "sizeGb")]
881 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
882 pub size_gb: Option<i64>,
883 /// The state of this storage volume.
884 pub state: Option<String>,
885 /// The storage type for this LUN.
886 #[serde(rename = "storageType")]
887 pub storage_type: Option<String>,
888 /// Display the storage volume for this LUN.
889 #[serde(rename = "storageVolume")]
890 pub storage_volume: Option<String>,
891 /// The WWID for this LUN.
892 pub wwid: Option<String>,
893}
894
895impl common::ResponseResult for Lun {}
896
897/// A LUN(Logical Unit Number) range.
898///
899/// This type is not used in any activity, and only used as *part* of another schema.
900///
901#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
902#[serde_with::serde_as]
903#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
904pub struct LunRange {
905 /// Number of LUNs to create.
906 pub quantity: Option<i32>,
907 /// The requested size of each LUN, in GB.
908 #[serde(rename = "sizeGb")]
909 pub size_gb: Option<i32>,
910}
911
912impl common::Part for LunRange {}
913
914/// A Network.
915///
916/// # Activities
917///
918/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
919/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
920///
921/// * [locations networks get projects](ProjectLocationNetworkGetCall) (response)
922/// * [locations networks patch projects](ProjectLocationNetworkPatchCall) (request)
923/// * [locations networks rename projects](ProjectLocationNetworkRenameCall) (response)
924#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
925#[serde_with::serde_as]
926#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
927pub struct Network {
928 /// The cidr of the Network.
929 pub cidr: Option<String>,
930 /// Output only. Gateway ip address.
931 #[serde(rename = "gatewayIp")]
932 pub gateway_ip: Option<String>,
933 /// An identifier for the `Network`, generated by the backend.
934 pub id: Option<String>,
935 /// IP address configured.
936 #[serde(rename = "ipAddress")]
937 pub ip_address: Option<String>,
938 /// Whether network uses standard frames or jumbo ones.
939 #[serde(rename = "jumboFramesEnabled")]
940 pub jumbo_frames_enabled: Option<bool>,
941 /// Labels as key value pairs.
942 pub labels: Option<HashMap<String, String>>,
943 /// List of physical interfaces.
944 #[serde(rename = "macAddress")]
945 pub mac_address: Option<Vec<String>>,
946 /// Input only. List of mount points to attach the network to.
947 #[serde(rename = "mountPoints")]
948 pub mount_points: Option<Vec<NetworkMountPoint>>,
949 /// 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}`
950 pub name: Option<String>,
951 /// 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.
952 pub pod: Option<String>,
953 /// 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.
954 pub reservations: Option<Vec<NetworkAddressReservation>>,
955 /// IP range for reserved for services (e.g. NFS).
956 #[serde(rename = "servicesCidr")]
957 pub services_cidr: Option<String>,
958 /// The Network state.
959 pub state: Option<String>,
960 /// The type of this network.
961 #[serde(rename = "type")]
962 pub type_: Option<String>,
963 /// The vlan id of the Network.
964 #[serde(rename = "vlanId")]
965 pub vlan_id: Option<String>,
966 /// The Vrf for the Network. Use this only if a new Vrf needs to be created.
967 pub vrf: Option<VRF>,
968 /// Optional. The name of a pre-existing Vrf that the network should be attached to. Format is `vrfs/{vrf}`.
969 #[serde(rename = "vrfAttachment")]
970 pub vrf_attachment: Option<String>,
971}
972
973impl common::RequestValue for Network {}
974impl common::ResponseResult for Network {}
975
976/// A network.
977///
978/// This type is not used in any activity, and only used as *part* of another schema.
979///
980#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
981#[serde_with::serde_as]
982#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
983pub struct NetworkAddress {
984 /// IPv4 address to be assigned to the server.
985 pub address: Option<String>,
986 /// Name of the existing network to use.
987 #[serde(rename = "existingNetworkId")]
988 pub existing_network_id: Option<String>,
989 /// Id of the network to use, within the same ProvisioningConfig request.
990 #[serde(rename = "networkId")]
991 pub network_id: Option<String>,
992}
993
994impl common::Part for NetworkAddress {}
995
996/// A reservation of one or more addresses in a network.
997///
998/// This type is not used in any activity, and only used as *part* of another schema.
999///
1000#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1001#[serde_with::serde_as]
1002#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1003pub struct NetworkAddressReservation {
1004 /// 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.
1005 #[serde(rename = "endAddress")]
1006 pub end_address: Option<String>,
1007 /// A note about this reservation, intended for human consumption.
1008 pub note: Option<String>,
1009 /// The first address of this reservation block. Must be specified as a single IPv4 address, e.g. 10.1.2.2.
1010 #[serde(rename = "startAddress")]
1011 pub start_address: Option<String>,
1012}
1013
1014impl common::Part for NetworkAddressReservation {}
1015
1016/// Configuration parameters for a new network.
1017///
1018/// This type is not used in any activity, and only used as *part* of another schema.
1019///
1020#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1021#[serde_with::serde_as]
1022#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1023pub struct NetworkConfig {
1024 /// Interconnect bandwidth. Set only when type is CLIENT.
1025 pub bandwidth: Option<String>,
1026 /// CIDR range of the network.
1027 pub cidr: Option<String>,
1028 /// The GCP service of the network. Available gcp_service are in https://cloud.google.com/bare-metal/docs/bms-planning.
1029 #[serde(rename = "gcpService")]
1030 pub gcp_service: Option<String>,
1031 /// A transient unique identifier to identify a volume within an ProvisioningConfig request.
1032 pub id: Option<String>,
1033 /// The JumboFramesEnabled option for customer to set.
1034 #[serde(rename = "jumboFramesEnabled")]
1035 pub jumbo_frames_enabled: Option<bool>,
1036 /// Output only. The name of the network config.
1037 pub name: Option<String>,
1038 /// Service CIDR, if any.
1039 #[serde(rename = "serviceCidr")]
1040 pub service_cidr: Option<String>,
1041 /// The type of this network, either Client or Private.
1042 #[serde(rename = "type")]
1043 pub type_: Option<String>,
1044 /// User note field, it can be used by customers to add additional information for the BMS Ops team .
1045 #[serde(rename = "userNote")]
1046 pub user_note: Option<String>,
1047 /// List of VLAN attachments. As of now there are always 2 attachments, but it is going to change in the future (multi vlan).
1048 #[serde(rename = "vlanAttachments")]
1049 pub vlan_attachments: Option<Vec<IntakeVlanAttachment>>,
1050 /// Whether the VLAN attachment pair is located in the same project.
1051 #[serde(rename = "vlanSameProject")]
1052 pub vlan_same_project: Option<bool>,
1053}
1054
1055impl common::Part for NetworkConfig {}
1056
1057/// Mount point for a network.
1058///
1059/// This type is not used in any activity, and only used as *part* of another schema.
1060///
1061#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1062#[serde_with::serde_as]
1063#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1064pub struct NetworkMountPoint {
1065 /// Network should be a default gateway.
1066 #[serde(rename = "defaultGateway")]
1067 pub default_gateway: Option<bool>,
1068 /// Instance to attach network to.
1069 pub instance: Option<String>,
1070 /// Ip address of the server.
1071 #[serde(rename = "ipAddress")]
1072 pub ip_address: Option<String>,
1073 /// Logical interface to detach from.
1074 #[serde(rename = "logicalInterface")]
1075 pub logical_interface: Option<String>,
1076}
1077
1078impl common::Part for NetworkMountPoint {}
1079
1080/// Network with all used IP addresses.
1081///
1082/// This type is not used in any activity, and only used as *part* of another schema.
1083///
1084#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1085#[serde_with::serde_as]
1086#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1087pub struct NetworkUsage {
1088 /// Network.
1089 pub network: Option<Network>,
1090 /// All used IP addresses in this network.
1091 #[serde(rename = "usedIps")]
1092 pub used_ips: Option<Vec<String>>,
1093}
1094
1095impl common::Part for NetworkUsage {}
1096
1097/// A NFS export entry.
1098///
1099/// This type is not used in any activity, and only used as *part* of another schema.
1100///
1101#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1102#[serde_with::serde_as]
1103#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1104pub struct NfsExport {
1105 /// Allow dev flag in NfsShare AllowedClientsRequest.
1106 #[serde(rename = "allowDev")]
1107 pub allow_dev: Option<bool>,
1108 /// Allow the setuid flag.
1109 #[serde(rename = "allowSuid")]
1110 pub allow_suid: Option<bool>,
1111 /// A CIDR range.
1112 pub cidr: Option<String>,
1113 /// Either a single machine, identified by an ID, or a comma-separated list of machine IDs.
1114 #[serde(rename = "machineId")]
1115 pub machine_id: Option<String>,
1116 /// Network to use to publish the export.
1117 #[serde(rename = "networkId")]
1118 pub network_id: Option<String>,
1119 /// 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.
1120 #[serde(rename = "noRootSquash")]
1121 pub no_root_squash: Option<bool>,
1122 /// Export permissions.
1123 pub permissions: Option<String>,
1124}
1125
1126impl common::Part for NfsExport {}
1127
1128/// An NFS share.
1129///
1130/// # Activities
1131///
1132/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1133/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1134///
1135/// * [locations nfs shares create projects](ProjectLocationNfsShareCreateCall) (request)
1136/// * [locations nfs shares get projects](ProjectLocationNfsShareGetCall) (response)
1137/// * [locations nfs shares patch projects](ProjectLocationNfsSharePatchCall) (request)
1138/// * [locations nfs shares rename projects](ProjectLocationNfsShareRenameCall) (response)
1139#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1140#[serde_with::serde_as]
1141#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1142pub struct NfsShare {
1143 /// List of allowed access points.
1144 #[serde(rename = "allowedClients")]
1145 pub allowed_clients: Option<Vec<AllowedClient>>,
1146 /// 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.
1147 pub id: Option<String>,
1148 /// Labels as key value pairs.
1149 pub labels: Option<HashMap<String, String>>,
1150 /// Immutable. The name of the NFS share.
1151 pub name: Option<String>,
1152 /// Output only. An identifier for the NFS share, generated by the backend. This field will be deprecated in the future, use `id` instead.
1153 #[serde(rename = "nfsShareId")]
1154 pub nfs_share_id: Option<String>,
1155 /// 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.
1156 pub pod: Option<String>,
1157 /// The requested size, in GiB.
1158 #[serde(rename = "requestedSizeGib")]
1159 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1160 pub requested_size_gib: Option<i64>,
1161 /// Output only. The state of the NFS share.
1162 pub state: Option<String>,
1163 /// Immutable. The storage type of the underlying volume.
1164 #[serde(rename = "storageType")]
1165 pub storage_type: Option<String>,
1166 /// Output only. The underlying volume of the share. Created automatically during provisioning.
1167 pub volume: Option<String>,
1168}
1169
1170impl common::RequestValue for NfsShare {}
1171impl common::ResponseResult for NfsShare {}
1172
1173/// Operation System image.
1174///
1175/// # Activities
1176///
1177/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1178/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1179///
1180/// * [locations os images get projects](ProjectLocationOsImageGetCall) (response)
1181#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1182#[serde_with::serde_as]
1183#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1184pub struct OSImage {
1185 /// Instance types this image is applicable to. [Available types](https://cloud.google.com/bare-metal/docs/bms-planning#server_configurations)
1186 #[serde(rename = "applicableInstanceTypes")]
1187 pub applicable_instance_types: Option<Vec<String>>,
1188 /// OS Image code.
1189 pub code: Option<String>,
1190 /// OS Image description.
1191 pub description: Option<String>,
1192 /// Output only. OS Image's unique name.
1193 pub name: Option<String>,
1194 /// Network templates that can be used with this OS Image.
1195 #[serde(rename = "supportedNetworkTemplates")]
1196 pub supported_network_templates: Option<Vec<String>>,
1197}
1198
1199impl common::ResponseResult for OSImage {}
1200
1201/// This resource represents a long-running operation that is the result of a network API call.
1202///
1203/// # Activities
1204///
1205/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1206/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1207///
1208/// * [locations instances detach lun projects](ProjectLocationInstanceDetachLunCall) (response)
1209/// * [locations instances disable hyperthreading projects](ProjectLocationInstanceDisableHyperthreadingCall) (response)
1210/// * [locations instances disable interactive serial console projects](ProjectLocationInstanceDisableInteractiveSerialConsoleCall) (response)
1211/// * [locations instances enable hyperthreading projects](ProjectLocationInstanceEnableHyperthreadingCall) (response)
1212/// * [locations instances enable interactive serial console projects](ProjectLocationInstanceEnableInteractiveSerialConsoleCall) (response)
1213/// * [locations instances patch projects](ProjectLocationInstancePatchCall) (response)
1214/// * [locations instances reimage projects](ProjectLocationInstanceReimageCall) (response)
1215/// * [locations instances reset projects](ProjectLocationInstanceResetCall) (response)
1216/// * [locations instances start projects](ProjectLocationInstanceStartCall) (response)
1217/// * [locations instances stop projects](ProjectLocationInstanceStopCall) (response)
1218/// * [locations networks patch projects](ProjectLocationNetworkPatchCall) (response)
1219/// * [locations nfs shares create projects](ProjectLocationNfsShareCreateCall) (response)
1220/// * [locations nfs shares delete projects](ProjectLocationNfsShareDeleteCall) (response)
1221/// * [locations nfs shares patch projects](ProjectLocationNfsSharePatchCall) (response)
1222/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
1223/// * [locations volumes luns evict projects](ProjectLocationVolumeLunEvictCall) (response)
1224/// * [locations volumes snapshots restore volume snapshot projects](ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall) (response)
1225/// * [locations volumes evict projects](ProjectLocationVolumeEvictCall) (response)
1226/// * [locations volumes patch projects](ProjectLocationVolumePatchCall) (response)
1227/// * [locations volumes resize projects](ProjectLocationVolumeResizeCall) (response)
1228#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1229#[serde_with::serde_as]
1230#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1231pub struct Operation {
1232 /// 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.
1233 pub done: Option<bool>,
1234 /// The error result of the operation in case of failure or cancellation.
1235 pub error: Option<Status>,
1236 /// 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.
1237 pub metadata: Option<HashMap<String, serde_json::Value>>,
1238 /// 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}`.
1239 pub name: Option<String>,
1240 /// 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`.
1241 pub response: Option<HashMap<String, serde_json::Value>>,
1242}
1243
1244impl common::ResponseResult for Operation {}
1245
1246/// A provisioning configuration.
1247///
1248/// # Activities
1249///
1250/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1251/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1252///
1253/// * [locations provisioning configs create projects](ProjectLocationProvisioningConfigCreateCall) (request|response)
1254/// * [locations provisioning configs get projects](ProjectLocationProvisioningConfigGetCall) (response)
1255/// * [locations provisioning configs patch projects](ProjectLocationProvisioningConfigPatchCall) (request|response)
1256#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1257#[serde_with::serde_as]
1258#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1259pub struct ProvisioningConfig {
1260 /// Output only. URI to Cloud Console UI view of this provisioning config.
1261 #[serde(rename = "cloudConsoleUri")]
1262 pub cloud_console_uri: Option<String>,
1263 /// Optional. The user-defined identifier of the provisioning config.
1264 #[serde(rename = "customId")]
1265 pub custom_id: Option<String>,
1266 /// Email provided to send a confirmation with provisioning config to. Deprecated in favour of email field in request messages.
1267 pub email: Option<String>,
1268 /// A service account to enable customers to access instance credentials upon handover.
1269 #[serde(rename = "handoverServiceAccount")]
1270 pub handover_service_account: Option<String>,
1271 /// Instances to be created.
1272 pub instances: Option<Vec<InstanceConfig>>,
1273 /// Optional. Location name of this ProvisioningConfig. It is optional only for Intake UI transition period.
1274 pub location: Option<String>,
1275 /// Output only. The system-generated name of the provisioning config. This follows the UUID format.
1276 pub name: Option<String>,
1277 /// Networks to be created.
1278 pub networks: Option<Vec<NetworkConfig>>,
1279 /// 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.
1280 pub pod: Option<String>,
1281 /// Output only. State of ProvisioningConfig.
1282 pub state: Option<String>,
1283 /// Optional status messages associated with the FAILED state.
1284 #[serde(rename = "statusMessage")]
1285 pub status_message: Option<String>,
1286 /// A generated ticket id to track provisioning request.
1287 #[serde(rename = "ticketId")]
1288 pub ticket_id: Option<String>,
1289 /// Output only. Last update timestamp.
1290 #[serde(rename = "updateTime")]
1291 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1292 /// Volumes to be created.
1293 pub volumes: Option<Vec<VolumeConfig>>,
1294 /// If true, VPC SC is enabled for the cluster.
1295 #[serde(rename = "vpcScEnabled")]
1296 pub vpc_sc_enabled: Option<bool>,
1297}
1298
1299impl common::RequestValue for ProvisioningConfig {}
1300impl common::ResponseResult for ProvisioningConfig {}
1301
1302/// A provisioning quota for a given project.
1303///
1304/// This type is not used in any activity, and only used as *part* of another schema.
1305///
1306#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1307#[serde_with::serde_as]
1308#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1309pub struct ProvisioningQuota {
1310 /// The asset type of this provisioning quota.
1311 #[serde(rename = "assetType")]
1312 pub asset_type: Option<String>,
1313 /// The available count of the provisioning quota.
1314 #[serde(rename = "availableCount")]
1315 pub available_count: Option<i32>,
1316 /// The gcp service of the provisioning quota.
1317 #[serde(rename = "gcpService")]
1318 pub gcp_service: Option<String>,
1319 /// Instance quota.
1320 #[serde(rename = "instanceQuota")]
1321 pub instance_quota: Option<InstanceQuota>,
1322 /// The specific location of the provisioining quota.
1323 pub location: Option<String>,
1324 /// Output only. The name of the provisioning quota.
1325 pub name: Option<String>,
1326 /// Network bandwidth, Gbps
1327 #[serde(rename = "networkBandwidth")]
1328 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1329 pub network_bandwidth: Option<i64>,
1330 /// Server count.
1331 #[serde(rename = "serverCount")]
1332 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1333 pub server_count: Option<i64>,
1334 /// Storage size (GB).
1335 #[serde(rename = "storageGib")]
1336 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1337 pub storage_gib: Option<i64>,
1338}
1339
1340impl common::Part for ProvisioningQuota {}
1341
1342/// QOS policy parameters.
1343///
1344/// This type is not used in any activity, and only used as *part* of another schema.
1345///
1346#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1347#[serde_with::serde_as]
1348#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1349pub struct QosPolicy {
1350 /// The bandwidth permitted by the QOS policy, in gbps.
1351 #[serde(rename = "bandwidthGbps")]
1352 pub bandwidth_gbps: Option<f64>,
1353}
1354
1355impl common::Part for QosPolicy {}
1356
1357/// Message requesting to perform reimage operation on a server.
1358///
1359/// # Activities
1360///
1361/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1362/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1363///
1364/// * [locations instances reimage projects](ProjectLocationInstanceReimageCall) (request)
1365#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1366#[serde_with::serde_as]
1367#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1368pub struct ReimageInstanceRequest {
1369 /// 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}`.
1370 #[serde(rename = "kmsKeyVersion")]
1371 pub kms_key_version: Option<String>,
1372 /// Required. The OS image code of the image which will be used in the reimage operation.
1373 #[serde(rename = "osImage")]
1374 pub os_image: Option<String>,
1375 /// Optional. List of SSH Keys used during reimaging an instance.
1376 #[serde(rename = "sshKeys")]
1377 pub ssh_keys: Option<Vec<String>>,
1378}
1379
1380impl common::RequestValue for ReimageInstanceRequest {}
1381
1382/// Message requesting rename of a server.
1383///
1384/// # Activities
1385///
1386/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1387/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1388///
1389/// * [locations instances rename projects](ProjectLocationInstanceRenameCall) (request)
1390#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1391#[serde_with::serde_as]
1392#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1393pub struct RenameInstanceRequest {
1394 /// Required. The new `id` of the instance.
1395 #[serde(rename = "newInstanceId")]
1396 pub new_instance_id: Option<String>,
1397}
1398
1399impl common::RequestValue for RenameInstanceRequest {}
1400
1401/// Message requesting rename of a server.
1402///
1403/// # Activities
1404///
1405/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1406/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1407///
1408/// * [locations networks rename projects](ProjectLocationNetworkRenameCall) (request)
1409#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1410#[serde_with::serde_as]
1411#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1412pub struct RenameNetworkRequest {
1413 /// Required. The new `id` of the network.
1414 #[serde(rename = "newNetworkId")]
1415 pub new_network_id: Option<String>,
1416}
1417
1418impl common::RequestValue for RenameNetworkRequest {}
1419
1420/// Message requesting rename of a server.
1421///
1422/// # Activities
1423///
1424/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1425/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1426///
1427/// * [locations nfs shares rename projects](ProjectLocationNfsShareRenameCall) (request)
1428#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1429#[serde_with::serde_as]
1430#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1431pub struct RenameNfsShareRequest {
1432 /// Required. The new `id` of the nfsshare.
1433 #[serde(rename = "newNfsshareId")]
1434 pub new_nfsshare_id: Option<String>,
1435}
1436
1437impl common::RequestValue for RenameNfsShareRequest {}
1438
1439/// Message requesting rename of a server.
1440///
1441/// # Activities
1442///
1443/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1444/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1445///
1446/// * [locations volumes rename projects](ProjectLocationVolumeRenameCall) (request)
1447#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1448#[serde_with::serde_as]
1449#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1450pub struct RenameVolumeRequest {
1451 /// Required. The new `id` of the volume.
1452 #[serde(rename = "newVolumeId")]
1453 pub new_volume_id: Option<String>,
1454}
1455
1456impl common::RequestValue for RenameVolumeRequest {}
1457
1458/// Message requesting to reset a server.
1459///
1460/// # Activities
1461///
1462/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1463/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1464///
1465/// * [locations instances reset projects](ProjectLocationInstanceResetCall) (request)
1466#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1467#[serde_with::serde_as]
1468#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1469pub struct ResetInstanceRequest {
1470 _never_set: Option<bool>,
1471}
1472
1473impl common::RequestValue for ResetInstanceRequest {}
1474
1475/// Request for emergency resize Volume.
1476///
1477/// # Activities
1478///
1479/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1480/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1481///
1482/// * [locations volumes resize projects](ProjectLocationVolumeResizeCall) (request)
1483#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1484#[serde_with::serde_as]
1485#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1486pub struct ResizeVolumeRequest {
1487 /// New Volume size, in GiB.
1488 #[serde(rename = "sizeGib")]
1489 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1490 pub size_gib: Option<i64>,
1491}
1492
1493impl common::RequestValue for ResizeVolumeRequest {}
1494
1495/// Message for restoring a volume snapshot.
1496///
1497/// # Activities
1498///
1499/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1500/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1501///
1502/// * [locations volumes snapshots restore volume snapshot projects](ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall) (request)
1503#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1504#[serde_with::serde_as]
1505#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1506pub struct RestoreVolumeSnapshotRequest {
1507 _never_set: Option<bool>,
1508}
1509
1510impl common::RequestValue for RestoreVolumeSnapshotRequest {}
1511
1512/// An SSH key, used for authorizing with the interactive serial console feature.
1513///
1514/// # Activities
1515///
1516/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1517/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1518///
1519/// * [locations ssh keys create projects](ProjectLocationSshKeyCreateCall) (request|response)
1520#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1521#[serde_with::serde_as]
1522#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1523pub struct SSHKey {
1524 /// Output only. The name of this SSH key. Currently, the only valid value for the location is "global".
1525 pub name: Option<String>,
1526 /// The public SSH key. This must be in OpenSSH .authorized_keys format.
1527 #[serde(rename = "publicKey")]
1528 pub public_key: Option<String>,
1529}
1530
1531impl common::RequestValue for SSHKey {}
1532impl common::ResponseResult for SSHKey {}
1533
1534/// Details about snapshot space reservation and usage on the storage volume.
1535///
1536/// This type is not used in any activity, and only used as *part* of another schema.
1537///
1538#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1539#[serde_with::serde_as]
1540#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1541pub struct SnapshotReservationDetail {
1542 /// The space on this storage volume reserved for snapshots, shown in GiB.
1543 #[serde(rename = "reservedSpaceGib")]
1544 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1545 pub reserved_space_gib: Option<i64>,
1546 /// 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.
1547 #[serde(rename = "reservedSpacePercent")]
1548 pub reserved_space_percent: Option<i32>,
1549 /// The amount, in GiB, of available space in this storage volume's reserved snapshot space.
1550 #[serde(rename = "reservedSpaceRemainingGib")]
1551 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1552 pub reserved_space_remaining_gib: Option<i64>,
1553 /// 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.
1554 #[serde(rename = "reservedSpaceUsedPercent")]
1555 pub reserved_space_used_percent: Option<i32>,
1556}
1557
1558impl common::Part for SnapshotReservationDetail {}
1559
1560/// Message requesting to start a server.
1561///
1562/// # Activities
1563///
1564/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1565/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1566///
1567/// * [locations instances start projects](ProjectLocationInstanceStartCall) (request)
1568#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1569#[serde_with::serde_as]
1570#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1571pub struct StartInstanceRequest {
1572 _never_set: Option<bool>,
1573}
1574
1575impl common::RequestValue for StartInstanceRequest {}
1576
1577/// 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).
1578///
1579/// This type is not used in any activity, and only used as *part* of another schema.
1580///
1581#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1582#[serde_with::serde_as]
1583#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1584pub struct Status {
1585 /// The status code, which should be an enum value of google.rpc.Code.
1586 pub code: Option<i32>,
1587 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1588 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1589 /// 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.
1590 pub message: Option<String>,
1591}
1592
1593impl common::Part for Status {}
1594
1595/// Message requesting to stop a server.
1596///
1597/// # Activities
1598///
1599/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1600/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1601///
1602/// * [locations instances stop projects](ProjectLocationInstanceStopCall) (request)
1603#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1604#[serde_with::serde_as]
1605#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1606pub struct StopInstanceRequest {
1607 _never_set: Option<bool>,
1608}
1609
1610impl common::RequestValue for StopInstanceRequest {}
1611
1612/// Request for SubmitProvisioningConfig.
1613///
1614/// # Activities
1615///
1616/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1617/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1618///
1619/// * [locations provisioning configs submit projects](ProjectLocationProvisioningConfigSubmitCall) (request)
1620#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1621#[serde_with::serde_as]
1622#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1623pub struct SubmitProvisioningConfigRequest {
1624 /// Optional. Email provided to send a confirmation with provisioning config to.
1625 pub email: Option<String>,
1626 /// Required. The ProvisioningConfig to create.
1627 #[serde(rename = "provisioningConfig")]
1628 pub provisioning_config: Option<ProvisioningConfig>,
1629}
1630
1631impl common::RequestValue for SubmitProvisioningConfigRequest {}
1632
1633/// Response for SubmitProvisioningConfig.
1634///
1635/// # Activities
1636///
1637/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1638/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1639///
1640/// * [locations provisioning configs submit projects](ProjectLocationProvisioningConfigSubmitCall) (response)
1641#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1642#[serde_with::serde_as]
1643#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1644pub struct SubmitProvisioningConfigResponse {
1645 /// The submitted provisioning config.
1646 #[serde(rename = "provisioningConfig")]
1647 pub provisioning_config: Option<ProvisioningConfig>,
1648}
1649
1650impl common::ResponseResult for SubmitProvisioningConfigResponse {}
1651
1652/// User account provisioned for the customer.
1653///
1654/// This type is not used in any activity, and only used as *part* of another schema.
1655///
1656#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1657#[serde_with::serde_as]
1658#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1659pub struct UserAccount {
1660 /// Encrypted initial password value.
1661 #[serde(rename = "encryptedPassword")]
1662 pub encrypted_password: Option<String>,
1663 /// KMS CryptoKey Version used to encrypt the password.
1664 #[serde(rename = "kmsKeyVersion")]
1665 pub kms_key_version: Option<String>,
1666}
1667
1668impl common::Part for UserAccount {}
1669
1670/// A network VRF.
1671///
1672/// This type is not used in any activity, and only used as *part* of another schema.
1673///
1674#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1675#[serde_with::serde_as]
1676#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1677pub struct VRF {
1678 /// The name of the VRF.
1679 pub name: Option<String>,
1680 /// 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.
1681 #[serde(rename = "qosPolicy")]
1682 pub qos_policy: Option<QosPolicy>,
1683 /// The possible state of VRF.
1684 pub state: Option<String>,
1685 /// The list of VLAN attachments for the VRF.
1686 #[serde(rename = "vlanAttachments")]
1687 pub vlan_attachments: Option<Vec<VlanAttachment>>,
1688}
1689
1690impl common::Part for VRF {}
1691
1692/// VLAN attachment details.
1693///
1694/// This type is not used in any activity, and only used as *part* of another schema.
1695///
1696#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1697#[serde_with::serde_as]
1698#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1699pub struct VlanAttachment {
1700 /// Immutable. The identifier of the attachment within vrf.
1701 pub id: Option<String>,
1702 /// Optional. The name of the vlan attachment within vrf. This is of the form projects/{project_number}/regions/{region}/interconnectAttachments/{interconnect_attachment}
1703 #[serde(rename = "interconnectAttachment")]
1704 pub interconnect_attachment: Option<String>,
1705 /// Input only. Pairing key.
1706 #[serde(rename = "pairingKey")]
1707 pub pairing_key: Option<String>,
1708 /// The peer IP of the attachment.
1709 #[serde(rename = "peerIp")]
1710 pub peer_ip: Option<String>,
1711 /// The peer vlan ID of the attachment.
1712 #[serde(rename = "peerVlanId")]
1713 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1714 pub peer_vlan_id: Option<i64>,
1715 /// The QOS policy applied to this VLAN attachment. This value should be preferred to using qos at vrf level.
1716 #[serde(rename = "qosPolicy")]
1717 pub qos_policy: Option<QosPolicy>,
1718 /// The router IP of the attachment.
1719 #[serde(rename = "routerIp")]
1720 pub router_ip: Option<String>,
1721}
1722
1723impl common::Part for VlanAttachment {}
1724
1725/// A storage volume.
1726///
1727/// # Activities
1728///
1729/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1730/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1731///
1732/// * [locations volumes get projects](ProjectLocationVolumeGetCall) (response)
1733/// * [locations volumes patch projects](ProjectLocationVolumePatchCall) (request)
1734/// * [locations volumes rename projects](ProjectLocationVolumeRenameCall) (response)
1735#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1736#[serde_with::serde_as]
1737#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1738pub struct Volume {
1739 /// 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.
1740 pub attached: Option<bool>,
1741 /// 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.
1742 #[serde(rename = "autoGrownSizeGib")]
1743 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1744 pub auto_grown_size_gib: Option<i64>,
1745 /// Output only. Whether this volume is a boot volume. A boot volume is one which contains a boot LUN.
1746 #[serde(rename = "bootVolume")]
1747 pub boot_volume: Option<bool>,
1748 /// 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.
1749 #[serde(rename = "currentSizeGib")]
1750 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1751 pub current_size_gib: Option<i64>,
1752 /// Additional emergency size that was requested for this Volume, in GiB. current_size_gib includes this value.
1753 #[serde(rename = "emergencySizeGib")]
1754 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1755 pub emergency_size_gib: Option<i64>,
1756 /// Output only. Time after which volume will be fully deleted. It is filled only for volumes in COOLOFF state.
1757 #[serde(rename = "expireTime")]
1758 pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1759 /// An identifier for the `Volume`, generated by the backend.
1760 pub id: Option<String>,
1761 /// Output only. Instances this Volume is attached to. This field is set only in Get requests.
1762 pub instances: Option<Vec<String>>,
1763 /// Labels as key value pairs.
1764 pub labels: Option<HashMap<String, String>>,
1765 /// Maximum size volume can be expanded to in case of evergency, in GiB.
1766 #[serde(rename = "maxSizeGib")]
1767 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1768 pub max_size_gib: Option<i64>,
1769 /// 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}`
1770 pub name: Option<String>,
1771 /// Input only. User-specified notes for new Volume. Used to provision Volumes that require manual intervention.
1772 pub notes: Option<String>,
1773 /// Originally requested size, in GiB.
1774 #[serde(rename = "originallyRequestedSizeGib")]
1775 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1776 pub originally_requested_size_gib: Option<i64>,
1777 /// Immutable. Performance tier of the Volume. Default is SHARED.
1778 #[serde(rename = "performanceTier")]
1779 pub performance_tier: Option<String>,
1780 /// Immutable. Pod name. Pod is an independent part of infrastructure. Volume can only be connected to the instances allocated in the same pod.
1781 pub pod: Option<String>,
1782 /// Output only. Storage protocol for the Volume.
1783 pub protocol: Option<String>,
1784 /// The space remaining in the storage volume for new LUNs, in GiB, excluding space reserved for snapshots.
1785 #[serde(rename = "remainingSpaceGib")]
1786 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1787 pub remaining_space_gib: Option<i64>,
1788 /// The requested size of this storage volume, in GiB.
1789 #[serde(rename = "requestedSizeGib")]
1790 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1791 pub requested_size_gib: Option<i64>,
1792 /// The behavior to use when snapshot reserved space is full.
1793 #[serde(rename = "snapshotAutoDeleteBehavior")]
1794 pub snapshot_auto_delete_behavior: Option<String>,
1795 /// Whether snapshots are enabled.
1796 #[serde(rename = "snapshotEnabled")]
1797 pub snapshot_enabled: Option<bool>,
1798 /// Details about snapshot space reservation and usage on the storage volume.
1799 #[serde(rename = "snapshotReservationDetail")]
1800 pub snapshot_reservation_detail: Option<SnapshotReservationDetail>,
1801 /// The state of this storage volume.
1802 pub state: Option<String>,
1803 /// The storage type for this volume.
1804 #[serde(rename = "storageType")]
1805 pub storage_type: Option<String>,
1806 /// The workload profile for the volume.
1807 #[serde(rename = "workloadProfile")]
1808 pub workload_profile: Option<String>,
1809}
1810
1811impl common::RequestValue for Volume {}
1812impl common::ResponseResult for Volume {}
1813
1814/// Configuration parameters for a new volume.
1815///
1816/// This type is not used in any activity, and only used as *part* of another schema.
1817///
1818#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1819#[serde_with::serde_as]
1820#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1821pub struct VolumeConfig {
1822 /// The GCP service of the storage volume. Available gcp_service are in https://cloud.google.com/bare-metal/docs/bms-planning.
1823 #[serde(rename = "gcpService")]
1824 pub gcp_service: Option<String>,
1825 /// A transient unique identifier to identify a volume within an ProvisioningConfig request.
1826 pub id: Option<String>,
1827 /// LUN ranges to be configured. Set only when protocol is PROTOCOL_FC.
1828 #[serde(rename = "lunRanges")]
1829 pub lun_ranges: Option<Vec<LunRange>>,
1830 /// Machine ids connected to this volume. Set only when protocol is PROTOCOL_FC.
1831 #[serde(rename = "machineIds")]
1832 pub machine_ids: Option<Vec<String>>,
1833 /// Output only. The name of the volume config.
1834 pub name: Option<String>,
1835 /// NFS exports. Set only when protocol is PROTOCOL_NFS.
1836 #[serde(rename = "nfsExports")]
1837 pub nfs_exports: Option<Vec<NfsExport>>,
1838 /// Performance tier of the Volume. Default is SHARED.
1839 #[serde(rename = "performanceTier")]
1840 pub performance_tier: Option<String>,
1841 /// Volume protocol.
1842 pub protocol: Option<String>,
1843 /// The requested size of this volume, in GB.
1844 #[serde(rename = "sizeGb")]
1845 pub size_gb: Option<i32>,
1846 /// Whether snapshots should be enabled.
1847 #[serde(rename = "snapshotsEnabled")]
1848 pub snapshots_enabled: Option<bool>,
1849 /// The type of this Volume.
1850 #[serde(rename = "type")]
1851 pub type_: Option<String>,
1852 /// User note field, it can be used by customers to add additional information for the BMS Ops team .
1853 #[serde(rename = "userNote")]
1854 pub user_note: Option<String>,
1855}
1856
1857impl common::Part for VolumeConfig {}
1858
1859/// A snapshot of a volume. Only boot volumes can have snapshots.
1860///
1861/// # Activities
1862///
1863/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1864/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1865///
1866/// * [locations volumes snapshots create projects](ProjectLocationVolumeSnapshotCreateCall) (request|response)
1867/// * [locations volumes snapshots get projects](ProjectLocationVolumeSnapshotGetCall) (response)
1868#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1869#[serde_with::serde_as]
1870#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1871pub struct VolumeSnapshot {
1872 /// Output only. The creation time of the snapshot.
1873 #[serde(rename = "createTime")]
1874 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1875 /// The description of the snapshot.
1876 pub description: Option<String>,
1877 /// Output only. An identifier for the snapshot, generated by the backend.
1878 pub id: Option<String>,
1879 /// The name of the snapshot.
1880 pub name: Option<String>,
1881 /// Output only. The name of the volume which this snapshot belongs to.
1882 #[serde(rename = "storageVolume")]
1883 pub storage_volume: Option<String>,
1884 /// Output only. The type of the snapshot which indicates whether it was scheduled or manual/ad-hoc.
1885 #[serde(rename = "type")]
1886 pub type_: Option<String>,
1887}
1888
1889impl common::RequestValue for VolumeSnapshot {}
1890impl common::ResponseResult for VolumeSnapshot {}
1891
1892// ###################
1893// MethodBuilders ###
1894// #################
1895
1896/// A builder providing access to all methods supported on *project* resources.
1897/// It is not used directly, but through the [`Baremetalsolution`] hub.
1898///
1899/// # Example
1900///
1901/// Instantiate a resource builder
1902///
1903/// ```test_harness,no_run
1904/// extern crate hyper;
1905/// extern crate hyper_rustls;
1906/// extern crate google_baremetalsolution2 as baremetalsolution2;
1907///
1908/// # async fn dox() {
1909/// use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1910///
1911/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1912/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1913/// secret,
1914/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1915/// ).build().await.unwrap();
1916///
1917/// let client = hyper_util::client::legacy::Client::builder(
1918/// hyper_util::rt::TokioExecutor::new()
1919/// )
1920/// .build(
1921/// hyper_rustls::HttpsConnectorBuilder::new()
1922/// .with_native_roots()
1923/// .unwrap()
1924/// .https_or_http()
1925/// .enable_http1()
1926/// .build()
1927/// );
1928/// let mut hub = Baremetalsolution::new(client, auth);
1929/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1930/// // 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(...)`
1931/// // to build up your call.
1932/// let rb = hub.projects();
1933/// # }
1934/// ```
1935pub struct ProjectMethods<'a, C>
1936where
1937 C: 'a,
1938{
1939 hub: &'a Baremetalsolution<C>,
1940}
1941
1942impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1943
1944impl<'a, C> ProjectMethods<'a, C> {
1945 /// Create a builder to help you perform the following task:
1946 ///
1947 /// Detach LUN from Instance.
1948 ///
1949 /// # Arguments
1950 ///
1951 /// * `request` - No description provided.
1952 /// * `instance` - Required. Name of the instance.
1953 pub fn locations_instances_detach_lun(
1954 &self,
1955 request: DetachLunRequest,
1956 instance: &str,
1957 ) -> ProjectLocationInstanceDetachLunCall<'a, C> {
1958 ProjectLocationInstanceDetachLunCall {
1959 hub: self.hub,
1960 _request: request,
1961 _instance: instance.to_string(),
1962 _delegate: Default::default(),
1963 _additional_params: Default::default(),
1964 _scopes: Default::default(),
1965 }
1966 }
1967
1968 /// Create a builder to help you perform the following task:
1969 ///
1970 /// Perform disable hyperthreading operation on a single server.
1971 ///
1972 /// # Arguments
1973 ///
1974 /// * `request` - No description provided.
1975 /// * `name` - Required. The `name` field is used to identify the instance. Format: projects/{project}/locations/{location}/instances/{instance}
1976 pub fn locations_instances_disable_hyperthreading(
1977 &self,
1978 request: DisableHyperthreadingRequest,
1979 name: &str,
1980 ) -> ProjectLocationInstanceDisableHyperthreadingCall<'a, C> {
1981 ProjectLocationInstanceDisableHyperthreadingCall {
1982 hub: self.hub,
1983 _request: request,
1984 _name: name.to_string(),
1985 _delegate: Default::default(),
1986 _additional_params: Default::default(),
1987 _scopes: Default::default(),
1988 }
1989 }
1990
1991 /// Create a builder to help you perform the following task:
1992 ///
1993 /// Disable the interactive serial console feature on an instance.
1994 ///
1995 /// # Arguments
1996 ///
1997 /// * `request` - No description provided.
1998 /// * `name` - Required. Name of the resource.
1999 pub fn locations_instances_disable_interactive_serial_console(
2000 &self,
2001 request: DisableInteractiveSerialConsoleRequest,
2002 name: &str,
2003 ) -> ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C> {
2004 ProjectLocationInstanceDisableInteractiveSerialConsoleCall {
2005 hub: self.hub,
2006 _request: request,
2007 _name: name.to_string(),
2008 _delegate: Default::default(),
2009 _additional_params: Default::default(),
2010 _scopes: Default::default(),
2011 }
2012 }
2013
2014 /// Create a builder to help you perform the following task:
2015 ///
2016 /// Perform enable hyperthreading operation on a single server.
2017 ///
2018 /// # Arguments
2019 ///
2020 /// * `request` - No description provided.
2021 /// * `name` - Required. The `name` field is used to identify the instance. Format: projects/{project}/locations/{location}/instances/{instance}
2022 pub fn locations_instances_enable_hyperthreading(
2023 &self,
2024 request: EnableHyperthreadingRequest,
2025 name: &str,
2026 ) -> ProjectLocationInstanceEnableHyperthreadingCall<'a, C> {
2027 ProjectLocationInstanceEnableHyperthreadingCall {
2028 hub: self.hub,
2029 _request: request,
2030 _name: name.to_string(),
2031 _delegate: Default::default(),
2032 _additional_params: Default::default(),
2033 _scopes: Default::default(),
2034 }
2035 }
2036
2037 /// Create a builder to help you perform the following task:
2038 ///
2039 /// Enable the interactive serial console feature on an instance.
2040 ///
2041 /// # Arguments
2042 ///
2043 /// * `request` - No description provided.
2044 /// * `name` - Required. Name of the resource.
2045 pub fn locations_instances_enable_interactive_serial_console(
2046 &self,
2047 request: EnableInteractiveSerialConsoleRequest,
2048 name: &str,
2049 ) -> ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'a, C> {
2050 ProjectLocationInstanceEnableInteractiveSerialConsoleCall {
2051 hub: self.hub,
2052 _request: request,
2053 _name: name.to_string(),
2054 _delegate: Default::default(),
2055 _additional_params: Default::default(),
2056 _scopes: Default::default(),
2057 }
2058 }
2059
2060 /// Create a builder to help you perform the following task:
2061 ///
2062 /// Get details about a single server.
2063 ///
2064 /// # Arguments
2065 ///
2066 /// * `name` - Required. Name of the resource.
2067 pub fn locations_instances_get(&self, name: &str) -> ProjectLocationInstanceGetCall<'a, C> {
2068 ProjectLocationInstanceGetCall {
2069 hub: self.hub,
2070 _name: name.to_string(),
2071 _delegate: Default::default(),
2072 _additional_params: Default::default(),
2073 _scopes: Default::default(),
2074 }
2075 }
2076
2077 /// Create a builder to help you perform the following task:
2078 ///
2079 /// List servers in a given project and location.
2080 ///
2081 /// # Arguments
2082 ///
2083 /// * `parent` - Required. Parent value for ListInstancesRequest.
2084 pub fn locations_instances_list(&self, parent: &str) -> ProjectLocationInstanceListCall<'a, C> {
2085 ProjectLocationInstanceListCall {
2086 hub: self.hub,
2087 _parent: parent.to_string(),
2088 _page_token: Default::default(),
2089 _page_size: Default::default(),
2090 _filter: Default::default(),
2091 _delegate: Default::default(),
2092 _additional_params: Default::default(),
2093 _scopes: Default::default(),
2094 }
2095 }
2096
2097 /// Create a builder to help you perform the following task:
2098 ///
2099 /// Load auth info for a server.
2100 ///
2101 /// # Arguments
2102 ///
2103 /// * `name` - Required. Name of the server.
2104 pub fn locations_instances_load_auth_info(
2105 &self,
2106 name: &str,
2107 ) -> ProjectLocationInstanceLoadAuthInfoCall<'a, C> {
2108 ProjectLocationInstanceLoadAuthInfoCall {
2109 hub: self.hub,
2110 _name: name.to_string(),
2111 _delegate: Default::default(),
2112 _additional_params: Default::default(),
2113 _scopes: Default::default(),
2114 }
2115 }
2116
2117 /// Create a builder to help you perform the following task:
2118 ///
2119 /// Update details of a single server.
2120 ///
2121 /// # Arguments
2122 ///
2123 /// * `request` - No description provided.
2124 /// * `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}`
2125 pub fn locations_instances_patch(
2126 &self,
2127 request: Instance,
2128 name: &str,
2129 ) -> ProjectLocationInstancePatchCall<'a, C> {
2130 ProjectLocationInstancePatchCall {
2131 hub: self.hub,
2132 _request: request,
2133 _name: name.to_string(),
2134 _update_mask: Default::default(),
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 /// Perform reimage operation on a single server.
2144 ///
2145 /// # Arguments
2146 ///
2147 /// * `request` - No description provided.
2148 /// * `name` - Required. The `name` field is used to identify the instance. Format: projects/{project}/locations/{location}/instances/{instance}
2149 pub fn locations_instances_reimage(
2150 &self,
2151 request: ReimageInstanceRequest,
2152 name: &str,
2153 ) -> ProjectLocationInstanceReimageCall<'a, C> {
2154 ProjectLocationInstanceReimageCall {
2155 hub: self.hub,
2156 _request: request,
2157 _name: name.to_string(),
2158 _delegate: Default::default(),
2159 _additional_params: Default::default(),
2160 _scopes: Default::default(),
2161 }
2162 }
2163
2164 /// Create a builder to help you perform the following task:
2165 ///
2166 /// RenameInstance sets a new name for an instance. Use with caution, previous names become immediately invalidated.
2167 ///
2168 /// # Arguments
2169 ///
2170 /// * `request` - No description provided.
2171 /// * `name` - Required. The `name` field is used to identify the instance. Format: projects/{project}/locations/{location}/instances/{instance}
2172 pub fn locations_instances_rename(
2173 &self,
2174 request: RenameInstanceRequest,
2175 name: &str,
2176 ) -> ProjectLocationInstanceRenameCall<'a, C> {
2177 ProjectLocationInstanceRenameCall {
2178 hub: self.hub,
2179 _request: request,
2180 _name: name.to_string(),
2181 _delegate: Default::default(),
2182 _additional_params: Default::default(),
2183 _scopes: Default::default(),
2184 }
2185 }
2186
2187 /// Create a builder to help you perform the following task:
2188 ///
2189 /// Perform an ungraceful, hard reset on a server. Equivalent to shutting the power off and then turning it back on.
2190 ///
2191 /// # Arguments
2192 ///
2193 /// * `request` - No description provided.
2194 /// * `name` - Required. Name of the resource.
2195 pub fn locations_instances_reset(
2196 &self,
2197 request: ResetInstanceRequest,
2198 name: &str,
2199 ) -> ProjectLocationInstanceResetCall<'a, C> {
2200 ProjectLocationInstanceResetCall {
2201 hub: self.hub,
2202 _request: request,
2203 _name: name.to_string(),
2204 _delegate: Default::default(),
2205 _additional_params: Default::default(),
2206 _scopes: Default::default(),
2207 }
2208 }
2209
2210 /// Create a builder to help you perform the following task:
2211 ///
2212 /// Starts a server that was shutdown.
2213 ///
2214 /// # Arguments
2215 ///
2216 /// * `request` - No description provided.
2217 /// * `name` - Required. Name of the resource.
2218 pub fn locations_instances_start(
2219 &self,
2220 request: StartInstanceRequest,
2221 name: &str,
2222 ) -> ProjectLocationInstanceStartCall<'a, C> {
2223 ProjectLocationInstanceStartCall {
2224 hub: self.hub,
2225 _request: request,
2226 _name: name.to_string(),
2227 _delegate: Default::default(),
2228 _additional_params: Default::default(),
2229 _scopes: Default::default(),
2230 }
2231 }
2232
2233 /// Create a builder to help you perform the following task:
2234 ///
2235 /// Stop a running server.
2236 ///
2237 /// # Arguments
2238 ///
2239 /// * `request` - No description provided.
2240 /// * `name` - Required. Name of the resource.
2241 pub fn locations_instances_stop(
2242 &self,
2243 request: StopInstanceRequest,
2244 name: &str,
2245 ) -> ProjectLocationInstanceStopCall<'a, C> {
2246 ProjectLocationInstanceStopCall {
2247 hub: self.hub,
2248 _request: request,
2249 _name: name.to_string(),
2250 _delegate: Default::default(),
2251 _additional_params: Default::default(),
2252 _scopes: Default::default(),
2253 }
2254 }
2255
2256 /// Create a builder to help you perform the following task:
2257 ///
2258 /// Get details of a single network.
2259 ///
2260 /// # Arguments
2261 ///
2262 /// * `name` - Required. Name of the resource.
2263 pub fn locations_networks_get(&self, name: &str) -> ProjectLocationNetworkGetCall<'a, C> {
2264 ProjectLocationNetworkGetCall {
2265 hub: self.hub,
2266 _name: name.to_string(),
2267 _delegate: Default::default(),
2268 _additional_params: Default::default(),
2269 _scopes: Default::default(),
2270 }
2271 }
2272
2273 /// Create a builder to help you perform the following task:
2274 ///
2275 /// List network in a given project and location.
2276 ///
2277 /// # Arguments
2278 ///
2279 /// * `parent` - Required. Parent value for ListNetworksRequest.
2280 pub fn locations_networks_list(&self, parent: &str) -> ProjectLocationNetworkListCall<'a, C> {
2281 ProjectLocationNetworkListCall {
2282 hub: self.hub,
2283 _parent: parent.to_string(),
2284 _page_token: Default::default(),
2285 _page_size: Default::default(),
2286 _filter: Default::default(),
2287 _delegate: Default::default(),
2288 _additional_params: Default::default(),
2289 _scopes: Default::default(),
2290 }
2291 }
2292
2293 /// Create a builder to help you perform the following task:
2294 ///
2295 /// List all Networks (and used IPs for each Network) in the vendor account associated with the specified project.
2296 ///
2297 /// # Arguments
2298 ///
2299 /// * `location` - Required. Parent value (project and location).
2300 pub fn locations_networks_list_network_usage(
2301 &self,
2302 location: &str,
2303 ) -> ProjectLocationNetworkListNetworkUsageCall<'a, C> {
2304 ProjectLocationNetworkListNetworkUsageCall {
2305 hub: self.hub,
2306 _location: location.to_string(),
2307 _delegate: Default::default(),
2308 _additional_params: Default::default(),
2309 _scopes: Default::default(),
2310 }
2311 }
2312
2313 /// Create a builder to help you perform the following task:
2314 ///
2315 /// Update details of a single network.
2316 ///
2317 /// # Arguments
2318 ///
2319 /// * `request` - No description provided.
2320 /// * `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}`
2321 pub fn locations_networks_patch(
2322 &self,
2323 request: Network,
2324 name: &str,
2325 ) -> ProjectLocationNetworkPatchCall<'a, C> {
2326 ProjectLocationNetworkPatchCall {
2327 hub: self.hub,
2328 _request: request,
2329 _name: name.to_string(),
2330 _update_mask: Default::default(),
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 /// RenameNetwork sets a new name for a network. Use with caution, previous names become immediately invalidated.
2340 ///
2341 /// # Arguments
2342 ///
2343 /// * `request` - No description provided.
2344 /// * `name` - Required. The `name` field is used to identify the network. Format: projects/{project}/locations/{location}/networks/{network}
2345 pub fn locations_networks_rename(
2346 &self,
2347 request: RenameNetworkRequest,
2348 name: &str,
2349 ) -> ProjectLocationNetworkRenameCall<'a, C> {
2350 ProjectLocationNetworkRenameCall {
2351 hub: self.hub,
2352 _request: request,
2353 _name: name.to_string(),
2354 _delegate: Default::default(),
2355 _additional_params: Default::default(),
2356 _scopes: Default::default(),
2357 }
2358 }
2359
2360 /// Create a builder to help you perform the following task:
2361 ///
2362 /// Create an NFS share.
2363 ///
2364 /// # Arguments
2365 ///
2366 /// * `request` - No description provided.
2367 /// * `parent` - Required. The parent project and location.
2368 pub fn locations_nfs_shares_create(
2369 &self,
2370 request: NfsShare,
2371 parent: &str,
2372 ) -> ProjectLocationNfsShareCreateCall<'a, C> {
2373 ProjectLocationNfsShareCreateCall {
2374 hub: self.hub,
2375 _request: request,
2376 _parent: parent.to_string(),
2377 _delegate: Default::default(),
2378 _additional_params: Default::default(),
2379 _scopes: Default::default(),
2380 }
2381 }
2382
2383 /// Create a builder to help you perform the following task:
2384 ///
2385 /// Delete an NFS share. The underlying volume is automatically deleted.
2386 ///
2387 /// # Arguments
2388 ///
2389 /// * `name` - Required. The name of the NFS share to delete.
2390 pub fn locations_nfs_shares_delete(
2391 &self,
2392 name: &str,
2393 ) -> ProjectLocationNfsShareDeleteCall<'a, C> {
2394 ProjectLocationNfsShareDeleteCall {
2395 hub: self.hub,
2396 _name: name.to_string(),
2397 _delegate: Default::default(),
2398 _additional_params: Default::default(),
2399 _scopes: Default::default(),
2400 }
2401 }
2402
2403 /// Create a builder to help you perform the following task:
2404 ///
2405 /// Get details of a single NFS share.
2406 ///
2407 /// # Arguments
2408 ///
2409 /// * `name` - Required. Name of the resource.
2410 pub fn locations_nfs_shares_get(&self, name: &str) -> ProjectLocationNfsShareGetCall<'a, C> {
2411 ProjectLocationNfsShareGetCall {
2412 hub: self.hub,
2413 _name: name.to_string(),
2414 _delegate: Default::default(),
2415 _additional_params: Default::default(),
2416 _scopes: Default::default(),
2417 }
2418 }
2419
2420 /// Create a builder to help you perform the following task:
2421 ///
2422 /// List NFS shares.
2423 ///
2424 /// # Arguments
2425 ///
2426 /// * `parent` - Required. Parent value for ListNfsSharesRequest.
2427 pub fn locations_nfs_shares_list(
2428 &self,
2429 parent: &str,
2430 ) -> ProjectLocationNfsShareListCall<'a, C> {
2431 ProjectLocationNfsShareListCall {
2432 hub: self.hub,
2433 _parent: parent.to_string(),
2434 _page_token: Default::default(),
2435 _page_size: Default::default(),
2436 _filter: Default::default(),
2437 _delegate: Default::default(),
2438 _additional_params: Default::default(),
2439 _scopes: Default::default(),
2440 }
2441 }
2442
2443 /// Create a builder to help you perform the following task:
2444 ///
2445 /// Update details of a single NFS share.
2446 ///
2447 /// # Arguments
2448 ///
2449 /// * `request` - No description provided.
2450 /// * `name` - Immutable. The name of the NFS share.
2451 pub fn locations_nfs_shares_patch(
2452 &self,
2453 request: NfsShare,
2454 name: &str,
2455 ) -> ProjectLocationNfsSharePatchCall<'a, C> {
2456 ProjectLocationNfsSharePatchCall {
2457 hub: self.hub,
2458 _request: request,
2459 _name: name.to_string(),
2460 _update_mask: 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 /// RenameNfsShare sets a new name for an nfsshare. Use with caution, previous names become immediately invalidated.
2470 ///
2471 /// # Arguments
2472 ///
2473 /// * `request` - No description provided.
2474 /// * `name` - Required. The `name` field is used to identify the nfsshare. Format: projects/{project}/locations/{location}/nfsshares/{nfsshare}
2475 pub fn locations_nfs_shares_rename(
2476 &self,
2477 request: RenameNfsShareRequest,
2478 name: &str,
2479 ) -> ProjectLocationNfsShareRenameCall<'a, C> {
2480 ProjectLocationNfsShareRenameCall {
2481 hub: self.hub,
2482 _request: request,
2483 _name: name.to_string(),
2484 _delegate: Default::default(),
2485 _additional_params: Default::default(),
2486 _scopes: Default::default(),
2487 }
2488 }
2489
2490 /// Create a builder to help you perform the following task:
2491 ///
2492 /// Get details about an operation.
2493 ///
2494 /// # Arguments
2495 ///
2496 /// * `name` - The name of the operation resource.
2497 pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
2498 ProjectLocationOperationGetCall {
2499 hub: self.hub,
2500 _name: name.to_string(),
2501 _delegate: Default::default(),
2502 _additional_params: Default::default(),
2503 _scopes: Default::default(),
2504 }
2505 }
2506
2507 /// Create a builder to help you perform the following task:
2508 ///
2509 /// Get details of a single OS image.
2510 ///
2511 /// # Arguments
2512 ///
2513 /// * `name` - Required. Name of the OS image.
2514 pub fn locations_os_images_get(&self, name: &str) -> ProjectLocationOsImageGetCall<'a, C> {
2515 ProjectLocationOsImageGetCall {
2516 hub: self.hub,
2517 _name: name.to_string(),
2518 _delegate: Default::default(),
2519 _additional_params: Default::default(),
2520 _scopes: Default::default(),
2521 }
2522 }
2523
2524 /// Create a builder to help you perform the following task:
2525 ///
2526 /// Retrieves the list of OS images which are currently approved.
2527 ///
2528 /// # Arguments
2529 ///
2530 /// * `parent` - Required. Parent value for ListOSImagesRequest.
2531 pub fn locations_os_images_list(&self, parent: &str) -> ProjectLocationOsImageListCall<'a, C> {
2532 ProjectLocationOsImageListCall {
2533 hub: self.hub,
2534 _parent: parent.to_string(),
2535 _page_token: Default::default(),
2536 _page_size: Default::default(),
2537 _delegate: Default::default(),
2538 _additional_params: Default::default(),
2539 _scopes: Default::default(),
2540 }
2541 }
2542
2543 /// Create a builder to help you perform the following task:
2544 ///
2545 /// Create new ProvisioningConfig.
2546 ///
2547 /// # Arguments
2548 ///
2549 /// * `request` - No description provided.
2550 /// * `parent` - Required. The parent project and location containing the ProvisioningConfig.
2551 pub fn locations_provisioning_configs_create(
2552 &self,
2553 request: ProvisioningConfig,
2554 parent: &str,
2555 ) -> ProjectLocationProvisioningConfigCreateCall<'a, C> {
2556 ProjectLocationProvisioningConfigCreateCall {
2557 hub: self.hub,
2558 _request: request,
2559 _parent: parent.to_string(),
2560 _email: 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 /// Get ProvisioningConfig by name.
2570 ///
2571 /// # Arguments
2572 ///
2573 /// * `name` - Required. Name of the ProvisioningConfig.
2574 pub fn locations_provisioning_configs_get(
2575 &self,
2576 name: &str,
2577 ) -> ProjectLocationProvisioningConfigGetCall<'a, C> {
2578 ProjectLocationProvisioningConfigGetCall {
2579 hub: self.hub,
2580 _name: name.to_string(),
2581 _delegate: Default::default(),
2582 _additional_params: Default::default(),
2583 _scopes: Default::default(),
2584 }
2585 }
2586
2587 /// Create a builder to help you perform the following task:
2588 ///
2589 /// Update existing ProvisioningConfig.
2590 ///
2591 /// # Arguments
2592 ///
2593 /// * `request` - No description provided.
2594 /// * `name` - Output only. The system-generated name of the provisioning config. This follows the UUID format.
2595 pub fn locations_provisioning_configs_patch(
2596 &self,
2597 request: ProvisioningConfig,
2598 name: &str,
2599 ) -> ProjectLocationProvisioningConfigPatchCall<'a, C> {
2600 ProjectLocationProvisioningConfigPatchCall {
2601 hub: self.hub,
2602 _request: request,
2603 _name: name.to_string(),
2604 _update_mask: Default::default(),
2605 _email: Default::default(),
2606 _delegate: Default::default(),
2607 _additional_params: Default::default(),
2608 _scopes: Default::default(),
2609 }
2610 }
2611
2612 /// Create a builder to help you perform the following task:
2613 ///
2614 /// Submit a provisiong configuration for a given project.
2615 ///
2616 /// # Arguments
2617 ///
2618 /// * `request` - No description provided.
2619 /// * `parent` - Required. The parent project and location containing the ProvisioningConfig.
2620 pub fn locations_provisioning_configs_submit(
2621 &self,
2622 request: SubmitProvisioningConfigRequest,
2623 parent: &str,
2624 ) -> ProjectLocationProvisioningConfigSubmitCall<'a, C> {
2625 ProjectLocationProvisioningConfigSubmitCall {
2626 hub: self.hub,
2627 _request: request,
2628 _parent: parent.to_string(),
2629 _delegate: Default::default(),
2630 _additional_params: Default::default(),
2631 _scopes: Default::default(),
2632 }
2633 }
2634
2635 /// Create a builder to help you perform the following task:
2636 ///
2637 /// List the budget details to provision resources on a given project.
2638 ///
2639 /// # Arguments
2640 ///
2641 /// * `parent` - Required. Parent value for ListProvisioningQuotasRequest.
2642 pub fn locations_provisioning_quotas_list(
2643 &self,
2644 parent: &str,
2645 ) -> ProjectLocationProvisioningQuotaListCall<'a, C> {
2646 ProjectLocationProvisioningQuotaListCall {
2647 hub: self.hub,
2648 _parent: parent.to_string(),
2649 _page_token: Default::default(),
2650 _page_size: Default::default(),
2651 _delegate: Default::default(),
2652 _additional_params: Default::default(),
2653 _scopes: Default::default(),
2654 }
2655 }
2656
2657 /// Create a builder to help you perform the following task:
2658 ///
2659 /// Register a public SSH key in the specified project for use with the interactive serial console feature.
2660 ///
2661 /// # Arguments
2662 ///
2663 /// * `request` - No description provided.
2664 /// * `parent` - Required. The parent containing the SSH keys.
2665 pub fn locations_ssh_keys_create(
2666 &self,
2667 request: SSHKey,
2668 parent: &str,
2669 ) -> ProjectLocationSshKeyCreateCall<'a, C> {
2670 ProjectLocationSshKeyCreateCall {
2671 hub: self.hub,
2672 _request: request,
2673 _parent: parent.to_string(),
2674 _ssh_key_id: 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 /// Deletes a public SSH key registered in the specified project.
2684 ///
2685 /// # Arguments
2686 ///
2687 /// * `name` - Required. The name of the SSH key to delete. Currently, the only valid value for the location is "global".
2688 pub fn locations_ssh_keys_delete(&self, name: &str) -> ProjectLocationSshKeyDeleteCall<'a, C> {
2689 ProjectLocationSshKeyDeleteCall {
2690 hub: self.hub,
2691 _name: name.to_string(),
2692 _delegate: Default::default(),
2693 _additional_params: Default::default(),
2694 _scopes: Default::default(),
2695 }
2696 }
2697
2698 /// Create a builder to help you perform the following task:
2699 ///
2700 /// Lists the public SSH keys registered for the specified project. These SSH keys are used only for the interactive serial console feature.
2701 ///
2702 /// # Arguments
2703 ///
2704 /// * `parent` - Required. The parent containing the SSH keys. Currently, the only valid value for the location is "global".
2705 pub fn locations_ssh_keys_list(&self, parent: &str) -> ProjectLocationSshKeyListCall<'a, C> {
2706 ProjectLocationSshKeyListCall {
2707 hub: self.hub,
2708 _parent: parent.to_string(),
2709 _page_token: Default::default(),
2710 _page_size: Default::default(),
2711 _delegate: Default::default(),
2712 _additional_params: Default::default(),
2713 _scopes: Default::default(),
2714 }
2715 }
2716
2717 /// Create a builder to help you perform the following task:
2718 ///
2719 /// Skips lun's cooloff and deletes it now. Lun must be in cooloff state.
2720 ///
2721 /// # Arguments
2722 ///
2723 /// * `request` - No description provided.
2724 /// * `name` - Required. The name of the lun.
2725 pub fn locations_volumes_luns_evict(
2726 &self,
2727 request: EvictLunRequest,
2728 name: &str,
2729 ) -> ProjectLocationVolumeLunEvictCall<'a, C> {
2730 ProjectLocationVolumeLunEvictCall {
2731 hub: self.hub,
2732 _request: request,
2733 _name: name.to_string(),
2734 _delegate: Default::default(),
2735 _additional_params: Default::default(),
2736 _scopes: Default::default(),
2737 }
2738 }
2739
2740 /// Create a builder to help you perform the following task:
2741 ///
2742 /// Get details of a single storage logical unit number(LUN).
2743 ///
2744 /// # Arguments
2745 ///
2746 /// * `name` - Required. Name of the resource.
2747 pub fn locations_volumes_luns_get(&self, name: &str) -> ProjectLocationVolumeLunGetCall<'a, C> {
2748 ProjectLocationVolumeLunGetCall {
2749 hub: self.hub,
2750 _name: name.to_string(),
2751 _delegate: Default::default(),
2752 _additional_params: Default::default(),
2753 _scopes: Default::default(),
2754 }
2755 }
2756
2757 /// Create a builder to help you perform the following task:
2758 ///
2759 /// List storage volume luns for given storage volume.
2760 ///
2761 /// # Arguments
2762 ///
2763 /// * `parent` - Required. Parent value for ListLunsRequest.
2764 pub fn locations_volumes_luns_list(
2765 &self,
2766 parent: &str,
2767 ) -> ProjectLocationVolumeLunListCall<'a, C> {
2768 ProjectLocationVolumeLunListCall {
2769 hub: self.hub,
2770 _parent: parent.to_string(),
2771 _page_token: Default::default(),
2772 _page_size: Default::default(),
2773 _delegate: Default::default(),
2774 _additional_params: Default::default(),
2775 _scopes: Default::default(),
2776 }
2777 }
2778
2779 /// Create a builder to help you perform the following task:
2780 ///
2781 /// Takes a snapshot of a boot volume. Returns INVALID_ARGUMENT if called for a non-boot volume.
2782 ///
2783 /// # Arguments
2784 ///
2785 /// * `request` - No description provided.
2786 /// * `parent` - Required. The volume to snapshot.
2787 pub fn locations_volumes_snapshots_create(
2788 &self,
2789 request: VolumeSnapshot,
2790 parent: &str,
2791 ) -> ProjectLocationVolumeSnapshotCreateCall<'a, C> {
2792 ProjectLocationVolumeSnapshotCreateCall {
2793 hub: self.hub,
2794 _request: request,
2795 _parent: parent.to_string(),
2796 _delegate: Default::default(),
2797 _additional_params: Default::default(),
2798 _scopes: Default::default(),
2799 }
2800 }
2801
2802 /// Create a builder to help you perform the following task:
2803 ///
2804 /// Deletes a volume snapshot. Returns INVALID_ARGUMENT if called for a non-boot volume.
2805 ///
2806 /// # Arguments
2807 ///
2808 /// * `name` - Required. The name of the snapshot to delete.
2809 pub fn locations_volumes_snapshots_delete(
2810 &self,
2811 name: &str,
2812 ) -> ProjectLocationVolumeSnapshotDeleteCall<'a, C> {
2813 ProjectLocationVolumeSnapshotDeleteCall {
2814 hub: self.hub,
2815 _name: name.to_string(),
2816 _delegate: Default::default(),
2817 _additional_params: Default::default(),
2818 _scopes: Default::default(),
2819 }
2820 }
2821
2822 /// Create a builder to help you perform the following task:
2823 ///
2824 /// Returns the specified snapshot resource. Returns INVALID_ARGUMENT if called for a non-boot volume.
2825 ///
2826 /// # Arguments
2827 ///
2828 /// * `name` - Required. The name of the snapshot.
2829 pub fn locations_volumes_snapshots_get(
2830 &self,
2831 name: &str,
2832 ) -> ProjectLocationVolumeSnapshotGetCall<'a, C> {
2833 ProjectLocationVolumeSnapshotGetCall {
2834 hub: self.hub,
2835 _name: name.to_string(),
2836 _delegate: Default::default(),
2837 _additional_params: Default::default(),
2838 _scopes: Default::default(),
2839 }
2840 }
2841
2842 /// Create a builder to help you perform the following task:
2843 ///
2844 /// 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.
2845 ///
2846 /// # Arguments
2847 ///
2848 /// * `parent` - Required. Parent value for ListVolumesRequest.
2849 pub fn locations_volumes_snapshots_list(
2850 &self,
2851 parent: &str,
2852 ) -> ProjectLocationVolumeSnapshotListCall<'a, C> {
2853 ProjectLocationVolumeSnapshotListCall {
2854 hub: self.hub,
2855 _parent: parent.to_string(),
2856 _page_token: Default::default(),
2857 _page_size: Default::default(),
2858 _delegate: Default::default(),
2859 _additional_params: Default::default(),
2860 _scopes: Default::default(),
2861 }
2862 }
2863
2864 /// Create a builder to help you perform the following task:
2865 ///
2866 /// Uses the specified snapshot to restore its parent volume. Returns INVALID_ARGUMENT if called for a non-boot volume.
2867 ///
2868 /// # Arguments
2869 ///
2870 /// * `request` - No description provided.
2871 /// * `volumeSnapshot` - Required. Name of the snapshot which will be used to restore its parent volume.
2872 pub fn locations_volumes_snapshots_restore_volume_snapshot(
2873 &self,
2874 request: RestoreVolumeSnapshotRequest,
2875 volume_snapshot: &str,
2876 ) -> ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C> {
2877 ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall {
2878 hub: self.hub,
2879 _request: request,
2880 _volume_snapshot: volume_snapshot.to_string(),
2881 _delegate: Default::default(),
2882 _additional_params: Default::default(),
2883 _scopes: Default::default(),
2884 }
2885 }
2886
2887 /// Create a builder to help you perform the following task:
2888 ///
2889 /// Skips volume's cooloff and deletes it now. Volume must be in cooloff state.
2890 ///
2891 /// # Arguments
2892 ///
2893 /// * `request` - No description provided.
2894 /// * `name` - Required. The name of the Volume.
2895 pub fn locations_volumes_evict(
2896 &self,
2897 request: EvictVolumeRequest,
2898 name: &str,
2899 ) -> ProjectLocationVolumeEvictCall<'a, C> {
2900 ProjectLocationVolumeEvictCall {
2901 hub: self.hub,
2902 _request: request,
2903 _name: name.to_string(),
2904 _delegate: Default::default(),
2905 _additional_params: Default::default(),
2906 _scopes: Default::default(),
2907 }
2908 }
2909
2910 /// Create a builder to help you perform the following task:
2911 ///
2912 /// Get details of a single storage volume.
2913 ///
2914 /// # Arguments
2915 ///
2916 /// * `name` - Required. Name of the resource.
2917 pub fn locations_volumes_get(&self, name: &str) -> ProjectLocationVolumeGetCall<'a, C> {
2918 ProjectLocationVolumeGetCall {
2919 hub: self.hub,
2920 _name: name.to_string(),
2921 _delegate: Default::default(),
2922 _additional_params: Default::default(),
2923 _scopes: Default::default(),
2924 }
2925 }
2926
2927 /// Create a builder to help you perform the following task:
2928 ///
2929 /// List storage volumes in a given project and location.
2930 ///
2931 /// # Arguments
2932 ///
2933 /// * `parent` - Required. Parent value for ListVolumesRequest.
2934 pub fn locations_volumes_list(&self, parent: &str) -> ProjectLocationVolumeListCall<'a, C> {
2935 ProjectLocationVolumeListCall {
2936 hub: self.hub,
2937 _parent: parent.to_string(),
2938 _page_token: Default::default(),
2939 _page_size: Default::default(),
2940 _filter: Default::default(),
2941 _delegate: Default::default(),
2942 _additional_params: Default::default(),
2943 _scopes: Default::default(),
2944 }
2945 }
2946
2947 /// Create a builder to help you perform the following task:
2948 ///
2949 /// Update details of a single storage volume.
2950 ///
2951 /// # Arguments
2952 ///
2953 /// * `request` - No description provided.
2954 /// * `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}`
2955 pub fn locations_volumes_patch(
2956 &self,
2957 request: Volume,
2958 name: &str,
2959 ) -> ProjectLocationVolumePatchCall<'a, C> {
2960 ProjectLocationVolumePatchCall {
2961 hub: self.hub,
2962 _request: request,
2963 _name: name.to_string(),
2964 _update_mask: 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 /// RenameVolume sets a new name for a volume. Use with caution, previous names become immediately invalidated.
2974 ///
2975 /// # Arguments
2976 ///
2977 /// * `request` - No description provided.
2978 /// * `name` - Required. The `name` field is used to identify the volume. Format: projects/{project}/locations/{location}/volumes/{volume}
2979 pub fn locations_volumes_rename(
2980 &self,
2981 request: RenameVolumeRequest,
2982 name: &str,
2983 ) -> ProjectLocationVolumeRenameCall<'a, C> {
2984 ProjectLocationVolumeRenameCall {
2985 hub: self.hub,
2986 _request: request,
2987 _name: name.to_string(),
2988 _delegate: Default::default(),
2989 _additional_params: Default::default(),
2990 _scopes: Default::default(),
2991 }
2992 }
2993
2994 /// Create a builder to help you perform the following task:
2995 ///
2996 /// Emergency Volume resize.
2997 ///
2998 /// # Arguments
2999 ///
3000 /// * `request` - No description provided.
3001 /// * `volume` - Required. Volume to resize.
3002 pub fn locations_volumes_resize(
3003 &self,
3004 request: ResizeVolumeRequest,
3005 volume: &str,
3006 ) -> ProjectLocationVolumeResizeCall<'a, C> {
3007 ProjectLocationVolumeResizeCall {
3008 hub: self.hub,
3009 _request: request,
3010 _volume: volume.to_string(),
3011 _delegate: Default::default(),
3012 _additional_params: Default::default(),
3013 _scopes: Default::default(),
3014 }
3015 }
3016
3017 /// Create a builder to help you perform the following task:
3018 ///
3019 /// Gets information about a location.
3020 ///
3021 /// # Arguments
3022 ///
3023 /// * `name` - Resource name for the location.
3024 pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
3025 ProjectLocationGetCall {
3026 hub: self.hub,
3027 _name: name.to_string(),
3028 _delegate: Default::default(),
3029 _additional_params: Default::default(),
3030 _scopes: Default::default(),
3031 }
3032 }
3033
3034 /// Create a builder to help you perform the following task:
3035 ///
3036 /// Lists information about the supported locations for this service.
3037 ///
3038 /// # Arguments
3039 ///
3040 /// * `name` - The resource that owns the locations collection, if applicable.
3041 pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
3042 ProjectLocationListCall {
3043 hub: self.hub,
3044 _name: name.to_string(),
3045 _page_token: Default::default(),
3046 _page_size: Default::default(),
3047 _filter: Default::default(),
3048 _delegate: Default::default(),
3049 _additional_params: Default::default(),
3050 _scopes: Default::default(),
3051 }
3052 }
3053}
3054
3055// ###################
3056// CallBuilders ###
3057// #################
3058
3059/// Detach LUN from Instance.
3060///
3061/// A builder for the *locations.instances.detachLun* method supported by a *project* resource.
3062/// It is not used directly, but through a [`ProjectMethods`] instance.
3063///
3064/// # Example
3065///
3066/// Instantiate a resource method builder
3067///
3068/// ```test_harness,no_run
3069/// # extern crate hyper;
3070/// # extern crate hyper_rustls;
3071/// # extern crate google_baremetalsolution2 as baremetalsolution2;
3072/// use baremetalsolution2::api::DetachLunRequest;
3073/// # async fn dox() {
3074/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3075///
3076/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3077/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3078/// # secret,
3079/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3080/// # ).build().await.unwrap();
3081///
3082/// # let client = hyper_util::client::legacy::Client::builder(
3083/// # hyper_util::rt::TokioExecutor::new()
3084/// # )
3085/// # .build(
3086/// # hyper_rustls::HttpsConnectorBuilder::new()
3087/// # .with_native_roots()
3088/// # .unwrap()
3089/// # .https_or_http()
3090/// # .enable_http1()
3091/// # .build()
3092/// # );
3093/// # let mut hub = Baremetalsolution::new(client, auth);
3094/// // As the method needs a request, you would usually fill it with the desired information
3095/// // into the respective structure. Some of the parts shown here might not be applicable !
3096/// // Values shown here are possibly random and not representative !
3097/// let mut req = DetachLunRequest::default();
3098///
3099/// // You can configure optional parameters by calling the respective setters at will, and
3100/// // execute the final call using `doit()`.
3101/// // Values shown here are possibly random and not representative !
3102/// let result = hub.projects().locations_instances_detach_lun(req, "instance")
3103/// .doit().await;
3104/// # }
3105/// ```
3106pub struct ProjectLocationInstanceDetachLunCall<'a, C>
3107where
3108 C: 'a,
3109{
3110 hub: &'a Baremetalsolution<C>,
3111 _request: DetachLunRequest,
3112 _instance: String,
3113 _delegate: Option<&'a mut dyn common::Delegate>,
3114 _additional_params: HashMap<String, String>,
3115 _scopes: BTreeSet<String>,
3116}
3117
3118impl<'a, C> common::CallBuilder for ProjectLocationInstanceDetachLunCall<'a, C> {}
3119
3120impl<'a, C> ProjectLocationInstanceDetachLunCall<'a, C>
3121where
3122 C: common::Connector,
3123{
3124 /// Perform the operation you have build so far.
3125 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3126 use std::borrow::Cow;
3127 use std::io::{Read, Seek};
3128
3129 use common::{url::Params, ToParts};
3130 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3131
3132 let mut dd = common::DefaultDelegate;
3133 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3134 dlg.begin(common::MethodInfo {
3135 id: "baremetalsolution.projects.locations.instances.detachLun",
3136 http_method: hyper::Method::POST,
3137 });
3138
3139 for &field in ["alt", "instance"].iter() {
3140 if self._additional_params.contains_key(field) {
3141 dlg.finished(false);
3142 return Err(common::Error::FieldClash(field));
3143 }
3144 }
3145
3146 let mut params = Params::with_capacity(4 + self._additional_params.len());
3147 params.push("instance", self._instance);
3148
3149 params.extend(self._additional_params.iter());
3150
3151 params.push("alt", "json");
3152 let mut url = self.hub._base_url.clone() + "v2/{+instance}:detachLun";
3153 if self._scopes.is_empty() {
3154 self._scopes
3155 .insert(Scope::CloudPlatform.as_ref().to_string());
3156 }
3157
3158 #[allow(clippy::single_element_loop)]
3159 for &(find_this, param_name) in [("{+instance}", "instance")].iter() {
3160 url = params.uri_replacement(url, param_name, find_this, true);
3161 }
3162 {
3163 let to_remove = ["instance"];
3164 params.remove_params(&to_remove);
3165 }
3166
3167 let url = params.parse_with_url(&url);
3168
3169 let mut json_mime_type = mime::APPLICATION_JSON;
3170 let mut request_value_reader = {
3171 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3172 common::remove_json_null_values(&mut value);
3173 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3174 serde_json::to_writer(&mut dst, &value).unwrap();
3175 dst
3176 };
3177 let request_size = request_value_reader
3178 .seek(std::io::SeekFrom::End(0))
3179 .unwrap();
3180 request_value_reader
3181 .seek(std::io::SeekFrom::Start(0))
3182 .unwrap();
3183
3184 loop {
3185 let token = match self
3186 .hub
3187 .auth
3188 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3189 .await
3190 {
3191 Ok(token) => token,
3192 Err(e) => match dlg.token(e) {
3193 Ok(token) => token,
3194 Err(e) => {
3195 dlg.finished(false);
3196 return Err(common::Error::MissingToken(e));
3197 }
3198 },
3199 };
3200 request_value_reader
3201 .seek(std::io::SeekFrom::Start(0))
3202 .unwrap();
3203 let mut req_result = {
3204 let client = &self.hub.client;
3205 dlg.pre_request();
3206 let mut req_builder = hyper::Request::builder()
3207 .method(hyper::Method::POST)
3208 .uri(url.as_str())
3209 .header(USER_AGENT, self.hub._user_agent.clone());
3210
3211 if let Some(token) = token.as_ref() {
3212 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3213 }
3214
3215 let request = req_builder
3216 .header(CONTENT_TYPE, json_mime_type.to_string())
3217 .header(CONTENT_LENGTH, request_size as u64)
3218 .body(common::to_body(
3219 request_value_reader.get_ref().clone().into(),
3220 ));
3221
3222 client.request(request.unwrap()).await
3223 };
3224
3225 match req_result {
3226 Err(err) => {
3227 if let common::Retry::After(d) = dlg.http_error(&err) {
3228 sleep(d).await;
3229 continue;
3230 }
3231 dlg.finished(false);
3232 return Err(common::Error::HttpError(err));
3233 }
3234 Ok(res) => {
3235 let (mut parts, body) = res.into_parts();
3236 let mut body = common::Body::new(body);
3237 if !parts.status.is_success() {
3238 let bytes = common::to_bytes(body).await.unwrap_or_default();
3239 let error = serde_json::from_str(&common::to_string(&bytes));
3240 let response = common::to_response(parts, bytes.into());
3241
3242 if let common::Retry::After(d) =
3243 dlg.http_failure(&response, error.as_ref().ok())
3244 {
3245 sleep(d).await;
3246 continue;
3247 }
3248
3249 dlg.finished(false);
3250
3251 return Err(match error {
3252 Ok(value) => common::Error::BadRequest(value),
3253 _ => common::Error::Failure(response),
3254 });
3255 }
3256 let response = {
3257 let bytes = common::to_bytes(body).await.unwrap_or_default();
3258 let encoded = common::to_string(&bytes);
3259 match serde_json::from_str(&encoded) {
3260 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3261 Err(error) => {
3262 dlg.response_json_decode_error(&encoded, &error);
3263 return Err(common::Error::JsonDecodeError(
3264 encoded.to_string(),
3265 error,
3266 ));
3267 }
3268 }
3269 };
3270
3271 dlg.finished(true);
3272 return Ok(response);
3273 }
3274 }
3275 }
3276 }
3277
3278 ///
3279 /// Sets the *request* property to the given value.
3280 ///
3281 /// Even though the property as already been set when instantiating this call,
3282 /// we provide this method for API completeness.
3283 pub fn request(
3284 mut self,
3285 new_value: DetachLunRequest,
3286 ) -> ProjectLocationInstanceDetachLunCall<'a, C> {
3287 self._request = new_value;
3288 self
3289 }
3290 /// Required. Name of the instance.
3291 ///
3292 /// Sets the *instance* path property to the given value.
3293 ///
3294 /// Even though the property as already been set when instantiating this call,
3295 /// we provide this method for API completeness.
3296 pub fn instance(mut self, new_value: &str) -> ProjectLocationInstanceDetachLunCall<'a, C> {
3297 self._instance = new_value.to_string();
3298 self
3299 }
3300 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3301 /// while executing the actual API request.
3302 ///
3303 /// ````text
3304 /// It should be used to handle progress information, and to implement a certain level of resilience.
3305 /// ````
3306 ///
3307 /// Sets the *delegate* property to the given value.
3308 pub fn delegate(
3309 mut self,
3310 new_value: &'a mut dyn common::Delegate,
3311 ) -> ProjectLocationInstanceDetachLunCall<'a, C> {
3312 self._delegate = Some(new_value);
3313 self
3314 }
3315
3316 /// Set any additional parameter of the query string used in the request.
3317 /// It should be used to set parameters which are not yet available through their own
3318 /// setters.
3319 ///
3320 /// Please note that this method must not be used to set any of the known parameters
3321 /// which have their own setter method. If done anyway, the request will fail.
3322 ///
3323 /// # Additional Parameters
3324 ///
3325 /// * *$.xgafv* (query-string) - V1 error format.
3326 /// * *access_token* (query-string) - OAuth access token.
3327 /// * *alt* (query-string) - Data format for response.
3328 /// * *callback* (query-string) - JSONP
3329 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3330 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3331 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3332 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3333 /// * *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.
3334 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3335 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3336 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceDetachLunCall<'a, C>
3337 where
3338 T: AsRef<str>,
3339 {
3340 self._additional_params
3341 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3342 self
3343 }
3344
3345 /// Identifies the authorization scope for the method you are building.
3346 ///
3347 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3348 /// [`Scope::CloudPlatform`].
3349 ///
3350 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3351 /// tokens for more than one scope.
3352 ///
3353 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3354 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3355 /// sufficient, a read-write scope will do as well.
3356 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceDetachLunCall<'a, C>
3357 where
3358 St: AsRef<str>,
3359 {
3360 self._scopes.insert(String::from(scope.as_ref()));
3361 self
3362 }
3363 /// Identifies the authorization scope(s) for the method you are building.
3364 ///
3365 /// See [`Self::add_scope()`] for details.
3366 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceDetachLunCall<'a, C>
3367 where
3368 I: IntoIterator<Item = St>,
3369 St: AsRef<str>,
3370 {
3371 self._scopes
3372 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3373 self
3374 }
3375
3376 /// Removes all scopes, and no default scope will be used either.
3377 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3378 /// for details).
3379 pub fn clear_scopes(mut self) -> ProjectLocationInstanceDetachLunCall<'a, C> {
3380 self._scopes.clear();
3381 self
3382 }
3383}
3384
3385/// Perform disable hyperthreading operation on a single server.
3386///
3387/// A builder for the *locations.instances.disableHyperthreading* method supported by a *project* resource.
3388/// It is not used directly, but through a [`ProjectMethods`] instance.
3389///
3390/// # Example
3391///
3392/// Instantiate a resource method builder
3393///
3394/// ```test_harness,no_run
3395/// # extern crate hyper;
3396/// # extern crate hyper_rustls;
3397/// # extern crate google_baremetalsolution2 as baremetalsolution2;
3398/// use baremetalsolution2::api::DisableHyperthreadingRequest;
3399/// # async fn dox() {
3400/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3401///
3402/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3403/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3404/// # secret,
3405/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3406/// # ).build().await.unwrap();
3407///
3408/// # let client = hyper_util::client::legacy::Client::builder(
3409/// # hyper_util::rt::TokioExecutor::new()
3410/// # )
3411/// # .build(
3412/// # hyper_rustls::HttpsConnectorBuilder::new()
3413/// # .with_native_roots()
3414/// # .unwrap()
3415/// # .https_or_http()
3416/// # .enable_http1()
3417/// # .build()
3418/// # );
3419/// # let mut hub = Baremetalsolution::new(client, auth);
3420/// // As the method needs a request, you would usually fill it with the desired information
3421/// // into the respective structure. Some of the parts shown here might not be applicable !
3422/// // Values shown here are possibly random and not representative !
3423/// let mut req = DisableHyperthreadingRequest::default();
3424///
3425/// // You can configure optional parameters by calling the respective setters at will, and
3426/// // execute the final call using `doit()`.
3427/// // Values shown here are possibly random and not representative !
3428/// let result = hub.projects().locations_instances_disable_hyperthreading(req, "name")
3429/// .doit().await;
3430/// # }
3431/// ```
3432pub struct ProjectLocationInstanceDisableHyperthreadingCall<'a, C>
3433where
3434 C: 'a,
3435{
3436 hub: &'a Baremetalsolution<C>,
3437 _request: DisableHyperthreadingRequest,
3438 _name: String,
3439 _delegate: Option<&'a mut dyn common::Delegate>,
3440 _additional_params: HashMap<String, String>,
3441 _scopes: BTreeSet<String>,
3442}
3443
3444impl<'a, C> common::CallBuilder for ProjectLocationInstanceDisableHyperthreadingCall<'a, C> {}
3445
3446impl<'a, C> ProjectLocationInstanceDisableHyperthreadingCall<'a, C>
3447where
3448 C: common::Connector,
3449{
3450 /// Perform the operation you have build so far.
3451 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3452 use std::borrow::Cow;
3453 use std::io::{Read, Seek};
3454
3455 use common::{url::Params, ToParts};
3456 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3457
3458 let mut dd = common::DefaultDelegate;
3459 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3460 dlg.begin(common::MethodInfo {
3461 id: "baremetalsolution.projects.locations.instances.disableHyperthreading",
3462 http_method: hyper::Method::POST,
3463 });
3464
3465 for &field in ["alt", "name"].iter() {
3466 if self._additional_params.contains_key(field) {
3467 dlg.finished(false);
3468 return Err(common::Error::FieldClash(field));
3469 }
3470 }
3471
3472 let mut params = Params::with_capacity(4 + self._additional_params.len());
3473 params.push("name", self._name);
3474
3475 params.extend(self._additional_params.iter());
3476
3477 params.push("alt", "json");
3478 let mut url = self.hub._base_url.clone() + "v2/{+name}:disableHyperthreading";
3479 if self._scopes.is_empty() {
3480 self._scopes
3481 .insert(Scope::CloudPlatform.as_ref().to_string());
3482 }
3483
3484 #[allow(clippy::single_element_loop)]
3485 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3486 url = params.uri_replacement(url, param_name, find_this, true);
3487 }
3488 {
3489 let to_remove = ["name"];
3490 params.remove_params(&to_remove);
3491 }
3492
3493 let url = params.parse_with_url(&url);
3494
3495 let mut json_mime_type = mime::APPLICATION_JSON;
3496 let mut request_value_reader = {
3497 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3498 common::remove_json_null_values(&mut value);
3499 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3500 serde_json::to_writer(&mut dst, &value).unwrap();
3501 dst
3502 };
3503 let request_size = request_value_reader
3504 .seek(std::io::SeekFrom::End(0))
3505 .unwrap();
3506 request_value_reader
3507 .seek(std::io::SeekFrom::Start(0))
3508 .unwrap();
3509
3510 loop {
3511 let token = match self
3512 .hub
3513 .auth
3514 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3515 .await
3516 {
3517 Ok(token) => token,
3518 Err(e) => match dlg.token(e) {
3519 Ok(token) => token,
3520 Err(e) => {
3521 dlg.finished(false);
3522 return Err(common::Error::MissingToken(e));
3523 }
3524 },
3525 };
3526 request_value_reader
3527 .seek(std::io::SeekFrom::Start(0))
3528 .unwrap();
3529 let mut req_result = {
3530 let client = &self.hub.client;
3531 dlg.pre_request();
3532 let mut req_builder = hyper::Request::builder()
3533 .method(hyper::Method::POST)
3534 .uri(url.as_str())
3535 .header(USER_AGENT, self.hub._user_agent.clone());
3536
3537 if let Some(token) = token.as_ref() {
3538 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3539 }
3540
3541 let request = req_builder
3542 .header(CONTENT_TYPE, json_mime_type.to_string())
3543 .header(CONTENT_LENGTH, request_size as u64)
3544 .body(common::to_body(
3545 request_value_reader.get_ref().clone().into(),
3546 ));
3547
3548 client.request(request.unwrap()).await
3549 };
3550
3551 match req_result {
3552 Err(err) => {
3553 if let common::Retry::After(d) = dlg.http_error(&err) {
3554 sleep(d).await;
3555 continue;
3556 }
3557 dlg.finished(false);
3558 return Err(common::Error::HttpError(err));
3559 }
3560 Ok(res) => {
3561 let (mut parts, body) = res.into_parts();
3562 let mut body = common::Body::new(body);
3563 if !parts.status.is_success() {
3564 let bytes = common::to_bytes(body).await.unwrap_or_default();
3565 let error = serde_json::from_str(&common::to_string(&bytes));
3566 let response = common::to_response(parts, bytes.into());
3567
3568 if let common::Retry::After(d) =
3569 dlg.http_failure(&response, error.as_ref().ok())
3570 {
3571 sleep(d).await;
3572 continue;
3573 }
3574
3575 dlg.finished(false);
3576
3577 return Err(match error {
3578 Ok(value) => common::Error::BadRequest(value),
3579 _ => common::Error::Failure(response),
3580 });
3581 }
3582 let response = {
3583 let bytes = common::to_bytes(body).await.unwrap_or_default();
3584 let encoded = common::to_string(&bytes);
3585 match serde_json::from_str(&encoded) {
3586 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3587 Err(error) => {
3588 dlg.response_json_decode_error(&encoded, &error);
3589 return Err(common::Error::JsonDecodeError(
3590 encoded.to_string(),
3591 error,
3592 ));
3593 }
3594 }
3595 };
3596
3597 dlg.finished(true);
3598 return Ok(response);
3599 }
3600 }
3601 }
3602 }
3603
3604 ///
3605 /// Sets the *request* property to the given value.
3606 ///
3607 /// Even though the property as already been set when instantiating this call,
3608 /// we provide this method for API completeness.
3609 pub fn request(
3610 mut self,
3611 new_value: DisableHyperthreadingRequest,
3612 ) -> ProjectLocationInstanceDisableHyperthreadingCall<'a, C> {
3613 self._request = new_value;
3614 self
3615 }
3616 /// Required. The `name` field is used to identify the instance. Format: projects/{project}/locations/{location}/instances/{instance}
3617 ///
3618 /// Sets the *name* path property to the given value.
3619 ///
3620 /// Even though the property as already been set when instantiating this call,
3621 /// we provide this method for API completeness.
3622 pub fn name(
3623 mut self,
3624 new_value: &str,
3625 ) -> ProjectLocationInstanceDisableHyperthreadingCall<'a, C> {
3626 self._name = new_value.to_string();
3627 self
3628 }
3629 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3630 /// while executing the actual API request.
3631 ///
3632 /// ````text
3633 /// It should be used to handle progress information, and to implement a certain level of resilience.
3634 /// ````
3635 ///
3636 /// Sets the *delegate* property to the given value.
3637 pub fn delegate(
3638 mut self,
3639 new_value: &'a mut dyn common::Delegate,
3640 ) -> ProjectLocationInstanceDisableHyperthreadingCall<'a, C> {
3641 self._delegate = Some(new_value);
3642 self
3643 }
3644
3645 /// Set any additional parameter of the query string used in the request.
3646 /// It should be used to set parameters which are not yet available through their own
3647 /// setters.
3648 ///
3649 /// Please note that this method must not be used to set any of the known parameters
3650 /// which have their own setter method. If done anyway, the request will fail.
3651 ///
3652 /// # Additional Parameters
3653 ///
3654 /// * *$.xgafv* (query-string) - V1 error format.
3655 /// * *access_token* (query-string) - OAuth access token.
3656 /// * *alt* (query-string) - Data format for response.
3657 /// * *callback* (query-string) - JSONP
3658 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3659 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3660 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3661 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3662 /// * *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.
3663 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3664 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3665 pub fn param<T>(
3666 mut self,
3667 name: T,
3668 value: T,
3669 ) -> ProjectLocationInstanceDisableHyperthreadingCall<'a, C>
3670 where
3671 T: AsRef<str>,
3672 {
3673 self._additional_params
3674 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3675 self
3676 }
3677
3678 /// Identifies the authorization scope for the method you are building.
3679 ///
3680 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3681 /// [`Scope::CloudPlatform`].
3682 ///
3683 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3684 /// tokens for more than one scope.
3685 ///
3686 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3687 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3688 /// sufficient, a read-write scope will do as well.
3689 pub fn add_scope<St>(
3690 mut self,
3691 scope: St,
3692 ) -> ProjectLocationInstanceDisableHyperthreadingCall<'a, C>
3693 where
3694 St: AsRef<str>,
3695 {
3696 self._scopes.insert(String::from(scope.as_ref()));
3697 self
3698 }
3699 /// Identifies the authorization scope(s) for the method you are building.
3700 ///
3701 /// See [`Self::add_scope()`] for details.
3702 pub fn add_scopes<I, St>(
3703 mut self,
3704 scopes: I,
3705 ) -> ProjectLocationInstanceDisableHyperthreadingCall<'a, C>
3706 where
3707 I: IntoIterator<Item = St>,
3708 St: AsRef<str>,
3709 {
3710 self._scopes
3711 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3712 self
3713 }
3714
3715 /// Removes all scopes, and no default scope will be used either.
3716 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3717 /// for details).
3718 pub fn clear_scopes(mut self) -> ProjectLocationInstanceDisableHyperthreadingCall<'a, C> {
3719 self._scopes.clear();
3720 self
3721 }
3722}
3723
3724/// Disable the interactive serial console feature on an instance.
3725///
3726/// A builder for the *locations.instances.disableInteractiveSerialConsole* method supported by a *project* resource.
3727/// It is not used directly, but through a [`ProjectMethods`] instance.
3728///
3729/// # Example
3730///
3731/// Instantiate a resource method builder
3732///
3733/// ```test_harness,no_run
3734/// # extern crate hyper;
3735/// # extern crate hyper_rustls;
3736/// # extern crate google_baremetalsolution2 as baremetalsolution2;
3737/// use baremetalsolution2::api::DisableInteractiveSerialConsoleRequest;
3738/// # async fn dox() {
3739/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3740///
3741/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3742/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3743/// # secret,
3744/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3745/// # ).build().await.unwrap();
3746///
3747/// # let client = hyper_util::client::legacy::Client::builder(
3748/// # hyper_util::rt::TokioExecutor::new()
3749/// # )
3750/// # .build(
3751/// # hyper_rustls::HttpsConnectorBuilder::new()
3752/// # .with_native_roots()
3753/// # .unwrap()
3754/// # .https_or_http()
3755/// # .enable_http1()
3756/// # .build()
3757/// # );
3758/// # let mut hub = Baremetalsolution::new(client, auth);
3759/// // As the method needs a request, you would usually fill it with the desired information
3760/// // into the respective structure. Some of the parts shown here might not be applicable !
3761/// // Values shown here are possibly random and not representative !
3762/// let mut req = DisableInteractiveSerialConsoleRequest::default();
3763///
3764/// // You can configure optional parameters by calling the respective setters at will, and
3765/// // execute the final call using `doit()`.
3766/// // Values shown here are possibly random and not representative !
3767/// let result = hub.projects().locations_instances_disable_interactive_serial_console(req, "name")
3768/// .doit().await;
3769/// # }
3770/// ```
3771pub struct ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C>
3772where
3773 C: 'a,
3774{
3775 hub: &'a Baremetalsolution<C>,
3776 _request: DisableInteractiveSerialConsoleRequest,
3777 _name: String,
3778 _delegate: Option<&'a mut dyn common::Delegate>,
3779 _additional_params: HashMap<String, String>,
3780 _scopes: BTreeSet<String>,
3781}
3782
3783impl<'a, C> common::CallBuilder
3784 for ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C>
3785{
3786}
3787
3788impl<'a, C> ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C>
3789where
3790 C: common::Connector,
3791{
3792 /// Perform the operation you have build so far.
3793 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3794 use std::borrow::Cow;
3795 use std::io::{Read, Seek};
3796
3797 use common::{url::Params, ToParts};
3798 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3799
3800 let mut dd = common::DefaultDelegate;
3801 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3802 dlg.begin(common::MethodInfo {
3803 id: "baremetalsolution.projects.locations.instances.disableInteractiveSerialConsole",
3804 http_method: hyper::Method::POST,
3805 });
3806
3807 for &field in ["alt", "name"].iter() {
3808 if self._additional_params.contains_key(field) {
3809 dlg.finished(false);
3810 return Err(common::Error::FieldClash(field));
3811 }
3812 }
3813
3814 let mut params = Params::with_capacity(4 + self._additional_params.len());
3815 params.push("name", self._name);
3816
3817 params.extend(self._additional_params.iter());
3818
3819 params.push("alt", "json");
3820 let mut url = self.hub._base_url.clone() + "v2/{+name}:disableInteractiveSerialConsole";
3821 if self._scopes.is_empty() {
3822 self._scopes
3823 .insert(Scope::CloudPlatform.as_ref().to_string());
3824 }
3825
3826 #[allow(clippy::single_element_loop)]
3827 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3828 url = params.uri_replacement(url, param_name, find_this, true);
3829 }
3830 {
3831 let to_remove = ["name"];
3832 params.remove_params(&to_remove);
3833 }
3834
3835 let url = params.parse_with_url(&url);
3836
3837 let mut json_mime_type = mime::APPLICATION_JSON;
3838 let mut request_value_reader = {
3839 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3840 common::remove_json_null_values(&mut value);
3841 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3842 serde_json::to_writer(&mut dst, &value).unwrap();
3843 dst
3844 };
3845 let request_size = request_value_reader
3846 .seek(std::io::SeekFrom::End(0))
3847 .unwrap();
3848 request_value_reader
3849 .seek(std::io::SeekFrom::Start(0))
3850 .unwrap();
3851
3852 loop {
3853 let token = match self
3854 .hub
3855 .auth
3856 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3857 .await
3858 {
3859 Ok(token) => token,
3860 Err(e) => match dlg.token(e) {
3861 Ok(token) => token,
3862 Err(e) => {
3863 dlg.finished(false);
3864 return Err(common::Error::MissingToken(e));
3865 }
3866 },
3867 };
3868 request_value_reader
3869 .seek(std::io::SeekFrom::Start(0))
3870 .unwrap();
3871 let mut req_result = {
3872 let client = &self.hub.client;
3873 dlg.pre_request();
3874 let mut req_builder = hyper::Request::builder()
3875 .method(hyper::Method::POST)
3876 .uri(url.as_str())
3877 .header(USER_AGENT, self.hub._user_agent.clone());
3878
3879 if let Some(token) = token.as_ref() {
3880 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3881 }
3882
3883 let request = req_builder
3884 .header(CONTENT_TYPE, json_mime_type.to_string())
3885 .header(CONTENT_LENGTH, request_size as u64)
3886 .body(common::to_body(
3887 request_value_reader.get_ref().clone().into(),
3888 ));
3889
3890 client.request(request.unwrap()).await
3891 };
3892
3893 match req_result {
3894 Err(err) => {
3895 if let common::Retry::After(d) = dlg.http_error(&err) {
3896 sleep(d).await;
3897 continue;
3898 }
3899 dlg.finished(false);
3900 return Err(common::Error::HttpError(err));
3901 }
3902 Ok(res) => {
3903 let (mut parts, body) = res.into_parts();
3904 let mut body = common::Body::new(body);
3905 if !parts.status.is_success() {
3906 let bytes = common::to_bytes(body).await.unwrap_or_default();
3907 let error = serde_json::from_str(&common::to_string(&bytes));
3908 let response = common::to_response(parts, bytes.into());
3909
3910 if let common::Retry::After(d) =
3911 dlg.http_failure(&response, error.as_ref().ok())
3912 {
3913 sleep(d).await;
3914 continue;
3915 }
3916
3917 dlg.finished(false);
3918
3919 return Err(match error {
3920 Ok(value) => common::Error::BadRequest(value),
3921 _ => common::Error::Failure(response),
3922 });
3923 }
3924 let response = {
3925 let bytes = common::to_bytes(body).await.unwrap_or_default();
3926 let encoded = common::to_string(&bytes);
3927 match serde_json::from_str(&encoded) {
3928 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3929 Err(error) => {
3930 dlg.response_json_decode_error(&encoded, &error);
3931 return Err(common::Error::JsonDecodeError(
3932 encoded.to_string(),
3933 error,
3934 ));
3935 }
3936 }
3937 };
3938
3939 dlg.finished(true);
3940 return Ok(response);
3941 }
3942 }
3943 }
3944 }
3945
3946 ///
3947 /// Sets the *request* property to the given value.
3948 ///
3949 /// Even though the property as already been set when instantiating this call,
3950 /// we provide this method for API completeness.
3951 pub fn request(
3952 mut self,
3953 new_value: DisableInteractiveSerialConsoleRequest,
3954 ) -> ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C> {
3955 self._request = new_value;
3956 self
3957 }
3958 /// Required. Name of the resource.
3959 ///
3960 /// Sets the *name* path property to the given value.
3961 ///
3962 /// Even though the property as already been set when instantiating this call,
3963 /// we provide this method for API completeness.
3964 pub fn name(
3965 mut self,
3966 new_value: &str,
3967 ) -> ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C> {
3968 self._name = new_value.to_string();
3969 self
3970 }
3971 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3972 /// while executing the actual API request.
3973 ///
3974 /// ````text
3975 /// It should be used to handle progress information, and to implement a certain level of resilience.
3976 /// ````
3977 ///
3978 /// Sets the *delegate* property to the given value.
3979 pub fn delegate(
3980 mut self,
3981 new_value: &'a mut dyn common::Delegate,
3982 ) -> ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C> {
3983 self._delegate = Some(new_value);
3984 self
3985 }
3986
3987 /// Set any additional parameter of the query string used in the request.
3988 /// It should be used to set parameters which are not yet available through their own
3989 /// setters.
3990 ///
3991 /// Please note that this method must not be used to set any of the known parameters
3992 /// which have their own setter method. If done anyway, the request will fail.
3993 ///
3994 /// # Additional Parameters
3995 ///
3996 /// * *$.xgafv* (query-string) - V1 error format.
3997 /// * *access_token* (query-string) - OAuth access token.
3998 /// * *alt* (query-string) - Data format for response.
3999 /// * *callback* (query-string) - JSONP
4000 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4001 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4002 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4003 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4004 /// * *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.
4005 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4006 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4007 pub fn param<T>(
4008 mut self,
4009 name: T,
4010 value: T,
4011 ) -> ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C>
4012 where
4013 T: AsRef<str>,
4014 {
4015 self._additional_params
4016 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4017 self
4018 }
4019
4020 /// Identifies the authorization scope for the method you are building.
4021 ///
4022 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4023 /// [`Scope::CloudPlatform`].
4024 ///
4025 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4026 /// tokens for more than one scope.
4027 ///
4028 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4029 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4030 /// sufficient, a read-write scope will do as well.
4031 pub fn add_scope<St>(
4032 mut self,
4033 scope: St,
4034 ) -> ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C>
4035 where
4036 St: AsRef<str>,
4037 {
4038 self._scopes.insert(String::from(scope.as_ref()));
4039 self
4040 }
4041 /// Identifies the authorization scope(s) for the method you are building.
4042 ///
4043 /// See [`Self::add_scope()`] for details.
4044 pub fn add_scopes<I, St>(
4045 mut self,
4046 scopes: I,
4047 ) -> ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C>
4048 where
4049 I: IntoIterator<Item = St>,
4050 St: AsRef<str>,
4051 {
4052 self._scopes
4053 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4054 self
4055 }
4056
4057 /// Removes all scopes, and no default scope will be used either.
4058 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4059 /// for details).
4060 pub fn clear_scopes(
4061 mut self,
4062 ) -> ProjectLocationInstanceDisableInteractiveSerialConsoleCall<'a, C> {
4063 self._scopes.clear();
4064 self
4065 }
4066}
4067
4068/// Perform enable hyperthreading operation on a single server.
4069///
4070/// A builder for the *locations.instances.enableHyperthreading* method supported by a *project* resource.
4071/// It is not used directly, but through a [`ProjectMethods`] instance.
4072///
4073/// # Example
4074///
4075/// Instantiate a resource method builder
4076///
4077/// ```test_harness,no_run
4078/// # extern crate hyper;
4079/// # extern crate hyper_rustls;
4080/// # extern crate google_baremetalsolution2 as baremetalsolution2;
4081/// use baremetalsolution2::api::EnableHyperthreadingRequest;
4082/// # async fn dox() {
4083/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4084///
4085/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4086/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4087/// # secret,
4088/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4089/// # ).build().await.unwrap();
4090///
4091/// # let client = hyper_util::client::legacy::Client::builder(
4092/// # hyper_util::rt::TokioExecutor::new()
4093/// # )
4094/// # .build(
4095/// # hyper_rustls::HttpsConnectorBuilder::new()
4096/// # .with_native_roots()
4097/// # .unwrap()
4098/// # .https_or_http()
4099/// # .enable_http1()
4100/// # .build()
4101/// # );
4102/// # let mut hub = Baremetalsolution::new(client, auth);
4103/// // As the method needs a request, you would usually fill it with the desired information
4104/// // into the respective structure. Some of the parts shown here might not be applicable !
4105/// // Values shown here are possibly random and not representative !
4106/// let mut req = EnableHyperthreadingRequest::default();
4107///
4108/// // You can configure optional parameters by calling the respective setters at will, and
4109/// // execute the final call using `doit()`.
4110/// // Values shown here are possibly random and not representative !
4111/// let result = hub.projects().locations_instances_enable_hyperthreading(req, "name")
4112/// .doit().await;
4113/// # }
4114/// ```
4115pub struct ProjectLocationInstanceEnableHyperthreadingCall<'a, C>
4116where
4117 C: 'a,
4118{
4119 hub: &'a Baremetalsolution<C>,
4120 _request: EnableHyperthreadingRequest,
4121 _name: String,
4122 _delegate: Option<&'a mut dyn common::Delegate>,
4123 _additional_params: HashMap<String, String>,
4124 _scopes: BTreeSet<String>,
4125}
4126
4127impl<'a, C> common::CallBuilder for ProjectLocationInstanceEnableHyperthreadingCall<'a, C> {}
4128
4129impl<'a, C> ProjectLocationInstanceEnableHyperthreadingCall<'a, C>
4130where
4131 C: common::Connector,
4132{
4133 /// Perform the operation you have build so far.
4134 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4135 use std::borrow::Cow;
4136 use std::io::{Read, Seek};
4137
4138 use common::{url::Params, ToParts};
4139 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4140
4141 let mut dd = common::DefaultDelegate;
4142 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4143 dlg.begin(common::MethodInfo {
4144 id: "baremetalsolution.projects.locations.instances.enableHyperthreading",
4145 http_method: hyper::Method::POST,
4146 });
4147
4148 for &field in ["alt", "name"].iter() {
4149 if self._additional_params.contains_key(field) {
4150 dlg.finished(false);
4151 return Err(common::Error::FieldClash(field));
4152 }
4153 }
4154
4155 let mut params = Params::with_capacity(4 + self._additional_params.len());
4156 params.push("name", self._name);
4157
4158 params.extend(self._additional_params.iter());
4159
4160 params.push("alt", "json");
4161 let mut url = self.hub._base_url.clone() + "v2/{+name}:enableHyperthreading";
4162 if self._scopes.is_empty() {
4163 self._scopes
4164 .insert(Scope::CloudPlatform.as_ref().to_string());
4165 }
4166
4167 #[allow(clippy::single_element_loop)]
4168 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4169 url = params.uri_replacement(url, param_name, find_this, true);
4170 }
4171 {
4172 let to_remove = ["name"];
4173 params.remove_params(&to_remove);
4174 }
4175
4176 let url = params.parse_with_url(&url);
4177
4178 let mut json_mime_type = mime::APPLICATION_JSON;
4179 let mut request_value_reader = {
4180 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4181 common::remove_json_null_values(&mut value);
4182 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4183 serde_json::to_writer(&mut dst, &value).unwrap();
4184 dst
4185 };
4186 let request_size = request_value_reader
4187 .seek(std::io::SeekFrom::End(0))
4188 .unwrap();
4189 request_value_reader
4190 .seek(std::io::SeekFrom::Start(0))
4191 .unwrap();
4192
4193 loop {
4194 let token = match self
4195 .hub
4196 .auth
4197 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4198 .await
4199 {
4200 Ok(token) => token,
4201 Err(e) => match dlg.token(e) {
4202 Ok(token) => token,
4203 Err(e) => {
4204 dlg.finished(false);
4205 return Err(common::Error::MissingToken(e));
4206 }
4207 },
4208 };
4209 request_value_reader
4210 .seek(std::io::SeekFrom::Start(0))
4211 .unwrap();
4212 let mut req_result = {
4213 let client = &self.hub.client;
4214 dlg.pre_request();
4215 let mut req_builder = hyper::Request::builder()
4216 .method(hyper::Method::POST)
4217 .uri(url.as_str())
4218 .header(USER_AGENT, self.hub._user_agent.clone());
4219
4220 if let Some(token) = token.as_ref() {
4221 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4222 }
4223
4224 let request = req_builder
4225 .header(CONTENT_TYPE, json_mime_type.to_string())
4226 .header(CONTENT_LENGTH, request_size as u64)
4227 .body(common::to_body(
4228 request_value_reader.get_ref().clone().into(),
4229 ));
4230
4231 client.request(request.unwrap()).await
4232 };
4233
4234 match req_result {
4235 Err(err) => {
4236 if let common::Retry::After(d) = dlg.http_error(&err) {
4237 sleep(d).await;
4238 continue;
4239 }
4240 dlg.finished(false);
4241 return Err(common::Error::HttpError(err));
4242 }
4243 Ok(res) => {
4244 let (mut parts, body) = res.into_parts();
4245 let mut body = common::Body::new(body);
4246 if !parts.status.is_success() {
4247 let bytes = common::to_bytes(body).await.unwrap_or_default();
4248 let error = serde_json::from_str(&common::to_string(&bytes));
4249 let response = common::to_response(parts, bytes.into());
4250
4251 if let common::Retry::After(d) =
4252 dlg.http_failure(&response, error.as_ref().ok())
4253 {
4254 sleep(d).await;
4255 continue;
4256 }
4257
4258 dlg.finished(false);
4259
4260 return Err(match error {
4261 Ok(value) => common::Error::BadRequest(value),
4262 _ => common::Error::Failure(response),
4263 });
4264 }
4265 let response = {
4266 let bytes = common::to_bytes(body).await.unwrap_or_default();
4267 let encoded = common::to_string(&bytes);
4268 match serde_json::from_str(&encoded) {
4269 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4270 Err(error) => {
4271 dlg.response_json_decode_error(&encoded, &error);
4272 return Err(common::Error::JsonDecodeError(
4273 encoded.to_string(),
4274 error,
4275 ));
4276 }
4277 }
4278 };
4279
4280 dlg.finished(true);
4281 return Ok(response);
4282 }
4283 }
4284 }
4285 }
4286
4287 ///
4288 /// Sets the *request* property to the given value.
4289 ///
4290 /// Even though the property as already been set when instantiating this call,
4291 /// we provide this method for API completeness.
4292 pub fn request(
4293 mut self,
4294 new_value: EnableHyperthreadingRequest,
4295 ) -> ProjectLocationInstanceEnableHyperthreadingCall<'a, C> {
4296 self._request = new_value;
4297 self
4298 }
4299 /// Required. The `name` field is used to identify the instance. Format: projects/{project}/locations/{location}/instances/{instance}
4300 ///
4301 /// Sets the *name* path property to the given value.
4302 ///
4303 /// Even though the property as already been set when instantiating this call,
4304 /// we provide this method for API completeness.
4305 pub fn name(
4306 mut self,
4307 new_value: &str,
4308 ) -> ProjectLocationInstanceEnableHyperthreadingCall<'a, C> {
4309 self._name = new_value.to_string();
4310 self
4311 }
4312 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4313 /// while executing the actual API request.
4314 ///
4315 /// ````text
4316 /// It should be used to handle progress information, and to implement a certain level of resilience.
4317 /// ````
4318 ///
4319 /// Sets the *delegate* property to the given value.
4320 pub fn delegate(
4321 mut self,
4322 new_value: &'a mut dyn common::Delegate,
4323 ) -> ProjectLocationInstanceEnableHyperthreadingCall<'a, C> {
4324 self._delegate = Some(new_value);
4325 self
4326 }
4327
4328 /// Set any additional parameter of the query string used in the request.
4329 /// It should be used to set parameters which are not yet available through their own
4330 /// setters.
4331 ///
4332 /// Please note that this method must not be used to set any of the known parameters
4333 /// which have their own setter method. If done anyway, the request will fail.
4334 ///
4335 /// # Additional Parameters
4336 ///
4337 /// * *$.xgafv* (query-string) - V1 error format.
4338 /// * *access_token* (query-string) - OAuth access token.
4339 /// * *alt* (query-string) - Data format for response.
4340 /// * *callback* (query-string) - JSONP
4341 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4342 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4343 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4344 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4345 /// * *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.
4346 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4347 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4348 pub fn param<T>(
4349 mut self,
4350 name: T,
4351 value: T,
4352 ) -> ProjectLocationInstanceEnableHyperthreadingCall<'a, C>
4353 where
4354 T: AsRef<str>,
4355 {
4356 self._additional_params
4357 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4358 self
4359 }
4360
4361 /// Identifies the authorization scope for the method you are building.
4362 ///
4363 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4364 /// [`Scope::CloudPlatform`].
4365 ///
4366 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4367 /// tokens for more than one scope.
4368 ///
4369 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4370 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4371 /// sufficient, a read-write scope will do as well.
4372 pub fn add_scope<St>(
4373 mut self,
4374 scope: St,
4375 ) -> ProjectLocationInstanceEnableHyperthreadingCall<'a, C>
4376 where
4377 St: AsRef<str>,
4378 {
4379 self._scopes.insert(String::from(scope.as_ref()));
4380 self
4381 }
4382 /// Identifies the authorization scope(s) for the method you are building.
4383 ///
4384 /// See [`Self::add_scope()`] for details.
4385 pub fn add_scopes<I, St>(
4386 mut self,
4387 scopes: I,
4388 ) -> ProjectLocationInstanceEnableHyperthreadingCall<'a, C>
4389 where
4390 I: IntoIterator<Item = St>,
4391 St: AsRef<str>,
4392 {
4393 self._scopes
4394 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4395 self
4396 }
4397
4398 /// Removes all scopes, and no default scope will be used either.
4399 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4400 /// for details).
4401 pub fn clear_scopes(mut self) -> ProjectLocationInstanceEnableHyperthreadingCall<'a, C> {
4402 self._scopes.clear();
4403 self
4404 }
4405}
4406
4407/// Enable the interactive serial console feature on an instance.
4408///
4409/// A builder for the *locations.instances.enableInteractiveSerialConsole* method supported by a *project* resource.
4410/// It is not used directly, but through a [`ProjectMethods`] instance.
4411///
4412/// # Example
4413///
4414/// Instantiate a resource method builder
4415///
4416/// ```test_harness,no_run
4417/// # extern crate hyper;
4418/// # extern crate hyper_rustls;
4419/// # extern crate google_baremetalsolution2 as baremetalsolution2;
4420/// use baremetalsolution2::api::EnableInteractiveSerialConsoleRequest;
4421/// # async fn dox() {
4422/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4423///
4424/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4425/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4426/// # secret,
4427/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4428/// # ).build().await.unwrap();
4429///
4430/// # let client = hyper_util::client::legacy::Client::builder(
4431/// # hyper_util::rt::TokioExecutor::new()
4432/// # )
4433/// # .build(
4434/// # hyper_rustls::HttpsConnectorBuilder::new()
4435/// # .with_native_roots()
4436/// # .unwrap()
4437/// # .https_or_http()
4438/// # .enable_http1()
4439/// # .build()
4440/// # );
4441/// # let mut hub = Baremetalsolution::new(client, auth);
4442/// // As the method needs a request, you would usually fill it with the desired information
4443/// // into the respective structure. Some of the parts shown here might not be applicable !
4444/// // Values shown here are possibly random and not representative !
4445/// let mut req = EnableInteractiveSerialConsoleRequest::default();
4446///
4447/// // You can configure optional parameters by calling the respective setters at will, and
4448/// // execute the final call using `doit()`.
4449/// // Values shown here are possibly random and not representative !
4450/// let result = hub.projects().locations_instances_enable_interactive_serial_console(req, "name")
4451/// .doit().await;
4452/// # }
4453/// ```
4454pub struct ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'a, C>
4455where
4456 C: 'a,
4457{
4458 hub: &'a Baremetalsolution<C>,
4459 _request: EnableInteractiveSerialConsoleRequest,
4460 _name: String,
4461 _delegate: Option<&'a mut dyn common::Delegate>,
4462 _additional_params: HashMap<String, String>,
4463 _scopes: BTreeSet<String>,
4464}
4465
4466impl<'a, C> common::CallBuilder
4467 for ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'a, C>
4468{
4469}
4470
4471impl<'a, C> ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'a, C>
4472where
4473 C: common::Connector,
4474{
4475 /// Perform the operation you have build so far.
4476 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4477 use std::borrow::Cow;
4478 use std::io::{Read, Seek};
4479
4480 use common::{url::Params, ToParts};
4481 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4482
4483 let mut dd = common::DefaultDelegate;
4484 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4485 dlg.begin(common::MethodInfo {
4486 id: "baremetalsolution.projects.locations.instances.enableInteractiveSerialConsole",
4487 http_method: hyper::Method::POST,
4488 });
4489
4490 for &field in ["alt", "name"].iter() {
4491 if self._additional_params.contains_key(field) {
4492 dlg.finished(false);
4493 return Err(common::Error::FieldClash(field));
4494 }
4495 }
4496
4497 let mut params = Params::with_capacity(4 + self._additional_params.len());
4498 params.push("name", self._name);
4499
4500 params.extend(self._additional_params.iter());
4501
4502 params.push("alt", "json");
4503 let mut url = self.hub._base_url.clone() + "v2/{+name}:enableInteractiveSerialConsole";
4504 if self._scopes.is_empty() {
4505 self._scopes
4506 .insert(Scope::CloudPlatform.as_ref().to_string());
4507 }
4508
4509 #[allow(clippy::single_element_loop)]
4510 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4511 url = params.uri_replacement(url, param_name, find_this, true);
4512 }
4513 {
4514 let to_remove = ["name"];
4515 params.remove_params(&to_remove);
4516 }
4517
4518 let url = params.parse_with_url(&url);
4519
4520 let mut json_mime_type = mime::APPLICATION_JSON;
4521 let mut request_value_reader = {
4522 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4523 common::remove_json_null_values(&mut value);
4524 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4525 serde_json::to_writer(&mut dst, &value).unwrap();
4526 dst
4527 };
4528 let request_size = request_value_reader
4529 .seek(std::io::SeekFrom::End(0))
4530 .unwrap();
4531 request_value_reader
4532 .seek(std::io::SeekFrom::Start(0))
4533 .unwrap();
4534
4535 loop {
4536 let token = match self
4537 .hub
4538 .auth
4539 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4540 .await
4541 {
4542 Ok(token) => token,
4543 Err(e) => match dlg.token(e) {
4544 Ok(token) => token,
4545 Err(e) => {
4546 dlg.finished(false);
4547 return Err(common::Error::MissingToken(e));
4548 }
4549 },
4550 };
4551 request_value_reader
4552 .seek(std::io::SeekFrom::Start(0))
4553 .unwrap();
4554 let mut req_result = {
4555 let client = &self.hub.client;
4556 dlg.pre_request();
4557 let mut req_builder = hyper::Request::builder()
4558 .method(hyper::Method::POST)
4559 .uri(url.as_str())
4560 .header(USER_AGENT, self.hub._user_agent.clone());
4561
4562 if let Some(token) = token.as_ref() {
4563 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4564 }
4565
4566 let request = req_builder
4567 .header(CONTENT_TYPE, json_mime_type.to_string())
4568 .header(CONTENT_LENGTH, request_size as u64)
4569 .body(common::to_body(
4570 request_value_reader.get_ref().clone().into(),
4571 ));
4572
4573 client.request(request.unwrap()).await
4574 };
4575
4576 match req_result {
4577 Err(err) => {
4578 if let common::Retry::After(d) = dlg.http_error(&err) {
4579 sleep(d).await;
4580 continue;
4581 }
4582 dlg.finished(false);
4583 return Err(common::Error::HttpError(err));
4584 }
4585 Ok(res) => {
4586 let (mut parts, body) = res.into_parts();
4587 let mut body = common::Body::new(body);
4588 if !parts.status.is_success() {
4589 let bytes = common::to_bytes(body).await.unwrap_or_default();
4590 let error = serde_json::from_str(&common::to_string(&bytes));
4591 let response = common::to_response(parts, bytes.into());
4592
4593 if let common::Retry::After(d) =
4594 dlg.http_failure(&response, error.as_ref().ok())
4595 {
4596 sleep(d).await;
4597 continue;
4598 }
4599
4600 dlg.finished(false);
4601
4602 return Err(match error {
4603 Ok(value) => common::Error::BadRequest(value),
4604 _ => common::Error::Failure(response),
4605 });
4606 }
4607 let response = {
4608 let bytes = common::to_bytes(body).await.unwrap_or_default();
4609 let encoded = common::to_string(&bytes);
4610 match serde_json::from_str(&encoded) {
4611 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4612 Err(error) => {
4613 dlg.response_json_decode_error(&encoded, &error);
4614 return Err(common::Error::JsonDecodeError(
4615 encoded.to_string(),
4616 error,
4617 ));
4618 }
4619 }
4620 };
4621
4622 dlg.finished(true);
4623 return Ok(response);
4624 }
4625 }
4626 }
4627 }
4628
4629 ///
4630 /// Sets the *request* property to the given value.
4631 ///
4632 /// Even though the property as already been set when instantiating this call,
4633 /// we provide this method for API completeness.
4634 pub fn request(
4635 mut self,
4636 new_value: EnableInteractiveSerialConsoleRequest,
4637 ) -> ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'a, C> {
4638 self._request = new_value;
4639 self
4640 }
4641 /// Required. Name of the resource.
4642 ///
4643 /// Sets the *name* path property to the given value.
4644 ///
4645 /// Even though the property as already been set when instantiating this call,
4646 /// we provide this method for API completeness.
4647 pub fn name(
4648 mut self,
4649 new_value: &str,
4650 ) -> ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'a, C> {
4651 self._name = new_value.to_string();
4652 self
4653 }
4654 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4655 /// while executing the actual API request.
4656 ///
4657 /// ````text
4658 /// It should be used to handle progress information, and to implement a certain level of resilience.
4659 /// ````
4660 ///
4661 /// Sets the *delegate* property to the given value.
4662 pub fn delegate(
4663 mut self,
4664 new_value: &'a mut dyn common::Delegate,
4665 ) -> ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'a, C> {
4666 self._delegate = Some(new_value);
4667 self
4668 }
4669
4670 /// Set any additional parameter of the query string used in the request.
4671 /// It should be used to set parameters which are not yet available through their own
4672 /// setters.
4673 ///
4674 /// Please note that this method must not be used to set any of the known parameters
4675 /// which have their own setter method. If done anyway, the request will fail.
4676 ///
4677 /// # Additional Parameters
4678 ///
4679 /// * *$.xgafv* (query-string) - V1 error format.
4680 /// * *access_token* (query-string) - OAuth access token.
4681 /// * *alt* (query-string) - Data format for response.
4682 /// * *callback* (query-string) - JSONP
4683 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4684 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4685 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4686 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4687 /// * *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.
4688 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4689 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4690 pub fn param<T>(
4691 mut self,
4692 name: T,
4693 value: T,
4694 ) -> ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'a, C>
4695 where
4696 T: AsRef<str>,
4697 {
4698 self._additional_params
4699 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4700 self
4701 }
4702
4703 /// Identifies the authorization scope for the method you are building.
4704 ///
4705 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4706 /// [`Scope::CloudPlatform`].
4707 ///
4708 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4709 /// tokens for more than one scope.
4710 ///
4711 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4712 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4713 /// sufficient, a read-write scope will do as well.
4714 pub fn add_scope<St>(
4715 mut self,
4716 scope: St,
4717 ) -> ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'a, C>
4718 where
4719 St: AsRef<str>,
4720 {
4721 self._scopes.insert(String::from(scope.as_ref()));
4722 self
4723 }
4724 /// Identifies the authorization scope(s) for the method you are building.
4725 ///
4726 /// See [`Self::add_scope()`] for details.
4727 pub fn add_scopes<I, St>(
4728 mut self,
4729 scopes: I,
4730 ) -> ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'a, C>
4731 where
4732 I: IntoIterator<Item = St>,
4733 St: AsRef<str>,
4734 {
4735 self._scopes
4736 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4737 self
4738 }
4739
4740 /// Removes all scopes, and no default scope will be used either.
4741 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4742 /// for details).
4743 pub fn clear_scopes(
4744 mut self,
4745 ) -> ProjectLocationInstanceEnableInteractiveSerialConsoleCall<'a, C> {
4746 self._scopes.clear();
4747 self
4748 }
4749}
4750
4751/// Get details about a single server.
4752///
4753/// A builder for the *locations.instances.get* method supported by a *project* resource.
4754/// It is not used directly, but through a [`ProjectMethods`] instance.
4755///
4756/// # Example
4757///
4758/// Instantiate a resource method builder
4759///
4760/// ```test_harness,no_run
4761/// # extern crate hyper;
4762/// # extern crate hyper_rustls;
4763/// # extern crate google_baremetalsolution2 as baremetalsolution2;
4764/// # async fn dox() {
4765/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4766///
4767/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4768/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4769/// # secret,
4770/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4771/// # ).build().await.unwrap();
4772///
4773/// # let client = hyper_util::client::legacy::Client::builder(
4774/// # hyper_util::rt::TokioExecutor::new()
4775/// # )
4776/// # .build(
4777/// # hyper_rustls::HttpsConnectorBuilder::new()
4778/// # .with_native_roots()
4779/// # .unwrap()
4780/// # .https_or_http()
4781/// # .enable_http1()
4782/// # .build()
4783/// # );
4784/// # let mut hub = Baremetalsolution::new(client, auth);
4785/// // You can configure optional parameters by calling the respective setters at will, and
4786/// // execute the final call using `doit()`.
4787/// // Values shown here are possibly random and not representative !
4788/// let result = hub.projects().locations_instances_get("name")
4789/// .doit().await;
4790/// # }
4791/// ```
4792pub struct ProjectLocationInstanceGetCall<'a, C>
4793where
4794 C: 'a,
4795{
4796 hub: &'a Baremetalsolution<C>,
4797 _name: String,
4798 _delegate: Option<&'a mut dyn common::Delegate>,
4799 _additional_params: HashMap<String, String>,
4800 _scopes: BTreeSet<String>,
4801}
4802
4803impl<'a, C> common::CallBuilder for ProjectLocationInstanceGetCall<'a, C> {}
4804
4805impl<'a, C> ProjectLocationInstanceGetCall<'a, C>
4806where
4807 C: common::Connector,
4808{
4809 /// Perform the operation you have build so far.
4810 pub async fn doit(mut self) -> common::Result<(common::Response, Instance)> {
4811 use std::borrow::Cow;
4812 use std::io::{Read, Seek};
4813
4814 use common::{url::Params, ToParts};
4815 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4816
4817 let mut dd = common::DefaultDelegate;
4818 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4819 dlg.begin(common::MethodInfo {
4820 id: "baremetalsolution.projects.locations.instances.get",
4821 http_method: hyper::Method::GET,
4822 });
4823
4824 for &field in ["alt", "name"].iter() {
4825 if self._additional_params.contains_key(field) {
4826 dlg.finished(false);
4827 return Err(common::Error::FieldClash(field));
4828 }
4829 }
4830
4831 let mut params = Params::with_capacity(3 + self._additional_params.len());
4832 params.push("name", self._name);
4833
4834 params.extend(self._additional_params.iter());
4835
4836 params.push("alt", "json");
4837 let mut url = self.hub._base_url.clone() + "v2/{+name}";
4838 if self._scopes.is_empty() {
4839 self._scopes
4840 .insert(Scope::CloudPlatform.as_ref().to_string());
4841 }
4842
4843 #[allow(clippy::single_element_loop)]
4844 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4845 url = params.uri_replacement(url, param_name, find_this, true);
4846 }
4847 {
4848 let to_remove = ["name"];
4849 params.remove_params(&to_remove);
4850 }
4851
4852 let url = params.parse_with_url(&url);
4853
4854 loop {
4855 let token = match self
4856 .hub
4857 .auth
4858 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4859 .await
4860 {
4861 Ok(token) => token,
4862 Err(e) => match dlg.token(e) {
4863 Ok(token) => token,
4864 Err(e) => {
4865 dlg.finished(false);
4866 return Err(common::Error::MissingToken(e));
4867 }
4868 },
4869 };
4870 let mut req_result = {
4871 let client = &self.hub.client;
4872 dlg.pre_request();
4873 let mut req_builder = hyper::Request::builder()
4874 .method(hyper::Method::GET)
4875 .uri(url.as_str())
4876 .header(USER_AGENT, self.hub._user_agent.clone());
4877
4878 if let Some(token) = token.as_ref() {
4879 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4880 }
4881
4882 let request = req_builder
4883 .header(CONTENT_LENGTH, 0_u64)
4884 .body(common::to_body::<String>(None));
4885
4886 client.request(request.unwrap()).await
4887 };
4888
4889 match req_result {
4890 Err(err) => {
4891 if let common::Retry::After(d) = dlg.http_error(&err) {
4892 sleep(d).await;
4893 continue;
4894 }
4895 dlg.finished(false);
4896 return Err(common::Error::HttpError(err));
4897 }
4898 Ok(res) => {
4899 let (mut parts, body) = res.into_parts();
4900 let mut body = common::Body::new(body);
4901 if !parts.status.is_success() {
4902 let bytes = common::to_bytes(body).await.unwrap_or_default();
4903 let error = serde_json::from_str(&common::to_string(&bytes));
4904 let response = common::to_response(parts, bytes.into());
4905
4906 if let common::Retry::After(d) =
4907 dlg.http_failure(&response, error.as_ref().ok())
4908 {
4909 sleep(d).await;
4910 continue;
4911 }
4912
4913 dlg.finished(false);
4914
4915 return Err(match error {
4916 Ok(value) => common::Error::BadRequest(value),
4917 _ => common::Error::Failure(response),
4918 });
4919 }
4920 let response = {
4921 let bytes = common::to_bytes(body).await.unwrap_or_default();
4922 let encoded = common::to_string(&bytes);
4923 match serde_json::from_str(&encoded) {
4924 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4925 Err(error) => {
4926 dlg.response_json_decode_error(&encoded, &error);
4927 return Err(common::Error::JsonDecodeError(
4928 encoded.to_string(),
4929 error,
4930 ));
4931 }
4932 }
4933 };
4934
4935 dlg.finished(true);
4936 return Ok(response);
4937 }
4938 }
4939 }
4940 }
4941
4942 /// Required. Name of the resource.
4943 ///
4944 /// Sets the *name* path property to the given value.
4945 ///
4946 /// Even though the property as already been set when instantiating this call,
4947 /// we provide this method for API completeness.
4948 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceGetCall<'a, C> {
4949 self._name = new_value.to_string();
4950 self
4951 }
4952 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4953 /// while executing the actual API request.
4954 ///
4955 /// ````text
4956 /// It should be used to handle progress information, and to implement a certain level of resilience.
4957 /// ````
4958 ///
4959 /// Sets the *delegate* property to the given value.
4960 pub fn delegate(
4961 mut self,
4962 new_value: &'a mut dyn common::Delegate,
4963 ) -> ProjectLocationInstanceGetCall<'a, C> {
4964 self._delegate = Some(new_value);
4965 self
4966 }
4967
4968 /// Set any additional parameter of the query string used in the request.
4969 /// It should be used to set parameters which are not yet available through their own
4970 /// setters.
4971 ///
4972 /// Please note that this method must not be used to set any of the known parameters
4973 /// which have their own setter method. If done anyway, the request will fail.
4974 ///
4975 /// # Additional Parameters
4976 ///
4977 /// * *$.xgafv* (query-string) - V1 error format.
4978 /// * *access_token* (query-string) - OAuth access token.
4979 /// * *alt* (query-string) - Data format for response.
4980 /// * *callback* (query-string) - JSONP
4981 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4982 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4983 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4984 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4985 /// * *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.
4986 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4987 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4988 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceGetCall<'a, C>
4989 where
4990 T: AsRef<str>,
4991 {
4992 self._additional_params
4993 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4994 self
4995 }
4996
4997 /// Identifies the authorization scope for the method you are building.
4998 ///
4999 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5000 /// [`Scope::CloudPlatform`].
5001 ///
5002 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5003 /// tokens for more than one scope.
5004 ///
5005 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5006 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5007 /// sufficient, a read-write scope will do as well.
5008 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceGetCall<'a, C>
5009 where
5010 St: AsRef<str>,
5011 {
5012 self._scopes.insert(String::from(scope.as_ref()));
5013 self
5014 }
5015 /// Identifies the authorization scope(s) for the method you are building.
5016 ///
5017 /// See [`Self::add_scope()`] for details.
5018 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceGetCall<'a, C>
5019 where
5020 I: IntoIterator<Item = St>,
5021 St: AsRef<str>,
5022 {
5023 self._scopes
5024 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5025 self
5026 }
5027
5028 /// Removes all scopes, and no default scope will be used either.
5029 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5030 /// for details).
5031 pub fn clear_scopes(mut self) -> ProjectLocationInstanceGetCall<'a, C> {
5032 self._scopes.clear();
5033 self
5034 }
5035}
5036
5037/// List servers in a given project and location.
5038///
5039/// A builder for the *locations.instances.list* method supported by a *project* resource.
5040/// It is not used directly, but through a [`ProjectMethods`] instance.
5041///
5042/// # Example
5043///
5044/// Instantiate a resource method builder
5045///
5046/// ```test_harness,no_run
5047/// # extern crate hyper;
5048/// # extern crate hyper_rustls;
5049/// # extern crate google_baremetalsolution2 as baremetalsolution2;
5050/// # async fn dox() {
5051/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5052///
5053/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5054/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5055/// # secret,
5056/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5057/// # ).build().await.unwrap();
5058///
5059/// # let client = hyper_util::client::legacy::Client::builder(
5060/// # hyper_util::rt::TokioExecutor::new()
5061/// # )
5062/// # .build(
5063/// # hyper_rustls::HttpsConnectorBuilder::new()
5064/// # .with_native_roots()
5065/// # .unwrap()
5066/// # .https_or_http()
5067/// # .enable_http1()
5068/// # .build()
5069/// # );
5070/// # let mut hub = Baremetalsolution::new(client, auth);
5071/// // You can configure optional parameters by calling the respective setters at will, and
5072/// // execute the final call using `doit()`.
5073/// // Values shown here are possibly random and not representative !
5074/// let result = hub.projects().locations_instances_list("parent")
5075/// .page_token("amet.")
5076/// .page_size(-20)
5077/// .filter("ipsum")
5078/// .doit().await;
5079/// # }
5080/// ```
5081pub struct ProjectLocationInstanceListCall<'a, C>
5082where
5083 C: 'a,
5084{
5085 hub: &'a Baremetalsolution<C>,
5086 _parent: String,
5087 _page_token: Option<String>,
5088 _page_size: Option<i32>,
5089 _filter: Option<String>,
5090 _delegate: Option<&'a mut dyn common::Delegate>,
5091 _additional_params: HashMap<String, String>,
5092 _scopes: BTreeSet<String>,
5093}
5094
5095impl<'a, C> common::CallBuilder for ProjectLocationInstanceListCall<'a, C> {}
5096
5097impl<'a, C> ProjectLocationInstanceListCall<'a, C>
5098where
5099 C: common::Connector,
5100{
5101 /// Perform the operation you have build so far.
5102 pub async fn doit(mut self) -> common::Result<(common::Response, ListInstancesResponse)> {
5103 use std::borrow::Cow;
5104 use std::io::{Read, Seek};
5105
5106 use common::{url::Params, ToParts};
5107 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5108
5109 let mut dd = common::DefaultDelegate;
5110 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5111 dlg.begin(common::MethodInfo {
5112 id: "baremetalsolution.projects.locations.instances.list",
5113 http_method: hyper::Method::GET,
5114 });
5115
5116 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
5117 if self._additional_params.contains_key(field) {
5118 dlg.finished(false);
5119 return Err(common::Error::FieldClash(field));
5120 }
5121 }
5122
5123 let mut params = Params::with_capacity(6 + self._additional_params.len());
5124 params.push("parent", self._parent);
5125 if let Some(value) = self._page_token.as_ref() {
5126 params.push("pageToken", value);
5127 }
5128 if let Some(value) = self._page_size.as_ref() {
5129 params.push("pageSize", value.to_string());
5130 }
5131 if let Some(value) = self._filter.as_ref() {
5132 params.push("filter", value);
5133 }
5134
5135 params.extend(self._additional_params.iter());
5136
5137 params.push("alt", "json");
5138 let mut url = self.hub._base_url.clone() + "v2/{+parent}/instances";
5139 if self._scopes.is_empty() {
5140 self._scopes
5141 .insert(Scope::CloudPlatform.as_ref().to_string());
5142 }
5143
5144 #[allow(clippy::single_element_loop)]
5145 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5146 url = params.uri_replacement(url, param_name, find_this, true);
5147 }
5148 {
5149 let to_remove = ["parent"];
5150 params.remove_params(&to_remove);
5151 }
5152
5153 let url = params.parse_with_url(&url);
5154
5155 loop {
5156 let token = match self
5157 .hub
5158 .auth
5159 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5160 .await
5161 {
5162 Ok(token) => token,
5163 Err(e) => match dlg.token(e) {
5164 Ok(token) => token,
5165 Err(e) => {
5166 dlg.finished(false);
5167 return Err(common::Error::MissingToken(e));
5168 }
5169 },
5170 };
5171 let mut req_result = {
5172 let client = &self.hub.client;
5173 dlg.pre_request();
5174 let mut req_builder = hyper::Request::builder()
5175 .method(hyper::Method::GET)
5176 .uri(url.as_str())
5177 .header(USER_AGENT, self.hub._user_agent.clone());
5178
5179 if let Some(token) = token.as_ref() {
5180 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5181 }
5182
5183 let request = req_builder
5184 .header(CONTENT_LENGTH, 0_u64)
5185 .body(common::to_body::<String>(None));
5186
5187 client.request(request.unwrap()).await
5188 };
5189
5190 match req_result {
5191 Err(err) => {
5192 if let common::Retry::After(d) = dlg.http_error(&err) {
5193 sleep(d).await;
5194 continue;
5195 }
5196 dlg.finished(false);
5197 return Err(common::Error::HttpError(err));
5198 }
5199 Ok(res) => {
5200 let (mut parts, body) = res.into_parts();
5201 let mut body = common::Body::new(body);
5202 if !parts.status.is_success() {
5203 let bytes = common::to_bytes(body).await.unwrap_or_default();
5204 let error = serde_json::from_str(&common::to_string(&bytes));
5205 let response = common::to_response(parts, bytes.into());
5206
5207 if let common::Retry::After(d) =
5208 dlg.http_failure(&response, error.as_ref().ok())
5209 {
5210 sleep(d).await;
5211 continue;
5212 }
5213
5214 dlg.finished(false);
5215
5216 return Err(match error {
5217 Ok(value) => common::Error::BadRequest(value),
5218 _ => common::Error::Failure(response),
5219 });
5220 }
5221 let response = {
5222 let bytes = common::to_bytes(body).await.unwrap_or_default();
5223 let encoded = common::to_string(&bytes);
5224 match serde_json::from_str(&encoded) {
5225 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5226 Err(error) => {
5227 dlg.response_json_decode_error(&encoded, &error);
5228 return Err(common::Error::JsonDecodeError(
5229 encoded.to_string(),
5230 error,
5231 ));
5232 }
5233 }
5234 };
5235
5236 dlg.finished(true);
5237 return Ok(response);
5238 }
5239 }
5240 }
5241 }
5242
5243 /// Required. Parent value for ListInstancesRequest.
5244 ///
5245 /// Sets the *parent* path property to the given value.
5246 ///
5247 /// Even though the property as already been set when instantiating this call,
5248 /// we provide this method for API completeness.
5249 pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
5250 self._parent = new_value.to_string();
5251 self
5252 }
5253 /// A token identifying a page of results from the server.
5254 ///
5255 /// Sets the *page token* query property to the given value.
5256 pub fn page_token(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
5257 self._page_token = Some(new_value.to_string());
5258 self
5259 }
5260 /// Requested page size. Server may return fewer items than requested. If unspecified, the server will pick an appropriate default.
5261 ///
5262 /// Sets the *page size* query property to the given value.
5263 pub fn page_size(mut self, new_value: i32) -> ProjectLocationInstanceListCall<'a, C> {
5264 self._page_size = Some(new_value);
5265 self
5266 }
5267 /// List filter.
5268 ///
5269 /// Sets the *filter* query property to the given value.
5270 pub fn filter(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
5271 self._filter = Some(new_value.to_string());
5272 self
5273 }
5274 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5275 /// while executing the actual API request.
5276 ///
5277 /// ````text
5278 /// It should be used to handle progress information, and to implement a certain level of resilience.
5279 /// ````
5280 ///
5281 /// Sets the *delegate* property to the given value.
5282 pub fn delegate(
5283 mut self,
5284 new_value: &'a mut dyn common::Delegate,
5285 ) -> ProjectLocationInstanceListCall<'a, C> {
5286 self._delegate = Some(new_value);
5287 self
5288 }
5289
5290 /// Set any additional parameter of the query string used in the request.
5291 /// It should be used to set parameters which are not yet available through their own
5292 /// setters.
5293 ///
5294 /// Please note that this method must not be used to set any of the known parameters
5295 /// which have their own setter method. If done anyway, the request will fail.
5296 ///
5297 /// # Additional Parameters
5298 ///
5299 /// * *$.xgafv* (query-string) - V1 error format.
5300 /// * *access_token* (query-string) - OAuth access token.
5301 /// * *alt* (query-string) - Data format for response.
5302 /// * *callback* (query-string) - JSONP
5303 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5304 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5305 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5306 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5307 /// * *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.
5308 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5309 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5310 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceListCall<'a, C>
5311 where
5312 T: AsRef<str>,
5313 {
5314 self._additional_params
5315 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5316 self
5317 }
5318
5319 /// Identifies the authorization scope for the method you are building.
5320 ///
5321 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5322 /// [`Scope::CloudPlatform`].
5323 ///
5324 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5325 /// tokens for more than one scope.
5326 ///
5327 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5328 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5329 /// sufficient, a read-write scope will do as well.
5330 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceListCall<'a, C>
5331 where
5332 St: AsRef<str>,
5333 {
5334 self._scopes.insert(String::from(scope.as_ref()));
5335 self
5336 }
5337 /// Identifies the authorization scope(s) for the method you are building.
5338 ///
5339 /// See [`Self::add_scope()`] for details.
5340 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceListCall<'a, C>
5341 where
5342 I: IntoIterator<Item = St>,
5343 St: AsRef<str>,
5344 {
5345 self._scopes
5346 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5347 self
5348 }
5349
5350 /// Removes all scopes, and no default scope will be used either.
5351 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5352 /// for details).
5353 pub fn clear_scopes(mut self) -> ProjectLocationInstanceListCall<'a, C> {
5354 self._scopes.clear();
5355 self
5356 }
5357}
5358
5359/// Load auth info for a server.
5360///
5361/// A builder for the *locations.instances.loadAuthInfo* method supported by a *project* resource.
5362/// It is not used directly, but through a [`ProjectMethods`] instance.
5363///
5364/// # Example
5365///
5366/// Instantiate a resource method builder
5367///
5368/// ```test_harness,no_run
5369/// # extern crate hyper;
5370/// # extern crate hyper_rustls;
5371/// # extern crate google_baremetalsolution2 as baremetalsolution2;
5372/// # async fn dox() {
5373/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5374///
5375/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5376/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5377/// # secret,
5378/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5379/// # ).build().await.unwrap();
5380///
5381/// # let client = hyper_util::client::legacy::Client::builder(
5382/// # hyper_util::rt::TokioExecutor::new()
5383/// # )
5384/// # .build(
5385/// # hyper_rustls::HttpsConnectorBuilder::new()
5386/// # .with_native_roots()
5387/// # .unwrap()
5388/// # .https_or_http()
5389/// # .enable_http1()
5390/// # .build()
5391/// # );
5392/// # let mut hub = Baremetalsolution::new(client, auth);
5393/// // You can configure optional parameters by calling the respective setters at will, and
5394/// // execute the final call using `doit()`.
5395/// // Values shown here are possibly random and not representative !
5396/// let result = hub.projects().locations_instances_load_auth_info("name")
5397/// .doit().await;
5398/// # }
5399/// ```
5400pub struct ProjectLocationInstanceLoadAuthInfoCall<'a, C>
5401where
5402 C: 'a,
5403{
5404 hub: &'a Baremetalsolution<C>,
5405 _name: String,
5406 _delegate: Option<&'a mut dyn common::Delegate>,
5407 _additional_params: HashMap<String, String>,
5408 _scopes: BTreeSet<String>,
5409}
5410
5411impl<'a, C> common::CallBuilder for ProjectLocationInstanceLoadAuthInfoCall<'a, C> {}
5412
5413impl<'a, C> ProjectLocationInstanceLoadAuthInfoCall<'a, C>
5414where
5415 C: common::Connector,
5416{
5417 /// Perform the operation you have build so far.
5418 pub async fn doit(
5419 mut self,
5420 ) -> common::Result<(common::Response, LoadInstanceAuthInfoResponse)> {
5421 use std::borrow::Cow;
5422 use std::io::{Read, Seek};
5423
5424 use common::{url::Params, ToParts};
5425 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5426
5427 let mut dd = common::DefaultDelegate;
5428 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5429 dlg.begin(common::MethodInfo {
5430 id: "baremetalsolution.projects.locations.instances.loadAuthInfo",
5431 http_method: hyper::Method::GET,
5432 });
5433
5434 for &field in ["alt", "name"].iter() {
5435 if self._additional_params.contains_key(field) {
5436 dlg.finished(false);
5437 return Err(common::Error::FieldClash(field));
5438 }
5439 }
5440
5441 let mut params = Params::with_capacity(3 + self._additional_params.len());
5442 params.push("name", self._name);
5443
5444 params.extend(self._additional_params.iter());
5445
5446 params.push("alt", "json");
5447 let mut url = self.hub._base_url.clone() + "v2/{+name}:loadAuthInfo";
5448 if self._scopes.is_empty() {
5449 self._scopes
5450 .insert(Scope::CloudPlatform.as_ref().to_string());
5451 }
5452
5453 #[allow(clippy::single_element_loop)]
5454 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5455 url = params.uri_replacement(url, param_name, find_this, true);
5456 }
5457 {
5458 let to_remove = ["name"];
5459 params.remove_params(&to_remove);
5460 }
5461
5462 let url = params.parse_with_url(&url);
5463
5464 loop {
5465 let token = match self
5466 .hub
5467 .auth
5468 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5469 .await
5470 {
5471 Ok(token) => token,
5472 Err(e) => match dlg.token(e) {
5473 Ok(token) => token,
5474 Err(e) => {
5475 dlg.finished(false);
5476 return Err(common::Error::MissingToken(e));
5477 }
5478 },
5479 };
5480 let mut req_result = {
5481 let client = &self.hub.client;
5482 dlg.pre_request();
5483 let mut req_builder = hyper::Request::builder()
5484 .method(hyper::Method::GET)
5485 .uri(url.as_str())
5486 .header(USER_AGENT, self.hub._user_agent.clone());
5487
5488 if let Some(token) = token.as_ref() {
5489 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5490 }
5491
5492 let request = req_builder
5493 .header(CONTENT_LENGTH, 0_u64)
5494 .body(common::to_body::<String>(None));
5495
5496 client.request(request.unwrap()).await
5497 };
5498
5499 match req_result {
5500 Err(err) => {
5501 if let common::Retry::After(d) = dlg.http_error(&err) {
5502 sleep(d).await;
5503 continue;
5504 }
5505 dlg.finished(false);
5506 return Err(common::Error::HttpError(err));
5507 }
5508 Ok(res) => {
5509 let (mut parts, body) = res.into_parts();
5510 let mut body = common::Body::new(body);
5511 if !parts.status.is_success() {
5512 let bytes = common::to_bytes(body).await.unwrap_or_default();
5513 let error = serde_json::from_str(&common::to_string(&bytes));
5514 let response = common::to_response(parts, bytes.into());
5515
5516 if let common::Retry::After(d) =
5517 dlg.http_failure(&response, error.as_ref().ok())
5518 {
5519 sleep(d).await;
5520 continue;
5521 }
5522
5523 dlg.finished(false);
5524
5525 return Err(match error {
5526 Ok(value) => common::Error::BadRequest(value),
5527 _ => common::Error::Failure(response),
5528 });
5529 }
5530 let response = {
5531 let bytes = common::to_bytes(body).await.unwrap_or_default();
5532 let encoded = common::to_string(&bytes);
5533 match serde_json::from_str(&encoded) {
5534 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5535 Err(error) => {
5536 dlg.response_json_decode_error(&encoded, &error);
5537 return Err(common::Error::JsonDecodeError(
5538 encoded.to_string(),
5539 error,
5540 ));
5541 }
5542 }
5543 };
5544
5545 dlg.finished(true);
5546 return Ok(response);
5547 }
5548 }
5549 }
5550 }
5551
5552 /// Required. Name of the server.
5553 ///
5554 /// Sets the *name* path property to the given value.
5555 ///
5556 /// Even though the property as already been set when instantiating this call,
5557 /// we provide this method for API completeness.
5558 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceLoadAuthInfoCall<'a, C> {
5559 self._name = new_value.to_string();
5560 self
5561 }
5562 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5563 /// while executing the actual API request.
5564 ///
5565 /// ````text
5566 /// It should be used to handle progress information, and to implement a certain level of resilience.
5567 /// ````
5568 ///
5569 /// Sets the *delegate* property to the given value.
5570 pub fn delegate(
5571 mut self,
5572 new_value: &'a mut dyn common::Delegate,
5573 ) -> ProjectLocationInstanceLoadAuthInfoCall<'a, C> {
5574 self._delegate = Some(new_value);
5575 self
5576 }
5577
5578 /// Set any additional parameter of the query string used in the request.
5579 /// It should be used to set parameters which are not yet available through their own
5580 /// setters.
5581 ///
5582 /// Please note that this method must not be used to set any of the known parameters
5583 /// which have their own setter method. If done anyway, the request will fail.
5584 ///
5585 /// # Additional Parameters
5586 ///
5587 /// * *$.xgafv* (query-string) - V1 error format.
5588 /// * *access_token* (query-string) - OAuth access token.
5589 /// * *alt* (query-string) - Data format for response.
5590 /// * *callback* (query-string) - JSONP
5591 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5592 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5593 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5594 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5595 /// * *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.
5596 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5597 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5598 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceLoadAuthInfoCall<'a, C>
5599 where
5600 T: AsRef<str>,
5601 {
5602 self._additional_params
5603 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5604 self
5605 }
5606
5607 /// Identifies the authorization scope for the method you are building.
5608 ///
5609 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5610 /// [`Scope::CloudPlatform`].
5611 ///
5612 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5613 /// tokens for more than one scope.
5614 ///
5615 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5616 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5617 /// sufficient, a read-write scope will do as well.
5618 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceLoadAuthInfoCall<'a, C>
5619 where
5620 St: AsRef<str>,
5621 {
5622 self._scopes.insert(String::from(scope.as_ref()));
5623 self
5624 }
5625 /// Identifies the authorization scope(s) for the method you are building.
5626 ///
5627 /// See [`Self::add_scope()`] for details.
5628 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceLoadAuthInfoCall<'a, C>
5629 where
5630 I: IntoIterator<Item = St>,
5631 St: AsRef<str>,
5632 {
5633 self._scopes
5634 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5635 self
5636 }
5637
5638 /// Removes all scopes, and no default scope will be used either.
5639 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5640 /// for details).
5641 pub fn clear_scopes(mut self) -> ProjectLocationInstanceLoadAuthInfoCall<'a, C> {
5642 self._scopes.clear();
5643 self
5644 }
5645}
5646
5647/// Update details of a single server.
5648///
5649/// A builder for the *locations.instances.patch* method supported by a *project* resource.
5650/// It is not used directly, but through a [`ProjectMethods`] instance.
5651///
5652/// # Example
5653///
5654/// Instantiate a resource method builder
5655///
5656/// ```test_harness,no_run
5657/// # extern crate hyper;
5658/// # extern crate hyper_rustls;
5659/// # extern crate google_baremetalsolution2 as baremetalsolution2;
5660/// use baremetalsolution2::api::Instance;
5661/// # async fn dox() {
5662/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5663///
5664/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5665/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5666/// # secret,
5667/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5668/// # ).build().await.unwrap();
5669///
5670/// # let client = hyper_util::client::legacy::Client::builder(
5671/// # hyper_util::rt::TokioExecutor::new()
5672/// # )
5673/// # .build(
5674/// # hyper_rustls::HttpsConnectorBuilder::new()
5675/// # .with_native_roots()
5676/// # .unwrap()
5677/// # .https_or_http()
5678/// # .enable_http1()
5679/// # .build()
5680/// # );
5681/// # let mut hub = Baremetalsolution::new(client, auth);
5682/// // As the method needs a request, you would usually fill it with the desired information
5683/// // into the respective structure. Some of the parts shown here might not be applicable !
5684/// // Values shown here are possibly random and not representative !
5685/// let mut req = Instance::default();
5686///
5687/// // You can configure optional parameters by calling the respective setters at will, and
5688/// // execute the final call using `doit()`.
5689/// // Values shown here are possibly random and not representative !
5690/// let result = hub.projects().locations_instances_patch(req, "name")
5691/// .update_mask(FieldMask::new::<&str>(&[]))
5692/// .doit().await;
5693/// # }
5694/// ```
5695pub struct ProjectLocationInstancePatchCall<'a, C>
5696where
5697 C: 'a,
5698{
5699 hub: &'a Baremetalsolution<C>,
5700 _request: Instance,
5701 _name: String,
5702 _update_mask: Option<common::FieldMask>,
5703 _delegate: Option<&'a mut dyn common::Delegate>,
5704 _additional_params: HashMap<String, String>,
5705 _scopes: BTreeSet<String>,
5706}
5707
5708impl<'a, C> common::CallBuilder for ProjectLocationInstancePatchCall<'a, C> {}
5709
5710impl<'a, C> ProjectLocationInstancePatchCall<'a, C>
5711where
5712 C: common::Connector,
5713{
5714 /// Perform the operation you have build so far.
5715 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5716 use std::borrow::Cow;
5717 use std::io::{Read, Seek};
5718
5719 use common::{url::Params, ToParts};
5720 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5721
5722 let mut dd = common::DefaultDelegate;
5723 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5724 dlg.begin(common::MethodInfo {
5725 id: "baremetalsolution.projects.locations.instances.patch",
5726 http_method: hyper::Method::PATCH,
5727 });
5728
5729 for &field in ["alt", "name", "updateMask"].iter() {
5730 if self._additional_params.contains_key(field) {
5731 dlg.finished(false);
5732 return Err(common::Error::FieldClash(field));
5733 }
5734 }
5735
5736 let mut params = Params::with_capacity(5 + self._additional_params.len());
5737 params.push("name", self._name);
5738 if let Some(value) = self._update_mask.as_ref() {
5739 params.push("updateMask", value.to_string());
5740 }
5741
5742 params.extend(self._additional_params.iter());
5743
5744 params.push("alt", "json");
5745 let mut url = self.hub._base_url.clone() + "v2/{+name}";
5746 if self._scopes.is_empty() {
5747 self._scopes
5748 .insert(Scope::CloudPlatform.as_ref().to_string());
5749 }
5750
5751 #[allow(clippy::single_element_loop)]
5752 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5753 url = params.uri_replacement(url, param_name, find_this, true);
5754 }
5755 {
5756 let to_remove = ["name"];
5757 params.remove_params(&to_remove);
5758 }
5759
5760 let url = params.parse_with_url(&url);
5761
5762 let mut json_mime_type = mime::APPLICATION_JSON;
5763 let mut request_value_reader = {
5764 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5765 common::remove_json_null_values(&mut value);
5766 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5767 serde_json::to_writer(&mut dst, &value).unwrap();
5768 dst
5769 };
5770 let request_size = request_value_reader
5771 .seek(std::io::SeekFrom::End(0))
5772 .unwrap();
5773 request_value_reader
5774 .seek(std::io::SeekFrom::Start(0))
5775 .unwrap();
5776
5777 loop {
5778 let token = match self
5779 .hub
5780 .auth
5781 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5782 .await
5783 {
5784 Ok(token) => token,
5785 Err(e) => match dlg.token(e) {
5786 Ok(token) => token,
5787 Err(e) => {
5788 dlg.finished(false);
5789 return Err(common::Error::MissingToken(e));
5790 }
5791 },
5792 };
5793 request_value_reader
5794 .seek(std::io::SeekFrom::Start(0))
5795 .unwrap();
5796 let mut req_result = {
5797 let client = &self.hub.client;
5798 dlg.pre_request();
5799 let mut req_builder = hyper::Request::builder()
5800 .method(hyper::Method::PATCH)
5801 .uri(url.as_str())
5802 .header(USER_AGENT, self.hub._user_agent.clone());
5803
5804 if let Some(token) = token.as_ref() {
5805 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5806 }
5807
5808 let request = req_builder
5809 .header(CONTENT_TYPE, json_mime_type.to_string())
5810 .header(CONTENT_LENGTH, request_size as u64)
5811 .body(common::to_body(
5812 request_value_reader.get_ref().clone().into(),
5813 ));
5814
5815 client.request(request.unwrap()).await
5816 };
5817
5818 match req_result {
5819 Err(err) => {
5820 if let common::Retry::After(d) = dlg.http_error(&err) {
5821 sleep(d).await;
5822 continue;
5823 }
5824 dlg.finished(false);
5825 return Err(common::Error::HttpError(err));
5826 }
5827 Ok(res) => {
5828 let (mut parts, body) = res.into_parts();
5829 let mut body = common::Body::new(body);
5830 if !parts.status.is_success() {
5831 let bytes = common::to_bytes(body).await.unwrap_or_default();
5832 let error = serde_json::from_str(&common::to_string(&bytes));
5833 let response = common::to_response(parts, bytes.into());
5834
5835 if let common::Retry::After(d) =
5836 dlg.http_failure(&response, error.as_ref().ok())
5837 {
5838 sleep(d).await;
5839 continue;
5840 }
5841
5842 dlg.finished(false);
5843
5844 return Err(match error {
5845 Ok(value) => common::Error::BadRequest(value),
5846 _ => common::Error::Failure(response),
5847 });
5848 }
5849 let response = {
5850 let bytes = common::to_bytes(body).await.unwrap_or_default();
5851 let encoded = common::to_string(&bytes);
5852 match serde_json::from_str(&encoded) {
5853 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5854 Err(error) => {
5855 dlg.response_json_decode_error(&encoded, &error);
5856 return Err(common::Error::JsonDecodeError(
5857 encoded.to_string(),
5858 error,
5859 ));
5860 }
5861 }
5862 };
5863
5864 dlg.finished(true);
5865 return Ok(response);
5866 }
5867 }
5868 }
5869 }
5870
5871 ///
5872 /// Sets the *request* property to the given value.
5873 ///
5874 /// Even though the property as already been set when instantiating this call,
5875 /// we provide this method for API completeness.
5876 pub fn request(mut self, new_value: Instance) -> ProjectLocationInstancePatchCall<'a, C> {
5877 self._request = new_value;
5878 self
5879 }
5880 /// 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}`
5881 ///
5882 /// Sets the *name* path property to the given value.
5883 ///
5884 /// Even though the property as already been set when instantiating this call,
5885 /// we provide this method for API completeness.
5886 pub fn name(mut self, new_value: &str) -> ProjectLocationInstancePatchCall<'a, C> {
5887 self._name = new_value.to_string();
5888 self
5889 }
5890 /// The list of fields to update. The currently supported fields are: `labels` `hyperthreading_enabled` `os_image` `ssh_keys` `kms_key_version`
5891 ///
5892 /// Sets the *update mask* query property to the given value.
5893 pub fn update_mask(
5894 mut self,
5895 new_value: common::FieldMask,
5896 ) -> ProjectLocationInstancePatchCall<'a, C> {
5897 self._update_mask = Some(new_value);
5898 self
5899 }
5900 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5901 /// while executing the actual API request.
5902 ///
5903 /// ````text
5904 /// It should be used to handle progress information, and to implement a certain level of resilience.
5905 /// ````
5906 ///
5907 /// Sets the *delegate* property to the given value.
5908 pub fn delegate(
5909 mut self,
5910 new_value: &'a mut dyn common::Delegate,
5911 ) -> ProjectLocationInstancePatchCall<'a, C> {
5912 self._delegate = Some(new_value);
5913 self
5914 }
5915
5916 /// Set any additional parameter of the query string used in the request.
5917 /// It should be used to set parameters which are not yet available through their own
5918 /// setters.
5919 ///
5920 /// Please note that this method must not be used to set any of the known parameters
5921 /// which have their own setter method. If done anyway, the request will fail.
5922 ///
5923 /// # Additional Parameters
5924 ///
5925 /// * *$.xgafv* (query-string) - V1 error format.
5926 /// * *access_token* (query-string) - OAuth access token.
5927 /// * *alt* (query-string) - Data format for response.
5928 /// * *callback* (query-string) - JSONP
5929 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5930 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5931 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5932 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5933 /// * *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.
5934 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5935 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5936 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstancePatchCall<'a, C>
5937 where
5938 T: AsRef<str>,
5939 {
5940 self._additional_params
5941 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5942 self
5943 }
5944
5945 /// Identifies the authorization scope for the method you are building.
5946 ///
5947 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5948 /// [`Scope::CloudPlatform`].
5949 ///
5950 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5951 /// tokens for more than one scope.
5952 ///
5953 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5954 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5955 /// sufficient, a read-write scope will do as well.
5956 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstancePatchCall<'a, C>
5957 where
5958 St: AsRef<str>,
5959 {
5960 self._scopes.insert(String::from(scope.as_ref()));
5961 self
5962 }
5963 /// Identifies the authorization scope(s) for the method you are building.
5964 ///
5965 /// See [`Self::add_scope()`] for details.
5966 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstancePatchCall<'a, C>
5967 where
5968 I: IntoIterator<Item = St>,
5969 St: AsRef<str>,
5970 {
5971 self._scopes
5972 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5973 self
5974 }
5975
5976 /// Removes all scopes, and no default scope will be used either.
5977 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5978 /// for details).
5979 pub fn clear_scopes(mut self) -> ProjectLocationInstancePatchCall<'a, C> {
5980 self._scopes.clear();
5981 self
5982 }
5983}
5984
5985/// Perform reimage operation on a single server.
5986///
5987/// A builder for the *locations.instances.reimage* method supported by a *project* resource.
5988/// It is not used directly, but through a [`ProjectMethods`] instance.
5989///
5990/// # Example
5991///
5992/// Instantiate a resource method builder
5993///
5994/// ```test_harness,no_run
5995/// # extern crate hyper;
5996/// # extern crate hyper_rustls;
5997/// # extern crate google_baremetalsolution2 as baremetalsolution2;
5998/// use baremetalsolution2::api::ReimageInstanceRequest;
5999/// # async fn dox() {
6000/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6001///
6002/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6003/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6004/// # secret,
6005/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6006/// # ).build().await.unwrap();
6007///
6008/// # let client = hyper_util::client::legacy::Client::builder(
6009/// # hyper_util::rt::TokioExecutor::new()
6010/// # )
6011/// # .build(
6012/// # hyper_rustls::HttpsConnectorBuilder::new()
6013/// # .with_native_roots()
6014/// # .unwrap()
6015/// # .https_or_http()
6016/// # .enable_http1()
6017/// # .build()
6018/// # );
6019/// # let mut hub = Baremetalsolution::new(client, auth);
6020/// // As the method needs a request, you would usually fill it with the desired information
6021/// // into the respective structure. Some of the parts shown here might not be applicable !
6022/// // Values shown here are possibly random and not representative !
6023/// let mut req = ReimageInstanceRequest::default();
6024///
6025/// // You can configure optional parameters by calling the respective setters at will, and
6026/// // execute the final call using `doit()`.
6027/// // Values shown here are possibly random and not representative !
6028/// let result = hub.projects().locations_instances_reimage(req, "name")
6029/// .doit().await;
6030/// # }
6031/// ```
6032pub struct ProjectLocationInstanceReimageCall<'a, C>
6033where
6034 C: 'a,
6035{
6036 hub: &'a Baremetalsolution<C>,
6037 _request: ReimageInstanceRequest,
6038 _name: String,
6039 _delegate: Option<&'a mut dyn common::Delegate>,
6040 _additional_params: HashMap<String, String>,
6041 _scopes: BTreeSet<String>,
6042}
6043
6044impl<'a, C> common::CallBuilder for ProjectLocationInstanceReimageCall<'a, C> {}
6045
6046impl<'a, C> ProjectLocationInstanceReimageCall<'a, C>
6047where
6048 C: common::Connector,
6049{
6050 /// Perform the operation you have build so far.
6051 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6052 use std::borrow::Cow;
6053 use std::io::{Read, Seek};
6054
6055 use common::{url::Params, ToParts};
6056 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6057
6058 let mut dd = common::DefaultDelegate;
6059 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6060 dlg.begin(common::MethodInfo {
6061 id: "baremetalsolution.projects.locations.instances.reimage",
6062 http_method: hyper::Method::POST,
6063 });
6064
6065 for &field in ["alt", "name"].iter() {
6066 if self._additional_params.contains_key(field) {
6067 dlg.finished(false);
6068 return Err(common::Error::FieldClash(field));
6069 }
6070 }
6071
6072 let mut params = Params::with_capacity(4 + self._additional_params.len());
6073 params.push("name", self._name);
6074
6075 params.extend(self._additional_params.iter());
6076
6077 params.push("alt", "json");
6078 let mut url = self.hub._base_url.clone() + "v2/{+name}:reimage";
6079 if self._scopes.is_empty() {
6080 self._scopes
6081 .insert(Scope::CloudPlatform.as_ref().to_string());
6082 }
6083
6084 #[allow(clippy::single_element_loop)]
6085 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6086 url = params.uri_replacement(url, param_name, find_this, true);
6087 }
6088 {
6089 let to_remove = ["name"];
6090 params.remove_params(&to_remove);
6091 }
6092
6093 let url = params.parse_with_url(&url);
6094
6095 let mut json_mime_type = mime::APPLICATION_JSON;
6096 let mut request_value_reader = {
6097 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6098 common::remove_json_null_values(&mut value);
6099 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6100 serde_json::to_writer(&mut dst, &value).unwrap();
6101 dst
6102 };
6103 let request_size = request_value_reader
6104 .seek(std::io::SeekFrom::End(0))
6105 .unwrap();
6106 request_value_reader
6107 .seek(std::io::SeekFrom::Start(0))
6108 .unwrap();
6109
6110 loop {
6111 let token = match self
6112 .hub
6113 .auth
6114 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6115 .await
6116 {
6117 Ok(token) => token,
6118 Err(e) => match dlg.token(e) {
6119 Ok(token) => token,
6120 Err(e) => {
6121 dlg.finished(false);
6122 return Err(common::Error::MissingToken(e));
6123 }
6124 },
6125 };
6126 request_value_reader
6127 .seek(std::io::SeekFrom::Start(0))
6128 .unwrap();
6129 let mut req_result = {
6130 let client = &self.hub.client;
6131 dlg.pre_request();
6132 let mut req_builder = hyper::Request::builder()
6133 .method(hyper::Method::POST)
6134 .uri(url.as_str())
6135 .header(USER_AGENT, self.hub._user_agent.clone());
6136
6137 if let Some(token) = token.as_ref() {
6138 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6139 }
6140
6141 let request = req_builder
6142 .header(CONTENT_TYPE, json_mime_type.to_string())
6143 .header(CONTENT_LENGTH, request_size as u64)
6144 .body(common::to_body(
6145 request_value_reader.get_ref().clone().into(),
6146 ));
6147
6148 client.request(request.unwrap()).await
6149 };
6150
6151 match req_result {
6152 Err(err) => {
6153 if let common::Retry::After(d) = dlg.http_error(&err) {
6154 sleep(d).await;
6155 continue;
6156 }
6157 dlg.finished(false);
6158 return Err(common::Error::HttpError(err));
6159 }
6160 Ok(res) => {
6161 let (mut parts, body) = res.into_parts();
6162 let mut body = common::Body::new(body);
6163 if !parts.status.is_success() {
6164 let bytes = common::to_bytes(body).await.unwrap_or_default();
6165 let error = serde_json::from_str(&common::to_string(&bytes));
6166 let response = common::to_response(parts, bytes.into());
6167
6168 if let common::Retry::After(d) =
6169 dlg.http_failure(&response, error.as_ref().ok())
6170 {
6171 sleep(d).await;
6172 continue;
6173 }
6174
6175 dlg.finished(false);
6176
6177 return Err(match error {
6178 Ok(value) => common::Error::BadRequest(value),
6179 _ => common::Error::Failure(response),
6180 });
6181 }
6182 let response = {
6183 let bytes = common::to_bytes(body).await.unwrap_or_default();
6184 let encoded = common::to_string(&bytes);
6185 match serde_json::from_str(&encoded) {
6186 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6187 Err(error) => {
6188 dlg.response_json_decode_error(&encoded, &error);
6189 return Err(common::Error::JsonDecodeError(
6190 encoded.to_string(),
6191 error,
6192 ));
6193 }
6194 }
6195 };
6196
6197 dlg.finished(true);
6198 return Ok(response);
6199 }
6200 }
6201 }
6202 }
6203
6204 ///
6205 /// Sets the *request* property to the given value.
6206 ///
6207 /// Even though the property as already been set when instantiating this call,
6208 /// we provide this method for API completeness.
6209 pub fn request(
6210 mut self,
6211 new_value: ReimageInstanceRequest,
6212 ) -> ProjectLocationInstanceReimageCall<'a, C> {
6213 self._request = new_value;
6214 self
6215 }
6216 /// Required. The `name` field is used to identify the instance. Format: projects/{project}/locations/{location}/instances/{instance}
6217 ///
6218 /// Sets the *name* path property to the given value.
6219 ///
6220 /// Even though the property as already been set when instantiating this call,
6221 /// we provide this method for API completeness.
6222 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceReimageCall<'a, C> {
6223 self._name = new_value.to_string();
6224 self
6225 }
6226 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6227 /// while executing the actual API request.
6228 ///
6229 /// ````text
6230 /// It should be used to handle progress information, and to implement a certain level of resilience.
6231 /// ````
6232 ///
6233 /// Sets the *delegate* property to the given value.
6234 pub fn delegate(
6235 mut self,
6236 new_value: &'a mut dyn common::Delegate,
6237 ) -> ProjectLocationInstanceReimageCall<'a, C> {
6238 self._delegate = Some(new_value);
6239 self
6240 }
6241
6242 /// Set any additional parameter of the query string used in the request.
6243 /// It should be used to set parameters which are not yet available through their own
6244 /// setters.
6245 ///
6246 /// Please note that this method must not be used to set any of the known parameters
6247 /// which have their own setter method. If done anyway, the request will fail.
6248 ///
6249 /// # Additional Parameters
6250 ///
6251 /// * *$.xgafv* (query-string) - V1 error format.
6252 /// * *access_token* (query-string) - OAuth access token.
6253 /// * *alt* (query-string) - Data format for response.
6254 /// * *callback* (query-string) - JSONP
6255 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6256 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6257 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6258 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6259 /// * *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.
6260 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6261 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6262 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceReimageCall<'a, C>
6263 where
6264 T: AsRef<str>,
6265 {
6266 self._additional_params
6267 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6268 self
6269 }
6270
6271 /// Identifies the authorization scope for the method you are building.
6272 ///
6273 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6274 /// [`Scope::CloudPlatform`].
6275 ///
6276 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6277 /// tokens for more than one scope.
6278 ///
6279 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6280 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6281 /// sufficient, a read-write scope will do as well.
6282 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceReimageCall<'a, C>
6283 where
6284 St: AsRef<str>,
6285 {
6286 self._scopes.insert(String::from(scope.as_ref()));
6287 self
6288 }
6289 /// Identifies the authorization scope(s) for the method you are building.
6290 ///
6291 /// See [`Self::add_scope()`] for details.
6292 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceReimageCall<'a, C>
6293 where
6294 I: IntoIterator<Item = St>,
6295 St: AsRef<str>,
6296 {
6297 self._scopes
6298 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6299 self
6300 }
6301
6302 /// Removes all scopes, and no default scope will be used either.
6303 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6304 /// for details).
6305 pub fn clear_scopes(mut self) -> ProjectLocationInstanceReimageCall<'a, C> {
6306 self._scopes.clear();
6307 self
6308 }
6309}
6310
6311/// RenameInstance sets a new name for an instance. Use with caution, previous names become immediately invalidated.
6312///
6313/// A builder for the *locations.instances.rename* method supported by a *project* resource.
6314/// It is not used directly, but through a [`ProjectMethods`] instance.
6315///
6316/// # Example
6317///
6318/// Instantiate a resource method builder
6319///
6320/// ```test_harness,no_run
6321/// # extern crate hyper;
6322/// # extern crate hyper_rustls;
6323/// # extern crate google_baremetalsolution2 as baremetalsolution2;
6324/// use baremetalsolution2::api::RenameInstanceRequest;
6325/// # async fn dox() {
6326/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6327///
6328/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6329/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6330/// # secret,
6331/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6332/// # ).build().await.unwrap();
6333///
6334/// # let client = hyper_util::client::legacy::Client::builder(
6335/// # hyper_util::rt::TokioExecutor::new()
6336/// # )
6337/// # .build(
6338/// # hyper_rustls::HttpsConnectorBuilder::new()
6339/// # .with_native_roots()
6340/// # .unwrap()
6341/// # .https_or_http()
6342/// # .enable_http1()
6343/// # .build()
6344/// # );
6345/// # let mut hub = Baremetalsolution::new(client, auth);
6346/// // As the method needs a request, you would usually fill it with the desired information
6347/// // into the respective structure. Some of the parts shown here might not be applicable !
6348/// // Values shown here are possibly random and not representative !
6349/// let mut req = RenameInstanceRequest::default();
6350///
6351/// // You can configure optional parameters by calling the respective setters at will, and
6352/// // execute the final call using `doit()`.
6353/// // Values shown here are possibly random and not representative !
6354/// let result = hub.projects().locations_instances_rename(req, "name")
6355/// .doit().await;
6356/// # }
6357/// ```
6358pub struct ProjectLocationInstanceRenameCall<'a, C>
6359where
6360 C: 'a,
6361{
6362 hub: &'a Baremetalsolution<C>,
6363 _request: RenameInstanceRequest,
6364 _name: String,
6365 _delegate: Option<&'a mut dyn common::Delegate>,
6366 _additional_params: HashMap<String, String>,
6367 _scopes: BTreeSet<String>,
6368}
6369
6370impl<'a, C> common::CallBuilder for ProjectLocationInstanceRenameCall<'a, C> {}
6371
6372impl<'a, C> ProjectLocationInstanceRenameCall<'a, C>
6373where
6374 C: common::Connector,
6375{
6376 /// Perform the operation you have build so far.
6377 pub async fn doit(mut self) -> common::Result<(common::Response, Instance)> {
6378 use std::borrow::Cow;
6379 use std::io::{Read, Seek};
6380
6381 use common::{url::Params, ToParts};
6382 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6383
6384 let mut dd = common::DefaultDelegate;
6385 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6386 dlg.begin(common::MethodInfo {
6387 id: "baremetalsolution.projects.locations.instances.rename",
6388 http_method: hyper::Method::POST,
6389 });
6390
6391 for &field in ["alt", "name"].iter() {
6392 if self._additional_params.contains_key(field) {
6393 dlg.finished(false);
6394 return Err(common::Error::FieldClash(field));
6395 }
6396 }
6397
6398 let mut params = Params::with_capacity(4 + self._additional_params.len());
6399 params.push("name", self._name);
6400
6401 params.extend(self._additional_params.iter());
6402
6403 params.push("alt", "json");
6404 let mut url = self.hub._base_url.clone() + "v2/{+name}:rename";
6405 if self._scopes.is_empty() {
6406 self._scopes
6407 .insert(Scope::CloudPlatform.as_ref().to_string());
6408 }
6409
6410 #[allow(clippy::single_element_loop)]
6411 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6412 url = params.uri_replacement(url, param_name, find_this, true);
6413 }
6414 {
6415 let to_remove = ["name"];
6416 params.remove_params(&to_remove);
6417 }
6418
6419 let url = params.parse_with_url(&url);
6420
6421 let mut json_mime_type = mime::APPLICATION_JSON;
6422 let mut request_value_reader = {
6423 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6424 common::remove_json_null_values(&mut value);
6425 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6426 serde_json::to_writer(&mut dst, &value).unwrap();
6427 dst
6428 };
6429 let request_size = request_value_reader
6430 .seek(std::io::SeekFrom::End(0))
6431 .unwrap();
6432 request_value_reader
6433 .seek(std::io::SeekFrom::Start(0))
6434 .unwrap();
6435
6436 loop {
6437 let token = match self
6438 .hub
6439 .auth
6440 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6441 .await
6442 {
6443 Ok(token) => token,
6444 Err(e) => match dlg.token(e) {
6445 Ok(token) => token,
6446 Err(e) => {
6447 dlg.finished(false);
6448 return Err(common::Error::MissingToken(e));
6449 }
6450 },
6451 };
6452 request_value_reader
6453 .seek(std::io::SeekFrom::Start(0))
6454 .unwrap();
6455 let mut req_result = {
6456 let client = &self.hub.client;
6457 dlg.pre_request();
6458 let mut req_builder = hyper::Request::builder()
6459 .method(hyper::Method::POST)
6460 .uri(url.as_str())
6461 .header(USER_AGENT, self.hub._user_agent.clone());
6462
6463 if let Some(token) = token.as_ref() {
6464 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6465 }
6466
6467 let request = req_builder
6468 .header(CONTENT_TYPE, json_mime_type.to_string())
6469 .header(CONTENT_LENGTH, request_size as u64)
6470 .body(common::to_body(
6471 request_value_reader.get_ref().clone().into(),
6472 ));
6473
6474 client.request(request.unwrap()).await
6475 };
6476
6477 match req_result {
6478 Err(err) => {
6479 if let common::Retry::After(d) = dlg.http_error(&err) {
6480 sleep(d).await;
6481 continue;
6482 }
6483 dlg.finished(false);
6484 return Err(common::Error::HttpError(err));
6485 }
6486 Ok(res) => {
6487 let (mut parts, body) = res.into_parts();
6488 let mut body = common::Body::new(body);
6489 if !parts.status.is_success() {
6490 let bytes = common::to_bytes(body).await.unwrap_or_default();
6491 let error = serde_json::from_str(&common::to_string(&bytes));
6492 let response = common::to_response(parts, bytes.into());
6493
6494 if let common::Retry::After(d) =
6495 dlg.http_failure(&response, error.as_ref().ok())
6496 {
6497 sleep(d).await;
6498 continue;
6499 }
6500
6501 dlg.finished(false);
6502
6503 return Err(match error {
6504 Ok(value) => common::Error::BadRequest(value),
6505 _ => common::Error::Failure(response),
6506 });
6507 }
6508 let response = {
6509 let bytes = common::to_bytes(body).await.unwrap_or_default();
6510 let encoded = common::to_string(&bytes);
6511 match serde_json::from_str(&encoded) {
6512 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6513 Err(error) => {
6514 dlg.response_json_decode_error(&encoded, &error);
6515 return Err(common::Error::JsonDecodeError(
6516 encoded.to_string(),
6517 error,
6518 ));
6519 }
6520 }
6521 };
6522
6523 dlg.finished(true);
6524 return Ok(response);
6525 }
6526 }
6527 }
6528 }
6529
6530 ///
6531 /// Sets the *request* property to the given value.
6532 ///
6533 /// Even though the property as already been set when instantiating this call,
6534 /// we provide this method for API completeness.
6535 pub fn request(
6536 mut self,
6537 new_value: RenameInstanceRequest,
6538 ) -> ProjectLocationInstanceRenameCall<'a, C> {
6539 self._request = new_value;
6540 self
6541 }
6542 /// Required. The `name` field is used to identify the instance. Format: projects/{project}/locations/{location}/instances/{instance}
6543 ///
6544 /// Sets the *name* path property to the given value.
6545 ///
6546 /// Even though the property as already been set when instantiating this call,
6547 /// we provide this method for API completeness.
6548 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceRenameCall<'a, C> {
6549 self._name = new_value.to_string();
6550 self
6551 }
6552 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6553 /// while executing the actual API request.
6554 ///
6555 /// ````text
6556 /// It should be used to handle progress information, and to implement a certain level of resilience.
6557 /// ````
6558 ///
6559 /// Sets the *delegate* property to the given value.
6560 pub fn delegate(
6561 mut self,
6562 new_value: &'a mut dyn common::Delegate,
6563 ) -> ProjectLocationInstanceRenameCall<'a, C> {
6564 self._delegate = Some(new_value);
6565 self
6566 }
6567
6568 /// Set any additional parameter of the query string used in the request.
6569 /// It should be used to set parameters which are not yet available through their own
6570 /// setters.
6571 ///
6572 /// Please note that this method must not be used to set any of the known parameters
6573 /// which have their own setter method. If done anyway, the request will fail.
6574 ///
6575 /// # Additional Parameters
6576 ///
6577 /// * *$.xgafv* (query-string) - V1 error format.
6578 /// * *access_token* (query-string) - OAuth access token.
6579 /// * *alt* (query-string) - Data format for response.
6580 /// * *callback* (query-string) - JSONP
6581 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6582 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6583 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6584 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6585 /// * *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.
6586 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6587 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6588 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceRenameCall<'a, C>
6589 where
6590 T: AsRef<str>,
6591 {
6592 self._additional_params
6593 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6594 self
6595 }
6596
6597 /// Identifies the authorization scope for the method you are building.
6598 ///
6599 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6600 /// [`Scope::CloudPlatform`].
6601 ///
6602 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6603 /// tokens for more than one scope.
6604 ///
6605 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6606 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6607 /// sufficient, a read-write scope will do as well.
6608 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceRenameCall<'a, C>
6609 where
6610 St: AsRef<str>,
6611 {
6612 self._scopes.insert(String::from(scope.as_ref()));
6613 self
6614 }
6615 /// Identifies the authorization scope(s) for the method you are building.
6616 ///
6617 /// See [`Self::add_scope()`] for details.
6618 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceRenameCall<'a, C>
6619 where
6620 I: IntoIterator<Item = St>,
6621 St: AsRef<str>,
6622 {
6623 self._scopes
6624 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6625 self
6626 }
6627
6628 /// Removes all scopes, and no default scope will be used either.
6629 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6630 /// for details).
6631 pub fn clear_scopes(mut self) -> ProjectLocationInstanceRenameCall<'a, C> {
6632 self._scopes.clear();
6633 self
6634 }
6635}
6636
6637/// Perform an ungraceful, hard reset on a server. Equivalent to shutting the power off and then turning it back on.
6638///
6639/// A builder for the *locations.instances.reset* method supported by a *project* resource.
6640/// It is not used directly, but through a [`ProjectMethods`] instance.
6641///
6642/// # Example
6643///
6644/// Instantiate a resource method builder
6645///
6646/// ```test_harness,no_run
6647/// # extern crate hyper;
6648/// # extern crate hyper_rustls;
6649/// # extern crate google_baremetalsolution2 as baremetalsolution2;
6650/// use baremetalsolution2::api::ResetInstanceRequest;
6651/// # async fn dox() {
6652/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6653///
6654/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6655/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6656/// # secret,
6657/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6658/// # ).build().await.unwrap();
6659///
6660/// # let client = hyper_util::client::legacy::Client::builder(
6661/// # hyper_util::rt::TokioExecutor::new()
6662/// # )
6663/// # .build(
6664/// # hyper_rustls::HttpsConnectorBuilder::new()
6665/// # .with_native_roots()
6666/// # .unwrap()
6667/// # .https_or_http()
6668/// # .enable_http1()
6669/// # .build()
6670/// # );
6671/// # let mut hub = Baremetalsolution::new(client, auth);
6672/// // As the method needs a request, you would usually fill it with the desired information
6673/// // into the respective structure. Some of the parts shown here might not be applicable !
6674/// // Values shown here are possibly random and not representative !
6675/// let mut req = ResetInstanceRequest::default();
6676///
6677/// // You can configure optional parameters by calling the respective setters at will, and
6678/// // execute the final call using `doit()`.
6679/// // Values shown here are possibly random and not representative !
6680/// let result = hub.projects().locations_instances_reset(req, "name")
6681/// .doit().await;
6682/// # }
6683/// ```
6684pub struct ProjectLocationInstanceResetCall<'a, C>
6685where
6686 C: 'a,
6687{
6688 hub: &'a Baremetalsolution<C>,
6689 _request: ResetInstanceRequest,
6690 _name: String,
6691 _delegate: Option<&'a mut dyn common::Delegate>,
6692 _additional_params: HashMap<String, String>,
6693 _scopes: BTreeSet<String>,
6694}
6695
6696impl<'a, C> common::CallBuilder for ProjectLocationInstanceResetCall<'a, C> {}
6697
6698impl<'a, C> ProjectLocationInstanceResetCall<'a, C>
6699where
6700 C: common::Connector,
6701{
6702 /// Perform the operation you have build so far.
6703 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6704 use std::borrow::Cow;
6705 use std::io::{Read, Seek};
6706
6707 use common::{url::Params, ToParts};
6708 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6709
6710 let mut dd = common::DefaultDelegate;
6711 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6712 dlg.begin(common::MethodInfo {
6713 id: "baremetalsolution.projects.locations.instances.reset",
6714 http_method: hyper::Method::POST,
6715 });
6716
6717 for &field in ["alt", "name"].iter() {
6718 if self._additional_params.contains_key(field) {
6719 dlg.finished(false);
6720 return Err(common::Error::FieldClash(field));
6721 }
6722 }
6723
6724 let mut params = Params::with_capacity(4 + self._additional_params.len());
6725 params.push("name", self._name);
6726
6727 params.extend(self._additional_params.iter());
6728
6729 params.push("alt", "json");
6730 let mut url = self.hub._base_url.clone() + "v2/{+name}:reset";
6731 if self._scopes.is_empty() {
6732 self._scopes
6733 .insert(Scope::CloudPlatform.as_ref().to_string());
6734 }
6735
6736 #[allow(clippy::single_element_loop)]
6737 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6738 url = params.uri_replacement(url, param_name, find_this, true);
6739 }
6740 {
6741 let to_remove = ["name"];
6742 params.remove_params(&to_remove);
6743 }
6744
6745 let url = params.parse_with_url(&url);
6746
6747 let mut json_mime_type = mime::APPLICATION_JSON;
6748 let mut request_value_reader = {
6749 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6750 common::remove_json_null_values(&mut value);
6751 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6752 serde_json::to_writer(&mut dst, &value).unwrap();
6753 dst
6754 };
6755 let request_size = request_value_reader
6756 .seek(std::io::SeekFrom::End(0))
6757 .unwrap();
6758 request_value_reader
6759 .seek(std::io::SeekFrom::Start(0))
6760 .unwrap();
6761
6762 loop {
6763 let token = match self
6764 .hub
6765 .auth
6766 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6767 .await
6768 {
6769 Ok(token) => token,
6770 Err(e) => match dlg.token(e) {
6771 Ok(token) => token,
6772 Err(e) => {
6773 dlg.finished(false);
6774 return Err(common::Error::MissingToken(e));
6775 }
6776 },
6777 };
6778 request_value_reader
6779 .seek(std::io::SeekFrom::Start(0))
6780 .unwrap();
6781 let mut req_result = {
6782 let client = &self.hub.client;
6783 dlg.pre_request();
6784 let mut req_builder = hyper::Request::builder()
6785 .method(hyper::Method::POST)
6786 .uri(url.as_str())
6787 .header(USER_AGENT, self.hub._user_agent.clone());
6788
6789 if let Some(token) = token.as_ref() {
6790 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6791 }
6792
6793 let request = req_builder
6794 .header(CONTENT_TYPE, json_mime_type.to_string())
6795 .header(CONTENT_LENGTH, request_size as u64)
6796 .body(common::to_body(
6797 request_value_reader.get_ref().clone().into(),
6798 ));
6799
6800 client.request(request.unwrap()).await
6801 };
6802
6803 match req_result {
6804 Err(err) => {
6805 if let common::Retry::After(d) = dlg.http_error(&err) {
6806 sleep(d).await;
6807 continue;
6808 }
6809 dlg.finished(false);
6810 return Err(common::Error::HttpError(err));
6811 }
6812 Ok(res) => {
6813 let (mut parts, body) = res.into_parts();
6814 let mut body = common::Body::new(body);
6815 if !parts.status.is_success() {
6816 let bytes = common::to_bytes(body).await.unwrap_or_default();
6817 let error = serde_json::from_str(&common::to_string(&bytes));
6818 let response = common::to_response(parts, bytes.into());
6819
6820 if let common::Retry::After(d) =
6821 dlg.http_failure(&response, error.as_ref().ok())
6822 {
6823 sleep(d).await;
6824 continue;
6825 }
6826
6827 dlg.finished(false);
6828
6829 return Err(match error {
6830 Ok(value) => common::Error::BadRequest(value),
6831 _ => common::Error::Failure(response),
6832 });
6833 }
6834 let response = {
6835 let bytes = common::to_bytes(body).await.unwrap_or_default();
6836 let encoded = common::to_string(&bytes);
6837 match serde_json::from_str(&encoded) {
6838 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6839 Err(error) => {
6840 dlg.response_json_decode_error(&encoded, &error);
6841 return Err(common::Error::JsonDecodeError(
6842 encoded.to_string(),
6843 error,
6844 ));
6845 }
6846 }
6847 };
6848
6849 dlg.finished(true);
6850 return Ok(response);
6851 }
6852 }
6853 }
6854 }
6855
6856 ///
6857 /// Sets the *request* property to the given value.
6858 ///
6859 /// Even though the property as already been set when instantiating this call,
6860 /// we provide this method for API completeness.
6861 pub fn request(
6862 mut self,
6863 new_value: ResetInstanceRequest,
6864 ) -> ProjectLocationInstanceResetCall<'a, C> {
6865 self._request = new_value;
6866 self
6867 }
6868 /// Required. Name of the resource.
6869 ///
6870 /// Sets the *name* path property to the given value.
6871 ///
6872 /// Even though the property as already been set when instantiating this call,
6873 /// we provide this method for API completeness.
6874 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceResetCall<'a, C> {
6875 self._name = new_value.to_string();
6876 self
6877 }
6878 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6879 /// while executing the actual API request.
6880 ///
6881 /// ````text
6882 /// It should be used to handle progress information, and to implement a certain level of resilience.
6883 /// ````
6884 ///
6885 /// Sets the *delegate* property to the given value.
6886 pub fn delegate(
6887 mut self,
6888 new_value: &'a mut dyn common::Delegate,
6889 ) -> ProjectLocationInstanceResetCall<'a, C> {
6890 self._delegate = Some(new_value);
6891 self
6892 }
6893
6894 /// Set any additional parameter of the query string used in the request.
6895 /// It should be used to set parameters which are not yet available through their own
6896 /// setters.
6897 ///
6898 /// Please note that this method must not be used to set any of the known parameters
6899 /// which have their own setter method. If done anyway, the request will fail.
6900 ///
6901 /// # Additional Parameters
6902 ///
6903 /// * *$.xgafv* (query-string) - V1 error format.
6904 /// * *access_token* (query-string) - OAuth access token.
6905 /// * *alt* (query-string) - Data format for response.
6906 /// * *callback* (query-string) - JSONP
6907 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6908 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6909 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6910 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6911 /// * *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.
6912 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6913 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6914 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceResetCall<'a, C>
6915 where
6916 T: AsRef<str>,
6917 {
6918 self._additional_params
6919 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6920 self
6921 }
6922
6923 /// Identifies the authorization scope for the method you are building.
6924 ///
6925 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6926 /// [`Scope::CloudPlatform`].
6927 ///
6928 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6929 /// tokens for more than one scope.
6930 ///
6931 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6932 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6933 /// sufficient, a read-write scope will do as well.
6934 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceResetCall<'a, C>
6935 where
6936 St: AsRef<str>,
6937 {
6938 self._scopes.insert(String::from(scope.as_ref()));
6939 self
6940 }
6941 /// Identifies the authorization scope(s) for the method you are building.
6942 ///
6943 /// See [`Self::add_scope()`] for details.
6944 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceResetCall<'a, C>
6945 where
6946 I: IntoIterator<Item = St>,
6947 St: AsRef<str>,
6948 {
6949 self._scopes
6950 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6951 self
6952 }
6953
6954 /// Removes all scopes, and no default scope will be used either.
6955 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6956 /// for details).
6957 pub fn clear_scopes(mut self) -> ProjectLocationInstanceResetCall<'a, C> {
6958 self._scopes.clear();
6959 self
6960 }
6961}
6962
6963/// Starts a server that was shutdown.
6964///
6965/// A builder for the *locations.instances.start* method supported by a *project* resource.
6966/// It is not used directly, but through a [`ProjectMethods`] instance.
6967///
6968/// # Example
6969///
6970/// Instantiate a resource method builder
6971///
6972/// ```test_harness,no_run
6973/// # extern crate hyper;
6974/// # extern crate hyper_rustls;
6975/// # extern crate google_baremetalsolution2 as baremetalsolution2;
6976/// use baremetalsolution2::api::StartInstanceRequest;
6977/// # async fn dox() {
6978/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6979///
6980/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6981/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6982/// # secret,
6983/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6984/// # ).build().await.unwrap();
6985///
6986/// # let client = hyper_util::client::legacy::Client::builder(
6987/// # hyper_util::rt::TokioExecutor::new()
6988/// # )
6989/// # .build(
6990/// # hyper_rustls::HttpsConnectorBuilder::new()
6991/// # .with_native_roots()
6992/// # .unwrap()
6993/// # .https_or_http()
6994/// # .enable_http1()
6995/// # .build()
6996/// # );
6997/// # let mut hub = Baremetalsolution::new(client, auth);
6998/// // As the method needs a request, you would usually fill it with the desired information
6999/// // into the respective structure. Some of the parts shown here might not be applicable !
7000/// // Values shown here are possibly random and not representative !
7001/// let mut req = StartInstanceRequest::default();
7002///
7003/// // You can configure optional parameters by calling the respective setters at will, and
7004/// // execute the final call using `doit()`.
7005/// // Values shown here are possibly random and not representative !
7006/// let result = hub.projects().locations_instances_start(req, "name")
7007/// .doit().await;
7008/// # }
7009/// ```
7010pub struct ProjectLocationInstanceStartCall<'a, C>
7011where
7012 C: 'a,
7013{
7014 hub: &'a Baremetalsolution<C>,
7015 _request: StartInstanceRequest,
7016 _name: String,
7017 _delegate: Option<&'a mut dyn common::Delegate>,
7018 _additional_params: HashMap<String, String>,
7019 _scopes: BTreeSet<String>,
7020}
7021
7022impl<'a, C> common::CallBuilder for ProjectLocationInstanceStartCall<'a, C> {}
7023
7024impl<'a, C> ProjectLocationInstanceStartCall<'a, C>
7025where
7026 C: common::Connector,
7027{
7028 /// Perform the operation you have build so far.
7029 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7030 use std::borrow::Cow;
7031 use std::io::{Read, Seek};
7032
7033 use common::{url::Params, ToParts};
7034 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7035
7036 let mut dd = common::DefaultDelegate;
7037 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7038 dlg.begin(common::MethodInfo {
7039 id: "baremetalsolution.projects.locations.instances.start",
7040 http_method: hyper::Method::POST,
7041 });
7042
7043 for &field in ["alt", "name"].iter() {
7044 if self._additional_params.contains_key(field) {
7045 dlg.finished(false);
7046 return Err(common::Error::FieldClash(field));
7047 }
7048 }
7049
7050 let mut params = Params::with_capacity(4 + self._additional_params.len());
7051 params.push("name", self._name);
7052
7053 params.extend(self._additional_params.iter());
7054
7055 params.push("alt", "json");
7056 let mut url = self.hub._base_url.clone() + "v2/{+name}:start";
7057 if self._scopes.is_empty() {
7058 self._scopes
7059 .insert(Scope::CloudPlatform.as_ref().to_string());
7060 }
7061
7062 #[allow(clippy::single_element_loop)]
7063 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7064 url = params.uri_replacement(url, param_name, find_this, true);
7065 }
7066 {
7067 let to_remove = ["name"];
7068 params.remove_params(&to_remove);
7069 }
7070
7071 let url = params.parse_with_url(&url);
7072
7073 let mut json_mime_type = mime::APPLICATION_JSON;
7074 let mut request_value_reader = {
7075 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7076 common::remove_json_null_values(&mut value);
7077 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7078 serde_json::to_writer(&mut dst, &value).unwrap();
7079 dst
7080 };
7081 let request_size = request_value_reader
7082 .seek(std::io::SeekFrom::End(0))
7083 .unwrap();
7084 request_value_reader
7085 .seek(std::io::SeekFrom::Start(0))
7086 .unwrap();
7087
7088 loop {
7089 let token = match self
7090 .hub
7091 .auth
7092 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7093 .await
7094 {
7095 Ok(token) => token,
7096 Err(e) => match dlg.token(e) {
7097 Ok(token) => token,
7098 Err(e) => {
7099 dlg.finished(false);
7100 return Err(common::Error::MissingToken(e));
7101 }
7102 },
7103 };
7104 request_value_reader
7105 .seek(std::io::SeekFrom::Start(0))
7106 .unwrap();
7107 let mut req_result = {
7108 let client = &self.hub.client;
7109 dlg.pre_request();
7110 let mut req_builder = hyper::Request::builder()
7111 .method(hyper::Method::POST)
7112 .uri(url.as_str())
7113 .header(USER_AGENT, self.hub._user_agent.clone());
7114
7115 if let Some(token) = token.as_ref() {
7116 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7117 }
7118
7119 let request = req_builder
7120 .header(CONTENT_TYPE, json_mime_type.to_string())
7121 .header(CONTENT_LENGTH, request_size as u64)
7122 .body(common::to_body(
7123 request_value_reader.get_ref().clone().into(),
7124 ));
7125
7126 client.request(request.unwrap()).await
7127 };
7128
7129 match req_result {
7130 Err(err) => {
7131 if let common::Retry::After(d) = dlg.http_error(&err) {
7132 sleep(d).await;
7133 continue;
7134 }
7135 dlg.finished(false);
7136 return Err(common::Error::HttpError(err));
7137 }
7138 Ok(res) => {
7139 let (mut parts, body) = res.into_parts();
7140 let mut body = common::Body::new(body);
7141 if !parts.status.is_success() {
7142 let bytes = common::to_bytes(body).await.unwrap_or_default();
7143 let error = serde_json::from_str(&common::to_string(&bytes));
7144 let response = common::to_response(parts, bytes.into());
7145
7146 if let common::Retry::After(d) =
7147 dlg.http_failure(&response, error.as_ref().ok())
7148 {
7149 sleep(d).await;
7150 continue;
7151 }
7152
7153 dlg.finished(false);
7154
7155 return Err(match error {
7156 Ok(value) => common::Error::BadRequest(value),
7157 _ => common::Error::Failure(response),
7158 });
7159 }
7160 let response = {
7161 let bytes = common::to_bytes(body).await.unwrap_or_default();
7162 let encoded = common::to_string(&bytes);
7163 match serde_json::from_str(&encoded) {
7164 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7165 Err(error) => {
7166 dlg.response_json_decode_error(&encoded, &error);
7167 return Err(common::Error::JsonDecodeError(
7168 encoded.to_string(),
7169 error,
7170 ));
7171 }
7172 }
7173 };
7174
7175 dlg.finished(true);
7176 return Ok(response);
7177 }
7178 }
7179 }
7180 }
7181
7182 ///
7183 /// Sets the *request* property to the given value.
7184 ///
7185 /// Even though the property as already been set when instantiating this call,
7186 /// we provide this method for API completeness.
7187 pub fn request(
7188 mut self,
7189 new_value: StartInstanceRequest,
7190 ) -> ProjectLocationInstanceStartCall<'a, C> {
7191 self._request = new_value;
7192 self
7193 }
7194 /// Required. Name of the resource.
7195 ///
7196 /// Sets the *name* path property to the given value.
7197 ///
7198 /// Even though the property as already been set when instantiating this call,
7199 /// we provide this method for API completeness.
7200 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceStartCall<'a, C> {
7201 self._name = new_value.to_string();
7202 self
7203 }
7204 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7205 /// while executing the actual API request.
7206 ///
7207 /// ````text
7208 /// It should be used to handle progress information, and to implement a certain level of resilience.
7209 /// ````
7210 ///
7211 /// Sets the *delegate* property to the given value.
7212 pub fn delegate(
7213 mut self,
7214 new_value: &'a mut dyn common::Delegate,
7215 ) -> ProjectLocationInstanceStartCall<'a, C> {
7216 self._delegate = Some(new_value);
7217 self
7218 }
7219
7220 /// Set any additional parameter of the query string used in the request.
7221 /// It should be used to set parameters which are not yet available through their own
7222 /// setters.
7223 ///
7224 /// Please note that this method must not be used to set any of the known parameters
7225 /// which have their own setter method. If done anyway, the request will fail.
7226 ///
7227 /// # Additional Parameters
7228 ///
7229 /// * *$.xgafv* (query-string) - V1 error format.
7230 /// * *access_token* (query-string) - OAuth access token.
7231 /// * *alt* (query-string) - Data format for response.
7232 /// * *callback* (query-string) - JSONP
7233 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7234 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7235 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7236 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7237 /// * *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.
7238 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7239 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7240 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceStartCall<'a, C>
7241 where
7242 T: AsRef<str>,
7243 {
7244 self._additional_params
7245 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7246 self
7247 }
7248
7249 /// Identifies the authorization scope for the method you are building.
7250 ///
7251 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7252 /// [`Scope::CloudPlatform`].
7253 ///
7254 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7255 /// tokens for more than one scope.
7256 ///
7257 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7258 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7259 /// sufficient, a read-write scope will do as well.
7260 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceStartCall<'a, C>
7261 where
7262 St: AsRef<str>,
7263 {
7264 self._scopes.insert(String::from(scope.as_ref()));
7265 self
7266 }
7267 /// Identifies the authorization scope(s) for the method you are building.
7268 ///
7269 /// See [`Self::add_scope()`] for details.
7270 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceStartCall<'a, C>
7271 where
7272 I: IntoIterator<Item = St>,
7273 St: AsRef<str>,
7274 {
7275 self._scopes
7276 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7277 self
7278 }
7279
7280 /// Removes all scopes, and no default scope will be used either.
7281 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7282 /// for details).
7283 pub fn clear_scopes(mut self) -> ProjectLocationInstanceStartCall<'a, C> {
7284 self._scopes.clear();
7285 self
7286 }
7287}
7288
7289/// Stop a running server.
7290///
7291/// A builder for the *locations.instances.stop* method supported by a *project* resource.
7292/// It is not used directly, but through a [`ProjectMethods`] instance.
7293///
7294/// # Example
7295///
7296/// Instantiate a resource method builder
7297///
7298/// ```test_harness,no_run
7299/// # extern crate hyper;
7300/// # extern crate hyper_rustls;
7301/// # extern crate google_baremetalsolution2 as baremetalsolution2;
7302/// use baremetalsolution2::api::StopInstanceRequest;
7303/// # async fn dox() {
7304/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7305///
7306/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7307/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7308/// # secret,
7309/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7310/// # ).build().await.unwrap();
7311///
7312/// # let client = hyper_util::client::legacy::Client::builder(
7313/// # hyper_util::rt::TokioExecutor::new()
7314/// # )
7315/// # .build(
7316/// # hyper_rustls::HttpsConnectorBuilder::new()
7317/// # .with_native_roots()
7318/// # .unwrap()
7319/// # .https_or_http()
7320/// # .enable_http1()
7321/// # .build()
7322/// # );
7323/// # let mut hub = Baremetalsolution::new(client, auth);
7324/// // As the method needs a request, you would usually fill it with the desired information
7325/// // into the respective structure. Some of the parts shown here might not be applicable !
7326/// // Values shown here are possibly random and not representative !
7327/// let mut req = StopInstanceRequest::default();
7328///
7329/// // You can configure optional parameters by calling the respective setters at will, and
7330/// // execute the final call using `doit()`.
7331/// // Values shown here are possibly random and not representative !
7332/// let result = hub.projects().locations_instances_stop(req, "name")
7333/// .doit().await;
7334/// # }
7335/// ```
7336pub struct ProjectLocationInstanceStopCall<'a, C>
7337where
7338 C: 'a,
7339{
7340 hub: &'a Baremetalsolution<C>,
7341 _request: StopInstanceRequest,
7342 _name: String,
7343 _delegate: Option<&'a mut dyn common::Delegate>,
7344 _additional_params: HashMap<String, String>,
7345 _scopes: BTreeSet<String>,
7346}
7347
7348impl<'a, C> common::CallBuilder for ProjectLocationInstanceStopCall<'a, C> {}
7349
7350impl<'a, C> ProjectLocationInstanceStopCall<'a, C>
7351where
7352 C: common::Connector,
7353{
7354 /// Perform the operation you have build so far.
7355 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7356 use std::borrow::Cow;
7357 use std::io::{Read, Seek};
7358
7359 use common::{url::Params, ToParts};
7360 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7361
7362 let mut dd = common::DefaultDelegate;
7363 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7364 dlg.begin(common::MethodInfo {
7365 id: "baremetalsolution.projects.locations.instances.stop",
7366 http_method: hyper::Method::POST,
7367 });
7368
7369 for &field in ["alt", "name"].iter() {
7370 if self._additional_params.contains_key(field) {
7371 dlg.finished(false);
7372 return Err(common::Error::FieldClash(field));
7373 }
7374 }
7375
7376 let mut params = Params::with_capacity(4 + self._additional_params.len());
7377 params.push("name", self._name);
7378
7379 params.extend(self._additional_params.iter());
7380
7381 params.push("alt", "json");
7382 let mut url = self.hub._base_url.clone() + "v2/{+name}:stop";
7383 if self._scopes.is_empty() {
7384 self._scopes
7385 .insert(Scope::CloudPlatform.as_ref().to_string());
7386 }
7387
7388 #[allow(clippy::single_element_loop)]
7389 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7390 url = params.uri_replacement(url, param_name, find_this, true);
7391 }
7392 {
7393 let to_remove = ["name"];
7394 params.remove_params(&to_remove);
7395 }
7396
7397 let url = params.parse_with_url(&url);
7398
7399 let mut json_mime_type = mime::APPLICATION_JSON;
7400 let mut request_value_reader = {
7401 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7402 common::remove_json_null_values(&mut value);
7403 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7404 serde_json::to_writer(&mut dst, &value).unwrap();
7405 dst
7406 };
7407 let request_size = request_value_reader
7408 .seek(std::io::SeekFrom::End(0))
7409 .unwrap();
7410 request_value_reader
7411 .seek(std::io::SeekFrom::Start(0))
7412 .unwrap();
7413
7414 loop {
7415 let token = match self
7416 .hub
7417 .auth
7418 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7419 .await
7420 {
7421 Ok(token) => token,
7422 Err(e) => match dlg.token(e) {
7423 Ok(token) => token,
7424 Err(e) => {
7425 dlg.finished(false);
7426 return Err(common::Error::MissingToken(e));
7427 }
7428 },
7429 };
7430 request_value_reader
7431 .seek(std::io::SeekFrom::Start(0))
7432 .unwrap();
7433 let mut req_result = {
7434 let client = &self.hub.client;
7435 dlg.pre_request();
7436 let mut req_builder = hyper::Request::builder()
7437 .method(hyper::Method::POST)
7438 .uri(url.as_str())
7439 .header(USER_AGENT, self.hub._user_agent.clone());
7440
7441 if let Some(token) = token.as_ref() {
7442 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7443 }
7444
7445 let request = req_builder
7446 .header(CONTENT_TYPE, json_mime_type.to_string())
7447 .header(CONTENT_LENGTH, request_size as u64)
7448 .body(common::to_body(
7449 request_value_reader.get_ref().clone().into(),
7450 ));
7451
7452 client.request(request.unwrap()).await
7453 };
7454
7455 match req_result {
7456 Err(err) => {
7457 if let common::Retry::After(d) = dlg.http_error(&err) {
7458 sleep(d).await;
7459 continue;
7460 }
7461 dlg.finished(false);
7462 return Err(common::Error::HttpError(err));
7463 }
7464 Ok(res) => {
7465 let (mut parts, body) = res.into_parts();
7466 let mut body = common::Body::new(body);
7467 if !parts.status.is_success() {
7468 let bytes = common::to_bytes(body).await.unwrap_or_default();
7469 let error = serde_json::from_str(&common::to_string(&bytes));
7470 let response = common::to_response(parts, bytes.into());
7471
7472 if let common::Retry::After(d) =
7473 dlg.http_failure(&response, error.as_ref().ok())
7474 {
7475 sleep(d).await;
7476 continue;
7477 }
7478
7479 dlg.finished(false);
7480
7481 return Err(match error {
7482 Ok(value) => common::Error::BadRequest(value),
7483 _ => common::Error::Failure(response),
7484 });
7485 }
7486 let response = {
7487 let bytes = common::to_bytes(body).await.unwrap_or_default();
7488 let encoded = common::to_string(&bytes);
7489 match serde_json::from_str(&encoded) {
7490 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7491 Err(error) => {
7492 dlg.response_json_decode_error(&encoded, &error);
7493 return Err(common::Error::JsonDecodeError(
7494 encoded.to_string(),
7495 error,
7496 ));
7497 }
7498 }
7499 };
7500
7501 dlg.finished(true);
7502 return Ok(response);
7503 }
7504 }
7505 }
7506 }
7507
7508 ///
7509 /// Sets the *request* property to the given value.
7510 ///
7511 /// Even though the property as already been set when instantiating this call,
7512 /// we provide this method for API completeness.
7513 pub fn request(
7514 mut self,
7515 new_value: StopInstanceRequest,
7516 ) -> ProjectLocationInstanceStopCall<'a, C> {
7517 self._request = new_value;
7518 self
7519 }
7520 /// Required. Name of the resource.
7521 ///
7522 /// Sets the *name* path property to the given value.
7523 ///
7524 /// Even though the property as already been set when instantiating this call,
7525 /// we provide this method for API completeness.
7526 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceStopCall<'a, C> {
7527 self._name = new_value.to_string();
7528 self
7529 }
7530 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7531 /// while executing the actual API request.
7532 ///
7533 /// ````text
7534 /// It should be used to handle progress information, and to implement a certain level of resilience.
7535 /// ````
7536 ///
7537 /// Sets the *delegate* property to the given value.
7538 pub fn delegate(
7539 mut self,
7540 new_value: &'a mut dyn common::Delegate,
7541 ) -> ProjectLocationInstanceStopCall<'a, C> {
7542 self._delegate = Some(new_value);
7543 self
7544 }
7545
7546 /// Set any additional parameter of the query string used in the request.
7547 /// It should be used to set parameters which are not yet available through their own
7548 /// setters.
7549 ///
7550 /// Please note that this method must not be used to set any of the known parameters
7551 /// which have their own setter method. If done anyway, the request will fail.
7552 ///
7553 /// # Additional Parameters
7554 ///
7555 /// * *$.xgafv* (query-string) - V1 error format.
7556 /// * *access_token* (query-string) - OAuth access token.
7557 /// * *alt* (query-string) - Data format for response.
7558 /// * *callback* (query-string) - JSONP
7559 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7560 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7561 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7562 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7563 /// * *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.
7564 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7565 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7566 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceStopCall<'a, C>
7567 where
7568 T: AsRef<str>,
7569 {
7570 self._additional_params
7571 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7572 self
7573 }
7574
7575 /// Identifies the authorization scope for the method you are building.
7576 ///
7577 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7578 /// [`Scope::CloudPlatform`].
7579 ///
7580 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7581 /// tokens for more than one scope.
7582 ///
7583 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7584 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7585 /// sufficient, a read-write scope will do as well.
7586 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceStopCall<'a, C>
7587 where
7588 St: AsRef<str>,
7589 {
7590 self._scopes.insert(String::from(scope.as_ref()));
7591 self
7592 }
7593 /// Identifies the authorization scope(s) for the method you are building.
7594 ///
7595 /// See [`Self::add_scope()`] for details.
7596 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceStopCall<'a, C>
7597 where
7598 I: IntoIterator<Item = St>,
7599 St: AsRef<str>,
7600 {
7601 self._scopes
7602 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7603 self
7604 }
7605
7606 /// Removes all scopes, and no default scope will be used either.
7607 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7608 /// for details).
7609 pub fn clear_scopes(mut self) -> ProjectLocationInstanceStopCall<'a, C> {
7610 self._scopes.clear();
7611 self
7612 }
7613}
7614
7615/// Get details of a single network.
7616///
7617/// A builder for the *locations.networks.get* method supported by a *project* resource.
7618/// It is not used directly, but through a [`ProjectMethods`] instance.
7619///
7620/// # Example
7621///
7622/// Instantiate a resource method builder
7623///
7624/// ```test_harness,no_run
7625/// # extern crate hyper;
7626/// # extern crate hyper_rustls;
7627/// # extern crate google_baremetalsolution2 as baremetalsolution2;
7628/// # async fn dox() {
7629/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7630///
7631/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7632/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7633/// # secret,
7634/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7635/// # ).build().await.unwrap();
7636///
7637/// # let client = hyper_util::client::legacy::Client::builder(
7638/// # hyper_util::rt::TokioExecutor::new()
7639/// # )
7640/// # .build(
7641/// # hyper_rustls::HttpsConnectorBuilder::new()
7642/// # .with_native_roots()
7643/// # .unwrap()
7644/// # .https_or_http()
7645/// # .enable_http1()
7646/// # .build()
7647/// # );
7648/// # let mut hub = Baremetalsolution::new(client, auth);
7649/// // You can configure optional parameters by calling the respective setters at will, and
7650/// // execute the final call using `doit()`.
7651/// // Values shown here are possibly random and not representative !
7652/// let result = hub.projects().locations_networks_get("name")
7653/// .doit().await;
7654/// # }
7655/// ```
7656pub struct ProjectLocationNetworkGetCall<'a, C>
7657where
7658 C: 'a,
7659{
7660 hub: &'a Baremetalsolution<C>,
7661 _name: String,
7662 _delegate: Option<&'a mut dyn common::Delegate>,
7663 _additional_params: HashMap<String, String>,
7664 _scopes: BTreeSet<String>,
7665}
7666
7667impl<'a, C> common::CallBuilder for ProjectLocationNetworkGetCall<'a, C> {}
7668
7669impl<'a, C> ProjectLocationNetworkGetCall<'a, C>
7670where
7671 C: common::Connector,
7672{
7673 /// Perform the operation you have build so far.
7674 pub async fn doit(mut self) -> common::Result<(common::Response, Network)> {
7675 use std::borrow::Cow;
7676 use std::io::{Read, Seek};
7677
7678 use common::{url::Params, ToParts};
7679 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7680
7681 let mut dd = common::DefaultDelegate;
7682 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7683 dlg.begin(common::MethodInfo {
7684 id: "baremetalsolution.projects.locations.networks.get",
7685 http_method: hyper::Method::GET,
7686 });
7687
7688 for &field in ["alt", "name"].iter() {
7689 if self._additional_params.contains_key(field) {
7690 dlg.finished(false);
7691 return Err(common::Error::FieldClash(field));
7692 }
7693 }
7694
7695 let mut params = Params::with_capacity(3 + self._additional_params.len());
7696 params.push("name", self._name);
7697
7698 params.extend(self._additional_params.iter());
7699
7700 params.push("alt", "json");
7701 let mut url = self.hub._base_url.clone() + "v2/{+name}";
7702 if self._scopes.is_empty() {
7703 self._scopes
7704 .insert(Scope::CloudPlatform.as_ref().to_string());
7705 }
7706
7707 #[allow(clippy::single_element_loop)]
7708 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7709 url = params.uri_replacement(url, param_name, find_this, true);
7710 }
7711 {
7712 let to_remove = ["name"];
7713 params.remove_params(&to_remove);
7714 }
7715
7716 let url = params.parse_with_url(&url);
7717
7718 loop {
7719 let token = match self
7720 .hub
7721 .auth
7722 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7723 .await
7724 {
7725 Ok(token) => token,
7726 Err(e) => match dlg.token(e) {
7727 Ok(token) => token,
7728 Err(e) => {
7729 dlg.finished(false);
7730 return Err(common::Error::MissingToken(e));
7731 }
7732 },
7733 };
7734 let mut req_result = {
7735 let client = &self.hub.client;
7736 dlg.pre_request();
7737 let mut req_builder = hyper::Request::builder()
7738 .method(hyper::Method::GET)
7739 .uri(url.as_str())
7740 .header(USER_AGENT, self.hub._user_agent.clone());
7741
7742 if let Some(token) = token.as_ref() {
7743 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7744 }
7745
7746 let request = req_builder
7747 .header(CONTENT_LENGTH, 0_u64)
7748 .body(common::to_body::<String>(None));
7749
7750 client.request(request.unwrap()).await
7751 };
7752
7753 match req_result {
7754 Err(err) => {
7755 if let common::Retry::After(d) = dlg.http_error(&err) {
7756 sleep(d).await;
7757 continue;
7758 }
7759 dlg.finished(false);
7760 return Err(common::Error::HttpError(err));
7761 }
7762 Ok(res) => {
7763 let (mut parts, body) = res.into_parts();
7764 let mut body = common::Body::new(body);
7765 if !parts.status.is_success() {
7766 let bytes = common::to_bytes(body).await.unwrap_or_default();
7767 let error = serde_json::from_str(&common::to_string(&bytes));
7768 let response = common::to_response(parts, bytes.into());
7769
7770 if let common::Retry::After(d) =
7771 dlg.http_failure(&response, error.as_ref().ok())
7772 {
7773 sleep(d).await;
7774 continue;
7775 }
7776
7777 dlg.finished(false);
7778
7779 return Err(match error {
7780 Ok(value) => common::Error::BadRequest(value),
7781 _ => common::Error::Failure(response),
7782 });
7783 }
7784 let response = {
7785 let bytes = common::to_bytes(body).await.unwrap_or_default();
7786 let encoded = common::to_string(&bytes);
7787 match serde_json::from_str(&encoded) {
7788 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7789 Err(error) => {
7790 dlg.response_json_decode_error(&encoded, &error);
7791 return Err(common::Error::JsonDecodeError(
7792 encoded.to_string(),
7793 error,
7794 ));
7795 }
7796 }
7797 };
7798
7799 dlg.finished(true);
7800 return Ok(response);
7801 }
7802 }
7803 }
7804 }
7805
7806 /// Required. Name of the resource.
7807 ///
7808 /// Sets the *name* path property to the given value.
7809 ///
7810 /// Even though the property as already been set when instantiating this call,
7811 /// we provide this method for API completeness.
7812 pub fn name(mut self, new_value: &str) -> ProjectLocationNetworkGetCall<'a, C> {
7813 self._name = new_value.to_string();
7814 self
7815 }
7816 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7817 /// while executing the actual API request.
7818 ///
7819 /// ````text
7820 /// It should be used to handle progress information, and to implement a certain level of resilience.
7821 /// ````
7822 ///
7823 /// Sets the *delegate* property to the given value.
7824 pub fn delegate(
7825 mut self,
7826 new_value: &'a mut dyn common::Delegate,
7827 ) -> ProjectLocationNetworkGetCall<'a, C> {
7828 self._delegate = Some(new_value);
7829 self
7830 }
7831
7832 /// Set any additional parameter of the query string used in the request.
7833 /// It should be used to set parameters which are not yet available through their own
7834 /// setters.
7835 ///
7836 /// Please note that this method must not be used to set any of the known parameters
7837 /// which have their own setter method. If done anyway, the request will fail.
7838 ///
7839 /// # Additional Parameters
7840 ///
7841 /// * *$.xgafv* (query-string) - V1 error format.
7842 /// * *access_token* (query-string) - OAuth access token.
7843 /// * *alt* (query-string) - Data format for response.
7844 /// * *callback* (query-string) - JSONP
7845 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7846 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7847 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7848 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7849 /// * *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.
7850 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7851 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7852 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNetworkGetCall<'a, C>
7853 where
7854 T: AsRef<str>,
7855 {
7856 self._additional_params
7857 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7858 self
7859 }
7860
7861 /// Identifies the authorization scope for the method you are building.
7862 ///
7863 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7864 /// [`Scope::CloudPlatform`].
7865 ///
7866 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7867 /// tokens for more than one scope.
7868 ///
7869 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7870 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7871 /// sufficient, a read-write scope will do as well.
7872 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNetworkGetCall<'a, C>
7873 where
7874 St: AsRef<str>,
7875 {
7876 self._scopes.insert(String::from(scope.as_ref()));
7877 self
7878 }
7879 /// Identifies the authorization scope(s) for the method you are building.
7880 ///
7881 /// See [`Self::add_scope()`] for details.
7882 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNetworkGetCall<'a, C>
7883 where
7884 I: IntoIterator<Item = St>,
7885 St: AsRef<str>,
7886 {
7887 self._scopes
7888 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7889 self
7890 }
7891
7892 /// Removes all scopes, and no default scope will be used either.
7893 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7894 /// for details).
7895 pub fn clear_scopes(mut self) -> ProjectLocationNetworkGetCall<'a, C> {
7896 self._scopes.clear();
7897 self
7898 }
7899}
7900
7901/// List network in a given project and location.
7902///
7903/// A builder for the *locations.networks.list* method supported by a *project* resource.
7904/// It is not used directly, but through a [`ProjectMethods`] instance.
7905///
7906/// # Example
7907///
7908/// Instantiate a resource method builder
7909///
7910/// ```test_harness,no_run
7911/// # extern crate hyper;
7912/// # extern crate hyper_rustls;
7913/// # extern crate google_baremetalsolution2 as baremetalsolution2;
7914/// # async fn dox() {
7915/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7916///
7917/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7918/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7919/// # secret,
7920/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7921/// # ).build().await.unwrap();
7922///
7923/// # let client = hyper_util::client::legacy::Client::builder(
7924/// # hyper_util::rt::TokioExecutor::new()
7925/// # )
7926/// # .build(
7927/// # hyper_rustls::HttpsConnectorBuilder::new()
7928/// # .with_native_roots()
7929/// # .unwrap()
7930/// # .https_or_http()
7931/// # .enable_http1()
7932/// # .build()
7933/// # );
7934/// # let mut hub = Baremetalsolution::new(client, auth);
7935/// // You can configure optional parameters by calling the respective setters at will, and
7936/// // execute the final call using `doit()`.
7937/// // Values shown here are possibly random and not representative !
7938/// let result = hub.projects().locations_networks_list("parent")
7939/// .page_token("duo")
7940/// .page_size(-50)
7941/// .filter("sed")
7942/// .doit().await;
7943/// # }
7944/// ```
7945pub struct ProjectLocationNetworkListCall<'a, C>
7946where
7947 C: 'a,
7948{
7949 hub: &'a Baremetalsolution<C>,
7950 _parent: String,
7951 _page_token: Option<String>,
7952 _page_size: Option<i32>,
7953 _filter: Option<String>,
7954 _delegate: Option<&'a mut dyn common::Delegate>,
7955 _additional_params: HashMap<String, String>,
7956 _scopes: BTreeSet<String>,
7957}
7958
7959impl<'a, C> common::CallBuilder for ProjectLocationNetworkListCall<'a, C> {}
7960
7961impl<'a, C> ProjectLocationNetworkListCall<'a, C>
7962where
7963 C: common::Connector,
7964{
7965 /// Perform the operation you have build so far.
7966 pub async fn doit(mut self) -> common::Result<(common::Response, ListNetworksResponse)> {
7967 use std::borrow::Cow;
7968 use std::io::{Read, Seek};
7969
7970 use common::{url::Params, ToParts};
7971 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7972
7973 let mut dd = common::DefaultDelegate;
7974 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7975 dlg.begin(common::MethodInfo {
7976 id: "baremetalsolution.projects.locations.networks.list",
7977 http_method: hyper::Method::GET,
7978 });
7979
7980 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
7981 if self._additional_params.contains_key(field) {
7982 dlg.finished(false);
7983 return Err(common::Error::FieldClash(field));
7984 }
7985 }
7986
7987 let mut params = Params::with_capacity(6 + self._additional_params.len());
7988 params.push("parent", self._parent);
7989 if let Some(value) = self._page_token.as_ref() {
7990 params.push("pageToken", value);
7991 }
7992 if let Some(value) = self._page_size.as_ref() {
7993 params.push("pageSize", value.to_string());
7994 }
7995 if let Some(value) = self._filter.as_ref() {
7996 params.push("filter", value);
7997 }
7998
7999 params.extend(self._additional_params.iter());
8000
8001 params.push("alt", "json");
8002 let mut url = self.hub._base_url.clone() + "v2/{+parent}/networks";
8003 if self._scopes.is_empty() {
8004 self._scopes
8005 .insert(Scope::CloudPlatform.as_ref().to_string());
8006 }
8007
8008 #[allow(clippy::single_element_loop)]
8009 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8010 url = params.uri_replacement(url, param_name, find_this, true);
8011 }
8012 {
8013 let to_remove = ["parent"];
8014 params.remove_params(&to_remove);
8015 }
8016
8017 let url = params.parse_with_url(&url);
8018
8019 loop {
8020 let token = match self
8021 .hub
8022 .auth
8023 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8024 .await
8025 {
8026 Ok(token) => token,
8027 Err(e) => match dlg.token(e) {
8028 Ok(token) => token,
8029 Err(e) => {
8030 dlg.finished(false);
8031 return Err(common::Error::MissingToken(e));
8032 }
8033 },
8034 };
8035 let mut req_result = {
8036 let client = &self.hub.client;
8037 dlg.pre_request();
8038 let mut req_builder = hyper::Request::builder()
8039 .method(hyper::Method::GET)
8040 .uri(url.as_str())
8041 .header(USER_AGENT, self.hub._user_agent.clone());
8042
8043 if let Some(token) = token.as_ref() {
8044 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8045 }
8046
8047 let request = req_builder
8048 .header(CONTENT_LENGTH, 0_u64)
8049 .body(common::to_body::<String>(None));
8050
8051 client.request(request.unwrap()).await
8052 };
8053
8054 match req_result {
8055 Err(err) => {
8056 if let common::Retry::After(d) = dlg.http_error(&err) {
8057 sleep(d).await;
8058 continue;
8059 }
8060 dlg.finished(false);
8061 return Err(common::Error::HttpError(err));
8062 }
8063 Ok(res) => {
8064 let (mut parts, body) = res.into_parts();
8065 let mut body = common::Body::new(body);
8066 if !parts.status.is_success() {
8067 let bytes = common::to_bytes(body).await.unwrap_or_default();
8068 let error = serde_json::from_str(&common::to_string(&bytes));
8069 let response = common::to_response(parts, bytes.into());
8070
8071 if let common::Retry::After(d) =
8072 dlg.http_failure(&response, error.as_ref().ok())
8073 {
8074 sleep(d).await;
8075 continue;
8076 }
8077
8078 dlg.finished(false);
8079
8080 return Err(match error {
8081 Ok(value) => common::Error::BadRequest(value),
8082 _ => common::Error::Failure(response),
8083 });
8084 }
8085 let response = {
8086 let bytes = common::to_bytes(body).await.unwrap_or_default();
8087 let encoded = common::to_string(&bytes);
8088 match serde_json::from_str(&encoded) {
8089 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8090 Err(error) => {
8091 dlg.response_json_decode_error(&encoded, &error);
8092 return Err(common::Error::JsonDecodeError(
8093 encoded.to_string(),
8094 error,
8095 ));
8096 }
8097 }
8098 };
8099
8100 dlg.finished(true);
8101 return Ok(response);
8102 }
8103 }
8104 }
8105 }
8106
8107 /// Required. Parent value for ListNetworksRequest.
8108 ///
8109 /// Sets the *parent* path property to the given value.
8110 ///
8111 /// Even though the property as already been set when instantiating this call,
8112 /// we provide this method for API completeness.
8113 pub fn parent(mut self, new_value: &str) -> ProjectLocationNetworkListCall<'a, C> {
8114 self._parent = new_value.to_string();
8115 self
8116 }
8117 /// A token identifying a page of results from the server.
8118 ///
8119 /// Sets the *page token* query property to the given value.
8120 pub fn page_token(mut self, new_value: &str) -> ProjectLocationNetworkListCall<'a, C> {
8121 self._page_token = Some(new_value.to_string());
8122 self
8123 }
8124 /// Requested page size. The server might return fewer items than requested. If unspecified, server will pick an appropriate default.
8125 ///
8126 /// Sets the *page size* query property to the given value.
8127 pub fn page_size(mut self, new_value: i32) -> ProjectLocationNetworkListCall<'a, C> {
8128 self._page_size = Some(new_value);
8129 self
8130 }
8131 /// List filter.
8132 ///
8133 /// Sets the *filter* query property to the given value.
8134 pub fn filter(mut self, new_value: &str) -> ProjectLocationNetworkListCall<'a, C> {
8135 self._filter = Some(new_value.to_string());
8136 self
8137 }
8138 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8139 /// while executing the actual API request.
8140 ///
8141 /// ````text
8142 /// It should be used to handle progress information, and to implement a certain level of resilience.
8143 /// ````
8144 ///
8145 /// Sets the *delegate* property to the given value.
8146 pub fn delegate(
8147 mut self,
8148 new_value: &'a mut dyn common::Delegate,
8149 ) -> ProjectLocationNetworkListCall<'a, C> {
8150 self._delegate = Some(new_value);
8151 self
8152 }
8153
8154 /// Set any additional parameter of the query string used in the request.
8155 /// It should be used to set parameters which are not yet available through their own
8156 /// setters.
8157 ///
8158 /// Please note that this method must not be used to set any of the known parameters
8159 /// which have their own setter method. If done anyway, the request will fail.
8160 ///
8161 /// # Additional Parameters
8162 ///
8163 /// * *$.xgafv* (query-string) - V1 error format.
8164 /// * *access_token* (query-string) - OAuth access token.
8165 /// * *alt* (query-string) - Data format for response.
8166 /// * *callback* (query-string) - JSONP
8167 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8168 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8169 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8170 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8171 /// * *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.
8172 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8173 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8174 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNetworkListCall<'a, C>
8175 where
8176 T: AsRef<str>,
8177 {
8178 self._additional_params
8179 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8180 self
8181 }
8182
8183 /// Identifies the authorization scope for the method you are building.
8184 ///
8185 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8186 /// [`Scope::CloudPlatform`].
8187 ///
8188 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8189 /// tokens for more than one scope.
8190 ///
8191 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8192 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8193 /// sufficient, a read-write scope will do as well.
8194 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNetworkListCall<'a, C>
8195 where
8196 St: AsRef<str>,
8197 {
8198 self._scopes.insert(String::from(scope.as_ref()));
8199 self
8200 }
8201 /// Identifies the authorization scope(s) for the method you are building.
8202 ///
8203 /// See [`Self::add_scope()`] for details.
8204 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNetworkListCall<'a, C>
8205 where
8206 I: IntoIterator<Item = St>,
8207 St: AsRef<str>,
8208 {
8209 self._scopes
8210 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8211 self
8212 }
8213
8214 /// Removes all scopes, and no default scope will be used either.
8215 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8216 /// for details).
8217 pub fn clear_scopes(mut self) -> ProjectLocationNetworkListCall<'a, C> {
8218 self._scopes.clear();
8219 self
8220 }
8221}
8222
8223/// List all Networks (and used IPs for each Network) in the vendor account associated with the specified project.
8224///
8225/// A builder for the *locations.networks.listNetworkUsage* method supported by a *project* resource.
8226/// It is not used directly, but through a [`ProjectMethods`] instance.
8227///
8228/// # Example
8229///
8230/// Instantiate a resource method builder
8231///
8232/// ```test_harness,no_run
8233/// # extern crate hyper;
8234/// # extern crate hyper_rustls;
8235/// # extern crate google_baremetalsolution2 as baremetalsolution2;
8236/// # async fn dox() {
8237/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8238///
8239/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8240/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8241/// # secret,
8242/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8243/// # ).build().await.unwrap();
8244///
8245/// # let client = hyper_util::client::legacy::Client::builder(
8246/// # hyper_util::rt::TokioExecutor::new()
8247/// # )
8248/// # .build(
8249/// # hyper_rustls::HttpsConnectorBuilder::new()
8250/// # .with_native_roots()
8251/// # .unwrap()
8252/// # .https_or_http()
8253/// # .enable_http1()
8254/// # .build()
8255/// # );
8256/// # let mut hub = Baremetalsolution::new(client, auth);
8257/// // You can configure optional parameters by calling the respective setters at will, and
8258/// // execute the final call using `doit()`.
8259/// // Values shown here are possibly random and not representative !
8260/// let result = hub.projects().locations_networks_list_network_usage("location")
8261/// .doit().await;
8262/// # }
8263/// ```
8264pub struct ProjectLocationNetworkListNetworkUsageCall<'a, C>
8265where
8266 C: 'a,
8267{
8268 hub: &'a Baremetalsolution<C>,
8269 _location: String,
8270 _delegate: Option<&'a mut dyn common::Delegate>,
8271 _additional_params: HashMap<String, String>,
8272 _scopes: BTreeSet<String>,
8273}
8274
8275impl<'a, C> common::CallBuilder for ProjectLocationNetworkListNetworkUsageCall<'a, C> {}
8276
8277impl<'a, C> ProjectLocationNetworkListNetworkUsageCall<'a, C>
8278where
8279 C: common::Connector,
8280{
8281 /// Perform the operation you have build so far.
8282 pub async fn doit(mut self) -> common::Result<(common::Response, ListNetworkUsageResponse)> {
8283 use std::borrow::Cow;
8284 use std::io::{Read, Seek};
8285
8286 use common::{url::Params, ToParts};
8287 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8288
8289 let mut dd = common::DefaultDelegate;
8290 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8291 dlg.begin(common::MethodInfo {
8292 id: "baremetalsolution.projects.locations.networks.listNetworkUsage",
8293 http_method: hyper::Method::GET,
8294 });
8295
8296 for &field in ["alt", "location"].iter() {
8297 if self._additional_params.contains_key(field) {
8298 dlg.finished(false);
8299 return Err(common::Error::FieldClash(field));
8300 }
8301 }
8302
8303 let mut params = Params::with_capacity(3 + self._additional_params.len());
8304 params.push("location", self._location);
8305
8306 params.extend(self._additional_params.iter());
8307
8308 params.push("alt", "json");
8309 let mut url = self.hub._base_url.clone() + "v2/{+location}/networks:listNetworkUsage";
8310 if self._scopes.is_empty() {
8311 self._scopes
8312 .insert(Scope::CloudPlatform.as_ref().to_string());
8313 }
8314
8315 #[allow(clippy::single_element_loop)]
8316 for &(find_this, param_name) in [("{+location}", "location")].iter() {
8317 url = params.uri_replacement(url, param_name, find_this, true);
8318 }
8319 {
8320 let to_remove = ["location"];
8321 params.remove_params(&to_remove);
8322 }
8323
8324 let url = params.parse_with_url(&url);
8325
8326 loop {
8327 let token = match self
8328 .hub
8329 .auth
8330 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8331 .await
8332 {
8333 Ok(token) => token,
8334 Err(e) => match dlg.token(e) {
8335 Ok(token) => token,
8336 Err(e) => {
8337 dlg.finished(false);
8338 return Err(common::Error::MissingToken(e));
8339 }
8340 },
8341 };
8342 let mut req_result = {
8343 let client = &self.hub.client;
8344 dlg.pre_request();
8345 let mut req_builder = hyper::Request::builder()
8346 .method(hyper::Method::GET)
8347 .uri(url.as_str())
8348 .header(USER_AGENT, self.hub._user_agent.clone());
8349
8350 if let Some(token) = token.as_ref() {
8351 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8352 }
8353
8354 let request = req_builder
8355 .header(CONTENT_LENGTH, 0_u64)
8356 .body(common::to_body::<String>(None));
8357
8358 client.request(request.unwrap()).await
8359 };
8360
8361 match req_result {
8362 Err(err) => {
8363 if let common::Retry::After(d) = dlg.http_error(&err) {
8364 sleep(d).await;
8365 continue;
8366 }
8367 dlg.finished(false);
8368 return Err(common::Error::HttpError(err));
8369 }
8370 Ok(res) => {
8371 let (mut parts, body) = res.into_parts();
8372 let mut body = common::Body::new(body);
8373 if !parts.status.is_success() {
8374 let bytes = common::to_bytes(body).await.unwrap_or_default();
8375 let error = serde_json::from_str(&common::to_string(&bytes));
8376 let response = common::to_response(parts, bytes.into());
8377
8378 if let common::Retry::After(d) =
8379 dlg.http_failure(&response, error.as_ref().ok())
8380 {
8381 sleep(d).await;
8382 continue;
8383 }
8384
8385 dlg.finished(false);
8386
8387 return Err(match error {
8388 Ok(value) => common::Error::BadRequest(value),
8389 _ => common::Error::Failure(response),
8390 });
8391 }
8392 let response = {
8393 let bytes = common::to_bytes(body).await.unwrap_or_default();
8394 let encoded = common::to_string(&bytes);
8395 match serde_json::from_str(&encoded) {
8396 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8397 Err(error) => {
8398 dlg.response_json_decode_error(&encoded, &error);
8399 return Err(common::Error::JsonDecodeError(
8400 encoded.to_string(),
8401 error,
8402 ));
8403 }
8404 }
8405 };
8406
8407 dlg.finished(true);
8408 return Ok(response);
8409 }
8410 }
8411 }
8412 }
8413
8414 /// Required. Parent value (project and location).
8415 ///
8416 /// Sets the *location* path property to the given value.
8417 ///
8418 /// Even though the property as already been set when instantiating this call,
8419 /// we provide this method for API completeness.
8420 pub fn location(
8421 mut self,
8422 new_value: &str,
8423 ) -> ProjectLocationNetworkListNetworkUsageCall<'a, C> {
8424 self._location = new_value.to_string();
8425 self
8426 }
8427 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8428 /// while executing the actual API request.
8429 ///
8430 /// ````text
8431 /// It should be used to handle progress information, and to implement a certain level of resilience.
8432 /// ````
8433 ///
8434 /// Sets the *delegate* property to the given value.
8435 pub fn delegate(
8436 mut self,
8437 new_value: &'a mut dyn common::Delegate,
8438 ) -> ProjectLocationNetworkListNetworkUsageCall<'a, C> {
8439 self._delegate = Some(new_value);
8440 self
8441 }
8442
8443 /// Set any additional parameter of the query string used in the request.
8444 /// It should be used to set parameters which are not yet available through their own
8445 /// setters.
8446 ///
8447 /// Please note that this method must not be used to set any of the known parameters
8448 /// which have their own setter method. If done anyway, the request will fail.
8449 ///
8450 /// # Additional Parameters
8451 ///
8452 /// * *$.xgafv* (query-string) - V1 error format.
8453 /// * *access_token* (query-string) - OAuth access token.
8454 /// * *alt* (query-string) - Data format for response.
8455 /// * *callback* (query-string) - JSONP
8456 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8457 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8458 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8459 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8460 /// * *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.
8461 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8462 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8463 pub fn param<T>(
8464 mut self,
8465 name: T,
8466 value: T,
8467 ) -> ProjectLocationNetworkListNetworkUsageCall<'a, C>
8468 where
8469 T: AsRef<str>,
8470 {
8471 self._additional_params
8472 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8473 self
8474 }
8475
8476 /// Identifies the authorization scope for the method you are building.
8477 ///
8478 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8479 /// [`Scope::CloudPlatform`].
8480 ///
8481 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8482 /// tokens for more than one scope.
8483 ///
8484 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8485 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8486 /// sufficient, a read-write scope will do as well.
8487 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNetworkListNetworkUsageCall<'a, C>
8488 where
8489 St: AsRef<str>,
8490 {
8491 self._scopes.insert(String::from(scope.as_ref()));
8492 self
8493 }
8494 /// Identifies the authorization scope(s) for the method you are building.
8495 ///
8496 /// See [`Self::add_scope()`] for details.
8497 pub fn add_scopes<I, St>(
8498 mut self,
8499 scopes: I,
8500 ) -> ProjectLocationNetworkListNetworkUsageCall<'a, C>
8501 where
8502 I: IntoIterator<Item = St>,
8503 St: AsRef<str>,
8504 {
8505 self._scopes
8506 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8507 self
8508 }
8509
8510 /// Removes all scopes, and no default scope will be used either.
8511 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8512 /// for details).
8513 pub fn clear_scopes(mut self) -> ProjectLocationNetworkListNetworkUsageCall<'a, C> {
8514 self._scopes.clear();
8515 self
8516 }
8517}
8518
8519/// Update details of a single network.
8520///
8521/// A builder for the *locations.networks.patch* method supported by a *project* resource.
8522/// It is not used directly, but through a [`ProjectMethods`] instance.
8523///
8524/// # Example
8525///
8526/// Instantiate a resource method builder
8527///
8528/// ```test_harness,no_run
8529/// # extern crate hyper;
8530/// # extern crate hyper_rustls;
8531/// # extern crate google_baremetalsolution2 as baremetalsolution2;
8532/// use baremetalsolution2::api::Network;
8533/// # async fn dox() {
8534/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8535///
8536/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8537/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8538/// # secret,
8539/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8540/// # ).build().await.unwrap();
8541///
8542/// # let client = hyper_util::client::legacy::Client::builder(
8543/// # hyper_util::rt::TokioExecutor::new()
8544/// # )
8545/// # .build(
8546/// # hyper_rustls::HttpsConnectorBuilder::new()
8547/// # .with_native_roots()
8548/// # .unwrap()
8549/// # .https_or_http()
8550/// # .enable_http1()
8551/// # .build()
8552/// # );
8553/// # let mut hub = Baremetalsolution::new(client, auth);
8554/// // As the method needs a request, you would usually fill it with the desired information
8555/// // into the respective structure. Some of the parts shown here might not be applicable !
8556/// // Values shown here are possibly random and not representative !
8557/// let mut req = Network::default();
8558///
8559/// // You can configure optional parameters by calling the respective setters at will, and
8560/// // execute the final call using `doit()`.
8561/// // Values shown here are possibly random and not representative !
8562/// let result = hub.projects().locations_networks_patch(req, "name")
8563/// .update_mask(FieldMask::new::<&str>(&[]))
8564/// .doit().await;
8565/// # }
8566/// ```
8567pub struct ProjectLocationNetworkPatchCall<'a, C>
8568where
8569 C: 'a,
8570{
8571 hub: &'a Baremetalsolution<C>,
8572 _request: Network,
8573 _name: String,
8574 _update_mask: Option<common::FieldMask>,
8575 _delegate: Option<&'a mut dyn common::Delegate>,
8576 _additional_params: HashMap<String, String>,
8577 _scopes: BTreeSet<String>,
8578}
8579
8580impl<'a, C> common::CallBuilder for ProjectLocationNetworkPatchCall<'a, C> {}
8581
8582impl<'a, C> ProjectLocationNetworkPatchCall<'a, C>
8583where
8584 C: common::Connector,
8585{
8586 /// Perform the operation you have build so far.
8587 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8588 use std::borrow::Cow;
8589 use std::io::{Read, Seek};
8590
8591 use common::{url::Params, ToParts};
8592 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8593
8594 let mut dd = common::DefaultDelegate;
8595 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8596 dlg.begin(common::MethodInfo {
8597 id: "baremetalsolution.projects.locations.networks.patch",
8598 http_method: hyper::Method::PATCH,
8599 });
8600
8601 for &field in ["alt", "name", "updateMask"].iter() {
8602 if self._additional_params.contains_key(field) {
8603 dlg.finished(false);
8604 return Err(common::Error::FieldClash(field));
8605 }
8606 }
8607
8608 let mut params = Params::with_capacity(5 + self._additional_params.len());
8609 params.push("name", self._name);
8610 if let Some(value) = self._update_mask.as_ref() {
8611 params.push("updateMask", value.to_string());
8612 }
8613
8614 params.extend(self._additional_params.iter());
8615
8616 params.push("alt", "json");
8617 let mut url = self.hub._base_url.clone() + "v2/{+name}";
8618 if self._scopes.is_empty() {
8619 self._scopes
8620 .insert(Scope::CloudPlatform.as_ref().to_string());
8621 }
8622
8623 #[allow(clippy::single_element_loop)]
8624 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8625 url = params.uri_replacement(url, param_name, find_this, true);
8626 }
8627 {
8628 let to_remove = ["name"];
8629 params.remove_params(&to_remove);
8630 }
8631
8632 let url = params.parse_with_url(&url);
8633
8634 let mut json_mime_type = mime::APPLICATION_JSON;
8635 let mut request_value_reader = {
8636 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8637 common::remove_json_null_values(&mut value);
8638 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8639 serde_json::to_writer(&mut dst, &value).unwrap();
8640 dst
8641 };
8642 let request_size = request_value_reader
8643 .seek(std::io::SeekFrom::End(0))
8644 .unwrap();
8645 request_value_reader
8646 .seek(std::io::SeekFrom::Start(0))
8647 .unwrap();
8648
8649 loop {
8650 let token = match self
8651 .hub
8652 .auth
8653 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8654 .await
8655 {
8656 Ok(token) => token,
8657 Err(e) => match dlg.token(e) {
8658 Ok(token) => token,
8659 Err(e) => {
8660 dlg.finished(false);
8661 return Err(common::Error::MissingToken(e));
8662 }
8663 },
8664 };
8665 request_value_reader
8666 .seek(std::io::SeekFrom::Start(0))
8667 .unwrap();
8668 let mut req_result = {
8669 let client = &self.hub.client;
8670 dlg.pre_request();
8671 let mut req_builder = hyper::Request::builder()
8672 .method(hyper::Method::PATCH)
8673 .uri(url.as_str())
8674 .header(USER_AGENT, self.hub._user_agent.clone());
8675
8676 if let Some(token) = token.as_ref() {
8677 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8678 }
8679
8680 let request = req_builder
8681 .header(CONTENT_TYPE, json_mime_type.to_string())
8682 .header(CONTENT_LENGTH, request_size as u64)
8683 .body(common::to_body(
8684 request_value_reader.get_ref().clone().into(),
8685 ));
8686
8687 client.request(request.unwrap()).await
8688 };
8689
8690 match req_result {
8691 Err(err) => {
8692 if let common::Retry::After(d) = dlg.http_error(&err) {
8693 sleep(d).await;
8694 continue;
8695 }
8696 dlg.finished(false);
8697 return Err(common::Error::HttpError(err));
8698 }
8699 Ok(res) => {
8700 let (mut parts, body) = res.into_parts();
8701 let mut body = common::Body::new(body);
8702 if !parts.status.is_success() {
8703 let bytes = common::to_bytes(body).await.unwrap_or_default();
8704 let error = serde_json::from_str(&common::to_string(&bytes));
8705 let response = common::to_response(parts, bytes.into());
8706
8707 if let common::Retry::After(d) =
8708 dlg.http_failure(&response, error.as_ref().ok())
8709 {
8710 sleep(d).await;
8711 continue;
8712 }
8713
8714 dlg.finished(false);
8715
8716 return Err(match error {
8717 Ok(value) => common::Error::BadRequest(value),
8718 _ => common::Error::Failure(response),
8719 });
8720 }
8721 let response = {
8722 let bytes = common::to_bytes(body).await.unwrap_or_default();
8723 let encoded = common::to_string(&bytes);
8724 match serde_json::from_str(&encoded) {
8725 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8726 Err(error) => {
8727 dlg.response_json_decode_error(&encoded, &error);
8728 return Err(common::Error::JsonDecodeError(
8729 encoded.to_string(),
8730 error,
8731 ));
8732 }
8733 }
8734 };
8735
8736 dlg.finished(true);
8737 return Ok(response);
8738 }
8739 }
8740 }
8741 }
8742
8743 ///
8744 /// Sets the *request* property to the given value.
8745 ///
8746 /// Even though the property as already been set when instantiating this call,
8747 /// we provide this method for API completeness.
8748 pub fn request(mut self, new_value: Network) -> ProjectLocationNetworkPatchCall<'a, C> {
8749 self._request = new_value;
8750 self
8751 }
8752 /// 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}`
8753 ///
8754 /// Sets the *name* path property to the given value.
8755 ///
8756 /// Even though the property as already been set when instantiating this call,
8757 /// we provide this method for API completeness.
8758 pub fn name(mut self, new_value: &str) -> ProjectLocationNetworkPatchCall<'a, C> {
8759 self._name = new_value.to_string();
8760 self
8761 }
8762 /// The list of fields to update. The only currently supported fields are: `labels`, `reservations`, `vrf.vlan_attachments`
8763 ///
8764 /// Sets the *update mask* query property to the given value.
8765 pub fn update_mask(
8766 mut self,
8767 new_value: common::FieldMask,
8768 ) -> ProjectLocationNetworkPatchCall<'a, C> {
8769 self._update_mask = Some(new_value);
8770 self
8771 }
8772 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8773 /// while executing the actual API request.
8774 ///
8775 /// ````text
8776 /// It should be used to handle progress information, and to implement a certain level of resilience.
8777 /// ````
8778 ///
8779 /// Sets the *delegate* property to the given value.
8780 pub fn delegate(
8781 mut self,
8782 new_value: &'a mut dyn common::Delegate,
8783 ) -> ProjectLocationNetworkPatchCall<'a, C> {
8784 self._delegate = Some(new_value);
8785 self
8786 }
8787
8788 /// Set any additional parameter of the query string used in the request.
8789 /// It should be used to set parameters which are not yet available through their own
8790 /// setters.
8791 ///
8792 /// Please note that this method must not be used to set any of the known parameters
8793 /// which have their own setter method. If done anyway, the request will fail.
8794 ///
8795 /// # Additional Parameters
8796 ///
8797 /// * *$.xgafv* (query-string) - V1 error format.
8798 /// * *access_token* (query-string) - OAuth access token.
8799 /// * *alt* (query-string) - Data format for response.
8800 /// * *callback* (query-string) - JSONP
8801 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8802 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8803 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8804 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8805 /// * *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.
8806 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8807 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8808 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNetworkPatchCall<'a, C>
8809 where
8810 T: AsRef<str>,
8811 {
8812 self._additional_params
8813 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8814 self
8815 }
8816
8817 /// Identifies the authorization scope for the method you are building.
8818 ///
8819 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8820 /// [`Scope::CloudPlatform`].
8821 ///
8822 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8823 /// tokens for more than one scope.
8824 ///
8825 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8826 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8827 /// sufficient, a read-write scope will do as well.
8828 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNetworkPatchCall<'a, C>
8829 where
8830 St: AsRef<str>,
8831 {
8832 self._scopes.insert(String::from(scope.as_ref()));
8833 self
8834 }
8835 /// Identifies the authorization scope(s) for the method you are building.
8836 ///
8837 /// See [`Self::add_scope()`] for details.
8838 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNetworkPatchCall<'a, C>
8839 where
8840 I: IntoIterator<Item = St>,
8841 St: AsRef<str>,
8842 {
8843 self._scopes
8844 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8845 self
8846 }
8847
8848 /// Removes all scopes, and no default scope will be used either.
8849 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8850 /// for details).
8851 pub fn clear_scopes(mut self) -> ProjectLocationNetworkPatchCall<'a, C> {
8852 self._scopes.clear();
8853 self
8854 }
8855}
8856
8857/// RenameNetwork sets a new name for a network. Use with caution, previous names become immediately invalidated.
8858///
8859/// A builder for the *locations.networks.rename* method supported by a *project* resource.
8860/// It is not used directly, but through a [`ProjectMethods`] instance.
8861///
8862/// # Example
8863///
8864/// Instantiate a resource method builder
8865///
8866/// ```test_harness,no_run
8867/// # extern crate hyper;
8868/// # extern crate hyper_rustls;
8869/// # extern crate google_baremetalsolution2 as baremetalsolution2;
8870/// use baremetalsolution2::api::RenameNetworkRequest;
8871/// # async fn dox() {
8872/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8873///
8874/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8875/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8876/// # secret,
8877/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8878/// # ).build().await.unwrap();
8879///
8880/// # let client = hyper_util::client::legacy::Client::builder(
8881/// # hyper_util::rt::TokioExecutor::new()
8882/// # )
8883/// # .build(
8884/// # hyper_rustls::HttpsConnectorBuilder::new()
8885/// # .with_native_roots()
8886/// # .unwrap()
8887/// # .https_or_http()
8888/// # .enable_http1()
8889/// # .build()
8890/// # );
8891/// # let mut hub = Baremetalsolution::new(client, auth);
8892/// // As the method needs a request, you would usually fill it with the desired information
8893/// // into the respective structure. Some of the parts shown here might not be applicable !
8894/// // Values shown here are possibly random and not representative !
8895/// let mut req = RenameNetworkRequest::default();
8896///
8897/// // You can configure optional parameters by calling the respective setters at will, and
8898/// // execute the final call using `doit()`.
8899/// // Values shown here are possibly random and not representative !
8900/// let result = hub.projects().locations_networks_rename(req, "name")
8901/// .doit().await;
8902/// # }
8903/// ```
8904pub struct ProjectLocationNetworkRenameCall<'a, C>
8905where
8906 C: 'a,
8907{
8908 hub: &'a Baremetalsolution<C>,
8909 _request: RenameNetworkRequest,
8910 _name: String,
8911 _delegate: Option<&'a mut dyn common::Delegate>,
8912 _additional_params: HashMap<String, String>,
8913 _scopes: BTreeSet<String>,
8914}
8915
8916impl<'a, C> common::CallBuilder for ProjectLocationNetworkRenameCall<'a, C> {}
8917
8918impl<'a, C> ProjectLocationNetworkRenameCall<'a, C>
8919where
8920 C: common::Connector,
8921{
8922 /// Perform the operation you have build so far.
8923 pub async fn doit(mut self) -> common::Result<(common::Response, Network)> {
8924 use std::borrow::Cow;
8925 use std::io::{Read, Seek};
8926
8927 use common::{url::Params, ToParts};
8928 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8929
8930 let mut dd = common::DefaultDelegate;
8931 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8932 dlg.begin(common::MethodInfo {
8933 id: "baremetalsolution.projects.locations.networks.rename",
8934 http_method: hyper::Method::POST,
8935 });
8936
8937 for &field in ["alt", "name"].iter() {
8938 if self._additional_params.contains_key(field) {
8939 dlg.finished(false);
8940 return Err(common::Error::FieldClash(field));
8941 }
8942 }
8943
8944 let mut params = Params::with_capacity(4 + self._additional_params.len());
8945 params.push("name", self._name);
8946
8947 params.extend(self._additional_params.iter());
8948
8949 params.push("alt", "json");
8950 let mut url = self.hub._base_url.clone() + "v2/{+name}:rename";
8951 if self._scopes.is_empty() {
8952 self._scopes
8953 .insert(Scope::CloudPlatform.as_ref().to_string());
8954 }
8955
8956 #[allow(clippy::single_element_loop)]
8957 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8958 url = params.uri_replacement(url, param_name, find_this, true);
8959 }
8960 {
8961 let to_remove = ["name"];
8962 params.remove_params(&to_remove);
8963 }
8964
8965 let url = params.parse_with_url(&url);
8966
8967 let mut json_mime_type = mime::APPLICATION_JSON;
8968 let mut request_value_reader = {
8969 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8970 common::remove_json_null_values(&mut value);
8971 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8972 serde_json::to_writer(&mut dst, &value).unwrap();
8973 dst
8974 };
8975 let request_size = request_value_reader
8976 .seek(std::io::SeekFrom::End(0))
8977 .unwrap();
8978 request_value_reader
8979 .seek(std::io::SeekFrom::Start(0))
8980 .unwrap();
8981
8982 loop {
8983 let token = match self
8984 .hub
8985 .auth
8986 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8987 .await
8988 {
8989 Ok(token) => token,
8990 Err(e) => match dlg.token(e) {
8991 Ok(token) => token,
8992 Err(e) => {
8993 dlg.finished(false);
8994 return Err(common::Error::MissingToken(e));
8995 }
8996 },
8997 };
8998 request_value_reader
8999 .seek(std::io::SeekFrom::Start(0))
9000 .unwrap();
9001 let mut req_result = {
9002 let client = &self.hub.client;
9003 dlg.pre_request();
9004 let mut req_builder = hyper::Request::builder()
9005 .method(hyper::Method::POST)
9006 .uri(url.as_str())
9007 .header(USER_AGENT, self.hub._user_agent.clone());
9008
9009 if let Some(token) = token.as_ref() {
9010 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9011 }
9012
9013 let request = req_builder
9014 .header(CONTENT_TYPE, json_mime_type.to_string())
9015 .header(CONTENT_LENGTH, request_size as u64)
9016 .body(common::to_body(
9017 request_value_reader.get_ref().clone().into(),
9018 ));
9019
9020 client.request(request.unwrap()).await
9021 };
9022
9023 match req_result {
9024 Err(err) => {
9025 if let common::Retry::After(d) = dlg.http_error(&err) {
9026 sleep(d).await;
9027 continue;
9028 }
9029 dlg.finished(false);
9030 return Err(common::Error::HttpError(err));
9031 }
9032 Ok(res) => {
9033 let (mut parts, body) = res.into_parts();
9034 let mut body = common::Body::new(body);
9035 if !parts.status.is_success() {
9036 let bytes = common::to_bytes(body).await.unwrap_or_default();
9037 let error = serde_json::from_str(&common::to_string(&bytes));
9038 let response = common::to_response(parts, bytes.into());
9039
9040 if let common::Retry::After(d) =
9041 dlg.http_failure(&response, error.as_ref().ok())
9042 {
9043 sleep(d).await;
9044 continue;
9045 }
9046
9047 dlg.finished(false);
9048
9049 return Err(match error {
9050 Ok(value) => common::Error::BadRequest(value),
9051 _ => common::Error::Failure(response),
9052 });
9053 }
9054 let response = {
9055 let bytes = common::to_bytes(body).await.unwrap_or_default();
9056 let encoded = common::to_string(&bytes);
9057 match serde_json::from_str(&encoded) {
9058 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9059 Err(error) => {
9060 dlg.response_json_decode_error(&encoded, &error);
9061 return Err(common::Error::JsonDecodeError(
9062 encoded.to_string(),
9063 error,
9064 ));
9065 }
9066 }
9067 };
9068
9069 dlg.finished(true);
9070 return Ok(response);
9071 }
9072 }
9073 }
9074 }
9075
9076 ///
9077 /// Sets the *request* property to the given value.
9078 ///
9079 /// Even though the property as already been set when instantiating this call,
9080 /// we provide this method for API completeness.
9081 pub fn request(
9082 mut self,
9083 new_value: RenameNetworkRequest,
9084 ) -> ProjectLocationNetworkRenameCall<'a, C> {
9085 self._request = new_value;
9086 self
9087 }
9088 /// Required. The `name` field is used to identify the network. Format: projects/{project}/locations/{location}/networks/{network}
9089 ///
9090 /// Sets the *name* path property to the given value.
9091 ///
9092 /// Even though the property as already been set when instantiating this call,
9093 /// we provide this method for API completeness.
9094 pub fn name(mut self, new_value: &str) -> ProjectLocationNetworkRenameCall<'a, C> {
9095 self._name = new_value.to_string();
9096 self
9097 }
9098 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9099 /// while executing the actual API request.
9100 ///
9101 /// ````text
9102 /// It should be used to handle progress information, and to implement a certain level of resilience.
9103 /// ````
9104 ///
9105 /// Sets the *delegate* property to the given value.
9106 pub fn delegate(
9107 mut self,
9108 new_value: &'a mut dyn common::Delegate,
9109 ) -> ProjectLocationNetworkRenameCall<'a, C> {
9110 self._delegate = Some(new_value);
9111 self
9112 }
9113
9114 /// Set any additional parameter of the query string used in the request.
9115 /// It should be used to set parameters which are not yet available through their own
9116 /// setters.
9117 ///
9118 /// Please note that this method must not be used to set any of the known parameters
9119 /// which have their own setter method. If done anyway, the request will fail.
9120 ///
9121 /// # Additional Parameters
9122 ///
9123 /// * *$.xgafv* (query-string) - V1 error format.
9124 /// * *access_token* (query-string) - OAuth access token.
9125 /// * *alt* (query-string) - Data format for response.
9126 /// * *callback* (query-string) - JSONP
9127 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9128 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9129 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9130 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9131 /// * *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.
9132 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9133 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9134 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNetworkRenameCall<'a, C>
9135 where
9136 T: AsRef<str>,
9137 {
9138 self._additional_params
9139 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9140 self
9141 }
9142
9143 /// Identifies the authorization scope for the method you are building.
9144 ///
9145 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9146 /// [`Scope::CloudPlatform`].
9147 ///
9148 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9149 /// tokens for more than one scope.
9150 ///
9151 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9152 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9153 /// sufficient, a read-write scope will do as well.
9154 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNetworkRenameCall<'a, C>
9155 where
9156 St: AsRef<str>,
9157 {
9158 self._scopes.insert(String::from(scope.as_ref()));
9159 self
9160 }
9161 /// Identifies the authorization scope(s) for the method you are building.
9162 ///
9163 /// See [`Self::add_scope()`] for details.
9164 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNetworkRenameCall<'a, C>
9165 where
9166 I: IntoIterator<Item = St>,
9167 St: AsRef<str>,
9168 {
9169 self._scopes
9170 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9171 self
9172 }
9173
9174 /// Removes all scopes, and no default scope will be used either.
9175 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9176 /// for details).
9177 pub fn clear_scopes(mut self) -> ProjectLocationNetworkRenameCall<'a, C> {
9178 self._scopes.clear();
9179 self
9180 }
9181}
9182
9183/// Create an NFS share.
9184///
9185/// A builder for the *locations.nfsShares.create* method supported by a *project* resource.
9186/// It is not used directly, but through a [`ProjectMethods`] instance.
9187///
9188/// # Example
9189///
9190/// Instantiate a resource method builder
9191///
9192/// ```test_harness,no_run
9193/// # extern crate hyper;
9194/// # extern crate hyper_rustls;
9195/// # extern crate google_baremetalsolution2 as baremetalsolution2;
9196/// use baremetalsolution2::api::NfsShare;
9197/// # async fn dox() {
9198/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9199///
9200/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9201/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9202/// # secret,
9203/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9204/// # ).build().await.unwrap();
9205///
9206/// # let client = hyper_util::client::legacy::Client::builder(
9207/// # hyper_util::rt::TokioExecutor::new()
9208/// # )
9209/// # .build(
9210/// # hyper_rustls::HttpsConnectorBuilder::new()
9211/// # .with_native_roots()
9212/// # .unwrap()
9213/// # .https_or_http()
9214/// # .enable_http1()
9215/// # .build()
9216/// # );
9217/// # let mut hub = Baremetalsolution::new(client, auth);
9218/// // As the method needs a request, you would usually fill it with the desired information
9219/// // into the respective structure. Some of the parts shown here might not be applicable !
9220/// // Values shown here are possibly random and not representative !
9221/// let mut req = NfsShare::default();
9222///
9223/// // You can configure optional parameters by calling the respective setters at will, and
9224/// // execute the final call using `doit()`.
9225/// // Values shown here are possibly random and not representative !
9226/// let result = hub.projects().locations_nfs_shares_create(req, "parent")
9227/// .doit().await;
9228/// # }
9229/// ```
9230pub struct ProjectLocationNfsShareCreateCall<'a, C>
9231where
9232 C: 'a,
9233{
9234 hub: &'a Baremetalsolution<C>,
9235 _request: NfsShare,
9236 _parent: String,
9237 _delegate: Option<&'a mut dyn common::Delegate>,
9238 _additional_params: HashMap<String, String>,
9239 _scopes: BTreeSet<String>,
9240}
9241
9242impl<'a, C> common::CallBuilder for ProjectLocationNfsShareCreateCall<'a, C> {}
9243
9244impl<'a, C> ProjectLocationNfsShareCreateCall<'a, C>
9245where
9246 C: common::Connector,
9247{
9248 /// Perform the operation you have build so far.
9249 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9250 use std::borrow::Cow;
9251 use std::io::{Read, Seek};
9252
9253 use common::{url::Params, ToParts};
9254 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9255
9256 let mut dd = common::DefaultDelegate;
9257 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9258 dlg.begin(common::MethodInfo {
9259 id: "baremetalsolution.projects.locations.nfsShares.create",
9260 http_method: hyper::Method::POST,
9261 });
9262
9263 for &field in ["alt", "parent"].iter() {
9264 if self._additional_params.contains_key(field) {
9265 dlg.finished(false);
9266 return Err(common::Error::FieldClash(field));
9267 }
9268 }
9269
9270 let mut params = Params::with_capacity(4 + self._additional_params.len());
9271 params.push("parent", self._parent);
9272
9273 params.extend(self._additional_params.iter());
9274
9275 params.push("alt", "json");
9276 let mut url = self.hub._base_url.clone() + "v2/{+parent}/nfsShares";
9277 if self._scopes.is_empty() {
9278 self._scopes
9279 .insert(Scope::CloudPlatform.as_ref().to_string());
9280 }
9281
9282 #[allow(clippy::single_element_loop)]
9283 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9284 url = params.uri_replacement(url, param_name, find_this, true);
9285 }
9286 {
9287 let to_remove = ["parent"];
9288 params.remove_params(&to_remove);
9289 }
9290
9291 let url = params.parse_with_url(&url);
9292
9293 let mut json_mime_type = mime::APPLICATION_JSON;
9294 let mut request_value_reader = {
9295 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9296 common::remove_json_null_values(&mut value);
9297 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9298 serde_json::to_writer(&mut dst, &value).unwrap();
9299 dst
9300 };
9301 let request_size = request_value_reader
9302 .seek(std::io::SeekFrom::End(0))
9303 .unwrap();
9304 request_value_reader
9305 .seek(std::io::SeekFrom::Start(0))
9306 .unwrap();
9307
9308 loop {
9309 let token = match self
9310 .hub
9311 .auth
9312 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9313 .await
9314 {
9315 Ok(token) => token,
9316 Err(e) => match dlg.token(e) {
9317 Ok(token) => token,
9318 Err(e) => {
9319 dlg.finished(false);
9320 return Err(common::Error::MissingToken(e));
9321 }
9322 },
9323 };
9324 request_value_reader
9325 .seek(std::io::SeekFrom::Start(0))
9326 .unwrap();
9327 let mut req_result = {
9328 let client = &self.hub.client;
9329 dlg.pre_request();
9330 let mut req_builder = hyper::Request::builder()
9331 .method(hyper::Method::POST)
9332 .uri(url.as_str())
9333 .header(USER_AGENT, self.hub._user_agent.clone());
9334
9335 if let Some(token) = token.as_ref() {
9336 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9337 }
9338
9339 let request = req_builder
9340 .header(CONTENT_TYPE, json_mime_type.to_string())
9341 .header(CONTENT_LENGTH, request_size as u64)
9342 .body(common::to_body(
9343 request_value_reader.get_ref().clone().into(),
9344 ));
9345
9346 client.request(request.unwrap()).await
9347 };
9348
9349 match req_result {
9350 Err(err) => {
9351 if let common::Retry::After(d) = dlg.http_error(&err) {
9352 sleep(d).await;
9353 continue;
9354 }
9355 dlg.finished(false);
9356 return Err(common::Error::HttpError(err));
9357 }
9358 Ok(res) => {
9359 let (mut parts, body) = res.into_parts();
9360 let mut body = common::Body::new(body);
9361 if !parts.status.is_success() {
9362 let bytes = common::to_bytes(body).await.unwrap_or_default();
9363 let error = serde_json::from_str(&common::to_string(&bytes));
9364 let response = common::to_response(parts, bytes.into());
9365
9366 if let common::Retry::After(d) =
9367 dlg.http_failure(&response, error.as_ref().ok())
9368 {
9369 sleep(d).await;
9370 continue;
9371 }
9372
9373 dlg.finished(false);
9374
9375 return Err(match error {
9376 Ok(value) => common::Error::BadRequest(value),
9377 _ => common::Error::Failure(response),
9378 });
9379 }
9380 let response = {
9381 let bytes = common::to_bytes(body).await.unwrap_or_default();
9382 let encoded = common::to_string(&bytes);
9383 match serde_json::from_str(&encoded) {
9384 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9385 Err(error) => {
9386 dlg.response_json_decode_error(&encoded, &error);
9387 return Err(common::Error::JsonDecodeError(
9388 encoded.to_string(),
9389 error,
9390 ));
9391 }
9392 }
9393 };
9394
9395 dlg.finished(true);
9396 return Ok(response);
9397 }
9398 }
9399 }
9400 }
9401
9402 ///
9403 /// Sets the *request* property to the given value.
9404 ///
9405 /// Even though the property as already been set when instantiating this call,
9406 /// we provide this method for API completeness.
9407 pub fn request(mut self, new_value: NfsShare) -> ProjectLocationNfsShareCreateCall<'a, C> {
9408 self._request = new_value;
9409 self
9410 }
9411 /// Required. The parent project and location.
9412 ///
9413 /// Sets the *parent* path property to the given value.
9414 ///
9415 /// Even though the property as already been set when instantiating this call,
9416 /// we provide this method for API completeness.
9417 pub fn parent(mut self, new_value: &str) -> ProjectLocationNfsShareCreateCall<'a, C> {
9418 self._parent = new_value.to_string();
9419 self
9420 }
9421 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9422 /// while executing the actual API request.
9423 ///
9424 /// ````text
9425 /// It should be used to handle progress information, and to implement a certain level of resilience.
9426 /// ````
9427 ///
9428 /// Sets the *delegate* property to the given value.
9429 pub fn delegate(
9430 mut self,
9431 new_value: &'a mut dyn common::Delegate,
9432 ) -> ProjectLocationNfsShareCreateCall<'a, C> {
9433 self._delegate = Some(new_value);
9434 self
9435 }
9436
9437 /// Set any additional parameter of the query string used in the request.
9438 /// It should be used to set parameters which are not yet available through their own
9439 /// setters.
9440 ///
9441 /// Please note that this method must not be used to set any of the known parameters
9442 /// which have their own setter method. If done anyway, the request will fail.
9443 ///
9444 /// # Additional Parameters
9445 ///
9446 /// * *$.xgafv* (query-string) - V1 error format.
9447 /// * *access_token* (query-string) - OAuth access token.
9448 /// * *alt* (query-string) - Data format for response.
9449 /// * *callback* (query-string) - JSONP
9450 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9451 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9452 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9453 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9454 /// * *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.
9455 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9456 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9457 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNfsShareCreateCall<'a, C>
9458 where
9459 T: AsRef<str>,
9460 {
9461 self._additional_params
9462 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9463 self
9464 }
9465
9466 /// Identifies the authorization scope for the method you are building.
9467 ///
9468 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9469 /// [`Scope::CloudPlatform`].
9470 ///
9471 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9472 /// tokens for more than one scope.
9473 ///
9474 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9475 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9476 /// sufficient, a read-write scope will do as well.
9477 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNfsShareCreateCall<'a, C>
9478 where
9479 St: AsRef<str>,
9480 {
9481 self._scopes.insert(String::from(scope.as_ref()));
9482 self
9483 }
9484 /// Identifies the authorization scope(s) for the method you are building.
9485 ///
9486 /// See [`Self::add_scope()`] for details.
9487 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNfsShareCreateCall<'a, C>
9488 where
9489 I: IntoIterator<Item = St>,
9490 St: AsRef<str>,
9491 {
9492 self._scopes
9493 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9494 self
9495 }
9496
9497 /// Removes all scopes, and no default scope will be used either.
9498 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9499 /// for details).
9500 pub fn clear_scopes(mut self) -> ProjectLocationNfsShareCreateCall<'a, C> {
9501 self._scopes.clear();
9502 self
9503 }
9504}
9505
9506/// Delete an NFS share. The underlying volume is automatically deleted.
9507///
9508/// A builder for the *locations.nfsShares.delete* method supported by a *project* resource.
9509/// It is not used directly, but through a [`ProjectMethods`] instance.
9510///
9511/// # Example
9512///
9513/// Instantiate a resource method builder
9514///
9515/// ```test_harness,no_run
9516/// # extern crate hyper;
9517/// # extern crate hyper_rustls;
9518/// # extern crate google_baremetalsolution2 as baremetalsolution2;
9519/// # async fn dox() {
9520/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9521///
9522/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9523/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9524/// # secret,
9525/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9526/// # ).build().await.unwrap();
9527///
9528/// # let client = hyper_util::client::legacy::Client::builder(
9529/// # hyper_util::rt::TokioExecutor::new()
9530/// # )
9531/// # .build(
9532/// # hyper_rustls::HttpsConnectorBuilder::new()
9533/// # .with_native_roots()
9534/// # .unwrap()
9535/// # .https_or_http()
9536/// # .enable_http1()
9537/// # .build()
9538/// # );
9539/// # let mut hub = Baremetalsolution::new(client, auth);
9540/// // You can configure optional parameters by calling the respective setters at will, and
9541/// // execute the final call using `doit()`.
9542/// // Values shown here are possibly random and not representative !
9543/// let result = hub.projects().locations_nfs_shares_delete("name")
9544/// .doit().await;
9545/// # }
9546/// ```
9547pub struct ProjectLocationNfsShareDeleteCall<'a, C>
9548where
9549 C: 'a,
9550{
9551 hub: &'a Baremetalsolution<C>,
9552 _name: String,
9553 _delegate: Option<&'a mut dyn common::Delegate>,
9554 _additional_params: HashMap<String, String>,
9555 _scopes: BTreeSet<String>,
9556}
9557
9558impl<'a, C> common::CallBuilder for ProjectLocationNfsShareDeleteCall<'a, C> {}
9559
9560impl<'a, C> ProjectLocationNfsShareDeleteCall<'a, C>
9561where
9562 C: common::Connector,
9563{
9564 /// Perform the operation you have build so far.
9565 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9566 use std::borrow::Cow;
9567 use std::io::{Read, Seek};
9568
9569 use common::{url::Params, ToParts};
9570 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9571
9572 let mut dd = common::DefaultDelegate;
9573 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9574 dlg.begin(common::MethodInfo {
9575 id: "baremetalsolution.projects.locations.nfsShares.delete",
9576 http_method: hyper::Method::DELETE,
9577 });
9578
9579 for &field in ["alt", "name"].iter() {
9580 if self._additional_params.contains_key(field) {
9581 dlg.finished(false);
9582 return Err(common::Error::FieldClash(field));
9583 }
9584 }
9585
9586 let mut params = Params::with_capacity(3 + self._additional_params.len());
9587 params.push("name", self._name);
9588
9589 params.extend(self._additional_params.iter());
9590
9591 params.push("alt", "json");
9592 let mut url = self.hub._base_url.clone() + "v2/{+name}";
9593 if self._scopes.is_empty() {
9594 self._scopes
9595 .insert(Scope::CloudPlatform.as_ref().to_string());
9596 }
9597
9598 #[allow(clippy::single_element_loop)]
9599 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9600 url = params.uri_replacement(url, param_name, find_this, true);
9601 }
9602 {
9603 let to_remove = ["name"];
9604 params.remove_params(&to_remove);
9605 }
9606
9607 let url = params.parse_with_url(&url);
9608
9609 loop {
9610 let token = match self
9611 .hub
9612 .auth
9613 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9614 .await
9615 {
9616 Ok(token) => token,
9617 Err(e) => match dlg.token(e) {
9618 Ok(token) => token,
9619 Err(e) => {
9620 dlg.finished(false);
9621 return Err(common::Error::MissingToken(e));
9622 }
9623 },
9624 };
9625 let mut req_result = {
9626 let client = &self.hub.client;
9627 dlg.pre_request();
9628 let mut req_builder = hyper::Request::builder()
9629 .method(hyper::Method::DELETE)
9630 .uri(url.as_str())
9631 .header(USER_AGENT, self.hub._user_agent.clone());
9632
9633 if let Some(token) = token.as_ref() {
9634 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9635 }
9636
9637 let request = req_builder
9638 .header(CONTENT_LENGTH, 0_u64)
9639 .body(common::to_body::<String>(None));
9640
9641 client.request(request.unwrap()).await
9642 };
9643
9644 match req_result {
9645 Err(err) => {
9646 if let common::Retry::After(d) = dlg.http_error(&err) {
9647 sleep(d).await;
9648 continue;
9649 }
9650 dlg.finished(false);
9651 return Err(common::Error::HttpError(err));
9652 }
9653 Ok(res) => {
9654 let (mut parts, body) = res.into_parts();
9655 let mut body = common::Body::new(body);
9656 if !parts.status.is_success() {
9657 let bytes = common::to_bytes(body).await.unwrap_or_default();
9658 let error = serde_json::from_str(&common::to_string(&bytes));
9659 let response = common::to_response(parts, bytes.into());
9660
9661 if let common::Retry::After(d) =
9662 dlg.http_failure(&response, error.as_ref().ok())
9663 {
9664 sleep(d).await;
9665 continue;
9666 }
9667
9668 dlg.finished(false);
9669
9670 return Err(match error {
9671 Ok(value) => common::Error::BadRequest(value),
9672 _ => common::Error::Failure(response),
9673 });
9674 }
9675 let response = {
9676 let bytes = common::to_bytes(body).await.unwrap_or_default();
9677 let encoded = common::to_string(&bytes);
9678 match serde_json::from_str(&encoded) {
9679 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9680 Err(error) => {
9681 dlg.response_json_decode_error(&encoded, &error);
9682 return Err(common::Error::JsonDecodeError(
9683 encoded.to_string(),
9684 error,
9685 ));
9686 }
9687 }
9688 };
9689
9690 dlg.finished(true);
9691 return Ok(response);
9692 }
9693 }
9694 }
9695 }
9696
9697 /// Required. The name of the NFS share to delete.
9698 ///
9699 /// Sets the *name* path property to the given value.
9700 ///
9701 /// Even though the property as already been set when instantiating this call,
9702 /// we provide this method for API completeness.
9703 pub fn name(mut self, new_value: &str) -> ProjectLocationNfsShareDeleteCall<'a, C> {
9704 self._name = new_value.to_string();
9705 self
9706 }
9707 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9708 /// while executing the actual API request.
9709 ///
9710 /// ````text
9711 /// It should be used to handle progress information, and to implement a certain level of resilience.
9712 /// ````
9713 ///
9714 /// Sets the *delegate* property to the given value.
9715 pub fn delegate(
9716 mut self,
9717 new_value: &'a mut dyn common::Delegate,
9718 ) -> ProjectLocationNfsShareDeleteCall<'a, C> {
9719 self._delegate = Some(new_value);
9720 self
9721 }
9722
9723 /// Set any additional parameter of the query string used in the request.
9724 /// It should be used to set parameters which are not yet available through their own
9725 /// setters.
9726 ///
9727 /// Please note that this method must not be used to set any of the known parameters
9728 /// which have their own setter method. If done anyway, the request will fail.
9729 ///
9730 /// # Additional Parameters
9731 ///
9732 /// * *$.xgafv* (query-string) - V1 error format.
9733 /// * *access_token* (query-string) - OAuth access token.
9734 /// * *alt* (query-string) - Data format for response.
9735 /// * *callback* (query-string) - JSONP
9736 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9737 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9738 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9739 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9740 /// * *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.
9741 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9742 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9743 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNfsShareDeleteCall<'a, C>
9744 where
9745 T: AsRef<str>,
9746 {
9747 self._additional_params
9748 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9749 self
9750 }
9751
9752 /// Identifies the authorization scope for the method you are building.
9753 ///
9754 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9755 /// [`Scope::CloudPlatform`].
9756 ///
9757 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9758 /// tokens for more than one scope.
9759 ///
9760 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9761 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9762 /// sufficient, a read-write scope will do as well.
9763 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNfsShareDeleteCall<'a, C>
9764 where
9765 St: AsRef<str>,
9766 {
9767 self._scopes.insert(String::from(scope.as_ref()));
9768 self
9769 }
9770 /// Identifies the authorization scope(s) for the method you are building.
9771 ///
9772 /// See [`Self::add_scope()`] for details.
9773 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNfsShareDeleteCall<'a, C>
9774 where
9775 I: IntoIterator<Item = St>,
9776 St: AsRef<str>,
9777 {
9778 self._scopes
9779 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9780 self
9781 }
9782
9783 /// Removes all scopes, and no default scope will be used either.
9784 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9785 /// for details).
9786 pub fn clear_scopes(mut self) -> ProjectLocationNfsShareDeleteCall<'a, C> {
9787 self._scopes.clear();
9788 self
9789 }
9790}
9791
9792/// Get details of a single NFS share.
9793///
9794/// A builder for the *locations.nfsShares.get* method supported by a *project* resource.
9795/// It is not used directly, but through a [`ProjectMethods`] instance.
9796///
9797/// # Example
9798///
9799/// Instantiate a resource method builder
9800///
9801/// ```test_harness,no_run
9802/// # extern crate hyper;
9803/// # extern crate hyper_rustls;
9804/// # extern crate google_baremetalsolution2 as baremetalsolution2;
9805/// # async fn dox() {
9806/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9807///
9808/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9809/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9810/// # secret,
9811/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9812/// # ).build().await.unwrap();
9813///
9814/// # let client = hyper_util::client::legacy::Client::builder(
9815/// # hyper_util::rt::TokioExecutor::new()
9816/// # )
9817/// # .build(
9818/// # hyper_rustls::HttpsConnectorBuilder::new()
9819/// # .with_native_roots()
9820/// # .unwrap()
9821/// # .https_or_http()
9822/// # .enable_http1()
9823/// # .build()
9824/// # );
9825/// # let mut hub = Baremetalsolution::new(client, auth);
9826/// // You can configure optional parameters by calling the respective setters at will, and
9827/// // execute the final call using `doit()`.
9828/// // Values shown here are possibly random and not representative !
9829/// let result = hub.projects().locations_nfs_shares_get("name")
9830/// .doit().await;
9831/// # }
9832/// ```
9833pub struct ProjectLocationNfsShareGetCall<'a, C>
9834where
9835 C: 'a,
9836{
9837 hub: &'a Baremetalsolution<C>,
9838 _name: String,
9839 _delegate: Option<&'a mut dyn common::Delegate>,
9840 _additional_params: HashMap<String, String>,
9841 _scopes: BTreeSet<String>,
9842}
9843
9844impl<'a, C> common::CallBuilder for ProjectLocationNfsShareGetCall<'a, C> {}
9845
9846impl<'a, C> ProjectLocationNfsShareGetCall<'a, C>
9847where
9848 C: common::Connector,
9849{
9850 /// Perform the operation you have build so far.
9851 pub async fn doit(mut self) -> common::Result<(common::Response, NfsShare)> {
9852 use std::borrow::Cow;
9853 use std::io::{Read, Seek};
9854
9855 use common::{url::Params, ToParts};
9856 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9857
9858 let mut dd = common::DefaultDelegate;
9859 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9860 dlg.begin(common::MethodInfo {
9861 id: "baremetalsolution.projects.locations.nfsShares.get",
9862 http_method: hyper::Method::GET,
9863 });
9864
9865 for &field in ["alt", "name"].iter() {
9866 if self._additional_params.contains_key(field) {
9867 dlg.finished(false);
9868 return Err(common::Error::FieldClash(field));
9869 }
9870 }
9871
9872 let mut params = Params::with_capacity(3 + self._additional_params.len());
9873 params.push("name", self._name);
9874
9875 params.extend(self._additional_params.iter());
9876
9877 params.push("alt", "json");
9878 let mut url = self.hub._base_url.clone() + "v2/{+name}";
9879 if self._scopes.is_empty() {
9880 self._scopes
9881 .insert(Scope::CloudPlatform.as_ref().to_string());
9882 }
9883
9884 #[allow(clippy::single_element_loop)]
9885 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9886 url = params.uri_replacement(url, param_name, find_this, true);
9887 }
9888 {
9889 let to_remove = ["name"];
9890 params.remove_params(&to_remove);
9891 }
9892
9893 let url = params.parse_with_url(&url);
9894
9895 loop {
9896 let token = match self
9897 .hub
9898 .auth
9899 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9900 .await
9901 {
9902 Ok(token) => token,
9903 Err(e) => match dlg.token(e) {
9904 Ok(token) => token,
9905 Err(e) => {
9906 dlg.finished(false);
9907 return Err(common::Error::MissingToken(e));
9908 }
9909 },
9910 };
9911 let mut req_result = {
9912 let client = &self.hub.client;
9913 dlg.pre_request();
9914 let mut req_builder = hyper::Request::builder()
9915 .method(hyper::Method::GET)
9916 .uri(url.as_str())
9917 .header(USER_AGENT, self.hub._user_agent.clone());
9918
9919 if let Some(token) = token.as_ref() {
9920 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9921 }
9922
9923 let request = req_builder
9924 .header(CONTENT_LENGTH, 0_u64)
9925 .body(common::to_body::<String>(None));
9926
9927 client.request(request.unwrap()).await
9928 };
9929
9930 match req_result {
9931 Err(err) => {
9932 if let common::Retry::After(d) = dlg.http_error(&err) {
9933 sleep(d).await;
9934 continue;
9935 }
9936 dlg.finished(false);
9937 return Err(common::Error::HttpError(err));
9938 }
9939 Ok(res) => {
9940 let (mut parts, body) = res.into_parts();
9941 let mut body = common::Body::new(body);
9942 if !parts.status.is_success() {
9943 let bytes = common::to_bytes(body).await.unwrap_or_default();
9944 let error = serde_json::from_str(&common::to_string(&bytes));
9945 let response = common::to_response(parts, bytes.into());
9946
9947 if let common::Retry::After(d) =
9948 dlg.http_failure(&response, error.as_ref().ok())
9949 {
9950 sleep(d).await;
9951 continue;
9952 }
9953
9954 dlg.finished(false);
9955
9956 return Err(match error {
9957 Ok(value) => common::Error::BadRequest(value),
9958 _ => common::Error::Failure(response),
9959 });
9960 }
9961 let response = {
9962 let bytes = common::to_bytes(body).await.unwrap_or_default();
9963 let encoded = common::to_string(&bytes);
9964 match serde_json::from_str(&encoded) {
9965 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9966 Err(error) => {
9967 dlg.response_json_decode_error(&encoded, &error);
9968 return Err(common::Error::JsonDecodeError(
9969 encoded.to_string(),
9970 error,
9971 ));
9972 }
9973 }
9974 };
9975
9976 dlg.finished(true);
9977 return Ok(response);
9978 }
9979 }
9980 }
9981 }
9982
9983 /// Required. Name of the resource.
9984 ///
9985 /// Sets the *name* path property to the given value.
9986 ///
9987 /// Even though the property as already been set when instantiating this call,
9988 /// we provide this method for API completeness.
9989 pub fn name(mut self, new_value: &str) -> ProjectLocationNfsShareGetCall<'a, C> {
9990 self._name = new_value.to_string();
9991 self
9992 }
9993 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9994 /// while executing the actual API request.
9995 ///
9996 /// ````text
9997 /// It should be used to handle progress information, and to implement a certain level of resilience.
9998 /// ````
9999 ///
10000 /// Sets the *delegate* property to the given value.
10001 pub fn delegate(
10002 mut self,
10003 new_value: &'a mut dyn common::Delegate,
10004 ) -> ProjectLocationNfsShareGetCall<'a, C> {
10005 self._delegate = Some(new_value);
10006 self
10007 }
10008
10009 /// Set any additional parameter of the query string used in the request.
10010 /// It should be used to set parameters which are not yet available through their own
10011 /// setters.
10012 ///
10013 /// Please note that this method must not be used to set any of the known parameters
10014 /// which have their own setter method. If done anyway, the request will fail.
10015 ///
10016 /// # Additional Parameters
10017 ///
10018 /// * *$.xgafv* (query-string) - V1 error format.
10019 /// * *access_token* (query-string) - OAuth access token.
10020 /// * *alt* (query-string) - Data format for response.
10021 /// * *callback* (query-string) - JSONP
10022 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10023 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10024 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10025 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10026 /// * *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.
10027 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10028 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10029 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNfsShareGetCall<'a, C>
10030 where
10031 T: AsRef<str>,
10032 {
10033 self._additional_params
10034 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10035 self
10036 }
10037
10038 /// Identifies the authorization scope for the method you are building.
10039 ///
10040 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10041 /// [`Scope::CloudPlatform`].
10042 ///
10043 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10044 /// tokens for more than one scope.
10045 ///
10046 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10047 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10048 /// sufficient, a read-write scope will do as well.
10049 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNfsShareGetCall<'a, C>
10050 where
10051 St: AsRef<str>,
10052 {
10053 self._scopes.insert(String::from(scope.as_ref()));
10054 self
10055 }
10056 /// Identifies the authorization scope(s) for the method you are building.
10057 ///
10058 /// See [`Self::add_scope()`] for details.
10059 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNfsShareGetCall<'a, C>
10060 where
10061 I: IntoIterator<Item = St>,
10062 St: AsRef<str>,
10063 {
10064 self._scopes
10065 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10066 self
10067 }
10068
10069 /// Removes all scopes, and no default scope will be used either.
10070 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10071 /// for details).
10072 pub fn clear_scopes(mut self) -> ProjectLocationNfsShareGetCall<'a, C> {
10073 self._scopes.clear();
10074 self
10075 }
10076}
10077
10078/// List NFS shares.
10079///
10080/// A builder for the *locations.nfsShares.list* method supported by a *project* resource.
10081/// It is not used directly, but through a [`ProjectMethods`] instance.
10082///
10083/// # Example
10084///
10085/// Instantiate a resource method builder
10086///
10087/// ```test_harness,no_run
10088/// # extern crate hyper;
10089/// # extern crate hyper_rustls;
10090/// # extern crate google_baremetalsolution2 as baremetalsolution2;
10091/// # async fn dox() {
10092/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10093///
10094/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10095/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10096/// # secret,
10097/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10098/// # ).build().await.unwrap();
10099///
10100/// # let client = hyper_util::client::legacy::Client::builder(
10101/// # hyper_util::rt::TokioExecutor::new()
10102/// # )
10103/// # .build(
10104/// # hyper_rustls::HttpsConnectorBuilder::new()
10105/// # .with_native_roots()
10106/// # .unwrap()
10107/// # .https_or_http()
10108/// # .enable_http1()
10109/// # .build()
10110/// # );
10111/// # let mut hub = Baremetalsolution::new(client, auth);
10112/// // You can configure optional parameters by calling the respective setters at will, and
10113/// // execute the final call using `doit()`.
10114/// // Values shown here are possibly random and not representative !
10115/// let result = hub.projects().locations_nfs_shares_list("parent")
10116/// .page_token("gubergren")
10117/// .page_size(-17)
10118/// .filter("dolor")
10119/// .doit().await;
10120/// # }
10121/// ```
10122pub struct ProjectLocationNfsShareListCall<'a, C>
10123where
10124 C: 'a,
10125{
10126 hub: &'a Baremetalsolution<C>,
10127 _parent: String,
10128 _page_token: Option<String>,
10129 _page_size: Option<i32>,
10130 _filter: Option<String>,
10131 _delegate: Option<&'a mut dyn common::Delegate>,
10132 _additional_params: HashMap<String, String>,
10133 _scopes: BTreeSet<String>,
10134}
10135
10136impl<'a, C> common::CallBuilder for ProjectLocationNfsShareListCall<'a, C> {}
10137
10138impl<'a, C> ProjectLocationNfsShareListCall<'a, C>
10139where
10140 C: common::Connector,
10141{
10142 /// Perform the operation you have build so far.
10143 pub async fn doit(mut self) -> common::Result<(common::Response, ListNfsSharesResponse)> {
10144 use std::borrow::Cow;
10145 use std::io::{Read, Seek};
10146
10147 use common::{url::Params, ToParts};
10148 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10149
10150 let mut dd = common::DefaultDelegate;
10151 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10152 dlg.begin(common::MethodInfo {
10153 id: "baremetalsolution.projects.locations.nfsShares.list",
10154 http_method: hyper::Method::GET,
10155 });
10156
10157 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
10158 if self._additional_params.contains_key(field) {
10159 dlg.finished(false);
10160 return Err(common::Error::FieldClash(field));
10161 }
10162 }
10163
10164 let mut params = Params::with_capacity(6 + self._additional_params.len());
10165 params.push("parent", self._parent);
10166 if let Some(value) = self._page_token.as_ref() {
10167 params.push("pageToken", value);
10168 }
10169 if let Some(value) = self._page_size.as_ref() {
10170 params.push("pageSize", value.to_string());
10171 }
10172 if let Some(value) = self._filter.as_ref() {
10173 params.push("filter", value);
10174 }
10175
10176 params.extend(self._additional_params.iter());
10177
10178 params.push("alt", "json");
10179 let mut url = self.hub._base_url.clone() + "v2/{+parent}/nfsShares";
10180 if self._scopes.is_empty() {
10181 self._scopes
10182 .insert(Scope::CloudPlatform.as_ref().to_string());
10183 }
10184
10185 #[allow(clippy::single_element_loop)]
10186 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10187 url = params.uri_replacement(url, param_name, find_this, true);
10188 }
10189 {
10190 let to_remove = ["parent"];
10191 params.remove_params(&to_remove);
10192 }
10193
10194 let url = params.parse_with_url(&url);
10195
10196 loop {
10197 let token = match self
10198 .hub
10199 .auth
10200 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10201 .await
10202 {
10203 Ok(token) => token,
10204 Err(e) => match dlg.token(e) {
10205 Ok(token) => token,
10206 Err(e) => {
10207 dlg.finished(false);
10208 return Err(common::Error::MissingToken(e));
10209 }
10210 },
10211 };
10212 let mut req_result = {
10213 let client = &self.hub.client;
10214 dlg.pre_request();
10215 let mut req_builder = hyper::Request::builder()
10216 .method(hyper::Method::GET)
10217 .uri(url.as_str())
10218 .header(USER_AGENT, self.hub._user_agent.clone());
10219
10220 if let Some(token) = token.as_ref() {
10221 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10222 }
10223
10224 let request = req_builder
10225 .header(CONTENT_LENGTH, 0_u64)
10226 .body(common::to_body::<String>(None));
10227
10228 client.request(request.unwrap()).await
10229 };
10230
10231 match req_result {
10232 Err(err) => {
10233 if let common::Retry::After(d) = dlg.http_error(&err) {
10234 sleep(d).await;
10235 continue;
10236 }
10237 dlg.finished(false);
10238 return Err(common::Error::HttpError(err));
10239 }
10240 Ok(res) => {
10241 let (mut parts, body) = res.into_parts();
10242 let mut body = common::Body::new(body);
10243 if !parts.status.is_success() {
10244 let bytes = common::to_bytes(body).await.unwrap_or_default();
10245 let error = serde_json::from_str(&common::to_string(&bytes));
10246 let response = common::to_response(parts, bytes.into());
10247
10248 if let common::Retry::After(d) =
10249 dlg.http_failure(&response, error.as_ref().ok())
10250 {
10251 sleep(d).await;
10252 continue;
10253 }
10254
10255 dlg.finished(false);
10256
10257 return Err(match error {
10258 Ok(value) => common::Error::BadRequest(value),
10259 _ => common::Error::Failure(response),
10260 });
10261 }
10262 let response = {
10263 let bytes = common::to_bytes(body).await.unwrap_or_default();
10264 let encoded = common::to_string(&bytes);
10265 match serde_json::from_str(&encoded) {
10266 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10267 Err(error) => {
10268 dlg.response_json_decode_error(&encoded, &error);
10269 return Err(common::Error::JsonDecodeError(
10270 encoded.to_string(),
10271 error,
10272 ));
10273 }
10274 }
10275 };
10276
10277 dlg.finished(true);
10278 return Ok(response);
10279 }
10280 }
10281 }
10282 }
10283
10284 /// Required. Parent value for ListNfsSharesRequest.
10285 ///
10286 /// Sets the *parent* path property to the given value.
10287 ///
10288 /// Even though the property as already been set when instantiating this call,
10289 /// we provide this method for API completeness.
10290 pub fn parent(mut self, new_value: &str) -> ProjectLocationNfsShareListCall<'a, C> {
10291 self._parent = new_value.to_string();
10292 self
10293 }
10294 /// A token identifying a page of results from the server.
10295 ///
10296 /// Sets the *page token* query property to the given value.
10297 pub fn page_token(mut self, new_value: &str) -> ProjectLocationNfsShareListCall<'a, C> {
10298 self._page_token = Some(new_value.to_string());
10299 self
10300 }
10301 /// Requested page size. The server might return fewer items than requested. If unspecified, server will pick an appropriate default.
10302 ///
10303 /// Sets the *page size* query property to the given value.
10304 pub fn page_size(mut self, new_value: i32) -> ProjectLocationNfsShareListCall<'a, C> {
10305 self._page_size = Some(new_value);
10306 self
10307 }
10308 /// List filter.
10309 ///
10310 /// Sets the *filter* query property to the given value.
10311 pub fn filter(mut self, new_value: &str) -> ProjectLocationNfsShareListCall<'a, C> {
10312 self._filter = Some(new_value.to_string());
10313 self
10314 }
10315 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10316 /// while executing the actual API request.
10317 ///
10318 /// ````text
10319 /// It should be used to handle progress information, and to implement a certain level of resilience.
10320 /// ````
10321 ///
10322 /// Sets the *delegate* property to the given value.
10323 pub fn delegate(
10324 mut self,
10325 new_value: &'a mut dyn common::Delegate,
10326 ) -> ProjectLocationNfsShareListCall<'a, C> {
10327 self._delegate = Some(new_value);
10328 self
10329 }
10330
10331 /// Set any additional parameter of the query string used in the request.
10332 /// It should be used to set parameters which are not yet available through their own
10333 /// setters.
10334 ///
10335 /// Please note that this method must not be used to set any of the known parameters
10336 /// which have their own setter method. If done anyway, the request will fail.
10337 ///
10338 /// # Additional Parameters
10339 ///
10340 /// * *$.xgafv* (query-string) - V1 error format.
10341 /// * *access_token* (query-string) - OAuth access token.
10342 /// * *alt* (query-string) - Data format for response.
10343 /// * *callback* (query-string) - JSONP
10344 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10345 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10346 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10347 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10348 /// * *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.
10349 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10350 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10351 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNfsShareListCall<'a, C>
10352 where
10353 T: AsRef<str>,
10354 {
10355 self._additional_params
10356 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10357 self
10358 }
10359
10360 /// Identifies the authorization scope for the method you are building.
10361 ///
10362 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10363 /// [`Scope::CloudPlatform`].
10364 ///
10365 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10366 /// tokens for more than one scope.
10367 ///
10368 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10369 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10370 /// sufficient, a read-write scope will do as well.
10371 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNfsShareListCall<'a, C>
10372 where
10373 St: AsRef<str>,
10374 {
10375 self._scopes.insert(String::from(scope.as_ref()));
10376 self
10377 }
10378 /// Identifies the authorization scope(s) for the method you are building.
10379 ///
10380 /// See [`Self::add_scope()`] for details.
10381 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNfsShareListCall<'a, C>
10382 where
10383 I: IntoIterator<Item = St>,
10384 St: AsRef<str>,
10385 {
10386 self._scopes
10387 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10388 self
10389 }
10390
10391 /// Removes all scopes, and no default scope will be used either.
10392 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10393 /// for details).
10394 pub fn clear_scopes(mut self) -> ProjectLocationNfsShareListCall<'a, C> {
10395 self._scopes.clear();
10396 self
10397 }
10398}
10399
10400/// Update details of a single NFS share.
10401///
10402/// A builder for the *locations.nfsShares.patch* method supported by a *project* resource.
10403/// It is not used directly, but through a [`ProjectMethods`] instance.
10404///
10405/// # Example
10406///
10407/// Instantiate a resource method builder
10408///
10409/// ```test_harness,no_run
10410/// # extern crate hyper;
10411/// # extern crate hyper_rustls;
10412/// # extern crate google_baremetalsolution2 as baremetalsolution2;
10413/// use baremetalsolution2::api::NfsShare;
10414/// # async fn dox() {
10415/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10416///
10417/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10418/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10419/// # secret,
10420/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10421/// # ).build().await.unwrap();
10422///
10423/// # let client = hyper_util::client::legacy::Client::builder(
10424/// # hyper_util::rt::TokioExecutor::new()
10425/// # )
10426/// # .build(
10427/// # hyper_rustls::HttpsConnectorBuilder::new()
10428/// # .with_native_roots()
10429/// # .unwrap()
10430/// # .https_or_http()
10431/// # .enable_http1()
10432/// # .build()
10433/// # );
10434/// # let mut hub = Baremetalsolution::new(client, auth);
10435/// // As the method needs a request, you would usually fill it with the desired information
10436/// // into the respective structure. Some of the parts shown here might not be applicable !
10437/// // Values shown here are possibly random and not representative !
10438/// let mut req = NfsShare::default();
10439///
10440/// // You can configure optional parameters by calling the respective setters at will, and
10441/// // execute the final call using `doit()`.
10442/// // Values shown here are possibly random and not representative !
10443/// let result = hub.projects().locations_nfs_shares_patch(req, "name")
10444/// .update_mask(FieldMask::new::<&str>(&[]))
10445/// .doit().await;
10446/// # }
10447/// ```
10448pub struct ProjectLocationNfsSharePatchCall<'a, C>
10449where
10450 C: 'a,
10451{
10452 hub: &'a Baremetalsolution<C>,
10453 _request: NfsShare,
10454 _name: String,
10455 _update_mask: Option<common::FieldMask>,
10456 _delegate: Option<&'a mut dyn common::Delegate>,
10457 _additional_params: HashMap<String, String>,
10458 _scopes: BTreeSet<String>,
10459}
10460
10461impl<'a, C> common::CallBuilder for ProjectLocationNfsSharePatchCall<'a, C> {}
10462
10463impl<'a, C> ProjectLocationNfsSharePatchCall<'a, C>
10464where
10465 C: common::Connector,
10466{
10467 /// Perform the operation you have build so far.
10468 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10469 use std::borrow::Cow;
10470 use std::io::{Read, Seek};
10471
10472 use common::{url::Params, ToParts};
10473 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10474
10475 let mut dd = common::DefaultDelegate;
10476 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10477 dlg.begin(common::MethodInfo {
10478 id: "baremetalsolution.projects.locations.nfsShares.patch",
10479 http_method: hyper::Method::PATCH,
10480 });
10481
10482 for &field in ["alt", "name", "updateMask"].iter() {
10483 if self._additional_params.contains_key(field) {
10484 dlg.finished(false);
10485 return Err(common::Error::FieldClash(field));
10486 }
10487 }
10488
10489 let mut params = Params::with_capacity(5 + self._additional_params.len());
10490 params.push("name", self._name);
10491 if let Some(value) = self._update_mask.as_ref() {
10492 params.push("updateMask", value.to_string());
10493 }
10494
10495 params.extend(self._additional_params.iter());
10496
10497 params.push("alt", "json");
10498 let mut url = self.hub._base_url.clone() + "v2/{+name}";
10499 if self._scopes.is_empty() {
10500 self._scopes
10501 .insert(Scope::CloudPlatform.as_ref().to_string());
10502 }
10503
10504 #[allow(clippy::single_element_loop)]
10505 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10506 url = params.uri_replacement(url, param_name, find_this, true);
10507 }
10508 {
10509 let to_remove = ["name"];
10510 params.remove_params(&to_remove);
10511 }
10512
10513 let url = params.parse_with_url(&url);
10514
10515 let mut json_mime_type = mime::APPLICATION_JSON;
10516 let mut request_value_reader = {
10517 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10518 common::remove_json_null_values(&mut value);
10519 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10520 serde_json::to_writer(&mut dst, &value).unwrap();
10521 dst
10522 };
10523 let request_size = request_value_reader
10524 .seek(std::io::SeekFrom::End(0))
10525 .unwrap();
10526 request_value_reader
10527 .seek(std::io::SeekFrom::Start(0))
10528 .unwrap();
10529
10530 loop {
10531 let token = match self
10532 .hub
10533 .auth
10534 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10535 .await
10536 {
10537 Ok(token) => token,
10538 Err(e) => match dlg.token(e) {
10539 Ok(token) => token,
10540 Err(e) => {
10541 dlg.finished(false);
10542 return Err(common::Error::MissingToken(e));
10543 }
10544 },
10545 };
10546 request_value_reader
10547 .seek(std::io::SeekFrom::Start(0))
10548 .unwrap();
10549 let mut req_result = {
10550 let client = &self.hub.client;
10551 dlg.pre_request();
10552 let mut req_builder = hyper::Request::builder()
10553 .method(hyper::Method::PATCH)
10554 .uri(url.as_str())
10555 .header(USER_AGENT, self.hub._user_agent.clone());
10556
10557 if let Some(token) = token.as_ref() {
10558 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10559 }
10560
10561 let request = req_builder
10562 .header(CONTENT_TYPE, json_mime_type.to_string())
10563 .header(CONTENT_LENGTH, request_size as u64)
10564 .body(common::to_body(
10565 request_value_reader.get_ref().clone().into(),
10566 ));
10567
10568 client.request(request.unwrap()).await
10569 };
10570
10571 match req_result {
10572 Err(err) => {
10573 if let common::Retry::After(d) = dlg.http_error(&err) {
10574 sleep(d).await;
10575 continue;
10576 }
10577 dlg.finished(false);
10578 return Err(common::Error::HttpError(err));
10579 }
10580 Ok(res) => {
10581 let (mut parts, body) = res.into_parts();
10582 let mut body = common::Body::new(body);
10583 if !parts.status.is_success() {
10584 let bytes = common::to_bytes(body).await.unwrap_or_default();
10585 let error = serde_json::from_str(&common::to_string(&bytes));
10586 let response = common::to_response(parts, bytes.into());
10587
10588 if let common::Retry::After(d) =
10589 dlg.http_failure(&response, error.as_ref().ok())
10590 {
10591 sleep(d).await;
10592 continue;
10593 }
10594
10595 dlg.finished(false);
10596
10597 return Err(match error {
10598 Ok(value) => common::Error::BadRequest(value),
10599 _ => common::Error::Failure(response),
10600 });
10601 }
10602 let response = {
10603 let bytes = common::to_bytes(body).await.unwrap_or_default();
10604 let encoded = common::to_string(&bytes);
10605 match serde_json::from_str(&encoded) {
10606 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10607 Err(error) => {
10608 dlg.response_json_decode_error(&encoded, &error);
10609 return Err(common::Error::JsonDecodeError(
10610 encoded.to_string(),
10611 error,
10612 ));
10613 }
10614 }
10615 };
10616
10617 dlg.finished(true);
10618 return Ok(response);
10619 }
10620 }
10621 }
10622 }
10623
10624 ///
10625 /// Sets the *request* property to the given value.
10626 ///
10627 /// Even though the property as already been set when instantiating this call,
10628 /// we provide this method for API completeness.
10629 pub fn request(mut self, new_value: NfsShare) -> ProjectLocationNfsSharePatchCall<'a, C> {
10630 self._request = new_value;
10631 self
10632 }
10633 /// Immutable. The name of the NFS share.
10634 ///
10635 /// Sets the *name* path property to the given value.
10636 ///
10637 /// Even though the property as already been set when instantiating this call,
10638 /// we provide this method for API completeness.
10639 pub fn name(mut self, new_value: &str) -> ProjectLocationNfsSharePatchCall<'a, C> {
10640 self._name = new_value.to_string();
10641 self
10642 }
10643 /// The list of fields to update. The only currently supported fields are: `labels` `allowed_clients`
10644 ///
10645 /// Sets the *update mask* query property to the given value.
10646 pub fn update_mask(
10647 mut self,
10648 new_value: common::FieldMask,
10649 ) -> ProjectLocationNfsSharePatchCall<'a, C> {
10650 self._update_mask = Some(new_value);
10651 self
10652 }
10653 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10654 /// while executing the actual API request.
10655 ///
10656 /// ````text
10657 /// It should be used to handle progress information, and to implement a certain level of resilience.
10658 /// ````
10659 ///
10660 /// Sets the *delegate* property to the given value.
10661 pub fn delegate(
10662 mut self,
10663 new_value: &'a mut dyn common::Delegate,
10664 ) -> ProjectLocationNfsSharePatchCall<'a, C> {
10665 self._delegate = Some(new_value);
10666 self
10667 }
10668
10669 /// Set any additional parameter of the query string used in the request.
10670 /// It should be used to set parameters which are not yet available through their own
10671 /// setters.
10672 ///
10673 /// Please note that this method must not be used to set any of the known parameters
10674 /// which have their own setter method. If done anyway, the request will fail.
10675 ///
10676 /// # Additional Parameters
10677 ///
10678 /// * *$.xgafv* (query-string) - V1 error format.
10679 /// * *access_token* (query-string) - OAuth access token.
10680 /// * *alt* (query-string) - Data format for response.
10681 /// * *callback* (query-string) - JSONP
10682 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10683 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10684 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10685 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10686 /// * *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.
10687 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10688 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10689 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNfsSharePatchCall<'a, C>
10690 where
10691 T: AsRef<str>,
10692 {
10693 self._additional_params
10694 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10695 self
10696 }
10697
10698 /// Identifies the authorization scope for the method you are building.
10699 ///
10700 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10701 /// [`Scope::CloudPlatform`].
10702 ///
10703 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10704 /// tokens for more than one scope.
10705 ///
10706 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10707 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10708 /// sufficient, a read-write scope will do as well.
10709 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNfsSharePatchCall<'a, C>
10710 where
10711 St: AsRef<str>,
10712 {
10713 self._scopes.insert(String::from(scope.as_ref()));
10714 self
10715 }
10716 /// Identifies the authorization scope(s) for the method you are building.
10717 ///
10718 /// See [`Self::add_scope()`] for details.
10719 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNfsSharePatchCall<'a, C>
10720 where
10721 I: IntoIterator<Item = St>,
10722 St: AsRef<str>,
10723 {
10724 self._scopes
10725 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10726 self
10727 }
10728
10729 /// Removes all scopes, and no default scope will be used either.
10730 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10731 /// for details).
10732 pub fn clear_scopes(mut self) -> ProjectLocationNfsSharePatchCall<'a, C> {
10733 self._scopes.clear();
10734 self
10735 }
10736}
10737
10738/// RenameNfsShare sets a new name for an nfsshare. Use with caution, previous names become immediately invalidated.
10739///
10740/// A builder for the *locations.nfsShares.rename* method supported by a *project* resource.
10741/// It is not used directly, but through a [`ProjectMethods`] instance.
10742///
10743/// # Example
10744///
10745/// Instantiate a resource method builder
10746///
10747/// ```test_harness,no_run
10748/// # extern crate hyper;
10749/// # extern crate hyper_rustls;
10750/// # extern crate google_baremetalsolution2 as baremetalsolution2;
10751/// use baremetalsolution2::api::RenameNfsShareRequest;
10752/// # async fn dox() {
10753/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10754///
10755/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10756/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10757/// # secret,
10758/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10759/// # ).build().await.unwrap();
10760///
10761/// # let client = hyper_util::client::legacy::Client::builder(
10762/// # hyper_util::rt::TokioExecutor::new()
10763/// # )
10764/// # .build(
10765/// # hyper_rustls::HttpsConnectorBuilder::new()
10766/// # .with_native_roots()
10767/// # .unwrap()
10768/// # .https_or_http()
10769/// # .enable_http1()
10770/// # .build()
10771/// # );
10772/// # let mut hub = Baremetalsolution::new(client, auth);
10773/// // As the method needs a request, you would usually fill it with the desired information
10774/// // into the respective structure. Some of the parts shown here might not be applicable !
10775/// // Values shown here are possibly random and not representative !
10776/// let mut req = RenameNfsShareRequest::default();
10777///
10778/// // You can configure optional parameters by calling the respective setters at will, and
10779/// // execute the final call using `doit()`.
10780/// // Values shown here are possibly random and not representative !
10781/// let result = hub.projects().locations_nfs_shares_rename(req, "name")
10782/// .doit().await;
10783/// # }
10784/// ```
10785pub struct ProjectLocationNfsShareRenameCall<'a, C>
10786where
10787 C: 'a,
10788{
10789 hub: &'a Baremetalsolution<C>,
10790 _request: RenameNfsShareRequest,
10791 _name: String,
10792 _delegate: Option<&'a mut dyn common::Delegate>,
10793 _additional_params: HashMap<String, String>,
10794 _scopes: BTreeSet<String>,
10795}
10796
10797impl<'a, C> common::CallBuilder for ProjectLocationNfsShareRenameCall<'a, C> {}
10798
10799impl<'a, C> ProjectLocationNfsShareRenameCall<'a, C>
10800where
10801 C: common::Connector,
10802{
10803 /// Perform the operation you have build so far.
10804 pub async fn doit(mut self) -> common::Result<(common::Response, NfsShare)> {
10805 use std::borrow::Cow;
10806 use std::io::{Read, Seek};
10807
10808 use common::{url::Params, ToParts};
10809 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10810
10811 let mut dd = common::DefaultDelegate;
10812 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10813 dlg.begin(common::MethodInfo {
10814 id: "baremetalsolution.projects.locations.nfsShares.rename",
10815 http_method: hyper::Method::POST,
10816 });
10817
10818 for &field in ["alt", "name"].iter() {
10819 if self._additional_params.contains_key(field) {
10820 dlg.finished(false);
10821 return Err(common::Error::FieldClash(field));
10822 }
10823 }
10824
10825 let mut params = Params::with_capacity(4 + self._additional_params.len());
10826 params.push("name", self._name);
10827
10828 params.extend(self._additional_params.iter());
10829
10830 params.push("alt", "json");
10831 let mut url = self.hub._base_url.clone() + "v2/{+name}:rename";
10832 if self._scopes.is_empty() {
10833 self._scopes
10834 .insert(Scope::CloudPlatform.as_ref().to_string());
10835 }
10836
10837 #[allow(clippy::single_element_loop)]
10838 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10839 url = params.uri_replacement(url, param_name, find_this, true);
10840 }
10841 {
10842 let to_remove = ["name"];
10843 params.remove_params(&to_remove);
10844 }
10845
10846 let url = params.parse_with_url(&url);
10847
10848 let mut json_mime_type = mime::APPLICATION_JSON;
10849 let mut request_value_reader = {
10850 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10851 common::remove_json_null_values(&mut value);
10852 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10853 serde_json::to_writer(&mut dst, &value).unwrap();
10854 dst
10855 };
10856 let request_size = request_value_reader
10857 .seek(std::io::SeekFrom::End(0))
10858 .unwrap();
10859 request_value_reader
10860 .seek(std::io::SeekFrom::Start(0))
10861 .unwrap();
10862
10863 loop {
10864 let token = match self
10865 .hub
10866 .auth
10867 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10868 .await
10869 {
10870 Ok(token) => token,
10871 Err(e) => match dlg.token(e) {
10872 Ok(token) => token,
10873 Err(e) => {
10874 dlg.finished(false);
10875 return Err(common::Error::MissingToken(e));
10876 }
10877 },
10878 };
10879 request_value_reader
10880 .seek(std::io::SeekFrom::Start(0))
10881 .unwrap();
10882 let mut req_result = {
10883 let client = &self.hub.client;
10884 dlg.pre_request();
10885 let mut req_builder = hyper::Request::builder()
10886 .method(hyper::Method::POST)
10887 .uri(url.as_str())
10888 .header(USER_AGENT, self.hub._user_agent.clone());
10889
10890 if let Some(token) = token.as_ref() {
10891 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10892 }
10893
10894 let request = req_builder
10895 .header(CONTENT_TYPE, json_mime_type.to_string())
10896 .header(CONTENT_LENGTH, request_size as u64)
10897 .body(common::to_body(
10898 request_value_reader.get_ref().clone().into(),
10899 ));
10900
10901 client.request(request.unwrap()).await
10902 };
10903
10904 match req_result {
10905 Err(err) => {
10906 if let common::Retry::After(d) = dlg.http_error(&err) {
10907 sleep(d).await;
10908 continue;
10909 }
10910 dlg.finished(false);
10911 return Err(common::Error::HttpError(err));
10912 }
10913 Ok(res) => {
10914 let (mut parts, body) = res.into_parts();
10915 let mut body = common::Body::new(body);
10916 if !parts.status.is_success() {
10917 let bytes = common::to_bytes(body).await.unwrap_or_default();
10918 let error = serde_json::from_str(&common::to_string(&bytes));
10919 let response = common::to_response(parts, bytes.into());
10920
10921 if let common::Retry::After(d) =
10922 dlg.http_failure(&response, error.as_ref().ok())
10923 {
10924 sleep(d).await;
10925 continue;
10926 }
10927
10928 dlg.finished(false);
10929
10930 return Err(match error {
10931 Ok(value) => common::Error::BadRequest(value),
10932 _ => common::Error::Failure(response),
10933 });
10934 }
10935 let response = {
10936 let bytes = common::to_bytes(body).await.unwrap_or_default();
10937 let encoded = common::to_string(&bytes);
10938 match serde_json::from_str(&encoded) {
10939 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10940 Err(error) => {
10941 dlg.response_json_decode_error(&encoded, &error);
10942 return Err(common::Error::JsonDecodeError(
10943 encoded.to_string(),
10944 error,
10945 ));
10946 }
10947 }
10948 };
10949
10950 dlg.finished(true);
10951 return Ok(response);
10952 }
10953 }
10954 }
10955 }
10956
10957 ///
10958 /// Sets the *request* property to the given value.
10959 ///
10960 /// Even though the property as already been set when instantiating this call,
10961 /// we provide this method for API completeness.
10962 pub fn request(
10963 mut self,
10964 new_value: RenameNfsShareRequest,
10965 ) -> ProjectLocationNfsShareRenameCall<'a, C> {
10966 self._request = new_value;
10967 self
10968 }
10969 /// Required. The `name` field is used to identify the nfsshare. Format: projects/{project}/locations/{location}/nfsshares/{nfsshare}
10970 ///
10971 /// Sets the *name* path property to the given value.
10972 ///
10973 /// Even though the property as already been set when instantiating this call,
10974 /// we provide this method for API completeness.
10975 pub fn name(mut self, new_value: &str) -> ProjectLocationNfsShareRenameCall<'a, C> {
10976 self._name = new_value.to_string();
10977 self
10978 }
10979 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10980 /// while executing the actual API request.
10981 ///
10982 /// ````text
10983 /// It should be used to handle progress information, and to implement a certain level of resilience.
10984 /// ````
10985 ///
10986 /// Sets the *delegate* property to the given value.
10987 pub fn delegate(
10988 mut self,
10989 new_value: &'a mut dyn common::Delegate,
10990 ) -> ProjectLocationNfsShareRenameCall<'a, C> {
10991 self._delegate = Some(new_value);
10992 self
10993 }
10994
10995 /// Set any additional parameter of the query string used in the request.
10996 /// It should be used to set parameters which are not yet available through their own
10997 /// setters.
10998 ///
10999 /// Please note that this method must not be used to set any of the known parameters
11000 /// which have their own setter method. If done anyway, the request will fail.
11001 ///
11002 /// # Additional Parameters
11003 ///
11004 /// * *$.xgafv* (query-string) - V1 error format.
11005 /// * *access_token* (query-string) - OAuth access token.
11006 /// * *alt* (query-string) - Data format for response.
11007 /// * *callback* (query-string) - JSONP
11008 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11009 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11010 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11011 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11012 /// * *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.
11013 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11014 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11015 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNfsShareRenameCall<'a, C>
11016 where
11017 T: AsRef<str>,
11018 {
11019 self._additional_params
11020 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11021 self
11022 }
11023
11024 /// Identifies the authorization scope for the method you are building.
11025 ///
11026 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11027 /// [`Scope::CloudPlatform`].
11028 ///
11029 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11030 /// tokens for more than one scope.
11031 ///
11032 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11033 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11034 /// sufficient, a read-write scope will do as well.
11035 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNfsShareRenameCall<'a, C>
11036 where
11037 St: AsRef<str>,
11038 {
11039 self._scopes.insert(String::from(scope.as_ref()));
11040 self
11041 }
11042 /// Identifies the authorization scope(s) for the method you are building.
11043 ///
11044 /// See [`Self::add_scope()`] for details.
11045 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNfsShareRenameCall<'a, C>
11046 where
11047 I: IntoIterator<Item = St>,
11048 St: AsRef<str>,
11049 {
11050 self._scopes
11051 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11052 self
11053 }
11054
11055 /// Removes all scopes, and no default scope will be used either.
11056 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11057 /// for details).
11058 pub fn clear_scopes(mut self) -> ProjectLocationNfsShareRenameCall<'a, C> {
11059 self._scopes.clear();
11060 self
11061 }
11062}
11063
11064/// Get details about an operation.
11065///
11066/// A builder for the *locations.operations.get* method supported by a *project* resource.
11067/// It is not used directly, but through a [`ProjectMethods`] instance.
11068///
11069/// # Example
11070///
11071/// Instantiate a resource method builder
11072///
11073/// ```test_harness,no_run
11074/// # extern crate hyper;
11075/// # extern crate hyper_rustls;
11076/// # extern crate google_baremetalsolution2 as baremetalsolution2;
11077/// # async fn dox() {
11078/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11079///
11080/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11081/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11082/// # secret,
11083/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11084/// # ).build().await.unwrap();
11085///
11086/// # let client = hyper_util::client::legacy::Client::builder(
11087/// # hyper_util::rt::TokioExecutor::new()
11088/// # )
11089/// # .build(
11090/// # hyper_rustls::HttpsConnectorBuilder::new()
11091/// # .with_native_roots()
11092/// # .unwrap()
11093/// # .https_or_http()
11094/// # .enable_http1()
11095/// # .build()
11096/// # );
11097/// # let mut hub = Baremetalsolution::new(client, auth);
11098/// // You can configure optional parameters by calling the respective setters at will, and
11099/// // execute the final call using `doit()`.
11100/// // Values shown here are possibly random and not representative !
11101/// let result = hub.projects().locations_operations_get("name")
11102/// .doit().await;
11103/// # }
11104/// ```
11105pub struct ProjectLocationOperationGetCall<'a, C>
11106where
11107 C: 'a,
11108{
11109 hub: &'a Baremetalsolution<C>,
11110 _name: String,
11111 _delegate: Option<&'a mut dyn common::Delegate>,
11112 _additional_params: HashMap<String, String>,
11113 _scopes: BTreeSet<String>,
11114}
11115
11116impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
11117
11118impl<'a, C> ProjectLocationOperationGetCall<'a, C>
11119where
11120 C: common::Connector,
11121{
11122 /// Perform the operation you have build so far.
11123 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11124 use std::borrow::Cow;
11125 use std::io::{Read, Seek};
11126
11127 use common::{url::Params, ToParts};
11128 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11129
11130 let mut dd = common::DefaultDelegate;
11131 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11132 dlg.begin(common::MethodInfo {
11133 id: "baremetalsolution.projects.locations.operations.get",
11134 http_method: hyper::Method::GET,
11135 });
11136
11137 for &field in ["alt", "name"].iter() {
11138 if self._additional_params.contains_key(field) {
11139 dlg.finished(false);
11140 return Err(common::Error::FieldClash(field));
11141 }
11142 }
11143
11144 let mut params = Params::with_capacity(3 + self._additional_params.len());
11145 params.push("name", self._name);
11146
11147 params.extend(self._additional_params.iter());
11148
11149 params.push("alt", "json");
11150 let mut url = self.hub._base_url.clone() + "v2/{+name}";
11151 if self._scopes.is_empty() {
11152 self._scopes
11153 .insert(Scope::CloudPlatform.as_ref().to_string());
11154 }
11155
11156 #[allow(clippy::single_element_loop)]
11157 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11158 url = params.uri_replacement(url, param_name, find_this, true);
11159 }
11160 {
11161 let to_remove = ["name"];
11162 params.remove_params(&to_remove);
11163 }
11164
11165 let url = params.parse_with_url(&url);
11166
11167 loop {
11168 let token = match self
11169 .hub
11170 .auth
11171 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11172 .await
11173 {
11174 Ok(token) => token,
11175 Err(e) => match dlg.token(e) {
11176 Ok(token) => token,
11177 Err(e) => {
11178 dlg.finished(false);
11179 return Err(common::Error::MissingToken(e));
11180 }
11181 },
11182 };
11183 let mut req_result = {
11184 let client = &self.hub.client;
11185 dlg.pre_request();
11186 let mut req_builder = hyper::Request::builder()
11187 .method(hyper::Method::GET)
11188 .uri(url.as_str())
11189 .header(USER_AGENT, self.hub._user_agent.clone());
11190
11191 if let Some(token) = token.as_ref() {
11192 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11193 }
11194
11195 let request = req_builder
11196 .header(CONTENT_LENGTH, 0_u64)
11197 .body(common::to_body::<String>(None));
11198
11199 client.request(request.unwrap()).await
11200 };
11201
11202 match req_result {
11203 Err(err) => {
11204 if let common::Retry::After(d) = dlg.http_error(&err) {
11205 sleep(d).await;
11206 continue;
11207 }
11208 dlg.finished(false);
11209 return Err(common::Error::HttpError(err));
11210 }
11211 Ok(res) => {
11212 let (mut parts, body) = res.into_parts();
11213 let mut body = common::Body::new(body);
11214 if !parts.status.is_success() {
11215 let bytes = common::to_bytes(body).await.unwrap_or_default();
11216 let error = serde_json::from_str(&common::to_string(&bytes));
11217 let response = common::to_response(parts, bytes.into());
11218
11219 if let common::Retry::After(d) =
11220 dlg.http_failure(&response, error.as_ref().ok())
11221 {
11222 sleep(d).await;
11223 continue;
11224 }
11225
11226 dlg.finished(false);
11227
11228 return Err(match error {
11229 Ok(value) => common::Error::BadRequest(value),
11230 _ => common::Error::Failure(response),
11231 });
11232 }
11233 let response = {
11234 let bytes = common::to_bytes(body).await.unwrap_or_default();
11235 let encoded = common::to_string(&bytes);
11236 match serde_json::from_str(&encoded) {
11237 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11238 Err(error) => {
11239 dlg.response_json_decode_error(&encoded, &error);
11240 return Err(common::Error::JsonDecodeError(
11241 encoded.to_string(),
11242 error,
11243 ));
11244 }
11245 }
11246 };
11247
11248 dlg.finished(true);
11249 return Ok(response);
11250 }
11251 }
11252 }
11253 }
11254
11255 /// The name of the operation resource.
11256 ///
11257 /// Sets the *name* path property to the given value.
11258 ///
11259 /// Even though the property as already been set when instantiating this call,
11260 /// we provide this method for API completeness.
11261 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
11262 self._name = new_value.to_string();
11263 self
11264 }
11265 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11266 /// while executing the actual API request.
11267 ///
11268 /// ````text
11269 /// It should be used to handle progress information, and to implement a certain level of resilience.
11270 /// ````
11271 ///
11272 /// Sets the *delegate* property to the given value.
11273 pub fn delegate(
11274 mut self,
11275 new_value: &'a mut dyn common::Delegate,
11276 ) -> ProjectLocationOperationGetCall<'a, C> {
11277 self._delegate = Some(new_value);
11278 self
11279 }
11280
11281 /// Set any additional parameter of the query string used in the request.
11282 /// It should be used to set parameters which are not yet available through their own
11283 /// setters.
11284 ///
11285 /// Please note that this method must not be used to set any of the known parameters
11286 /// which have their own setter method. If done anyway, the request will fail.
11287 ///
11288 /// # Additional Parameters
11289 ///
11290 /// * *$.xgafv* (query-string) - V1 error format.
11291 /// * *access_token* (query-string) - OAuth access token.
11292 /// * *alt* (query-string) - Data format for response.
11293 /// * *callback* (query-string) - JSONP
11294 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11295 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11296 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11297 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11298 /// * *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.
11299 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11300 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11301 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
11302 where
11303 T: AsRef<str>,
11304 {
11305 self._additional_params
11306 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11307 self
11308 }
11309
11310 /// Identifies the authorization scope for the method you are building.
11311 ///
11312 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11313 /// [`Scope::CloudPlatform`].
11314 ///
11315 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11316 /// tokens for more than one scope.
11317 ///
11318 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11319 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11320 /// sufficient, a read-write scope will do as well.
11321 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
11322 where
11323 St: AsRef<str>,
11324 {
11325 self._scopes.insert(String::from(scope.as_ref()));
11326 self
11327 }
11328 /// Identifies the authorization scope(s) for the method you are building.
11329 ///
11330 /// See [`Self::add_scope()`] for details.
11331 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
11332 where
11333 I: IntoIterator<Item = St>,
11334 St: AsRef<str>,
11335 {
11336 self._scopes
11337 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11338 self
11339 }
11340
11341 /// Removes all scopes, and no default scope will be used either.
11342 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11343 /// for details).
11344 pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
11345 self._scopes.clear();
11346 self
11347 }
11348}
11349
11350/// Get details of a single OS image.
11351///
11352/// A builder for the *locations.osImages.get* method supported by a *project* resource.
11353/// It is not used directly, but through a [`ProjectMethods`] instance.
11354///
11355/// # Example
11356///
11357/// Instantiate a resource method builder
11358///
11359/// ```test_harness,no_run
11360/// # extern crate hyper;
11361/// # extern crate hyper_rustls;
11362/// # extern crate google_baremetalsolution2 as baremetalsolution2;
11363/// # async fn dox() {
11364/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11365///
11366/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11367/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11368/// # secret,
11369/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11370/// # ).build().await.unwrap();
11371///
11372/// # let client = hyper_util::client::legacy::Client::builder(
11373/// # hyper_util::rt::TokioExecutor::new()
11374/// # )
11375/// # .build(
11376/// # hyper_rustls::HttpsConnectorBuilder::new()
11377/// # .with_native_roots()
11378/// # .unwrap()
11379/// # .https_or_http()
11380/// # .enable_http1()
11381/// # .build()
11382/// # );
11383/// # let mut hub = Baremetalsolution::new(client, auth);
11384/// // You can configure optional parameters by calling the respective setters at will, and
11385/// // execute the final call using `doit()`.
11386/// // Values shown here are possibly random and not representative !
11387/// let result = hub.projects().locations_os_images_get("name")
11388/// .doit().await;
11389/// # }
11390/// ```
11391pub struct ProjectLocationOsImageGetCall<'a, C>
11392where
11393 C: 'a,
11394{
11395 hub: &'a Baremetalsolution<C>,
11396 _name: String,
11397 _delegate: Option<&'a mut dyn common::Delegate>,
11398 _additional_params: HashMap<String, String>,
11399 _scopes: BTreeSet<String>,
11400}
11401
11402impl<'a, C> common::CallBuilder for ProjectLocationOsImageGetCall<'a, C> {}
11403
11404impl<'a, C> ProjectLocationOsImageGetCall<'a, C>
11405where
11406 C: common::Connector,
11407{
11408 /// Perform the operation you have build so far.
11409 pub async fn doit(mut self) -> common::Result<(common::Response, OSImage)> {
11410 use std::borrow::Cow;
11411 use std::io::{Read, Seek};
11412
11413 use common::{url::Params, ToParts};
11414 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11415
11416 let mut dd = common::DefaultDelegate;
11417 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11418 dlg.begin(common::MethodInfo {
11419 id: "baremetalsolution.projects.locations.osImages.get",
11420 http_method: hyper::Method::GET,
11421 });
11422
11423 for &field in ["alt", "name"].iter() {
11424 if self._additional_params.contains_key(field) {
11425 dlg.finished(false);
11426 return Err(common::Error::FieldClash(field));
11427 }
11428 }
11429
11430 let mut params = Params::with_capacity(3 + self._additional_params.len());
11431 params.push("name", self._name);
11432
11433 params.extend(self._additional_params.iter());
11434
11435 params.push("alt", "json");
11436 let mut url = self.hub._base_url.clone() + "v2/{+name}";
11437 if self._scopes.is_empty() {
11438 self._scopes
11439 .insert(Scope::CloudPlatform.as_ref().to_string());
11440 }
11441
11442 #[allow(clippy::single_element_loop)]
11443 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11444 url = params.uri_replacement(url, param_name, find_this, true);
11445 }
11446 {
11447 let to_remove = ["name"];
11448 params.remove_params(&to_remove);
11449 }
11450
11451 let url = params.parse_with_url(&url);
11452
11453 loop {
11454 let token = match self
11455 .hub
11456 .auth
11457 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11458 .await
11459 {
11460 Ok(token) => token,
11461 Err(e) => match dlg.token(e) {
11462 Ok(token) => token,
11463 Err(e) => {
11464 dlg.finished(false);
11465 return Err(common::Error::MissingToken(e));
11466 }
11467 },
11468 };
11469 let mut req_result = {
11470 let client = &self.hub.client;
11471 dlg.pre_request();
11472 let mut req_builder = hyper::Request::builder()
11473 .method(hyper::Method::GET)
11474 .uri(url.as_str())
11475 .header(USER_AGENT, self.hub._user_agent.clone());
11476
11477 if let Some(token) = token.as_ref() {
11478 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11479 }
11480
11481 let request = req_builder
11482 .header(CONTENT_LENGTH, 0_u64)
11483 .body(common::to_body::<String>(None));
11484
11485 client.request(request.unwrap()).await
11486 };
11487
11488 match req_result {
11489 Err(err) => {
11490 if let common::Retry::After(d) = dlg.http_error(&err) {
11491 sleep(d).await;
11492 continue;
11493 }
11494 dlg.finished(false);
11495 return Err(common::Error::HttpError(err));
11496 }
11497 Ok(res) => {
11498 let (mut parts, body) = res.into_parts();
11499 let mut body = common::Body::new(body);
11500 if !parts.status.is_success() {
11501 let bytes = common::to_bytes(body).await.unwrap_or_default();
11502 let error = serde_json::from_str(&common::to_string(&bytes));
11503 let response = common::to_response(parts, bytes.into());
11504
11505 if let common::Retry::After(d) =
11506 dlg.http_failure(&response, error.as_ref().ok())
11507 {
11508 sleep(d).await;
11509 continue;
11510 }
11511
11512 dlg.finished(false);
11513
11514 return Err(match error {
11515 Ok(value) => common::Error::BadRequest(value),
11516 _ => common::Error::Failure(response),
11517 });
11518 }
11519 let response = {
11520 let bytes = common::to_bytes(body).await.unwrap_or_default();
11521 let encoded = common::to_string(&bytes);
11522 match serde_json::from_str(&encoded) {
11523 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11524 Err(error) => {
11525 dlg.response_json_decode_error(&encoded, &error);
11526 return Err(common::Error::JsonDecodeError(
11527 encoded.to_string(),
11528 error,
11529 ));
11530 }
11531 }
11532 };
11533
11534 dlg.finished(true);
11535 return Ok(response);
11536 }
11537 }
11538 }
11539 }
11540
11541 /// Required. Name of the OS image.
11542 ///
11543 /// Sets the *name* path property to the given value.
11544 ///
11545 /// Even though the property as already been set when instantiating this call,
11546 /// we provide this method for API completeness.
11547 pub fn name(mut self, new_value: &str) -> ProjectLocationOsImageGetCall<'a, C> {
11548 self._name = new_value.to_string();
11549 self
11550 }
11551 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11552 /// while executing the actual API request.
11553 ///
11554 /// ````text
11555 /// It should be used to handle progress information, and to implement a certain level of resilience.
11556 /// ````
11557 ///
11558 /// Sets the *delegate* property to the given value.
11559 pub fn delegate(
11560 mut self,
11561 new_value: &'a mut dyn common::Delegate,
11562 ) -> ProjectLocationOsImageGetCall<'a, C> {
11563 self._delegate = Some(new_value);
11564 self
11565 }
11566
11567 /// Set any additional parameter of the query string used in the request.
11568 /// It should be used to set parameters which are not yet available through their own
11569 /// setters.
11570 ///
11571 /// Please note that this method must not be used to set any of the known parameters
11572 /// which have their own setter method. If done anyway, the request will fail.
11573 ///
11574 /// # Additional Parameters
11575 ///
11576 /// * *$.xgafv* (query-string) - V1 error format.
11577 /// * *access_token* (query-string) - OAuth access token.
11578 /// * *alt* (query-string) - Data format for response.
11579 /// * *callback* (query-string) - JSONP
11580 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11581 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11582 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11583 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11584 /// * *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.
11585 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11586 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11587 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOsImageGetCall<'a, C>
11588 where
11589 T: AsRef<str>,
11590 {
11591 self._additional_params
11592 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11593 self
11594 }
11595
11596 /// Identifies the authorization scope for the method you are building.
11597 ///
11598 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11599 /// [`Scope::CloudPlatform`].
11600 ///
11601 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11602 /// tokens for more than one scope.
11603 ///
11604 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11605 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11606 /// sufficient, a read-write scope will do as well.
11607 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOsImageGetCall<'a, C>
11608 where
11609 St: AsRef<str>,
11610 {
11611 self._scopes.insert(String::from(scope.as_ref()));
11612 self
11613 }
11614 /// Identifies the authorization scope(s) for the method you are building.
11615 ///
11616 /// See [`Self::add_scope()`] for details.
11617 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOsImageGetCall<'a, C>
11618 where
11619 I: IntoIterator<Item = St>,
11620 St: AsRef<str>,
11621 {
11622 self._scopes
11623 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11624 self
11625 }
11626
11627 /// Removes all scopes, and no default scope will be used either.
11628 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11629 /// for details).
11630 pub fn clear_scopes(mut self) -> ProjectLocationOsImageGetCall<'a, C> {
11631 self._scopes.clear();
11632 self
11633 }
11634}
11635
11636/// Retrieves the list of OS images which are currently approved.
11637///
11638/// A builder for the *locations.osImages.list* method supported by a *project* resource.
11639/// It is not used directly, but through a [`ProjectMethods`] instance.
11640///
11641/// # Example
11642///
11643/// Instantiate a resource method builder
11644///
11645/// ```test_harness,no_run
11646/// # extern crate hyper;
11647/// # extern crate hyper_rustls;
11648/// # extern crate google_baremetalsolution2 as baremetalsolution2;
11649/// # async fn dox() {
11650/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11651///
11652/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11653/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11654/// # secret,
11655/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11656/// # ).build().await.unwrap();
11657///
11658/// # let client = hyper_util::client::legacy::Client::builder(
11659/// # hyper_util::rt::TokioExecutor::new()
11660/// # )
11661/// # .build(
11662/// # hyper_rustls::HttpsConnectorBuilder::new()
11663/// # .with_native_roots()
11664/// # .unwrap()
11665/// # .https_or_http()
11666/// # .enable_http1()
11667/// # .build()
11668/// # );
11669/// # let mut hub = Baremetalsolution::new(client, auth);
11670/// // You can configure optional parameters by calling the respective setters at will, and
11671/// // execute the final call using `doit()`.
11672/// // Values shown here are possibly random and not representative !
11673/// let result = hub.projects().locations_os_images_list("parent")
11674/// .page_token("sed")
11675/// .page_size(-61)
11676/// .doit().await;
11677/// # }
11678/// ```
11679pub struct ProjectLocationOsImageListCall<'a, C>
11680where
11681 C: 'a,
11682{
11683 hub: &'a Baremetalsolution<C>,
11684 _parent: String,
11685 _page_token: Option<String>,
11686 _page_size: Option<i32>,
11687 _delegate: Option<&'a mut dyn common::Delegate>,
11688 _additional_params: HashMap<String, String>,
11689 _scopes: BTreeSet<String>,
11690}
11691
11692impl<'a, C> common::CallBuilder for ProjectLocationOsImageListCall<'a, C> {}
11693
11694impl<'a, C> ProjectLocationOsImageListCall<'a, C>
11695where
11696 C: common::Connector,
11697{
11698 /// Perform the operation you have build so far.
11699 pub async fn doit(mut self) -> common::Result<(common::Response, ListOSImagesResponse)> {
11700 use std::borrow::Cow;
11701 use std::io::{Read, Seek};
11702
11703 use common::{url::Params, ToParts};
11704 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11705
11706 let mut dd = common::DefaultDelegate;
11707 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11708 dlg.begin(common::MethodInfo {
11709 id: "baremetalsolution.projects.locations.osImages.list",
11710 http_method: hyper::Method::GET,
11711 });
11712
11713 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
11714 if self._additional_params.contains_key(field) {
11715 dlg.finished(false);
11716 return Err(common::Error::FieldClash(field));
11717 }
11718 }
11719
11720 let mut params = Params::with_capacity(5 + self._additional_params.len());
11721 params.push("parent", self._parent);
11722 if let Some(value) = self._page_token.as_ref() {
11723 params.push("pageToken", value);
11724 }
11725 if let Some(value) = self._page_size.as_ref() {
11726 params.push("pageSize", value.to_string());
11727 }
11728
11729 params.extend(self._additional_params.iter());
11730
11731 params.push("alt", "json");
11732 let mut url = self.hub._base_url.clone() + "v2/{+parent}/osImages";
11733 if self._scopes.is_empty() {
11734 self._scopes
11735 .insert(Scope::CloudPlatform.as_ref().to_string());
11736 }
11737
11738 #[allow(clippy::single_element_loop)]
11739 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11740 url = params.uri_replacement(url, param_name, find_this, true);
11741 }
11742 {
11743 let to_remove = ["parent"];
11744 params.remove_params(&to_remove);
11745 }
11746
11747 let url = params.parse_with_url(&url);
11748
11749 loop {
11750 let token = match self
11751 .hub
11752 .auth
11753 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11754 .await
11755 {
11756 Ok(token) => token,
11757 Err(e) => match dlg.token(e) {
11758 Ok(token) => token,
11759 Err(e) => {
11760 dlg.finished(false);
11761 return Err(common::Error::MissingToken(e));
11762 }
11763 },
11764 };
11765 let mut req_result = {
11766 let client = &self.hub.client;
11767 dlg.pre_request();
11768 let mut req_builder = hyper::Request::builder()
11769 .method(hyper::Method::GET)
11770 .uri(url.as_str())
11771 .header(USER_AGENT, self.hub._user_agent.clone());
11772
11773 if let Some(token) = token.as_ref() {
11774 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11775 }
11776
11777 let request = req_builder
11778 .header(CONTENT_LENGTH, 0_u64)
11779 .body(common::to_body::<String>(None));
11780
11781 client.request(request.unwrap()).await
11782 };
11783
11784 match req_result {
11785 Err(err) => {
11786 if let common::Retry::After(d) = dlg.http_error(&err) {
11787 sleep(d).await;
11788 continue;
11789 }
11790 dlg.finished(false);
11791 return Err(common::Error::HttpError(err));
11792 }
11793 Ok(res) => {
11794 let (mut parts, body) = res.into_parts();
11795 let mut body = common::Body::new(body);
11796 if !parts.status.is_success() {
11797 let bytes = common::to_bytes(body).await.unwrap_or_default();
11798 let error = serde_json::from_str(&common::to_string(&bytes));
11799 let response = common::to_response(parts, bytes.into());
11800
11801 if let common::Retry::After(d) =
11802 dlg.http_failure(&response, error.as_ref().ok())
11803 {
11804 sleep(d).await;
11805 continue;
11806 }
11807
11808 dlg.finished(false);
11809
11810 return Err(match error {
11811 Ok(value) => common::Error::BadRequest(value),
11812 _ => common::Error::Failure(response),
11813 });
11814 }
11815 let response = {
11816 let bytes = common::to_bytes(body).await.unwrap_or_default();
11817 let encoded = common::to_string(&bytes);
11818 match serde_json::from_str(&encoded) {
11819 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11820 Err(error) => {
11821 dlg.response_json_decode_error(&encoded, &error);
11822 return Err(common::Error::JsonDecodeError(
11823 encoded.to_string(),
11824 error,
11825 ));
11826 }
11827 }
11828 };
11829
11830 dlg.finished(true);
11831 return Ok(response);
11832 }
11833 }
11834 }
11835 }
11836
11837 /// Required. Parent value for ListOSImagesRequest.
11838 ///
11839 /// Sets the *parent* path property to the given value.
11840 ///
11841 /// Even though the property as already been set when instantiating this call,
11842 /// we provide this method for API completeness.
11843 pub fn parent(mut self, new_value: &str) -> ProjectLocationOsImageListCall<'a, C> {
11844 self._parent = new_value.to_string();
11845 self
11846 }
11847 /// A token identifying a page of results from the server.
11848 ///
11849 /// Sets the *page token* query property to the given value.
11850 pub fn page_token(mut self, new_value: &str) -> ProjectLocationOsImageListCall<'a, C> {
11851 self._page_token = Some(new_value.to_string());
11852 self
11853 }
11854 /// 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.
11855 ///
11856 /// Sets the *page size* query property to the given value.
11857 pub fn page_size(mut self, new_value: i32) -> ProjectLocationOsImageListCall<'a, C> {
11858 self._page_size = Some(new_value);
11859 self
11860 }
11861 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11862 /// while executing the actual API request.
11863 ///
11864 /// ````text
11865 /// It should be used to handle progress information, and to implement a certain level of resilience.
11866 /// ````
11867 ///
11868 /// Sets the *delegate* property to the given value.
11869 pub fn delegate(
11870 mut self,
11871 new_value: &'a mut dyn common::Delegate,
11872 ) -> ProjectLocationOsImageListCall<'a, C> {
11873 self._delegate = Some(new_value);
11874 self
11875 }
11876
11877 /// Set any additional parameter of the query string used in the request.
11878 /// It should be used to set parameters which are not yet available through their own
11879 /// setters.
11880 ///
11881 /// Please note that this method must not be used to set any of the known parameters
11882 /// which have their own setter method. If done anyway, the request will fail.
11883 ///
11884 /// # Additional Parameters
11885 ///
11886 /// * *$.xgafv* (query-string) - V1 error format.
11887 /// * *access_token* (query-string) - OAuth access token.
11888 /// * *alt* (query-string) - Data format for response.
11889 /// * *callback* (query-string) - JSONP
11890 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11891 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11892 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11893 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11894 /// * *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.
11895 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11896 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11897 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOsImageListCall<'a, C>
11898 where
11899 T: AsRef<str>,
11900 {
11901 self._additional_params
11902 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11903 self
11904 }
11905
11906 /// Identifies the authorization scope for the method you are building.
11907 ///
11908 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11909 /// [`Scope::CloudPlatform`].
11910 ///
11911 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11912 /// tokens for more than one scope.
11913 ///
11914 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11915 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11916 /// sufficient, a read-write scope will do as well.
11917 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOsImageListCall<'a, C>
11918 where
11919 St: AsRef<str>,
11920 {
11921 self._scopes.insert(String::from(scope.as_ref()));
11922 self
11923 }
11924 /// Identifies the authorization scope(s) for the method you are building.
11925 ///
11926 /// See [`Self::add_scope()`] for details.
11927 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOsImageListCall<'a, C>
11928 where
11929 I: IntoIterator<Item = St>,
11930 St: AsRef<str>,
11931 {
11932 self._scopes
11933 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11934 self
11935 }
11936
11937 /// Removes all scopes, and no default scope will be used either.
11938 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11939 /// for details).
11940 pub fn clear_scopes(mut self) -> ProjectLocationOsImageListCall<'a, C> {
11941 self._scopes.clear();
11942 self
11943 }
11944}
11945
11946/// Create new ProvisioningConfig.
11947///
11948/// A builder for the *locations.provisioningConfigs.create* method supported by a *project* resource.
11949/// It is not used directly, but through a [`ProjectMethods`] instance.
11950///
11951/// # Example
11952///
11953/// Instantiate a resource method builder
11954///
11955/// ```test_harness,no_run
11956/// # extern crate hyper;
11957/// # extern crate hyper_rustls;
11958/// # extern crate google_baremetalsolution2 as baremetalsolution2;
11959/// use baremetalsolution2::api::ProvisioningConfig;
11960/// # async fn dox() {
11961/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11962///
11963/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11964/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11965/// # secret,
11966/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11967/// # ).build().await.unwrap();
11968///
11969/// # let client = hyper_util::client::legacy::Client::builder(
11970/// # hyper_util::rt::TokioExecutor::new()
11971/// # )
11972/// # .build(
11973/// # hyper_rustls::HttpsConnectorBuilder::new()
11974/// # .with_native_roots()
11975/// # .unwrap()
11976/// # .https_or_http()
11977/// # .enable_http1()
11978/// # .build()
11979/// # );
11980/// # let mut hub = Baremetalsolution::new(client, auth);
11981/// // As the method needs a request, you would usually fill it with the desired information
11982/// // into the respective structure. Some of the parts shown here might not be applicable !
11983/// // Values shown here are possibly random and not representative !
11984/// let mut req = ProvisioningConfig::default();
11985///
11986/// // You can configure optional parameters by calling the respective setters at will, and
11987/// // execute the final call using `doit()`.
11988/// // Values shown here are possibly random and not representative !
11989/// let result = hub.projects().locations_provisioning_configs_create(req, "parent")
11990/// .email("kasd")
11991/// .doit().await;
11992/// # }
11993/// ```
11994pub struct ProjectLocationProvisioningConfigCreateCall<'a, C>
11995where
11996 C: 'a,
11997{
11998 hub: &'a Baremetalsolution<C>,
11999 _request: ProvisioningConfig,
12000 _parent: String,
12001 _email: Option<String>,
12002 _delegate: Option<&'a mut dyn common::Delegate>,
12003 _additional_params: HashMap<String, String>,
12004 _scopes: BTreeSet<String>,
12005}
12006
12007impl<'a, C> common::CallBuilder for ProjectLocationProvisioningConfigCreateCall<'a, C> {}
12008
12009impl<'a, C> ProjectLocationProvisioningConfigCreateCall<'a, C>
12010where
12011 C: common::Connector,
12012{
12013 /// Perform the operation you have build so far.
12014 pub async fn doit(mut self) -> common::Result<(common::Response, ProvisioningConfig)> {
12015 use std::borrow::Cow;
12016 use std::io::{Read, Seek};
12017
12018 use common::{url::Params, ToParts};
12019 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12020
12021 let mut dd = common::DefaultDelegate;
12022 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12023 dlg.begin(common::MethodInfo {
12024 id: "baremetalsolution.projects.locations.provisioningConfigs.create",
12025 http_method: hyper::Method::POST,
12026 });
12027
12028 for &field in ["alt", "parent", "email"].iter() {
12029 if self._additional_params.contains_key(field) {
12030 dlg.finished(false);
12031 return Err(common::Error::FieldClash(field));
12032 }
12033 }
12034
12035 let mut params = Params::with_capacity(5 + self._additional_params.len());
12036 params.push("parent", self._parent);
12037 if let Some(value) = self._email.as_ref() {
12038 params.push("email", value);
12039 }
12040
12041 params.extend(self._additional_params.iter());
12042
12043 params.push("alt", "json");
12044 let mut url = self.hub._base_url.clone() + "v2/{+parent}/provisioningConfigs";
12045 if self._scopes.is_empty() {
12046 self._scopes
12047 .insert(Scope::CloudPlatform.as_ref().to_string());
12048 }
12049
12050 #[allow(clippy::single_element_loop)]
12051 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12052 url = params.uri_replacement(url, param_name, find_this, true);
12053 }
12054 {
12055 let to_remove = ["parent"];
12056 params.remove_params(&to_remove);
12057 }
12058
12059 let url = params.parse_with_url(&url);
12060
12061 let mut json_mime_type = mime::APPLICATION_JSON;
12062 let mut request_value_reader = {
12063 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12064 common::remove_json_null_values(&mut value);
12065 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12066 serde_json::to_writer(&mut dst, &value).unwrap();
12067 dst
12068 };
12069 let request_size = request_value_reader
12070 .seek(std::io::SeekFrom::End(0))
12071 .unwrap();
12072 request_value_reader
12073 .seek(std::io::SeekFrom::Start(0))
12074 .unwrap();
12075
12076 loop {
12077 let token = match self
12078 .hub
12079 .auth
12080 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12081 .await
12082 {
12083 Ok(token) => token,
12084 Err(e) => match dlg.token(e) {
12085 Ok(token) => token,
12086 Err(e) => {
12087 dlg.finished(false);
12088 return Err(common::Error::MissingToken(e));
12089 }
12090 },
12091 };
12092 request_value_reader
12093 .seek(std::io::SeekFrom::Start(0))
12094 .unwrap();
12095 let mut req_result = {
12096 let client = &self.hub.client;
12097 dlg.pre_request();
12098 let mut req_builder = hyper::Request::builder()
12099 .method(hyper::Method::POST)
12100 .uri(url.as_str())
12101 .header(USER_AGENT, self.hub._user_agent.clone());
12102
12103 if let Some(token) = token.as_ref() {
12104 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12105 }
12106
12107 let request = req_builder
12108 .header(CONTENT_TYPE, json_mime_type.to_string())
12109 .header(CONTENT_LENGTH, request_size as u64)
12110 .body(common::to_body(
12111 request_value_reader.get_ref().clone().into(),
12112 ));
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 ///
12171 /// Sets the *request* property to the given value.
12172 ///
12173 /// Even though the property as already been set when instantiating this call,
12174 /// we provide this method for API completeness.
12175 pub fn request(
12176 mut self,
12177 new_value: ProvisioningConfig,
12178 ) -> ProjectLocationProvisioningConfigCreateCall<'a, C> {
12179 self._request = new_value;
12180 self
12181 }
12182 /// Required. The parent project and location containing the ProvisioningConfig.
12183 ///
12184 /// Sets the *parent* path property to the given value.
12185 ///
12186 /// Even though the property as already been set when instantiating this call,
12187 /// we provide this method for API completeness.
12188 pub fn parent(mut self, new_value: &str) -> ProjectLocationProvisioningConfigCreateCall<'a, C> {
12189 self._parent = new_value.to_string();
12190 self
12191 }
12192 /// Optional. Email provided to send a confirmation with provisioning config to.
12193 ///
12194 /// Sets the *email* query property to the given value.
12195 pub fn email(mut self, new_value: &str) -> ProjectLocationProvisioningConfigCreateCall<'a, C> {
12196 self._email = Some(new_value.to_string());
12197 self
12198 }
12199 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12200 /// while executing the actual API request.
12201 ///
12202 /// ````text
12203 /// It should be used to handle progress information, and to implement a certain level of resilience.
12204 /// ````
12205 ///
12206 /// Sets the *delegate* property to the given value.
12207 pub fn delegate(
12208 mut self,
12209 new_value: &'a mut dyn common::Delegate,
12210 ) -> ProjectLocationProvisioningConfigCreateCall<'a, C> {
12211 self._delegate = Some(new_value);
12212 self
12213 }
12214
12215 /// Set any additional parameter of the query string used in the request.
12216 /// It should be used to set parameters which are not yet available through their own
12217 /// setters.
12218 ///
12219 /// Please note that this method must not be used to set any of the known parameters
12220 /// which have their own setter method. If done anyway, the request will fail.
12221 ///
12222 /// # Additional Parameters
12223 ///
12224 /// * *$.xgafv* (query-string) - V1 error format.
12225 /// * *access_token* (query-string) - OAuth access token.
12226 /// * *alt* (query-string) - Data format for response.
12227 /// * *callback* (query-string) - JSONP
12228 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12229 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12230 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12231 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12232 /// * *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.
12233 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12234 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12235 pub fn param<T>(
12236 mut self,
12237 name: T,
12238 value: T,
12239 ) -> ProjectLocationProvisioningConfigCreateCall<'a, C>
12240 where
12241 T: AsRef<str>,
12242 {
12243 self._additional_params
12244 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12245 self
12246 }
12247
12248 /// Identifies the authorization scope for the method you are building.
12249 ///
12250 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12251 /// [`Scope::CloudPlatform`].
12252 ///
12253 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12254 /// tokens for more than one scope.
12255 ///
12256 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12257 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12258 /// sufficient, a read-write scope will do as well.
12259 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProvisioningConfigCreateCall<'a, C>
12260 where
12261 St: AsRef<str>,
12262 {
12263 self._scopes.insert(String::from(scope.as_ref()));
12264 self
12265 }
12266 /// Identifies the authorization scope(s) for the method you are building.
12267 ///
12268 /// See [`Self::add_scope()`] for details.
12269 pub fn add_scopes<I, St>(
12270 mut self,
12271 scopes: I,
12272 ) -> ProjectLocationProvisioningConfigCreateCall<'a, C>
12273 where
12274 I: IntoIterator<Item = St>,
12275 St: AsRef<str>,
12276 {
12277 self._scopes
12278 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12279 self
12280 }
12281
12282 /// Removes all scopes, and no default scope will be used either.
12283 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12284 /// for details).
12285 pub fn clear_scopes(mut self) -> ProjectLocationProvisioningConfigCreateCall<'a, C> {
12286 self._scopes.clear();
12287 self
12288 }
12289}
12290
12291/// Get ProvisioningConfig by name.
12292///
12293/// A builder for the *locations.provisioningConfigs.get* method supported by a *project* resource.
12294/// It is not used directly, but through a [`ProjectMethods`] instance.
12295///
12296/// # Example
12297///
12298/// Instantiate a resource method builder
12299///
12300/// ```test_harness,no_run
12301/// # extern crate hyper;
12302/// # extern crate hyper_rustls;
12303/// # extern crate google_baremetalsolution2 as baremetalsolution2;
12304/// # async fn dox() {
12305/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12306///
12307/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12308/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12309/// # secret,
12310/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
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_http1()
12322/// # .build()
12323/// # );
12324/// # let mut hub = Baremetalsolution::new(client, auth);
12325/// // You can configure optional parameters by calling the respective setters at will, and
12326/// // execute the final call using `doit()`.
12327/// // Values shown here are possibly random and not representative !
12328/// let result = hub.projects().locations_provisioning_configs_get("name")
12329/// .doit().await;
12330/// # }
12331/// ```
12332pub struct ProjectLocationProvisioningConfigGetCall<'a, C>
12333where
12334 C: 'a,
12335{
12336 hub: &'a Baremetalsolution<C>,
12337 _name: String,
12338 _delegate: Option<&'a mut dyn common::Delegate>,
12339 _additional_params: HashMap<String, String>,
12340 _scopes: BTreeSet<String>,
12341}
12342
12343impl<'a, C> common::CallBuilder for ProjectLocationProvisioningConfigGetCall<'a, C> {}
12344
12345impl<'a, C> ProjectLocationProvisioningConfigGetCall<'a, C>
12346where
12347 C: common::Connector,
12348{
12349 /// Perform the operation you have build so far.
12350 pub async fn doit(mut self) -> common::Result<(common::Response, ProvisioningConfig)> {
12351 use std::borrow::Cow;
12352 use std::io::{Read, Seek};
12353
12354 use common::{url::Params, ToParts};
12355 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12356
12357 let mut dd = common::DefaultDelegate;
12358 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12359 dlg.begin(common::MethodInfo {
12360 id: "baremetalsolution.projects.locations.provisioningConfigs.get",
12361 http_method: hyper::Method::GET,
12362 });
12363
12364 for &field in ["alt", "name"].iter() {
12365 if self._additional_params.contains_key(field) {
12366 dlg.finished(false);
12367 return Err(common::Error::FieldClash(field));
12368 }
12369 }
12370
12371 let mut params = Params::with_capacity(3 + self._additional_params.len());
12372 params.push("name", self._name);
12373
12374 params.extend(self._additional_params.iter());
12375
12376 params.push("alt", "json");
12377 let mut url = self.hub._base_url.clone() + "v2/{+name}";
12378 if self._scopes.is_empty() {
12379 self._scopes
12380 .insert(Scope::CloudPlatform.as_ref().to_string());
12381 }
12382
12383 #[allow(clippy::single_element_loop)]
12384 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12385 url = params.uri_replacement(url, param_name, find_this, true);
12386 }
12387 {
12388 let to_remove = ["name"];
12389 params.remove_params(&to_remove);
12390 }
12391
12392 let url = params.parse_with_url(&url);
12393
12394 loop {
12395 let token = match self
12396 .hub
12397 .auth
12398 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12399 .await
12400 {
12401 Ok(token) => token,
12402 Err(e) => match dlg.token(e) {
12403 Ok(token) => token,
12404 Err(e) => {
12405 dlg.finished(false);
12406 return Err(common::Error::MissingToken(e));
12407 }
12408 },
12409 };
12410 let mut req_result = {
12411 let client = &self.hub.client;
12412 dlg.pre_request();
12413 let mut req_builder = hyper::Request::builder()
12414 .method(hyper::Method::GET)
12415 .uri(url.as_str())
12416 .header(USER_AGENT, self.hub._user_agent.clone());
12417
12418 if let Some(token) = token.as_ref() {
12419 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12420 }
12421
12422 let request = req_builder
12423 .header(CONTENT_LENGTH, 0_u64)
12424 .body(common::to_body::<String>(None));
12425
12426 client.request(request.unwrap()).await
12427 };
12428
12429 match req_result {
12430 Err(err) => {
12431 if let common::Retry::After(d) = dlg.http_error(&err) {
12432 sleep(d).await;
12433 continue;
12434 }
12435 dlg.finished(false);
12436 return Err(common::Error::HttpError(err));
12437 }
12438 Ok(res) => {
12439 let (mut parts, body) = res.into_parts();
12440 let mut body = common::Body::new(body);
12441 if !parts.status.is_success() {
12442 let bytes = common::to_bytes(body).await.unwrap_or_default();
12443 let error = serde_json::from_str(&common::to_string(&bytes));
12444 let response = common::to_response(parts, bytes.into());
12445
12446 if let common::Retry::After(d) =
12447 dlg.http_failure(&response, error.as_ref().ok())
12448 {
12449 sleep(d).await;
12450 continue;
12451 }
12452
12453 dlg.finished(false);
12454
12455 return Err(match error {
12456 Ok(value) => common::Error::BadRequest(value),
12457 _ => common::Error::Failure(response),
12458 });
12459 }
12460 let response = {
12461 let bytes = common::to_bytes(body).await.unwrap_or_default();
12462 let encoded = common::to_string(&bytes);
12463 match serde_json::from_str(&encoded) {
12464 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12465 Err(error) => {
12466 dlg.response_json_decode_error(&encoded, &error);
12467 return Err(common::Error::JsonDecodeError(
12468 encoded.to_string(),
12469 error,
12470 ));
12471 }
12472 }
12473 };
12474
12475 dlg.finished(true);
12476 return Ok(response);
12477 }
12478 }
12479 }
12480 }
12481
12482 /// Required. Name of the ProvisioningConfig.
12483 ///
12484 /// Sets the *name* path property to the given value.
12485 ///
12486 /// Even though the property as already been set when instantiating this call,
12487 /// we provide this method for API completeness.
12488 pub fn name(mut self, new_value: &str) -> ProjectLocationProvisioningConfigGetCall<'a, C> {
12489 self._name = new_value.to_string();
12490 self
12491 }
12492 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12493 /// while executing the actual API request.
12494 ///
12495 /// ````text
12496 /// It should be used to handle progress information, and to implement a certain level of resilience.
12497 /// ````
12498 ///
12499 /// Sets the *delegate* property to the given value.
12500 pub fn delegate(
12501 mut self,
12502 new_value: &'a mut dyn common::Delegate,
12503 ) -> ProjectLocationProvisioningConfigGetCall<'a, C> {
12504 self._delegate = Some(new_value);
12505 self
12506 }
12507
12508 /// Set any additional parameter of the query string used in the request.
12509 /// It should be used to set parameters which are not yet available through their own
12510 /// setters.
12511 ///
12512 /// Please note that this method must not be used to set any of the known parameters
12513 /// which have their own setter method. If done anyway, the request will fail.
12514 ///
12515 /// # Additional Parameters
12516 ///
12517 /// * *$.xgafv* (query-string) - V1 error format.
12518 /// * *access_token* (query-string) - OAuth access token.
12519 /// * *alt* (query-string) - Data format for response.
12520 /// * *callback* (query-string) - JSONP
12521 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12522 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12523 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12524 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12525 /// * *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.
12526 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12527 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12528 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProvisioningConfigGetCall<'a, C>
12529 where
12530 T: AsRef<str>,
12531 {
12532 self._additional_params
12533 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12534 self
12535 }
12536
12537 /// Identifies the authorization scope for the method you are building.
12538 ///
12539 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12540 /// [`Scope::CloudPlatform`].
12541 ///
12542 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12543 /// tokens for more than one scope.
12544 ///
12545 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12546 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12547 /// sufficient, a read-write scope will do as well.
12548 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProvisioningConfigGetCall<'a, C>
12549 where
12550 St: AsRef<str>,
12551 {
12552 self._scopes.insert(String::from(scope.as_ref()));
12553 self
12554 }
12555 /// Identifies the authorization scope(s) for the method you are building.
12556 ///
12557 /// See [`Self::add_scope()`] for details.
12558 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProvisioningConfigGetCall<'a, C>
12559 where
12560 I: IntoIterator<Item = St>,
12561 St: AsRef<str>,
12562 {
12563 self._scopes
12564 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12565 self
12566 }
12567
12568 /// Removes all scopes, and no default scope will be used either.
12569 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12570 /// for details).
12571 pub fn clear_scopes(mut self) -> ProjectLocationProvisioningConfigGetCall<'a, C> {
12572 self._scopes.clear();
12573 self
12574 }
12575}
12576
12577/// Update existing ProvisioningConfig.
12578///
12579/// A builder for the *locations.provisioningConfigs.patch* method supported by a *project* resource.
12580/// It is not used directly, but through a [`ProjectMethods`] instance.
12581///
12582/// # Example
12583///
12584/// Instantiate a resource method builder
12585///
12586/// ```test_harness,no_run
12587/// # extern crate hyper;
12588/// # extern crate hyper_rustls;
12589/// # extern crate google_baremetalsolution2 as baremetalsolution2;
12590/// use baremetalsolution2::api::ProvisioningConfig;
12591/// # async fn dox() {
12592/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12593///
12594/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12595/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12596/// # secret,
12597/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12598/// # ).build().await.unwrap();
12599///
12600/// # let client = hyper_util::client::legacy::Client::builder(
12601/// # hyper_util::rt::TokioExecutor::new()
12602/// # )
12603/// # .build(
12604/// # hyper_rustls::HttpsConnectorBuilder::new()
12605/// # .with_native_roots()
12606/// # .unwrap()
12607/// # .https_or_http()
12608/// # .enable_http1()
12609/// # .build()
12610/// # );
12611/// # let mut hub = Baremetalsolution::new(client, auth);
12612/// // As the method needs a request, you would usually fill it with the desired information
12613/// // into the respective structure. Some of the parts shown here might not be applicable !
12614/// // Values shown here are possibly random and not representative !
12615/// let mut req = ProvisioningConfig::default();
12616///
12617/// // You can configure optional parameters by calling the respective setters at will, and
12618/// // execute the final call using `doit()`.
12619/// // Values shown here are possibly random and not representative !
12620/// let result = hub.projects().locations_provisioning_configs_patch(req, "name")
12621/// .update_mask(FieldMask::new::<&str>(&[]))
12622/// .email("et")
12623/// .doit().await;
12624/// # }
12625/// ```
12626pub struct ProjectLocationProvisioningConfigPatchCall<'a, C>
12627where
12628 C: 'a,
12629{
12630 hub: &'a Baremetalsolution<C>,
12631 _request: ProvisioningConfig,
12632 _name: String,
12633 _update_mask: Option<common::FieldMask>,
12634 _email: Option<String>,
12635 _delegate: Option<&'a mut dyn common::Delegate>,
12636 _additional_params: HashMap<String, String>,
12637 _scopes: BTreeSet<String>,
12638}
12639
12640impl<'a, C> common::CallBuilder for ProjectLocationProvisioningConfigPatchCall<'a, C> {}
12641
12642impl<'a, C> ProjectLocationProvisioningConfigPatchCall<'a, C>
12643where
12644 C: common::Connector,
12645{
12646 /// Perform the operation you have build so far.
12647 pub async fn doit(mut self) -> common::Result<(common::Response, ProvisioningConfig)> {
12648 use std::borrow::Cow;
12649 use std::io::{Read, Seek};
12650
12651 use common::{url::Params, ToParts};
12652 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12653
12654 let mut dd = common::DefaultDelegate;
12655 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12656 dlg.begin(common::MethodInfo {
12657 id: "baremetalsolution.projects.locations.provisioningConfigs.patch",
12658 http_method: hyper::Method::PATCH,
12659 });
12660
12661 for &field in ["alt", "name", "updateMask", "email"].iter() {
12662 if self._additional_params.contains_key(field) {
12663 dlg.finished(false);
12664 return Err(common::Error::FieldClash(field));
12665 }
12666 }
12667
12668 let mut params = Params::with_capacity(6 + self._additional_params.len());
12669 params.push("name", self._name);
12670 if let Some(value) = self._update_mask.as_ref() {
12671 params.push("updateMask", value.to_string());
12672 }
12673 if let Some(value) = self._email.as_ref() {
12674 params.push("email", value);
12675 }
12676
12677 params.extend(self._additional_params.iter());
12678
12679 params.push("alt", "json");
12680 let mut url = self.hub._base_url.clone() + "v2/{+name}";
12681 if self._scopes.is_empty() {
12682 self._scopes
12683 .insert(Scope::CloudPlatform.as_ref().to_string());
12684 }
12685
12686 #[allow(clippy::single_element_loop)]
12687 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12688 url = params.uri_replacement(url, param_name, find_this, true);
12689 }
12690 {
12691 let to_remove = ["name"];
12692 params.remove_params(&to_remove);
12693 }
12694
12695 let url = params.parse_with_url(&url);
12696
12697 let mut json_mime_type = mime::APPLICATION_JSON;
12698 let mut request_value_reader = {
12699 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12700 common::remove_json_null_values(&mut value);
12701 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12702 serde_json::to_writer(&mut dst, &value).unwrap();
12703 dst
12704 };
12705 let request_size = request_value_reader
12706 .seek(std::io::SeekFrom::End(0))
12707 .unwrap();
12708 request_value_reader
12709 .seek(std::io::SeekFrom::Start(0))
12710 .unwrap();
12711
12712 loop {
12713 let token = match self
12714 .hub
12715 .auth
12716 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12717 .await
12718 {
12719 Ok(token) => token,
12720 Err(e) => match dlg.token(e) {
12721 Ok(token) => token,
12722 Err(e) => {
12723 dlg.finished(false);
12724 return Err(common::Error::MissingToken(e));
12725 }
12726 },
12727 };
12728 request_value_reader
12729 .seek(std::io::SeekFrom::Start(0))
12730 .unwrap();
12731 let mut req_result = {
12732 let client = &self.hub.client;
12733 dlg.pre_request();
12734 let mut req_builder = hyper::Request::builder()
12735 .method(hyper::Method::PATCH)
12736 .uri(url.as_str())
12737 .header(USER_AGENT, self.hub._user_agent.clone());
12738
12739 if let Some(token) = token.as_ref() {
12740 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12741 }
12742
12743 let request = req_builder
12744 .header(CONTENT_TYPE, json_mime_type.to_string())
12745 .header(CONTENT_LENGTH, request_size as u64)
12746 .body(common::to_body(
12747 request_value_reader.get_ref().clone().into(),
12748 ));
12749
12750 client.request(request.unwrap()).await
12751 };
12752
12753 match req_result {
12754 Err(err) => {
12755 if let common::Retry::After(d) = dlg.http_error(&err) {
12756 sleep(d).await;
12757 continue;
12758 }
12759 dlg.finished(false);
12760 return Err(common::Error::HttpError(err));
12761 }
12762 Ok(res) => {
12763 let (mut parts, body) = res.into_parts();
12764 let mut body = common::Body::new(body);
12765 if !parts.status.is_success() {
12766 let bytes = common::to_bytes(body).await.unwrap_or_default();
12767 let error = serde_json::from_str(&common::to_string(&bytes));
12768 let response = common::to_response(parts, bytes.into());
12769
12770 if let common::Retry::After(d) =
12771 dlg.http_failure(&response, error.as_ref().ok())
12772 {
12773 sleep(d).await;
12774 continue;
12775 }
12776
12777 dlg.finished(false);
12778
12779 return Err(match error {
12780 Ok(value) => common::Error::BadRequest(value),
12781 _ => common::Error::Failure(response),
12782 });
12783 }
12784 let response = {
12785 let bytes = common::to_bytes(body).await.unwrap_or_default();
12786 let encoded = common::to_string(&bytes);
12787 match serde_json::from_str(&encoded) {
12788 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12789 Err(error) => {
12790 dlg.response_json_decode_error(&encoded, &error);
12791 return Err(common::Error::JsonDecodeError(
12792 encoded.to_string(),
12793 error,
12794 ));
12795 }
12796 }
12797 };
12798
12799 dlg.finished(true);
12800 return Ok(response);
12801 }
12802 }
12803 }
12804 }
12805
12806 ///
12807 /// Sets the *request* property to the given value.
12808 ///
12809 /// Even though the property as already been set when instantiating this call,
12810 /// we provide this method for API completeness.
12811 pub fn request(
12812 mut self,
12813 new_value: ProvisioningConfig,
12814 ) -> ProjectLocationProvisioningConfigPatchCall<'a, C> {
12815 self._request = new_value;
12816 self
12817 }
12818 /// Output only. The system-generated name of the provisioning config. This follows the UUID format.
12819 ///
12820 /// Sets the *name* path property to the given value.
12821 ///
12822 /// Even though the property as already been set when instantiating this call,
12823 /// we provide this method for API completeness.
12824 pub fn name(mut self, new_value: &str) -> ProjectLocationProvisioningConfigPatchCall<'a, C> {
12825 self._name = new_value.to_string();
12826 self
12827 }
12828 /// Required. The list of fields to update.
12829 ///
12830 /// Sets the *update mask* query property to the given value.
12831 pub fn update_mask(
12832 mut self,
12833 new_value: common::FieldMask,
12834 ) -> ProjectLocationProvisioningConfigPatchCall<'a, C> {
12835 self._update_mask = Some(new_value);
12836 self
12837 }
12838 /// Optional. Email provided to send a confirmation with provisioning config to.
12839 ///
12840 /// Sets the *email* query property to the given value.
12841 pub fn email(mut self, new_value: &str) -> ProjectLocationProvisioningConfigPatchCall<'a, C> {
12842 self._email = Some(new_value.to_string());
12843 self
12844 }
12845 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12846 /// while executing the actual API request.
12847 ///
12848 /// ````text
12849 /// It should be used to handle progress information, and to implement a certain level of resilience.
12850 /// ````
12851 ///
12852 /// Sets the *delegate* property to the given value.
12853 pub fn delegate(
12854 mut self,
12855 new_value: &'a mut dyn common::Delegate,
12856 ) -> ProjectLocationProvisioningConfigPatchCall<'a, C> {
12857 self._delegate = Some(new_value);
12858 self
12859 }
12860
12861 /// Set any additional parameter of the query string used in the request.
12862 /// It should be used to set parameters which are not yet available through their own
12863 /// setters.
12864 ///
12865 /// Please note that this method must not be used to set any of the known parameters
12866 /// which have their own setter method. If done anyway, the request will fail.
12867 ///
12868 /// # Additional Parameters
12869 ///
12870 /// * *$.xgafv* (query-string) - V1 error format.
12871 /// * *access_token* (query-string) - OAuth access token.
12872 /// * *alt* (query-string) - Data format for response.
12873 /// * *callback* (query-string) - JSONP
12874 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12875 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12876 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12877 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12878 /// * *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.
12879 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12880 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12881 pub fn param<T>(
12882 mut self,
12883 name: T,
12884 value: T,
12885 ) -> ProjectLocationProvisioningConfigPatchCall<'a, C>
12886 where
12887 T: AsRef<str>,
12888 {
12889 self._additional_params
12890 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12891 self
12892 }
12893
12894 /// Identifies the authorization scope for the method you are building.
12895 ///
12896 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12897 /// [`Scope::CloudPlatform`].
12898 ///
12899 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12900 /// tokens for more than one scope.
12901 ///
12902 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12903 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12904 /// sufficient, a read-write scope will do as well.
12905 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProvisioningConfigPatchCall<'a, C>
12906 where
12907 St: AsRef<str>,
12908 {
12909 self._scopes.insert(String::from(scope.as_ref()));
12910 self
12911 }
12912 /// Identifies the authorization scope(s) for the method you are building.
12913 ///
12914 /// See [`Self::add_scope()`] for details.
12915 pub fn add_scopes<I, St>(
12916 mut self,
12917 scopes: I,
12918 ) -> ProjectLocationProvisioningConfigPatchCall<'a, C>
12919 where
12920 I: IntoIterator<Item = St>,
12921 St: AsRef<str>,
12922 {
12923 self._scopes
12924 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12925 self
12926 }
12927
12928 /// Removes all scopes, and no default scope will be used either.
12929 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12930 /// for details).
12931 pub fn clear_scopes(mut self) -> ProjectLocationProvisioningConfigPatchCall<'a, C> {
12932 self._scopes.clear();
12933 self
12934 }
12935}
12936
12937/// Submit a provisiong configuration for a given project.
12938///
12939/// A builder for the *locations.provisioningConfigs.submit* method supported by a *project* resource.
12940/// It is not used directly, but through a [`ProjectMethods`] instance.
12941///
12942/// # Example
12943///
12944/// Instantiate a resource method builder
12945///
12946/// ```test_harness,no_run
12947/// # extern crate hyper;
12948/// # extern crate hyper_rustls;
12949/// # extern crate google_baremetalsolution2 as baremetalsolution2;
12950/// use baremetalsolution2::api::SubmitProvisioningConfigRequest;
12951/// # async fn dox() {
12952/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12953///
12954/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12955/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12956/// # secret,
12957/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12958/// # ).build().await.unwrap();
12959///
12960/// # let client = hyper_util::client::legacy::Client::builder(
12961/// # hyper_util::rt::TokioExecutor::new()
12962/// # )
12963/// # .build(
12964/// # hyper_rustls::HttpsConnectorBuilder::new()
12965/// # .with_native_roots()
12966/// # .unwrap()
12967/// # .https_or_http()
12968/// # .enable_http1()
12969/// # .build()
12970/// # );
12971/// # let mut hub = Baremetalsolution::new(client, auth);
12972/// // As the method needs a request, you would usually fill it with the desired information
12973/// // into the respective structure. Some of the parts shown here might not be applicable !
12974/// // Values shown here are possibly random and not representative !
12975/// let mut req = SubmitProvisioningConfigRequest::default();
12976///
12977/// // You can configure optional parameters by calling the respective setters at will, and
12978/// // execute the final call using `doit()`.
12979/// // Values shown here are possibly random and not representative !
12980/// let result = hub.projects().locations_provisioning_configs_submit(req, "parent")
12981/// .doit().await;
12982/// # }
12983/// ```
12984pub struct ProjectLocationProvisioningConfigSubmitCall<'a, C>
12985where
12986 C: 'a,
12987{
12988 hub: &'a Baremetalsolution<C>,
12989 _request: SubmitProvisioningConfigRequest,
12990 _parent: String,
12991 _delegate: Option<&'a mut dyn common::Delegate>,
12992 _additional_params: HashMap<String, String>,
12993 _scopes: BTreeSet<String>,
12994}
12995
12996impl<'a, C> common::CallBuilder for ProjectLocationProvisioningConfigSubmitCall<'a, C> {}
12997
12998impl<'a, C> ProjectLocationProvisioningConfigSubmitCall<'a, C>
12999where
13000 C: common::Connector,
13001{
13002 /// Perform the operation you have build so far.
13003 pub async fn doit(
13004 mut self,
13005 ) -> common::Result<(common::Response, SubmitProvisioningConfigResponse)> {
13006 use std::borrow::Cow;
13007 use std::io::{Read, Seek};
13008
13009 use common::{url::Params, ToParts};
13010 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13011
13012 let mut dd = common::DefaultDelegate;
13013 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13014 dlg.begin(common::MethodInfo {
13015 id: "baremetalsolution.projects.locations.provisioningConfigs.submit",
13016 http_method: hyper::Method::POST,
13017 });
13018
13019 for &field in ["alt", "parent"].iter() {
13020 if self._additional_params.contains_key(field) {
13021 dlg.finished(false);
13022 return Err(common::Error::FieldClash(field));
13023 }
13024 }
13025
13026 let mut params = Params::with_capacity(4 + self._additional_params.len());
13027 params.push("parent", self._parent);
13028
13029 params.extend(self._additional_params.iter());
13030
13031 params.push("alt", "json");
13032 let mut url = self.hub._base_url.clone() + "v2/{+parent}/provisioningConfigs:submit";
13033 if self._scopes.is_empty() {
13034 self._scopes
13035 .insert(Scope::CloudPlatform.as_ref().to_string());
13036 }
13037
13038 #[allow(clippy::single_element_loop)]
13039 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13040 url = params.uri_replacement(url, param_name, find_this, true);
13041 }
13042 {
13043 let to_remove = ["parent"];
13044 params.remove_params(&to_remove);
13045 }
13046
13047 let url = params.parse_with_url(&url);
13048
13049 let mut json_mime_type = mime::APPLICATION_JSON;
13050 let mut request_value_reader = {
13051 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13052 common::remove_json_null_values(&mut value);
13053 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13054 serde_json::to_writer(&mut dst, &value).unwrap();
13055 dst
13056 };
13057 let request_size = request_value_reader
13058 .seek(std::io::SeekFrom::End(0))
13059 .unwrap();
13060 request_value_reader
13061 .seek(std::io::SeekFrom::Start(0))
13062 .unwrap();
13063
13064 loop {
13065 let token = match self
13066 .hub
13067 .auth
13068 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13069 .await
13070 {
13071 Ok(token) => token,
13072 Err(e) => match dlg.token(e) {
13073 Ok(token) => token,
13074 Err(e) => {
13075 dlg.finished(false);
13076 return Err(common::Error::MissingToken(e));
13077 }
13078 },
13079 };
13080 request_value_reader
13081 .seek(std::io::SeekFrom::Start(0))
13082 .unwrap();
13083 let mut req_result = {
13084 let client = &self.hub.client;
13085 dlg.pre_request();
13086 let mut req_builder = hyper::Request::builder()
13087 .method(hyper::Method::POST)
13088 .uri(url.as_str())
13089 .header(USER_AGENT, self.hub._user_agent.clone());
13090
13091 if let Some(token) = token.as_ref() {
13092 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13093 }
13094
13095 let request = req_builder
13096 .header(CONTENT_TYPE, json_mime_type.to_string())
13097 .header(CONTENT_LENGTH, request_size as u64)
13098 .body(common::to_body(
13099 request_value_reader.get_ref().clone().into(),
13100 ));
13101
13102 client.request(request.unwrap()).await
13103 };
13104
13105 match req_result {
13106 Err(err) => {
13107 if let common::Retry::After(d) = dlg.http_error(&err) {
13108 sleep(d).await;
13109 continue;
13110 }
13111 dlg.finished(false);
13112 return Err(common::Error::HttpError(err));
13113 }
13114 Ok(res) => {
13115 let (mut parts, body) = res.into_parts();
13116 let mut body = common::Body::new(body);
13117 if !parts.status.is_success() {
13118 let bytes = common::to_bytes(body).await.unwrap_or_default();
13119 let error = serde_json::from_str(&common::to_string(&bytes));
13120 let response = common::to_response(parts, bytes.into());
13121
13122 if let common::Retry::After(d) =
13123 dlg.http_failure(&response, error.as_ref().ok())
13124 {
13125 sleep(d).await;
13126 continue;
13127 }
13128
13129 dlg.finished(false);
13130
13131 return Err(match error {
13132 Ok(value) => common::Error::BadRequest(value),
13133 _ => common::Error::Failure(response),
13134 });
13135 }
13136 let response = {
13137 let bytes = common::to_bytes(body).await.unwrap_or_default();
13138 let encoded = common::to_string(&bytes);
13139 match serde_json::from_str(&encoded) {
13140 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13141 Err(error) => {
13142 dlg.response_json_decode_error(&encoded, &error);
13143 return Err(common::Error::JsonDecodeError(
13144 encoded.to_string(),
13145 error,
13146 ));
13147 }
13148 }
13149 };
13150
13151 dlg.finished(true);
13152 return Ok(response);
13153 }
13154 }
13155 }
13156 }
13157
13158 ///
13159 /// Sets the *request* property to the given value.
13160 ///
13161 /// Even though the property as already been set when instantiating this call,
13162 /// we provide this method for API completeness.
13163 pub fn request(
13164 mut self,
13165 new_value: SubmitProvisioningConfigRequest,
13166 ) -> ProjectLocationProvisioningConfigSubmitCall<'a, C> {
13167 self._request = new_value;
13168 self
13169 }
13170 /// Required. The parent project and location containing the ProvisioningConfig.
13171 ///
13172 /// Sets the *parent* path property to the given value.
13173 ///
13174 /// Even though the property as already been set when instantiating this call,
13175 /// we provide this method for API completeness.
13176 pub fn parent(mut self, new_value: &str) -> ProjectLocationProvisioningConfigSubmitCall<'a, C> {
13177 self._parent = new_value.to_string();
13178 self
13179 }
13180 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13181 /// while executing the actual API request.
13182 ///
13183 /// ````text
13184 /// It should be used to handle progress information, and to implement a certain level of resilience.
13185 /// ````
13186 ///
13187 /// Sets the *delegate* property to the given value.
13188 pub fn delegate(
13189 mut self,
13190 new_value: &'a mut dyn common::Delegate,
13191 ) -> ProjectLocationProvisioningConfigSubmitCall<'a, C> {
13192 self._delegate = Some(new_value);
13193 self
13194 }
13195
13196 /// Set any additional parameter of the query string used in the request.
13197 /// It should be used to set parameters which are not yet available through their own
13198 /// setters.
13199 ///
13200 /// Please note that this method must not be used to set any of the known parameters
13201 /// which have their own setter method. If done anyway, the request will fail.
13202 ///
13203 /// # Additional Parameters
13204 ///
13205 /// * *$.xgafv* (query-string) - V1 error format.
13206 /// * *access_token* (query-string) - OAuth access token.
13207 /// * *alt* (query-string) - Data format for response.
13208 /// * *callback* (query-string) - JSONP
13209 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13210 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13211 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13212 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13213 /// * *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.
13214 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13215 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13216 pub fn param<T>(
13217 mut self,
13218 name: T,
13219 value: T,
13220 ) -> ProjectLocationProvisioningConfigSubmitCall<'a, C>
13221 where
13222 T: AsRef<str>,
13223 {
13224 self._additional_params
13225 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13226 self
13227 }
13228
13229 /// Identifies the authorization scope for the method you are building.
13230 ///
13231 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13232 /// [`Scope::CloudPlatform`].
13233 ///
13234 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13235 /// tokens for more than one scope.
13236 ///
13237 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13238 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13239 /// sufficient, a read-write scope will do as well.
13240 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProvisioningConfigSubmitCall<'a, C>
13241 where
13242 St: AsRef<str>,
13243 {
13244 self._scopes.insert(String::from(scope.as_ref()));
13245 self
13246 }
13247 /// Identifies the authorization scope(s) for the method you are building.
13248 ///
13249 /// See [`Self::add_scope()`] for details.
13250 pub fn add_scopes<I, St>(
13251 mut self,
13252 scopes: I,
13253 ) -> ProjectLocationProvisioningConfigSubmitCall<'a, C>
13254 where
13255 I: IntoIterator<Item = St>,
13256 St: AsRef<str>,
13257 {
13258 self._scopes
13259 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13260 self
13261 }
13262
13263 /// Removes all scopes, and no default scope will be used either.
13264 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13265 /// for details).
13266 pub fn clear_scopes(mut self) -> ProjectLocationProvisioningConfigSubmitCall<'a, C> {
13267 self._scopes.clear();
13268 self
13269 }
13270}
13271
13272/// List the budget details to provision resources on a given project.
13273///
13274/// A builder for the *locations.provisioningQuotas.list* method supported by a *project* resource.
13275/// It is not used directly, but through a [`ProjectMethods`] instance.
13276///
13277/// # Example
13278///
13279/// Instantiate a resource method builder
13280///
13281/// ```test_harness,no_run
13282/// # extern crate hyper;
13283/// # extern crate hyper_rustls;
13284/// # extern crate google_baremetalsolution2 as baremetalsolution2;
13285/// # async fn dox() {
13286/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13287///
13288/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13289/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13290/// # secret,
13291/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13292/// # ).build().await.unwrap();
13293///
13294/// # let client = hyper_util::client::legacy::Client::builder(
13295/// # hyper_util::rt::TokioExecutor::new()
13296/// # )
13297/// # .build(
13298/// # hyper_rustls::HttpsConnectorBuilder::new()
13299/// # .with_native_roots()
13300/// # .unwrap()
13301/// # .https_or_http()
13302/// # .enable_http1()
13303/// # .build()
13304/// # );
13305/// # let mut hub = Baremetalsolution::new(client, auth);
13306/// // You can configure optional parameters by calling the respective setters at will, and
13307/// // execute the final call using `doit()`.
13308/// // Values shown here are possibly random and not representative !
13309/// let result = hub.projects().locations_provisioning_quotas_list("parent")
13310/// .page_token("erat")
13311/// .page_size(-93)
13312/// .doit().await;
13313/// # }
13314/// ```
13315pub struct ProjectLocationProvisioningQuotaListCall<'a, C>
13316where
13317 C: 'a,
13318{
13319 hub: &'a Baremetalsolution<C>,
13320 _parent: String,
13321 _page_token: Option<String>,
13322 _page_size: Option<i32>,
13323 _delegate: Option<&'a mut dyn common::Delegate>,
13324 _additional_params: HashMap<String, String>,
13325 _scopes: BTreeSet<String>,
13326}
13327
13328impl<'a, C> common::CallBuilder for ProjectLocationProvisioningQuotaListCall<'a, C> {}
13329
13330impl<'a, C> ProjectLocationProvisioningQuotaListCall<'a, C>
13331where
13332 C: common::Connector,
13333{
13334 /// Perform the operation you have build so far.
13335 pub async fn doit(
13336 mut self,
13337 ) -> common::Result<(common::Response, ListProvisioningQuotasResponse)> {
13338 use std::borrow::Cow;
13339 use std::io::{Read, Seek};
13340
13341 use common::{url::Params, ToParts};
13342 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13343
13344 let mut dd = common::DefaultDelegate;
13345 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13346 dlg.begin(common::MethodInfo {
13347 id: "baremetalsolution.projects.locations.provisioningQuotas.list",
13348 http_method: hyper::Method::GET,
13349 });
13350
13351 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
13352 if self._additional_params.contains_key(field) {
13353 dlg.finished(false);
13354 return Err(common::Error::FieldClash(field));
13355 }
13356 }
13357
13358 let mut params = Params::with_capacity(5 + self._additional_params.len());
13359 params.push("parent", self._parent);
13360 if let Some(value) = self._page_token.as_ref() {
13361 params.push("pageToken", value);
13362 }
13363 if let Some(value) = self._page_size.as_ref() {
13364 params.push("pageSize", value.to_string());
13365 }
13366
13367 params.extend(self._additional_params.iter());
13368
13369 params.push("alt", "json");
13370 let mut url = self.hub._base_url.clone() + "v2/{+parent}/provisioningQuotas";
13371 if self._scopes.is_empty() {
13372 self._scopes
13373 .insert(Scope::CloudPlatform.as_ref().to_string());
13374 }
13375
13376 #[allow(clippy::single_element_loop)]
13377 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13378 url = params.uri_replacement(url, param_name, find_this, true);
13379 }
13380 {
13381 let to_remove = ["parent"];
13382 params.remove_params(&to_remove);
13383 }
13384
13385 let url = params.parse_with_url(&url);
13386
13387 loop {
13388 let token = match self
13389 .hub
13390 .auth
13391 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13392 .await
13393 {
13394 Ok(token) => token,
13395 Err(e) => match dlg.token(e) {
13396 Ok(token) => token,
13397 Err(e) => {
13398 dlg.finished(false);
13399 return Err(common::Error::MissingToken(e));
13400 }
13401 },
13402 };
13403 let mut req_result = {
13404 let client = &self.hub.client;
13405 dlg.pre_request();
13406 let mut req_builder = hyper::Request::builder()
13407 .method(hyper::Method::GET)
13408 .uri(url.as_str())
13409 .header(USER_AGENT, self.hub._user_agent.clone());
13410
13411 if let Some(token) = token.as_ref() {
13412 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13413 }
13414
13415 let request = req_builder
13416 .header(CONTENT_LENGTH, 0_u64)
13417 .body(common::to_body::<String>(None));
13418
13419 client.request(request.unwrap()).await
13420 };
13421
13422 match req_result {
13423 Err(err) => {
13424 if let common::Retry::After(d) = dlg.http_error(&err) {
13425 sleep(d).await;
13426 continue;
13427 }
13428 dlg.finished(false);
13429 return Err(common::Error::HttpError(err));
13430 }
13431 Ok(res) => {
13432 let (mut parts, body) = res.into_parts();
13433 let mut body = common::Body::new(body);
13434 if !parts.status.is_success() {
13435 let bytes = common::to_bytes(body).await.unwrap_or_default();
13436 let error = serde_json::from_str(&common::to_string(&bytes));
13437 let response = common::to_response(parts, bytes.into());
13438
13439 if let common::Retry::After(d) =
13440 dlg.http_failure(&response, error.as_ref().ok())
13441 {
13442 sleep(d).await;
13443 continue;
13444 }
13445
13446 dlg.finished(false);
13447
13448 return Err(match error {
13449 Ok(value) => common::Error::BadRequest(value),
13450 _ => common::Error::Failure(response),
13451 });
13452 }
13453 let response = {
13454 let bytes = common::to_bytes(body).await.unwrap_or_default();
13455 let encoded = common::to_string(&bytes);
13456 match serde_json::from_str(&encoded) {
13457 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13458 Err(error) => {
13459 dlg.response_json_decode_error(&encoded, &error);
13460 return Err(common::Error::JsonDecodeError(
13461 encoded.to_string(),
13462 error,
13463 ));
13464 }
13465 }
13466 };
13467
13468 dlg.finished(true);
13469 return Ok(response);
13470 }
13471 }
13472 }
13473 }
13474
13475 /// Required. Parent value for ListProvisioningQuotasRequest.
13476 ///
13477 /// Sets the *parent* path property to the given value.
13478 ///
13479 /// Even though the property as already been set when instantiating this call,
13480 /// we provide this method for API completeness.
13481 pub fn parent(mut self, new_value: &str) -> ProjectLocationProvisioningQuotaListCall<'a, C> {
13482 self._parent = new_value.to_string();
13483 self
13484 }
13485 /// A token identifying a page of results from the server.
13486 ///
13487 /// Sets the *page token* query property to the given value.
13488 pub fn page_token(
13489 mut self,
13490 new_value: &str,
13491 ) -> ProjectLocationProvisioningQuotaListCall<'a, C> {
13492 self._page_token = Some(new_value.to_string());
13493 self
13494 }
13495 /// 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.
13496 ///
13497 /// Sets the *page size* query property to the given value.
13498 pub fn page_size(mut self, new_value: i32) -> ProjectLocationProvisioningQuotaListCall<'a, C> {
13499 self._page_size = Some(new_value);
13500 self
13501 }
13502 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13503 /// while executing the actual API request.
13504 ///
13505 /// ````text
13506 /// It should be used to handle progress information, and to implement a certain level of resilience.
13507 /// ````
13508 ///
13509 /// Sets the *delegate* property to the given value.
13510 pub fn delegate(
13511 mut self,
13512 new_value: &'a mut dyn common::Delegate,
13513 ) -> ProjectLocationProvisioningQuotaListCall<'a, C> {
13514 self._delegate = Some(new_value);
13515 self
13516 }
13517
13518 /// Set any additional parameter of the query string used in the request.
13519 /// It should be used to set parameters which are not yet available through their own
13520 /// setters.
13521 ///
13522 /// Please note that this method must not be used to set any of the known parameters
13523 /// which have their own setter method. If done anyway, the request will fail.
13524 ///
13525 /// # Additional Parameters
13526 ///
13527 /// * *$.xgafv* (query-string) - V1 error format.
13528 /// * *access_token* (query-string) - OAuth access token.
13529 /// * *alt* (query-string) - Data format for response.
13530 /// * *callback* (query-string) - JSONP
13531 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13532 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13533 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13534 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13535 /// * *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.
13536 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13537 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13538 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProvisioningQuotaListCall<'a, C>
13539 where
13540 T: AsRef<str>,
13541 {
13542 self._additional_params
13543 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13544 self
13545 }
13546
13547 /// Identifies the authorization scope for the method you are building.
13548 ///
13549 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13550 /// [`Scope::CloudPlatform`].
13551 ///
13552 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13553 /// tokens for more than one scope.
13554 ///
13555 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13556 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13557 /// sufficient, a read-write scope will do as well.
13558 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProvisioningQuotaListCall<'a, C>
13559 where
13560 St: AsRef<str>,
13561 {
13562 self._scopes.insert(String::from(scope.as_ref()));
13563 self
13564 }
13565 /// Identifies the authorization scope(s) for the method you are building.
13566 ///
13567 /// See [`Self::add_scope()`] for details.
13568 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProvisioningQuotaListCall<'a, C>
13569 where
13570 I: IntoIterator<Item = St>,
13571 St: AsRef<str>,
13572 {
13573 self._scopes
13574 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13575 self
13576 }
13577
13578 /// Removes all scopes, and no default scope will be used either.
13579 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13580 /// for details).
13581 pub fn clear_scopes(mut self) -> ProjectLocationProvisioningQuotaListCall<'a, C> {
13582 self._scopes.clear();
13583 self
13584 }
13585}
13586
13587/// Register a public SSH key in the specified project for use with the interactive serial console feature.
13588///
13589/// A builder for the *locations.sshKeys.create* method supported by a *project* resource.
13590/// It is not used directly, but through a [`ProjectMethods`] instance.
13591///
13592/// # Example
13593///
13594/// Instantiate a resource method builder
13595///
13596/// ```test_harness,no_run
13597/// # extern crate hyper;
13598/// # extern crate hyper_rustls;
13599/// # extern crate google_baremetalsolution2 as baremetalsolution2;
13600/// use baremetalsolution2::api::SSHKey;
13601/// # async fn dox() {
13602/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13603///
13604/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13605/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13606/// # secret,
13607/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13608/// # ).build().await.unwrap();
13609///
13610/// # let client = hyper_util::client::legacy::Client::builder(
13611/// # hyper_util::rt::TokioExecutor::new()
13612/// # )
13613/// # .build(
13614/// # hyper_rustls::HttpsConnectorBuilder::new()
13615/// # .with_native_roots()
13616/// # .unwrap()
13617/// # .https_or_http()
13618/// # .enable_http1()
13619/// # .build()
13620/// # );
13621/// # let mut hub = Baremetalsolution::new(client, auth);
13622/// // As the method needs a request, you would usually fill it with the desired information
13623/// // into the respective structure. Some of the parts shown here might not be applicable !
13624/// // Values shown here are possibly random and not representative !
13625/// let mut req = SSHKey::default();
13626///
13627/// // You can configure optional parameters by calling the respective setters at will, and
13628/// // execute the final call using `doit()`.
13629/// // Values shown here are possibly random and not representative !
13630/// let result = hub.projects().locations_ssh_keys_create(req, "parent")
13631/// .ssh_key_id("dolore")
13632/// .doit().await;
13633/// # }
13634/// ```
13635pub struct ProjectLocationSshKeyCreateCall<'a, C>
13636where
13637 C: 'a,
13638{
13639 hub: &'a Baremetalsolution<C>,
13640 _request: SSHKey,
13641 _parent: String,
13642 _ssh_key_id: Option<String>,
13643 _delegate: Option<&'a mut dyn common::Delegate>,
13644 _additional_params: HashMap<String, String>,
13645 _scopes: BTreeSet<String>,
13646}
13647
13648impl<'a, C> common::CallBuilder for ProjectLocationSshKeyCreateCall<'a, C> {}
13649
13650impl<'a, C> ProjectLocationSshKeyCreateCall<'a, C>
13651where
13652 C: common::Connector,
13653{
13654 /// Perform the operation you have build so far.
13655 pub async fn doit(mut self) -> common::Result<(common::Response, SSHKey)> {
13656 use std::borrow::Cow;
13657 use std::io::{Read, Seek};
13658
13659 use common::{url::Params, ToParts};
13660 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13661
13662 let mut dd = common::DefaultDelegate;
13663 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13664 dlg.begin(common::MethodInfo {
13665 id: "baremetalsolution.projects.locations.sshKeys.create",
13666 http_method: hyper::Method::POST,
13667 });
13668
13669 for &field in ["alt", "parent", "sshKeyId"].iter() {
13670 if self._additional_params.contains_key(field) {
13671 dlg.finished(false);
13672 return Err(common::Error::FieldClash(field));
13673 }
13674 }
13675
13676 let mut params = Params::with_capacity(5 + self._additional_params.len());
13677 params.push("parent", self._parent);
13678 if let Some(value) = self._ssh_key_id.as_ref() {
13679 params.push("sshKeyId", value);
13680 }
13681
13682 params.extend(self._additional_params.iter());
13683
13684 params.push("alt", "json");
13685 let mut url = self.hub._base_url.clone() + "v2/{+parent}/sshKeys";
13686 if self._scopes.is_empty() {
13687 self._scopes
13688 .insert(Scope::CloudPlatform.as_ref().to_string());
13689 }
13690
13691 #[allow(clippy::single_element_loop)]
13692 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13693 url = params.uri_replacement(url, param_name, find_this, true);
13694 }
13695 {
13696 let to_remove = ["parent"];
13697 params.remove_params(&to_remove);
13698 }
13699
13700 let url = params.parse_with_url(&url);
13701
13702 let mut json_mime_type = mime::APPLICATION_JSON;
13703 let mut request_value_reader = {
13704 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13705 common::remove_json_null_values(&mut value);
13706 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13707 serde_json::to_writer(&mut dst, &value).unwrap();
13708 dst
13709 };
13710 let request_size = request_value_reader
13711 .seek(std::io::SeekFrom::End(0))
13712 .unwrap();
13713 request_value_reader
13714 .seek(std::io::SeekFrom::Start(0))
13715 .unwrap();
13716
13717 loop {
13718 let token = match self
13719 .hub
13720 .auth
13721 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13722 .await
13723 {
13724 Ok(token) => token,
13725 Err(e) => match dlg.token(e) {
13726 Ok(token) => token,
13727 Err(e) => {
13728 dlg.finished(false);
13729 return Err(common::Error::MissingToken(e));
13730 }
13731 },
13732 };
13733 request_value_reader
13734 .seek(std::io::SeekFrom::Start(0))
13735 .unwrap();
13736 let mut req_result = {
13737 let client = &self.hub.client;
13738 dlg.pre_request();
13739 let mut req_builder = hyper::Request::builder()
13740 .method(hyper::Method::POST)
13741 .uri(url.as_str())
13742 .header(USER_AGENT, self.hub._user_agent.clone());
13743
13744 if let Some(token) = token.as_ref() {
13745 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13746 }
13747
13748 let request = req_builder
13749 .header(CONTENT_TYPE, json_mime_type.to_string())
13750 .header(CONTENT_LENGTH, request_size as u64)
13751 .body(common::to_body(
13752 request_value_reader.get_ref().clone().into(),
13753 ));
13754
13755 client.request(request.unwrap()).await
13756 };
13757
13758 match req_result {
13759 Err(err) => {
13760 if let common::Retry::After(d) = dlg.http_error(&err) {
13761 sleep(d).await;
13762 continue;
13763 }
13764 dlg.finished(false);
13765 return Err(common::Error::HttpError(err));
13766 }
13767 Ok(res) => {
13768 let (mut parts, body) = res.into_parts();
13769 let mut body = common::Body::new(body);
13770 if !parts.status.is_success() {
13771 let bytes = common::to_bytes(body).await.unwrap_or_default();
13772 let error = serde_json::from_str(&common::to_string(&bytes));
13773 let response = common::to_response(parts, bytes.into());
13774
13775 if let common::Retry::After(d) =
13776 dlg.http_failure(&response, error.as_ref().ok())
13777 {
13778 sleep(d).await;
13779 continue;
13780 }
13781
13782 dlg.finished(false);
13783
13784 return Err(match error {
13785 Ok(value) => common::Error::BadRequest(value),
13786 _ => common::Error::Failure(response),
13787 });
13788 }
13789 let response = {
13790 let bytes = common::to_bytes(body).await.unwrap_or_default();
13791 let encoded = common::to_string(&bytes);
13792 match serde_json::from_str(&encoded) {
13793 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13794 Err(error) => {
13795 dlg.response_json_decode_error(&encoded, &error);
13796 return Err(common::Error::JsonDecodeError(
13797 encoded.to_string(),
13798 error,
13799 ));
13800 }
13801 }
13802 };
13803
13804 dlg.finished(true);
13805 return Ok(response);
13806 }
13807 }
13808 }
13809 }
13810
13811 ///
13812 /// Sets the *request* property to the given value.
13813 ///
13814 /// Even though the property as already been set when instantiating this call,
13815 /// we provide this method for API completeness.
13816 pub fn request(mut self, new_value: SSHKey) -> ProjectLocationSshKeyCreateCall<'a, C> {
13817 self._request = new_value;
13818 self
13819 }
13820 /// Required. The parent containing the SSH keys.
13821 ///
13822 /// Sets the *parent* path property to the given value.
13823 ///
13824 /// Even though the property as already been set when instantiating this call,
13825 /// we provide this method for API completeness.
13826 pub fn parent(mut self, new_value: &str) -> ProjectLocationSshKeyCreateCall<'a, C> {
13827 self._parent = new_value.to_string();
13828 self
13829 }
13830 /// 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}
13831 ///
13832 /// Sets the *ssh key id* query property to the given value.
13833 pub fn ssh_key_id(mut self, new_value: &str) -> ProjectLocationSshKeyCreateCall<'a, C> {
13834 self._ssh_key_id = Some(new_value.to_string());
13835 self
13836 }
13837 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13838 /// while executing the actual API request.
13839 ///
13840 /// ````text
13841 /// It should be used to handle progress information, and to implement a certain level of resilience.
13842 /// ````
13843 ///
13844 /// Sets the *delegate* property to the given value.
13845 pub fn delegate(
13846 mut self,
13847 new_value: &'a mut dyn common::Delegate,
13848 ) -> ProjectLocationSshKeyCreateCall<'a, C> {
13849 self._delegate = Some(new_value);
13850 self
13851 }
13852
13853 /// Set any additional parameter of the query string used in the request.
13854 /// It should be used to set parameters which are not yet available through their own
13855 /// setters.
13856 ///
13857 /// Please note that this method must not be used to set any of the known parameters
13858 /// which have their own setter method. If done anyway, the request will fail.
13859 ///
13860 /// # Additional Parameters
13861 ///
13862 /// * *$.xgafv* (query-string) - V1 error format.
13863 /// * *access_token* (query-string) - OAuth access token.
13864 /// * *alt* (query-string) - Data format for response.
13865 /// * *callback* (query-string) - JSONP
13866 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13867 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13868 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13869 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13870 /// * *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.
13871 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13872 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13873 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSshKeyCreateCall<'a, C>
13874 where
13875 T: AsRef<str>,
13876 {
13877 self._additional_params
13878 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13879 self
13880 }
13881
13882 /// Identifies the authorization scope for the method you are building.
13883 ///
13884 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13885 /// [`Scope::CloudPlatform`].
13886 ///
13887 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13888 /// tokens for more than one scope.
13889 ///
13890 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13891 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13892 /// sufficient, a read-write scope will do as well.
13893 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSshKeyCreateCall<'a, C>
13894 where
13895 St: AsRef<str>,
13896 {
13897 self._scopes.insert(String::from(scope.as_ref()));
13898 self
13899 }
13900 /// Identifies the authorization scope(s) for the method you are building.
13901 ///
13902 /// See [`Self::add_scope()`] for details.
13903 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSshKeyCreateCall<'a, C>
13904 where
13905 I: IntoIterator<Item = St>,
13906 St: AsRef<str>,
13907 {
13908 self._scopes
13909 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13910 self
13911 }
13912
13913 /// Removes all scopes, and no default scope will be used either.
13914 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13915 /// for details).
13916 pub fn clear_scopes(mut self) -> ProjectLocationSshKeyCreateCall<'a, C> {
13917 self._scopes.clear();
13918 self
13919 }
13920}
13921
13922/// Deletes a public SSH key registered in the specified project.
13923///
13924/// A builder for the *locations.sshKeys.delete* method supported by a *project* resource.
13925/// It is not used directly, but through a [`ProjectMethods`] instance.
13926///
13927/// # Example
13928///
13929/// Instantiate a resource method builder
13930///
13931/// ```test_harness,no_run
13932/// # extern crate hyper;
13933/// # extern crate hyper_rustls;
13934/// # extern crate google_baremetalsolution2 as baremetalsolution2;
13935/// # async fn dox() {
13936/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13937///
13938/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13939/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13940/// # secret,
13941/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13942/// # ).build().await.unwrap();
13943///
13944/// # let client = hyper_util::client::legacy::Client::builder(
13945/// # hyper_util::rt::TokioExecutor::new()
13946/// # )
13947/// # .build(
13948/// # hyper_rustls::HttpsConnectorBuilder::new()
13949/// # .with_native_roots()
13950/// # .unwrap()
13951/// # .https_or_http()
13952/// # .enable_http1()
13953/// # .build()
13954/// # );
13955/// # let mut hub = Baremetalsolution::new(client, auth);
13956/// // You can configure optional parameters by calling the respective setters at will, and
13957/// // execute the final call using `doit()`.
13958/// // Values shown here are possibly random and not representative !
13959/// let result = hub.projects().locations_ssh_keys_delete("name")
13960/// .doit().await;
13961/// # }
13962/// ```
13963pub struct ProjectLocationSshKeyDeleteCall<'a, C>
13964where
13965 C: 'a,
13966{
13967 hub: &'a Baremetalsolution<C>,
13968 _name: String,
13969 _delegate: Option<&'a mut dyn common::Delegate>,
13970 _additional_params: HashMap<String, String>,
13971 _scopes: BTreeSet<String>,
13972}
13973
13974impl<'a, C> common::CallBuilder for ProjectLocationSshKeyDeleteCall<'a, C> {}
13975
13976impl<'a, C> ProjectLocationSshKeyDeleteCall<'a, C>
13977where
13978 C: common::Connector,
13979{
13980 /// Perform the operation you have build so far.
13981 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
13982 use std::borrow::Cow;
13983 use std::io::{Read, Seek};
13984
13985 use common::{url::Params, ToParts};
13986 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13987
13988 let mut dd = common::DefaultDelegate;
13989 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13990 dlg.begin(common::MethodInfo {
13991 id: "baremetalsolution.projects.locations.sshKeys.delete",
13992 http_method: hyper::Method::DELETE,
13993 });
13994
13995 for &field in ["alt", "name"].iter() {
13996 if self._additional_params.contains_key(field) {
13997 dlg.finished(false);
13998 return Err(common::Error::FieldClash(field));
13999 }
14000 }
14001
14002 let mut params = Params::with_capacity(3 + self._additional_params.len());
14003 params.push("name", self._name);
14004
14005 params.extend(self._additional_params.iter());
14006
14007 params.push("alt", "json");
14008 let mut url = self.hub._base_url.clone() + "v2/{+name}";
14009 if self._scopes.is_empty() {
14010 self._scopes
14011 .insert(Scope::CloudPlatform.as_ref().to_string());
14012 }
14013
14014 #[allow(clippy::single_element_loop)]
14015 for &(find_this, param_name) in [("{+name}", "name")].iter() {
14016 url = params.uri_replacement(url, param_name, find_this, true);
14017 }
14018 {
14019 let to_remove = ["name"];
14020 params.remove_params(&to_remove);
14021 }
14022
14023 let url = params.parse_with_url(&url);
14024
14025 loop {
14026 let token = match self
14027 .hub
14028 .auth
14029 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14030 .await
14031 {
14032 Ok(token) => token,
14033 Err(e) => match dlg.token(e) {
14034 Ok(token) => token,
14035 Err(e) => {
14036 dlg.finished(false);
14037 return Err(common::Error::MissingToken(e));
14038 }
14039 },
14040 };
14041 let mut req_result = {
14042 let client = &self.hub.client;
14043 dlg.pre_request();
14044 let mut req_builder = hyper::Request::builder()
14045 .method(hyper::Method::DELETE)
14046 .uri(url.as_str())
14047 .header(USER_AGENT, self.hub._user_agent.clone());
14048
14049 if let Some(token) = token.as_ref() {
14050 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14051 }
14052
14053 let request = req_builder
14054 .header(CONTENT_LENGTH, 0_u64)
14055 .body(common::to_body::<String>(None));
14056
14057 client.request(request.unwrap()).await
14058 };
14059
14060 match req_result {
14061 Err(err) => {
14062 if let common::Retry::After(d) = dlg.http_error(&err) {
14063 sleep(d).await;
14064 continue;
14065 }
14066 dlg.finished(false);
14067 return Err(common::Error::HttpError(err));
14068 }
14069 Ok(res) => {
14070 let (mut parts, body) = res.into_parts();
14071 let mut body = common::Body::new(body);
14072 if !parts.status.is_success() {
14073 let bytes = common::to_bytes(body).await.unwrap_or_default();
14074 let error = serde_json::from_str(&common::to_string(&bytes));
14075 let response = common::to_response(parts, bytes.into());
14076
14077 if let common::Retry::After(d) =
14078 dlg.http_failure(&response, error.as_ref().ok())
14079 {
14080 sleep(d).await;
14081 continue;
14082 }
14083
14084 dlg.finished(false);
14085
14086 return Err(match error {
14087 Ok(value) => common::Error::BadRequest(value),
14088 _ => common::Error::Failure(response),
14089 });
14090 }
14091 let response = {
14092 let bytes = common::to_bytes(body).await.unwrap_or_default();
14093 let encoded = common::to_string(&bytes);
14094 match serde_json::from_str(&encoded) {
14095 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14096 Err(error) => {
14097 dlg.response_json_decode_error(&encoded, &error);
14098 return Err(common::Error::JsonDecodeError(
14099 encoded.to_string(),
14100 error,
14101 ));
14102 }
14103 }
14104 };
14105
14106 dlg.finished(true);
14107 return Ok(response);
14108 }
14109 }
14110 }
14111 }
14112
14113 /// Required. The name of the SSH key to delete. Currently, the only valid value for the location is "global".
14114 ///
14115 /// Sets the *name* path property to the given value.
14116 ///
14117 /// Even though the property as already been set when instantiating this call,
14118 /// we provide this method for API completeness.
14119 pub fn name(mut self, new_value: &str) -> ProjectLocationSshKeyDeleteCall<'a, C> {
14120 self._name = new_value.to_string();
14121 self
14122 }
14123 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14124 /// while executing the actual API request.
14125 ///
14126 /// ````text
14127 /// It should be used to handle progress information, and to implement a certain level of resilience.
14128 /// ````
14129 ///
14130 /// Sets the *delegate* property to the given value.
14131 pub fn delegate(
14132 mut self,
14133 new_value: &'a mut dyn common::Delegate,
14134 ) -> ProjectLocationSshKeyDeleteCall<'a, C> {
14135 self._delegate = Some(new_value);
14136 self
14137 }
14138
14139 /// Set any additional parameter of the query string used in the request.
14140 /// It should be used to set parameters which are not yet available through their own
14141 /// setters.
14142 ///
14143 /// Please note that this method must not be used to set any of the known parameters
14144 /// which have their own setter method. If done anyway, the request will fail.
14145 ///
14146 /// # Additional Parameters
14147 ///
14148 /// * *$.xgafv* (query-string) - V1 error format.
14149 /// * *access_token* (query-string) - OAuth access token.
14150 /// * *alt* (query-string) - Data format for response.
14151 /// * *callback* (query-string) - JSONP
14152 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14153 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14154 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14155 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14156 /// * *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.
14157 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14158 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14159 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSshKeyDeleteCall<'a, C>
14160 where
14161 T: AsRef<str>,
14162 {
14163 self._additional_params
14164 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14165 self
14166 }
14167
14168 /// Identifies the authorization scope for the method you are building.
14169 ///
14170 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14171 /// [`Scope::CloudPlatform`].
14172 ///
14173 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14174 /// tokens for more than one scope.
14175 ///
14176 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14177 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14178 /// sufficient, a read-write scope will do as well.
14179 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSshKeyDeleteCall<'a, C>
14180 where
14181 St: AsRef<str>,
14182 {
14183 self._scopes.insert(String::from(scope.as_ref()));
14184 self
14185 }
14186 /// Identifies the authorization scope(s) for the method you are building.
14187 ///
14188 /// See [`Self::add_scope()`] for details.
14189 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSshKeyDeleteCall<'a, C>
14190 where
14191 I: IntoIterator<Item = St>,
14192 St: AsRef<str>,
14193 {
14194 self._scopes
14195 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14196 self
14197 }
14198
14199 /// Removes all scopes, and no default scope will be used either.
14200 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14201 /// for details).
14202 pub fn clear_scopes(mut self) -> ProjectLocationSshKeyDeleteCall<'a, C> {
14203 self._scopes.clear();
14204 self
14205 }
14206}
14207
14208/// Lists the public SSH keys registered for the specified project. These SSH keys are used only for the interactive serial console feature.
14209///
14210/// A builder for the *locations.sshKeys.list* method supported by a *project* resource.
14211/// It is not used directly, but through a [`ProjectMethods`] instance.
14212///
14213/// # Example
14214///
14215/// Instantiate a resource method builder
14216///
14217/// ```test_harness,no_run
14218/// # extern crate hyper;
14219/// # extern crate hyper_rustls;
14220/// # extern crate google_baremetalsolution2 as baremetalsolution2;
14221/// # async fn dox() {
14222/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14223///
14224/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14225/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14226/// # secret,
14227/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14228/// # ).build().await.unwrap();
14229///
14230/// # let client = hyper_util::client::legacy::Client::builder(
14231/// # hyper_util::rt::TokioExecutor::new()
14232/// # )
14233/// # .build(
14234/// # hyper_rustls::HttpsConnectorBuilder::new()
14235/// # .with_native_roots()
14236/// # .unwrap()
14237/// # .https_or_http()
14238/// # .enable_http1()
14239/// # .build()
14240/// # );
14241/// # let mut hub = Baremetalsolution::new(client, auth);
14242/// // You can configure optional parameters by calling the respective setters at will, and
14243/// // execute the final call using `doit()`.
14244/// // Values shown here are possibly random and not representative !
14245/// let result = hub.projects().locations_ssh_keys_list("parent")
14246/// .page_token("amet.")
14247/// .page_size(-96)
14248/// .doit().await;
14249/// # }
14250/// ```
14251pub struct ProjectLocationSshKeyListCall<'a, C>
14252where
14253 C: 'a,
14254{
14255 hub: &'a Baremetalsolution<C>,
14256 _parent: String,
14257 _page_token: Option<String>,
14258 _page_size: Option<i32>,
14259 _delegate: Option<&'a mut dyn common::Delegate>,
14260 _additional_params: HashMap<String, String>,
14261 _scopes: BTreeSet<String>,
14262}
14263
14264impl<'a, C> common::CallBuilder for ProjectLocationSshKeyListCall<'a, C> {}
14265
14266impl<'a, C> ProjectLocationSshKeyListCall<'a, C>
14267where
14268 C: common::Connector,
14269{
14270 /// Perform the operation you have build so far.
14271 pub async fn doit(mut self) -> common::Result<(common::Response, ListSSHKeysResponse)> {
14272 use std::borrow::Cow;
14273 use std::io::{Read, Seek};
14274
14275 use common::{url::Params, ToParts};
14276 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14277
14278 let mut dd = common::DefaultDelegate;
14279 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14280 dlg.begin(common::MethodInfo {
14281 id: "baremetalsolution.projects.locations.sshKeys.list",
14282 http_method: hyper::Method::GET,
14283 });
14284
14285 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
14286 if self._additional_params.contains_key(field) {
14287 dlg.finished(false);
14288 return Err(common::Error::FieldClash(field));
14289 }
14290 }
14291
14292 let mut params = Params::with_capacity(5 + self._additional_params.len());
14293 params.push("parent", self._parent);
14294 if let Some(value) = self._page_token.as_ref() {
14295 params.push("pageToken", value);
14296 }
14297 if let Some(value) = self._page_size.as_ref() {
14298 params.push("pageSize", value.to_string());
14299 }
14300
14301 params.extend(self._additional_params.iter());
14302
14303 params.push("alt", "json");
14304 let mut url = self.hub._base_url.clone() + "v2/{+parent}/sshKeys";
14305 if self._scopes.is_empty() {
14306 self._scopes
14307 .insert(Scope::CloudPlatform.as_ref().to_string());
14308 }
14309
14310 #[allow(clippy::single_element_loop)]
14311 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14312 url = params.uri_replacement(url, param_name, find_this, true);
14313 }
14314 {
14315 let to_remove = ["parent"];
14316 params.remove_params(&to_remove);
14317 }
14318
14319 let url = params.parse_with_url(&url);
14320
14321 loop {
14322 let token = match self
14323 .hub
14324 .auth
14325 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14326 .await
14327 {
14328 Ok(token) => token,
14329 Err(e) => match dlg.token(e) {
14330 Ok(token) => token,
14331 Err(e) => {
14332 dlg.finished(false);
14333 return Err(common::Error::MissingToken(e));
14334 }
14335 },
14336 };
14337 let mut req_result = {
14338 let client = &self.hub.client;
14339 dlg.pre_request();
14340 let mut req_builder = hyper::Request::builder()
14341 .method(hyper::Method::GET)
14342 .uri(url.as_str())
14343 .header(USER_AGENT, self.hub._user_agent.clone());
14344
14345 if let Some(token) = token.as_ref() {
14346 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14347 }
14348
14349 let request = req_builder
14350 .header(CONTENT_LENGTH, 0_u64)
14351 .body(common::to_body::<String>(None));
14352
14353 client.request(request.unwrap()).await
14354 };
14355
14356 match req_result {
14357 Err(err) => {
14358 if let common::Retry::After(d) = dlg.http_error(&err) {
14359 sleep(d).await;
14360 continue;
14361 }
14362 dlg.finished(false);
14363 return Err(common::Error::HttpError(err));
14364 }
14365 Ok(res) => {
14366 let (mut parts, body) = res.into_parts();
14367 let mut body = common::Body::new(body);
14368 if !parts.status.is_success() {
14369 let bytes = common::to_bytes(body).await.unwrap_or_default();
14370 let error = serde_json::from_str(&common::to_string(&bytes));
14371 let response = common::to_response(parts, bytes.into());
14372
14373 if let common::Retry::After(d) =
14374 dlg.http_failure(&response, error.as_ref().ok())
14375 {
14376 sleep(d).await;
14377 continue;
14378 }
14379
14380 dlg.finished(false);
14381
14382 return Err(match error {
14383 Ok(value) => common::Error::BadRequest(value),
14384 _ => common::Error::Failure(response),
14385 });
14386 }
14387 let response = {
14388 let bytes = common::to_bytes(body).await.unwrap_or_default();
14389 let encoded = common::to_string(&bytes);
14390 match serde_json::from_str(&encoded) {
14391 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14392 Err(error) => {
14393 dlg.response_json_decode_error(&encoded, &error);
14394 return Err(common::Error::JsonDecodeError(
14395 encoded.to_string(),
14396 error,
14397 ));
14398 }
14399 }
14400 };
14401
14402 dlg.finished(true);
14403 return Ok(response);
14404 }
14405 }
14406 }
14407 }
14408
14409 /// Required. The parent containing the SSH keys. Currently, the only valid value for the location is "global".
14410 ///
14411 /// Sets the *parent* path property to the given value.
14412 ///
14413 /// Even though the property as already been set when instantiating this call,
14414 /// we provide this method for API completeness.
14415 pub fn parent(mut self, new_value: &str) -> ProjectLocationSshKeyListCall<'a, C> {
14416 self._parent = new_value.to_string();
14417 self
14418 }
14419 /// The next_page_token value returned from a previous List request, if any.
14420 ///
14421 /// Sets the *page token* query property to the given value.
14422 pub fn page_token(mut self, new_value: &str) -> ProjectLocationSshKeyListCall<'a, C> {
14423 self._page_token = Some(new_value.to_string());
14424 self
14425 }
14426 /// The maximum number of items to return.
14427 ///
14428 /// Sets the *page size* query property to the given value.
14429 pub fn page_size(mut self, new_value: i32) -> ProjectLocationSshKeyListCall<'a, C> {
14430 self._page_size = Some(new_value);
14431 self
14432 }
14433 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14434 /// while executing the actual API request.
14435 ///
14436 /// ````text
14437 /// It should be used to handle progress information, and to implement a certain level of resilience.
14438 /// ````
14439 ///
14440 /// Sets the *delegate* property to the given value.
14441 pub fn delegate(
14442 mut self,
14443 new_value: &'a mut dyn common::Delegate,
14444 ) -> ProjectLocationSshKeyListCall<'a, C> {
14445 self._delegate = Some(new_value);
14446 self
14447 }
14448
14449 /// Set any additional parameter of the query string used in the request.
14450 /// It should be used to set parameters which are not yet available through their own
14451 /// setters.
14452 ///
14453 /// Please note that this method must not be used to set any of the known parameters
14454 /// which have their own setter method. If done anyway, the request will fail.
14455 ///
14456 /// # Additional Parameters
14457 ///
14458 /// * *$.xgafv* (query-string) - V1 error format.
14459 /// * *access_token* (query-string) - OAuth access token.
14460 /// * *alt* (query-string) - Data format for response.
14461 /// * *callback* (query-string) - JSONP
14462 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14463 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14464 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14465 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14466 /// * *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.
14467 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14468 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14469 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSshKeyListCall<'a, C>
14470 where
14471 T: AsRef<str>,
14472 {
14473 self._additional_params
14474 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14475 self
14476 }
14477
14478 /// Identifies the authorization scope for the method you are building.
14479 ///
14480 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14481 /// [`Scope::CloudPlatform`].
14482 ///
14483 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14484 /// tokens for more than one scope.
14485 ///
14486 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14487 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14488 /// sufficient, a read-write scope will do as well.
14489 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSshKeyListCall<'a, C>
14490 where
14491 St: AsRef<str>,
14492 {
14493 self._scopes.insert(String::from(scope.as_ref()));
14494 self
14495 }
14496 /// Identifies the authorization scope(s) for the method you are building.
14497 ///
14498 /// See [`Self::add_scope()`] for details.
14499 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSshKeyListCall<'a, C>
14500 where
14501 I: IntoIterator<Item = St>,
14502 St: AsRef<str>,
14503 {
14504 self._scopes
14505 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14506 self
14507 }
14508
14509 /// Removes all scopes, and no default scope will be used either.
14510 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14511 /// for details).
14512 pub fn clear_scopes(mut self) -> ProjectLocationSshKeyListCall<'a, C> {
14513 self._scopes.clear();
14514 self
14515 }
14516}
14517
14518/// Skips lun's cooloff and deletes it now. Lun must be in cooloff state.
14519///
14520/// A builder for the *locations.volumes.luns.evict* method supported by a *project* resource.
14521/// It is not used directly, but through a [`ProjectMethods`] instance.
14522///
14523/// # Example
14524///
14525/// Instantiate a resource method builder
14526///
14527/// ```test_harness,no_run
14528/// # extern crate hyper;
14529/// # extern crate hyper_rustls;
14530/// # extern crate google_baremetalsolution2 as baremetalsolution2;
14531/// use baremetalsolution2::api::EvictLunRequest;
14532/// # async fn dox() {
14533/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14534///
14535/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14536/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14537/// # secret,
14538/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14539/// # ).build().await.unwrap();
14540///
14541/// # let client = hyper_util::client::legacy::Client::builder(
14542/// # hyper_util::rt::TokioExecutor::new()
14543/// # )
14544/// # .build(
14545/// # hyper_rustls::HttpsConnectorBuilder::new()
14546/// # .with_native_roots()
14547/// # .unwrap()
14548/// # .https_or_http()
14549/// # .enable_http1()
14550/// # .build()
14551/// # );
14552/// # let mut hub = Baremetalsolution::new(client, auth);
14553/// // As the method needs a request, you would usually fill it with the desired information
14554/// // into the respective structure. Some of the parts shown here might not be applicable !
14555/// // Values shown here are possibly random and not representative !
14556/// let mut req = EvictLunRequest::default();
14557///
14558/// // You can configure optional parameters by calling the respective setters at will, and
14559/// // execute the final call using `doit()`.
14560/// // Values shown here are possibly random and not representative !
14561/// let result = hub.projects().locations_volumes_luns_evict(req, "name")
14562/// .doit().await;
14563/// # }
14564/// ```
14565pub struct ProjectLocationVolumeLunEvictCall<'a, C>
14566where
14567 C: 'a,
14568{
14569 hub: &'a Baremetalsolution<C>,
14570 _request: EvictLunRequest,
14571 _name: String,
14572 _delegate: Option<&'a mut dyn common::Delegate>,
14573 _additional_params: HashMap<String, String>,
14574 _scopes: BTreeSet<String>,
14575}
14576
14577impl<'a, C> common::CallBuilder for ProjectLocationVolumeLunEvictCall<'a, C> {}
14578
14579impl<'a, C> ProjectLocationVolumeLunEvictCall<'a, C>
14580where
14581 C: common::Connector,
14582{
14583 /// Perform the operation you have build so far.
14584 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
14585 use std::borrow::Cow;
14586 use std::io::{Read, Seek};
14587
14588 use common::{url::Params, ToParts};
14589 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14590
14591 let mut dd = common::DefaultDelegate;
14592 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14593 dlg.begin(common::MethodInfo {
14594 id: "baremetalsolution.projects.locations.volumes.luns.evict",
14595 http_method: hyper::Method::POST,
14596 });
14597
14598 for &field in ["alt", "name"].iter() {
14599 if self._additional_params.contains_key(field) {
14600 dlg.finished(false);
14601 return Err(common::Error::FieldClash(field));
14602 }
14603 }
14604
14605 let mut params = Params::with_capacity(4 + self._additional_params.len());
14606 params.push("name", self._name);
14607
14608 params.extend(self._additional_params.iter());
14609
14610 params.push("alt", "json");
14611 let mut url = self.hub._base_url.clone() + "v2/{+name}:evict";
14612 if self._scopes.is_empty() {
14613 self._scopes
14614 .insert(Scope::CloudPlatform.as_ref().to_string());
14615 }
14616
14617 #[allow(clippy::single_element_loop)]
14618 for &(find_this, param_name) in [("{+name}", "name")].iter() {
14619 url = params.uri_replacement(url, param_name, find_this, true);
14620 }
14621 {
14622 let to_remove = ["name"];
14623 params.remove_params(&to_remove);
14624 }
14625
14626 let url = params.parse_with_url(&url);
14627
14628 let mut json_mime_type = mime::APPLICATION_JSON;
14629 let mut request_value_reader = {
14630 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14631 common::remove_json_null_values(&mut value);
14632 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14633 serde_json::to_writer(&mut dst, &value).unwrap();
14634 dst
14635 };
14636 let request_size = request_value_reader
14637 .seek(std::io::SeekFrom::End(0))
14638 .unwrap();
14639 request_value_reader
14640 .seek(std::io::SeekFrom::Start(0))
14641 .unwrap();
14642
14643 loop {
14644 let token = match self
14645 .hub
14646 .auth
14647 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14648 .await
14649 {
14650 Ok(token) => token,
14651 Err(e) => match dlg.token(e) {
14652 Ok(token) => token,
14653 Err(e) => {
14654 dlg.finished(false);
14655 return Err(common::Error::MissingToken(e));
14656 }
14657 },
14658 };
14659 request_value_reader
14660 .seek(std::io::SeekFrom::Start(0))
14661 .unwrap();
14662 let mut req_result = {
14663 let client = &self.hub.client;
14664 dlg.pre_request();
14665 let mut req_builder = hyper::Request::builder()
14666 .method(hyper::Method::POST)
14667 .uri(url.as_str())
14668 .header(USER_AGENT, self.hub._user_agent.clone());
14669
14670 if let Some(token) = token.as_ref() {
14671 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14672 }
14673
14674 let request = req_builder
14675 .header(CONTENT_TYPE, json_mime_type.to_string())
14676 .header(CONTENT_LENGTH, request_size as u64)
14677 .body(common::to_body(
14678 request_value_reader.get_ref().clone().into(),
14679 ));
14680
14681 client.request(request.unwrap()).await
14682 };
14683
14684 match req_result {
14685 Err(err) => {
14686 if let common::Retry::After(d) = dlg.http_error(&err) {
14687 sleep(d).await;
14688 continue;
14689 }
14690 dlg.finished(false);
14691 return Err(common::Error::HttpError(err));
14692 }
14693 Ok(res) => {
14694 let (mut parts, body) = res.into_parts();
14695 let mut body = common::Body::new(body);
14696 if !parts.status.is_success() {
14697 let bytes = common::to_bytes(body).await.unwrap_or_default();
14698 let error = serde_json::from_str(&common::to_string(&bytes));
14699 let response = common::to_response(parts, bytes.into());
14700
14701 if let common::Retry::After(d) =
14702 dlg.http_failure(&response, error.as_ref().ok())
14703 {
14704 sleep(d).await;
14705 continue;
14706 }
14707
14708 dlg.finished(false);
14709
14710 return Err(match error {
14711 Ok(value) => common::Error::BadRequest(value),
14712 _ => common::Error::Failure(response),
14713 });
14714 }
14715 let response = {
14716 let bytes = common::to_bytes(body).await.unwrap_or_default();
14717 let encoded = common::to_string(&bytes);
14718 match serde_json::from_str(&encoded) {
14719 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14720 Err(error) => {
14721 dlg.response_json_decode_error(&encoded, &error);
14722 return Err(common::Error::JsonDecodeError(
14723 encoded.to_string(),
14724 error,
14725 ));
14726 }
14727 }
14728 };
14729
14730 dlg.finished(true);
14731 return Ok(response);
14732 }
14733 }
14734 }
14735 }
14736
14737 ///
14738 /// Sets the *request* property to the given value.
14739 ///
14740 /// Even though the property as already been set when instantiating this call,
14741 /// we provide this method for API completeness.
14742 pub fn request(
14743 mut self,
14744 new_value: EvictLunRequest,
14745 ) -> ProjectLocationVolumeLunEvictCall<'a, C> {
14746 self._request = new_value;
14747 self
14748 }
14749 /// Required. The name of the lun.
14750 ///
14751 /// Sets the *name* path property to the given value.
14752 ///
14753 /// Even though the property as already been set when instantiating this call,
14754 /// we provide this method for API completeness.
14755 pub fn name(mut self, new_value: &str) -> ProjectLocationVolumeLunEvictCall<'a, C> {
14756 self._name = new_value.to_string();
14757 self
14758 }
14759 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14760 /// while executing the actual API request.
14761 ///
14762 /// ````text
14763 /// It should be used to handle progress information, and to implement a certain level of resilience.
14764 /// ````
14765 ///
14766 /// Sets the *delegate* property to the given value.
14767 pub fn delegate(
14768 mut self,
14769 new_value: &'a mut dyn common::Delegate,
14770 ) -> ProjectLocationVolumeLunEvictCall<'a, C> {
14771 self._delegate = Some(new_value);
14772 self
14773 }
14774
14775 /// Set any additional parameter of the query string used in the request.
14776 /// It should be used to set parameters which are not yet available through their own
14777 /// setters.
14778 ///
14779 /// Please note that this method must not be used to set any of the known parameters
14780 /// which have their own setter method. If done anyway, the request will fail.
14781 ///
14782 /// # Additional Parameters
14783 ///
14784 /// * *$.xgafv* (query-string) - V1 error format.
14785 /// * *access_token* (query-string) - OAuth access token.
14786 /// * *alt* (query-string) - Data format for response.
14787 /// * *callback* (query-string) - JSONP
14788 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14789 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14790 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14791 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14792 /// * *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.
14793 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14794 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14795 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeLunEvictCall<'a, C>
14796 where
14797 T: AsRef<str>,
14798 {
14799 self._additional_params
14800 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14801 self
14802 }
14803
14804 /// Identifies the authorization scope for the method you are building.
14805 ///
14806 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14807 /// [`Scope::CloudPlatform`].
14808 ///
14809 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14810 /// tokens for more than one scope.
14811 ///
14812 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14813 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14814 /// sufficient, a read-write scope will do as well.
14815 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeLunEvictCall<'a, C>
14816 where
14817 St: AsRef<str>,
14818 {
14819 self._scopes.insert(String::from(scope.as_ref()));
14820 self
14821 }
14822 /// Identifies the authorization scope(s) for the method you are building.
14823 ///
14824 /// See [`Self::add_scope()`] for details.
14825 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeLunEvictCall<'a, C>
14826 where
14827 I: IntoIterator<Item = St>,
14828 St: AsRef<str>,
14829 {
14830 self._scopes
14831 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14832 self
14833 }
14834
14835 /// Removes all scopes, and no default scope will be used either.
14836 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14837 /// for details).
14838 pub fn clear_scopes(mut self) -> ProjectLocationVolumeLunEvictCall<'a, C> {
14839 self._scopes.clear();
14840 self
14841 }
14842}
14843
14844/// Get details of a single storage logical unit number(LUN).
14845///
14846/// A builder for the *locations.volumes.luns.get* method supported by a *project* resource.
14847/// It is not used directly, but through a [`ProjectMethods`] instance.
14848///
14849/// # Example
14850///
14851/// Instantiate a resource method builder
14852///
14853/// ```test_harness,no_run
14854/// # extern crate hyper;
14855/// # extern crate hyper_rustls;
14856/// # extern crate google_baremetalsolution2 as baremetalsolution2;
14857/// # async fn dox() {
14858/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14859///
14860/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14861/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14862/// # secret,
14863/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14864/// # ).build().await.unwrap();
14865///
14866/// # let client = hyper_util::client::legacy::Client::builder(
14867/// # hyper_util::rt::TokioExecutor::new()
14868/// # )
14869/// # .build(
14870/// # hyper_rustls::HttpsConnectorBuilder::new()
14871/// # .with_native_roots()
14872/// # .unwrap()
14873/// # .https_or_http()
14874/// # .enable_http1()
14875/// # .build()
14876/// # );
14877/// # let mut hub = Baremetalsolution::new(client, auth);
14878/// // You can configure optional parameters by calling the respective setters at will, and
14879/// // execute the final call using `doit()`.
14880/// // Values shown here are possibly random and not representative !
14881/// let result = hub.projects().locations_volumes_luns_get("name")
14882/// .doit().await;
14883/// # }
14884/// ```
14885pub struct ProjectLocationVolumeLunGetCall<'a, C>
14886where
14887 C: 'a,
14888{
14889 hub: &'a Baremetalsolution<C>,
14890 _name: String,
14891 _delegate: Option<&'a mut dyn common::Delegate>,
14892 _additional_params: HashMap<String, String>,
14893 _scopes: BTreeSet<String>,
14894}
14895
14896impl<'a, C> common::CallBuilder for ProjectLocationVolumeLunGetCall<'a, C> {}
14897
14898impl<'a, C> ProjectLocationVolumeLunGetCall<'a, C>
14899where
14900 C: common::Connector,
14901{
14902 /// Perform the operation you have build so far.
14903 pub async fn doit(mut self) -> common::Result<(common::Response, Lun)> {
14904 use std::borrow::Cow;
14905 use std::io::{Read, Seek};
14906
14907 use common::{url::Params, ToParts};
14908 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14909
14910 let mut dd = common::DefaultDelegate;
14911 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14912 dlg.begin(common::MethodInfo {
14913 id: "baremetalsolution.projects.locations.volumes.luns.get",
14914 http_method: hyper::Method::GET,
14915 });
14916
14917 for &field in ["alt", "name"].iter() {
14918 if self._additional_params.contains_key(field) {
14919 dlg.finished(false);
14920 return Err(common::Error::FieldClash(field));
14921 }
14922 }
14923
14924 let mut params = Params::with_capacity(3 + self._additional_params.len());
14925 params.push("name", self._name);
14926
14927 params.extend(self._additional_params.iter());
14928
14929 params.push("alt", "json");
14930 let mut url = self.hub._base_url.clone() + "v2/{+name}";
14931 if self._scopes.is_empty() {
14932 self._scopes
14933 .insert(Scope::CloudPlatform.as_ref().to_string());
14934 }
14935
14936 #[allow(clippy::single_element_loop)]
14937 for &(find_this, param_name) in [("{+name}", "name")].iter() {
14938 url = params.uri_replacement(url, param_name, find_this, true);
14939 }
14940 {
14941 let to_remove = ["name"];
14942 params.remove_params(&to_remove);
14943 }
14944
14945 let url = params.parse_with_url(&url);
14946
14947 loop {
14948 let token = match self
14949 .hub
14950 .auth
14951 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14952 .await
14953 {
14954 Ok(token) => token,
14955 Err(e) => match dlg.token(e) {
14956 Ok(token) => token,
14957 Err(e) => {
14958 dlg.finished(false);
14959 return Err(common::Error::MissingToken(e));
14960 }
14961 },
14962 };
14963 let mut req_result = {
14964 let client = &self.hub.client;
14965 dlg.pre_request();
14966 let mut req_builder = hyper::Request::builder()
14967 .method(hyper::Method::GET)
14968 .uri(url.as_str())
14969 .header(USER_AGENT, self.hub._user_agent.clone());
14970
14971 if let Some(token) = token.as_ref() {
14972 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14973 }
14974
14975 let request = req_builder
14976 .header(CONTENT_LENGTH, 0_u64)
14977 .body(common::to_body::<String>(None));
14978
14979 client.request(request.unwrap()).await
14980 };
14981
14982 match req_result {
14983 Err(err) => {
14984 if let common::Retry::After(d) = dlg.http_error(&err) {
14985 sleep(d).await;
14986 continue;
14987 }
14988 dlg.finished(false);
14989 return Err(common::Error::HttpError(err));
14990 }
14991 Ok(res) => {
14992 let (mut parts, body) = res.into_parts();
14993 let mut body = common::Body::new(body);
14994 if !parts.status.is_success() {
14995 let bytes = common::to_bytes(body).await.unwrap_or_default();
14996 let error = serde_json::from_str(&common::to_string(&bytes));
14997 let response = common::to_response(parts, bytes.into());
14998
14999 if let common::Retry::After(d) =
15000 dlg.http_failure(&response, error.as_ref().ok())
15001 {
15002 sleep(d).await;
15003 continue;
15004 }
15005
15006 dlg.finished(false);
15007
15008 return Err(match error {
15009 Ok(value) => common::Error::BadRequest(value),
15010 _ => common::Error::Failure(response),
15011 });
15012 }
15013 let response = {
15014 let bytes = common::to_bytes(body).await.unwrap_or_default();
15015 let encoded = common::to_string(&bytes);
15016 match serde_json::from_str(&encoded) {
15017 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15018 Err(error) => {
15019 dlg.response_json_decode_error(&encoded, &error);
15020 return Err(common::Error::JsonDecodeError(
15021 encoded.to_string(),
15022 error,
15023 ));
15024 }
15025 }
15026 };
15027
15028 dlg.finished(true);
15029 return Ok(response);
15030 }
15031 }
15032 }
15033 }
15034
15035 /// Required. Name of the resource.
15036 ///
15037 /// Sets the *name* path property to the given value.
15038 ///
15039 /// Even though the property as already been set when instantiating this call,
15040 /// we provide this method for API completeness.
15041 pub fn name(mut self, new_value: &str) -> ProjectLocationVolumeLunGetCall<'a, C> {
15042 self._name = new_value.to_string();
15043 self
15044 }
15045 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15046 /// while executing the actual API request.
15047 ///
15048 /// ````text
15049 /// It should be used to handle progress information, and to implement a certain level of resilience.
15050 /// ````
15051 ///
15052 /// Sets the *delegate* property to the given value.
15053 pub fn delegate(
15054 mut self,
15055 new_value: &'a mut dyn common::Delegate,
15056 ) -> ProjectLocationVolumeLunGetCall<'a, C> {
15057 self._delegate = Some(new_value);
15058 self
15059 }
15060
15061 /// Set any additional parameter of the query string used in the request.
15062 /// It should be used to set parameters which are not yet available through their own
15063 /// setters.
15064 ///
15065 /// Please note that this method must not be used to set any of the known parameters
15066 /// which have their own setter method. If done anyway, the request will fail.
15067 ///
15068 /// # Additional Parameters
15069 ///
15070 /// * *$.xgafv* (query-string) - V1 error format.
15071 /// * *access_token* (query-string) - OAuth access token.
15072 /// * *alt* (query-string) - Data format for response.
15073 /// * *callback* (query-string) - JSONP
15074 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15075 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15076 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15077 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15078 /// * *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.
15079 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15080 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15081 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeLunGetCall<'a, C>
15082 where
15083 T: AsRef<str>,
15084 {
15085 self._additional_params
15086 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15087 self
15088 }
15089
15090 /// Identifies the authorization scope for the method you are building.
15091 ///
15092 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15093 /// [`Scope::CloudPlatform`].
15094 ///
15095 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15096 /// tokens for more than one scope.
15097 ///
15098 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15099 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15100 /// sufficient, a read-write scope will do as well.
15101 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeLunGetCall<'a, C>
15102 where
15103 St: AsRef<str>,
15104 {
15105 self._scopes.insert(String::from(scope.as_ref()));
15106 self
15107 }
15108 /// Identifies the authorization scope(s) for the method you are building.
15109 ///
15110 /// See [`Self::add_scope()`] for details.
15111 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeLunGetCall<'a, C>
15112 where
15113 I: IntoIterator<Item = St>,
15114 St: AsRef<str>,
15115 {
15116 self._scopes
15117 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15118 self
15119 }
15120
15121 /// Removes all scopes, and no default scope will be used either.
15122 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15123 /// for details).
15124 pub fn clear_scopes(mut self) -> ProjectLocationVolumeLunGetCall<'a, C> {
15125 self._scopes.clear();
15126 self
15127 }
15128}
15129
15130/// List storage volume luns for given storage volume.
15131///
15132/// A builder for the *locations.volumes.luns.list* method supported by a *project* resource.
15133/// It is not used directly, but through a [`ProjectMethods`] instance.
15134///
15135/// # Example
15136///
15137/// Instantiate a resource method builder
15138///
15139/// ```test_harness,no_run
15140/// # extern crate hyper;
15141/// # extern crate hyper_rustls;
15142/// # extern crate google_baremetalsolution2 as baremetalsolution2;
15143/// # async fn dox() {
15144/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15145///
15146/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15147/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15148/// # secret,
15149/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15150/// # ).build().await.unwrap();
15151///
15152/// # let client = hyper_util::client::legacy::Client::builder(
15153/// # hyper_util::rt::TokioExecutor::new()
15154/// # )
15155/// # .build(
15156/// # hyper_rustls::HttpsConnectorBuilder::new()
15157/// # .with_native_roots()
15158/// # .unwrap()
15159/// # .https_or_http()
15160/// # .enable_http1()
15161/// # .build()
15162/// # );
15163/// # let mut hub = Baremetalsolution::new(client, auth);
15164/// // You can configure optional parameters by calling the respective setters at will, and
15165/// // execute the final call using `doit()`.
15166/// // Values shown here are possibly random and not representative !
15167/// let result = hub.projects().locations_volumes_luns_list("parent")
15168/// .page_token("et")
15169/// .page_size(-95)
15170/// .doit().await;
15171/// # }
15172/// ```
15173pub struct ProjectLocationVolumeLunListCall<'a, C>
15174where
15175 C: 'a,
15176{
15177 hub: &'a Baremetalsolution<C>,
15178 _parent: String,
15179 _page_token: Option<String>,
15180 _page_size: Option<i32>,
15181 _delegate: Option<&'a mut dyn common::Delegate>,
15182 _additional_params: HashMap<String, String>,
15183 _scopes: BTreeSet<String>,
15184}
15185
15186impl<'a, C> common::CallBuilder for ProjectLocationVolumeLunListCall<'a, C> {}
15187
15188impl<'a, C> ProjectLocationVolumeLunListCall<'a, C>
15189where
15190 C: common::Connector,
15191{
15192 /// Perform the operation you have build so far.
15193 pub async fn doit(mut self) -> common::Result<(common::Response, ListLunsResponse)> {
15194 use std::borrow::Cow;
15195 use std::io::{Read, Seek};
15196
15197 use common::{url::Params, ToParts};
15198 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15199
15200 let mut dd = common::DefaultDelegate;
15201 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15202 dlg.begin(common::MethodInfo {
15203 id: "baremetalsolution.projects.locations.volumes.luns.list",
15204 http_method: hyper::Method::GET,
15205 });
15206
15207 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
15208 if self._additional_params.contains_key(field) {
15209 dlg.finished(false);
15210 return Err(common::Error::FieldClash(field));
15211 }
15212 }
15213
15214 let mut params = Params::with_capacity(5 + self._additional_params.len());
15215 params.push("parent", self._parent);
15216 if let Some(value) = self._page_token.as_ref() {
15217 params.push("pageToken", value);
15218 }
15219 if let Some(value) = self._page_size.as_ref() {
15220 params.push("pageSize", value.to_string());
15221 }
15222
15223 params.extend(self._additional_params.iter());
15224
15225 params.push("alt", "json");
15226 let mut url = self.hub._base_url.clone() + "v2/{+parent}/luns";
15227 if self._scopes.is_empty() {
15228 self._scopes
15229 .insert(Scope::CloudPlatform.as_ref().to_string());
15230 }
15231
15232 #[allow(clippy::single_element_loop)]
15233 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
15234 url = params.uri_replacement(url, param_name, find_this, true);
15235 }
15236 {
15237 let to_remove = ["parent"];
15238 params.remove_params(&to_remove);
15239 }
15240
15241 let url = params.parse_with_url(&url);
15242
15243 loop {
15244 let token = match self
15245 .hub
15246 .auth
15247 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15248 .await
15249 {
15250 Ok(token) => token,
15251 Err(e) => match dlg.token(e) {
15252 Ok(token) => token,
15253 Err(e) => {
15254 dlg.finished(false);
15255 return Err(common::Error::MissingToken(e));
15256 }
15257 },
15258 };
15259 let mut req_result = {
15260 let client = &self.hub.client;
15261 dlg.pre_request();
15262 let mut req_builder = hyper::Request::builder()
15263 .method(hyper::Method::GET)
15264 .uri(url.as_str())
15265 .header(USER_AGENT, self.hub._user_agent.clone());
15266
15267 if let Some(token) = token.as_ref() {
15268 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15269 }
15270
15271 let request = req_builder
15272 .header(CONTENT_LENGTH, 0_u64)
15273 .body(common::to_body::<String>(None));
15274
15275 client.request(request.unwrap()).await
15276 };
15277
15278 match req_result {
15279 Err(err) => {
15280 if let common::Retry::After(d) = dlg.http_error(&err) {
15281 sleep(d).await;
15282 continue;
15283 }
15284 dlg.finished(false);
15285 return Err(common::Error::HttpError(err));
15286 }
15287 Ok(res) => {
15288 let (mut parts, body) = res.into_parts();
15289 let mut body = common::Body::new(body);
15290 if !parts.status.is_success() {
15291 let bytes = common::to_bytes(body).await.unwrap_or_default();
15292 let error = serde_json::from_str(&common::to_string(&bytes));
15293 let response = common::to_response(parts, bytes.into());
15294
15295 if let common::Retry::After(d) =
15296 dlg.http_failure(&response, error.as_ref().ok())
15297 {
15298 sleep(d).await;
15299 continue;
15300 }
15301
15302 dlg.finished(false);
15303
15304 return Err(match error {
15305 Ok(value) => common::Error::BadRequest(value),
15306 _ => common::Error::Failure(response),
15307 });
15308 }
15309 let response = {
15310 let bytes = common::to_bytes(body).await.unwrap_or_default();
15311 let encoded = common::to_string(&bytes);
15312 match serde_json::from_str(&encoded) {
15313 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15314 Err(error) => {
15315 dlg.response_json_decode_error(&encoded, &error);
15316 return Err(common::Error::JsonDecodeError(
15317 encoded.to_string(),
15318 error,
15319 ));
15320 }
15321 }
15322 };
15323
15324 dlg.finished(true);
15325 return Ok(response);
15326 }
15327 }
15328 }
15329 }
15330
15331 /// Required. Parent value for ListLunsRequest.
15332 ///
15333 /// Sets the *parent* path property to the given value.
15334 ///
15335 /// Even though the property as already been set when instantiating this call,
15336 /// we provide this method for API completeness.
15337 pub fn parent(mut self, new_value: &str) -> ProjectLocationVolumeLunListCall<'a, C> {
15338 self._parent = new_value.to_string();
15339 self
15340 }
15341 /// A token identifying a page of results from the server.
15342 ///
15343 /// Sets the *page token* query property to the given value.
15344 pub fn page_token(mut self, new_value: &str) -> ProjectLocationVolumeLunListCall<'a, C> {
15345 self._page_token = Some(new_value.to_string());
15346 self
15347 }
15348 /// Requested page size. The server might return fewer items than requested. If unspecified, server will pick an appropriate default.
15349 ///
15350 /// Sets the *page size* query property to the given value.
15351 pub fn page_size(mut self, new_value: i32) -> ProjectLocationVolumeLunListCall<'a, C> {
15352 self._page_size = Some(new_value);
15353 self
15354 }
15355 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15356 /// while executing the actual API request.
15357 ///
15358 /// ````text
15359 /// It should be used to handle progress information, and to implement a certain level of resilience.
15360 /// ````
15361 ///
15362 /// Sets the *delegate* property to the given value.
15363 pub fn delegate(
15364 mut self,
15365 new_value: &'a mut dyn common::Delegate,
15366 ) -> ProjectLocationVolumeLunListCall<'a, C> {
15367 self._delegate = Some(new_value);
15368 self
15369 }
15370
15371 /// Set any additional parameter of the query string used in the request.
15372 /// It should be used to set parameters which are not yet available through their own
15373 /// setters.
15374 ///
15375 /// Please note that this method must not be used to set any of the known parameters
15376 /// which have their own setter method. If done anyway, the request will fail.
15377 ///
15378 /// # Additional Parameters
15379 ///
15380 /// * *$.xgafv* (query-string) - V1 error format.
15381 /// * *access_token* (query-string) - OAuth access token.
15382 /// * *alt* (query-string) - Data format for response.
15383 /// * *callback* (query-string) - JSONP
15384 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15385 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15386 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15387 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15388 /// * *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.
15389 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15390 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15391 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeLunListCall<'a, C>
15392 where
15393 T: AsRef<str>,
15394 {
15395 self._additional_params
15396 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15397 self
15398 }
15399
15400 /// Identifies the authorization scope for the method you are building.
15401 ///
15402 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15403 /// [`Scope::CloudPlatform`].
15404 ///
15405 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15406 /// tokens for more than one scope.
15407 ///
15408 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15409 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15410 /// sufficient, a read-write scope will do as well.
15411 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeLunListCall<'a, C>
15412 where
15413 St: AsRef<str>,
15414 {
15415 self._scopes.insert(String::from(scope.as_ref()));
15416 self
15417 }
15418 /// Identifies the authorization scope(s) for the method you are building.
15419 ///
15420 /// See [`Self::add_scope()`] for details.
15421 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeLunListCall<'a, C>
15422 where
15423 I: IntoIterator<Item = St>,
15424 St: AsRef<str>,
15425 {
15426 self._scopes
15427 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15428 self
15429 }
15430
15431 /// Removes all scopes, and no default scope will be used either.
15432 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15433 /// for details).
15434 pub fn clear_scopes(mut self) -> ProjectLocationVolumeLunListCall<'a, C> {
15435 self._scopes.clear();
15436 self
15437 }
15438}
15439
15440/// Takes a snapshot of a boot volume. Returns INVALID_ARGUMENT if called for a non-boot volume.
15441///
15442/// A builder for the *locations.volumes.snapshots.create* method supported by a *project* resource.
15443/// It is not used directly, but through a [`ProjectMethods`] instance.
15444///
15445/// # Example
15446///
15447/// Instantiate a resource method builder
15448///
15449/// ```test_harness,no_run
15450/// # extern crate hyper;
15451/// # extern crate hyper_rustls;
15452/// # extern crate google_baremetalsolution2 as baremetalsolution2;
15453/// use baremetalsolution2::api::VolumeSnapshot;
15454/// # async fn dox() {
15455/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15456///
15457/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15458/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15459/// # secret,
15460/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15461/// # ).build().await.unwrap();
15462///
15463/// # let client = hyper_util::client::legacy::Client::builder(
15464/// # hyper_util::rt::TokioExecutor::new()
15465/// # )
15466/// # .build(
15467/// # hyper_rustls::HttpsConnectorBuilder::new()
15468/// # .with_native_roots()
15469/// # .unwrap()
15470/// # .https_or_http()
15471/// # .enable_http1()
15472/// # .build()
15473/// # );
15474/// # let mut hub = Baremetalsolution::new(client, auth);
15475/// // As the method needs a request, you would usually fill it with the desired information
15476/// // into the respective structure. Some of the parts shown here might not be applicable !
15477/// // Values shown here are possibly random and not representative !
15478/// let mut req = VolumeSnapshot::default();
15479///
15480/// // You can configure optional parameters by calling the respective setters at will, and
15481/// // execute the final call using `doit()`.
15482/// // Values shown here are possibly random and not representative !
15483/// let result = hub.projects().locations_volumes_snapshots_create(req, "parent")
15484/// .doit().await;
15485/// # }
15486/// ```
15487pub struct ProjectLocationVolumeSnapshotCreateCall<'a, C>
15488where
15489 C: 'a,
15490{
15491 hub: &'a Baremetalsolution<C>,
15492 _request: VolumeSnapshot,
15493 _parent: String,
15494 _delegate: Option<&'a mut dyn common::Delegate>,
15495 _additional_params: HashMap<String, String>,
15496 _scopes: BTreeSet<String>,
15497}
15498
15499impl<'a, C> common::CallBuilder for ProjectLocationVolumeSnapshotCreateCall<'a, C> {}
15500
15501impl<'a, C> ProjectLocationVolumeSnapshotCreateCall<'a, C>
15502where
15503 C: common::Connector,
15504{
15505 /// Perform the operation you have build so far.
15506 pub async fn doit(mut self) -> common::Result<(common::Response, VolumeSnapshot)> {
15507 use std::borrow::Cow;
15508 use std::io::{Read, Seek};
15509
15510 use common::{url::Params, ToParts};
15511 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15512
15513 let mut dd = common::DefaultDelegate;
15514 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15515 dlg.begin(common::MethodInfo {
15516 id: "baremetalsolution.projects.locations.volumes.snapshots.create",
15517 http_method: hyper::Method::POST,
15518 });
15519
15520 for &field in ["alt", "parent"].iter() {
15521 if self._additional_params.contains_key(field) {
15522 dlg.finished(false);
15523 return Err(common::Error::FieldClash(field));
15524 }
15525 }
15526
15527 let mut params = Params::with_capacity(4 + self._additional_params.len());
15528 params.push("parent", self._parent);
15529
15530 params.extend(self._additional_params.iter());
15531
15532 params.push("alt", "json");
15533 let mut url = self.hub._base_url.clone() + "v2/{+parent}/snapshots";
15534 if self._scopes.is_empty() {
15535 self._scopes
15536 .insert(Scope::CloudPlatform.as_ref().to_string());
15537 }
15538
15539 #[allow(clippy::single_element_loop)]
15540 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
15541 url = params.uri_replacement(url, param_name, find_this, true);
15542 }
15543 {
15544 let to_remove = ["parent"];
15545 params.remove_params(&to_remove);
15546 }
15547
15548 let url = params.parse_with_url(&url);
15549
15550 let mut json_mime_type = mime::APPLICATION_JSON;
15551 let mut request_value_reader = {
15552 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15553 common::remove_json_null_values(&mut value);
15554 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15555 serde_json::to_writer(&mut dst, &value).unwrap();
15556 dst
15557 };
15558 let request_size = request_value_reader
15559 .seek(std::io::SeekFrom::End(0))
15560 .unwrap();
15561 request_value_reader
15562 .seek(std::io::SeekFrom::Start(0))
15563 .unwrap();
15564
15565 loop {
15566 let token = match self
15567 .hub
15568 .auth
15569 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15570 .await
15571 {
15572 Ok(token) => token,
15573 Err(e) => match dlg.token(e) {
15574 Ok(token) => token,
15575 Err(e) => {
15576 dlg.finished(false);
15577 return Err(common::Error::MissingToken(e));
15578 }
15579 },
15580 };
15581 request_value_reader
15582 .seek(std::io::SeekFrom::Start(0))
15583 .unwrap();
15584 let mut req_result = {
15585 let client = &self.hub.client;
15586 dlg.pre_request();
15587 let mut req_builder = hyper::Request::builder()
15588 .method(hyper::Method::POST)
15589 .uri(url.as_str())
15590 .header(USER_AGENT, self.hub._user_agent.clone());
15591
15592 if let Some(token) = token.as_ref() {
15593 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15594 }
15595
15596 let request = req_builder
15597 .header(CONTENT_TYPE, json_mime_type.to_string())
15598 .header(CONTENT_LENGTH, request_size as u64)
15599 .body(common::to_body(
15600 request_value_reader.get_ref().clone().into(),
15601 ));
15602
15603 client.request(request.unwrap()).await
15604 };
15605
15606 match req_result {
15607 Err(err) => {
15608 if let common::Retry::After(d) = dlg.http_error(&err) {
15609 sleep(d).await;
15610 continue;
15611 }
15612 dlg.finished(false);
15613 return Err(common::Error::HttpError(err));
15614 }
15615 Ok(res) => {
15616 let (mut parts, body) = res.into_parts();
15617 let mut body = common::Body::new(body);
15618 if !parts.status.is_success() {
15619 let bytes = common::to_bytes(body).await.unwrap_or_default();
15620 let error = serde_json::from_str(&common::to_string(&bytes));
15621 let response = common::to_response(parts, bytes.into());
15622
15623 if let common::Retry::After(d) =
15624 dlg.http_failure(&response, error.as_ref().ok())
15625 {
15626 sleep(d).await;
15627 continue;
15628 }
15629
15630 dlg.finished(false);
15631
15632 return Err(match error {
15633 Ok(value) => common::Error::BadRequest(value),
15634 _ => common::Error::Failure(response),
15635 });
15636 }
15637 let response = {
15638 let bytes = common::to_bytes(body).await.unwrap_or_default();
15639 let encoded = common::to_string(&bytes);
15640 match serde_json::from_str(&encoded) {
15641 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15642 Err(error) => {
15643 dlg.response_json_decode_error(&encoded, &error);
15644 return Err(common::Error::JsonDecodeError(
15645 encoded.to_string(),
15646 error,
15647 ));
15648 }
15649 }
15650 };
15651
15652 dlg.finished(true);
15653 return Ok(response);
15654 }
15655 }
15656 }
15657 }
15658
15659 ///
15660 /// Sets the *request* property to the given value.
15661 ///
15662 /// Even though the property as already been set when instantiating this call,
15663 /// we provide this method for API completeness.
15664 pub fn request(
15665 mut self,
15666 new_value: VolumeSnapshot,
15667 ) -> ProjectLocationVolumeSnapshotCreateCall<'a, C> {
15668 self._request = new_value;
15669 self
15670 }
15671 /// Required. The volume to snapshot.
15672 ///
15673 /// Sets the *parent* path property to the given value.
15674 ///
15675 /// Even though the property as already been set when instantiating this call,
15676 /// we provide this method for API completeness.
15677 pub fn parent(mut self, new_value: &str) -> ProjectLocationVolumeSnapshotCreateCall<'a, C> {
15678 self._parent = new_value.to_string();
15679 self
15680 }
15681 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15682 /// while executing the actual API request.
15683 ///
15684 /// ````text
15685 /// It should be used to handle progress information, and to implement a certain level of resilience.
15686 /// ````
15687 ///
15688 /// Sets the *delegate* property to the given value.
15689 pub fn delegate(
15690 mut self,
15691 new_value: &'a mut dyn common::Delegate,
15692 ) -> ProjectLocationVolumeSnapshotCreateCall<'a, C> {
15693 self._delegate = Some(new_value);
15694 self
15695 }
15696
15697 /// Set any additional parameter of the query string used in the request.
15698 /// It should be used to set parameters which are not yet available through their own
15699 /// setters.
15700 ///
15701 /// Please note that this method must not be used to set any of the known parameters
15702 /// which have their own setter method. If done anyway, the request will fail.
15703 ///
15704 /// # Additional Parameters
15705 ///
15706 /// * *$.xgafv* (query-string) - V1 error format.
15707 /// * *access_token* (query-string) - OAuth access token.
15708 /// * *alt* (query-string) - Data format for response.
15709 /// * *callback* (query-string) - JSONP
15710 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15711 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15712 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15713 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15714 /// * *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.
15715 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15716 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15717 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeSnapshotCreateCall<'a, C>
15718 where
15719 T: AsRef<str>,
15720 {
15721 self._additional_params
15722 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15723 self
15724 }
15725
15726 /// Identifies the authorization scope for the method you are building.
15727 ///
15728 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15729 /// [`Scope::CloudPlatform`].
15730 ///
15731 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15732 /// tokens for more than one scope.
15733 ///
15734 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15735 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15736 /// sufficient, a read-write scope will do as well.
15737 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeSnapshotCreateCall<'a, C>
15738 where
15739 St: AsRef<str>,
15740 {
15741 self._scopes.insert(String::from(scope.as_ref()));
15742 self
15743 }
15744 /// Identifies the authorization scope(s) for the method you are building.
15745 ///
15746 /// See [`Self::add_scope()`] for details.
15747 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeSnapshotCreateCall<'a, C>
15748 where
15749 I: IntoIterator<Item = St>,
15750 St: AsRef<str>,
15751 {
15752 self._scopes
15753 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15754 self
15755 }
15756
15757 /// Removes all scopes, and no default scope will be used either.
15758 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15759 /// for details).
15760 pub fn clear_scopes(mut self) -> ProjectLocationVolumeSnapshotCreateCall<'a, C> {
15761 self._scopes.clear();
15762 self
15763 }
15764}
15765
15766/// Deletes a volume snapshot. Returns INVALID_ARGUMENT if called for a non-boot volume.
15767///
15768/// A builder for the *locations.volumes.snapshots.delete* method supported by a *project* resource.
15769/// It is not used directly, but through a [`ProjectMethods`] instance.
15770///
15771/// # Example
15772///
15773/// Instantiate a resource method builder
15774///
15775/// ```test_harness,no_run
15776/// # extern crate hyper;
15777/// # extern crate hyper_rustls;
15778/// # extern crate google_baremetalsolution2 as baremetalsolution2;
15779/// # async fn dox() {
15780/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15781///
15782/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15783/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15784/// # secret,
15785/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15786/// # ).build().await.unwrap();
15787///
15788/// # let client = hyper_util::client::legacy::Client::builder(
15789/// # hyper_util::rt::TokioExecutor::new()
15790/// # )
15791/// # .build(
15792/// # hyper_rustls::HttpsConnectorBuilder::new()
15793/// # .with_native_roots()
15794/// # .unwrap()
15795/// # .https_or_http()
15796/// # .enable_http1()
15797/// # .build()
15798/// # );
15799/// # let mut hub = Baremetalsolution::new(client, auth);
15800/// // You can configure optional parameters by calling the respective setters at will, and
15801/// // execute the final call using `doit()`.
15802/// // Values shown here are possibly random and not representative !
15803/// let result = hub.projects().locations_volumes_snapshots_delete("name")
15804/// .doit().await;
15805/// # }
15806/// ```
15807pub struct ProjectLocationVolumeSnapshotDeleteCall<'a, C>
15808where
15809 C: 'a,
15810{
15811 hub: &'a Baremetalsolution<C>,
15812 _name: String,
15813 _delegate: Option<&'a mut dyn common::Delegate>,
15814 _additional_params: HashMap<String, String>,
15815 _scopes: BTreeSet<String>,
15816}
15817
15818impl<'a, C> common::CallBuilder for ProjectLocationVolumeSnapshotDeleteCall<'a, C> {}
15819
15820impl<'a, C> ProjectLocationVolumeSnapshotDeleteCall<'a, C>
15821where
15822 C: common::Connector,
15823{
15824 /// Perform the operation you have build so far.
15825 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
15826 use std::borrow::Cow;
15827 use std::io::{Read, Seek};
15828
15829 use common::{url::Params, ToParts};
15830 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15831
15832 let mut dd = common::DefaultDelegate;
15833 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15834 dlg.begin(common::MethodInfo {
15835 id: "baremetalsolution.projects.locations.volumes.snapshots.delete",
15836 http_method: hyper::Method::DELETE,
15837 });
15838
15839 for &field in ["alt", "name"].iter() {
15840 if self._additional_params.contains_key(field) {
15841 dlg.finished(false);
15842 return Err(common::Error::FieldClash(field));
15843 }
15844 }
15845
15846 let mut params = Params::with_capacity(3 + self._additional_params.len());
15847 params.push("name", self._name);
15848
15849 params.extend(self._additional_params.iter());
15850
15851 params.push("alt", "json");
15852 let mut url = self.hub._base_url.clone() + "v2/{+name}";
15853 if self._scopes.is_empty() {
15854 self._scopes
15855 .insert(Scope::CloudPlatform.as_ref().to_string());
15856 }
15857
15858 #[allow(clippy::single_element_loop)]
15859 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15860 url = params.uri_replacement(url, param_name, find_this, true);
15861 }
15862 {
15863 let to_remove = ["name"];
15864 params.remove_params(&to_remove);
15865 }
15866
15867 let url = params.parse_with_url(&url);
15868
15869 loop {
15870 let token = match self
15871 .hub
15872 .auth
15873 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15874 .await
15875 {
15876 Ok(token) => token,
15877 Err(e) => match dlg.token(e) {
15878 Ok(token) => token,
15879 Err(e) => {
15880 dlg.finished(false);
15881 return Err(common::Error::MissingToken(e));
15882 }
15883 },
15884 };
15885 let mut req_result = {
15886 let client = &self.hub.client;
15887 dlg.pre_request();
15888 let mut req_builder = hyper::Request::builder()
15889 .method(hyper::Method::DELETE)
15890 .uri(url.as_str())
15891 .header(USER_AGENT, self.hub._user_agent.clone());
15892
15893 if let Some(token) = token.as_ref() {
15894 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15895 }
15896
15897 let request = req_builder
15898 .header(CONTENT_LENGTH, 0_u64)
15899 .body(common::to_body::<String>(None));
15900
15901 client.request(request.unwrap()).await
15902 };
15903
15904 match req_result {
15905 Err(err) => {
15906 if let common::Retry::After(d) = dlg.http_error(&err) {
15907 sleep(d).await;
15908 continue;
15909 }
15910 dlg.finished(false);
15911 return Err(common::Error::HttpError(err));
15912 }
15913 Ok(res) => {
15914 let (mut parts, body) = res.into_parts();
15915 let mut body = common::Body::new(body);
15916 if !parts.status.is_success() {
15917 let bytes = common::to_bytes(body).await.unwrap_or_default();
15918 let error = serde_json::from_str(&common::to_string(&bytes));
15919 let response = common::to_response(parts, bytes.into());
15920
15921 if let common::Retry::After(d) =
15922 dlg.http_failure(&response, error.as_ref().ok())
15923 {
15924 sleep(d).await;
15925 continue;
15926 }
15927
15928 dlg.finished(false);
15929
15930 return Err(match error {
15931 Ok(value) => common::Error::BadRequest(value),
15932 _ => common::Error::Failure(response),
15933 });
15934 }
15935 let response = {
15936 let bytes = common::to_bytes(body).await.unwrap_or_default();
15937 let encoded = common::to_string(&bytes);
15938 match serde_json::from_str(&encoded) {
15939 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15940 Err(error) => {
15941 dlg.response_json_decode_error(&encoded, &error);
15942 return Err(common::Error::JsonDecodeError(
15943 encoded.to_string(),
15944 error,
15945 ));
15946 }
15947 }
15948 };
15949
15950 dlg.finished(true);
15951 return Ok(response);
15952 }
15953 }
15954 }
15955 }
15956
15957 /// Required. The name of the snapshot to delete.
15958 ///
15959 /// Sets the *name* path property to the given value.
15960 ///
15961 /// Even though the property as already been set when instantiating this call,
15962 /// we provide this method for API completeness.
15963 pub fn name(mut self, new_value: &str) -> ProjectLocationVolumeSnapshotDeleteCall<'a, C> {
15964 self._name = new_value.to_string();
15965 self
15966 }
15967 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15968 /// while executing the actual API request.
15969 ///
15970 /// ````text
15971 /// It should be used to handle progress information, and to implement a certain level of resilience.
15972 /// ````
15973 ///
15974 /// Sets the *delegate* property to the given value.
15975 pub fn delegate(
15976 mut self,
15977 new_value: &'a mut dyn common::Delegate,
15978 ) -> ProjectLocationVolumeSnapshotDeleteCall<'a, C> {
15979 self._delegate = Some(new_value);
15980 self
15981 }
15982
15983 /// Set any additional parameter of the query string used in the request.
15984 /// It should be used to set parameters which are not yet available through their own
15985 /// setters.
15986 ///
15987 /// Please note that this method must not be used to set any of the known parameters
15988 /// which have their own setter method. If done anyway, the request will fail.
15989 ///
15990 /// # Additional Parameters
15991 ///
15992 /// * *$.xgafv* (query-string) - V1 error format.
15993 /// * *access_token* (query-string) - OAuth access token.
15994 /// * *alt* (query-string) - Data format for response.
15995 /// * *callback* (query-string) - JSONP
15996 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15997 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15998 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15999 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16000 /// * *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.
16001 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16002 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16003 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeSnapshotDeleteCall<'a, C>
16004 where
16005 T: AsRef<str>,
16006 {
16007 self._additional_params
16008 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16009 self
16010 }
16011
16012 /// Identifies the authorization scope for the method you are building.
16013 ///
16014 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16015 /// [`Scope::CloudPlatform`].
16016 ///
16017 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16018 /// tokens for more than one scope.
16019 ///
16020 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16021 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16022 /// sufficient, a read-write scope will do as well.
16023 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeSnapshotDeleteCall<'a, C>
16024 where
16025 St: AsRef<str>,
16026 {
16027 self._scopes.insert(String::from(scope.as_ref()));
16028 self
16029 }
16030 /// Identifies the authorization scope(s) for the method you are building.
16031 ///
16032 /// See [`Self::add_scope()`] for details.
16033 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeSnapshotDeleteCall<'a, C>
16034 where
16035 I: IntoIterator<Item = St>,
16036 St: AsRef<str>,
16037 {
16038 self._scopes
16039 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16040 self
16041 }
16042
16043 /// Removes all scopes, and no default scope will be used either.
16044 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16045 /// for details).
16046 pub fn clear_scopes(mut self) -> ProjectLocationVolumeSnapshotDeleteCall<'a, C> {
16047 self._scopes.clear();
16048 self
16049 }
16050}
16051
16052/// Returns the specified snapshot resource. Returns INVALID_ARGUMENT if called for a non-boot volume.
16053///
16054/// A builder for the *locations.volumes.snapshots.get* method supported by a *project* resource.
16055/// It is not used directly, but through a [`ProjectMethods`] instance.
16056///
16057/// # Example
16058///
16059/// Instantiate a resource method builder
16060///
16061/// ```test_harness,no_run
16062/// # extern crate hyper;
16063/// # extern crate hyper_rustls;
16064/// # extern crate google_baremetalsolution2 as baremetalsolution2;
16065/// # async fn dox() {
16066/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16067///
16068/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16069/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16070/// # secret,
16071/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16072/// # ).build().await.unwrap();
16073///
16074/// # let client = hyper_util::client::legacy::Client::builder(
16075/// # hyper_util::rt::TokioExecutor::new()
16076/// # )
16077/// # .build(
16078/// # hyper_rustls::HttpsConnectorBuilder::new()
16079/// # .with_native_roots()
16080/// # .unwrap()
16081/// # .https_or_http()
16082/// # .enable_http1()
16083/// # .build()
16084/// # );
16085/// # let mut hub = Baremetalsolution::new(client, auth);
16086/// // You can configure optional parameters by calling the respective setters at will, and
16087/// // execute the final call using `doit()`.
16088/// // Values shown here are possibly random and not representative !
16089/// let result = hub.projects().locations_volumes_snapshots_get("name")
16090/// .doit().await;
16091/// # }
16092/// ```
16093pub struct ProjectLocationVolumeSnapshotGetCall<'a, C>
16094where
16095 C: 'a,
16096{
16097 hub: &'a Baremetalsolution<C>,
16098 _name: String,
16099 _delegate: Option<&'a mut dyn common::Delegate>,
16100 _additional_params: HashMap<String, String>,
16101 _scopes: BTreeSet<String>,
16102}
16103
16104impl<'a, C> common::CallBuilder for ProjectLocationVolumeSnapshotGetCall<'a, C> {}
16105
16106impl<'a, C> ProjectLocationVolumeSnapshotGetCall<'a, C>
16107where
16108 C: common::Connector,
16109{
16110 /// Perform the operation you have build so far.
16111 pub async fn doit(mut self) -> common::Result<(common::Response, VolumeSnapshot)> {
16112 use std::borrow::Cow;
16113 use std::io::{Read, Seek};
16114
16115 use common::{url::Params, ToParts};
16116 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16117
16118 let mut dd = common::DefaultDelegate;
16119 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16120 dlg.begin(common::MethodInfo {
16121 id: "baremetalsolution.projects.locations.volumes.snapshots.get",
16122 http_method: hyper::Method::GET,
16123 });
16124
16125 for &field in ["alt", "name"].iter() {
16126 if self._additional_params.contains_key(field) {
16127 dlg.finished(false);
16128 return Err(common::Error::FieldClash(field));
16129 }
16130 }
16131
16132 let mut params = Params::with_capacity(3 + self._additional_params.len());
16133 params.push("name", self._name);
16134
16135 params.extend(self._additional_params.iter());
16136
16137 params.push("alt", "json");
16138 let mut url = self.hub._base_url.clone() + "v2/{+name}";
16139 if self._scopes.is_empty() {
16140 self._scopes
16141 .insert(Scope::CloudPlatform.as_ref().to_string());
16142 }
16143
16144 #[allow(clippy::single_element_loop)]
16145 for &(find_this, param_name) in [("{+name}", "name")].iter() {
16146 url = params.uri_replacement(url, param_name, find_this, true);
16147 }
16148 {
16149 let to_remove = ["name"];
16150 params.remove_params(&to_remove);
16151 }
16152
16153 let url = params.parse_with_url(&url);
16154
16155 loop {
16156 let token = match self
16157 .hub
16158 .auth
16159 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16160 .await
16161 {
16162 Ok(token) => token,
16163 Err(e) => match dlg.token(e) {
16164 Ok(token) => token,
16165 Err(e) => {
16166 dlg.finished(false);
16167 return Err(common::Error::MissingToken(e));
16168 }
16169 },
16170 };
16171 let mut req_result = {
16172 let client = &self.hub.client;
16173 dlg.pre_request();
16174 let mut req_builder = hyper::Request::builder()
16175 .method(hyper::Method::GET)
16176 .uri(url.as_str())
16177 .header(USER_AGENT, self.hub._user_agent.clone());
16178
16179 if let Some(token) = token.as_ref() {
16180 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16181 }
16182
16183 let request = req_builder
16184 .header(CONTENT_LENGTH, 0_u64)
16185 .body(common::to_body::<String>(None));
16186
16187 client.request(request.unwrap()).await
16188 };
16189
16190 match req_result {
16191 Err(err) => {
16192 if let common::Retry::After(d) = dlg.http_error(&err) {
16193 sleep(d).await;
16194 continue;
16195 }
16196 dlg.finished(false);
16197 return Err(common::Error::HttpError(err));
16198 }
16199 Ok(res) => {
16200 let (mut parts, body) = res.into_parts();
16201 let mut body = common::Body::new(body);
16202 if !parts.status.is_success() {
16203 let bytes = common::to_bytes(body).await.unwrap_or_default();
16204 let error = serde_json::from_str(&common::to_string(&bytes));
16205 let response = common::to_response(parts, bytes.into());
16206
16207 if let common::Retry::After(d) =
16208 dlg.http_failure(&response, error.as_ref().ok())
16209 {
16210 sleep(d).await;
16211 continue;
16212 }
16213
16214 dlg.finished(false);
16215
16216 return Err(match error {
16217 Ok(value) => common::Error::BadRequest(value),
16218 _ => common::Error::Failure(response),
16219 });
16220 }
16221 let response = {
16222 let bytes = common::to_bytes(body).await.unwrap_or_default();
16223 let encoded = common::to_string(&bytes);
16224 match serde_json::from_str(&encoded) {
16225 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16226 Err(error) => {
16227 dlg.response_json_decode_error(&encoded, &error);
16228 return Err(common::Error::JsonDecodeError(
16229 encoded.to_string(),
16230 error,
16231 ));
16232 }
16233 }
16234 };
16235
16236 dlg.finished(true);
16237 return Ok(response);
16238 }
16239 }
16240 }
16241 }
16242
16243 /// Required. The name of the snapshot.
16244 ///
16245 /// Sets the *name* path property to the given value.
16246 ///
16247 /// Even though the property as already been set when instantiating this call,
16248 /// we provide this method for API completeness.
16249 pub fn name(mut self, new_value: &str) -> ProjectLocationVolumeSnapshotGetCall<'a, C> {
16250 self._name = new_value.to_string();
16251 self
16252 }
16253 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16254 /// while executing the actual API request.
16255 ///
16256 /// ````text
16257 /// It should be used to handle progress information, and to implement a certain level of resilience.
16258 /// ````
16259 ///
16260 /// Sets the *delegate* property to the given value.
16261 pub fn delegate(
16262 mut self,
16263 new_value: &'a mut dyn common::Delegate,
16264 ) -> ProjectLocationVolumeSnapshotGetCall<'a, C> {
16265 self._delegate = Some(new_value);
16266 self
16267 }
16268
16269 /// Set any additional parameter of the query string used in the request.
16270 /// It should be used to set parameters which are not yet available through their own
16271 /// setters.
16272 ///
16273 /// Please note that this method must not be used to set any of the known parameters
16274 /// which have their own setter method. If done anyway, the request will fail.
16275 ///
16276 /// # Additional Parameters
16277 ///
16278 /// * *$.xgafv* (query-string) - V1 error format.
16279 /// * *access_token* (query-string) - OAuth access token.
16280 /// * *alt* (query-string) - Data format for response.
16281 /// * *callback* (query-string) - JSONP
16282 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16283 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16284 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16285 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16286 /// * *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.
16287 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16288 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16289 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeSnapshotGetCall<'a, C>
16290 where
16291 T: AsRef<str>,
16292 {
16293 self._additional_params
16294 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16295 self
16296 }
16297
16298 /// Identifies the authorization scope for the method you are building.
16299 ///
16300 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16301 /// [`Scope::CloudPlatform`].
16302 ///
16303 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16304 /// tokens for more than one scope.
16305 ///
16306 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16307 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16308 /// sufficient, a read-write scope will do as well.
16309 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeSnapshotGetCall<'a, C>
16310 where
16311 St: AsRef<str>,
16312 {
16313 self._scopes.insert(String::from(scope.as_ref()));
16314 self
16315 }
16316 /// Identifies the authorization scope(s) for the method you are building.
16317 ///
16318 /// See [`Self::add_scope()`] for details.
16319 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeSnapshotGetCall<'a, C>
16320 where
16321 I: IntoIterator<Item = St>,
16322 St: AsRef<str>,
16323 {
16324 self._scopes
16325 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16326 self
16327 }
16328
16329 /// Removes all scopes, and no default scope will be used either.
16330 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16331 /// for details).
16332 pub fn clear_scopes(mut self) -> ProjectLocationVolumeSnapshotGetCall<'a, C> {
16333 self._scopes.clear();
16334 self
16335 }
16336}
16337
16338/// 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.
16339///
16340/// A builder for the *locations.volumes.snapshots.list* method supported by a *project* resource.
16341/// It is not used directly, but through a [`ProjectMethods`] instance.
16342///
16343/// # Example
16344///
16345/// Instantiate a resource method builder
16346///
16347/// ```test_harness,no_run
16348/// # extern crate hyper;
16349/// # extern crate hyper_rustls;
16350/// # extern crate google_baremetalsolution2 as baremetalsolution2;
16351/// # async fn dox() {
16352/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16353///
16354/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16355/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16356/// # secret,
16357/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16358/// # ).build().await.unwrap();
16359///
16360/// # let client = hyper_util::client::legacy::Client::builder(
16361/// # hyper_util::rt::TokioExecutor::new()
16362/// # )
16363/// # .build(
16364/// # hyper_rustls::HttpsConnectorBuilder::new()
16365/// # .with_native_roots()
16366/// # .unwrap()
16367/// # .https_or_http()
16368/// # .enable_http1()
16369/// # .build()
16370/// # );
16371/// # let mut hub = Baremetalsolution::new(client, auth);
16372/// // You can configure optional parameters by calling the respective setters at will, and
16373/// // execute the final call using `doit()`.
16374/// // Values shown here are possibly random and not representative !
16375/// let result = hub.projects().locations_volumes_snapshots_list("parent")
16376/// .page_token("vero")
16377/// .page_size(-88)
16378/// .doit().await;
16379/// # }
16380/// ```
16381pub struct ProjectLocationVolumeSnapshotListCall<'a, C>
16382where
16383 C: 'a,
16384{
16385 hub: &'a Baremetalsolution<C>,
16386 _parent: String,
16387 _page_token: Option<String>,
16388 _page_size: Option<i32>,
16389 _delegate: Option<&'a mut dyn common::Delegate>,
16390 _additional_params: HashMap<String, String>,
16391 _scopes: BTreeSet<String>,
16392}
16393
16394impl<'a, C> common::CallBuilder for ProjectLocationVolumeSnapshotListCall<'a, C> {}
16395
16396impl<'a, C> ProjectLocationVolumeSnapshotListCall<'a, C>
16397where
16398 C: common::Connector,
16399{
16400 /// Perform the operation you have build so far.
16401 pub async fn doit(mut self) -> common::Result<(common::Response, ListVolumeSnapshotsResponse)> {
16402 use std::borrow::Cow;
16403 use std::io::{Read, Seek};
16404
16405 use common::{url::Params, ToParts};
16406 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16407
16408 let mut dd = common::DefaultDelegate;
16409 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16410 dlg.begin(common::MethodInfo {
16411 id: "baremetalsolution.projects.locations.volumes.snapshots.list",
16412 http_method: hyper::Method::GET,
16413 });
16414
16415 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
16416 if self._additional_params.contains_key(field) {
16417 dlg.finished(false);
16418 return Err(common::Error::FieldClash(field));
16419 }
16420 }
16421
16422 let mut params = Params::with_capacity(5 + self._additional_params.len());
16423 params.push("parent", self._parent);
16424 if let Some(value) = self._page_token.as_ref() {
16425 params.push("pageToken", value);
16426 }
16427 if let Some(value) = self._page_size.as_ref() {
16428 params.push("pageSize", value.to_string());
16429 }
16430
16431 params.extend(self._additional_params.iter());
16432
16433 params.push("alt", "json");
16434 let mut url = self.hub._base_url.clone() + "v2/{+parent}/snapshots";
16435 if self._scopes.is_empty() {
16436 self._scopes
16437 .insert(Scope::CloudPlatform.as_ref().to_string());
16438 }
16439
16440 #[allow(clippy::single_element_loop)]
16441 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
16442 url = params.uri_replacement(url, param_name, find_this, true);
16443 }
16444 {
16445 let to_remove = ["parent"];
16446 params.remove_params(&to_remove);
16447 }
16448
16449 let url = params.parse_with_url(&url);
16450
16451 loop {
16452 let token = match self
16453 .hub
16454 .auth
16455 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16456 .await
16457 {
16458 Ok(token) => token,
16459 Err(e) => match dlg.token(e) {
16460 Ok(token) => token,
16461 Err(e) => {
16462 dlg.finished(false);
16463 return Err(common::Error::MissingToken(e));
16464 }
16465 },
16466 };
16467 let mut req_result = {
16468 let client = &self.hub.client;
16469 dlg.pre_request();
16470 let mut req_builder = hyper::Request::builder()
16471 .method(hyper::Method::GET)
16472 .uri(url.as_str())
16473 .header(USER_AGENT, self.hub._user_agent.clone());
16474
16475 if let Some(token) = token.as_ref() {
16476 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16477 }
16478
16479 let request = req_builder
16480 .header(CONTENT_LENGTH, 0_u64)
16481 .body(common::to_body::<String>(None));
16482
16483 client.request(request.unwrap()).await
16484 };
16485
16486 match req_result {
16487 Err(err) => {
16488 if let common::Retry::After(d) = dlg.http_error(&err) {
16489 sleep(d).await;
16490 continue;
16491 }
16492 dlg.finished(false);
16493 return Err(common::Error::HttpError(err));
16494 }
16495 Ok(res) => {
16496 let (mut parts, body) = res.into_parts();
16497 let mut body = common::Body::new(body);
16498 if !parts.status.is_success() {
16499 let bytes = common::to_bytes(body).await.unwrap_or_default();
16500 let error = serde_json::from_str(&common::to_string(&bytes));
16501 let response = common::to_response(parts, bytes.into());
16502
16503 if let common::Retry::After(d) =
16504 dlg.http_failure(&response, error.as_ref().ok())
16505 {
16506 sleep(d).await;
16507 continue;
16508 }
16509
16510 dlg.finished(false);
16511
16512 return Err(match error {
16513 Ok(value) => common::Error::BadRequest(value),
16514 _ => common::Error::Failure(response),
16515 });
16516 }
16517 let response = {
16518 let bytes = common::to_bytes(body).await.unwrap_or_default();
16519 let encoded = common::to_string(&bytes);
16520 match serde_json::from_str(&encoded) {
16521 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16522 Err(error) => {
16523 dlg.response_json_decode_error(&encoded, &error);
16524 return Err(common::Error::JsonDecodeError(
16525 encoded.to_string(),
16526 error,
16527 ));
16528 }
16529 }
16530 };
16531
16532 dlg.finished(true);
16533 return Ok(response);
16534 }
16535 }
16536 }
16537 }
16538
16539 /// Required. Parent value for ListVolumesRequest.
16540 ///
16541 /// Sets the *parent* path property to the given value.
16542 ///
16543 /// Even though the property as already been set when instantiating this call,
16544 /// we provide this method for API completeness.
16545 pub fn parent(mut self, new_value: &str) -> ProjectLocationVolumeSnapshotListCall<'a, C> {
16546 self._parent = new_value.to_string();
16547 self
16548 }
16549 /// A token identifying a page of results from the server.
16550 ///
16551 /// Sets the *page token* query property to the given value.
16552 pub fn page_token(mut self, new_value: &str) -> ProjectLocationVolumeSnapshotListCall<'a, C> {
16553 self._page_token = Some(new_value.to_string());
16554 self
16555 }
16556 /// Requested page size. The server might return fewer items than requested. If unspecified, server will pick an appropriate default.
16557 ///
16558 /// Sets the *page size* query property to the given value.
16559 pub fn page_size(mut self, new_value: i32) -> ProjectLocationVolumeSnapshotListCall<'a, C> {
16560 self._page_size = Some(new_value);
16561 self
16562 }
16563 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16564 /// while executing the actual API request.
16565 ///
16566 /// ````text
16567 /// It should be used to handle progress information, and to implement a certain level of resilience.
16568 /// ````
16569 ///
16570 /// Sets the *delegate* property to the given value.
16571 pub fn delegate(
16572 mut self,
16573 new_value: &'a mut dyn common::Delegate,
16574 ) -> ProjectLocationVolumeSnapshotListCall<'a, C> {
16575 self._delegate = Some(new_value);
16576 self
16577 }
16578
16579 /// Set any additional parameter of the query string used in the request.
16580 /// It should be used to set parameters which are not yet available through their own
16581 /// setters.
16582 ///
16583 /// Please note that this method must not be used to set any of the known parameters
16584 /// which have their own setter method. If done anyway, the request will fail.
16585 ///
16586 /// # Additional Parameters
16587 ///
16588 /// * *$.xgafv* (query-string) - V1 error format.
16589 /// * *access_token* (query-string) - OAuth access token.
16590 /// * *alt* (query-string) - Data format for response.
16591 /// * *callback* (query-string) - JSONP
16592 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16593 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16594 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16595 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16596 /// * *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.
16597 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16598 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16599 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeSnapshotListCall<'a, C>
16600 where
16601 T: AsRef<str>,
16602 {
16603 self._additional_params
16604 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16605 self
16606 }
16607
16608 /// Identifies the authorization scope for the method you are building.
16609 ///
16610 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16611 /// [`Scope::CloudPlatform`].
16612 ///
16613 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16614 /// tokens for more than one scope.
16615 ///
16616 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16617 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16618 /// sufficient, a read-write scope will do as well.
16619 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeSnapshotListCall<'a, C>
16620 where
16621 St: AsRef<str>,
16622 {
16623 self._scopes.insert(String::from(scope.as_ref()));
16624 self
16625 }
16626 /// Identifies the authorization scope(s) for the method you are building.
16627 ///
16628 /// See [`Self::add_scope()`] for details.
16629 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeSnapshotListCall<'a, C>
16630 where
16631 I: IntoIterator<Item = St>,
16632 St: AsRef<str>,
16633 {
16634 self._scopes
16635 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16636 self
16637 }
16638
16639 /// Removes all scopes, and no default scope will be used either.
16640 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16641 /// for details).
16642 pub fn clear_scopes(mut self) -> ProjectLocationVolumeSnapshotListCall<'a, C> {
16643 self._scopes.clear();
16644 self
16645 }
16646}
16647
16648/// Uses the specified snapshot to restore its parent volume. Returns INVALID_ARGUMENT if called for a non-boot volume.
16649///
16650/// A builder for the *locations.volumes.snapshots.restoreVolumeSnapshot* method supported by a *project* resource.
16651/// It is not used directly, but through a [`ProjectMethods`] instance.
16652///
16653/// # Example
16654///
16655/// Instantiate a resource method builder
16656///
16657/// ```test_harness,no_run
16658/// # extern crate hyper;
16659/// # extern crate hyper_rustls;
16660/// # extern crate google_baremetalsolution2 as baremetalsolution2;
16661/// use baremetalsolution2::api::RestoreVolumeSnapshotRequest;
16662/// # async fn dox() {
16663/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16664///
16665/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16666/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16667/// # secret,
16668/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16669/// # ).build().await.unwrap();
16670///
16671/// # let client = hyper_util::client::legacy::Client::builder(
16672/// # hyper_util::rt::TokioExecutor::new()
16673/// # )
16674/// # .build(
16675/// # hyper_rustls::HttpsConnectorBuilder::new()
16676/// # .with_native_roots()
16677/// # .unwrap()
16678/// # .https_or_http()
16679/// # .enable_http1()
16680/// # .build()
16681/// # );
16682/// # let mut hub = Baremetalsolution::new(client, auth);
16683/// // As the method needs a request, you would usually fill it with the desired information
16684/// // into the respective structure. Some of the parts shown here might not be applicable !
16685/// // Values shown here are possibly random and not representative !
16686/// let mut req = RestoreVolumeSnapshotRequest::default();
16687///
16688/// // You can configure optional parameters by calling the respective setters at will, and
16689/// // execute the final call using `doit()`.
16690/// // Values shown here are possibly random and not representative !
16691/// let result = hub.projects().locations_volumes_snapshots_restore_volume_snapshot(req, "volumeSnapshot")
16692/// .doit().await;
16693/// # }
16694/// ```
16695pub struct ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C>
16696where
16697 C: 'a,
16698{
16699 hub: &'a Baremetalsolution<C>,
16700 _request: RestoreVolumeSnapshotRequest,
16701 _volume_snapshot: String,
16702 _delegate: Option<&'a mut dyn common::Delegate>,
16703 _additional_params: HashMap<String, String>,
16704 _scopes: BTreeSet<String>,
16705}
16706
16707impl<'a, C> common::CallBuilder for ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C> {}
16708
16709impl<'a, C> ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C>
16710where
16711 C: common::Connector,
16712{
16713 /// Perform the operation you have build so far.
16714 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
16715 use std::borrow::Cow;
16716 use std::io::{Read, Seek};
16717
16718 use common::{url::Params, ToParts};
16719 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16720
16721 let mut dd = common::DefaultDelegate;
16722 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16723 dlg.begin(common::MethodInfo {
16724 id: "baremetalsolution.projects.locations.volumes.snapshots.restoreVolumeSnapshot",
16725 http_method: hyper::Method::POST,
16726 });
16727
16728 for &field in ["alt", "volumeSnapshot"].iter() {
16729 if self._additional_params.contains_key(field) {
16730 dlg.finished(false);
16731 return Err(common::Error::FieldClash(field));
16732 }
16733 }
16734
16735 let mut params = Params::with_capacity(4 + self._additional_params.len());
16736 params.push("volumeSnapshot", self._volume_snapshot);
16737
16738 params.extend(self._additional_params.iter());
16739
16740 params.push("alt", "json");
16741 let mut url = self.hub._base_url.clone() + "v2/{+volumeSnapshot}:restoreVolumeSnapshot";
16742 if self._scopes.is_empty() {
16743 self._scopes
16744 .insert(Scope::CloudPlatform.as_ref().to_string());
16745 }
16746
16747 #[allow(clippy::single_element_loop)]
16748 for &(find_this, param_name) in [("{+volumeSnapshot}", "volumeSnapshot")].iter() {
16749 url = params.uri_replacement(url, param_name, find_this, true);
16750 }
16751 {
16752 let to_remove = ["volumeSnapshot"];
16753 params.remove_params(&to_remove);
16754 }
16755
16756 let url = params.parse_with_url(&url);
16757
16758 let mut json_mime_type = mime::APPLICATION_JSON;
16759 let mut request_value_reader = {
16760 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16761 common::remove_json_null_values(&mut value);
16762 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16763 serde_json::to_writer(&mut dst, &value).unwrap();
16764 dst
16765 };
16766 let request_size = request_value_reader
16767 .seek(std::io::SeekFrom::End(0))
16768 .unwrap();
16769 request_value_reader
16770 .seek(std::io::SeekFrom::Start(0))
16771 .unwrap();
16772
16773 loop {
16774 let token = match self
16775 .hub
16776 .auth
16777 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16778 .await
16779 {
16780 Ok(token) => token,
16781 Err(e) => match dlg.token(e) {
16782 Ok(token) => token,
16783 Err(e) => {
16784 dlg.finished(false);
16785 return Err(common::Error::MissingToken(e));
16786 }
16787 },
16788 };
16789 request_value_reader
16790 .seek(std::io::SeekFrom::Start(0))
16791 .unwrap();
16792 let mut req_result = {
16793 let client = &self.hub.client;
16794 dlg.pre_request();
16795 let mut req_builder = hyper::Request::builder()
16796 .method(hyper::Method::POST)
16797 .uri(url.as_str())
16798 .header(USER_AGENT, self.hub._user_agent.clone());
16799
16800 if let Some(token) = token.as_ref() {
16801 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16802 }
16803
16804 let request = req_builder
16805 .header(CONTENT_TYPE, json_mime_type.to_string())
16806 .header(CONTENT_LENGTH, request_size as u64)
16807 .body(common::to_body(
16808 request_value_reader.get_ref().clone().into(),
16809 ));
16810
16811 client.request(request.unwrap()).await
16812 };
16813
16814 match req_result {
16815 Err(err) => {
16816 if let common::Retry::After(d) = dlg.http_error(&err) {
16817 sleep(d).await;
16818 continue;
16819 }
16820 dlg.finished(false);
16821 return Err(common::Error::HttpError(err));
16822 }
16823 Ok(res) => {
16824 let (mut parts, body) = res.into_parts();
16825 let mut body = common::Body::new(body);
16826 if !parts.status.is_success() {
16827 let bytes = common::to_bytes(body).await.unwrap_or_default();
16828 let error = serde_json::from_str(&common::to_string(&bytes));
16829 let response = common::to_response(parts, bytes.into());
16830
16831 if let common::Retry::After(d) =
16832 dlg.http_failure(&response, error.as_ref().ok())
16833 {
16834 sleep(d).await;
16835 continue;
16836 }
16837
16838 dlg.finished(false);
16839
16840 return Err(match error {
16841 Ok(value) => common::Error::BadRequest(value),
16842 _ => common::Error::Failure(response),
16843 });
16844 }
16845 let response = {
16846 let bytes = common::to_bytes(body).await.unwrap_or_default();
16847 let encoded = common::to_string(&bytes);
16848 match serde_json::from_str(&encoded) {
16849 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16850 Err(error) => {
16851 dlg.response_json_decode_error(&encoded, &error);
16852 return Err(common::Error::JsonDecodeError(
16853 encoded.to_string(),
16854 error,
16855 ));
16856 }
16857 }
16858 };
16859
16860 dlg.finished(true);
16861 return Ok(response);
16862 }
16863 }
16864 }
16865 }
16866
16867 ///
16868 /// Sets the *request* property to the given value.
16869 ///
16870 /// Even though the property as already been set when instantiating this call,
16871 /// we provide this method for API completeness.
16872 pub fn request(
16873 mut self,
16874 new_value: RestoreVolumeSnapshotRequest,
16875 ) -> ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C> {
16876 self._request = new_value;
16877 self
16878 }
16879 /// Required. Name of the snapshot which will be used to restore its parent volume.
16880 ///
16881 /// Sets the *volume snapshot* path property to the given value.
16882 ///
16883 /// Even though the property as already been set when instantiating this call,
16884 /// we provide this method for API completeness.
16885 pub fn volume_snapshot(
16886 mut self,
16887 new_value: &str,
16888 ) -> ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C> {
16889 self._volume_snapshot = new_value.to_string();
16890 self
16891 }
16892 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16893 /// while executing the actual API request.
16894 ///
16895 /// ````text
16896 /// It should be used to handle progress information, and to implement a certain level of resilience.
16897 /// ````
16898 ///
16899 /// Sets the *delegate* property to the given value.
16900 pub fn delegate(
16901 mut self,
16902 new_value: &'a mut dyn common::Delegate,
16903 ) -> ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C> {
16904 self._delegate = Some(new_value);
16905 self
16906 }
16907
16908 /// Set any additional parameter of the query string used in the request.
16909 /// It should be used to set parameters which are not yet available through their own
16910 /// setters.
16911 ///
16912 /// Please note that this method must not be used to set any of the known parameters
16913 /// which have their own setter method. If done anyway, the request will fail.
16914 ///
16915 /// # Additional Parameters
16916 ///
16917 /// * *$.xgafv* (query-string) - V1 error format.
16918 /// * *access_token* (query-string) - OAuth access token.
16919 /// * *alt* (query-string) - Data format for response.
16920 /// * *callback* (query-string) - JSONP
16921 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16922 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
16923 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16924 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16925 /// * *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.
16926 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16927 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16928 pub fn param<T>(
16929 mut self,
16930 name: T,
16931 value: T,
16932 ) -> ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C>
16933 where
16934 T: AsRef<str>,
16935 {
16936 self._additional_params
16937 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16938 self
16939 }
16940
16941 /// Identifies the authorization scope for the method you are building.
16942 ///
16943 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16944 /// [`Scope::CloudPlatform`].
16945 ///
16946 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16947 /// tokens for more than one scope.
16948 ///
16949 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16950 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16951 /// sufficient, a read-write scope will do as well.
16952 pub fn add_scope<St>(
16953 mut self,
16954 scope: St,
16955 ) -> ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C>
16956 where
16957 St: AsRef<str>,
16958 {
16959 self._scopes.insert(String::from(scope.as_ref()));
16960 self
16961 }
16962 /// Identifies the authorization scope(s) for the method you are building.
16963 ///
16964 /// See [`Self::add_scope()`] for details.
16965 pub fn add_scopes<I, St>(
16966 mut self,
16967 scopes: I,
16968 ) -> ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C>
16969 where
16970 I: IntoIterator<Item = St>,
16971 St: AsRef<str>,
16972 {
16973 self._scopes
16974 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16975 self
16976 }
16977
16978 /// Removes all scopes, and no default scope will be used either.
16979 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16980 /// for details).
16981 pub fn clear_scopes(mut self) -> ProjectLocationVolumeSnapshotRestoreVolumeSnapshotCall<'a, C> {
16982 self._scopes.clear();
16983 self
16984 }
16985}
16986
16987/// Skips volume's cooloff and deletes it now. Volume must be in cooloff state.
16988///
16989/// A builder for the *locations.volumes.evict* method supported by a *project* resource.
16990/// It is not used directly, but through a [`ProjectMethods`] instance.
16991///
16992/// # Example
16993///
16994/// Instantiate a resource method builder
16995///
16996/// ```test_harness,no_run
16997/// # extern crate hyper;
16998/// # extern crate hyper_rustls;
16999/// # extern crate google_baremetalsolution2 as baremetalsolution2;
17000/// use baremetalsolution2::api::EvictVolumeRequest;
17001/// # async fn dox() {
17002/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17003///
17004/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17005/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17006/// # secret,
17007/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17008/// # ).build().await.unwrap();
17009///
17010/// # let client = hyper_util::client::legacy::Client::builder(
17011/// # hyper_util::rt::TokioExecutor::new()
17012/// # )
17013/// # .build(
17014/// # hyper_rustls::HttpsConnectorBuilder::new()
17015/// # .with_native_roots()
17016/// # .unwrap()
17017/// # .https_or_http()
17018/// # .enable_http1()
17019/// # .build()
17020/// # );
17021/// # let mut hub = Baremetalsolution::new(client, auth);
17022/// // As the method needs a request, you would usually fill it with the desired information
17023/// // into the respective structure. Some of the parts shown here might not be applicable !
17024/// // Values shown here are possibly random and not representative !
17025/// let mut req = EvictVolumeRequest::default();
17026///
17027/// // You can configure optional parameters by calling the respective setters at will, and
17028/// // execute the final call using `doit()`.
17029/// // Values shown here are possibly random and not representative !
17030/// let result = hub.projects().locations_volumes_evict(req, "name")
17031/// .doit().await;
17032/// # }
17033/// ```
17034pub struct ProjectLocationVolumeEvictCall<'a, C>
17035where
17036 C: 'a,
17037{
17038 hub: &'a Baremetalsolution<C>,
17039 _request: EvictVolumeRequest,
17040 _name: String,
17041 _delegate: Option<&'a mut dyn common::Delegate>,
17042 _additional_params: HashMap<String, String>,
17043 _scopes: BTreeSet<String>,
17044}
17045
17046impl<'a, C> common::CallBuilder for ProjectLocationVolumeEvictCall<'a, C> {}
17047
17048impl<'a, C> ProjectLocationVolumeEvictCall<'a, C>
17049where
17050 C: common::Connector,
17051{
17052 /// Perform the operation you have build so far.
17053 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
17054 use std::borrow::Cow;
17055 use std::io::{Read, Seek};
17056
17057 use common::{url::Params, ToParts};
17058 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17059
17060 let mut dd = common::DefaultDelegate;
17061 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17062 dlg.begin(common::MethodInfo {
17063 id: "baremetalsolution.projects.locations.volumes.evict",
17064 http_method: hyper::Method::POST,
17065 });
17066
17067 for &field in ["alt", "name"].iter() {
17068 if self._additional_params.contains_key(field) {
17069 dlg.finished(false);
17070 return Err(common::Error::FieldClash(field));
17071 }
17072 }
17073
17074 let mut params = Params::with_capacity(4 + self._additional_params.len());
17075 params.push("name", self._name);
17076
17077 params.extend(self._additional_params.iter());
17078
17079 params.push("alt", "json");
17080 let mut url = self.hub._base_url.clone() + "v2/{+name}:evict";
17081 if self._scopes.is_empty() {
17082 self._scopes
17083 .insert(Scope::CloudPlatform.as_ref().to_string());
17084 }
17085
17086 #[allow(clippy::single_element_loop)]
17087 for &(find_this, param_name) in [("{+name}", "name")].iter() {
17088 url = params.uri_replacement(url, param_name, find_this, true);
17089 }
17090 {
17091 let to_remove = ["name"];
17092 params.remove_params(&to_remove);
17093 }
17094
17095 let url = params.parse_with_url(&url);
17096
17097 let mut json_mime_type = mime::APPLICATION_JSON;
17098 let mut request_value_reader = {
17099 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17100 common::remove_json_null_values(&mut value);
17101 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17102 serde_json::to_writer(&mut dst, &value).unwrap();
17103 dst
17104 };
17105 let request_size = request_value_reader
17106 .seek(std::io::SeekFrom::End(0))
17107 .unwrap();
17108 request_value_reader
17109 .seek(std::io::SeekFrom::Start(0))
17110 .unwrap();
17111
17112 loop {
17113 let token = match self
17114 .hub
17115 .auth
17116 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17117 .await
17118 {
17119 Ok(token) => token,
17120 Err(e) => match dlg.token(e) {
17121 Ok(token) => token,
17122 Err(e) => {
17123 dlg.finished(false);
17124 return Err(common::Error::MissingToken(e));
17125 }
17126 },
17127 };
17128 request_value_reader
17129 .seek(std::io::SeekFrom::Start(0))
17130 .unwrap();
17131 let mut req_result = {
17132 let client = &self.hub.client;
17133 dlg.pre_request();
17134 let mut req_builder = hyper::Request::builder()
17135 .method(hyper::Method::POST)
17136 .uri(url.as_str())
17137 .header(USER_AGENT, self.hub._user_agent.clone());
17138
17139 if let Some(token) = token.as_ref() {
17140 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17141 }
17142
17143 let request = req_builder
17144 .header(CONTENT_TYPE, json_mime_type.to_string())
17145 .header(CONTENT_LENGTH, request_size as u64)
17146 .body(common::to_body(
17147 request_value_reader.get_ref().clone().into(),
17148 ));
17149
17150 client.request(request.unwrap()).await
17151 };
17152
17153 match req_result {
17154 Err(err) => {
17155 if let common::Retry::After(d) = dlg.http_error(&err) {
17156 sleep(d).await;
17157 continue;
17158 }
17159 dlg.finished(false);
17160 return Err(common::Error::HttpError(err));
17161 }
17162 Ok(res) => {
17163 let (mut parts, body) = res.into_parts();
17164 let mut body = common::Body::new(body);
17165 if !parts.status.is_success() {
17166 let bytes = common::to_bytes(body).await.unwrap_or_default();
17167 let error = serde_json::from_str(&common::to_string(&bytes));
17168 let response = common::to_response(parts, bytes.into());
17169
17170 if let common::Retry::After(d) =
17171 dlg.http_failure(&response, error.as_ref().ok())
17172 {
17173 sleep(d).await;
17174 continue;
17175 }
17176
17177 dlg.finished(false);
17178
17179 return Err(match error {
17180 Ok(value) => common::Error::BadRequest(value),
17181 _ => common::Error::Failure(response),
17182 });
17183 }
17184 let response = {
17185 let bytes = common::to_bytes(body).await.unwrap_or_default();
17186 let encoded = common::to_string(&bytes);
17187 match serde_json::from_str(&encoded) {
17188 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17189 Err(error) => {
17190 dlg.response_json_decode_error(&encoded, &error);
17191 return Err(common::Error::JsonDecodeError(
17192 encoded.to_string(),
17193 error,
17194 ));
17195 }
17196 }
17197 };
17198
17199 dlg.finished(true);
17200 return Ok(response);
17201 }
17202 }
17203 }
17204 }
17205
17206 ///
17207 /// Sets the *request* property to the given value.
17208 ///
17209 /// Even though the property as already been set when instantiating this call,
17210 /// we provide this method for API completeness.
17211 pub fn request(
17212 mut self,
17213 new_value: EvictVolumeRequest,
17214 ) -> ProjectLocationVolumeEvictCall<'a, C> {
17215 self._request = new_value;
17216 self
17217 }
17218 /// Required. The name of the Volume.
17219 ///
17220 /// Sets the *name* path property to the given value.
17221 ///
17222 /// Even though the property as already been set when instantiating this call,
17223 /// we provide this method for API completeness.
17224 pub fn name(mut self, new_value: &str) -> ProjectLocationVolumeEvictCall<'a, C> {
17225 self._name = new_value.to_string();
17226 self
17227 }
17228 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17229 /// while executing the actual API request.
17230 ///
17231 /// ````text
17232 /// It should be used to handle progress information, and to implement a certain level of resilience.
17233 /// ````
17234 ///
17235 /// Sets the *delegate* property to the given value.
17236 pub fn delegate(
17237 mut self,
17238 new_value: &'a mut dyn common::Delegate,
17239 ) -> ProjectLocationVolumeEvictCall<'a, C> {
17240 self._delegate = Some(new_value);
17241 self
17242 }
17243
17244 /// Set any additional parameter of the query string used in the request.
17245 /// It should be used to set parameters which are not yet available through their own
17246 /// setters.
17247 ///
17248 /// Please note that this method must not be used to set any of the known parameters
17249 /// which have their own setter method. If done anyway, the request will fail.
17250 ///
17251 /// # Additional Parameters
17252 ///
17253 /// * *$.xgafv* (query-string) - V1 error format.
17254 /// * *access_token* (query-string) - OAuth access token.
17255 /// * *alt* (query-string) - Data format for response.
17256 /// * *callback* (query-string) - JSONP
17257 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17258 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17259 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17260 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17261 /// * *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.
17262 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17263 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17264 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeEvictCall<'a, C>
17265 where
17266 T: AsRef<str>,
17267 {
17268 self._additional_params
17269 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17270 self
17271 }
17272
17273 /// Identifies the authorization scope for the method you are building.
17274 ///
17275 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17276 /// [`Scope::CloudPlatform`].
17277 ///
17278 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17279 /// tokens for more than one scope.
17280 ///
17281 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17282 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17283 /// sufficient, a read-write scope will do as well.
17284 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeEvictCall<'a, C>
17285 where
17286 St: AsRef<str>,
17287 {
17288 self._scopes.insert(String::from(scope.as_ref()));
17289 self
17290 }
17291 /// Identifies the authorization scope(s) for the method you are building.
17292 ///
17293 /// See [`Self::add_scope()`] for details.
17294 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeEvictCall<'a, C>
17295 where
17296 I: IntoIterator<Item = St>,
17297 St: AsRef<str>,
17298 {
17299 self._scopes
17300 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17301 self
17302 }
17303
17304 /// Removes all scopes, and no default scope will be used either.
17305 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17306 /// for details).
17307 pub fn clear_scopes(mut self) -> ProjectLocationVolumeEvictCall<'a, C> {
17308 self._scopes.clear();
17309 self
17310 }
17311}
17312
17313/// Get details of a single storage volume.
17314///
17315/// A builder for the *locations.volumes.get* method supported by a *project* resource.
17316/// It is not used directly, but through a [`ProjectMethods`] instance.
17317///
17318/// # Example
17319///
17320/// Instantiate a resource method builder
17321///
17322/// ```test_harness,no_run
17323/// # extern crate hyper;
17324/// # extern crate hyper_rustls;
17325/// # extern crate google_baremetalsolution2 as baremetalsolution2;
17326/// # async fn dox() {
17327/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17328///
17329/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17330/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17331/// # secret,
17332/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17333/// # ).build().await.unwrap();
17334///
17335/// # let client = hyper_util::client::legacy::Client::builder(
17336/// # hyper_util::rt::TokioExecutor::new()
17337/// # )
17338/// # .build(
17339/// # hyper_rustls::HttpsConnectorBuilder::new()
17340/// # .with_native_roots()
17341/// # .unwrap()
17342/// # .https_or_http()
17343/// # .enable_http1()
17344/// # .build()
17345/// # );
17346/// # let mut hub = Baremetalsolution::new(client, auth);
17347/// // You can configure optional parameters by calling the respective setters at will, and
17348/// // execute the final call using `doit()`.
17349/// // Values shown here are possibly random and not representative !
17350/// let result = hub.projects().locations_volumes_get("name")
17351/// .doit().await;
17352/// # }
17353/// ```
17354pub struct ProjectLocationVolumeGetCall<'a, C>
17355where
17356 C: 'a,
17357{
17358 hub: &'a Baremetalsolution<C>,
17359 _name: String,
17360 _delegate: Option<&'a mut dyn common::Delegate>,
17361 _additional_params: HashMap<String, String>,
17362 _scopes: BTreeSet<String>,
17363}
17364
17365impl<'a, C> common::CallBuilder for ProjectLocationVolumeGetCall<'a, C> {}
17366
17367impl<'a, C> ProjectLocationVolumeGetCall<'a, C>
17368where
17369 C: common::Connector,
17370{
17371 /// Perform the operation you have build so far.
17372 pub async fn doit(mut self) -> common::Result<(common::Response, Volume)> {
17373 use std::borrow::Cow;
17374 use std::io::{Read, Seek};
17375
17376 use common::{url::Params, ToParts};
17377 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17378
17379 let mut dd = common::DefaultDelegate;
17380 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17381 dlg.begin(common::MethodInfo {
17382 id: "baremetalsolution.projects.locations.volumes.get",
17383 http_method: hyper::Method::GET,
17384 });
17385
17386 for &field in ["alt", "name"].iter() {
17387 if self._additional_params.contains_key(field) {
17388 dlg.finished(false);
17389 return Err(common::Error::FieldClash(field));
17390 }
17391 }
17392
17393 let mut params = Params::with_capacity(3 + self._additional_params.len());
17394 params.push("name", self._name);
17395
17396 params.extend(self._additional_params.iter());
17397
17398 params.push("alt", "json");
17399 let mut url = self.hub._base_url.clone() + "v2/{+name}";
17400 if self._scopes.is_empty() {
17401 self._scopes
17402 .insert(Scope::CloudPlatform.as_ref().to_string());
17403 }
17404
17405 #[allow(clippy::single_element_loop)]
17406 for &(find_this, param_name) in [("{+name}", "name")].iter() {
17407 url = params.uri_replacement(url, param_name, find_this, true);
17408 }
17409 {
17410 let to_remove = ["name"];
17411 params.remove_params(&to_remove);
17412 }
17413
17414 let url = params.parse_with_url(&url);
17415
17416 loop {
17417 let token = match self
17418 .hub
17419 .auth
17420 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17421 .await
17422 {
17423 Ok(token) => token,
17424 Err(e) => match dlg.token(e) {
17425 Ok(token) => token,
17426 Err(e) => {
17427 dlg.finished(false);
17428 return Err(common::Error::MissingToken(e));
17429 }
17430 },
17431 };
17432 let mut req_result = {
17433 let client = &self.hub.client;
17434 dlg.pre_request();
17435 let mut req_builder = hyper::Request::builder()
17436 .method(hyper::Method::GET)
17437 .uri(url.as_str())
17438 .header(USER_AGENT, self.hub._user_agent.clone());
17439
17440 if let Some(token) = token.as_ref() {
17441 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17442 }
17443
17444 let request = req_builder
17445 .header(CONTENT_LENGTH, 0_u64)
17446 .body(common::to_body::<String>(None));
17447
17448 client.request(request.unwrap()).await
17449 };
17450
17451 match req_result {
17452 Err(err) => {
17453 if let common::Retry::After(d) = dlg.http_error(&err) {
17454 sleep(d).await;
17455 continue;
17456 }
17457 dlg.finished(false);
17458 return Err(common::Error::HttpError(err));
17459 }
17460 Ok(res) => {
17461 let (mut parts, body) = res.into_parts();
17462 let mut body = common::Body::new(body);
17463 if !parts.status.is_success() {
17464 let bytes = common::to_bytes(body).await.unwrap_or_default();
17465 let error = serde_json::from_str(&common::to_string(&bytes));
17466 let response = common::to_response(parts, bytes.into());
17467
17468 if let common::Retry::After(d) =
17469 dlg.http_failure(&response, error.as_ref().ok())
17470 {
17471 sleep(d).await;
17472 continue;
17473 }
17474
17475 dlg.finished(false);
17476
17477 return Err(match error {
17478 Ok(value) => common::Error::BadRequest(value),
17479 _ => common::Error::Failure(response),
17480 });
17481 }
17482 let response = {
17483 let bytes = common::to_bytes(body).await.unwrap_or_default();
17484 let encoded = common::to_string(&bytes);
17485 match serde_json::from_str(&encoded) {
17486 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17487 Err(error) => {
17488 dlg.response_json_decode_error(&encoded, &error);
17489 return Err(common::Error::JsonDecodeError(
17490 encoded.to_string(),
17491 error,
17492 ));
17493 }
17494 }
17495 };
17496
17497 dlg.finished(true);
17498 return Ok(response);
17499 }
17500 }
17501 }
17502 }
17503
17504 /// Required. Name of the resource.
17505 ///
17506 /// Sets the *name* path property to the given value.
17507 ///
17508 /// Even though the property as already been set when instantiating this call,
17509 /// we provide this method for API completeness.
17510 pub fn name(mut self, new_value: &str) -> ProjectLocationVolumeGetCall<'a, C> {
17511 self._name = new_value.to_string();
17512 self
17513 }
17514 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17515 /// while executing the actual API request.
17516 ///
17517 /// ````text
17518 /// It should be used to handle progress information, and to implement a certain level of resilience.
17519 /// ````
17520 ///
17521 /// Sets the *delegate* property to the given value.
17522 pub fn delegate(
17523 mut self,
17524 new_value: &'a mut dyn common::Delegate,
17525 ) -> ProjectLocationVolumeGetCall<'a, C> {
17526 self._delegate = Some(new_value);
17527 self
17528 }
17529
17530 /// Set any additional parameter of the query string used in the request.
17531 /// It should be used to set parameters which are not yet available through their own
17532 /// setters.
17533 ///
17534 /// Please note that this method must not be used to set any of the known parameters
17535 /// which have their own setter method. If done anyway, the request will fail.
17536 ///
17537 /// # Additional Parameters
17538 ///
17539 /// * *$.xgafv* (query-string) - V1 error format.
17540 /// * *access_token* (query-string) - OAuth access token.
17541 /// * *alt* (query-string) - Data format for response.
17542 /// * *callback* (query-string) - JSONP
17543 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17544 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17545 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17546 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17547 /// * *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.
17548 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17549 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17550 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeGetCall<'a, C>
17551 where
17552 T: AsRef<str>,
17553 {
17554 self._additional_params
17555 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17556 self
17557 }
17558
17559 /// Identifies the authorization scope for the method you are building.
17560 ///
17561 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17562 /// [`Scope::CloudPlatform`].
17563 ///
17564 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17565 /// tokens for more than one scope.
17566 ///
17567 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17568 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17569 /// sufficient, a read-write scope will do as well.
17570 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeGetCall<'a, C>
17571 where
17572 St: AsRef<str>,
17573 {
17574 self._scopes.insert(String::from(scope.as_ref()));
17575 self
17576 }
17577 /// Identifies the authorization scope(s) for the method you are building.
17578 ///
17579 /// See [`Self::add_scope()`] for details.
17580 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeGetCall<'a, C>
17581 where
17582 I: IntoIterator<Item = St>,
17583 St: AsRef<str>,
17584 {
17585 self._scopes
17586 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17587 self
17588 }
17589
17590 /// Removes all scopes, and no default scope will be used either.
17591 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17592 /// for details).
17593 pub fn clear_scopes(mut self) -> ProjectLocationVolumeGetCall<'a, C> {
17594 self._scopes.clear();
17595 self
17596 }
17597}
17598
17599/// List storage volumes in a given project and location.
17600///
17601/// A builder for the *locations.volumes.list* method supported by a *project* resource.
17602/// It is not used directly, but through a [`ProjectMethods`] instance.
17603///
17604/// # Example
17605///
17606/// Instantiate a resource method builder
17607///
17608/// ```test_harness,no_run
17609/// # extern crate hyper;
17610/// # extern crate hyper_rustls;
17611/// # extern crate google_baremetalsolution2 as baremetalsolution2;
17612/// # async fn dox() {
17613/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17614///
17615/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17616/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17617/// # secret,
17618/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17619/// # ).build().await.unwrap();
17620///
17621/// # let client = hyper_util::client::legacy::Client::builder(
17622/// # hyper_util::rt::TokioExecutor::new()
17623/// # )
17624/// # .build(
17625/// # hyper_rustls::HttpsConnectorBuilder::new()
17626/// # .with_native_roots()
17627/// # .unwrap()
17628/// # .https_or_http()
17629/// # .enable_http1()
17630/// # .build()
17631/// # );
17632/// # let mut hub = Baremetalsolution::new(client, auth);
17633/// // You can configure optional parameters by calling the respective setters at will, and
17634/// // execute the final call using `doit()`.
17635/// // Values shown here are possibly random and not representative !
17636/// let result = hub.projects().locations_volumes_list("parent")
17637/// .page_token("diam")
17638/// .page_size(-61)
17639/// .filter("ipsum")
17640/// .doit().await;
17641/// # }
17642/// ```
17643pub struct ProjectLocationVolumeListCall<'a, C>
17644where
17645 C: 'a,
17646{
17647 hub: &'a Baremetalsolution<C>,
17648 _parent: String,
17649 _page_token: Option<String>,
17650 _page_size: Option<i32>,
17651 _filter: Option<String>,
17652 _delegate: Option<&'a mut dyn common::Delegate>,
17653 _additional_params: HashMap<String, String>,
17654 _scopes: BTreeSet<String>,
17655}
17656
17657impl<'a, C> common::CallBuilder for ProjectLocationVolumeListCall<'a, C> {}
17658
17659impl<'a, C> ProjectLocationVolumeListCall<'a, C>
17660where
17661 C: common::Connector,
17662{
17663 /// Perform the operation you have build so far.
17664 pub async fn doit(mut self) -> common::Result<(common::Response, ListVolumesResponse)> {
17665 use std::borrow::Cow;
17666 use std::io::{Read, Seek};
17667
17668 use common::{url::Params, ToParts};
17669 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17670
17671 let mut dd = common::DefaultDelegate;
17672 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17673 dlg.begin(common::MethodInfo {
17674 id: "baremetalsolution.projects.locations.volumes.list",
17675 http_method: hyper::Method::GET,
17676 });
17677
17678 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
17679 if self._additional_params.contains_key(field) {
17680 dlg.finished(false);
17681 return Err(common::Error::FieldClash(field));
17682 }
17683 }
17684
17685 let mut params = Params::with_capacity(6 + self._additional_params.len());
17686 params.push("parent", self._parent);
17687 if let Some(value) = self._page_token.as_ref() {
17688 params.push("pageToken", value);
17689 }
17690 if let Some(value) = self._page_size.as_ref() {
17691 params.push("pageSize", value.to_string());
17692 }
17693 if let Some(value) = self._filter.as_ref() {
17694 params.push("filter", value);
17695 }
17696
17697 params.extend(self._additional_params.iter());
17698
17699 params.push("alt", "json");
17700 let mut url = self.hub._base_url.clone() + "v2/{+parent}/volumes";
17701 if self._scopes.is_empty() {
17702 self._scopes
17703 .insert(Scope::CloudPlatform.as_ref().to_string());
17704 }
17705
17706 #[allow(clippy::single_element_loop)]
17707 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
17708 url = params.uri_replacement(url, param_name, find_this, true);
17709 }
17710 {
17711 let to_remove = ["parent"];
17712 params.remove_params(&to_remove);
17713 }
17714
17715 let url = params.parse_with_url(&url);
17716
17717 loop {
17718 let token = match self
17719 .hub
17720 .auth
17721 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17722 .await
17723 {
17724 Ok(token) => token,
17725 Err(e) => match dlg.token(e) {
17726 Ok(token) => token,
17727 Err(e) => {
17728 dlg.finished(false);
17729 return Err(common::Error::MissingToken(e));
17730 }
17731 },
17732 };
17733 let mut req_result = {
17734 let client = &self.hub.client;
17735 dlg.pre_request();
17736 let mut req_builder = hyper::Request::builder()
17737 .method(hyper::Method::GET)
17738 .uri(url.as_str())
17739 .header(USER_AGENT, self.hub._user_agent.clone());
17740
17741 if let Some(token) = token.as_ref() {
17742 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17743 }
17744
17745 let request = req_builder
17746 .header(CONTENT_LENGTH, 0_u64)
17747 .body(common::to_body::<String>(None));
17748
17749 client.request(request.unwrap()).await
17750 };
17751
17752 match req_result {
17753 Err(err) => {
17754 if let common::Retry::After(d) = dlg.http_error(&err) {
17755 sleep(d).await;
17756 continue;
17757 }
17758 dlg.finished(false);
17759 return Err(common::Error::HttpError(err));
17760 }
17761 Ok(res) => {
17762 let (mut parts, body) = res.into_parts();
17763 let mut body = common::Body::new(body);
17764 if !parts.status.is_success() {
17765 let bytes = common::to_bytes(body).await.unwrap_or_default();
17766 let error = serde_json::from_str(&common::to_string(&bytes));
17767 let response = common::to_response(parts, bytes.into());
17768
17769 if let common::Retry::After(d) =
17770 dlg.http_failure(&response, error.as_ref().ok())
17771 {
17772 sleep(d).await;
17773 continue;
17774 }
17775
17776 dlg.finished(false);
17777
17778 return Err(match error {
17779 Ok(value) => common::Error::BadRequest(value),
17780 _ => common::Error::Failure(response),
17781 });
17782 }
17783 let response = {
17784 let bytes = common::to_bytes(body).await.unwrap_or_default();
17785 let encoded = common::to_string(&bytes);
17786 match serde_json::from_str(&encoded) {
17787 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17788 Err(error) => {
17789 dlg.response_json_decode_error(&encoded, &error);
17790 return Err(common::Error::JsonDecodeError(
17791 encoded.to_string(),
17792 error,
17793 ));
17794 }
17795 }
17796 };
17797
17798 dlg.finished(true);
17799 return Ok(response);
17800 }
17801 }
17802 }
17803 }
17804
17805 /// Required. Parent value for ListVolumesRequest.
17806 ///
17807 /// Sets the *parent* path property to the given value.
17808 ///
17809 /// Even though the property as already been set when instantiating this call,
17810 /// we provide this method for API completeness.
17811 pub fn parent(mut self, new_value: &str) -> ProjectLocationVolumeListCall<'a, C> {
17812 self._parent = new_value.to_string();
17813 self
17814 }
17815 /// A token identifying a page of results from the server.
17816 ///
17817 /// Sets the *page token* query property to the given value.
17818 pub fn page_token(mut self, new_value: &str) -> ProjectLocationVolumeListCall<'a, C> {
17819 self._page_token = Some(new_value.to_string());
17820 self
17821 }
17822 /// Requested page size. The server might return fewer items than requested. If unspecified, server will pick an appropriate default.
17823 ///
17824 /// Sets the *page size* query property to the given value.
17825 pub fn page_size(mut self, new_value: i32) -> ProjectLocationVolumeListCall<'a, C> {
17826 self._page_size = Some(new_value);
17827 self
17828 }
17829 /// List filter.
17830 ///
17831 /// Sets the *filter* query property to the given value.
17832 pub fn filter(mut self, new_value: &str) -> ProjectLocationVolumeListCall<'a, C> {
17833 self._filter = Some(new_value.to_string());
17834 self
17835 }
17836 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17837 /// while executing the actual API request.
17838 ///
17839 /// ````text
17840 /// It should be used to handle progress information, and to implement a certain level of resilience.
17841 /// ````
17842 ///
17843 /// Sets the *delegate* property to the given value.
17844 pub fn delegate(
17845 mut self,
17846 new_value: &'a mut dyn common::Delegate,
17847 ) -> ProjectLocationVolumeListCall<'a, C> {
17848 self._delegate = Some(new_value);
17849 self
17850 }
17851
17852 /// Set any additional parameter of the query string used in the request.
17853 /// It should be used to set parameters which are not yet available through their own
17854 /// setters.
17855 ///
17856 /// Please note that this method must not be used to set any of the known parameters
17857 /// which have their own setter method. If done anyway, the request will fail.
17858 ///
17859 /// # Additional Parameters
17860 ///
17861 /// * *$.xgafv* (query-string) - V1 error format.
17862 /// * *access_token* (query-string) - OAuth access token.
17863 /// * *alt* (query-string) - Data format for response.
17864 /// * *callback* (query-string) - JSONP
17865 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17866 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
17867 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17868 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17869 /// * *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.
17870 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17871 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17872 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeListCall<'a, C>
17873 where
17874 T: AsRef<str>,
17875 {
17876 self._additional_params
17877 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17878 self
17879 }
17880
17881 /// Identifies the authorization scope for the method you are building.
17882 ///
17883 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17884 /// [`Scope::CloudPlatform`].
17885 ///
17886 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17887 /// tokens for more than one scope.
17888 ///
17889 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17890 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17891 /// sufficient, a read-write scope will do as well.
17892 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeListCall<'a, C>
17893 where
17894 St: AsRef<str>,
17895 {
17896 self._scopes.insert(String::from(scope.as_ref()));
17897 self
17898 }
17899 /// Identifies the authorization scope(s) for the method you are building.
17900 ///
17901 /// See [`Self::add_scope()`] for details.
17902 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeListCall<'a, C>
17903 where
17904 I: IntoIterator<Item = St>,
17905 St: AsRef<str>,
17906 {
17907 self._scopes
17908 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17909 self
17910 }
17911
17912 /// Removes all scopes, and no default scope will be used either.
17913 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17914 /// for details).
17915 pub fn clear_scopes(mut self) -> ProjectLocationVolumeListCall<'a, C> {
17916 self._scopes.clear();
17917 self
17918 }
17919}
17920
17921/// Update details of a single storage volume.
17922///
17923/// A builder for the *locations.volumes.patch* method supported by a *project* resource.
17924/// It is not used directly, but through a [`ProjectMethods`] instance.
17925///
17926/// # Example
17927///
17928/// Instantiate a resource method builder
17929///
17930/// ```test_harness,no_run
17931/// # extern crate hyper;
17932/// # extern crate hyper_rustls;
17933/// # extern crate google_baremetalsolution2 as baremetalsolution2;
17934/// use baremetalsolution2::api::Volume;
17935/// # async fn dox() {
17936/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17937///
17938/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17939/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17940/// # secret,
17941/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17942/// # ).build().await.unwrap();
17943///
17944/// # let client = hyper_util::client::legacy::Client::builder(
17945/// # hyper_util::rt::TokioExecutor::new()
17946/// # )
17947/// # .build(
17948/// # hyper_rustls::HttpsConnectorBuilder::new()
17949/// # .with_native_roots()
17950/// # .unwrap()
17951/// # .https_or_http()
17952/// # .enable_http1()
17953/// # .build()
17954/// # );
17955/// # let mut hub = Baremetalsolution::new(client, auth);
17956/// // As the method needs a request, you would usually fill it with the desired information
17957/// // into the respective structure. Some of the parts shown here might not be applicable !
17958/// // Values shown here are possibly random and not representative !
17959/// let mut req = Volume::default();
17960///
17961/// // You can configure optional parameters by calling the respective setters at will, and
17962/// // execute the final call using `doit()`.
17963/// // Values shown here are possibly random and not representative !
17964/// let result = hub.projects().locations_volumes_patch(req, "name")
17965/// .update_mask(FieldMask::new::<&str>(&[]))
17966/// .doit().await;
17967/// # }
17968/// ```
17969pub struct ProjectLocationVolumePatchCall<'a, C>
17970where
17971 C: 'a,
17972{
17973 hub: &'a Baremetalsolution<C>,
17974 _request: Volume,
17975 _name: String,
17976 _update_mask: Option<common::FieldMask>,
17977 _delegate: Option<&'a mut dyn common::Delegate>,
17978 _additional_params: HashMap<String, String>,
17979 _scopes: BTreeSet<String>,
17980}
17981
17982impl<'a, C> common::CallBuilder for ProjectLocationVolumePatchCall<'a, C> {}
17983
17984impl<'a, C> ProjectLocationVolumePatchCall<'a, C>
17985where
17986 C: common::Connector,
17987{
17988 /// Perform the operation you have build so far.
17989 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
17990 use std::borrow::Cow;
17991 use std::io::{Read, Seek};
17992
17993 use common::{url::Params, ToParts};
17994 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17995
17996 let mut dd = common::DefaultDelegate;
17997 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17998 dlg.begin(common::MethodInfo {
17999 id: "baremetalsolution.projects.locations.volumes.patch",
18000 http_method: hyper::Method::PATCH,
18001 });
18002
18003 for &field in ["alt", "name", "updateMask"].iter() {
18004 if self._additional_params.contains_key(field) {
18005 dlg.finished(false);
18006 return Err(common::Error::FieldClash(field));
18007 }
18008 }
18009
18010 let mut params = Params::with_capacity(5 + self._additional_params.len());
18011 params.push("name", self._name);
18012 if let Some(value) = self._update_mask.as_ref() {
18013 params.push("updateMask", value.to_string());
18014 }
18015
18016 params.extend(self._additional_params.iter());
18017
18018 params.push("alt", "json");
18019 let mut url = self.hub._base_url.clone() + "v2/{+name}";
18020 if self._scopes.is_empty() {
18021 self._scopes
18022 .insert(Scope::CloudPlatform.as_ref().to_string());
18023 }
18024
18025 #[allow(clippy::single_element_loop)]
18026 for &(find_this, param_name) in [("{+name}", "name")].iter() {
18027 url = params.uri_replacement(url, param_name, find_this, true);
18028 }
18029 {
18030 let to_remove = ["name"];
18031 params.remove_params(&to_remove);
18032 }
18033
18034 let url = params.parse_with_url(&url);
18035
18036 let mut json_mime_type = mime::APPLICATION_JSON;
18037 let mut request_value_reader = {
18038 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18039 common::remove_json_null_values(&mut value);
18040 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18041 serde_json::to_writer(&mut dst, &value).unwrap();
18042 dst
18043 };
18044 let request_size = request_value_reader
18045 .seek(std::io::SeekFrom::End(0))
18046 .unwrap();
18047 request_value_reader
18048 .seek(std::io::SeekFrom::Start(0))
18049 .unwrap();
18050
18051 loop {
18052 let token = match self
18053 .hub
18054 .auth
18055 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18056 .await
18057 {
18058 Ok(token) => token,
18059 Err(e) => match dlg.token(e) {
18060 Ok(token) => token,
18061 Err(e) => {
18062 dlg.finished(false);
18063 return Err(common::Error::MissingToken(e));
18064 }
18065 },
18066 };
18067 request_value_reader
18068 .seek(std::io::SeekFrom::Start(0))
18069 .unwrap();
18070 let mut req_result = {
18071 let client = &self.hub.client;
18072 dlg.pre_request();
18073 let mut req_builder = hyper::Request::builder()
18074 .method(hyper::Method::PATCH)
18075 .uri(url.as_str())
18076 .header(USER_AGENT, self.hub._user_agent.clone());
18077
18078 if let Some(token) = token.as_ref() {
18079 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18080 }
18081
18082 let request = req_builder
18083 .header(CONTENT_TYPE, json_mime_type.to_string())
18084 .header(CONTENT_LENGTH, request_size as u64)
18085 .body(common::to_body(
18086 request_value_reader.get_ref().clone().into(),
18087 ));
18088
18089 client.request(request.unwrap()).await
18090 };
18091
18092 match req_result {
18093 Err(err) => {
18094 if let common::Retry::After(d) = dlg.http_error(&err) {
18095 sleep(d).await;
18096 continue;
18097 }
18098 dlg.finished(false);
18099 return Err(common::Error::HttpError(err));
18100 }
18101 Ok(res) => {
18102 let (mut parts, body) = res.into_parts();
18103 let mut body = common::Body::new(body);
18104 if !parts.status.is_success() {
18105 let bytes = common::to_bytes(body).await.unwrap_or_default();
18106 let error = serde_json::from_str(&common::to_string(&bytes));
18107 let response = common::to_response(parts, bytes.into());
18108
18109 if let common::Retry::After(d) =
18110 dlg.http_failure(&response, error.as_ref().ok())
18111 {
18112 sleep(d).await;
18113 continue;
18114 }
18115
18116 dlg.finished(false);
18117
18118 return Err(match error {
18119 Ok(value) => common::Error::BadRequest(value),
18120 _ => common::Error::Failure(response),
18121 });
18122 }
18123 let response = {
18124 let bytes = common::to_bytes(body).await.unwrap_or_default();
18125 let encoded = common::to_string(&bytes);
18126 match serde_json::from_str(&encoded) {
18127 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18128 Err(error) => {
18129 dlg.response_json_decode_error(&encoded, &error);
18130 return Err(common::Error::JsonDecodeError(
18131 encoded.to_string(),
18132 error,
18133 ));
18134 }
18135 }
18136 };
18137
18138 dlg.finished(true);
18139 return Ok(response);
18140 }
18141 }
18142 }
18143 }
18144
18145 ///
18146 /// Sets the *request* property to the given value.
18147 ///
18148 /// Even though the property as already been set when instantiating this call,
18149 /// we provide this method for API completeness.
18150 pub fn request(mut self, new_value: Volume) -> ProjectLocationVolumePatchCall<'a, C> {
18151 self._request = new_value;
18152 self
18153 }
18154 /// 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}`
18155 ///
18156 /// Sets the *name* path property to the given value.
18157 ///
18158 /// Even though the property as already been set when instantiating this call,
18159 /// we provide this method for API completeness.
18160 pub fn name(mut self, new_value: &str) -> ProjectLocationVolumePatchCall<'a, C> {
18161 self._name = new_value.to_string();
18162 self
18163 }
18164 /// The list of fields to update. The only currently supported fields are: 'labels'
18165 ///
18166 /// Sets the *update mask* query property to the given value.
18167 pub fn update_mask(
18168 mut self,
18169 new_value: common::FieldMask,
18170 ) -> ProjectLocationVolumePatchCall<'a, C> {
18171 self._update_mask = Some(new_value);
18172 self
18173 }
18174 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18175 /// while executing the actual API request.
18176 ///
18177 /// ````text
18178 /// It should be used to handle progress information, and to implement a certain level of resilience.
18179 /// ````
18180 ///
18181 /// Sets the *delegate* property to the given value.
18182 pub fn delegate(
18183 mut self,
18184 new_value: &'a mut dyn common::Delegate,
18185 ) -> ProjectLocationVolumePatchCall<'a, C> {
18186 self._delegate = Some(new_value);
18187 self
18188 }
18189
18190 /// Set any additional parameter of the query string used in the request.
18191 /// It should be used to set parameters which are not yet available through their own
18192 /// setters.
18193 ///
18194 /// Please note that this method must not be used to set any of the known parameters
18195 /// which have their own setter method. If done anyway, the request will fail.
18196 ///
18197 /// # Additional Parameters
18198 ///
18199 /// * *$.xgafv* (query-string) - V1 error format.
18200 /// * *access_token* (query-string) - OAuth access token.
18201 /// * *alt* (query-string) - Data format for response.
18202 /// * *callback* (query-string) - JSONP
18203 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18204 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18205 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18206 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18207 /// * *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.
18208 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18209 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18210 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumePatchCall<'a, C>
18211 where
18212 T: AsRef<str>,
18213 {
18214 self._additional_params
18215 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18216 self
18217 }
18218
18219 /// Identifies the authorization scope for the method you are building.
18220 ///
18221 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18222 /// [`Scope::CloudPlatform`].
18223 ///
18224 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18225 /// tokens for more than one scope.
18226 ///
18227 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18228 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18229 /// sufficient, a read-write scope will do as well.
18230 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumePatchCall<'a, C>
18231 where
18232 St: AsRef<str>,
18233 {
18234 self._scopes.insert(String::from(scope.as_ref()));
18235 self
18236 }
18237 /// Identifies the authorization scope(s) for the method you are building.
18238 ///
18239 /// See [`Self::add_scope()`] for details.
18240 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumePatchCall<'a, C>
18241 where
18242 I: IntoIterator<Item = St>,
18243 St: AsRef<str>,
18244 {
18245 self._scopes
18246 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18247 self
18248 }
18249
18250 /// Removes all scopes, and no default scope will be used either.
18251 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18252 /// for details).
18253 pub fn clear_scopes(mut self) -> ProjectLocationVolumePatchCall<'a, C> {
18254 self._scopes.clear();
18255 self
18256 }
18257}
18258
18259/// RenameVolume sets a new name for a volume. Use with caution, previous names become immediately invalidated.
18260///
18261/// A builder for the *locations.volumes.rename* method supported by a *project* resource.
18262/// It is not used directly, but through a [`ProjectMethods`] instance.
18263///
18264/// # Example
18265///
18266/// Instantiate a resource method builder
18267///
18268/// ```test_harness,no_run
18269/// # extern crate hyper;
18270/// # extern crate hyper_rustls;
18271/// # extern crate google_baremetalsolution2 as baremetalsolution2;
18272/// use baremetalsolution2::api::RenameVolumeRequest;
18273/// # async fn dox() {
18274/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18275///
18276/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18277/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18278/// # secret,
18279/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18280/// # ).build().await.unwrap();
18281///
18282/// # let client = hyper_util::client::legacy::Client::builder(
18283/// # hyper_util::rt::TokioExecutor::new()
18284/// # )
18285/// # .build(
18286/// # hyper_rustls::HttpsConnectorBuilder::new()
18287/// # .with_native_roots()
18288/// # .unwrap()
18289/// # .https_or_http()
18290/// # .enable_http1()
18291/// # .build()
18292/// # );
18293/// # let mut hub = Baremetalsolution::new(client, auth);
18294/// // As the method needs a request, you would usually fill it with the desired information
18295/// // into the respective structure. Some of the parts shown here might not be applicable !
18296/// // Values shown here are possibly random and not representative !
18297/// let mut req = RenameVolumeRequest::default();
18298///
18299/// // You can configure optional parameters by calling the respective setters at will, and
18300/// // execute the final call using `doit()`.
18301/// // Values shown here are possibly random and not representative !
18302/// let result = hub.projects().locations_volumes_rename(req, "name")
18303/// .doit().await;
18304/// # }
18305/// ```
18306pub struct ProjectLocationVolumeRenameCall<'a, C>
18307where
18308 C: 'a,
18309{
18310 hub: &'a Baremetalsolution<C>,
18311 _request: RenameVolumeRequest,
18312 _name: String,
18313 _delegate: Option<&'a mut dyn common::Delegate>,
18314 _additional_params: HashMap<String, String>,
18315 _scopes: BTreeSet<String>,
18316}
18317
18318impl<'a, C> common::CallBuilder for ProjectLocationVolumeRenameCall<'a, C> {}
18319
18320impl<'a, C> ProjectLocationVolumeRenameCall<'a, C>
18321where
18322 C: common::Connector,
18323{
18324 /// Perform the operation you have build so far.
18325 pub async fn doit(mut self) -> common::Result<(common::Response, Volume)> {
18326 use std::borrow::Cow;
18327 use std::io::{Read, Seek};
18328
18329 use common::{url::Params, ToParts};
18330 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18331
18332 let mut dd = common::DefaultDelegate;
18333 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18334 dlg.begin(common::MethodInfo {
18335 id: "baremetalsolution.projects.locations.volumes.rename",
18336 http_method: hyper::Method::POST,
18337 });
18338
18339 for &field in ["alt", "name"].iter() {
18340 if self._additional_params.contains_key(field) {
18341 dlg.finished(false);
18342 return Err(common::Error::FieldClash(field));
18343 }
18344 }
18345
18346 let mut params = Params::with_capacity(4 + self._additional_params.len());
18347 params.push("name", self._name);
18348
18349 params.extend(self._additional_params.iter());
18350
18351 params.push("alt", "json");
18352 let mut url = self.hub._base_url.clone() + "v2/{+name}:rename";
18353 if self._scopes.is_empty() {
18354 self._scopes
18355 .insert(Scope::CloudPlatform.as_ref().to_string());
18356 }
18357
18358 #[allow(clippy::single_element_loop)]
18359 for &(find_this, param_name) in [("{+name}", "name")].iter() {
18360 url = params.uri_replacement(url, param_name, find_this, true);
18361 }
18362 {
18363 let to_remove = ["name"];
18364 params.remove_params(&to_remove);
18365 }
18366
18367 let url = params.parse_with_url(&url);
18368
18369 let mut json_mime_type = mime::APPLICATION_JSON;
18370 let mut request_value_reader = {
18371 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18372 common::remove_json_null_values(&mut value);
18373 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18374 serde_json::to_writer(&mut dst, &value).unwrap();
18375 dst
18376 };
18377 let request_size = request_value_reader
18378 .seek(std::io::SeekFrom::End(0))
18379 .unwrap();
18380 request_value_reader
18381 .seek(std::io::SeekFrom::Start(0))
18382 .unwrap();
18383
18384 loop {
18385 let token = match self
18386 .hub
18387 .auth
18388 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18389 .await
18390 {
18391 Ok(token) => token,
18392 Err(e) => match dlg.token(e) {
18393 Ok(token) => token,
18394 Err(e) => {
18395 dlg.finished(false);
18396 return Err(common::Error::MissingToken(e));
18397 }
18398 },
18399 };
18400 request_value_reader
18401 .seek(std::io::SeekFrom::Start(0))
18402 .unwrap();
18403 let mut req_result = {
18404 let client = &self.hub.client;
18405 dlg.pre_request();
18406 let mut req_builder = hyper::Request::builder()
18407 .method(hyper::Method::POST)
18408 .uri(url.as_str())
18409 .header(USER_AGENT, self.hub._user_agent.clone());
18410
18411 if let Some(token) = token.as_ref() {
18412 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18413 }
18414
18415 let request = req_builder
18416 .header(CONTENT_TYPE, json_mime_type.to_string())
18417 .header(CONTENT_LENGTH, request_size as u64)
18418 .body(common::to_body(
18419 request_value_reader.get_ref().clone().into(),
18420 ));
18421
18422 client.request(request.unwrap()).await
18423 };
18424
18425 match req_result {
18426 Err(err) => {
18427 if let common::Retry::After(d) = dlg.http_error(&err) {
18428 sleep(d).await;
18429 continue;
18430 }
18431 dlg.finished(false);
18432 return Err(common::Error::HttpError(err));
18433 }
18434 Ok(res) => {
18435 let (mut parts, body) = res.into_parts();
18436 let mut body = common::Body::new(body);
18437 if !parts.status.is_success() {
18438 let bytes = common::to_bytes(body).await.unwrap_or_default();
18439 let error = serde_json::from_str(&common::to_string(&bytes));
18440 let response = common::to_response(parts, bytes.into());
18441
18442 if let common::Retry::After(d) =
18443 dlg.http_failure(&response, error.as_ref().ok())
18444 {
18445 sleep(d).await;
18446 continue;
18447 }
18448
18449 dlg.finished(false);
18450
18451 return Err(match error {
18452 Ok(value) => common::Error::BadRequest(value),
18453 _ => common::Error::Failure(response),
18454 });
18455 }
18456 let response = {
18457 let bytes = common::to_bytes(body).await.unwrap_or_default();
18458 let encoded = common::to_string(&bytes);
18459 match serde_json::from_str(&encoded) {
18460 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18461 Err(error) => {
18462 dlg.response_json_decode_error(&encoded, &error);
18463 return Err(common::Error::JsonDecodeError(
18464 encoded.to_string(),
18465 error,
18466 ));
18467 }
18468 }
18469 };
18470
18471 dlg.finished(true);
18472 return Ok(response);
18473 }
18474 }
18475 }
18476 }
18477
18478 ///
18479 /// Sets the *request* property to the given value.
18480 ///
18481 /// Even though the property as already been set when instantiating this call,
18482 /// we provide this method for API completeness.
18483 pub fn request(
18484 mut self,
18485 new_value: RenameVolumeRequest,
18486 ) -> ProjectLocationVolumeRenameCall<'a, C> {
18487 self._request = new_value;
18488 self
18489 }
18490 /// Required. The `name` field is used to identify the volume. Format: projects/{project}/locations/{location}/volumes/{volume}
18491 ///
18492 /// Sets the *name* path property to the given value.
18493 ///
18494 /// Even though the property as already been set when instantiating this call,
18495 /// we provide this method for API completeness.
18496 pub fn name(mut self, new_value: &str) -> ProjectLocationVolumeRenameCall<'a, C> {
18497 self._name = new_value.to_string();
18498 self
18499 }
18500 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18501 /// while executing the actual API request.
18502 ///
18503 /// ````text
18504 /// It should be used to handle progress information, and to implement a certain level of resilience.
18505 /// ````
18506 ///
18507 /// Sets the *delegate* property to the given value.
18508 pub fn delegate(
18509 mut self,
18510 new_value: &'a mut dyn common::Delegate,
18511 ) -> ProjectLocationVolumeRenameCall<'a, C> {
18512 self._delegate = Some(new_value);
18513 self
18514 }
18515
18516 /// Set any additional parameter of the query string used in the request.
18517 /// It should be used to set parameters which are not yet available through their own
18518 /// setters.
18519 ///
18520 /// Please note that this method must not be used to set any of the known parameters
18521 /// which have their own setter method. If done anyway, the request will fail.
18522 ///
18523 /// # Additional Parameters
18524 ///
18525 /// * *$.xgafv* (query-string) - V1 error format.
18526 /// * *access_token* (query-string) - OAuth access token.
18527 /// * *alt* (query-string) - Data format for response.
18528 /// * *callback* (query-string) - JSONP
18529 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18530 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18531 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18532 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18533 /// * *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.
18534 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18535 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18536 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeRenameCall<'a, C>
18537 where
18538 T: AsRef<str>,
18539 {
18540 self._additional_params
18541 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18542 self
18543 }
18544
18545 /// Identifies the authorization scope for the method you are building.
18546 ///
18547 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18548 /// [`Scope::CloudPlatform`].
18549 ///
18550 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18551 /// tokens for more than one scope.
18552 ///
18553 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18554 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18555 /// sufficient, a read-write scope will do as well.
18556 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeRenameCall<'a, C>
18557 where
18558 St: AsRef<str>,
18559 {
18560 self._scopes.insert(String::from(scope.as_ref()));
18561 self
18562 }
18563 /// Identifies the authorization scope(s) for the method you are building.
18564 ///
18565 /// See [`Self::add_scope()`] for details.
18566 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeRenameCall<'a, C>
18567 where
18568 I: IntoIterator<Item = St>,
18569 St: AsRef<str>,
18570 {
18571 self._scopes
18572 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18573 self
18574 }
18575
18576 /// Removes all scopes, and no default scope will be used either.
18577 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18578 /// for details).
18579 pub fn clear_scopes(mut self) -> ProjectLocationVolumeRenameCall<'a, C> {
18580 self._scopes.clear();
18581 self
18582 }
18583}
18584
18585/// Emergency Volume resize.
18586///
18587/// A builder for the *locations.volumes.resize* method supported by a *project* resource.
18588/// It is not used directly, but through a [`ProjectMethods`] instance.
18589///
18590/// # Example
18591///
18592/// Instantiate a resource method builder
18593///
18594/// ```test_harness,no_run
18595/// # extern crate hyper;
18596/// # extern crate hyper_rustls;
18597/// # extern crate google_baremetalsolution2 as baremetalsolution2;
18598/// use baremetalsolution2::api::ResizeVolumeRequest;
18599/// # async fn dox() {
18600/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18601///
18602/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18603/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18604/// # secret,
18605/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18606/// # ).build().await.unwrap();
18607///
18608/// # let client = hyper_util::client::legacy::Client::builder(
18609/// # hyper_util::rt::TokioExecutor::new()
18610/// # )
18611/// # .build(
18612/// # hyper_rustls::HttpsConnectorBuilder::new()
18613/// # .with_native_roots()
18614/// # .unwrap()
18615/// # .https_or_http()
18616/// # .enable_http1()
18617/// # .build()
18618/// # );
18619/// # let mut hub = Baremetalsolution::new(client, auth);
18620/// // As the method needs a request, you would usually fill it with the desired information
18621/// // into the respective structure. Some of the parts shown here might not be applicable !
18622/// // Values shown here are possibly random and not representative !
18623/// let mut req = ResizeVolumeRequest::default();
18624///
18625/// // You can configure optional parameters by calling the respective setters at will, and
18626/// // execute the final call using `doit()`.
18627/// // Values shown here are possibly random and not representative !
18628/// let result = hub.projects().locations_volumes_resize(req, "volume")
18629/// .doit().await;
18630/// # }
18631/// ```
18632pub struct ProjectLocationVolumeResizeCall<'a, C>
18633where
18634 C: 'a,
18635{
18636 hub: &'a Baremetalsolution<C>,
18637 _request: ResizeVolumeRequest,
18638 _volume: String,
18639 _delegate: Option<&'a mut dyn common::Delegate>,
18640 _additional_params: HashMap<String, String>,
18641 _scopes: BTreeSet<String>,
18642}
18643
18644impl<'a, C> common::CallBuilder for ProjectLocationVolumeResizeCall<'a, C> {}
18645
18646impl<'a, C> ProjectLocationVolumeResizeCall<'a, C>
18647where
18648 C: common::Connector,
18649{
18650 /// Perform the operation you have build so far.
18651 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
18652 use std::borrow::Cow;
18653 use std::io::{Read, Seek};
18654
18655 use common::{url::Params, ToParts};
18656 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18657
18658 let mut dd = common::DefaultDelegate;
18659 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18660 dlg.begin(common::MethodInfo {
18661 id: "baremetalsolution.projects.locations.volumes.resize",
18662 http_method: hyper::Method::POST,
18663 });
18664
18665 for &field in ["alt", "volume"].iter() {
18666 if self._additional_params.contains_key(field) {
18667 dlg.finished(false);
18668 return Err(common::Error::FieldClash(field));
18669 }
18670 }
18671
18672 let mut params = Params::with_capacity(4 + self._additional_params.len());
18673 params.push("volume", self._volume);
18674
18675 params.extend(self._additional_params.iter());
18676
18677 params.push("alt", "json");
18678 let mut url = self.hub._base_url.clone() + "v2/{+volume}:resize";
18679 if self._scopes.is_empty() {
18680 self._scopes
18681 .insert(Scope::CloudPlatform.as_ref().to_string());
18682 }
18683
18684 #[allow(clippy::single_element_loop)]
18685 for &(find_this, param_name) in [("{+volume}", "volume")].iter() {
18686 url = params.uri_replacement(url, param_name, find_this, true);
18687 }
18688 {
18689 let to_remove = ["volume"];
18690 params.remove_params(&to_remove);
18691 }
18692
18693 let url = params.parse_with_url(&url);
18694
18695 let mut json_mime_type = mime::APPLICATION_JSON;
18696 let mut request_value_reader = {
18697 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18698 common::remove_json_null_values(&mut value);
18699 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18700 serde_json::to_writer(&mut dst, &value).unwrap();
18701 dst
18702 };
18703 let request_size = request_value_reader
18704 .seek(std::io::SeekFrom::End(0))
18705 .unwrap();
18706 request_value_reader
18707 .seek(std::io::SeekFrom::Start(0))
18708 .unwrap();
18709
18710 loop {
18711 let token = match self
18712 .hub
18713 .auth
18714 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18715 .await
18716 {
18717 Ok(token) => token,
18718 Err(e) => match dlg.token(e) {
18719 Ok(token) => token,
18720 Err(e) => {
18721 dlg.finished(false);
18722 return Err(common::Error::MissingToken(e));
18723 }
18724 },
18725 };
18726 request_value_reader
18727 .seek(std::io::SeekFrom::Start(0))
18728 .unwrap();
18729 let mut req_result = {
18730 let client = &self.hub.client;
18731 dlg.pre_request();
18732 let mut req_builder = hyper::Request::builder()
18733 .method(hyper::Method::POST)
18734 .uri(url.as_str())
18735 .header(USER_AGENT, self.hub._user_agent.clone());
18736
18737 if let Some(token) = token.as_ref() {
18738 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18739 }
18740
18741 let request = req_builder
18742 .header(CONTENT_TYPE, json_mime_type.to_string())
18743 .header(CONTENT_LENGTH, request_size as u64)
18744 .body(common::to_body(
18745 request_value_reader.get_ref().clone().into(),
18746 ));
18747
18748 client.request(request.unwrap()).await
18749 };
18750
18751 match req_result {
18752 Err(err) => {
18753 if let common::Retry::After(d) = dlg.http_error(&err) {
18754 sleep(d).await;
18755 continue;
18756 }
18757 dlg.finished(false);
18758 return Err(common::Error::HttpError(err));
18759 }
18760 Ok(res) => {
18761 let (mut parts, body) = res.into_parts();
18762 let mut body = common::Body::new(body);
18763 if !parts.status.is_success() {
18764 let bytes = common::to_bytes(body).await.unwrap_or_default();
18765 let error = serde_json::from_str(&common::to_string(&bytes));
18766 let response = common::to_response(parts, bytes.into());
18767
18768 if let common::Retry::After(d) =
18769 dlg.http_failure(&response, error.as_ref().ok())
18770 {
18771 sleep(d).await;
18772 continue;
18773 }
18774
18775 dlg.finished(false);
18776
18777 return Err(match error {
18778 Ok(value) => common::Error::BadRequest(value),
18779 _ => common::Error::Failure(response),
18780 });
18781 }
18782 let response = {
18783 let bytes = common::to_bytes(body).await.unwrap_or_default();
18784 let encoded = common::to_string(&bytes);
18785 match serde_json::from_str(&encoded) {
18786 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18787 Err(error) => {
18788 dlg.response_json_decode_error(&encoded, &error);
18789 return Err(common::Error::JsonDecodeError(
18790 encoded.to_string(),
18791 error,
18792 ));
18793 }
18794 }
18795 };
18796
18797 dlg.finished(true);
18798 return Ok(response);
18799 }
18800 }
18801 }
18802 }
18803
18804 ///
18805 /// Sets the *request* property to the given value.
18806 ///
18807 /// Even though the property as already been set when instantiating this call,
18808 /// we provide this method for API completeness.
18809 pub fn request(
18810 mut self,
18811 new_value: ResizeVolumeRequest,
18812 ) -> ProjectLocationVolumeResizeCall<'a, C> {
18813 self._request = new_value;
18814 self
18815 }
18816 /// Required. Volume to resize.
18817 ///
18818 /// Sets the *volume* path property to the given value.
18819 ///
18820 /// Even though the property as already been set when instantiating this call,
18821 /// we provide this method for API completeness.
18822 pub fn volume(mut self, new_value: &str) -> ProjectLocationVolumeResizeCall<'a, C> {
18823 self._volume = new_value.to_string();
18824 self
18825 }
18826 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18827 /// while executing the actual API request.
18828 ///
18829 /// ````text
18830 /// It should be used to handle progress information, and to implement a certain level of resilience.
18831 /// ````
18832 ///
18833 /// Sets the *delegate* property to the given value.
18834 pub fn delegate(
18835 mut self,
18836 new_value: &'a mut dyn common::Delegate,
18837 ) -> ProjectLocationVolumeResizeCall<'a, C> {
18838 self._delegate = Some(new_value);
18839 self
18840 }
18841
18842 /// Set any additional parameter of the query string used in the request.
18843 /// It should be used to set parameters which are not yet available through their own
18844 /// setters.
18845 ///
18846 /// Please note that this method must not be used to set any of the known parameters
18847 /// which have their own setter method. If done anyway, the request will fail.
18848 ///
18849 /// # Additional Parameters
18850 ///
18851 /// * *$.xgafv* (query-string) - V1 error format.
18852 /// * *access_token* (query-string) - OAuth access token.
18853 /// * *alt* (query-string) - Data format for response.
18854 /// * *callback* (query-string) - JSONP
18855 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18856 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
18857 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18858 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18859 /// * *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.
18860 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18861 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18862 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationVolumeResizeCall<'a, C>
18863 where
18864 T: AsRef<str>,
18865 {
18866 self._additional_params
18867 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18868 self
18869 }
18870
18871 /// Identifies the authorization scope for the method you are building.
18872 ///
18873 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18874 /// [`Scope::CloudPlatform`].
18875 ///
18876 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18877 /// tokens for more than one scope.
18878 ///
18879 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18880 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18881 /// sufficient, a read-write scope will do as well.
18882 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationVolumeResizeCall<'a, C>
18883 where
18884 St: AsRef<str>,
18885 {
18886 self._scopes.insert(String::from(scope.as_ref()));
18887 self
18888 }
18889 /// Identifies the authorization scope(s) for the method you are building.
18890 ///
18891 /// See [`Self::add_scope()`] for details.
18892 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationVolumeResizeCall<'a, C>
18893 where
18894 I: IntoIterator<Item = St>,
18895 St: AsRef<str>,
18896 {
18897 self._scopes
18898 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18899 self
18900 }
18901
18902 /// Removes all scopes, and no default scope will be used either.
18903 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18904 /// for details).
18905 pub fn clear_scopes(mut self) -> ProjectLocationVolumeResizeCall<'a, C> {
18906 self._scopes.clear();
18907 self
18908 }
18909}
18910
18911/// Gets information about a location.
18912///
18913/// A builder for the *locations.get* method supported by a *project* resource.
18914/// It is not used directly, but through a [`ProjectMethods`] instance.
18915///
18916/// # Example
18917///
18918/// Instantiate a resource method builder
18919///
18920/// ```test_harness,no_run
18921/// # extern crate hyper;
18922/// # extern crate hyper_rustls;
18923/// # extern crate google_baremetalsolution2 as baremetalsolution2;
18924/// # async fn dox() {
18925/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18926///
18927/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18928/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18929/// # secret,
18930/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18931/// # ).build().await.unwrap();
18932///
18933/// # let client = hyper_util::client::legacy::Client::builder(
18934/// # hyper_util::rt::TokioExecutor::new()
18935/// # )
18936/// # .build(
18937/// # hyper_rustls::HttpsConnectorBuilder::new()
18938/// # .with_native_roots()
18939/// # .unwrap()
18940/// # .https_or_http()
18941/// # .enable_http1()
18942/// # .build()
18943/// # );
18944/// # let mut hub = Baremetalsolution::new(client, auth);
18945/// // You can configure optional parameters by calling the respective setters at will, and
18946/// // execute the final call using `doit()`.
18947/// // Values shown here are possibly random and not representative !
18948/// let result = hub.projects().locations_get("name")
18949/// .doit().await;
18950/// # }
18951/// ```
18952pub struct ProjectLocationGetCall<'a, C>
18953where
18954 C: 'a,
18955{
18956 hub: &'a Baremetalsolution<C>,
18957 _name: String,
18958 _delegate: Option<&'a mut dyn common::Delegate>,
18959 _additional_params: HashMap<String, String>,
18960 _scopes: BTreeSet<String>,
18961}
18962
18963impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
18964
18965impl<'a, C> ProjectLocationGetCall<'a, C>
18966where
18967 C: common::Connector,
18968{
18969 /// Perform the operation you have build so far.
18970 pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
18971 use std::borrow::Cow;
18972 use std::io::{Read, Seek};
18973
18974 use common::{url::Params, ToParts};
18975 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18976
18977 let mut dd = common::DefaultDelegate;
18978 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18979 dlg.begin(common::MethodInfo {
18980 id: "baremetalsolution.projects.locations.get",
18981 http_method: hyper::Method::GET,
18982 });
18983
18984 for &field in ["alt", "name"].iter() {
18985 if self._additional_params.contains_key(field) {
18986 dlg.finished(false);
18987 return Err(common::Error::FieldClash(field));
18988 }
18989 }
18990
18991 let mut params = Params::with_capacity(3 + self._additional_params.len());
18992 params.push("name", self._name);
18993
18994 params.extend(self._additional_params.iter());
18995
18996 params.push("alt", "json");
18997 let mut url = self.hub._base_url.clone() + "v2/{+name}";
18998 if self._scopes.is_empty() {
18999 self._scopes
19000 .insert(Scope::CloudPlatform.as_ref().to_string());
19001 }
19002
19003 #[allow(clippy::single_element_loop)]
19004 for &(find_this, param_name) in [("{+name}", "name")].iter() {
19005 url = params.uri_replacement(url, param_name, find_this, true);
19006 }
19007 {
19008 let to_remove = ["name"];
19009 params.remove_params(&to_remove);
19010 }
19011
19012 let url = params.parse_with_url(&url);
19013
19014 loop {
19015 let token = match self
19016 .hub
19017 .auth
19018 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19019 .await
19020 {
19021 Ok(token) => token,
19022 Err(e) => match dlg.token(e) {
19023 Ok(token) => token,
19024 Err(e) => {
19025 dlg.finished(false);
19026 return Err(common::Error::MissingToken(e));
19027 }
19028 },
19029 };
19030 let mut req_result = {
19031 let client = &self.hub.client;
19032 dlg.pre_request();
19033 let mut req_builder = hyper::Request::builder()
19034 .method(hyper::Method::GET)
19035 .uri(url.as_str())
19036 .header(USER_AGENT, self.hub._user_agent.clone());
19037
19038 if let Some(token) = token.as_ref() {
19039 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19040 }
19041
19042 let request = req_builder
19043 .header(CONTENT_LENGTH, 0_u64)
19044 .body(common::to_body::<String>(None));
19045
19046 client.request(request.unwrap()).await
19047 };
19048
19049 match req_result {
19050 Err(err) => {
19051 if let common::Retry::After(d) = dlg.http_error(&err) {
19052 sleep(d).await;
19053 continue;
19054 }
19055 dlg.finished(false);
19056 return Err(common::Error::HttpError(err));
19057 }
19058 Ok(res) => {
19059 let (mut parts, body) = res.into_parts();
19060 let mut body = common::Body::new(body);
19061 if !parts.status.is_success() {
19062 let bytes = common::to_bytes(body).await.unwrap_or_default();
19063 let error = serde_json::from_str(&common::to_string(&bytes));
19064 let response = common::to_response(parts, bytes.into());
19065
19066 if let common::Retry::After(d) =
19067 dlg.http_failure(&response, error.as_ref().ok())
19068 {
19069 sleep(d).await;
19070 continue;
19071 }
19072
19073 dlg.finished(false);
19074
19075 return Err(match error {
19076 Ok(value) => common::Error::BadRequest(value),
19077 _ => common::Error::Failure(response),
19078 });
19079 }
19080 let response = {
19081 let bytes = common::to_bytes(body).await.unwrap_or_default();
19082 let encoded = common::to_string(&bytes);
19083 match serde_json::from_str(&encoded) {
19084 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19085 Err(error) => {
19086 dlg.response_json_decode_error(&encoded, &error);
19087 return Err(common::Error::JsonDecodeError(
19088 encoded.to_string(),
19089 error,
19090 ));
19091 }
19092 }
19093 };
19094
19095 dlg.finished(true);
19096 return Ok(response);
19097 }
19098 }
19099 }
19100 }
19101
19102 /// Resource name for the location.
19103 ///
19104 /// Sets the *name* path property to the given value.
19105 ///
19106 /// Even though the property as already been set when instantiating this call,
19107 /// we provide this method for API completeness.
19108 pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
19109 self._name = new_value.to_string();
19110 self
19111 }
19112 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19113 /// while executing the actual API request.
19114 ///
19115 /// ````text
19116 /// It should be used to handle progress information, and to implement a certain level of resilience.
19117 /// ````
19118 ///
19119 /// Sets the *delegate* property to the given value.
19120 pub fn delegate(
19121 mut self,
19122 new_value: &'a mut dyn common::Delegate,
19123 ) -> ProjectLocationGetCall<'a, C> {
19124 self._delegate = Some(new_value);
19125 self
19126 }
19127
19128 /// Set any additional parameter of the query string used in the request.
19129 /// It should be used to set parameters which are not yet available through their own
19130 /// setters.
19131 ///
19132 /// Please note that this method must not be used to set any of the known parameters
19133 /// which have their own setter method. If done anyway, the request will fail.
19134 ///
19135 /// # Additional Parameters
19136 ///
19137 /// * *$.xgafv* (query-string) - V1 error format.
19138 /// * *access_token* (query-string) - OAuth access token.
19139 /// * *alt* (query-string) - Data format for response.
19140 /// * *callback* (query-string) - JSONP
19141 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19142 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
19143 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19144 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19145 /// * *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.
19146 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19147 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19148 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
19149 where
19150 T: AsRef<str>,
19151 {
19152 self._additional_params
19153 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19154 self
19155 }
19156
19157 /// Identifies the authorization scope for the method you are building.
19158 ///
19159 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19160 /// [`Scope::CloudPlatform`].
19161 ///
19162 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19163 /// tokens for more than one scope.
19164 ///
19165 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19166 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19167 /// sufficient, a read-write scope will do as well.
19168 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
19169 where
19170 St: AsRef<str>,
19171 {
19172 self._scopes.insert(String::from(scope.as_ref()));
19173 self
19174 }
19175 /// Identifies the authorization scope(s) for the method you are building.
19176 ///
19177 /// See [`Self::add_scope()`] for details.
19178 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
19179 where
19180 I: IntoIterator<Item = St>,
19181 St: AsRef<str>,
19182 {
19183 self._scopes
19184 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19185 self
19186 }
19187
19188 /// Removes all scopes, and no default scope will be used either.
19189 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19190 /// for details).
19191 pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
19192 self._scopes.clear();
19193 self
19194 }
19195}
19196
19197/// Lists information about the supported locations for this service.
19198///
19199/// A builder for the *locations.list* method supported by a *project* resource.
19200/// It is not used directly, but through a [`ProjectMethods`] instance.
19201///
19202/// # Example
19203///
19204/// Instantiate a resource method builder
19205///
19206/// ```test_harness,no_run
19207/// # extern crate hyper;
19208/// # extern crate hyper_rustls;
19209/// # extern crate google_baremetalsolution2 as baremetalsolution2;
19210/// # async fn dox() {
19211/// # use baremetalsolution2::{Baremetalsolution, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19212///
19213/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19214/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19215/// # secret,
19216/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19217/// # ).build().await.unwrap();
19218///
19219/// # let client = hyper_util::client::legacy::Client::builder(
19220/// # hyper_util::rt::TokioExecutor::new()
19221/// # )
19222/// # .build(
19223/// # hyper_rustls::HttpsConnectorBuilder::new()
19224/// # .with_native_roots()
19225/// # .unwrap()
19226/// # .https_or_http()
19227/// # .enable_http1()
19228/// # .build()
19229/// # );
19230/// # let mut hub = Baremetalsolution::new(client, auth);
19231/// // You can configure optional parameters by calling the respective setters at will, and
19232/// // execute the final call using `doit()`.
19233/// // Values shown here are possibly random and not representative !
19234/// let result = hub.projects().locations_list("name")
19235/// .page_token("erat")
19236/// .page_size(-96)
19237/// .filter("amet.")
19238/// .doit().await;
19239/// # }
19240/// ```
19241pub struct ProjectLocationListCall<'a, C>
19242where
19243 C: 'a,
19244{
19245 hub: &'a Baremetalsolution<C>,
19246 _name: String,
19247 _page_token: Option<String>,
19248 _page_size: Option<i32>,
19249 _filter: Option<String>,
19250 _delegate: Option<&'a mut dyn common::Delegate>,
19251 _additional_params: HashMap<String, String>,
19252 _scopes: BTreeSet<String>,
19253}
19254
19255impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
19256
19257impl<'a, C> ProjectLocationListCall<'a, C>
19258where
19259 C: common::Connector,
19260{
19261 /// Perform the operation you have build so far.
19262 pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
19263 use std::borrow::Cow;
19264 use std::io::{Read, Seek};
19265
19266 use common::{url::Params, ToParts};
19267 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19268
19269 let mut dd = common::DefaultDelegate;
19270 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19271 dlg.begin(common::MethodInfo {
19272 id: "baremetalsolution.projects.locations.list",
19273 http_method: hyper::Method::GET,
19274 });
19275
19276 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
19277 if self._additional_params.contains_key(field) {
19278 dlg.finished(false);
19279 return Err(common::Error::FieldClash(field));
19280 }
19281 }
19282
19283 let mut params = Params::with_capacity(6 + self._additional_params.len());
19284 params.push("name", self._name);
19285 if let Some(value) = self._page_token.as_ref() {
19286 params.push("pageToken", value);
19287 }
19288 if let Some(value) = self._page_size.as_ref() {
19289 params.push("pageSize", value.to_string());
19290 }
19291 if let Some(value) = self._filter.as_ref() {
19292 params.push("filter", value);
19293 }
19294
19295 params.extend(self._additional_params.iter());
19296
19297 params.push("alt", "json");
19298 let mut url = self.hub._base_url.clone() + "v2/{+name}/locations";
19299 if self._scopes.is_empty() {
19300 self._scopes
19301 .insert(Scope::CloudPlatform.as_ref().to_string());
19302 }
19303
19304 #[allow(clippy::single_element_loop)]
19305 for &(find_this, param_name) in [("{+name}", "name")].iter() {
19306 url = params.uri_replacement(url, param_name, find_this, true);
19307 }
19308 {
19309 let to_remove = ["name"];
19310 params.remove_params(&to_remove);
19311 }
19312
19313 let url = params.parse_with_url(&url);
19314
19315 loop {
19316 let token = match self
19317 .hub
19318 .auth
19319 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19320 .await
19321 {
19322 Ok(token) => token,
19323 Err(e) => match dlg.token(e) {
19324 Ok(token) => token,
19325 Err(e) => {
19326 dlg.finished(false);
19327 return Err(common::Error::MissingToken(e));
19328 }
19329 },
19330 };
19331 let mut req_result = {
19332 let client = &self.hub.client;
19333 dlg.pre_request();
19334 let mut req_builder = hyper::Request::builder()
19335 .method(hyper::Method::GET)
19336 .uri(url.as_str())
19337 .header(USER_AGENT, self.hub._user_agent.clone());
19338
19339 if let Some(token) = token.as_ref() {
19340 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19341 }
19342
19343 let request = req_builder
19344 .header(CONTENT_LENGTH, 0_u64)
19345 .body(common::to_body::<String>(None));
19346
19347 client.request(request.unwrap()).await
19348 };
19349
19350 match req_result {
19351 Err(err) => {
19352 if let common::Retry::After(d) = dlg.http_error(&err) {
19353 sleep(d).await;
19354 continue;
19355 }
19356 dlg.finished(false);
19357 return Err(common::Error::HttpError(err));
19358 }
19359 Ok(res) => {
19360 let (mut parts, body) = res.into_parts();
19361 let mut body = common::Body::new(body);
19362 if !parts.status.is_success() {
19363 let bytes = common::to_bytes(body).await.unwrap_or_default();
19364 let error = serde_json::from_str(&common::to_string(&bytes));
19365 let response = common::to_response(parts, bytes.into());
19366
19367 if let common::Retry::After(d) =
19368 dlg.http_failure(&response, error.as_ref().ok())
19369 {
19370 sleep(d).await;
19371 continue;
19372 }
19373
19374 dlg.finished(false);
19375
19376 return Err(match error {
19377 Ok(value) => common::Error::BadRequest(value),
19378 _ => common::Error::Failure(response),
19379 });
19380 }
19381 let response = {
19382 let bytes = common::to_bytes(body).await.unwrap_or_default();
19383 let encoded = common::to_string(&bytes);
19384 match serde_json::from_str(&encoded) {
19385 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19386 Err(error) => {
19387 dlg.response_json_decode_error(&encoded, &error);
19388 return Err(common::Error::JsonDecodeError(
19389 encoded.to_string(),
19390 error,
19391 ));
19392 }
19393 }
19394 };
19395
19396 dlg.finished(true);
19397 return Ok(response);
19398 }
19399 }
19400 }
19401 }
19402
19403 /// The resource that owns the locations collection, if applicable.
19404 ///
19405 /// Sets the *name* path property to the given value.
19406 ///
19407 /// Even though the property as already been set when instantiating this call,
19408 /// we provide this method for API completeness.
19409 pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
19410 self._name = new_value.to_string();
19411 self
19412 }
19413 /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
19414 ///
19415 /// Sets the *page token* query property to the given value.
19416 pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
19417 self._page_token = Some(new_value.to_string());
19418 self
19419 }
19420 /// The maximum number of results to return. If not set, the service selects a default.
19421 ///
19422 /// Sets the *page size* query property to the given value.
19423 pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
19424 self._page_size = Some(new_value);
19425 self
19426 }
19427 /// 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).
19428 ///
19429 /// Sets the *filter* query property to the given value.
19430 pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
19431 self._filter = Some(new_value.to_string());
19432 self
19433 }
19434 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19435 /// while executing the actual API request.
19436 ///
19437 /// ````text
19438 /// It should be used to handle progress information, and to implement a certain level of resilience.
19439 /// ````
19440 ///
19441 /// Sets the *delegate* property to the given value.
19442 pub fn delegate(
19443 mut self,
19444 new_value: &'a mut dyn common::Delegate,
19445 ) -> ProjectLocationListCall<'a, C> {
19446 self._delegate = Some(new_value);
19447 self
19448 }
19449
19450 /// Set any additional parameter of the query string used in the request.
19451 /// It should be used to set parameters which are not yet available through their own
19452 /// setters.
19453 ///
19454 /// Please note that this method must not be used to set any of the known parameters
19455 /// which have their own setter method. If done anyway, the request will fail.
19456 ///
19457 /// # Additional Parameters
19458 ///
19459 /// * *$.xgafv* (query-string) - V1 error format.
19460 /// * *access_token* (query-string) - OAuth access token.
19461 /// * *alt* (query-string) - Data format for response.
19462 /// * *callback* (query-string) - JSONP
19463 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19464 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
19465 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19466 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19467 /// * *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.
19468 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19469 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19470 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
19471 where
19472 T: AsRef<str>,
19473 {
19474 self._additional_params
19475 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19476 self
19477 }
19478
19479 /// Identifies the authorization scope for the method you are building.
19480 ///
19481 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19482 /// [`Scope::CloudPlatform`].
19483 ///
19484 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19485 /// tokens for more than one scope.
19486 ///
19487 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19488 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19489 /// sufficient, a read-write scope will do as well.
19490 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
19491 where
19492 St: AsRef<str>,
19493 {
19494 self._scopes.insert(String::from(scope.as_ref()));
19495 self
19496 }
19497 /// Identifies the authorization scope(s) for the method you are building.
19498 ///
19499 /// See [`Self::add_scope()`] for details.
19500 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
19501 where
19502 I: IntoIterator<Item = St>,
19503 St: AsRef<str>,
19504 {
19505 self._scopes
19506 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19507 self
19508 }
19509
19510 /// Removes all scopes, and no default scope will be used either.
19511 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19512 /// for details).
19513 pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
19514 self._scopes.clear();
19515 self
19516 }
19517}