google_vmmigration1/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 VMMigrationService 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_vmmigration1 as vmmigration1;
49/// use vmmigration1::api::Group;
50/// use vmmigration1::{Result, Error};
51/// # async fn dox() {
52/// use vmmigration1::{VMMigrationService, 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 = VMMigrationService::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 = Group::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_groups_create(req, "parent")
88/// .request_id("sed")
89/// .group_id("amet.")
90/// .doit().await;
91///
92/// match result {
93/// Err(e) => match e {
94/// // The Error enum provides details about what exactly happened.
95/// // You can also just use its `Debug`, `Display` or `Error` traits
96/// Error::HttpError(_)
97/// |Error::Io(_)
98/// |Error::MissingAPIKey
99/// |Error::MissingToken(_)
100/// |Error::Cancelled
101/// |Error::UploadSizeLimitExceeded(_, _)
102/// |Error::Failure(_)
103/// |Error::BadRequest(_)
104/// |Error::FieldClash(_)
105/// |Error::JsonDecodeError(_, _) => println!("{}", e),
106/// },
107/// Ok(res) => println!("Success: {:?}", res),
108/// }
109/// # }
110/// ```
111#[derive(Clone)]
112pub struct VMMigrationService<C> {
113 pub client: common::Client<C>,
114 pub auth: Box<dyn common::GetToken>,
115 _user_agent: String,
116 _base_url: String,
117 _root_url: String,
118}
119
120impl<C> common::Hub for VMMigrationService<C> {}
121
122impl<'a, C> VMMigrationService<C> {
123 pub fn new<A: 'static + common::GetToken>(
124 client: common::Client<C>,
125 auth: A,
126 ) -> VMMigrationService<C> {
127 VMMigrationService {
128 client,
129 auth: Box::new(auth),
130 _user_agent: "google-api-rust-client/6.0.0".to_string(),
131 _base_url: "https://vmmigration.googleapis.com/".to_string(),
132 _root_url: "https://vmmigration.googleapis.com/".to_string(),
133 }
134 }
135
136 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
137 ProjectMethods { hub: self }
138 }
139
140 /// Set the user-agent header field to use in all requests to the server.
141 /// It defaults to `google-api-rust-client/6.0.0`.
142 ///
143 /// Returns the previously set user-agent.
144 pub fn user_agent(&mut self, agent_name: String) -> String {
145 std::mem::replace(&mut self._user_agent, agent_name)
146 }
147
148 /// Set the base url to use in all requests to the server.
149 /// It defaults to `https://vmmigration.googleapis.com/`.
150 ///
151 /// Returns the previously set base url.
152 pub fn base_url(&mut self, new_base_url: String) -> String {
153 std::mem::replace(&mut self._base_url, new_base_url)
154 }
155
156 /// Set the root url to use in all requests to the server.
157 /// It defaults to `https://vmmigration.googleapis.com/`.
158 ///
159 /// Returns the previously set root url.
160 pub fn root_url(&mut self, new_root_url: String) -> String {
161 std::mem::replace(&mut self._root_url, new_root_url)
162 }
163}
164
165// ############
166// SCHEMAS ###
167// ##########
168/// Message describing AWS Credentials using access key id and secret.
169///
170/// This type is not used in any activity, and only used as *part* of another schema.
171///
172#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
173#[serde_with::serde_as]
174#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
175pub struct AccessKeyCredentials {
176 /// AWS access key ID.
177 #[serde(rename = "accessKeyId")]
178 pub access_key_id: Option<String>,
179 /// Input only. AWS secret access key.
180 #[serde(rename = "secretAccessKey")]
181 pub secret_access_key: Option<String>,
182 /// Input only. AWS session token. Used only when AWS security token service (STS) is responsible for creating the temporary credentials.
183 #[serde(rename = "sessionToken")]
184 pub session_token: Option<String>,
185}
186
187impl common::Part for AccessKeyCredentials {}
188
189/// AdaptingOSStep contains specific step details.
190///
191/// This type is not used in any activity, and only used as *part* of another schema.
192///
193#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
194#[serde_with::serde_as]
195#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
196pub struct AdaptingOSStep {
197 _never_set: Option<bool>,
198}
199
200impl common::Part for AdaptingOSStep {}
201
202/// Request message for ‘AddGroupMigration’ request.
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 groups add group migration projects](ProjectLocationGroupAddGroupMigrationCall) (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 AddGroupMigrationRequest {
214 /// The full path name of the MigratingVm to add.
215 #[serde(rename = "migratingVm")]
216 pub migrating_vm: Option<String>,
217}
218
219impl common::RequestValue for AddGroupMigrationRequest {}
220
221/// Describes an appliance version.
222///
223/// This type is not used in any activity, and only used as *part* of another schema.
224///
225#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
226#[serde_with::serde_as]
227#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
228pub struct ApplianceVersion {
229 /// Determine whether it's critical to upgrade the appliance to this version.
230 pub critical: Option<bool>,
231 /// Link to a page that contains the version release notes.
232 #[serde(rename = "releaseNotesUri")]
233 pub release_notes_uri: Option<String>,
234 /// A link for downloading the version.
235 pub uri: Option<String>,
236 /// The appliance version.
237 pub version: Option<String>,
238}
239
240impl common::Part for ApplianceVersion {}
241
242/// AppliedLicense holds the license data returned by adaptation module report.
243///
244/// This type is not used in any activity, and only used as *part* of another schema.
245///
246#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
247#[serde_with::serde_as]
248#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
249pub struct AppliedLicense {
250 /// The OS license returned from the adaptation module's report.
251 #[serde(rename = "osLicense")]
252 pub os_license: Option<String>,
253 /// The license type that was used in OS adaptation.
254 #[serde(rename = "type")]
255 pub type_: Option<String>,
256}
257
258impl common::Part for AppliedLicense {}
259
260/// Holds informatiom about the available versions for upgrade.
261///
262/// This type is not used in any activity, and only used as *part* of another schema.
263///
264#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
265#[serde_with::serde_as]
266#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
267pub struct AvailableUpdates {
268 /// The latest version for in place update. The current appliance can be updated to this version using the API or m4c CLI.
269 #[serde(rename = "inPlaceUpdate")]
270 pub in_place_update: Option<ApplianceVersion>,
271 /// The newest deployable version of the appliance. The current appliance can't be updated into this version, and the owner must manually deploy this OVA to a new appliance.
272 #[serde(rename = "newDeployableAppliance")]
273 pub new_deployable_appliance: Option<ApplianceVersion>,
274}
275
276impl common::Part for AvailableUpdates {}
277
278/// The details of an AWS instance disk.
279///
280/// This type is not used in any activity, and only used as *part* of another schema.
281///
282#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
283#[serde_with::serde_as]
284#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
285pub struct AwsDiskDetails {
286 /// Output only. The ordinal number of the disk.
287 #[serde(rename = "diskNumber")]
288 pub disk_number: Option<i32>,
289 /// Output only. Size in GB.
290 #[serde(rename = "sizeGb")]
291 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
292 pub size_gb: Option<i64>,
293 /// Output only. AWS volume ID.
294 #[serde(rename = "volumeId")]
295 pub volume_id: Option<String>,
296}
297
298impl common::Part for AwsDiskDetails {}
299
300/// AwsSecurityGroup describes a security group of an AWS VM.
301///
302/// This type is not used in any activity, and only used as *part* of another schema.
303///
304#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
305#[serde_with::serde_as]
306#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
307pub struct AwsSecurityGroup {
308 /// The AWS security group id.
309 pub id: Option<String>,
310 /// The AWS security group name.
311 pub name: Option<String>,
312}
313
314impl common::Part for AwsSecurityGroup {}
315
316/// AwsSourceDetails message describes a specific source details for the AWS source type.
317///
318/// This type is not used in any activity, and only used as *part* of another schema.
319///
320#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
321#[serde_with::serde_as]
322#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
323pub struct AwsSourceDetails {
324 /// AWS Credentials using access key id and secret.
325 #[serde(rename = "accessKeyCreds")]
326 pub access_key_creds: Option<AccessKeyCredentials>,
327 /// Immutable. The AWS region that the source VMs will be migrated from.
328 #[serde(rename = "awsRegion")]
329 pub aws_region: Option<String>,
330 /// Output only. Provides details on the state of the Source in case of an error.
331 pub error: Option<Status>,
332 /// AWS security group names to limit the scope of the source inventory.
333 #[serde(rename = "inventorySecurityGroupNames")]
334 pub inventory_security_group_names: Option<Vec<String>>,
335 /// AWS resource tags to limit the scope of the source inventory.
336 #[serde(rename = "inventoryTagList")]
337 pub inventory_tag_list: Option<Vec<Tag>>,
338 /// User specified tags to add to every M2VM generated resource in AWS. These tags will be set in addition to the default tags that are set as part of the migration process. The tags must not begin with the reserved prefix `m2vm`.
339 #[serde(rename = "migrationResourcesUserTags")]
340 pub migration_resources_user_tags: Option<HashMap<String, String>>,
341 /// Output only. Information about the network coniguration of the source. Only gatherred upon request.
342 #[serde(rename = "networkInsights")]
343 pub network_insights: Option<NetworkInsights>,
344 /// Output only. The source's public IP. All communication initiated by this source will originate from this IP.
345 #[serde(rename = "publicIp")]
346 pub public_ip: Option<String>,
347 /// Output only. State of the source as determined by the health check.
348 pub state: Option<String>,
349}
350
351impl common::Part for AwsSourceDetails {}
352
353/// Represent the source AWS VM details.
354///
355/// This type is not used in any activity, and only used as *part* of another schema.
356///
357#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
358#[serde_with::serde_as]
359#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
360pub struct AwsSourceVmDetails {
361 /// Output only. The total size of the disks being migrated in bytes.
362 #[serde(rename = "committedStorageBytes")]
363 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
364 pub committed_storage_bytes: Option<i64>,
365 /// Output only. The disks attached to the source VM.
366 pub disks: Option<Vec<AwsDiskDetails>>,
367 /// Output only. The firmware type of the source VM.
368 pub firmware: Option<String>,
369 /// Output only. Information about VM capabilities needed for some Compute Engine features.
370 #[serde(rename = "vmCapabilitiesInfo")]
371 pub vm_capabilities_info: Option<VmCapabilities>,
372}
373
374impl common::Part for AwsSourceVmDetails {}
375
376/// AwsVmDetails describes a VM in AWS.
377///
378/// This type is not used in any activity, and only used as *part* of another schema.
379///
380#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
381#[serde_with::serde_as]
382#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
383pub struct AwsVmDetails {
384 /// The CPU architecture.
385 pub architecture: Option<String>,
386 /// The VM Boot Option.
387 #[serde(rename = "bootOption")]
388 pub boot_option: Option<String>,
389 /// The total size of the storage allocated to the VM in MB.
390 #[serde(rename = "committedStorageMb")]
391 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
392 pub committed_storage_mb: Option<i64>,
393 /// The number of cpus the VM has.
394 #[serde(rename = "cpuCount")]
395 pub cpu_count: Option<i32>,
396 /// The number of disks the VM has.
397 #[serde(rename = "diskCount")]
398 pub disk_count: Option<i32>,
399 /// The display name of the VM. Note that this value is not necessarily unique.
400 #[serde(rename = "displayName")]
401 pub display_name: Option<String>,
402 /// The instance type of the VM.
403 #[serde(rename = "instanceType")]
404 pub instance_type: Option<String>,
405 /// The memory size of the VM in MB.
406 #[serde(rename = "memoryMb")]
407 pub memory_mb: Option<i32>,
408 /// The VM's OS.
409 #[serde(rename = "osDescription")]
410 pub os_description: Option<String>,
411 /// Output only. The power state of the VM at the moment list was taken.
412 #[serde(rename = "powerState")]
413 pub power_state: Option<String>,
414 /// The security groups the VM belongs to.
415 #[serde(rename = "securityGroups")]
416 pub security_groups: Option<Vec<AwsSecurityGroup>>,
417 /// The descriptive name of the AWS's source this VM is connected to.
418 #[serde(rename = "sourceDescription")]
419 pub source_description: Option<String>,
420 /// The id of the AWS's source this VM is connected to.
421 #[serde(rename = "sourceId")]
422 pub source_id: Option<String>,
423 /// The tags of the VM.
424 pub tags: Option<HashMap<String, String>>,
425 /// The virtualization type.
426 #[serde(rename = "virtualizationType")]
427 pub virtualization_type: Option<String>,
428 /// The VM ID in AWS.
429 #[serde(rename = "vmId")]
430 pub vm_id: Option<String>,
431 /// The VPC ID the VM belongs to.
432 #[serde(rename = "vpcId")]
433 pub vpc_id: Option<String>,
434 /// The AWS zone of the VM.
435 pub zone: Option<String>,
436}
437
438impl common::Part for AwsVmDetails {}
439
440/// AWSVmsDetails describes VMs in AWS.
441///
442/// This type is not used in any activity, and only used as *part* of another schema.
443///
444#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
445#[serde_with::serde_as]
446#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
447pub struct AwsVmsDetails {
448 /// The details of the AWS VMs.
449 pub details: Option<Vec<AwsVmDetails>>,
450}
451
452impl common::Part for AwsVmsDetails {}
453
454/// The details of an Azure VM disk.
455///
456/// This type is not used in any activity, and only used as *part* of another schema.
457///
458#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
459#[serde_with::serde_as]
460#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
461pub struct AzureDiskDetails {
462 /// Output only. Azure disk ID.
463 #[serde(rename = "diskId")]
464 pub disk_id: Option<String>,
465 /// Output only. The ordinal number of the disk.
466 #[serde(rename = "diskNumber")]
467 pub disk_number: Option<i32>,
468 /// Output only. Size in GB.
469 #[serde(rename = "sizeGb")]
470 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
471 pub size_gb: Option<i64>,
472}
473
474impl common::Part for AzureDiskDetails {}
475
476/// AzureSourceDetails message describes a specific source details for the Azure source type.
477///
478/// This type is not used in any activity, and only used as *part* of another schema.
479///
480#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
481#[serde_with::serde_as]
482#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
483pub struct AzureSourceDetails {
484 /// Immutable. The Azure location (region) that the source VMs will be migrated from.
485 #[serde(rename = "azureLocation")]
486 pub azure_location: Option<String>,
487 /// Azure Credentials using tenant ID, client ID and secret.
488 #[serde(rename = "clientSecretCreds")]
489 pub client_secret_creds: Option<ClientSecretCredentials>,
490 /// Output only. Provides details on the state of the Source in case of an error.
491 pub error: Option<Status>,
492 /// User specified tags to add to every M2VM generated resource in Azure. These tags will be set in addition to the default tags that are set as part of the migration process. The tags must not begin with the reserved prefix `m4ce` or `m2vm`.
493 #[serde(rename = "migrationResourcesUserTags")]
494 pub migration_resources_user_tags: Option<HashMap<String, String>>,
495 /// Output only. The ID of the Azure resource group that contains all resources related to the migration process of this source.
496 #[serde(rename = "resourceGroupId")]
497 pub resource_group_id: Option<String>,
498 /// Output only. State of the source as determined by the health check.
499 pub state: Option<String>,
500 /// Immutable. Azure subscription ID.
501 #[serde(rename = "subscriptionId")]
502 pub subscription_id: Option<String>,
503}
504
505impl common::Part for AzureSourceDetails {}
506
507/// Represent the source Azure VM details.
508///
509/// This type is not used in any activity, and only used as *part* of another schema.
510///
511#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
512#[serde_with::serde_as]
513#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
514pub struct AzureSourceVmDetails {
515 /// Output only. The total size of the disks being migrated in bytes.
516 #[serde(rename = "committedStorageBytes")]
517 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
518 pub committed_storage_bytes: Option<i64>,
519 /// Output only. The disks attached to the source VM.
520 pub disks: Option<Vec<AzureDiskDetails>>,
521 /// Output only. The firmware type of the source VM.
522 pub firmware: Option<String>,
523 /// Output only. Information about VM capabilities needed for some Compute Engine features.
524 #[serde(rename = "vmCapabilitiesInfo")]
525 pub vm_capabilities_info: Option<VmCapabilities>,
526}
527
528impl common::Part for AzureSourceVmDetails {}
529
530/// AzureVmDetails describes a VM in Azure.
531///
532/// This type is not used in any activity, and only used as *part* of another schema.
533///
534#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
535#[serde_with::serde_as]
536#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
537pub struct AzureVmDetails {
538 /// The VM Boot Option.
539 #[serde(rename = "bootOption")]
540 pub boot_option: Option<String>,
541 /// The total size of the storage allocated to the VM in MB.
542 #[serde(rename = "committedStorageMb")]
543 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
544 pub committed_storage_mb: Option<i64>,
545 /// The VM's ComputerName.
546 #[serde(rename = "computerName")]
547 pub computer_name: Option<String>,
548 /// The number of cpus the VM has.
549 #[serde(rename = "cpuCount")]
550 pub cpu_count: Option<i32>,
551 /// The number of disks the VM has, including OS disk.
552 #[serde(rename = "diskCount")]
553 pub disk_count: Option<i32>,
554 /// Description of the data disks.
555 pub disks: Option<Vec<Disk>>,
556 /// The memory size of the VM in MB.
557 #[serde(rename = "memoryMb")]
558 pub memory_mb: Option<i32>,
559 /// Description of the OS.
560 #[serde(rename = "osDescription")]
561 pub os_description: Option<OSDescription>,
562 /// Description of the OS disk.
563 #[serde(rename = "osDisk")]
564 pub os_disk: Option<OSDisk>,
565 /// The power state of the VM at the moment list was taken.
566 #[serde(rename = "powerState")]
567 pub power_state: Option<String>,
568 /// The tags of the VM.
569 pub tags: Option<HashMap<String, String>>,
570 /// The VM full path in Azure.
571 #[serde(rename = "vmId")]
572 pub vm_id: Option<String>,
573 /// VM size as configured in Azure. Determines the VM's hardware spec.
574 #[serde(rename = "vmSize")]
575 pub vm_size: Option<String>,
576}
577
578impl common::Part for AzureVmDetails {}
579
580/// AzureVmsDetails describes VMs in Azure.
581///
582/// This type is not used in any activity, and only used as *part* of another schema.
583///
584#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
585#[serde_with::serde_as]
586#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
587pub struct AzureVmsDetails {
588 /// The details of the Azure VMs.
589 pub details: Option<Vec<AzureVmDetails>>,
590}
591
592impl common::Part for AzureVmsDetails {}
593
594/// BootDiskDefaults hold information about the boot disk of a VM.
595///
596/// This type is not used in any activity, and only used as *part* of another schema.
597///
598#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
599#[serde_with::serde_as]
600#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
601pub struct BootDiskDefaults {
602 /// Optional. Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* tree of a Linux operating system running within the instance. If not specified, the server chooses a default device name to apply to this disk, in the form persistent-disk-x, where x is a number assigned by Google Compute Engine. This field is only applicable for persistent disks.
603 #[serde(rename = "deviceName")]
604 pub device_name: Option<String>,
605 /// Optional. The name of the disk.
606 #[serde(rename = "diskName")]
607 pub disk_name: Option<String>,
608 /// Optional. The type of disk provisioning to use for the VM.
609 #[serde(rename = "diskType")]
610 pub disk_type: Option<String>,
611 /// Optional. The encryption to apply to the boot disk.
612 pub encryption: Option<Encryption>,
613 /// The image to use when creating the disk.
614 pub image: Option<DiskImageDefaults>,
615}
616
617impl common::Part for BootDiskDefaults {}
618
619/// Request message for ‘CancelCloneJob’ request.
620///
621/// # Activities
622///
623/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
624/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
625///
626/// * [locations sources migrating vms clone jobs cancel projects](ProjectLocationSourceMigratingVmCloneJobCancelCall) (request)
627#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
628#[serde_with::serde_as]
629#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
630pub struct CancelCloneJobRequest {
631 _never_set: Option<bool>,
632}
633
634impl common::RequestValue for CancelCloneJobRequest {}
635
636/// Request message for ‘CancelCutoverJob’ request.
637///
638/// # Activities
639///
640/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
641/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
642///
643/// * [locations sources migrating vms cutover jobs cancel projects](ProjectLocationSourceMigratingVmCutoverJobCancelCall) (request)
644#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
645#[serde_with::serde_as]
646#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
647pub struct CancelCutoverJobRequest {
648 _never_set: Option<bool>,
649}
650
651impl common::RequestValue for CancelCutoverJobRequest {}
652
653/// Request message for ‘CancelImageImportJob’ request.
654///
655/// # Activities
656///
657/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
658/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
659///
660/// * [locations image imports image import jobs cancel projects](ProjectLocationImageImportImageImportJobCancelCall) (request)
661#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
662#[serde_with::serde_as]
663#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
664pub struct CancelImageImportJobRequest {
665 _never_set: Option<bool>,
666}
667
668impl common::RequestValue for CancelImageImportJobRequest {}
669
670/// The request message for Operations.CancelOperation.
671///
672/// # Activities
673///
674/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
675/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
676///
677/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (request)
678#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
679#[serde_with::serde_as]
680#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
681pub struct CancelOperationRequest {
682 _never_set: Option<bool>,
683}
684
685impl common::RequestValue for CancelOperationRequest {}
686
687/// Message describing Azure Credentials using tenant ID, client ID and secret.
688///
689/// This type is not used in any activity, and only used as *part* of another schema.
690///
691#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
692#[serde_with::serde_as]
693#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
694pub struct ClientSecretCredentials {
695 /// Azure client ID.
696 #[serde(rename = "clientId")]
697 pub client_id: Option<String>,
698 /// Input only. Azure client secret.
699 #[serde(rename = "clientSecret")]
700 pub client_secret: Option<String>,
701 /// Azure tenant ID.
702 #[serde(rename = "tenantId")]
703 pub tenant_id: Option<String>,
704}
705
706impl common::Part for ClientSecretCredentials {}
707
708/// CloneJob describes the process of creating a clone of a MigratingVM to the requested target based on the latest successful uploaded snapshots. While the migration cycles of a MigratingVm take place, it is possible to verify the uploaded VM can be started in the cloud, by creating a clone. The clone can be created without any downtime, and it is created using the latest snapshots which are already in the cloud. The cloneJob is only responsible for its work, not its products, which means once it is finished, it will never touch the instance it created. It will only delete it in case of the CloneJob being cancelled or upon failure to clone.
709///
710/// # Activities
711///
712/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
713/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
714///
715/// * [locations sources migrating vms clone jobs create projects](ProjectLocationSourceMigratingVmCloneJobCreateCall) (request)
716/// * [locations sources migrating vms clone jobs get projects](ProjectLocationSourceMigratingVmCloneJobGetCall) (response)
717#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
718#[serde_with::serde_as]
719#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
720pub struct CloneJob {
721 /// Output only. Details of the target Persistent Disks in Compute Engine.
722 #[serde(rename = "computeEngineDisksTargetDetails")]
723 pub compute_engine_disks_target_details: Option<ComputeEngineDisksTargetDetails>,
724 /// Output only. Details of the target VM in Compute Engine.
725 #[serde(rename = "computeEngineTargetDetails")]
726 pub compute_engine_target_details: Option<ComputeEngineTargetDetails>,
727 /// Output only. The time the clone job was created (as an API call, not when it was actually created in the target).
728 #[serde(rename = "createTime")]
729 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
730 /// Output only. The time the clone job was ended.
731 #[serde(rename = "endTime")]
732 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
733 /// Output only. Provides details for the errors that led to the Clone Job's state.
734 pub error: Option<Status>,
735 /// Output only. The name of the clone.
736 pub name: Option<String>,
737 /// Output only. State of the clone job.
738 pub state: Option<String>,
739 /// Output only. The time the state was last updated.
740 #[serde(rename = "stateTime")]
741 pub state_time: Option<chrono::DateTime<chrono::offset::Utc>>,
742 /// Output only. The clone steps list representing its progress.
743 pub steps: Option<Vec<CloneStep>>,
744}
745
746impl common::RequestValue for CloneJob {}
747impl common::ResponseResult for CloneJob {}
748
749/// CloneStep holds information about the clone step progress.
750///
751/// This type is not used in any activity, and only used as *part* of another schema.
752///
753#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
754#[serde_with::serde_as]
755#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
756pub struct CloneStep {
757 /// Adapting OS step.
758 #[serde(rename = "adaptingOs")]
759 pub adapting_os: Option<AdaptingOSStep>,
760 /// The time the step has ended.
761 #[serde(rename = "endTime")]
762 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
763 /// Instantiating migrated VM step.
764 #[serde(rename = "instantiatingMigratedVm")]
765 pub instantiating_migrated_vm: Option<InstantiatingMigratedVMStep>,
766 /// Preparing VM disks step.
767 #[serde(rename = "preparingVmDisks")]
768 pub preparing_vm_disks: Option<PreparingVMDisksStep>,
769 /// The time the step has started.
770 #[serde(rename = "startTime")]
771 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
772}
773
774impl common::Part for CloneStep {}
775
776/// ComputeEngineDisksTargetDefaults is a collection of details for creating Persistent Disks in a target Compute Engine project.
777///
778/// This type is not used in any activity, and only used as *part* of another schema.
779///
780#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
781#[serde_with::serde_as]
782#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
783pub struct ComputeEngineDisksTargetDefaults {
784 /// The details of each Persistent Disk to create.
785 pub disks: Option<Vec<PersistentDiskDefaults>>,
786 /// Details of the disk only migration target.
787 #[serde(rename = "disksTargetDefaults")]
788 pub disks_target_defaults: Option<DisksMigrationDisksTargetDefaults>,
789 /// The full path of the resource of type TargetProject which represents the Compute Engine project in which to create the Persistent Disks.
790 #[serde(rename = "targetProject")]
791 pub target_project: Option<String>,
792 /// Details of the VM migration target.
793 #[serde(rename = "vmTargetDefaults")]
794 pub vm_target_defaults: Option<DisksMigrationVmTargetDefaults>,
795 /// The zone in which to create the Persistent Disks.
796 pub zone: Option<String>,
797}
798
799impl common::Part for ComputeEngineDisksTargetDefaults {}
800
801/// ComputeEngineDisksTargetDetails is a collection of created Persistent Disks details.
802///
803/// This type is not used in any activity, and only used as *part* of another schema.
804///
805#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
806#[serde_with::serde_as]
807#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
808pub struct ComputeEngineDisksTargetDetails {
809 /// The details of each created Persistent Disk.
810 pub disks: Option<Vec<PersistentDisk>>,
811 /// Details of the disks-only migration target.
812 #[serde(rename = "disksTargetDetails")]
813 pub disks_target_details: Option<DisksMigrationDisksTargetDetails>,
814 /// Details for the VM the migrated data disks are attached to.
815 #[serde(rename = "vmTargetDetails")]
816 pub vm_target_details: Option<DisksMigrationVmTargetDetails>,
817}
818
819impl common::Part for ComputeEngineDisksTargetDetails {}
820
821/// ComputeEngineTargetDefaults is a collection of details for creating a VM in a target Compute Engine project.
822///
823/// This type is not used in any activity, and only used as *part* of another schema.
824///
825#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
826#[serde_with::serde_as]
827#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
828pub struct ComputeEngineTargetDefaults {
829 /// Additional licenses to assign to the VM.
830 #[serde(rename = "additionalLicenses")]
831 pub additional_licenses: Option<Vec<String>>,
832 /// Output only. The OS license returned from the adaptation module report.
833 #[serde(rename = "appliedLicense")]
834 pub applied_license: Option<AppliedLicense>,
835 /// Output only. The VM Boot Option, as set in the source VM.
836 #[serde(rename = "bootOption")]
837 pub boot_option: Option<String>,
838 /// Compute instance scheduling information (if empty default is used).
839 #[serde(rename = "computeScheduling")]
840 pub compute_scheduling: Option<ComputeScheduling>,
841 /// The disk type to use in the VM.
842 #[serde(rename = "diskType")]
843 pub disk_type: Option<String>,
844 /// Optional. Immutable. The encryption to apply to the VM disks.
845 pub encryption: Option<Encryption>,
846 /// The hostname to assign to the VM.
847 pub hostname: Option<String>,
848 /// A map of labels to associate with the VM.
849 pub labels: Option<HashMap<String, String>>,
850 /// The license type to use in OS adaptation.
851 #[serde(rename = "licenseType")]
852 pub license_type: Option<String>,
853 /// The machine type to create the VM with.
854 #[serde(rename = "machineType")]
855 pub machine_type: Option<String>,
856 /// The machine type series to create the VM with.
857 #[serde(rename = "machineTypeSeries")]
858 pub machine_type_series: Option<String>,
859 /// The metadata key/value pairs to assign to the VM.
860 pub metadata: Option<HashMap<String, String>>,
861 /// List of NICs connected to this VM.
862 #[serde(rename = "networkInterfaces")]
863 pub network_interfaces: Option<Vec<NetworkInterface>>,
864 /// A list of network tags to associate with the VM.
865 #[serde(rename = "networkTags")]
866 pub network_tags: Option<Vec<String>>,
867 /// Defines whether the instance has Secure Boot enabled. This can be set to true only if the VM boot option is EFI.
868 #[serde(rename = "secureBoot")]
869 pub secure_boot: Option<bool>,
870 /// The service account to associate the VM with.
871 #[serde(rename = "serviceAccount")]
872 pub service_account: Option<String>,
873 /// The full path of the resource of type TargetProject which represents the Compute Engine project in which to create this VM.
874 #[serde(rename = "targetProject")]
875 pub target_project: Option<String>,
876 /// The name of the VM to create.
877 #[serde(rename = "vmName")]
878 pub vm_name: Option<String>,
879 /// The zone in which to create the VM.
880 pub zone: Option<String>,
881}
882
883impl common::Part for ComputeEngineTargetDefaults {}
884
885/// ComputeEngineTargetDetails is a collection of details for creating a VM in a target Compute Engine project.
886///
887/// This type is not used in any activity, and only used as *part* of another schema.
888///
889#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
890#[serde_with::serde_as]
891#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
892pub struct ComputeEngineTargetDetails {
893 /// Additional licenses to assign to the VM.
894 #[serde(rename = "additionalLicenses")]
895 pub additional_licenses: Option<Vec<String>>,
896 /// The OS license returned from the adaptation module report.
897 #[serde(rename = "appliedLicense")]
898 pub applied_license: Option<AppliedLicense>,
899 /// The VM Boot Option, as set in the source VM.
900 #[serde(rename = "bootOption")]
901 pub boot_option: Option<String>,
902 /// Compute instance scheduling information (if empty default is used).
903 #[serde(rename = "computeScheduling")]
904 pub compute_scheduling: Option<ComputeScheduling>,
905 /// The disk type to use in the VM.
906 #[serde(rename = "diskType")]
907 pub disk_type: Option<String>,
908 /// Optional. The encryption to apply to the VM disks.
909 pub encryption: Option<Encryption>,
910 /// The hostname to assign to the VM.
911 pub hostname: Option<String>,
912 /// A map of labels to associate with the VM.
913 pub labels: Option<HashMap<String, String>>,
914 /// The license type to use in OS adaptation.
915 #[serde(rename = "licenseType")]
916 pub license_type: Option<String>,
917 /// The machine type to create the VM with.
918 #[serde(rename = "machineType")]
919 pub machine_type: Option<String>,
920 /// The machine type series to create the VM with.
921 #[serde(rename = "machineTypeSeries")]
922 pub machine_type_series: Option<String>,
923 /// The metadata key/value pairs to assign to the VM.
924 pub metadata: Option<HashMap<String, String>>,
925 /// List of NICs connected to this VM.
926 #[serde(rename = "networkInterfaces")]
927 pub network_interfaces: Option<Vec<NetworkInterface>>,
928 /// A list of network tags to associate with the VM.
929 #[serde(rename = "networkTags")]
930 pub network_tags: Option<Vec<String>>,
931 /// The Google Cloud target project ID or project name.
932 pub project: Option<String>,
933 /// Defines whether the instance has Secure Boot enabled. This can be set to true only if the VM boot option is EFI.
934 #[serde(rename = "secureBoot")]
935 pub secure_boot: Option<bool>,
936 /// The service account to associate the VM with.
937 #[serde(rename = "serviceAccount")]
938 pub service_account: Option<String>,
939 /// The name of the VM to create.
940 #[serde(rename = "vmName")]
941 pub vm_name: Option<String>,
942 /// The zone in which to create the VM.
943 pub zone: Option<String>,
944}
945
946impl common::Part for ComputeEngineTargetDetails {}
947
948/// Scheduling information for VM on maintenance/restart behaviour and node allocation in sole tenant nodes.
949///
950/// This type is not used in any activity, and only used as *part* of another schema.
951///
952#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
953#[serde_with::serde_as]
954#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
955pub struct ComputeScheduling {
956 /// The minimum number of virtual CPUs this instance will consume when running on a sole-tenant node. Ignored if no node_affinites are configured.
957 #[serde(rename = "minNodeCpus")]
958 pub min_node_cpus: Option<i32>,
959 /// A set of node affinity and anti-affinity configurations for sole tenant nodes.
960 #[serde(rename = "nodeAffinities")]
961 pub node_affinities: Option<Vec<SchedulingNodeAffinity>>,
962 /// How the instance should behave when the host machine undergoes maintenance that may temporarily impact instance performance.
963 #[serde(rename = "onHostMaintenance")]
964 pub on_host_maintenance: Option<String>,
965 /// Whether the Instance should be automatically restarted whenever it is terminated by Compute Engine (not terminated by user). This configuration is identical to `automaticRestart` field in Compute Engine create instance under scheduling. It was changed to an enum (instead of a boolean) to match the default value in Compute Engine which is automatic restart.
966 #[serde(rename = "restartType")]
967 pub restart_type: Option<String>,
968}
969
970impl common::Part for ComputeScheduling {}
971
972/// CreatingImageStep contains specific step details.
973///
974/// This type is not used in any activity, and only used as *part* of another schema.
975///
976#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
977#[serde_with::serde_as]
978#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
979pub struct CreatingImageStep {
980 _never_set: Option<bool>,
981}
982
983impl common::Part for CreatingImageStep {}
984
985/// CutoverForecast holds information about future CutoverJobs of a MigratingVm.
986///
987/// This type is not used in any activity, and only used as *part* of another schema.
988///
989#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
990#[serde_with::serde_as]
991#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
992pub struct CutoverForecast {
993 /// Output only. Estimation of the CutoverJob duration.
994 #[serde(rename = "estimatedCutoverJobDuration")]
995 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
996 pub estimated_cutover_job_duration: Option<chrono::Duration>,
997}
998
999impl common::Part for CutoverForecast {}
1000
1001/// CutoverJob message describes a cutover of a migrating VM. The CutoverJob is the operation of shutting down the VM, creating a snapshot and clonning the VM using the replicated snapshot.
1002///
1003/// # Activities
1004///
1005/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1006/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1007///
1008/// * [locations sources migrating vms cutover jobs create projects](ProjectLocationSourceMigratingVmCutoverJobCreateCall) (request)
1009/// * [locations sources migrating vms cutover jobs get projects](ProjectLocationSourceMigratingVmCutoverJobGetCall) (response)
1010#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1011#[serde_with::serde_as]
1012#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1013pub struct CutoverJob {
1014 /// Output only. Details of the target Persistent Disks in Compute Engine.
1015 #[serde(rename = "computeEngineDisksTargetDetails")]
1016 pub compute_engine_disks_target_details: Option<ComputeEngineDisksTargetDetails>,
1017 /// Output only. Details of the target VM in Compute Engine.
1018 #[serde(rename = "computeEngineTargetDetails")]
1019 pub compute_engine_target_details: Option<ComputeEngineTargetDetails>,
1020 /// Output only. The time the cutover job was created (as an API call, not when it was actually created in the target).
1021 #[serde(rename = "createTime")]
1022 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1023 /// Output only. The time the cutover job had finished.
1024 #[serde(rename = "endTime")]
1025 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1026 /// Output only. Provides details for the errors that led to the Cutover Job's state.
1027 pub error: Option<Status>,
1028 /// Output only. The name of the cutover job.
1029 pub name: Option<String>,
1030 /// Output only. The current progress in percentage of the cutover job.
1031 #[serde(rename = "progressPercent")]
1032 pub progress_percent: Option<i32>,
1033 /// Output only. State of the cutover job.
1034 pub state: Option<String>,
1035 /// Output only. A message providing possible extra details about the current state.
1036 #[serde(rename = "stateMessage")]
1037 pub state_message: Option<String>,
1038 /// Output only. The time the state was last updated.
1039 #[serde(rename = "stateTime")]
1040 pub state_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1041 /// Output only. The cutover steps list representing its progress.
1042 pub steps: Option<Vec<CutoverStep>>,
1043}
1044
1045impl common::RequestValue for CutoverJob {}
1046impl common::ResponseResult for CutoverJob {}
1047
1048/// CutoverStep holds information about the cutover step progress.
1049///
1050/// This type is not used in any activity, and only used as *part* of another schema.
1051///
1052#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1053#[serde_with::serde_as]
1054#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1055pub struct CutoverStep {
1056 /// The time the step has ended.
1057 #[serde(rename = "endTime")]
1058 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1059 /// Final sync step.
1060 #[serde(rename = "finalSync")]
1061 pub final_sync: Option<ReplicationCycle>,
1062 /// Instantiating migrated VM step.
1063 #[serde(rename = "instantiatingMigratedVm")]
1064 pub instantiating_migrated_vm: Option<InstantiatingMigratedVMStep>,
1065 /// Preparing VM disks step.
1066 #[serde(rename = "preparingVmDisks")]
1067 pub preparing_vm_disks: Option<PreparingVMDisksStep>,
1068 /// A replication cycle prior cutover step.
1069 #[serde(rename = "previousReplicationCycle")]
1070 pub previous_replication_cycle: Option<ReplicationCycle>,
1071 /// Shutting down VM step.
1072 #[serde(rename = "shuttingDownSourceVm")]
1073 pub shutting_down_source_vm: Option<ShuttingDownSourceVMStep>,
1074 /// The time the step has started.
1075 #[serde(rename = "startTime")]
1076 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1077}
1078
1079impl common::Part for CutoverStep {}
1080
1081/// CycleStep holds information about a step progress.
1082///
1083/// This type is not used in any activity, and only used as *part* of another schema.
1084///
1085#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1086#[serde_with::serde_as]
1087#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1088pub struct CycleStep {
1089 /// The time the cycle step has ended.
1090 #[serde(rename = "endTime")]
1091 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1092 /// Initializing replication step.
1093 #[serde(rename = "initializingReplication")]
1094 pub initializing_replication: Option<InitializingReplicationStep>,
1095 /// Post processing step.
1096 #[serde(rename = "postProcessing")]
1097 pub post_processing: Option<PostProcessingStep>,
1098 /// Replicating step.
1099 pub replicating: Option<ReplicatingStep>,
1100 /// The time the cycle step has started.
1101 #[serde(rename = "startTime")]
1102 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1103}
1104
1105impl common::Part for CycleStep {}
1106
1107/// Mentions that the image import is not using OS adaptation process.
1108///
1109/// This type is not used in any activity, and only used as *part* of another schema.
1110///
1111#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1112#[serde_with::serde_as]
1113#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1114pub struct DataDiskImageImport {
1115 _never_set: Option<bool>,
1116}
1117
1118impl common::Part for DataDiskImageImport {}
1119
1120/// DatacenterConnector message describes a connector between the Source and Google Cloud, which is installed on a vmware datacenter (an OVA vm installed by the user) to connect the Datacenter to Google Cloud and support vm migration data transfer.
1121///
1122/// # Activities
1123///
1124/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1125/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1126///
1127/// * [locations sources datacenter connectors create projects](ProjectLocationSourceDatacenterConnectorCreateCall) (request)
1128/// * [locations sources datacenter connectors get projects](ProjectLocationSourceDatacenterConnectorGetCall) (response)
1129#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1130#[serde_with::serde_as]
1131#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1132pub struct DatacenterConnector {
1133 /// Output only. Appliance OVA version. This is the OVA which is manually installed by the user and contains the infrastructure for the automatically updatable components on the appliance.
1134 #[serde(rename = "applianceInfrastructureVersion")]
1135 pub appliance_infrastructure_version: Option<String>,
1136 /// Output only. Appliance last installed update bundle version. This is the version of the automatically updatable components on the appliance.
1137 #[serde(rename = "applianceSoftwareVersion")]
1138 pub appliance_software_version: Option<String>,
1139 /// Output only. The available versions for updating this appliance.
1140 #[serde(rename = "availableVersions")]
1141 pub available_versions: Option<AvailableUpdates>,
1142 /// Output only. The communication channel between the datacenter connector and Google Cloud.
1143 pub bucket: Option<String>,
1144 /// Output only. The time the connector was created (as an API call, not when it was actually installed).
1145 #[serde(rename = "createTime")]
1146 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1147 /// Output only. Provides details on the state of the Datacenter Connector in case of an error.
1148 pub error: Option<Status>,
1149 /// Output only. The connector's name.
1150 pub name: Option<String>,
1151 /// Immutable. A unique key for this connector. This key is internal to the OVA connector and is supplied with its creation during the registration process and can not be modified.
1152 #[serde(rename = "registrationId")]
1153 pub registration_id: Option<String>,
1154 /// The service account to use in the connector when communicating with the cloud.
1155 #[serde(rename = "serviceAccount")]
1156 pub service_account: Option<String>,
1157 /// Output only. State of the DatacenterConnector, as determined by the health checks.
1158 pub state: Option<String>,
1159 /// Output only. The time the state was last set.
1160 #[serde(rename = "stateTime")]
1161 pub state_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1162 /// Output only. The last time the connector was updated with an API call.
1163 #[serde(rename = "updateTime")]
1164 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1165 /// Output only. The status of the current / last upgradeAppliance operation.
1166 #[serde(rename = "upgradeStatus")]
1167 pub upgrade_status: Option<UpgradeStatus>,
1168 /// The version running in the DatacenterConnector. This is supplied by the OVA connector during the registration process and can not be modified.
1169 pub version: Option<String>,
1170}
1171
1172impl common::RequestValue for DatacenterConnector {}
1173impl common::ResponseResult for DatacenterConnector {}
1174
1175/// A message describing a data disk.
1176///
1177/// This type is not used in any activity, and only used as *part* of another schema.
1178///
1179#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1180#[serde_with::serde_as]
1181#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1182pub struct Disk {
1183 /// The disk's Logical Unit Number (LUN).
1184 pub lun: Option<i32>,
1185 /// The disk name.
1186 pub name: Option<String>,
1187 /// The disk size in GB.
1188 #[serde(rename = "sizeGb")]
1189 pub size_gb: Option<i32>,
1190}
1191
1192impl common::Part for Disk {}
1193
1194/// Contains details about the image source used to create the disk.
1195///
1196/// This type is not used in any activity, and only used as *part* of another schema.
1197///
1198#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1199#[serde_with::serde_as]
1200#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1201pub struct DiskImageDefaults {
1202 /// Required. The Image resource used when creating the disk.
1203 #[serde(rename = "sourceImage")]
1204 pub source_image: Option<String>,
1205}
1206
1207impl common::Part for DiskImageDefaults {}
1208
1209/// The target details of the image resource that will be created by the import job.
1210///
1211/// This type is not used in any activity, and only used as *part* of another schema.
1212///
1213#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1214#[serde_with::serde_as]
1215#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1216pub struct DiskImageTargetDetails {
1217 /// Optional. Additional licenses to assign to the image.
1218 #[serde(rename = "additionalLicenses")]
1219 pub additional_licenses: Option<Vec<String>>,
1220 /// Optional. Use to skip OS adaptation process.
1221 #[serde(rename = "dataDiskImageImport")]
1222 pub data_disk_image_import: Option<DataDiskImageImport>,
1223 /// Optional. An optional description of the image.
1224 pub description: Option<String>,
1225 /// Immutable. The encryption to apply to the image.
1226 pub encryption: Option<Encryption>,
1227 /// Optional. The name of the image family to which the new image belongs.
1228 #[serde(rename = "familyName")]
1229 pub family_name: Option<String>,
1230 /// Required. The name of the image to be created.
1231 #[serde(rename = "imageName")]
1232 pub image_name: Option<String>,
1233 /// Optional. A map of labels to associate with the image.
1234 pub labels: Option<HashMap<String, String>>,
1235 /// Optional. Use to set the parameters relevant for the OS adaptation process.
1236 #[serde(rename = "osAdaptationParameters")]
1237 pub os_adaptation_parameters: Option<ImageImportOsAdaptationParameters>,
1238 /// Optional. Set to true to set the image storageLocations to the single region of the import job. When false, the closest multi-region is selected.
1239 #[serde(rename = "singleRegionStorage")]
1240 pub single_region_storage: Option<bool>,
1241 /// Required. Reference to the TargetProject resource that represents the target project in which the imported image will be created.
1242 #[serde(rename = "targetProject")]
1243 pub target_project: Option<String>,
1244}
1245
1246impl common::Part for DiskImageTargetDetails {}
1247
1248/// Details for a disk only migration.
1249///
1250/// This type is not used in any activity, and only used as *part* of another schema.
1251///
1252#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1253#[serde_with::serde_as]
1254#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1255pub struct DisksMigrationDisksTargetDefaults {
1256 _never_set: Option<bool>,
1257}
1258
1259impl common::Part for DisksMigrationDisksTargetDefaults {}
1260
1261/// Details for a disks-only migration.
1262///
1263/// This type is not used in any activity, and only used as *part* of another schema.
1264///
1265#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1266#[serde_with::serde_as]
1267#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1268pub struct DisksMigrationDisksTargetDetails {
1269 _never_set: Option<bool>,
1270}
1271
1272impl common::Part for DisksMigrationDisksTargetDetails {}
1273
1274/// Details for creation of a VM that migrated data disks will be attached to.
1275///
1276/// This type is not used in any activity, and only used as *part* of another schema.
1277///
1278#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1279#[serde_with::serde_as]
1280#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1281pub struct DisksMigrationVmTargetDefaults {
1282 /// Optional. Additional licenses to assign to the VM.
1283 #[serde(rename = "additionalLicenses")]
1284 pub additional_licenses: Option<Vec<String>>,
1285 /// Optional. Details of the boot disk of the VM.
1286 #[serde(rename = "bootDiskDefaults")]
1287 pub boot_disk_defaults: Option<BootDiskDefaults>,
1288 /// Optional. Compute instance scheduling information (if empty default is used).
1289 #[serde(rename = "computeScheduling")]
1290 pub compute_scheduling: Option<ComputeScheduling>,
1291 /// Optional. The encryption to apply to the VM.
1292 pub encryption: Option<Encryption>,
1293 /// Optional. The hostname to assign to the VM.
1294 pub hostname: Option<String>,
1295 /// Optional. A map of labels to associate with the VM.
1296 pub labels: Option<HashMap<String, String>>,
1297 /// Required. The machine type to create the VM with.
1298 #[serde(rename = "machineType")]
1299 pub machine_type: Option<String>,
1300 /// Optional. The machine type series to create the VM with. For presentation only.
1301 #[serde(rename = "machineTypeSeries")]
1302 pub machine_type_series: Option<String>,
1303 /// Optional. The metadata key/value pairs to assign to the VM.
1304 pub metadata: Option<HashMap<String, String>>,
1305 /// Optional. NICs to attach to the VM.
1306 #[serde(rename = "networkInterfaces")]
1307 pub network_interfaces: Option<Vec<NetworkInterface>>,
1308 /// Optional. A list of network tags to associate with the VM.
1309 #[serde(rename = "networkTags")]
1310 pub network_tags: Option<Vec<String>>,
1311 /// Optional. Defines whether the instance has Secure Boot enabled. This can be set to true only if the VM boot option is EFI.
1312 #[serde(rename = "secureBoot")]
1313 pub secure_boot: Option<bool>,
1314 /// Optional. The service account to associate the VM with.
1315 #[serde(rename = "serviceAccount")]
1316 pub service_account: Option<String>,
1317 /// Required. The name of the VM to create.
1318 #[serde(rename = "vmName")]
1319 pub vm_name: Option<String>,
1320}
1321
1322impl common::Part for DisksMigrationVmTargetDefaults {}
1323
1324/// Details for the VM created VM as part of disks migration.
1325///
1326/// This type is not used in any activity, and only used as *part* of another schema.
1327///
1328#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1329#[serde_with::serde_as]
1330#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1331pub struct DisksMigrationVmTargetDetails {
1332 /// Output only. The URI of the Compute Engine VM.
1333 #[serde(rename = "vmUri")]
1334 pub vm_uri: Option<String>,
1335}
1336
1337impl common::Part for DisksMigrationVmTargetDetails {}
1338
1339/// 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); }
1340///
1341/// # Activities
1342///
1343/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1344/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1345///
1346/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
1347/// * [locations operations delete projects](ProjectLocationOperationDeleteCall) (response)
1348#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1349#[serde_with::serde_as]
1350#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1351pub struct Empty {
1352 _never_set: Option<bool>,
1353}
1354
1355impl common::ResponseResult for Empty {}
1356
1357/// Encryption message describes the details of the applied encryption.
1358///
1359/// This type is not used in any activity, and only used as *part* of another schema.
1360///
1361#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1362#[serde_with::serde_as]
1363#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1364pub struct Encryption {
1365 /// Required. The name of the encryption key that is stored in Google Cloud KMS.
1366 #[serde(rename = "kmsKey")]
1367 pub kms_key: Option<String>,
1368}
1369
1370impl common::Part for Encryption {}
1371
1372/// Response message for fetchInventory.
1373///
1374/// # Activities
1375///
1376/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1377/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1378///
1379/// * [locations sources fetch inventory projects](ProjectLocationSourceFetchInventoryCall) (response)
1380#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1381#[serde_with::serde_as]
1382#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1383pub struct FetchInventoryResponse {
1384 /// The description of the VMs in a Source of type AWS.
1385 #[serde(rename = "awsVms")]
1386 pub aws_vms: Option<AwsVmsDetails>,
1387 /// The description of the VMs in a Source of type Azure.
1388 #[serde(rename = "azureVms")]
1389 pub azure_vms: Option<AzureVmsDetails>,
1390 /// Output only. A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1391 #[serde(rename = "nextPageToken")]
1392 pub next_page_token: Option<String>,
1393 /// Output only. The timestamp when the source was last queried (if the result is from the cache).
1394 #[serde(rename = "updateTime")]
1395 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1396 /// The description of the VMs in a Source of type Vmware.
1397 #[serde(rename = "vmwareVms")]
1398 pub vmware_vms: Option<VmwareVmsDetails>,
1399}
1400
1401impl common::ResponseResult for FetchInventoryResponse {}
1402
1403/// Request message for ‘FinalizeMigration’ request.
1404///
1405/// # Activities
1406///
1407/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1408/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1409///
1410/// * [locations sources migrating vms finalize migration projects](ProjectLocationSourceMigratingVmFinalizeMigrationCall) (request)
1411#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1412#[serde_with::serde_as]
1413#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1414pub struct FinalizeMigrationRequest {
1415 _never_set: Option<bool>,
1416}
1417
1418impl common::RequestValue for FinalizeMigrationRequest {}
1419
1420/// Describes message for ‘Group’ resource. The Group is a collections of several MigratingVms.
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 groups create projects](ProjectLocationGroupCreateCall) (request)
1428/// * [locations groups get projects](ProjectLocationGroupGetCall) (response)
1429/// * [locations groups patch projects](ProjectLocationGroupPatchCall) (request)
1430#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1431#[serde_with::serde_as]
1432#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1433pub struct Group {
1434 /// Output only. The create time timestamp.
1435 #[serde(rename = "createTime")]
1436 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1437 /// User-provided description of the group.
1438 pub description: Option<String>,
1439 /// Display name is a user defined name for this group which can be updated.
1440 #[serde(rename = "displayName")]
1441 pub display_name: Option<String>,
1442 /// Immutable. The target type of this group.
1443 #[serde(rename = "migrationTargetType")]
1444 pub migration_target_type: Option<String>,
1445 /// Output only. The Group name.
1446 pub name: Option<String>,
1447 /// Output only. The update time timestamp.
1448 #[serde(rename = "updateTime")]
1449 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1450}
1451
1452impl common::RequestValue for Group {}
1453impl common::ResponseResult for Group {}
1454
1455/// ImageImport describes the configuration of the image import to run.
1456///
1457/// # Activities
1458///
1459/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1460/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1461///
1462/// * [locations image imports create projects](ProjectLocationImageImportCreateCall) (request)
1463/// * [locations image imports get projects](ProjectLocationImageImportGetCall) (response)
1464#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1465#[serde_with::serde_as]
1466#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1467pub struct ImageImport {
1468 /// Immutable. The path to the Cloud Storage file from which the image should be imported.
1469 #[serde(rename = "cloudStorageUri")]
1470 pub cloud_storage_uri: Option<String>,
1471 /// Output only. The time the image import was created.
1472 #[serde(rename = "createTime")]
1473 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1474 /// Immutable. Target details for importing a disk image, will be used by ImageImportJob.
1475 #[serde(rename = "diskImageTargetDefaults")]
1476 pub disk_image_target_defaults: Option<DiskImageTargetDetails>,
1477 /// Immutable. The encryption details used by the image import process during the image adaptation for Compute Engine.
1478 pub encryption: Option<Encryption>,
1479 /// Output only. The resource path of the ImageImport.
1480 pub name: Option<String>,
1481 /// Output only. The result of the most recent runs for this ImageImport. All jobs for this ImageImport can be listed via ListImageImportJobs.
1482 #[serde(rename = "recentImageImportJobs")]
1483 pub recent_image_import_jobs: Option<Vec<ImageImportJob>>,
1484}
1485
1486impl common::RequestValue for ImageImport {}
1487impl common::ResponseResult for ImageImport {}
1488
1489/// ImageImportJob describes the progress and result of an image import.
1490///
1491/// # Activities
1492///
1493/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1494/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1495///
1496/// * [locations image imports image import jobs get projects](ProjectLocationImageImportImageImportJobGetCall) (response)
1497#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1498#[serde_with::serde_as]
1499#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1500pub struct ImageImportJob {
1501 /// Output only. The path to the Cloud Storage file from which the image should be imported.
1502 #[serde(rename = "cloudStorageUri")]
1503 pub cloud_storage_uri: Option<String>,
1504 /// Output only. The time the image import was created (as an API call, not when it was actually created in the target).
1505 #[serde(rename = "createTime")]
1506 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1507 /// Output only. The resource paths of the resources created by the image import job.
1508 #[serde(rename = "createdResources")]
1509 pub created_resources: Option<Vec<String>>,
1510 /// Output only. Target details used to import a disk image.
1511 #[serde(rename = "diskImageTargetDetails")]
1512 pub disk_image_target_details: Option<DiskImageTargetDetails>,
1513 /// Output only. The time the image import was ended.
1514 #[serde(rename = "endTime")]
1515 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1516 /// Output only. Provides details on the error that led to the image import state in case of an error.
1517 pub errors: Option<Vec<Status>>,
1518 /// Output only. The resource path of the ImageImportJob.
1519 pub name: Option<String>,
1520 /// Output only. The state of the image import.
1521 pub state: Option<String>,
1522 /// Output only. The image import steps list representing its progress.
1523 pub steps: Option<Vec<ImageImportStep>>,
1524 /// Output only. Warnings that occurred during the image import.
1525 pub warnings: Option<Vec<MigrationWarning>>,
1526}
1527
1528impl common::ResponseResult for ImageImportJob {}
1529
1530/// Parameters affecting the OS adaptation process.
1531///
1532/// This type is not used in any activity, and only used as *part* of another schema.
1533///
1534#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1535#[serde_with::serde_as]
1536#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1537pub struct ImageImportOsAdaptationParameters {
1538 /// Optional. Set to true in order to generalize the imported image. The generalization process enables co-existence of multiple VMs created from the same image. For Windows, generalizing the image removes computer-specific information such as installed drivers and the computer security identifier (SID).
1539 pub generalize: Option<bool>,
1540 /// Optional. Choose which type of license to apply to the imported image.
1541 #[serde(rename = "licenseType")]
1542 pub license_type: Option<String>,
1543}
1544
1545impl common::Part for ImageImportOsAdaptationParameters {}
1546
1547/// ImageImportStep holds information about the image import step progress.
1548///
1549/// This type is not used in any activity, and only used as *part* of another schema.
1550///
1551#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1552#[serde_with::serde_as]
1553#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1554pub struct ImageImportStep {
1555 /// Adapting OS step.
1556 #[serde(rename = "adaptingOs")]
1557 pub adapting_os: Option<AdaptingOSStep>,
1558 /// Creating image step.
1559 #[serde(rename = "creatingImage")]
1560 pub creating_image: Option<CreatingImageStep>,
1561 /// Output only. The time the step has ended.
1562 #[serde(rename = "endTime")]
1563 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1564 /// Initializing step.
1565 pub initializing: Option<InitializingImageImportStep>,
1566 /// Loading source files step.
1567 #[serde(rename = "loadingSourceFiles")]
1568 pub loading_source_files: Option<LoadingImageSourceFilesStep>,
1569 /// Output only. The time the step has started.
1570 #[serde(rename = "startTime")]
1571 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1572}
1573
1574impl common::Part for ImageImportStep {}
1575
1576/// InitializingImageImportStep contains specific step details.
1577///
1578/// This type is not used in any activity, and only used as *part* of another schema.
1579///
1580#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1581#[serde_with::serde_as]
1582#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1583pub struct InitializingImageImportStep {
1584 _never_set: Option<bool>,
1585}
1586
1587impl common::Part for InitializingImageImportStep {}
1588
1589/// InitializingReplicationStep contains specific step details.
1590///
1591/// This type is not used in any activity, and only used as *part* of another schema.
1592///
1593#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1594#[serde_with::serde_as]
1595#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1596pub struct InitializingReplicationStep {
1597 _never_set: Option<bool>,
1598}
1599
1600impl common::Part for InitializingReplicationStep {}
1601
1602/// InstantiatingMigratedVMStep contains specific step details.
1603///
1604/// This type is not used in any activity, and only used as *part* of another schema.
1605///
1606#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1607#[serde_with::serde_as]
1608#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1609pub struct InstantiatingMigratedVMStep {
1610 _never_set: Option<bool>,
1611}
1612
1613impl common::Part for InstantiatingMigratedVMStep {}
1614
1615/// Describes a URL link.
1616///
1617/// This type is not used in any activity, and only used as *part* of another schema.
1618///
1619#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1620#[serde_with::serde_as]
1621#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1622pub struct Link {
1623 /// Describes what the link offers.
1624 pub description: Option<String>,
1625 /// The URL of the link.
1626 pub url: Option<String>,
1627}
1628
1629impl common::Part for Link {}
1630
1631/// Response message for ‘ListCloneJobs’ request.
1632///
1633/// # Activities
1634///
1635/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1636/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1637///
1638/// * [locations sources migrating vms clone jobs list projects](ProjectLocationSourceMigratingVmCloneJobListCall) (response)
1639#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1640#[serde_with::serde_as]
1641#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1642pub struct ListCloneJobsResponse {
1643 /// Output only. The list of clone jobs response.
1644 #[serde(rename = "cloneJobs")]
1645 pub clone_jobs: Option<Vec<CloneJob>>,
1646 /// Output only. A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1647 #[serde(rename = "nextPageToken")]
1648 pub next_page_token: Option<String>,
1649 /// Output only. Locations that could not be reached.
1650 pub unreachable: Option<Vec<String>>,
1651}
1652
1653impl common::ResponseResult for ListCloneJobsResponse {}
1654
1655/// Response message for ‘ListCutoverJobs’ request.
1656///
1657/// # Activities
1658///
1659/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1660/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1661///
1662/// * [locations sources migrating vms cutover jobs list projects](ProjectLocationSourceMigratingVmCutoverJobListCall) (response)
1663#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1664#[serde_with::serde_as]
1665#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1666pub struct ListCutoverJobsResponse {
1667 /// Output only. The list of cutover jobs response.
1668 #[serde(rename = "cutoverJobs")]
1669 pub cutover_jobs: Option<Vec<CutoverJob>>,
1670 /// Output only. A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1671 #[serde(rename = "nextPageToken")]
1672 pub next_page_token: Option<String>,
1673 /// Output only. Locations that could not be reached.
1674 pub unreachable: Option<Vec<String>>,
1675}
1676
1677impl common::ResponseResult for ListCutoverJobsResponse {}
1678
1679/// Response message for ‘ListDatacenterConnectors’ request.
1680///
1681/// # Activities
1682///
1683/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1684/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1685///
1686/// * [locations sources datacenter connectors list projects](ProjectLocationSourceDatacenterConnectorListCall) (response)
1687#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1688#[serde_with::serde_as]
1689#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1690pub struct ListDatacenterConnectorsResponse {
1691 /// Output only. The list of sources response.
1692 #[serde(rename = "datacenterConnectors")]
1693 pub datacenter_connectors: Option<Vec<DatacenterConnector>>,
1694 /// Output only. A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1695 #[serde(rename = "nextPageToken")]
1696 pub next_page_token: Option<String>,
1697 /// Output only. Locations that could not be reached.
1698 pub unreachable: Option<Vec<String>>,
1699}
1700
1701impl common::ResponseResult for ListDatacenterConnectorsResponse {}
1702
1703/// Response message for ‘ListGroups’ request.
1704///
1705/// # Activities
1706///
1707/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1708/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1709///
1710/// * [locations groups list projects](ProjectLocationGroupListCall) (response)
1711#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1712#[serde_with::serde_as]
1713#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1714pub struct ListGroupsResponse {
1715 /// Output only. The list of groups response.
1716 pub groups: Option<Vec<Group>>,
1717 /// Output only. A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1718 #[serde(rename = "nextPageToken")]
1719 pub next_page_token: Option<String>,
1720 /// Output only. Locations that could not be reached.
1721 pub unreachable: Option<Vec<String>>,
1722}
1723
1724impl common::ResponseResult for ListGroupsResponse {}
1725
1726/// Response message for ‘ListImageImportJobs’ call.
1727///
1728/// # Activities
1729///
1730/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1731/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1732///
1733/// * [locations image imports image import jobs list projects](ProjectLocationImageImportImageImportJobListCall) (response)
1734#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1735#[serde_with::serde_as]
1736#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1737pub struct ListImageImportJobsResponse {
1738 /// Output only. The list of target response.
1739 #[serde(rename = "imageImportJobs")]
1740 pub image_import_jobs: Option<Vec<ImageImportJob>>,
1741 /// Output only. A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1742 #[serde(rename = "nextPageToken")]
1743 pub next_page_token: Option<String>,
1744 /// Output only. Locations that could not be reached.
1745 pub unreachable: Option<Vec<String>>,
1746}
1747
1748impl common::ResponseResult for ListImageImportJobsResponse {}
1749
1750/// Response message for ‘ListImageImports’ call.
1751///
1752/// # Activities
1753///
1754/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1755/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1756///
1757/// * [locations image imports list projects](ProjectLocationImageImportListCall) (response)
1758#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1759#[serde_with::serde_as]
1760#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1761pub struct ListImageImportsResponse {
1762 /// Output only. The list of target response.
1763 #[serde(rename = "imageImports")]
1764 pub image_imports: Option<Vec<ImageImport>>,
1765 /// Output only. A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1766 #[serde(rename = "nextPageToken")]
1767 pub next_page_token: Option<String>,
1768 /// Output only. Locations that could not be reached.
1769 pub unreachable: Option<Vec<String>>,
1770}
1771
1772impl common::ResponseResult for ListImageImportsResponse {}
1773
1774/// The response message for Locations.ListLocations.
1775///
1776/// # Activities
1777///
1778/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1779/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1780///
1781/// * [locations list projects](ProjectLocationListCall) (response)
1782#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1783#[serde_with::serde_as]
1784#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1785pub struct ListLocationsResponse {
1786 /// A list of locations that matches the specified filter in the request.
1787 pub locations: Option<Vec<Location>>,
1788 /// The standard List next-page token.
1789 #[serde(rename = "nextPageToken")]
1790 pub next_page_token: Option<String>,
1791}
1792
1793impl common::ResponseResult for ListLocationsResponse {}
1794
1795/// Response message for ‘ListMigratingVms’ request.
1796///
1797/// # Activities
1798///
1799/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1800/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1801///
1802/// * [locations sources migrating vms list projects](ProjectLocationSourceMigratingVmListCall) (response)
1803#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1804#[serde_with::serde_as]
1805#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1806pub struct ListMigratingVmsResponse {
1807 /// Output only. The list of Migrating VMs response.
1808 #[serde(rename = "migratingVms")]
1809 pub migrating_vms: Option<Vec<MigratingVm>>,
1810 /// Output only. A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1811 #[serde(rename = "nextPageToken")]
1812 pub next_page_token: Option<String>,
1813 /// Output only. Locations that could not be reached.
1814 pub unreachable: Option<Vec<String>>,
1815}
1816
1817impl common::ResponseResult for ListMigratingVmsResponse {}
1818
1819/// The response message for Operations.ListOperations.
1820///
1821/// # Activities
1822///
1823/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1824/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1825///
1826/// * [locations operations list projects](ProjectLocationOperationListCall) (response)
1827#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1828#[serde_with::serde_as]
1829#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1830pub struct ListOperationsResponse {
1831 /// The standard List next-page token.
1832 #[serde(rename = "nextPageToken")]
1833 pub next_page_token: Option<String>,
1834 /// A list of operations that matches the specified filter in the request.
1835 pub operations: Option<Vec<Operation>>,
1836}
1837
1838impl common::ResponseResult for ListOperationsResponse {}
1839
1840/// Response message for ‘ListReplicationCycles’ request.
1841///
1842/// # Activities
1843///
1844/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1845/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1846///
1847/// * [locations sources migrating vms replication cycles list projects](ProjectLocationSourceMigratingVmReplicationCycleListCall) (response)
1848#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1849#[serde_with::serde_as]
1850#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1851pub struct ListReplicationCyclesResponse {
1852 /// Output only. A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1853 #[serde(rename = "nextPageToken")]
1854 pub next_page_token: Option<String>,
1855 /// Output only. The list of replication cycles response.
1856 #[serde(rename = "replicationCycles")]
1857 pub replication_cycles: Option<Vec<ReplicationCycle>>,
1858 /// Output only. Locations that could not be reached.
1859 pub unreachable: Option<Vec<String>>,
1860}
1861
1862impl common::ResponseResult for ListReplicationCyclesResponse {}
1863
1864/// Response message for ‘ListSources’ request.
1865///
1866/// # Activities
1867///
1868/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1869/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1870///
1871/// * [locations sources list projects](ProjectLocationSourceListCall) (response)
1872#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1873#[serde_with::serde_as]
1874#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1875pub struct ListSourcesResponse {
1876 /// Output only. A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1877 #[serde(rename = "nextPageToken")]
1878 pub next_page_token: Option<String>,
1879 /// Output only. The list of sources response.
1880 pub sources: Option<Vec<Source>>,
1881 /// Output only. Locations that could not be reached.
1882 pub unreachable: Option<Vec<String>>,
1883}
1884
1885impl common::ResponseResult for ListSourcesResponse {}
1886
1887/// Response message for ‘ListTargetProjects’ call.
1888///
1889/// # Activities
1890///
1891/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1892/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1893///
1894/// * [locations target projects list projects](ProjectLocationTargetProjectListCall) (response)
1895#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1896#[serde_with::serde_as]
1897#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1898pub struct ListTargetProjectsResponse {
1899 /// Output only. A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1900 #[serde(rename = "nextPageToken")]
1901 pub next_page_token: Option<String>,
1902 /// Output only. The list of target response.
1903 #[serde(rename = "targetProjects")]
1904 pub target_projects: Option<Vec<TargetProject>>,
1905 /// Output only. Locations that could not be reached.
1906 pub unreachable: Option<Vec<String>>,
1907}
1908
1909impl common::ResponseResult for ListTargetProjectsResponse {}
1910
1911/// Response message for ‘ListUtilizationReports’ request.
1912///
1913/// # Activities
1914///
1915/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1916/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1917///
1918/// * [locations sources utilization reports list projects](ProjectLocationSourceUtilizationReportListCall) (response)
1919#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1920#[serde_with::serde_as]
1921#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1922pub struct ListUtilizationReportsResponse {
1923 /// Output only. A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1924 #[serde(rename = "nextPageToken")]
1925 pub next_page_token: Option<String>,
1926 /// Output only. Locations that could not be reached.
1927 pub unreachable: Option<Vec<String>>,
1928 /// Output only. The list of reports.
1929 #[serde(rename = "utilizationReports")]
1930 pub utilization_reports: Option<Vec<UtilizationReport>>,
1931}
1932
1933impl common::ResponseResult for ListUtilizationReportsResponse {}
1934
1935/// LoadingImageSourceFilesStep contains specific step details.
1936///
1937/// This type is not used in any activity, and only used as *part* of another schema.
1938///
1939#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1940#[serde_with::serde_as]
1941#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1942pub struct LoadingImageSourceFilesStep {
1943 _never_set: Option<bool>,
1944}
1945
1946impl common::Part for LoadingImageSourceFilesStep {}
1947
1948/// Provides a localized error message that is safe to return to the user which can be attached to an RPC error.
1949///
1950/// This type is not used in any activity, and only used as *part* of another schema.
1951///
1952#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1953#[serde_with::serde_as]
1954#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1955pub struct LocalizedMessage {
1956 /// The locale used following the specification defined at https://www.rfc-editor.org/rfc/bcp/bcp47.txt. Examples are: "en-US", "fr-CH", "es-MX"
1957 pub locale: Option<String>,
1958 /// The localized error message in the above locale.
1959 pub message: Option<String>,
1960}
1961
1962impl common::Part for LocalizedMessage {}
1963
1964/// A resource that represents a Google Cloud location.
1965///
1966/// # Activities
1967///
1968/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1969/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1970///
1971/// * [locations get projects](ProjectLocationGetCall) (response)
1972#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1973#[serde_with::serde_as]
1974#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1975pub struct Location {
1976 /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
1977 #[serde(rename = "displayName")]
1978 pub display_name: Option<String>,
1979 /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
1980 pub labels: Option<HashMap<String, String>>,
1981 /// The canonical id for this location. For example: `"us-east1"`.
1982 #[serde(rename = "locationId")]
1983 pub location_id: Option<String>,
1984 /// Service-specific metadata. For example the available capacity at the given location.
1985 pub metadata: Option<HashMap<String, serde_json::Value>>,
1986 /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
1987 pub name: Option<String>,
1988}
1989
1990impl common::ResponseResult for Location {}
1991
1992/// MigratingVm describes the VM that will be migrated from a Source environment and its replication state.
1993///
1994/// # Activities
1995///
1996/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1997/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1998///
1999/// * [locations sources migrating vms create projects](ProjectLocationSourceMigratingVmCreateCall) (request)
2000/// * [locations sources migrating vms get projects](ProjectLocationSourceMigratingVmGetCall) (response)
2001/// * [locations sources migrating vms patch projects](ProjectLocationSourceMigratingVmPatchCall) (request)
2002#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2003#[serde_with::serde_as]
2004#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2005pub struct MigratingVm {
2006 /// Output only. Details of the VM from an AWS source.
2007 #[serde(rename = "awsSourceVmDetails")]
2008 pub aws_source_vm_details: Option<AwsSourceVmDetails>,
2009 /// Output only. Details of the VM from an Azure source.
2010 #[serde(rename = "azureSourceVmDetails")]
2011 pub azure_source_vm_details: Option<AzureSourceVmDetails>,
2012 /// Details of the target Persistent Disks in Compute Engine.
2013 #[serde(rename = "computeEngineDisksTargetDefaults")]
2014 pub compute_engine_disks_target_defaults: Option<ComputeEngineDisksTargetDefaults>,
2015 /// Details of the target VM in Compute Engine.
2016 #[serde(rename = "computeEngineTargetDefaults")]
2017 pub compute_engine_target_defaults: Option<ComputeEngineTargetDefaults>,
2018 /// Output only. The time the migrating VM was created (this refers to this resource and not to the time it was installed in the source).
2019 #[serde(rename = "createTime")]
2020 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2021 /// Output only. Details of the current running replication cycle.
2022 #[serde(rename = "currentSyncInfo")]
2023 pub current_sync_info: Option<ReplicationCycle>,
2024 /// Output only. Provides details of future CutoverJobs of a MigratingVm. Set to empty when cutover forecast is unavailable.
2025 #[serde(rename = "cutoverForecast")]
2026 pub cutover_forecast: Option<CutoverForecast>,
2027 /// The description attached to the migrating VM by the user.
2028 pub description: Option<String>,
2029 /// The display name attached to the MigratingVm by the user.
2030 #[serde(rename = "displayName")]
2031 pub display_name: Option<String>,
2032 /// Output only. Provides details on the state of the Migrating VM in case of an error in replication.
2033 pub error: Option<Status>,
2034 /// Output only. The group this migrating vm is included in, if any. The group is represented by the full path of the appropriate Group resource.
2035 pub group: Option<String>,
2036 /// The labels of the migrating VM.
2037 pub labels: Option<HashMap<String, String>>,
2038 /// Output only. Details of the last replication cycle. This will be updated whenever a replication cycle is finished and is not to be confused with last_sync which is only updated on successful replication cycles.
2039 #[serde(rename = "lastReplicationCycle")]
2040 pub last_replication_cycle: Option<ReplicationCycle>,
2041 /// Output only. The most updated snapshot created time in the source that finished replication.
2042 #[serde(rename = "lastSync")]
2043 pub last_sync: Option<ReplicationSync>,
2044 /// Output only. The identifier of the MigratingVm.
2045 pub name: Option<String>,
2046 /// The replication schedule policy.
2047 pub policy: Option<SchedulePolicy>,
2048 /// Output only. The recent clone jobs performed on the migrating VM. This field holds the vm's last completed clone job and the vm's running clone job, if one exists. Note: To have this field populated you need to explicitly request it via the "view" parameter of the Get/List request.
2049 #[serde(rename = "recentCloneJobs")]
2050 pub recent_clone_jobs: Option<Vec<CloneJob>>,
2051 /// Output only. The recent cutover jobs performed on the migrating VM. This field holds the vm's last completed cutover job and the vm's running cutover job, if one exists. Note: To have this field populated you need to explicitly request it via the "view" parameter of the Get/List request.
2052 #[serde(rename = "recentCutoverJobs")]
2053 pub recent_cutover_jobs: Option<Vec<CutoverJob>>,
2054 /// The unique ID of the VM in the source. The VM's name in vSphere can be changed, so this is not the VM's name but rather its moRef id. This id is of the form vm-.
2055 #[serde(rename = "sourceVmId")]
2056 pub source_vm_id: Option<String>,
2057 /// Output only. State of the MigratingVm.
2058 pub state: Option<String>,
2059 /// Output only. The last time the migrating VM state was updated.
2060 #[serde(rename = "stateTime")]
2061 pub state_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2062 /// Output only. The last time the migrating VM resource was updated.
2063 #[serde(rename = "updateTime")]
2064 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2065 /// Output only. Details of the VM from a Vmware source.
2066 #[serde(rename = "vmwareSourceVmDetails")]
2067 pub vmware_source_vm_details: Option<VmwareSourceVmDetails>,
2068}
2069
2070impl common::RequestValue for MigratingVm {}
2071impl common::ResponseResult for MigratingVm {}
2072
2073/// Represents migration resource warning information that can be used with google.rpc.Status message. MigrationWarning is used to present the user with warning information in migration operations.
2074///
2075/// This type is not used in any activity, and only used as *part* of another schema.
2076///
2077#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2078#[serde_with::serde_as]
2079#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2080pub struct MigrationWarning {
2081 /// Output only. Suggested action for solving the warning.
2082 #[serde(rename = "actionItem")]
2083 pub action_item: Option<LocalizedMessage>,
2084 /// The warning code.
2085 pub code: Option<String>,
2086 /// Output only. URL(s) pointing to additional information on handling the current warning.
2087 #[serde(rename = "helpLinks")]
2088 pub help_links: Option<Vec<Link>>,
2089 /// Output only. The localized warning message.
2090 #[serde(rename = "warningMessage")]
2091 pub warning_message: Option<LocalizedMessage>,
2092 /// The time the warning occurred.
2093 #[serde(rename = "warningTime")]
2094 pub warning_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2095}
2096
2097impl common::Part for MigrationWarning {}
2098
2099/// Information about the network coniguration of the source.
2100///
2101/// This type is not used in any activity, and only used as *part* of another schema.
2102///
2103#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2104#[serde_with::serde_as]
2105#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2106pub struct NetworkInsights {
2107 /// Output only. The gathered network configuration of the source. Presented in json format.
2108 #[serde(rename = "sourceNetworkConfig")]
2109 pub source_network_config: Option<String>,
2110 /// Output only. The gathered network configuration of the source. Presented in terraform format.
2111 #[serde(rename = "sourceNetworkTerraform")]
2112 pub source_network_terraform: Option<String>,
2113}
2114
2115impl common::Part for NetworkInsights {}
2116
2117/// NetworkInterface represents a NIC of a VM.
2118///
2119/// This type is not used in any activity, and only used as *part* of another schema.
2120///
2121#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2122#[serde_with::serde_as]
2123#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2124pub struct NetworkInterface {
2125 /// Optional. The external IP to define in the NIC.
2126 #[serde(rename = "externalIp")]
2127 pub external_ip: Option<String>,
2128 /// Optional. The internal IP to define in the NIC. The formats accepted are: `ephemeral` \ ipv4 address \ a named address resource full path.
2129 #[serde(rename = "internalIp")]
2130 pub internal_ip: Option<String>,
2131 /// The network to connect the NIC to.
2132 pub network: Option<String>,
2133 /// The subnetwork to connect the NIC to.
2134 pub subnetwork: Option<String>,
2135}
2136
2137impl common::Part for NetworkInterface {}
2138
2139/// A message describing the VM's OS. Including OS, Publisher, Offer and Plan if applicable.
2140///
2141/// This type is not used in any activity, and only used as *part* of another schema.
2142///
2143#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2144#[serde_with::serde_as]
2145#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2146pub struct OSDescription {
2147 /// OS offer.
2148 pub offer: Option<String>,
2149 /// OS plan.
2150 pub plan: Option<String>,
2151 /// OS publisher.
2152 pub publisher: Option<String>,
2153 /// OS type.
2154 #[serde(rename = "type")]
2155 pub type_: Option<String>,
2156}
2157
2158impl common::Part for OSDescription {}
2159
2160/// A message describing the OS disk.
2161///
2162/// This type is not used in any activity, and only used as *part* of another schema.
2163///
2164#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2165#[serde_with::serde_as]
2166#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2167pub struct OSDisk {
2168 /// The disk's full name.
2169 pub name: Option<String>,
2170 /// The disk's size in GB.
2171 #[serde(rename = "sizeGb")]
2172 pub size_gb: Option<i32>,
2173 /// The disk's type.
2174 #[serde(rename = "type")]
2175 pub type_: Option<String>,
2176}
2177
2178impl common::Part for OSDisk {}
2179
2180/// This resource represents a long-running operation that is the result of a network API call.
2181///
2182/// # Activities
2183///
2184/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2185/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2186///
2187/// * [locations groups add group migration projects](ProjectLocationGroupAddGroupMigrationCall) (response)
2188/// * [locations groups create projects](ProjectLocationGroupCreateCall) (response)
2189/// * [locations groups delete projects](ProjectLocationGroupDeleteCall) (response)
2190/// * [locations groups patch projects](ProjectLocationGroupPatchCall) (response)
2191/// * [locations groups remove group migration projects](ProjectLocationGroupRemoveGroupMigrationCall) (response)
2192/// * [locations image imports image import jobs cancel projects](ProjectLocationImageImportImageImportJobCancelCall) (response)
2193/// * [locations image imports create projects](ProjectLocationImageImportCreateCall) (response)
2194/// * [locations image imports delete projects](ProjectLocationImageImportDeleteCall) (response)
2195/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
2196/// * [locations sources datacenter connectors create projects](ProjectLocationSourceDatacenterConnectorCreateCall) (response)
2197/// * [locations sources datacenter connectors delete projects](ProjectLocationSourceDatacenterConnectorDeleteCall) (response)
2198/// * [locations sources datacenter connectors upgrade appliance projects](ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall) (response)
2199/// * [locations sources migrating vms clone jobs cancel projects](ProjectLocationSourceMigratingVmCloneJobCancelCall) (response)
2200/// * [locations sources migrating vms clone jobs create projects](ProjectLocationSourceMigratingVmCloneJobCreateCall) (response)
2201/// * [locations sources migrating vms cutover jobs cancel projects](ProjectLocationSourceMigratingVmCutoverJobCancelCall) (response)
2202/// * [locations sources migrating vms cutover jobs create projects](ProjectLocationSourceMigratingVmCutoverJobCreateCall) (response)
2203/// * [locations sources migrating vms create projects](ProjectLocationSourceMigratingVmCreateCall) (response)
2204/// * [locations sources migrating vms delete projects](ProjectLocationSourceMigratingVmDeleteCall) (response)
2205/// * [locations sources migrating vms finalize migration projects](ProjectLocationSourceMigratingVmFinalizeMigrationCall) (response)
2206/// * [locations sources migrating vms patch projects](ProjectLocationSourceMigratingVmPatchCall) (response)
2207/// * [locations sources migrating vms pause migration projects](ProjectLocationSourceMigratingVmPauseMigrationCall) (response)
2208/// * [locations sources migrating vms resume migration projects](ProjectLocationSourceMigratingVmResumeMigrationCall) (response)
2209/// * [locations sources migrating vms start migration projects](ProjectLocationSourceMigratingVmStartMigrationCall) (response)
2210/// * [locations sources utilization reports create projects](ProjectLocationSourceUtilizationReportCreateCall) (response)
2211/// * [locations sources utilization reports delete projects](ProjectLocationSourceUtilizationReportDeleteCall) (response)
2212/// * [locations sources create projects](ProjectLocationSourceCreateCall) (response)
2213/// * [locations sources delete projects](ProjectLocationSourceDeleteCall) (response)
2214/// * [locations sources patch projects](ProjectLocationSourcePatchCall) (response)
2215/// * [locations target projects create projects](ProjectLocationTargetProjectCreateCall) (response)
2216/// * [locations target projects delete projects](ProjectLocationTargetProjectDeleteCall) (response)
2217/// * [locations target projects patch projects](ProjectLocationTargetProjectPatchCall) (response)
2218#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2219#[serde_with::serde_as]
2220#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2221pub struct Operation {
2222 /// 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.
2223 pub done: Option<bool>,
2224 /// The error result of the operation in case of failure or cancellation.
2225 pub error: Option<Status>,
2226 /// 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.
2227 pub metadata: Option<HashMap<String, serde_json::Value>>,
2228 /// 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}`.
2229 pub name: Option<String>,
2230 /// 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`.
2231 pub response: Option<HashMap<String, serde_json::Value>>,
2232}
2233
2234impl common::ResponseResult for Operation {}
2235
2236/// Request message for ‘PauseMigration’ request.
2237///
2238/// # Activities
2239///
2240/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2241/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2242///
2243/// * [locations sources migrating vms pause migration projects](ProjectLocationSourceMigratingVmPauseMigrationCall) (request)
2244#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2245#[serde_with::serde_as]
2246#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2247pub struct PauseMigrationRequest {
2248 _never_set: Option<bool>,
2249}
2250
2251impl common::RequestValue for PauseMigrationRequest {}
2252
2253/// Details of a created Persistent Disk.
2254///
2255/// This type is not used in any activity, and only used as *part* of another schema.
2256///
2257#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2258#[serde_with::serde_as]
2259#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2260pub struct PersistentDisk {
2261 /// The URI of the Persistent Disk.
2262 #[serde(rename = "diskUri")]
2263 pub disk_uri: Option<String>,
2264 /// The ordinal number of the source VM disk.
2265 #[serde(rename = "sourceDiskNumber")]
2266 pub source_disk_number: Option<i32>,
2267}
2268
2269impl common::Part for PersistentDisk {}
2270
2271/// Details for creation of a Persistent Disk.
2272///
2273/// This type is not used in any activity, and only used as *part* of another schema.
2274///
2275#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2276#[serde_with::serde_as]
2277#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2278pub struct PersistentDiskDefaults {
2279 /// A map of labels to associate with the Persistent Disk.
2280 #[serde(rename = "additionalLabels")]
2281 pub additional_labels: Option<HashMap<String, String>>,
2282 /// Optional. The name of the Persistent Disk to create.
2283 #[serde(rename = "diskName")]
2284 pub disk_name: Option<String>,
2285 /// The disk type to use.
2286 #[serde(rename = "diskType")]
2287 pub disk_type: Option<String>,
2288 /// Optional. The encryption to apply to the disk.
2289 pub encryption: Option<Encryption>,
2290 /// Required. The ordinal number of the source VM disk.
2291 #[serde(rename = "sourceDiskNumber")]
2292 pub source_disk_number: Option<i32>,
2293 /// Optional. Details for attachment of the disk to a VM. Used when the disk is set to be attacked to a target VM.
2294 #[serde(rename = "vmAttachmentDetails")]
2295 pub vm_attachment_details: Option<VmAttachmentDetails>,
2296}
2297
2298impl common::Part for PersistentDiskDefaults {}
2299
2300/// PostProcessingStep contains specific step details.
2301///
2302/// This type is not used in any activity, and only used as *part* of another schema.
2303///
2304#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2305#[serde_with::serde_as]
2306#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2307pub struct PostProcessingStep {
2308 _never_set: Option<bool>,
2309}
2310
2311impl common::Part for PostProcessingStep {}
2312
2313/// PreparingVMDisksStep contains specific step details.
2314///
2315/// This type is not used in any activity, and only used as *part* of another schema.
2316///
2317#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2318#[serde_with::serde_as]
2319#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2320pub struct PreparingVMDisksStep {
2321 _never_set: Option<bool>,
2322}
2323
2324impl common::Part for PreparingVMDisksStep {}
2325
2326/// Request message for ‘RemoveMigration’ request.
2327///
2328/// # Activities
2329///
2330/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2331/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2332///
2333/// * [locations groups remove group migration projects](ProjectLocationGroupRemoveGroupMigrationCall) (request)
2334#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2335#[serde_with::serde_as]
2336#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2337pub struct RemoveGroupMigrationRequest {
2338 /// The MigratingVm to remove.
2339 #[serde(rename = "migratingVm")]
2340 pub migrating_vm: Option<String>,
2341}
2342
2343impl common::RequestValue for RemoveGroupMigrationRequest {}
2344
2345/// ReplicatingStep contains specific step details.
2346///
2347/// This type is not used in any activity, and only used as *part* of another schema.
2348///
2349#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2350#[serde_with::serde_as]
2351#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2352pub struct ReplicatingStep {
2353 /// The source disks replication rate for the last 30 minutes in bytes per second.
2354 #[serde(rename = "lastThirtyMinutesAverageBytesPerSecond")]
2355 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2356 pub last_thirty_minutes_average_bytes_per_second: Option<i64>,
2357 /// The source disks replication rate for the last 2 minutes in bytes per second.
2358 #[serde(rename = "lastTwoMinutesAverageBytesPerSecond")]
2359 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2360 pub last_two_minutes_average_bytes_per_second: Option<i64>,
2361 /// Replicated bytes in the step.
2362 #[serde(rename = "replicatedBytes")]
2363 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2364 pub replicated_bytes: Option<i64>,
2365 /// Total bytes to be handled in the step.
2366 #[serde(rename = "totalBytes")]
2367 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2368 pub total_bytes: Option<i64>,
2369}
2370
2371impl common::Part for ReplicatingStep {}
2372
2373/// ReplicationCycle contains information about the current replication cycle status.
2374///
2375/// # Activities
2376///
2377/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2378/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2379///
2380/// * [locations sources migrating vms replication cycles get projects](ProjectLocationSourceMigratingVmReplicationCycleGetCall) (response)
2381#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2382#[serde_with::serde_as]
2383#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2384pub struct ReplicationCycle {
2385 /// The cycle's ordinal number.
2386 #[serde(rename = "cycleNumber")]
2387 pub cycle_number: Option<i32>,
2388 /// The time the replication cycle has ended.
2389 #[serde(rename = "endTime")]
2390 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2391 /// Output only. Provides details on the state of the cycle in case of an error.
2392 pub error: Option<Status>,
2393 /// The identifier of the ReplicationCycle.
2394 pub name: Option<String>,
2395 /// The current progress in percentage of this cycle. Was replaced by 'steps' field, which breaks down the cycle progression more accurately.
2396 #[serde(rename = "progressPercent")]
2397 pub progress_percent: Option<i32>,
2398 /// The time the replication cycle has started.
2399 #[serde(rename = "startTime")]
2400 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2401 /// State of the ReplicationCycle.
2402 pub state: Option<String>,
2403 /// The cycle's steps list representing its progress.
2404 pub steps: Option<Vec<CycleStep>>,
2405 /// The accumulated duration the replication cycle was paused.
2406 #[serde(rename = "totalPauseDuration")]
2407 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
2408 pub total_pause_duration: Option<chrono::Duration>,
2409 /// Output only. Warnings that occurred during the cycle.
2410 pub warnings: Option<Vec<MigrationWarning>>,
2411}
2412
2413impl common::ResponseResult for ReplicationCycle {}
2414
2415/// ReplicationSync contain information about the last replica sync to the cloud.
2416///
2417/// This type is not used in any activity, and only used as *part* of another schema.
2418///
2419#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2420#[serde_with::serde_as]
2421#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2422pub struct ReplicationSync {
2423 /// The most updated snapshot created time in the source that finished replication.
2424 #[serde(rename = "lastSyncTime")]
2425 pub last_sync_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2426}
2427
2428impl common::Part for ReplicationSync {}
2429
2430/// Request message for ‘ResumeMigration’ request.
2431///
2432/// # Activities
2433///
2434/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2435/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2436///
2437/// * [locations sources migrating vms resume migration projects](ProjectLocationSourceMigratingVmResumeMigrationCall) (request)
2438#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2439#[serde_with::serde_as]
2440#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2441pub struct ResumeMigrationRequest {
2442 _never_set: Option<bool>,
2443}
2444
2445impl common::RequestValue for ResumeMigrationRequest {}
2446
2447/// A policy for scheduling replications.
2448///
2449/// This type is not used in any activity, and only used as *part* of another schema.
2450///
2451#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2452#[serde_with::serde_as]
2453#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2454pub struct SchedulePolicy {
2455 /// The idle duration between replication stages.
2456 #[serde(rename = "idleDuration")]
2457 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
2458 pub idle_duration: Option<chrono::Duration>,
2459 /// A flag to indicate whether to skip OS adaptation during the replication sync. OS adaptation is a process where the VM's operating system undergoes changes and adaptations to fully function on Compute Engine.
2460 #[serde(rename = "skipOsAdaptation")]
2461 pub skip_os_adaptation: Option<bool>,
2462}
2463
2464impl common::Part for SchedulePolicy {}
2465
2466/// Node Affinity: the configuration of desired nodes onto which this Instance could be scheduled. Based on https://cloud.google.com/compute/docs/reference/rest/v1/instances/setScheduling
2467///
2468/// This type is not used in any activity, and only used as *part* of another schema.
2469///
2470#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2471#[serde_with::serde_as]
2472#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2473pub struct SchedulingNodeAffinity {
2474 /// The label key of Node resource to reference.
2475 pub key: Option<String>,
2476 /// The operator to use for the node resources specified in the `values` parameter.
2477 pub operator: Option<String>,
2478 /// Corresponds to the label values of Node resource.
2479 pub values: Option<Vec<String>>,
2480}
2481
2482impl common::Part for SchedulingNodeAffinity {}
2483
2484/// ShuttingDownSourceVMStep contains specific step details.
2485///
2486/// This type is not used in any activity, and only used as *part* of another schema.
2487///
2488#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2489#[serde_with::serde_as]
2490#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2491pub struct ShuttingDownSourceVMStep {
2492 _never_set: Option<bool>,
2493}
2494
2495impl common::Part for ShuttingDownSourceVMStep {}
2496
2497/// Source message describes a specific vm migration Source resource. It contains the source environment information.
2498///
2499/// # Activities
2500///
2501/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2502/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2503///
2504/// * [locations sources create projects](ProjectLocationSourceCreateCall) (request)
2505/// * [locations sources get projects](ProjectLocationSourceGetCall) (response)
2506/// * [locations sources patch projects](ProjectLocationSourcePatchCall) (request)
2507#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2508#[serde_with::serde_as]
2509#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2510pub struct Source {
2511 /// AWS type source details.
2512 pub aws: Option<AwsSourceDetails>,
2513 /// Azure type source details.
2514 pub azure: Option<AzureSourceDetails>,
2515 /// Output only. The create time timestamp.
2516 #[serde(rename = "createTime")]
2517 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2518 /// User-provided description of the source.
2519 pub description: Option<String>,
2520 /// Optional. Immutable. The encryption details of the source data stored by the service.
2521 pub encryption: Option<Encryption>,
2522 /// The labels of the source.
2523 pub labels: Option<HashMap<String, String>>,
2524 /// Output only. The Source name.
2525 pub name: Option<String>,
2526 /// Output only. The update time timestamp.
2527 #[serde(rename = "updateTime")]
2528 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2529 /// Vmware type source details.
2530 pub vmware: Option<VmwareSourceDetails>,
2531}
2532
2533impl common::RequestValue for Source {}
2534impl common::ResponseResult for Source {}
2535
2536/// Request message for ‘StartMigrationRequest’ request.
2537///
2538/// # Activities
2539///
2540/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2541/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2542///
2543/// * [locations sources migrating vms start migration projects](ProjectLocationSourceMigratingVmStartMigrationCall) (request)
2544#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2545#[serde_with::serde_as]
2546#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2547pub struct StartMigrationRequest {
2548 _never_set: Option<bool>,
2549}
2550
2551impl common::RequestValue for StartMigrationRequest {}
2552
2553/// 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).
2554///
2555/// This type is not used in any activity, and only used as *part* of another schema.
2556///
2557#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2558#[serde_with::serde_as]
2559#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2560pub struct Status {
2561 /// The status code, which should be an enum value of google.rpc.Code.
2562 pub code: Option<i32>,
2563 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
2564 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
2565 /// 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.
2566 pub message: Option<String>,
2567}
2568
2569impl common::Part for Status {}
2570
2571/// Tag is an AWS tag representation.
2572///
2573/// This type is not used in any activity, and only used as *part* of another schema.
2574///
2575#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2576#[serde_with::serde_as]
2577#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2578pub struct Tag {
2579 /// Required. Key of tag.
2580 pub key: Option<String>,
2581 /// Required. Value of tag.
2582 pub value: Option<String>,
2583}
2584
2585impl common::Part for Tag {}
2586
2587/// TargetProject message represents a target Compute Engine project for a migration or a clone.
2588///
2589/// # Activities
2590///
2591/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2592/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2593///
2594/// * [locations target projects create projects](ProjectLocationTargetProjectCreateCall) (request)
2595/// * [locations target projects get projects](ProjectLocationTargetProjectGetCall) (response)
2596/// * [locations target projects patch projects](ProjectLocationTargetProjectPatchCall) (request)
2597#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2598#[serde_with::serde_as]
2599#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2600pub struct TargetProject {
2601 /// Output only. The time this target project resource was created (not related to when the Compute Engine project it points to was created).
2602 #[serde(rename = "createTime")]
2603 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2604 /// The target project's description.
2605 pub description: Option<String>,
2606 /// Output only. The name of the target project.
2607 pub name: Option<String>,
2608 /// Required. The target project ID (number) or project name.
2609 pub project: Option<String>,
2610 /// Output only. The last time the target project resource was updated.
2611 #[serde(rename = "updateTime")]
2612 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2613}
2614
2615impl common::RequestValue for TargetProject {}
2616impl common::ResponseResult for TargetProject {}
2617
2618/// Request message for ‘UpgradeAppliance’ request.
2619///
2620/// # Activities
2621///
2622/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2623/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2624///
2625/// * [locations sources datacenter connectors upgrade appliance projects](ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall) (request)
2626#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2627#[serde_with::serde_as]
2628#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2629pub struct UpgradeApplianceRequest {
2630 /// A request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes after the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
2631 #[serde(rename = "requestId")]
2632 pub request_id: Option<String>,
2633}
2634
2635impl common::RequestValue for UpgradeApplianceRequest {}
2636
2637/// UpgradeStatus contains information about upgradeAppliance operation.
2638///
2639/// This type is not used in any activity, and only used as *part* of another schema.
2640///
2641#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2642#[serde_with::serde_as]
2643#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2644pub struct UpgradeStatus {
2645 /// Output only. Provides details on the state of the upgrade operation in case of an error.
2646 pub error: Option<Status>,
2647 /// The version from which we upgraded.
2648 #[serde(rename = "previousVersion")]
2649 pub previous_version: Option<String>,
2650 /// The time the operation was started.
2651 #[serde(rename = "startTime")]
2652 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2653 /// The state of the upgradeAppliance operation.
2654 pub state: Option<String>,
2655 /// The version to upgrade to.
2656 pub version: Option<String>,
2657}
2658
2659impl common::Part for UpgradeStatus {}
2660
2661/// Utilization report details the utilization (CPU, memory, etc.) of selected source VMs.
2662///
2663/// # Activities
2664///
2665/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2666/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2667///
2668/// * [locations sources utilization reports create projects](ProjectLocationSourceUtilizationReportCreateCall) (request)
2669/// * [locations sources utilization reports get projects](ProjectLocationSourceUtilizationReportGetCall) (response)
2670#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2671#[serde_with::serde_as]
2672#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2673pub struct UtilizationReport {
2674 /// Output only. The time the report was created (this refers to the time of the request, not the time the report creation completed).
2675 #[serde(rename = "createTime")]
2676 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2677 /// The report display name, as assigned by the user.
2678 #[serde(rename = "displayName")]
2679 pub display_name: Option<String>,
2680 /// Output only. Provides details on the state of the report in case of an error.
2681 pub error: Option<Status>,
2682 /// Output only. The point in time when the time frame ends. Notice that the time frame is counted backwards. For instance if the "frame_end_time" value is 2021/01/20 and the time frame is WEEK then the report covers the week between 2021/01/20 and 2021/01/14.
2683 #[serde(rename = "frameEndTime")]
2684 pub frame_end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2685 /// Output only. The report unique name.
2686 pub name: Option<String>,
2687 /// Output only. Current state of the report.
2688 pub state: Option<String>,
2689 /// Output only. The time the state was last set.
2690 #[serde(rename = "stateTime")]
2691 pub state_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2692 /// Time frame of the report.
2693 #[serde(rename = "timeFrame")]
2694 pub time_frame: Option<String>,
2695 /// Output only. Total number of VMs included in the report.
2696 #[serde(rename = "vmCount")]
2697 pub vm_count: Option<i32>,
2698 /// List of utilization information per VM. When sent as part of the request, the "vm_id" field is used in order to specify which VMs to include in the report. In that case all other fields are ignored.
2699 pub vms: Option<Vec<VmUtilizationInfo>>,
2700}
2701
2702impl common::RequestValue for UtilizationReport {}
2703impl common::ResponseResult for UtilizationReport {}
2704
2705/// Details for attachment of the disk to a VM.
2706///
2707/// This type is not used in any activity, and only used as *part* of another schema.
2708///
2709#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2710#[serde_with::serde_as]
2711#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2712pub struct VmAttachmentDetails {
2713 /// Optional. Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* tree of a Linux operating system running within the instance. If not specified, the server chooses a default device name to apply to this disk, in the form persistent-disk-x, where x is a number assigned by Google Compute Engine. This field is only applicable for persistent disks.
2714 #[serde(rename = "deviceName")]
2715 pub device_name: Option<String>,
2716}
2717
2718impl common::Part for VmAttachmentDetails {}
2719
2720/// Migrating VM source information about the VM capabilities needed for some Compute Engine features.
2721///
2722/// This type is not used in any activity, and only used as *part* of another schema.
2723///
2724#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2725#[serde_with::serde_as]
2726#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2727pub struct VmCapabilities {
2728 /// Output only. The last time OS capabilities list was updated.
2729 #[serde(rename = "lastOsCapabilitiesUpdateTime")]
2730 pub last_os_capabilities_update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2731 /// Output only. Unordered list. List of certain VM OS capabilities needed for some Compute Engine features.
2732 #[serde(rename = "osCapabilities")]
2733 pub os_capabilities: Option<Vec<String>>,
2734}
2735
2736impl common::Part for VmCapabilities {}
2737
2738/// Utilization information of a single VM.
2739///
2740/// This type is not used in any activity, and only used as *part* of another schema.
2741///
2742#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2743#[serde_with::serde_as]
2744#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2745pub struct VmUtilizationInfo {
2746 /// Utilization metrics for this VM.
2747 pub utilization: Option<VmUtilizationMetrics>,
2748 /// The VM's ID in the source.
2749 #[serde(rename = "vmId")]
2750 pub vm_id: Option<String>,
2751 /// The description of the VM in a Source of type Vmware.
2752 #[serde(rename = "vmwareVmDetails")]
2753 pub vmware_vm_details: Option<VmwareVmDetails>,
2754}
2755
2756impl common::Part for VmUtilizationInfo {}
2757
2758/// Utilization metrics values for a single VM.
2759///
2760/// This type is not used in any activity, and only used as *part* of another schema.
2761///
2762#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2763#[serde_with::serde_as]
2764#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2765pub struct VmUtilizationMetrics {
2766 /// Average CPU usage, percent.
2767 #[serde(rename = "cpuAveragePercent")]
2768 pub cpu_average_percent: Option<i32>,
2769 /// Max CPU usage, percent.
2770 #[serde(rename = "cpuMaxPercent")]
2771 pub cpu_max_percent: Option<i32>,
2772 /// Average disk IO rate, in kilobytes per second.
2773 #[serde(rename = "diskIoRateAverageKbps")]
2774 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2775 pub disk_io_rate_average_kbps: Option<i64>,
2776 /// Max disk IO rate, in kilobytes per second.
2777 #[serde(rename = "diskIoRateMaxKbps")]
2778 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2779 pub disk_io_rate_max_kbps: Option<i64>,
2780 /// Average memory usage, percent.
2781 #[serde(rename = "memoryAveragePercent")]
2782 pub memory_average_percent: Option<i32>,
2783 /// Max memory usage, percent.
2784 #[serde(rename = "memoryMaxPercent")]
2785 pub memory_max_percent: Option<i32>,
2786 /// Average network throughput (combined transmit-rates and receive-rates), in kilobytes per second.
2787 #[serde(rename = "networkThroughputAverageKbps")]
2788 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2789 pub network_throughput_average_kbps: Option<i64>,
2790 /// Max network throughput (combined transmit-rates and receive-rates), in kilobytes per second.
2791 #[serde(rename = "networkThroughputMaxKbps")]
2792 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2793 pub network_throughput_max_kbps: Option<i64>,
2794}
2795
2796impl common::Part for VmUtilizationMetrics {}
2797
2798/// The details of a Vmware VM disk.
2799///
2800/// This type is not used in any activity, and only used as *part* of another schema.
2801///
2802#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2803#[serde_with::serde_as]
2804#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2805pub struct VmwareDiskDetails {
2806 /// Output only. The ordinal number of the disk.
2807 #[serde(rename = "diskNumber")]
2808 pub disk_number: Option<i32>,
2809 /// Output only. The disk label.
2810 pub label: Option<String>,
2811 /// Output only. Size in GB.
2812 #[serde(rename = "sizeGb")]
2813 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2814 pub size_gb: Option<i64>,
2815}
2816
2817impl common::Part for VmwareDiskDetails {}
2818
2819/// VmwareSourceDetails message describes a specific source details for the vmware source type.
2820///
2821/// This type is not used in any activity, and only used as *part* of another schema.
2822///
2823#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2824#[serde_with::serde_as]
2825#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2826pub struct VmwareSourceDetails {
2827 /// Input only. The credentials password. This is write only and can not be read in a GET operation.
2828 pub password: Option<String>,
2829 /// The hostname of the vcenter.
2830 #[serde(rename = "resolvedVcenterHost")]
2831 pub resolved_vcenter_host: Option<String>,
2832 /// The thumbprint representing the certificate for the vcenter.
2833 pub thumbprint: Option<String>,
2834 /// The credentials username.
2835 pub username: Option<String>,
2836 /// The ip address of the vcenter this Source represents.
2837 #[serde(rename = "vcenterIp")]
2838 pub vcenter_ip: Option<String>,
2839}
2840
2841impl common::Part for VmwareSourceDetails {}
2842
2843/// Represent the source Vmware VM details.
2844///
2845/// This type is not used in any activity, and only used as *part* of another schema.
2846///
2847#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2848#[serde_with::serde_as]
2849#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2850pub struct VmwareSourceVmDetails {
2851 /// Output only. The total size of the disks being migrated in bytes.
2852 #[serde(rename = "committedStorageBytes")]
2853 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2854 pub committed_storage_bytes: Option<i64>,
2855 /// Output only. The disks attached to the source VM.
2856 pub disks: Option<Vec<VmwareDiskDetails>>,
2857 /// Output only. The firmware type of the source VM.
2858 pub firmware: Option<String>,
2859 /// Output only. Information about VM capabilities needed for some Compute Engine features.
2860 #[serde(rename = "vmCapabilitiesInfo")]
2861 pub vm_capabilities_info: Option<VmCapabilities>,
2862}
2863
2864impl common::Part for VmwareSourceVmDetails {}
2865
2866/// VmwareVmDetails describes a VM in vCenter.
2867///
2868/// This type is not used in any activity, and only used as *part* of another schema.
2869///
2870#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2871#[serde_with::serde_as]
2872#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2873pub struct VmwareVmDetails {
2874 /// Output only. The VM Boot Option.
2875 #[serde(rename = "bootOption")]
2876 pub boot_option: Option<String>,
2877 /// The total size of the storage allocated to the VM in MB.
2878 #[serde(rename = "committedStorageMb")]
2879 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2880 pub committed_storage_mb: Option<i64>,
2881 /// The number of cpus in the VM.
2882 #[serde(rename = "cpuCount")]
2883 pub cpu_count: Option<i32>,
2884 /// The descriptive name of the vCenter's datacenter this VM is contained in.
2885 #[serde(rename = "datacenterDescription")]
2886 pub datacenter_description: Option<String>,
2887 /// The id of the vCenter's datacenter this VM is contained in.
2888 #[serde(rename = "datacenterId")]
2889 pub datacenter_id: Option<String>,
2890 /// The number of disks the VM has.
2891 #[serde(rename = "diskCount")]
2892 pub disk_count: Option<i32>,
2893 /// The display name of the VM. Note that this is not necessarily unique.
2894 #[serde(rename = "displayName")]
2895 pub display_name: Option<String>,
2896 /// The VM's OS. See for example https://vdc-repo.vmware.com/vmwb-repository/dcr-public/da47f910-60ac-438b-8b9b-6122f4d14524/16b7274a-bf8b-4b4c-a05e-746f2aa93c8c/doc/vim.vm.GuestOsDescriptor.GuestOsIdentifier.html for types of strings this might hold.
2897 #[serde(rename = "guestDescription")]
2898 pub guest_description: Option<String>,
2899 /// The size of the memory of the VM in MB.
2900 #[serde(rename = "memoryMb")]
2901 pub memory_mb: Option<i32>,
2902 /// The power state of the VM at the moment list was taken.
2903 #[serde(rename = "powerState")]
2904 pub power_state: Option<String>,
2905 /// The unique identifier of the VM in vCenter.
2906 pub uuid: Option<String>,
2907 /// The VM's id in the source (note that this is not the MigratingVm's id). This is the moref id of the VM.
2908 #[serde(rename = "vmId")]
2909 pub vm_id: Option<String>,
2910}
2911
2912impl common::Part for VmwareVmDetails {}
2913
2914/// VmwareVmsDetails describes VMs in vCenter.
2915///
2916/// This type is not used in any activity, and only used as *part* of another schema.
2917///
2918#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2919#[serde_with::serde_as]
2920#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2921pub struct VmwareVmsDetails {
2922 /// The details of the vmware VMs.
2923 pub details: Option<Vec<VmwareVmDetails>>,
2924}
2925
2926impl common::Part for VmwareVmsDetails {}
2927
2928// ###################
2929// MethodBuilders ###
2930// #################
2931
2932/// A builder providing access to all methods supported on *project* resources.
2933/// It is not used directly, but through the [`VMMigrationService`] hub.
2934///
2935/// # Example
2936///
2937/// Instantiate a resource builder
2938///
2939/// ```test_harness,no_run
2940/// extern crate hyper;
2941/// extern crate hyper_rustls;
2942/// extern crate google_vmmigration1 as vmmigration1;
2943///
2944/// # async fn dox() {
2945/// use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2946///
2947/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2948/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2949/// secret,
2950/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2951/// ).build().await.unwrap();
2952///
2953/// let client = hyper_util::client::legacy::Client::builder(
2954/// hyper_util::rt::TokioExecutor::new()
2955/// )
2956/// .build(
2957/// hyper_rustls::HttpsConnectorBuilder::new()
2958/// .with_native_roots()
2959/// .unwrap()
2960/// .https_or_http()
2961/// .enable_http1()
2962/// .build()
2963/// );
2964/// let mut hub = VMMigrationService::new(client, auth);
2965/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2966/// // like `locations_get(...)`, `locations_groups_add_group_migration(...)`, `locations_groups_create(...)`, `locations_groups_delete(...)`, `locations_groups_get(...)`, `locations_groups_list(...)`, `locations_groups_patch(...)`, `locations_groups_remove_group_migration(...)`, `locations_image_imports_create(...)`, `locations_image_imports_delete(...)`, `locations_image_imports_get(...)`, `locations_image_imports_image_import_jobs_cancel(...)`, `locations_image_imports_image_import_jobs_get(...)`, `locations_image_imports_image_import_jobs_list(...)`, `locations_image_imports_list(...)`, `locations_list(...)`, `locations_operations_cancel(...)`, `locations_operations_delete(...)`, `locations_operations_get(...)`, `locations_operations_list(...)`, `locations_sources_create(...)`, `locations_sources_datacenter_connectors_create(...)`, `locations_sources_datacenter_connectors_delete(...)`, `locations_sources_datacenter_connectors_get(...)`, `locations_sources_datacenter_connectors_list(...)`, `locations_sources_datacenter_connectors_upgrade_appliance(...)`, `locations_sources_delete(...)`, `locations_sources_fetch_inventory(...)`, `locations_sources_get(...)`, `locations_sources_list(...)`, `locations_sources_migrating_vms_clone_jobs_cancel(...)`, `locations_sources_migrating_vms_clone_jobs_create(...)`, `locations_sources_migrating_vms_clone_jobs_get(...)`, `locations_sources_migrating_vms_clone_jobs_list(...)`, `locations_sources_migrating_vms_create(...)`, `locations_sources_migrating_vms_cutover_jobs_cancel(...)`, `locations_sources_migrating_vms_cutover_jobs_create(...)`, `locations_sources_migrating_vms_cutover_jobs_get(...)`, `locations_sources_migrating_vms_cutover_jobs_list(...)`, `locations_sources_migrating_vms_delete(...)`, `locations_sources_migrating_vms_finalize_migration(...)`, `locations_sources_migrating_vms_get(...)`, `locations_sources_migrating_vms_list(...)`, `locations_sources_migrating_vms_patch(...)`, `locations_sources_migrating_vms_pause_migration(...)`, `locations_sources_migrating_vms_replication_cycles_get(...)`, `locations_sources_migrating_vms_replication_cycles_list(...)`, `locations_sources_migrating_vms_resume_migration(...)`, `locations_sources_migrating_vms_start_migration(...)`, `locations_sources_patch(...)`, `locations_sources_utilization_reports_create(...)`, `locations_sources_utilization_reports_delete(...)`, `locations_sources_utilization_reports_get(...)`, `locations_sources_utilization_reports_list(...)`, `locations_target_projects_create(...)`, `locations_target_projects_delete(...)`, `locations_target_projects_get(...)`, `locations_target_projects_list(...)` and `locations_target_projects_patch(...)`
2967/// // to build up your call.
2968/// let rb = hub.projects();
2969/// # }
2970/// ```
2971pub struct ProjectMethods<'a, C>
2972where
2973 C: 'a,
2974{
2975 hub: &'a VMMigrationService<C>,
2976}
2977
2978impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
2979
2980impl<'a, C> ProjectMethods<'a, C> {
2981 /// Create a builder to help you perform the following task:
2982 ///
2983 /// Adds a MigratingVm to a Group.
2984 ///
2985 /// # Arguments
2986 ///
2987 /// * `request` - No description provided.
2988 /// * `group` - Required. The full path name of the Group to add to.
2989 pub fn locations_groups_add_group_migration(
2990 &self,
2991 request: AddGroupMigrationRequest,
2992 group: &str,
2993 ) -> ProjectLocationGroupAddGroupMigrationCall<'a, C> {
2994 ProjectLocationGroupAddGroupMigrationCall {
2995 hub: self.hub,
2996 _request: request,
2997 _group: group.to_string(),
2998 _delegate: Default::default(),
2999 _additional_params: Default::default(),
3000 _scopes: Default::default(),
3001 }
3002 }
3003
3004 /// Create a builder to help you perform the following task:
3005 ///
3006 /// Creates a new Group in a given project and location.
3007 ///
3008 /// # Arguments
3009 ///
3010 /// * `request` - No description provided.
3011 /// * `parent` - Required. The Group's parent.
3012 pub fn locations_groups_create(
3013 &self,
3014 request: Group,
3015 parent: &str,
3016 ) -> ProjectLocationGroupCreateCall<'a, C> {
3017 ProjectLocationGroupCreateCall {
3018 hub: self.hub,
3019 _request: request,
3020 _parent: parent.to_string(),
3021 _request_id: Default::default(),
3022 _group_id: Default::default(),
3023 _delegate: Default::default(),
3024 _additional_params: Default::default(),
3025 _scopes: Default::default(),
3026 }
3027 }
3028
3029 /// Create a builder to help you perform the following task:
3030 ///
3031 /// Deletes a single Group.
3032 ///
3033 /// # Arguments
3034 ///
3035 /// * `name` - Required. The Group name.
3036 pub fn locations_groups_delete(&self, name: &str) -> ProjectLocationGroupDeleteCall<'a, C> {
3037 ProjectLocationGroupDeleteCall {
3038 hub: self.hub,
3039 _name: name.to_string(),
3040 _request_id: Default::default(),
3041 _delegate: Default::default(),
3042 _additional_params: Default::default(),
3043 _scopes: Default::default(),
3044 }
3045 }
3046
3047 /// Create a builder to help you perform the following task:
3048 ///
3049 /// Gets details of a single Group.
3050 ///
3051 /// # Arguments
3052 ///
3053 /// * `name` - Required. The group name.
3054 pub fn locations_groups_get(&self, name: &str) -> ProjectLocationGroupGetCall<'a, C> {
3055 ProjectLocationGroupGetCall {
3056 hub: self.hub,
3057 _name: name.to_string(),
3058 _delegate: Default::default(),
3059 _additional_params: Default::default(),
3060 _scopes: Default::default(),
3061 }
3062 }
3063
3064 /// Create a builder to help you perform the following task:
3065 ///
3066 /// Lists Groups in a given project and location.
3067 ///
3068 /// # Arguments
3069 ///
3070 /// * `parent` - Required. The parent, which owns this collection of groups.
3071 pub fn locations_groups_list(&self, parent: &str) -> ProjectLocationGroupListCall<'a, C> {
3072 ProjectLocationGroupListCall {
3073 hub: self.hub,
3074 _parent: parent.to_string(),
3075 _page_token: Default::default(),
3076 _page_size: Default::default(),
3077 _order_by: Default::default(),
3078 _filter: Default::default(),
3079 _delegate: Default::default(),
3080 _additional_params: Default::default(),
3081 _scopes: Default::default(),
3082 }
3083 }
3084
3085 /// Create a builder to help you perform the following task:
3086 ///
3087 /// Updates the parameters of a single Group.
3088 ///
3089 /// # Arguments
3090 ///
3091 /// * `request` - No description provided.
3092 /// * `name` - Output only. The Group name.
3093 pub fn locations_groups_patch(
3094 &self,
3095 request: Group,
3096 name: &str,
3097 ) -> ProjectLocationGroupPatchCall<'a, C> {
3098 ProjectLocationGroupPatchCall {
3099 hub: self.hub,
3100 _request: request,
3101 _name: name.to_string(),
3102 _update_mask: Default::default(),
3103 _request_id: Default::default(),
3104 _delegate: Default::default(),
3105 _additional_params: Default::default(),
3106 _scopes: Default::default(),
3107 }
3108 }
3109
3110 /// Create a builder to help you perform the following task:
3111 ///
3112 /// Removes a MigratingVm from a Group.
3113 ///
3114 /// # Arguments
3115 ///
3116 /// * `request` - No description provided.
3117 /// * `group` - Required. The name of the Group.
3118 pub fn locations_groups_remove_group_migration(
3119 &self,
3120 request: RemoveGroupMigrationRequest,
3121 group: &str,
3122 ) -> ProjectLocationGroupRemoveGroupMigrationCall<'a, C> {
3123 ProjectLocationGroupRemoveGroupMigrationCall {
3124 hub: self.hub,
3125 _request: request,
3126 _group: group.to_string(),
3127 _delegate: Default::default(),
3128 _additional_params: Default::default(),
3129 _scopes: Default::default(),
3130 }
3131 }
3132
3133 /// Create a builder to help you perform the following task:
3134 ///
3135 /// Initiates the cancellation of a running clone job.
3136 ///
3137 /// # Arguments
3138 ///
3139 /// * `request` - No description provided.
3140 /// * `name` - Required. The image import job id.
3141 pub fn locations_image_imports_image_import_jobs_cancel(
3142 &self,
3143 request: CancelImageImportJobRequest,
3144 name: &str,
3145 ) -> ProjectLocationImageImportImageImportJobCancelCall<'a, C> {
3146 ProjectLocationImageImportImageImportJobCancelCall {
3147 hub: self.hub,
3148 _request: request,
3149 _name: name.to_string(),
3150 _delegate: Default::default(),
3151 _additional_params: Default::default(),
3152 _scopes: Default::default(),
3153 }
3154 }
3155
3156 /// Create a builder to help you perform the following task:
3157 ///
3158 /// Gets details of a single ImageImportJob.
3159 ///
3160 /// # Arguments
3161 ///
3162 /// * `name` - Required. The ImageImportJob name.
3163 pub fn locations_image_imports_image_import_jobs_get(
3164 &self,
3165 name: &str,
3166 ) -> ProjectLocationImageImportImageImportJobGetCall<'a, C> {
3167 ProjectLocationImageImportImageImportJobGetCall {
3168 hub: self.hub,
3169 _name: name.to_string(),
3170 _delegate: Default::default(),
3171 _additional_params: Default::default(),
3172 _scopes: Default::default(),
3173 }
3174 }
3175
3176 /// Create a builder to help you perform the following task:
3177 ///
3178 /// Lists ImageImportJobs in a given project.
3179 ///
3180 /// # Arguments
3181 ///
3182 /// * `parent` - Required. The parent, which owns this collection of targets.
3183 pub fn locations_image_imports_image_import_jobs_list(
3184 &self,
3185 parent: &str,
3186 ) -> ProjectLocationImageImportImageImportJobListCall<'a, C> {
3187 ProjectLocationImageImportImageImportJobListCall {
3188 hub: self.hub,
3189 _parent: parent.to_string(),
3190 _page_token: Default::default(),
3191 _page_size: Default::default(),
3192 _order_by: Default::default(),
3193 _filter: Default::default(),
3194 _delegate: Default::default(),
3195 _additional_params: Default::default(),
3196 _scopes: Default::default(),
3197 }
3198 }
3199
3200 /// Create a builder to help you perform the following task:
3201 ///
3202 /// Creates a new ImageImport in a given project.
3203 ///
3204 /// # Arguments
3205 ///
3206 /// * `request` - No description provided.
3207 /// * `parent` - Required. The ImageImport's parent.
3208 pub fn locations_image_imports_create(
3209 &self,
3210 request: ImageImport,
3211 parent: &str,
3212 ) -> ProjectLocationImageImportCreateCall<'a, C> {
3213 ProjectLocationImageImportCreateCall {
3214 hub: self.hub,
3215 _request: request,
3216 _parent: parent.to_string(),
3217 _request_id: Default::default(),
3218 _image_import_id: Default::default(),
3219 _delegate: Default::default(),
3220 _additional_params: Default::default(),
3221 _scopes: Default::default(),
3222 }
3223 }
3224
3225 /// Create a builder to help you perform the following task:
3226 ///
3227 /// Deletes a single ImageImport.
3228 ///
3229 /// # Arguments
3230 ///
3231 /// * `name` - Required. The ImageImport name.
3232 pub fn locations_image_imports_delete(
3233 &self,
3234 name: &str,
3235 ) -> ProjectLocationImageImportDeleteCall<'a, C> {
3236 ProjectLocationImageImportDeleteCall {
3237 hub: self.hub,
3238 _name: name.to_string(),
3239 _request_id: Default::default(),
3240 _delegate: Default::default(),
3241 _additional_params: Default::default(),
3242 _scopes: Default::default(),
3243 }
3244 }
3245
3246 /// Create a builder to help you perform the following task:
3247 ///
3248 /// Gets details of a single ImageImport.
3249 ///
3250 /// # Arguments
3251 ///
3252 /// * `name` - Required. The ImageImport name.
3253 pub fn locations_image_imports_get(
3254 &self,
3255 name: &str,
3256 ) -> ProjectLocationImageImportGetCall<'a, C> {
3257 ProjectLocationImageImportGetCall {
3258 hub: self.hub,
3259 _name: name.to_string(),
3260 _delegate: Default::default(),
3261 _additional_params: Default::default(),
3262 _scopes: Default::default(),
3263 }
3264 }
3265
3266 /// Create a builder to help you perform the following task:
3267 ///
3268 /// Lists ImageImports in a given project.
3269 ///
3270 /// # Arguments
3271 ///
3272 /// * `parent` - Required. The parent, which owns this collection of targets.
3273 pub fn locations_image_imports_list(
3274 &self,
3275 parent: &str,
3276 ) -> ProjectLocationImageImportListCall<'a, C> {
3277 ProjectLocationImageImportListCall {
3278 hub: self.hub,
3279 _parent: parent.to_string(),
3280 _page_token: Default::default(),
3281 _page_size: Default::default(),
3282 _order_by: Default::default(),
3283 _filter: Default::default(),
3284 _delegate: Default::default(),
3285 _additional_params: Default::default(),
3286 _scopes: Default::default(),
3287 }
3288 }
3289
3290 /// Create a builder to help you perform the following task:
3291 ///
3292 /// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`.
3293 ///
3294 /// # Arguments
3295 ///
3296 /// * `request` - No description provided.
3297 /// * `name` - The name of the operation resource to be cancelled.
3298 pub fn locations_operations_cancel(
3299 &self,
3300 request: CancelOperationRequest,
3301 name: &str,
3302 ) -> ProjectLocationOperationCancelCall<'a, C> {
3303 ProjectLocationOperationCancelCall {
3304 hub: self.hub,
3305 _request: request,
3306 _name: name.to_string(),
3307 _delegate: Default::default(),
3308 _additional_params: Default::default(),
3309 _scopes: Default::default(),
3310 }
3311 }
3312
3313 /// Create a builder to help you perform the following task:
3314 ///
3315 /// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
3316 ///
3317 /// # Arguments
3318 ///
3319 /// * `name` - The name of the operation resource to be deleted.
3320 pub fn locations_operations_delete(
3321 &self,
3322 name: &str,
3323 ) -> ProjectLocationOperationDeleteCall<'a, C> {
3324 ProjectLocationOperationDeleteCall {
3325 hub: self.hub,
3326 _name: name.to_string(),
3327 _delegate: Default::default(),
3328 _additional_params: Default::default(),
3329 _scopes: Default::default(),
3330 }
3331 }
3332
3333 /// Create a builder to help you perform the following task:
3334 ///
3335 /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
3336 ///
3337 /// # Arguments
3338 ///
3339 /// * `name` - The name of the operation resource.
3340 pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
3341 ProjectLocationOperationGetCall {
3342 hub: self.hub,
3343 _name: name.to_string(),
3344 _delegate: Default::default(),
3345 _additional_params: Default::default(),
3346 _scopes: Default::default(),
3347 }
3348 }
3349
3350 /// Create a builder to help you perform the following task:
3351 ///
3352 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
3353 ///
3354 /// # Arguments
3355 ///
3356 /// * `name` - The name of the operation's parent resource.
3357 pub fn locations_operations_list(&self, name: &str) -> ProjectLocationOperationListCall<'a, C> {
3358 ProjectLocationOperationListCall {
3359 hub: self.hub,
3360 _name: name.to_string(),
3361 _page_token: Default::default(),
3362 _page_size: Default::default(),
3363 _filter: Default::default(),
3364 _delegate: Default::default(),
3365 _additional_params: Default::default(),
3366 _scopes: Default::default(),
3367 }
3368 }
3369
3370 /// Create a builder to help you perform the following task:
3371 ///
3372 /// Creates a new DatacenterConnector in a given Source.
3373 ///
3374 /// # Arguments
3375 ///
3376 /// * `request` - No description provided.
3377 /// * `parent` - Required. The DatacenterConnector's parent. Required. The Source in where the new DatacenterConnector will be created. For example: `projects/my-project/locations/us-central1/sources/my-source`
3378 pub fn locations_sources_datacenter_connectors_create(
3379 &self,
3380 request: DatacenterConnector,
3381 parent: &str,
3382 ) -> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C> {
3383 ProjectLocationSourceDatacenterConnectorCreateCall {
3384 hub: self.hub,
3385 _request: request,
3386 _parent: parent.to_string(),
3387 _request_id: Default::default(),
3388 _datacenter_connector_id: Default::default(),
3389 _delegate: Default::default(),
3390 _additional_params: Default::default(),
3391 _scopes: Default::default(),
3392 }
3393 }
3394
3395 /// Create a builder to help you perform the following task:
3396 ///
3397 /// Deletes a single DatacenterConnector.
3398 ///
3399 /// # Arguments
3400 ///
3401 /// * `name` - Required. The DatacenterConnector name.
3402 pub fn locations_sources_datacenter_connectors_delete(
3403 &self,
3404 name: &str,
3405 ) -> ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C> {
3406 ProjectLocationSourceDatacenterConnectorDeleteCall {
3407 hub: self.hub,
3408 _name: name.to_string(),
3409 _request_id: Default::default(),
3410 _delegate: Default::default(),
3411 _additional_params: Default::default(),
3412 _scopes: Default::default(),
3413 }
3414 }
3415
3416 /// Create a builder to help you perform the following task:
3417 ///
3418 /// Gets details of a single DatacenterConnector.
3419 ///
3420 /// # Arguments
3421 ///
3422 /// * `name` - Required. The name of the DatacenterConnector.
3423 pub fn locations_sources_datacenter_connectors_get(
3424 &self,
3425 name: &str,
3426 ) -> ProjectLocationSourceDatacenterConnectorGetCall<'a, C> {
3427 ProjectLocationSourceDatacenterConnectorGetCall {
3428 hub: self.hub,
3429 _name: name.to_string(),
3430 _delegate: Default::default(),
3431 _additional_params: Default::default(),
3432 _scopes: Default::default(),
3433 }
3434 }
3435
3436 /// Create a builder to help you perform the following task:
3437 ///
3438 /// Lists DatacenterConnectors in a given Source.
3439 ///
3440 /// # Arguments
3441 ///
3442 /// * `parent` - Required. The parent, which owns this collection of connectors.
3443 pub fn locations_sources_datacenter_connectors_list(
3444 &self,
3445 parent: &str,
3446 ) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C> {
3447 ProjectLocationSourceDatacenterConnectorListCall {
3448 hub: self.hub,
3449 _parent: parent.to_string(),
3450 _page_token: Default::default(),
3451 _page_size: Default::default(),
3452 _order_by: Default::default(),
3453 _filter: Default::default(),
3454 _delegate: Default::default(),
3455 _additional_params: Default::default(),
3456 _scopes: Default::default(),
3457 }
3458 }
3459
3460 /// Create a builder to help you perform the following task:
3461 ///
3462 /// Upgrades the appliance relate to this DatacenterConnector to the in-place updateable version.
3463 ///
3464 /// # Arguments
3465 ///
3466 /// * `request` - No description provided.
3467 /// * `datacenterConnector` - Required. The DatacenterConnector name.
3468 pub fn locations_sources_datacenter_connectors_upgrade_appliance(
3469 &self,
3470 request: UpgradeApplianceRequest,
3471 datacenter_connector: &str,
3472 ) -> ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C> {
3473 ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall {
3474 hub: self.hub,
3475 _request: request,
3476 _datacenter_connector: datacenter_connector.to_string(),
3477 _delegate: Default::default(),
3478 _additional_params: Default::default(),
3479 _scopes: Default::default(),
3480 }
3481 }
3482
3483 /// Create a builder to help you perform the following task:
3484 ///
3485 /// Initiates the cancellation of a running clone job.
3486 ///
3487 /// # Arguments
3488 ///
3489 /// * `request` - No description provided.
3490 /// * `name` - Required. The clone job id
3491 pub fn locations_sources_migrating_vms_clone_jobs_cancel(
3492 &self,
3493 request: CancelCloneJobRequest,
3494 name: &str,
3495 ) -> ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C> {
3496 ProjectLocationSourceMigratingVmCloneJobCancelCall {
3497 hub: self.hub,
3498 _request: request,
3499 _name: name.to_string(),
3500 _delegate: Default::default(),
3501 _additional_params: Default::default(),
3502 _scopes: Default::default(),
3503 }
3504 }
3505
3506 /// Create a builder to help you perform the following task:
3507 ///
3508 /// Initiates a Clone of a specific migrating VM.
3509 ///
3510 /// # Arguments
3511 ///
3512 /// * `request` - No description provided.
3513 /// * `parent` - Required. The Clone's parent.
3514 pub fn locations_sources_migrating_vms_clone_jobs_create(
3515 &self,
3516 request: CloneJob,
3517 parent: &str,
3518 ) -> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C> {
3519 ProjectLocationSourceMigratingVmCloneJobCreateCall {
3520 hub: self.hub,
3521 _request: request,
3522 _parent: parent.to_string(),
3523 _request_id: Default::default(),
3524 _clone_job_id: Default::default(),
3525 _delegate: Default::default(),
3526 _additional_params: Default::default(),
3527 _scopes: Default::default(),
3528 }
3529 }
3530
3531 /// Create a builder to help you perform the following task:
3532 ///
3533 /// Gets details of a single CloneJob.
3534 ///
3535 /// # Arguments
3536 ///
3537 /// * `name` - Required. The name of the CloneJob.
3538 pub fn locations_sources_migrating_vms_clone_jobs_get(
3539 &self,
3540 name: &str,
3541 ) -> ProjectLocationSourceMigratingVmCloneJobGetCall<'a, C> {
3542 ProjectLocationSourceMigratingVmCloneJobGetCall {
3543 hub: self.hub,
3544 _name: name.to_string(),
3545 _delegate: Default::default(),
3546 _additional_params: Default::default(),
3547 _scopes: Default::default(),
3548 }
3549 }
3550
3551 /// Create a builder to help you perform the following task:
3552 ///
3553 /// Lists the CloneJobs of a migrating VM. Only 25 most recent CloneJobs are listed.
3554 ///
3555 /// # Arguments
3556 ///
3557 /// * `parent` - Required. The parent, which owns this collection of source VMs.
3558 pub fn locations_sources_migrating_vms_clone_jobs_list(
3559 &self,
3560 parent: &str,
3561 ) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C> {
3562 ProjectLocationSourceMigratingVmCloneJobListCall {
3563 hub: self.hub,
3564 _parent: parent.to_string(),
3565 _page_token: Default::default(),
3566 _page_size: Default::default(),
3567 _order_by: Default::default(),
3568 _filter: Default::default(),
3569 _delegate: Default::default(),
3570 _additional_params: Default::default(),
3571 _scopes: Default::default(),
3572 }
3573 }
3574
3575 /// Create a builder to help you perform the following task:
3576 ///
3577 /// Initiates the cancellation of a running cutover job.
3578 ///
3579 /// # Arguments
3580 ///
3581 /// * `request` - No description provided.
3582 /// * `name` - Required. The cutover job id
3583 pub fn locations_sources_migrating_vms_cutover_jobs_cancel(
3584 &self,
3585 request: CancelCutoverJobRequest,
3586 name: &str,
3587 ) -> ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C> {
3588 ProjectLocationSourceMigratingVmCutoverJobCancelCall {
3589 hub: self.hub,
3590 _request: request,
3591 _name: name.to_string(),
3592 _delegate: Default::default(),
3593 _additional_params: Default::default(),
3594 _scopes: Default::default(),
3595 }
3596 }
3597
3598 /// Create a builder to help you perform the following task:
3599 ///
3600 /// Initiates a Cutover of a specific migrating VM. The returned LRO is completed when the cutover job resource is created and the job is initiated.
3601 ///
3602 /// # Arguments
3603 ///
3604 /// * `request` - No description provided.
3605 /// * `parent` - Required. The Cutover's parent.
3606 pub fn locations_sources_migrating_vms_cutover_jobs_create(
3607 &self,
3608 request: CutoverJob,
3609 parent: &str,
3610 ) -> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C> {
3611 ProjectLocationSourceMigratingVmCutoverJobCreateCall {
3612 hub: self.hub,
3613 _request: request,
3614 _parent: parent.to_string(),
3615 _request_id: Default::default(),
3616 _cutover_job_id: Default::default(),
3617 _delegate: Default::default(),
3618 _additional_params: Default::default(),
3619 _scopes: Default::default(),
3620 }
3621 }
3622
3623 /// Create a builder to help you perform the following task:
3624 ///
3625 /// Gets details of a single CutoverJob.
3626 ///
3627 /// # Arguments
3628 ///
3629 /// * `name` - Required. The name of the CutoverJob.
3630 pub fn locations_sources_migrating_vms_cutover_jobs_get(
3631 &self,
3632 name: &str,
3633 ) -> ProjectLocationSourceMigratingVmCutoverJobGetCall<'a, C> {
3634 ProjectLocationSourceMigratingVmCutoverJobGetCall {
3635 hub: self.hub,
3636 _name: name.to_string(),
3637 _delegate: Default::default(),
3638 _additional_params: Default::default(),
3639 _scopes: Default::default(),
3640 }
3641 }
3642
3643 /// Create a builder to help you perform the following task:
3644 ///
3645 /// Lists the CutoverJobs of a migrating VM. Only 25 most recent CutoverJobs are listed.
3646 ///
3647 /// # Arguments
3648 ///
3649 /// * `parent` - Required. The parent, which owns this collection of migrating VMs.
3650 pub fn locations_sources_migrating_vms_cutover_jobs_list(
3651 &self,
3652 parent: &str,
3653 ) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C> {
3654 ProjectLocationSourceMigratingVmCutoverJobListCall {
3655 hub: self.hub,
3656 _parent: parent.to_string(),
3657 _page_token: Default::default(),
3658 _page_size: Default::default(),
3659 _order_by: Default::default(),
3660 _filter: Default::default(),
3661 _delegate: Default::default(),
3662 _additional_params: Default::default(),
3663 _scopes: Default::default(),
3664 }
3665 }
3666
3667 /// Create a builder to help you perform the following task:
3668 ///
3669 /// Gets details of a single ReplicationCycle.
3670 ///
3671 /// # Arguments
3672 ///
3673 /// * `name` - Required. The name of the ReplicationCycle.
3674 pub fn locations_sources_migrating_vms_replication_cycles_get(
3675 &self,
3676 name: &str,
3677 ) -> ProjectLocationSourceMigratingVmReplicationCycleGetCall<'a, C> {
3678 ProjectLocationSourceMigratingVmReplicationCycleGetCall {
3679 hub: self.hub,
3680 _name: name.to_string(),
3681 _delegate: Default::default(),
3682 _additional_params: Default::default(),
3683 _scopes: Default::default(),
3684 }
3685 }
3686
3687 /// Create a builder to help you perform the following task:
3688 ///
3689 /// Lists ReplicationCycles in a given MigratingVM.
3690 ///
3691 /// # Arguments
3692 ///
3693 /// * `parent` - Required. The parent, which owns this collection of ReplicationCycles.
3694 pub fn locations_sources_migrating_vms_replication_cycles_list(
3695 &self,
3696 parent: &str,
3697 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C> {
3698 ProjectLocationSourceMigratingVmReplicationCycleListCall {
3699 hub: self.hub,
3700 _parent: parent.to_string(),
3701 _page_token: Default::default(),
3702 _page_size: Default::default(),
3703 _order_by: Default::default(),
3704 _filter: Default::default(),
3705 _delegate: Default::default(),
3706 _additional_params: Default::default(),
3707 _scopes: Default::default(),
3708 }
3709 }
3710
3711 /// Create a builder to help you perform the following task:
3712 ///
3713 /// Creates a new MigratingVm in a given Source.
3714 ///
3715 /// # Arguments
3716 ///
3717 /// * `request` - No description provided.
3718 /// * `parent` - Required. The MigratingVm's parent.
3719 pub fn locations_sources_migrating_vms_create(
3720 &self,
3721 request: MigratingVm,
3722 parent: &str,
3723 ) -> ProjectLocationSourceMigratingVmCreateCall<'a, C> {
3724 ProjectLocationSourceMigratingVmCreateCall {
3725 hub: self.hub,
3726 _request: request,
3727 _parent: parent.to_string(),
3728 _request_id: Default::default(),
3729 _migrating_vm_id: Default::default(),
3730 _delegate: Default::default(),
3731 _additional_params: Default::default(),
3732 _scopes: Default::default(),
3733 }
3734 }
3735
3736 /// Create a builder to help you perform the following task:
3737 ///
3738 /// Deletes a single MigratingVm.
3739 ///
3740 /// # Arguments
3741 ///
3742 /// * `name` - Required. The name of the MigratingVm.
3743 pub fn locations_sources_migrating_vms_delete(
3744 &self,
3745 name: &str,
3746 ) -> ProjectLocationSourceMigratingVmDeleteCall<'a, C> {
3747 ProjectLocationSourceMigratingVmDeleteCall {
3748 hub: self.hub,
3749 _name: name.to_string(),
3750 _delegate: Default::default(),
3751 _additional_params: Default::default(),
3752 _scopes: Default::default(),
3753 }
3754 }
3755
3756 /// Create a builder to help you perform the following task:
3757 ///
3758 /// Marks a migration as completed, deleting migration resources that are no longer being used. Only applicable after cutover is done.
3759 ///
3760 /// # Arguments
3761 ///
3762 /// * `request` - No description provided.
3763 /// * `migratingVm` - Required. The name of the MigratingVm.
3764 pub fn locations_sources_migrating_vms_finalize_migration(
3765 &self,
3766 request: FinalizeMigrationRequest,
3767 migrating_vm: &str,
3768 ) -> ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C> {
3769 ProjectLocationSourceMigratingVmFinalizeMigrationCall {
3770 hub: self.hub,
3771 _request: request,
3772 _migrating_vm: migrating_vm.to_string(),
3773 _delegate: Default::default(),
3774 _additional_params: Default::default(),
3775 _scopes: Default::default(),
3776 }
3777 }
3778
3779 /// Create a builder to help you perform the following task:
3780 ///
3781 /// Gets details of a single MigratingVm.
3782 ///
3783 /// # Arguments
3784 ///
3785 /// * `name` - Required. The name of the MigratingVm.
3786 pub fn locations_sources_migrating_vms_get(
3787 &self,
3788 name: &str,
3789 ) -> ProjectLocationSourceMigratingVmGetCall<'a, C> {
3790 ProjectLocationSourceMigratingVmGetCall {
3791 hub: self.hub,
3792 _name: name.to_string(),
3793 _view: Default::default(),
3794 _delegate: Default::default(),
3795 _additional_params: Default::default(),
3796 _scopes: Default::default(),
3797 }
3798 }
3799
3800 /// Create a builder to help you perform the following task:
3801 ///
3802 /// Lists MigratingVms in a given Source.
3803 ///
3804 /// # Arguments
3805 ///
3806 /// * `parent` - Required. The parent, which owns this collection of MigratingVms.
3807 pub fn locations_sources_migrating_vms_list(
3808 &self,
3809 parent: &str,
3810 ) -> ProjectLocationSourceMigratingVmListCall<'a, C> {
3811 ProjectLocationSourceMigratingVmListCall {
3812 hub: self.hub,
3813 _parent: parent.to_string(),
3814 _view: Default::default(),
3815 _page_token: Default::default(),
3816 _page_size: Default::default(),
3817 _order_by: Default::default(),
3818 _filter: Default::default(),
3819 _delegate: Default::default(),
3820 _additional_params: Default::default(),
3821 _scopes: Default::default(),
3822 }
3823 }
3824
3825 /// Create a builder to help you perform the following task:
3826 ///
3827 /// Updates the parameters of a single MigratingVm.
3828 ///
3829 /// # Arguments
3830 ///
3831 /// * `request` - No description provided.
3832 /// * `name` - Output only. The identifier of the MigratingVm.
3833 pub fn locations_sources_migrating_vms_patch(
3834 &self,
3835 request: MigratingVm,
3836 name: &str,
3837 ) -> ProjectLocationSourceMigratingVmPatchCall<'a, C> {
3838 ProjectLocationSourceMigratingVmPatchCall {
3839 hub: self.hub,
3840 _request: request,
3841 _name: name.to_string(),
3842 _update_mask: Default::default(),
3843 _request_id: Default::default(),
3844 _delegate: Default::default(),
3845 _additional_params: Default::default(),
3846 _scopes: Default::default(),
3847 }
3848 }
3849
3850 /// Create a builder to help you perform the following task:
3851 ///
3852 /// Pauses a migration for a VM. If cycle tasks are running they will be cancelled, preserving source task data. Further replication cycles will not be triggered while the VM is paused.
3853 ///
3854 /// # Arguments
3855 ///
3856 /// * `request` - No description provided.
3857 /// * `migratingVm` - Required. The name of the MigratingVm.
3858 pub fn locations_sources_migrating_vms_pause_migration(
3859 &self,
3860 request: PauseMigrationRequest,
3861 migrating_vm: &str,
3862 ) -> ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C> {
3863 ProjectLocationSourceMigratingVmPauseMigrationCall {
3864 hub: self.hub,
3865 _request: request,
3866 _migrating_vm: migrating_vm.to_string(),
3867 _delegate: Default::default(),
3868 _additional_params: Default::default(),
3869 _scopes: Default::default(),
3870 }
3871 }
3872
3873 /// Create a builder to help you perform the following task:
3874 ///
3875 /// Resumes a migration for a VM. When called on a paused migration, will start the process of uploading data and creating snapshots; when called on a completed cut-over migration, will update the migration to active state and start the process of uploading data and creating snapshots.
3876 ///
3877 /// # Arguments
3878 ///
3879 /// * `request` - No description provided.
3880 /// * `migratingVm` - Required. The name of the MigratingVm.
3881 pub fn locations_sources_migrating_vms_resume_migration(
3882 &self,
3883 request: ResumeMigrationRequest,
3884 migrating_vm: &str,
3885 ) -> ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C> {
3886 ProjectLocationSourceMigratingVmResumeMigrationCall {
3887 hub: self.hub,
3888 _request: request,
3889 _migrating_vm: migrating_vm.to_string(),
3890 _delegate: Default::default(),
3891 _additional_params: Default::default(),
3892 _scopes: Default::default(),
3893 }
3894 }
3895
3896 /// Create a builder to help you perform the following task:
3897 ///
3898 /// Starts migration for a VM. Starts the process of uploading data and creating snapshots, in replication cycles scheduled by the policy.
3899 ///
3900 /// # Arguments
3901 ///
3902 /// * `request` - No description provided.
3903 /// * `migratingVm` - Required. The name of the MigratingVm.
3904 pub fn locations_sources_migrating_vms_start_migration(
3905 &self,
3906 request: StartMigrationRequest,
3907 migrating_vm: &str,
3908 ) -> ProjectLocationSourceMigratingVmStartMigrationCall<'a, C> {
3909 ProjectLocationSourceMigratingVmStartMigrationCall {
3910 hub: self.hub,
3911 _request: request,
3912 _migrating_vm: migrating_vm.to_string(),
3913 _delegate: Default::default(),
3914 _additional_params: Default::default(),
3915 _scopes: Default::default(),
3916 }
3917 }
3918
3919 /// Create a builder to help you perform the following task:
3920 ///
3921 /// Creates a new UtilizationReport.
3922 ///
3923 /// # Arguments
3924 ///
3925 /// * `request` - No description provided.
3926 /// * `parent` - Required. The Utilization Report's parent.
3927 pub fn locations_sources_utilization_reports_create(
3928 &self,
3929 request: UtilizationReport,
3930 parent: &str,
3931 ) -> ProjectLocationSourceUtilizationReportCreateCall<'a, C> {
3932 ProjectLocationSourceUtilizationReportCreateCall {
3933 hub: self.hub,
3934 _request: request,
3935 _parent: parent.to_string(),
3936 _utilization_report_id: Default::default(),
3937 _request_id: Default::default(),
3938 _delegate: Default::default(),
3939 _additional_params: Default::default(),
3940 _scopes: Default::default(),
3941 }
3942 }
3943
3944 /// Create a builder to help you perform the following task:
3945 ///
3946 /// Deletes a single Utilization Report.
3947 ///
3948 /// # Arguments
3949 ///
3950 /// * `name` - Required. The Utilization Report name.
3951 pub fn locations_sources_utilization_reports_delete(
3952 &self,
3953 name: &str,
3954 ) -> ProjectLocationSourceUtilizationReportDeleteCall<'a, C> {
3955 ProjectLocationSourceUtilizationReportDeleteCall {
3956 hub: self.hub,
3957 _name: name.to_string(),
3958 _request_id: Default::default(),
3959 _delegate: Default::default(),
3960 _additional_params: Default::default(),
3961 _scopes: Default::default(),
3962 }
3963 }
3964
3965 /// Create a builder to help you perform the following task:
3966 ///
3967 /// Gets a single Utilization Report.
3968 ///
3969 /// # Arguments
3970 ///
3971 /// * `name` - Required. The Utilization Report name.
3972 pub fn locations_sources_utilization_reports_get(
3973 &self,
3974 name: &str,
3975 ) -> ProjectLocationSourceUtilizationReportGetCall<'a, C> {
3976 ProjectLocationSourceUtilizationReportGetCall {
3977 hub: self.hub,
3978 _name: name.to_string(),
3979 _view: Default::default(),
3980 _delegate: Default::default(),
3981 _additional_params: Default::default(),
3982 _scopes: Default::default(),
3983 }
3984 }
3985
3986 /// Create a builder to help you perform the following task:
3987 ///
3988 /// Lists Utilization Reports of the given Source.
3989 ///
3990 /// # Arguments
3991 ///
3992 /// * `parent` - Required. The Utilization Reports parent.
3993 pub fn locations_sources_utilization_reports_list(
3994 &self,
3995 parent: &str,
3996 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C> {
3997 ProjectLocationSourceUtilizationReportListCall {
3998 hub: self.hub,
3999 _parent: parent.to_string(),
4000 _view: Default::default(),
4001 _page_token: Default::default(),
4002 _page_size: Default::default(),
4003 _order_by: Default::default(),
4004 _filter: Default::default(),
4005 _delegate: Default::default(),
4006 _additional_params: Default::default(),
4007 _scopes: Default::default(),
4008 }
4009 }
4010
4011 /// Create a builder to help you perform the following task:
4012 ///
4013 /// Creates a new Source in a given project and location.
4014 ///
4015 /// # Arguments
4016 ///
4017 /// * `request` - No description provided.
4018 /// * `parent` - Required. The Source's parent.
4019 pub fn locations_sources_create(
4020 &self,
4021 request: Source,
4022 parent: &str,
4023 ) -> ProjectLocationSourceCreateCall<'a, C> {
4024 ProjectLocationSourceCreateCall {
4025 hub: self.hub,
4026 _request: request,
4027 _parent: parent.to_string(),
4028 _source_id: Default::default(),
4029 _request_id: Default::default(),
4030 _delegate: Default::default(),
4031 _additional_params: Default::default(),
4032 _scopes: Default::default(),
4033 }
4034 }
4035
4036 /// Create a builder to help you perform the following task:
4037 ///
4038 /// Deletes a single Source.
4039 ///
4040 /// # Arguments
4041 ///
4042 /// * `name` - Required. The Source name.
4043 pub fn locations_sources_delete(&self, name: &str) -> ProjectLocationSourceDeleteCall<'a, C> {
4044 ProjectLocationSourceDeleteCall {
4045 hub: self.hub,
4046 _name: name.to_string(),
4047 _request_id: Default::default(),
4048 _delegate: Default::default(),
4049 _additional_params: Default::default(),
4050 _scopes: Default::default(),
4051 }
4052 }
4053
4054 /// Create a builder to help you perform the following task:
4055 ///
4056 /// List remote source's inventory of VMs. The remote source is the onprem vCenter (remote in the sense it's not in Compute Engine). The inventory describes the list of existing VMs in that source. Note that this operation lists the VMs on the remote source, as opposed to listing the MigratingVms resources in the vmmigration service.
4057 ///
4058 /// # Arguments
4059 ///
4060 /// * `source` - Required. The name of the Source.
4061 pub fn locations_sources_fetch_inventory(
4062 &self,
4063 source: &str,
4064 ) -> ProjectLocationSourceFetchInventoryCall<'a, C> {
4065 ProjectLocationSourceFetchInventoryCall {
4066 hub: self.hub,
4067 _source: source.to_string(),
4068 _page_token: Default::default(),
4069 _page_size: Default::default(),
4070 _force_refresh: Default::default(),
4071 _delegate: Default::default(),
4072 _additional_params: Default::default(),
4073 _scopes: Default::default(),
4074 }
4075 }
4076
4077 /// Create a builder to help you perform the following task:
4078 ///
4079 /// Gets details of a single Source.
4080 ///
4081 /// # Arguments
4082 ///
4083 /// * `name` - Required. The Source name.
4084 pub fn locations_sources_get(&self, name: &str) -> ProjectLocationSourceGetCall<'a, C> {
4085 ProjectLocationSourceGetCall {
4086 hub: self.hub,
4087 _name: name.to_string(),
4088 _delegate: Default::default(),
4089 _additional_params: Default::default(),
4090 _scopes: Default::default(),
4091 }
4092 }
4093
4094 /// Create a builder to help you perform the following task:
4095 ///
4096 /// Lists Sources in a given project and location.
4097 ///
4098 /// # Arguments
4099 ///
4100 /// * `parent` - Required. The parent, which owns this collection of sources.
4101 pub fn locations_sources_list(&self, parent: &str) -> ProjectLocationSourceListCall<'a, C> {
4102 ProjectLocationSourceListCall {
4103 hub: self.hub,
4104 _parent: parent.to_string(),
4105 _page_token: Default::default(),
4106 _page_size: Default::default(),
4107 _order_by: Default::default(),
4108 _filter: Default::default(),
4109 _delegate: Default::default(),
4110 _additional_params: Default::default(),
4111 _scopes: Default::default(),
4112 }
4113 }
4114
4115 /// Create a builder to help you perform the following task:
4116 ///
4117 /// Updates the parameters of a single Source.
4118 ///
4119 /// # Arguments
4120 ///
4121 /// * `request` - No description provided.
4122 /// * `name` - Output only. The Source name.
4123 pub fn locations_sources_patch(
4124 &self,
4125 request: Source,
4126 name: &str,
4127 ) -> ProjectLocationSourcePatchCall<'a, C> {
4128 ProjectLocationSourcePatchCall {
4129 hub: self.hub,
4130 _request: request,
4131 _name: name.to_string(),
4132 _update_mask: Default::default(),
4133 _request_id: Default::default(),
4134 _delegate: Default::default(),
4135 _additional_params: Default::default(),
4136 _scopes: Default::default(),
4137 }
4138 }
4139
4140 /// Create a builder to help you perform the following task:
4141 ///
4142 /// Creates a new TargetProject in a given project. NOTE: TargetProject is a global resource; hence the only supported value for location is `global`.
4143 ///
4144 /// # Arguments
4145 ///
4146 /// * `request` - No description provided.
4147 /// * `parent` - Required. The TargetProject's parent.
4148 pub fn locations_target_projects_create(
4149 &self,
4150 request: TargetProject,
4151 parent: &str,
4152 ) -> ProjectLocationTargetProjectCreateCall<'a, C> {
4153 ProjectLocationTargetProjectCreateCall {
4154 hub: self.hub,
4155 _request: request,
4156 _parent: parent.to_string(),
4157 _target_project_id: Default::default(),
4158 _request_id: Default::default(),
4159 _delegate: Default::default(),
4160 _additional_params: Default::default(),
4161 _scopes: Default::default(),
4162 }
4163 }
4164
4165 /// Create a builder to help you perform the following task:
4166 ///
4167 /// Deletes a single TargetProject. NOTE: TargetProject is a global resource; hence the only supported value for location is `global`.
4168 ///
4169 /// # Arguments
4170 ///
4171 /// * `name` - Required. The TargetProject name.
4172 pub fn locations_target_projects_delete(
4173 &self,
4174 name: &str,
4175 ) -> ProjectLocationTargetProjectDeleteCall<'a, C> {
4176 ProjectLocationTargetProjectDeleteCall {
4177 hub: self.hub,
4178 _name: name.to_string(),
4179 _request_id: Default::default(),
4180 _delegate: Default::default(),
4181 _additional_params: Default::default(),
4182 _scopes: Default::default(),
4183 }
4184 }
4185
4186 /// Create a builder to help you perform the following task:
4187 ///
4188 /// Gets details of a single TargetProject. NOTE: TargetProject is a global resource; hence the only supported value for location is `global`.
4189 ///
4190 /// # Arguments
4191 ///
4192 /// * `name` - Required. The TargetProject name.
4193 pub fn locations_target_projects_get(
4194 &self,
4195 name: &str,
4196 ) -> ProjectLocationTargetProjectGetCall<'a, C> {
4197 ProjectLocationTargetProjectGetCall {
4198 hub: self.hub,
4199 _name: name.to_string(),
4200 _delegate: Default::default(),
4201 _additional_params: Default::default(),
4202 _scopes: Default::default(),
4203 }
4204 }
4205
4206 /// Create a builder to help you perform the following task:
4207 ///
4208 /// Lists TargetProjects in a given project. NOTE: TargetProject is a global resource; hence the only supported value for location is `global`.
4209 ///
4210 /// # Arguments
4211 ///
4212 /// * `parent` - Required. The parent, which owns this collection of targets.
4213 pub fn locations_target_projects_list(
4214 &self,
4215 parent: &str,
4216 ) -> ProjectLocationTargetProjectListCall<'a, C> {
4217 ProjectLocationTargetProjectListCall {
4218 hub: self.hub,
4219 _parent: parent.to_string(),
4220 _page_token: Default::default(),
4221 _page_size: Default::default(),
4222 _order_by: Default::default(),
4223 _filter: Default::default(),
4224 _delegate: Default::default(),
4225 _additional_params: Default::default(),
4226 _scopes: Default::default(),
4227 }
4228 }
4229
4230 /// Create a builder to help you perform the following task:
4231 ///
4232 /// Updates the parameters of a single TargetProject. NOTE: TargetProject is a global resource; hence the only supported value for location is `global`.
4233 ///
4234 /// # Arguments
4235 ///
4236 /// * `request` - No description provided.
4237 /// * `name` - Output only. The name of the target project.
4238 pub fn locations_target_projects_patch(
4239 &self,
4240 request: TargetProject,
4241 name: &str,
4242 ) -> ProjectLocationTargetProjectPatchCall<'a, C> {
4243 ProjectLocationTargetProjectPatchCall {
4244 hub: self.hub,
4245 _request: request,
4246 _name: name.to_string(),
4247 _update_mask: Default::default(),
4248 _request_id: Default::default(),
4249 _delegate: Default::default(),
4250 _additional_params: Default::default(),
4251 _scopes: Default::default(),
4252 }
4253 }
4254
4255 /// Create a builder to help you perform the following task:
4256 ///
4257 /// Gets information about a location.
4258 ///
4259 /// # Arguments
4260 ///
4261 /// * `name` - Resource name for the location.
4262 pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
4263 ProjectLocationGetCall {
4264 hub: self.hub,
4265 _name: name.to_string(),
4266 _delegate: Default::default(),
4267 _additional_params: Default::default(),
4268 _scopes: Default::default(),
4269 }
4270 }
4271
4272 /// Create a builder to help you perform the following task:
4273 ///
4274 /// Lists information about the supported locations for this service.
4275 ///
4276 /// # Arguments
4277 ///
4278 /// * `name` - The resource that owns the locations collection, if applicable.
4279 pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
4280 ProjectLocationListCall {
4281 hub: self.hub,
4282 _name: name.to_string(),
4283 _page_token: Default::default(),
4284 _page_size: Default::default(),
4285 _filter: Default::default(),
4286 _delegate: Default::default(),
4287 _additional_params: Default::default(),
4288 _scopes: Default::default(),
4289 }
4290 }
4291}
4292
4293// ###################
4294// CallBuilders ###
4295// #################
4296
4297/// Adds a MigratingVm to a Group.
4298///
4299/// A builder for the *locations.groups.addGroupMigration* method supported by a *project* resource.
4300/// It is not used directly, but through a [`ProjectMethods`] instance.
4301///
4302/// # Example
4303///
4304/// Instantiate a resource method builder
4305///
4306/// ```test_harness,no_run
4307/// # extern crate hyper;
4308/// # extern crate hyper_rustls;
4309/// # extern crate google_vmmigration1 as vmmigration1;
4310/// use vmmigration1::api::AddGroupMigrationRequest;
4311/// # async fn dox() {
4312/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4313///
4314/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4315/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4316/// # secret,
4317/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4318/// # ).build().await.unwrap();
4319///
4320/// # let client = hyper_util::client::legacy::Client::builder(
4321/// # hyper_util::rt::TokioExecutor::new()
4322/// # )
4323/// # .build(
4324/// # hyper_rustls::HttpsConnectorBuilder::new()
4325/// # .with_native_roots()
4326/// # .unwrap()
4327/// # .https_or_http()
4328/// # .enable_http1()
4329/// # .build()
4330/// # );
4331/// # let mut hub = VMMigrationService::new(client, auth);
4332/// // As the method needs a request, you would usually fill it with the desired information
4333/// // into the respective structure. Some of the parts shown here might not be applicable !
4334/// // Values shown here are possibly random and not representative !
4335/// let mut req = AddGroupMigrationRequest::default();
4336///
4337/// // You can configure optional parameters by calling the respective setters at will, and
4338/// // execute the final call using `doit()`.
4339/// // Values shown here are possibly random and not representative !
4340/// let result = hub.projects().locations_groups_add_group_migration(req, "group")
4341/// .doit().await;
4342/// # }
4343/// ```
4344pub struct ProjectLocationGroupAddGroupMigrationCall<'a, C>
4345where
4346 C: 'a,
4347{
4348 hub: &'a VMMigrationService<C>,
4349 _request: AddGroupMigrationRequest,
4350 _group: String,
4351 _delegate: Option<&'a mut dyn common::Delegate>,
4352 _additional_params: HashMap<String, String>,
4353 _scopes: BTreeSet<String>,
4354}
4355
4356impl<'a, C> common::CallBuilder for ProjectLocationGroupAddGroupMigrationCall<'a, C> {}
4357
4358impl<'a, C> ProjectLocationGroupAddGroupMigrationCall<'a, C>
4359where
4360 C: common::Connector,
4361{
4362 /// Perform the operation you have build so far.
4363 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4364 use std::borrow::Cow;
4365 use std::io::{Read, Seek};
4366
4367 use common::{url::Params, ToParts};
4368 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4369
4370 let mut dd = common::DefaultDelegate;
4371 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4372 dlg.begin(common::MethodInfo {
4373 id: "vmmigration.projects.locations.groups.addGroupMigration",
4374 http_method: hyper::Method::POST,
4375 });
4376
4377 for &field in ["alt", "group"].iter() {
4378 if self._additional_params.contains_key(field) {
4379 dlg.finished(false);
4380 return Err(common::Error::FieldClash(field));
4381 }
4382 }
4383
4384 let mut params = Params::with_capacity(4 + self._additional_params.len());
4385 params.push("group", self._group);
4386
4387 params.extend(self._additional_params.iter());
4388
4389 params.push("alt", "json");
4390 let mut url = self.hub._base_url.clone() + "v1/{+group}:addGroupMigration";
4391 if self._scopes.is_empty() {
4392 self._scopes
4393 .insert(Scope::CloudPlatform.as_ref().to_string());
4394 }
4395
4396 #[allow(clippy::single_element_loop)]
4397 for &(find_this, param_name) in [("{+group}", "group")].iter() {
4398 url = params.uri_replacement(url, param_name, find_this, true);
4399 }
4400 {
4401 let to_remove = ["group"];
4402 params.remove_params(&to_remove);
4403 }
4404
4405 let url = params.parse_with_url(&url);
4406
4407 let mut json_mime_type = mime::APPLICATION_JSON;
4408 let mut request_value_reader = {
4409 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4410 common::remove_json_null_values(&mut value);
4411 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4412 serde_json::to_writer(&mut dst, &value).unwrap();
4413 dst
4414 };
4415 let request_size = request_value_reader
4416 .seek(std::io::SeekFrom::End(0))
4417 .unwrap();
4418 request_value_reader
4419 .seek(std::io::SeekFrom::Start(0))
4420 .unwrap();
4421
4422 loop {
4423 let token = match self
4424 .hub
4425 .auth
4426 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4427 .await
4428 {
4429 Ok(token) => token,
4430 Err(e) => match dlg.token(e) {
4431 Ok(token) => token,
4432 Err(e) => {
4433 dlg.finished(false);
4434 return Err(common::Error::MissingToken(e));
4435 }
4436 },
4437 };
4438 request_value_reader
4439 .seek(std::io::SeekFrom::Start(0))
4440 .unwrap();
4441 let mut req_result = {
4442 let client = &self.hub.client;
4443 dlg.pre_request();
4444 let mut req_builder = hyper::Request::builder()
4445 .method(hyper::Method::POST)
4446 .uri(url.as_str())
4447 .header(USER_AGENT, self.hub._user_agent.clone());
4448
4449 if let Some(token) = token.as_ref() {
4450 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4451 }
4452
4453 let request = req_builder
4454 .header(CONTENT_TYPE, json_mime_type.to_string())
4455 .header(CONTENT_LENGTH, request_size as u64)
4456 .body(common::to_body(
4457 request_value_reader.get_ref().clone().into(),
4458 ));
4459
4460 client.request(request.unwrap()).await
4461 };
4462
4463 match req_result {
4464 Err(err) => {
4465 if let common::Retry::After(d) = dlg.http_error(&err) {
4466 sleep(d).await;
4467 continue;
4468 }
4469 dlg.finished(false);
4470 return Err(common::Error::HttpError(err));
4471 }
4472 Ok(res) => {
4473 let (mut parts, body) = res.into_parts();
4474 let mut body = common::Body::new(body);
4475 if !parts.status.is_success() {
4476 let bytes = common::to_bytes(body).await.unwrap_or_default();
4477 let error = serde_json::from_str(&common::to_string(&bytes));
4478 let response = common::to_response(parts, bytes.into());
4479
4480 if let common::Retry::After(d) =
4481 dlg.http_failure(&response, error.as_ref().ok())
4482 {
4483 sleep(d).await;
4484 continue;
4485 }
4486
4487 dlg.finished(false);
4488
4489 return Err(match error {
4490 Ok(value) => common::Error::BadRequest(value),
4491 _ => common::Error::Failure(response),
4492 });
4493 }
4494 let response = {
4495 let bytes = common::to_bytes(body).await.unwrap_or_default();
4496 let encoded = common::to_string(&bytes);
4497 match serde_json::from_str(&encoded) {
4498 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4499 Err(error) => {
4500 dlg.response_json_decode_error(&encoded, &error);
4501 return Err(common::Error::JsonDecodeError(
4502 encoded.to_string(),
4503 error,
4504 ));
4505 }
4506 }
4507 };
4508
4509 dlg.finished(true);
4510 return Ok(response);
4511 }
4512 }
4513 }
4514 }
4515
4516 ///
4517 /// Sets the *request* property to the given value.
4518 ///
4519 /// Even though the property as already been set when instantiating this call,
4520 /// we provide this method for API completeness.
4521 pub fn request(
4522 mut self,
4523 new_value: AddGroupMigrationRequest,
4524 ) -> ProjectLocationGroupAddGroupMigrationCall<'a, C> {
4525 self._request = new_value;
4526 self
4527 }
4528 /// Required. The full path name of the Group to add to.
4529 ///
4530 /// Sets the *group* path property to the given value.
4531 ///
4532 /// Even though the property as already been set when instantiating this call,
4533 /// we provide this method for API completeness.
4534 pub fn group(mut self, new_value: &str) -> ProjectLocationGroupAddGroupMigrationCall<'a, C> {
4535 self._group = new_value.to_string();
4536 self
4537 }
4538 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4539 /// while executing the actual API request.
4540 ///
4541 /// ````text
4542 /// It should be used to handle progress information, and to implement a certain level of resilience.
4543 /// ````
4544 ///
4545 /// Sets the *delegate* property to the given value.
4546 pub fn delegate(
4547 mut self,
4548 new_value: &'a mut dyn common::Delegate,
4549 ) -> ProjectLocationGroupAddGroupMigrationCall<'a, C> {
4550 self._delegate = Some(new_value);
4551 self
4552 }
4553
4554 /// Set any additional parameter of the query string used in the request.
4555 /// It should be used to set parameters which are not yet available through their own
4556 /// setters.
4557 ///
4558 /// Please note that this method must not be used to set any of the known parameters
4559 /// which have their own setter method. If done anyway, the request will fail.
4560 ///
4561 /// # Additional Parameters
4562 ///
4563 /// * *$.xgafv* (query-string) - V1 error format.
4564 /// * *access_token* (query-string) - OAuth access token.
4565 /// * *alt* (query-string) - Data format for response.
4566 /// * *callback* (query-string) - JSONP
4567 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4568 /// * *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.
4569 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4570 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4571 /// * *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.
4572 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4573 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4574 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGroupAddGroupMigrationCall<'a, C>
4575 where
4576 T: AsRef<str>,
4577 {
4578 self._additional_params
4579 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4580 self
4581 }
4582
4583 /// Identifies the authorization scope for the method you are building.
4584 ///
4585 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4586 /// [`Scope::CloudPlatform`].
4587 ///
4588 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4589 /// tokens for more than one scope.
4590 ///
4591 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4592 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4593 /// sufficient, a read-write scope will do as well.
4594 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGroupAddGroupMigrationCall<'a, C>
4595 where
4596 St: AsRef<str>,
4597 {
4598 self._scopes.insert(String::from(scope.as_ref()));
4599 self
4600 }
4601 /// Identifies the authorization scope(s) for the method you are building.
4602 ///
4603 /// See [`Self::add_scope()`] for details.
4604 pub fn add_scopes<I, St>(
4605 mut self,
4606 scopes: I,
4607 ) -> ProjectLocationGroupAddGroupMigrationCall<'a, C>
4608 where
4609 I: IntoIterator<Item = St>,
4610 St: AsRef<str>,
4611 {
4612 self._scopes
4613 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4614 self
4615 }
4616
4617 /// Removes all scopes, and no default scope will be used either.
4618 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4619 /// for details).
4620 pub fn clear_scopes(mut self) -> ProjectLocationGroupAddGroupMigrationCall<'a, C> {
4621 self._scopes.clear();
4622 self
4623 }
4624}
4625
4626/// Creates a new Group in a given project and location.
4627///
4628/// A builder for the *locations.groups.create* method supported by a *project* resource.
4629/// It is not used directly, but through a [`ProjectMethods`] instance.
4630///
4631/// # Example
4632///
4633/// Instantiate a resource method builder
4634///
4635/// ```test_harness,no_run
4636/// # extern crate hyper;
4637/// # extern crate hyper_rustls;
4638/// # extern crate google_vmmigration1 as vmmigration1;
4639/// use vmmigration1::api::Group;
4640/// # async fn dox() {
4641/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4642///
4643/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4644/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4645/// # secret,
4646/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4647/// # ).build().await.unwrap();
4648///
4649/// # let client = hyper_util::client::legacy::Client::builder(
4650/// # hyper_util::rt::TokioExecutor::new()
4651/// # )
4652/// # .build(
4653/// # hyper_rustls::HttpsConnectorBuilder::new()
4654/// # .with_native_roots()
4655/// # .unwrap()
4656/// # .https_or_http()
4657/// # .enable_http1()
4658/// # .build()
4659/// # );
4660/// # let mut hub = VMMigrationService::new(client, auth);
4661/// // As the method needs a request, you would usually fill it with the desired information
4662/// // into the respective structure. Some of the parts shown here might not be applicable !
4663/// // Values shown here are possibly random and not representative !
4664/// let mut req = Group::default();
4665///
4666/// // You can configure optional parameters by calling the respective setters at will, and
4667/// // execute the final call using `doit()`.
4668/// // Values shown here are possibly random and not representative !
4669/// let result = hub.projects().locations_groups_create(req, "parent")
4670/// .request_id("duo")
4671/// .group_id("ipsum")
4672/// .doit().await;
4673/// # }
4674/// ```
4675pub struct ProjectLocationGroupCreateCall<'a, C>
4676where
4677 C: 'a,
4678{
4679 hub: &'a VMMigrationService<C>,
4680 _request: Group,
4681 _parent: String,
4682 _request_id: Option<String>,
4683 _group_id: Option<String>,
4684 _delegate: Option<&'a mut dyn common::Delegate>,
4685 _additional_params: HashMap<String, String>,
4686 _scopes: BTreeSet<String>,
4687}
4688
4689impl<'a, C> common::CallBuilder for ProjectLocationGroupCreateCall<'a, C> {}
4690
4691impl<'a, C> ProjectLocationGroupCreateCall<'a, C>
4692where
4693 C: common::Connector,
4694{
4695 /// Perform the operation you have build so far.
4696 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4697 use std::borrow::Cow;
4698 use std::io::{Read, Seek};
4699
4700 use common::{url::Params, ToParts};
4701 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4702
4703 let mut dd = common::DefaultDelegate;
4704 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4705 dlg.begin(common::MethodInfo {
4706 id: "vmmigration.projects.locations.groups.create",
4707 http_method: hyper::Method::POST,
4708 });
4709
4710 for &field in ["alt", "parent", "requestId", "groupId"].iter() {
4711 if self._additional_params.contains_key(field) {
4712 dlg.finished(false);
4713 return Err(common::Error::FieldClash(field));
4714 }
4715 }
4716
4717 let mut params = Params::with_capacity(6 + self._additional_params.len());
4718 params.push("parent", self._parent);
4719 if let Some(value) = self._request_id.as_ref() {
4720 params.push("requestId", value);
4721 }
4722 if let Some(value) = self._group_id.as_ref() {
4723 params.push("groupId", value);
4724 }
4725
4726 params.extend(self._additional_params.iter());
4727
4728 params.push("alt", "json");
4729 let mut url = self.hub._base_url.clone() + "v1/{+parent}/groups";
4730 if self._scopes.is_empty() {
4731 self._scopes
4732 .insert(Scope::CloudPlatform.as_ref().to_string());
4733 }
4734
4735 #[allow(clippy::single_element_loop)]
4736 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4737 url = params.uri_replacement(url, param_name, find_this, true);
4738 }
4739 {
4740 let to_remove = ["parent"];
4741 params.remove_params(&to_remove);
4742 }
4743
4744 let url = params.parse_with_url(&url);
4745
4746 let mut json_mime_type = mime::APPLICATION_JSON;
4747 let mut request_value_reader = {
4748 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4749 common::remove_json_null_values(&mut value);
4750 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4751 serde_json::to_writer(&mut dst, &value).unwrap();
4752 dst
4753 };
4754 let request_size = request_value_reader
4755 .seek(std::io::SeekFrom::End(0))
4756 .unwrap();
4757 request_value_reader
4758 .seek(std::io::SeekFrom::Start(0))
4759 .unwrap();
4760
4761 loop {
4762 let token = match self
4763 .hub
4764 .auth
4765 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4766 .await
4767 {
4768 Ok(token) => token,
4769 Err(e) => match dlg.token(e) {
4770 Ok(token) => token,
4771 Err(e) => {
4772 dlg.finished(false);
4773 return Err(common::Error::MissingToken(e));
4774 }
4775 },
4776 };
4777 request_value_reader
4778 .seek(std::io::SeekFrom::Start(0))
4779 .unwrap();
4780 let mut req_result = {
4781 let client = &self.hub.client;
4782 dlg.pre_request();
4783 let mut req_builder = hyper::Request::builder()
4784 .method(hyper::Method::POST)
4785 .uri(url.as_str())
4786 .header(USER_AGENT, self.hub._user_agent.clone());
4787
4788 if let Some(token) = token.as_ref() {
4789 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4790 }
4791
4792 let request = req_builder
4793 .header(CONTENT_TYPE, json_mime_type.to_string())
4794 .header(CONTENT_LENGTH, request_size as u64)
4795 .body(common::to_body(
4796 request_value_reader.get_ref().clone().into(),
4797 ));
4798
4799 client.request(request.unwrap()).await
4800 };
4801
4802 match req_result {
4803 Err(err) => {
4804 if let common::Retry::After(d) = dlg.http_error(&err) {
4805 sleep(d).await;
4806 continue;
4807 }
4808 dlg.finished(false);
4809 return Err(common::Error::HttpError(err));
4810 }
4811 Ok(res) => {
4812 let (mut parts, body) = res.into_parts();
4813 let mut body = common::Body::new(body);
4814 if !parts.status.is_success() {
4815 let bytes = common::to_bytes(body).await.unwrap_or_default();
4816 let error = serde_json::from_str(&common::to_string(&bytes));
4817 let response = common::to_response(parts, bytes.into());
4818
4819 if let common::Retry::After(d) =
4820 dlg.http_failure(&response, error.as_ref().ok())
4821 {
4822 sleep(d).await;
4823 continue;
4824 }
4825
4826 dlg.finished(false);
4827
4828 return Err(match error {
4829 Ok(value) => common::Error::BadRequest(value),
4830 _ => common::Error::Failure(response),
4831 });
4832 }
4833 let response = {
4834 let bytes = common::to_bytes(body).await.unwrap_or_default();
4835 let encoded = common::to_string(&bytes);
4836 match serde_json::from_str(&encoded) {
4837 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4838 Err(error) => {
4839 dlg.response_json_decode_error(&encoded, &error);
4840 return Err(common::Error::JsonDecodeError(
4841 encoded.to_string(),
4842 error,
4843 ));
4844 }
4845 }
4846 };
4847
4848 dlg.finished(true);
4849 return Ok(response);
4850 }
4851 }
4852 }
4853 }
4854
4855 ///
4856 /// Sets the *request* property to the given value.
4857 ///
4858 /// Even though the property as already been set when instantiating this call,
4859 /// we provide this method for API completeness.
4860 pub fn request(mut self, new_value: Group) -> ProjectLocationGroupCreateCall<'a, C> {
4861 self._request = new_value;
4862 self
4863 }
4864 /// Required. The Group's parent.
4865 ///
4866 /// Sets the *parent* path property to the given value.
4867 ///
4868 /// Even though the property as already been set when instantiating this call,
4869 /// we provide this method for API completeness.
4870 pub fn parent(mut self, new_value: &str) -> ProjectLocationGroupCreateCall<'a, C> {
4871 self._parent = new_value.to_string();
4872 self
4873 }
4874 /// A request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes since the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
4875 ///
4876 /// Sets the *request id* query property to the given value.
4877 pub fn request_id(mut self, new_value: &str) -> ProjectLocationGroupCreateCall<'a, C> {
4878 self._request_id = Some(new_value.to_string());
4879 self
4880 }
4881 /// Required. The group identifier.
4882 ///
4883 /// Sets the *group id* query property to the given value.
4884 pub fn group_id(mut self, new_value: &str) -> ProjectLocationGroupCreateCall<'a, C> {
4885 self._group_id = Some(new_value.to_string());
4886 self
4887 }
4888 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4889 /// while executing the actual API request.
4890 ///
4891 /// ````text
4892 /// It should be used to handle progress information, and to implement a certain level of resilience.
4893 /// ````
4894 ///
4895 /// Sets the *delegate* property to the given value.
4896 pub fn delegate(
4897 mut self,
4898 new_value: &'a mut dyn common::Delegate,
4899 ) -> ProjectLocationGroupCreateCall<'a, C> {
4900 self._delegate = Some(new_value);
4901 self
4902 }
4903
4904 /// Set any additional parameter of the query string used in the request.
4905 /// It should be used to set parameters which are not yet available through their own
4906 /// setters.
4907 ///
4908 /// Please note that this method must not be used to set any of the known parameters
4909 /// which have their own setter method. If done anyway, the request will fail.
4910 ///
4911 /// # Additional Parameters
4912 ///
4913 /// * *$.xgafv* (query-string) - V1 error format.
4914 /// * *access_token* (query-string) - OAuth access token.
4915 /// * *alt* (query-string) - Data format for response.
4916 /// * *callback* (query-string) - JSONP
4917 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4918 /// * *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.
4919 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4920 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4921 /// * *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.
4922 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4923 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4924 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGroupCreateCall<'a, C>
4925 where
4926 T: AsRef<str>,
4927 {
4928 self._additional_params
4929 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4930 self
4931 }
4932
4933 /// Identifies the authorization scope for the method you are building.
4934 ///
4935 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4936 /// [`Scope::CloudPlatform`].
4937 ///
4938 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4939 /// tokens for more than one scope.
4940 ///
4941 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4942 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4943 /// sufficient, a read-write scope will do as well.
4944 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGroupCreateCall<'a, C>
4945 where
4946 St: AsRef<str>,
4947 {
4948 self._scopes.insert(String::from(scope.as_ref()));
4949 self
4950 }
4951 /// Identifies the authorization scope(s) for the method you are building.
4952 ///
4953 /// See [`Self::add_scope()`] for details.
4954 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGroupCreateCall<'a, C>
4955 where
4956 I: IntoIterator<Item = St>,
4957 St: AsRef<str>,
4958 {
4959 self._scopes
4960 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4961 self
4962 }
4963
4964 /// Removes all scopes, and no default scope will be used either.
4965 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4966 /// for details).
4967 pub fn clear_scopes(mut self) -> ProjectLocationGroupCreateCall<'a, C> {
4968 self._scopes.clear();
4969 self
4970 }
4971}
4972
4973/// Deletes a single Group.
4974///
4975/// A builder for the *locations.groups.delete* method supported by a *project* resource.
4976/// It is not used directly, but through a [`ProjectMethods`] instance.
4977///
4978/// # Example
4979///
4980/// Instantiate a resource method builder
4981///
4982/// ```test_harness,no_run
4983/// # extern crate hyper;
4984/// # extern crate hyper_rustls;
4985/// # extern crate google_vmmigration1 as vmmigration1;
4986/// # async fn dox() {
4987/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4988///
4989/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4990/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4991/// # secret,
4992/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4993/// # ).build().await.unwrap();
4994///
4995/// # let client = hyper_util::client::legacy::Client::builder(
4996/// # hyper_util::rt::TokioExecutor::new()
4997/// # )
4998/// # .build(
4999/// # hyper_rustls::HttpsConnectorBuilder::new()
5000/// # .with_native_roots()
5001/// # .unwrap()
5002/// # .https_or_http()
5003/// # .enable_http1()
5004/// # .build()
5005/// # );
5006/// # let mut hub = VMMigrationService::new(client, auth);
5007/// // You can configure optional parameters by calling the respective setters at will, and
5008/// // execute the final call using `doit()`.
5009/// // Values shown here are possibly random and not representative !
5010/// let result = hub.projects().locations_groups_delete("name")
5011/// .request_id("Lorem")
5012/// .doit().await;
5013/// # }
5014/// ```
5015pub struct ProjectLocationGroupDeleteCall<'a, C>
5016where
5017 C: 'a,
5018{
5019 hub: &'a VMMigrationService<C>,
5020 _name: String,
5021 _request_id: Option<String>,
5022 _delegate: Option<&'a mut dyn common::Delegate>,
5023 _additional_params: HashMap<String, String>,
5024 _scopes: BTreeSet<String>,
5025}
5026
5027impl<'a, C> common::CallBuilder for ProjectLocationGroupDeleteCall<'a, C> {}
5028
5029impl<'a, C> ProjectLocationGroupDeleteCall<'a, C>
5030where
5031 C: common::Connector,
5032{
5033 /// Perform the operation you have build so far.
5034 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5035 use std::borrow::Cow;
5036 use std::io::{Read, Seek};
5037
5038 use common::{url::Params, ToParts};
5039 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5040
5041 let mut dd = common::DefaultDelegate;
5042 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5043 dlg.begin(common::MethodInfo {
5044 id: "vmmigration.projects.locations.groups.delete",
5045 http_method: hyper::Method::DELETE,
5046 });
5047
5048 for &field in ["alt", "name", "requestId"].iter() {
5049 if self._additional_params.contains_key(field) {
5050 dlg.finished(false);
5051 return Err(common::Error::FieldClash(field));
5052 }
5053 }
5054
5055 let mut params = Params::with_capacity(4 + self._additional_params.len());
5056 params.push("name", self._name);
5057 if let Some(value) = self._request_id.as_ref() {
5058 params.push("requestId", value);
5059 }
5060
5061 params.extend(self._additional_params.iter());
5062
5063 params.push("alt", "json");
5064 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5065 if self._scopes.is_empty() {
5066 self._scopes
5067 .insert(Scope::CloudPlatform.as_ref().to_string());
5068 }
5069
5070 #[allow(clippy::single_element_loop)]
5071 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5072 url = params.uri_replacement(url, param_name, find_this, true);
5073 }
5074 {
5075 let to_remove = ["name"];
5076 params.remove_params(&to_remove);
5077 }
5078
5079 let url = params.parse_with_url(&url);
5080
5081 loop {
5082 let token = match self
5083 .hub
5084 .auth
5085 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5086 .await
5087 {
5088 Ok(token) => token,
5089 Err(e) => match dlg.token(e) {
5090 Ok(token) => token,
5091 Err(e) => {
5092 dlg.finished(false);
5093 return Err(common::Error::MissingToken(e));
5094 }
5095 },
5096 };
5097 let mut req_result = {
5098 let client = &self.hub.client;
5099 dlg.pre_request();
5100 let mut req_builder = hyper::Request::builder()
5101 .method(hyper::Method::DELETE)
5102 .uri(url.as_str())
5103 .header(USER_AGENT, self.hub._user_agent.clone());
5104
5105 if let Some(token) = token.as_ref() {
5106 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5107 }
5108
5109 let request = req_builder
5110 .header(CONTENT_LENGTH, 0_u64)
5111 .body(common::to_body::<String>(None));
5112
5113 client.request(request.unwrap()).await
5114 };
5115
5116 match req_result {
5117 Err(err) => {
5118 if let common::Retry::After(d) = dlg.http_error(&err) {
5119 sleep(d).await;
5120 continue;
5121 }
5122 dlg.finished(false);
5123 return Err(common::Error::HttpError(err));
5124 }
5125 Ok(res) => {
5126 let (mut parts, body) = res.into_parts();
5127 let mut body = common::Body::new(body);
5128 if !parts.status.is_success() {
5129 let bytes = common::to_bytes(body).await.unwrap_or_default();
5130 let error = serde_json::from_str(&common::to_string(&bytes));
5131 let response = common::to_response(parts, bytes.into());
5132
5133 if let common::Retry::After(d) =
5134 dlg.http_failure(&response, error.as_ref().ok())
5135 {
5136 sleep(d).await;
5137 continue;
5138 }
5139
5140 dlg.finished(false);
5141
5142 return Err(match error {
5143 Ok(value) => common::Error::BadRequest(value),
5144 _ => common::Error::Failure(response),
5145 });
5146 }
5147 let response = {
5148 let bytes = common::to_bytes(body).await.unwrap_or_default();
5149 let encoded = common::to_string(&bytes);
5150 match serde_json::from_str(&encoded) {
5151 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5152 Err(error) => {
5153 dlg.response_json_decode_error(&encoded, &error);
5154 return Err(common::Error::JsonDecodeError(
5155 encoded.to_string(),
5156 error,
5157 ));
5158 }
5159 }
5160 };
5161
5162 dlg.finished(true);
5163 return Ok(response);
5164 }
5165 }
5166 }
5167 }
5168
5169 /// Required. The Group name.
5170 ///
5171 /// Sets the *name* path property to the given value.
5172 ///
5173 /// Even though the property as already been set when instantiating this call,
5174 /// we provide this method for API completeness.
5175 pub fn name(mut self, new_value: &str) -> ProjectLocationGroupDeleteCall<'a, C> {
5176 self._name = new_value.to_string();
5177 self
5178 }
5179 /// Optional. A request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes after the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
5180 ///
5181 /// Sets the *request id* query property to the given value.
5182 pub fn request_id(mut self, new_value: &str) -> ProjectLocationGroupDeleteCall<'a, C> {
5183 self._request_id = Some(new_value.to_string());
5184 self
5185 }
5186 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5187 /// while executing the actual API request.
5188 ///
5189 /// ````text
5190 /// It should be used to handle progress information, and to implement a certain level of resilience.
5191 /// ````
5192 ///
5193 /// Sets the *delegate* property to the given value.
5194 pub fn delegate(
5195 mut self,
5196 new_value: &'a mut dyn common::Delegate,
5197 ) -> ProjectLocationGroupDeleteCall<'a, C> {
5198 self._delegate = Some(new_value);
5199 self
5200 }
5201
5202 /// Set any additional parameter of the query string used in the request.
5203 /// It should be used to set parameters which are not yet available through their own
5204 /// setters.
5205 ///
5206 /// Please note that this method must not be used to set any of the known parameters
5207 /// which have their own setter method. If done anyway, the request will fail.
5208 ///
5209 /// # Additional Parameters
5210 ///
5211 /// * *$.xgafv* (query-string) - V1 error format.
5212 /// * *access_token* (query-string) - OAuth access token.
5213 /// * *alt* (query-string) - Data format for response.
5214 /// * *callback* (query-string) - JSONP
5215 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5216 /// * *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.
5217 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5218 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5219 /// * *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.
5220 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5221 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5222 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGroupDeleteCall<'a, C>
5223 where
5224 T: AsRef<str>,
5225 {
5226 self._additional_params
5227 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5228 self
5229 }
5230
5231 /// Identifies the authorization scope for the method you are building.
5232 ///
5233 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5234 /// [`Scope::CloudPlatform`].
5235 ///
5236 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5237 /// tokens for more than one scope.
5238 ///
5239 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5240 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5241 /// sufficient, a read-write scope will do as well.
5242 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGroupDeleteCall<'a, C>
5243 where
5244 St: AsRef<str>,
5245 {
5246 self._scopes.insert(String::from(scope.as_ref()));
5247 self
5248 }
5249 /// Identifies the authorization scope(s) for the method you are building.
5250 ///
5251 /// See [`Self::add_scope()`] for details.
5252 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGroupDeleteCall<'a, C>
5253 where
5254 I: IntoIterator<Item = St>,
5255 St: AsRef<str>,
5256 {
5257 self._scopes
5258 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5259 self
5260 }
5261
5262 /// Removes all scopes, and no default scope will be used either.
5263 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5264 /// for details).
5265 pub fn clear_scopes(mut self) -> ProjectLocationGroupDeleteCall<'a, C> {
5266 self._scopes.clear();
5267 self
5268 }
5269}
5270
5271/// Gets details of a single Group.
5272///
5273/// A builder for the *locations.groups.get* method supported by a *project* resource.
5274/// It is not used directly, but through a [`ProjectMethods`] instance.
5275///
5276/// # Example
5277///
5278/// Instantiate a resource method builder
5279///
5280/// ```test_harness,no_run
5281/// # extern crate hyper;
5282/// # extern crate hyper_rustls;
5283/// # extern crate google_vmmigration1 as vmmigration1;
5284/// # async fn dox() {
5285/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5286///
5287/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5288/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5289/// # secret,
5290/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5291/// # ).build().await.unwrap();
5292///
5293/// # let client = hyper_util::client::legacy::Client::builder(
5294/// # hyper_util::rt::TokioExecutor::new()
5295/// # )
5296/// # .build(
5297/// # hyper_rustls::HttpsConnectorBuilder::new()
5298/// # .with_native_roots()
5299/// # .unwrap()
5300/// # .https_or_http()
5301/// # .enable_http1()
5302/// # .build()
5303/// # );
5304/// # let mut hub = VMMigrationService::new(client, auth);
5305/// // You can configure optional parameters by calling the respective setters at will, and
5306/// // execute the final call using `doit()`.
5307/// // Values shown here are possibly random and not representative !
5308/// let result = hub.projects().locations_groups_get("name")
5309/// .doit().await;
5310/// # }
5311/// ```
5312pub struct ProjectLocationGroupGetCall<'a, C>
5313where
5314 C: 'a,
5315{
5316 hub: &'a VMMigrationService<C>,
5317 _name: String,
5318 _delegate: Option<&'a mut dyn common::Delegate>,
5319 _additional_params: HashMap<String, String>,
5320 _scopes: BTreeSet<String>,
5321}
5322
5323impl<'a, C> common::CallBuilder for ProjectLocationGroupGetCall<'a, C> {}
5324
5325impl<'a, C> ProjectLocationGroupGetCall<'a, C>
5326where
5327 C: common::Connector,
5328{
5329 /// Perform the operation you have build so far.
5330 pub async fn doit(mut self) -> common::Result<(common::Response, Group)> {
5331 use std::borrow::Cow;
5332 use std::io::{Read, Seek};
5333
5334 use common::{url::Params, ToParts};
5335 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5336
5337 let mut dd = common::DefaultDelegate;
5338 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5339 dlg.begin(common::MethodInfo {
5340 id: "vmmigration.projects.locations.groups.get",
5341 http_method: hyper::Method::GET,
5342 });
5343
5344 for &field in ["alt", "name"].iter() {
5345 if self._additional_params.contains_key(field) {
5346 dlg.finished(false);
5347 return Err(common::Error::FieldClash(field));
5348 }
5349 }
5350
5351 let mut params = Params::with_capacity(3 + self._additional_params.len());
5352 params.push("name", self._name);
5353
5354 params.extend(self._additional_params.iter());
5355
5356 params.push("alt", "json");
5357 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5358 if self._scopes.is_empty() {
5359 self._scopes
5360 .insert(Scope::CloudPlatform.as_ref().to_string());
5361 }
5362
5363 #[allow(clippy::single_element_loop)]
5364 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5365 url = params.uri_replacement(url, param_name, find_this, true);
5366 }
5367 {
5368 let to_remove = ["name"];
5369 params.remove_params(&to_remove);
5370 }
5371
5372 let url = params.parse_with_url(&url);
5373
5374 loop {
5375 let token = match self
5376 .hub
5377 .auth
5378 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5379 .await
5380 {
5381 Ok(token) => token,
5382 Err(e) => match dlg.token(e) {
5383 Ok(token) => token,
5384 Err(e) => {
5385 dlg.finished(false);
5386 return Err(common::Error::MissingToken(e));
5387 }
5388 },
5389 };
5390 let mut req_result = {
5391 let client = &self.hub.client;
5392 dlg.pre_request();
5393 let mut req_builder = hyper::Request::builder()
5394 .method(hyper::Method::GET)
5395 .uri(url.as_str())
5396 .header(USER_AGENT, self.hub._user_agent.clone());
5397
5398 if let Some(token) = token.as_ref() {
5399 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5400 }
5401
5402 let request = req_builder
5403 .header(CONTENT_LENGTH, 0_u64)
5404 .body(common::to_body::<String>(None));
5405
5406 client.request(request.unwrap()).await
5407 };
5408
5409 match req_result {
5410 Err(err) => {
5411 if let common::Retry::After(d) = dlg.http_error(&err) {
5412 sleep(d).await;
5413 continue;
5414 }
5415 dlg.finished(false);
5416 return Err(common::Error::HttpError(err));
5417 }
5418 Ok(res) => {
5419 let (mut parts, body) = res.into_parts();
5420 let mut body = common::Body::new(body);
5421 if !parts.status.is_success() {
5422 let bytes = common::to_bytes(body).await.unwrap_or_default();
5423 let error = serde_json::from_str(&common::to_string(&bytes));
5424 let response = common::to_response(parts, bytes.into());
5425
5426 if let common::Retry::After(d) =
5427 dlg.http_failure(&response, error.as_ref().ok())
5428 {
5429 sleep(d).await;
5430 continue;
5431 }
5432
5433 dlg.finished(false);
5434
5435 return Err(match error {
5436 Ok(value) => common::Error::BadRequest(value),
5437 _ => common::Error::Failure(response),
5438 });
5439 }
5440 let response = {
5441 let bytes = common::to_bytes(body).await.unwrap_or_default();
5442 let encoded = common::to_string(&bytes);
5443 match serde_json::from_str(&encoded) {
5444 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5445 Err(error) => {
5446 dlg.response_json_decode_error(&encoded, &error);
5447 return Err(common::Error::JsonDecodeError(
5448 encoded.to_string(),
5449 error,
5450 ));
5451 }
5452 }
5453 };
5454
5455 dlg.finished(true);
5456 return Ok(response);
5457 }
5458 }
5459 }
5460 }
5461
5462 /// Required. The group name.
5463 ///
5464 /// Sets the *name* path property to the given value.
5465 ///
5466 /// Even though the property as already been set when instantiating this call,
5467 /// we provide this method for API completeness.
5468 pub fn name(mut self, new_value: &str) -> ProjectLocationGroupGetCall<'a, C> {
5469 self._name = new_value.to_string();
5470 self
5471 }
5472 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5473 /// while executing the actual API request.
5474 ///
5475 /// ````text
5476 /// It should be used to handle progress information, and to implement a certain level of resilience.
5477 /// ````
5478 ///
5479 /// Sets the *delegate* property to the given value.
5480 pub fn delegate(
5481 mut self,
5482 new_value: &'a mut dyn common::Delegate,
5483 ) -> ProjectLocationGroupGetCall<'a, C> {
5484 self._delegate = Some(new_value);
5485 self
5486 }
5487
5488 /// Set any additional parameter of the query string used in the request.
5489 /// It should be used to set parameters which are not yet available through their own
5490 /// setters.
5491 ///
5492 /// Please note that this method must not be used to set any of the known parameters
5493 /// which have their own setter method. If done anyway, the request will fail.
5494 ///
5495 /// # Additional Parameters
5496 ///
5497 /// * *$.xgafv* (query-string) - V1 error format.
5498 /// * *access_token* (query-string) - OAuth access token.
5499 /// * *alt* (query-string) - Data format for response.
5500 /// * *callback* (query-string) - JSONP
5501 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5502 /// * *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.
5503 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5504 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5505 /// * *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.
5506 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5507 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5508 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGroupGetCall<'a, C>
5509 where
5510 T: AsRef<str>,
5511 {
5512 self._additional_params
5513 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5514 self
5515 }
5516
5517 /// Identifies the authorization scope for the method you are building.
5518 ///
5519 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5520 /// [`Scope::CloudPlatform`].
5521 ///
5522 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5523 /// tokens for more than one scope.
5524 ///
5525 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5526 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5527 /// sufficient, a read-write scope will do as well.
5528 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGroupGetCall<'a, C>
5529 where
5530 St: AsRef<str>,
5531 {
5532 self._scopes.insert(String::from(scope.as_ref()));
5533 self
5534 }
5535 /// Identifies the authorization scope(s) for the method you are building.
5536 ///
5537 /// See [`Self::add_scope()`] for details.
5538 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGroupGetCall<'a, C>
5539 where
5540 I: IntoIterator<Item = St>,
5541 St: AsRef<str>,
5542 {
5543 self._scopes
5544 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5545 self
5546 }
5547
5548 /// Removes all scopes, and no default scope will be used either.
5549 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5550 /// for details).
5551 pub fn clear_scopes(mut self) -> ProjectLocationGroupGetCall<'a, C> {
5552 self._scopes.clear();
5553 self
5554 }
5555}
5556
5557/// Lists Groups in a given project and location.
5558///
5559/// A builder for the *locations.groups.list* method supported by a *project* resource.
5560/// It is not used directly, but through a [`ProjectMethods`] instance.
5561///
5562/// # Example
5563///
5564/// Instantiate a resource method builder
5565///
5566/// ```test_harness,no_run
5567/// # extern crate hyper;
5568/// # extern crate hyper_rustls;
5569/// # extern crate google_vmmigration1 as vmmigration1;
5570/// # async fn dox() {
5571/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5572///
5573/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5574/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5575/// # secret,
5576/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5577/// # ).build().await.unwrap();
5578///
5579/// # let client = hyper_util::client::legacy::Client::builder(
5580/// # hyper_util::rt::TokioExecutor::new()
5581/// # )
5582/// # .build(
5583/// # hyper_rustls::HttpsConnectorBuilder::new()
5584/// # .with_native_roots()
5585/// # .unwrap()
5586/// # .https_or_http()
5587/// # .enable_http1()
5588/// # .build()
5589/// # );
5590/// # let mut hub = VMMigrationService::new(client, auth);
5591/// // You can configure optional parameters by calling the respective setters at will, and
5592/// // execute the final call using `doit()`.
5593/// // Values shown here are possibly random and not representative !
5594/// let result = hub.projects().locations_groups_list("parent")
5595/// .page_token("dolor")
5596/// .page_size(-17)
5597/// .order_by("ipsum")
5598/// .filter("invidunt")
5599/// .doit().await;
5600/// # }
5601/// ```
5602pub struct ProjectLocationGroupListCall<'a, C>
5603where
5604 C: 'a,
5605{
5606 hub: &'a VMMigrationService<C>,
5607 _parent: String,
5608 _page_token: Option<String>,
5609 _page_size: Option<i32>,
5610 _order_by: Option<String>,
5611 _filter: Option<String>,
5612 _delegate: Option<&'a mut dyn common::Delegate>,
5613 _additional_params: HashMap<String, String>,
5614 _scopes: BTreeSet<String>,
5615}
5616
5617impl<'a, C> common::CallBuilder for ProjectLocationGroupListCall<'a, C> {}
5618
5619impl<'a, C> ProjectLocationGroupListCall<'a, C>
5620where
5621 C: common::Connector,
5622{
5623 /// Perform the operation you have build so far.
5624 pub async fn doit(mut self) -> common::Result<(common::Response, ListGroupsResponse)> {
5625 use std::borrow::Cow;
5626 use std::io::{Read, Seek};
5627
5628 use common::{url::Params, ToParts};
5629 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5630
5631 let mut dd = common::DefaultDelegate;
5632 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5633 dlg.begin(common::MethodInfo {
5634 id: "vmmigration.projects.locations.groups.list",
5635 http_method: hyper::Method::GET,
5636 });
5637
5638 for &field in [
5639 "alt",
5640 "parent",
5641 "pageToken",
5642 "pageSize",
5643 "orderBy",
5644 "filter",
5645 ]
5646 .iter()
5647 {
5648 if self._additional_params.contains_key(field) {
5649 dlg.finished(false);
5650 return Err(common::Error::FieldClash(field));
5651 }
5652 }
5653
5654 let mut params = Params::with_capacity(7 + self._additional_params.len());
5655 params.push("parent", self._parent);
5656 if let Some(value) = self._page_token.as_ref() {
5657 params.push("pageToken", value);
5658 }
5659 if let Some(value) = self._page_size.as_ref() {
5660 params.push("pageSize", value.to_string());
5661 }
5662 if let Some(value) = self._order_by.as_ref() {
5663 params.push("orderBy", value);
5664 }
5665 if let Some(value) = self._filter.as_ref() {
5666 params.push("filter", value);
5667 }
5668
5669 params.extend(self._additional_params.iter());
5670
5671 params.push("alt", "json");
5672 let mut url = self.hub._base_url.clone() + "v1/{+parent}/groups";
5673 if self._scopes.is_empty() {
5674 self._scopes
5675 .insert(Scope::CloudPlatform.as_ref().to_string());
5676 }
5677
5678 #[allow(clippy::single_element_loop)]
5679 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5680 url = params.uri_replacement(url, param_name, find_this, true);
5681 }
5682 {
5683 let to_remove = ["parent"];
5684 params.remove_params(&to_remove);
5685 }
5686
5687 let url = params.parse_with_url(&url);
5688
5689 loop {
5690 let token = match self
5691 .hub
5692 .auth
5693 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5694 .await
5695 {
5696 Ok(token) => token,
5697 Err(e) => match dlg.token(e) {
5698 Ok(token) => token,
5699 Err(e) => {
5700 dlg.finished(false);
5701 return Err(common::Error::MissingToken(e));
5702 }
5703 },
5704 };
5705 let mut req_result = {
5706 let client = &self.hub.client;
5707 dlg.pre_request();
5708 let mut req_builder = hyper::Request::builder()
5709 .method(hyper::Method::GET)
5710 .uri(url.as_str())
5711 .header(USER_AGENT, self.hub._user_agent.clone());
5712
5713 if let Some(token) = token.as_ref() {
5714 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5715 }
5716
5717 let request = req_builder
5718 .header(CONTENT_LENGTH, 0_u64)
5719 .body(common::to_body::<String>(None));
5720
5721 client.request(request.unwrap()).await
5722 };
5723
5724 match req_result {
5725 Err(err) => {
5726 if let common::Retry::After(d) = dlg.http_error(&err) {
5727 sleep(d).await;
5728 continue;
5729 }
5730 dlg.finished(false);
5731 return Err(common::Error::HttpError(err));
5732 }
5733 Ok(res) => {
5734 let (mut parts, body) = res.into_parts();
5735 let mut body = common::Body::new(body);
5736 if !parts.status.is_success() {
5737 let bytes = common::to_bytes(body).await.unwrap_or_default();
5738 let error = serde_json::from_str(&common::to_string(&bytes));
5739 let response = common::to_response(parts, bytes.into());
5740
5741 if let common::Retry::After(d) =
5742 dlg.http_failure(&response, error.as_ref().ok())
5743 {
5744 sleep(d).await;
5745 continue;
5746 }
5747
5748 dlg.finished(false);
5749
5750 return Err(match error {
5751 Ok(value) => common::Error::BadRequest(value),
5752 _ => common::Error::Failure(response),
5753 });
5754 }
5755 let response = {
5756 let bytes = common::to_bytes(body).await.unwrap_or_default();
5757 let encoded = common::to_string(&bytes);
5758 match serde_json::from_str(&encoded) {
5759 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5760 Err(error) => {
5761 dlg.response_json_decode_error(&encoded, &error);
5762 return Err(common::Error::JsonDecodeError(
5763 encoded.to_string(),
5764 error,
5765 ));
5766 }
5767 }
5768 };
5769
5770 dlg.finished(true);
5771 return Ok(response);
5772 }
5773 }
5774 }
5775 }
5776
5777 /// Required. The parent, which owns this collection of groups.
5778 ///
5779 /// Sets the *parent* path property to the given value.
5780 ///
5781 /// Even though the property as already been set when instantiating this call,
5782 /// we provide this method for API completeness.
5783 pub fn parent(mut self, new_value: &str) -> ProjectLocationGroupListCall<'a, C> {
5784 self._parent = new_value.to_string();
5785 self
5786 }
5787 /// Required. A page token, received from a previous `ListGroups` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListGroups` must match the call that provided the page token.
5788 ///
5789 /// Sets the *page token* query property to the given value.
5790 pub fn page_token(mut self, new_value: &str) -> ProjectLocationGroupListCall<'a, C> {
5791 self._page_token = Some(new_value.to_string());
5792 self
5793 }
5794 /// Optional. The maximum number of groups to return. The service may return fewer than this value. If unspecified, at most 500 groups will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
5795 ///
5796 /// Sets the *page size* query property to the given value.
5797 pub fn page_size(mut self, new_value: i32) -> ProjectLocationGroupListCall<'a, C> {
5798 self._page_size = Some(new_value);
5799 self
5800 }
5801 /// Optional. the order by fields for the result.
5802 ///
5803 /// Sets the *order by* query property to the given value.
5804 pub fn order_by(mut self, new_value: &str) -> ProjectLocationGroupListCall<'a, C> {
5805 self._order_by = Some(new_value.to_string());
5806 self
5807 }
5808 /// Optional. The filter request.
5809 ///
5810 /// Sets the *filter* query property to the given value.
5811 pub fn filter(mut self, new_value: &str) -> ProjectLocationGroupListCall<'a, C> {
5812 self._filter = Some(new_value.to_string());
5813 self
5814 }
5815 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5816 /// while executing the actual API request.
5817 ///
5818 /// ````text
5819 /// It should be used to handle progress information, and to implement a certain level of resilience.
5820 /// ````
5821 ///
5822 /// Sets the *delegate* property to the given value.
5823 pub fn delegate(
5824 mut self,
5825 new_value: &'a mut dyn common::Delegate,
5826 ) -> ProjectLocationGroupListCall<'a, C> {
5827 self._delegate = Some(new_value);
5828 self
5829 }
5830
5831 /// Set any additional parameter of the query string used in the request.
5832 /// It should be used to set parameters which are not yet available through their own
5833 /// setters.
5834 ///
5835 /// Please note that this method must not be used to set any of the known parameters
5836 /// which have their own setter method. If done anyway, the request will fail.
5837 ///
5838 /// # Additional Parameters
5839 ///
5840 /// * *$.xgafv* (query-string) - V1 error format.
5841 /// * *access_token* (query-string) - OAuth access token.
5842 /// * *alt* (query-string) - Data format for response.
5843 /// * *callback* (query-string) - JSONP
5844 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5845 /// * *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.
5846 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5847 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5848 /// * *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.
5849 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5850 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5851 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGroupListCall<'a, C>
5852 where
5853 T: AsRef<str>,
5854 {
5855 self._additional_params
5856 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5857 self
5858 }
5859
5860 /// Identifies the authorization scope for the method you are building.
5861 ///
5862 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5863 /// [`Scope::CloudPlatform`].
5864 ///
5865 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5866 /// tokens for more than one scope.
5867 ///
5868 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5869 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5870 /// sufficient, a read-write scope will do as well.
5871 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGroupListCall<'a, C>
5872 where
5873 St: AsRef<str>,
5874 {
5875 self._scopes.insert(String::from(scope.as_ref()));
5876 self
5877 }
5878 /// Identifies the authorization scope(s) for the method you are building.
5879 ///
5880 /// See [`Self::add_scope()`] for details.
5881 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGroupListCall<'a, C>
5882 where
5883 I: IntoIterator<Item = St>,
5884 St: AsRef<str>,
5885 {
5886 self._scopes
5887 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5888 self
5889 }
5890
5891 /// Removes all scopes, and no default scope will be used either.
5892 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5893 /// for details).
5894 pub fn clear_scopes(mut self) -> ProjectLocationGroupListCall<'a, C> {
5895 self._scopes.clear();
5896 self
5897 }
5898}
5899
5900/// Updates the parameters of a single Group.
5901///
5902/// A builder for the *locations.groups.patch* method supported by a *project* resource.
5903/// It is not used directly, but through a [`ProjectMethods`] instance.
5904///
5905/// # Example
5906///
5907/// Instantiate a resource method builder
5908///
5909/// ```test_harness,no_run
5910/// # extern crate hyper;
5911/// # extern crate hyper_rustls;
5912/// # extern crate google_vmmigration1 as vmmigration1;
5913/// use vmmigration1::api::Group;
5914/// # async fn dox() {
5915/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5916///
5917/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5918/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5919/// # secret,
5920/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5921/// # ).build().await.unwrap();
5922///
5923/// # let client = hyper_util::client::legacy::Client::builder(
5924/// # hyper_util::rt::TokioExecutor::new()
5925/// # )
5926/// # .build(
5927/// # hyper_rustls::HttpsConnectorBuilder::new()
5928/// # .with_native_roots()
5929/// # .unwrap()
5930/// # .https_or_http()
5931/// # .enable_http1()
5932/// # .build()
5933/// # );
5934/// # let mut hub = VMMigrationService::new(client, auth);
5935/// // As the method needs a request, you would usually fill it with the desired information
5936/// // into the respective structure. Some of the parts shown here might not be applicable !
5937/// // Values shown here are possibly random and not representative !
5938/// let mut req = Group::default();
5939///
5940/// // You can configure optional parameters by calling the respective setters at will, and
5941/// // execute the final call using `doit()`.
5942/// // Values shown here are possibly random and not representative !
5943/// let result = hub.projects().locations_groups_patch(req, "name")
5944/// .update_mask(FieldMask::new::<&str>(&[]))
5945/// .request_id("duo")
5946/// .doit().await;
5947/// # }
5948/// ```
5949pub struct ProjectLocationGroupPatchCall<'a, C>
5950where
5951 C: 'a,
5952{
5953 hub: &'a VMMigrationService<C>,
5954 _request: Group,
5955 _name: String,
5956 _update_mask: Option<common::FieldMask>,
5957 _request_id: Option<String>,
5958 _delegate: Option<&'a mut dyn common::Delegate>,
5959 _additional_params: HashMap<String, String>,
5960 _scopes: BTreeSet<String>,
5961}
5962
5963impl<'a, C> common::CallBuilder for ProjectLocationGroupPatchCall<'a, C> {}
5964
5965impl<'a, C> ProjectLocationGroupPatchCall<'a, C>
5966where
5967 C: common::Connector,
5968{
5969 /// Perform the operation you have build so far.
5970 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5971 use std::borrow::Cow;
5972 use std::io::{Read, Seek};
5973
5974 use common::{url::Params, ToParts};
5975 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5976
5977 let mut dd = common::DefaultDelegate;
5978 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5979 dlg.begin(common::MethodInfo {
5980 id: "vmmigration.projects.locations.groups.patch",
5981 http_method: hyper::Method::PATCH,
5982 });
5983
5984 for &field in ["alt", "name", "updateMask", "requestId"].iter() {
5985 if self._additional_params.contains_key(field) {
5986 dlg.finished(false);
5987 return Err(common::Error::FieldClash(field));
5988 }
5989 }
5990
5991 let mut params = Params::with_capacity(6 + self._additional_params.len());
5992 params.push("name", self._name);
5993 if let Some(value) = self._update_mask.as_ref() {
5994 params.push("updateMask", value.to_string());
5995 }
5996 if let Some(value) = self._request_id.as_ref() {
5997 params.push("requestId", value);
5998 }
5999
6000 params.extend(self._additional_params.iter());
6001
6002 params.push("alt", "json");
6003 let mut url = self.hub._base_url.clone() + "v1/{+name}";
6004 if self._scopes.is_empty() {
6005 self._scopes
6006 .insert(Scope::CloudPlatform.as_ref().to_string());
6007 }
6008
6009 #[allow(clippy::single_element_loop)]
6010 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6011 url = params.uri_replacement(url, param_name, find_this, true);
6012 }
6013 {
6014 let to_remove = ["name"];
6015 params.remove_params(&to_remove);
6016 }
6017
6018 let url = params.parse_with_url(&url);
6019
6020 let mut json_mime_type = mime::APPLICATION_JSON;
6021 let mut request_value_reader = {
6022 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6023 common::remove_json_null_values(&mut value);
6024 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6025 serde_json::to_writer(&mut dst, &value).unwrap();
6026 dst
6027 };
6028 let request_size = request_value_reader
6029 .seek(std::io::SeekFrom::End(0))
6030 .unwrap();
6031 request_value_reader
6032 .seek(std::io::SeekFrom::Start(0))
6033 .unwrap();
6034
6035 loop {
6036 let token = match self
6037 .hub
6038 .auth
6039 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6040 .await
6041 {
6042 Ok(token) => token,
6043 Err(e) => match dlg.token(e) {
6044 Ok(token) => token,
6045 Err(e) => {
6046 dlg.finished(false);
6047 return Err(common::Error::MissingToken(e));
6048 }
6049 },
6050 };
6051 request_value_reader
6052 .seek(std::io::SeekFrom::Start(0))
6053 .unwrap();
6054 let mut req_result = {
6055 let client = &self.hub.client;
6056 dlg.pre_request();
6057 let mut req_builder = hyper::Request::builder()
6058 .method(hyper::Method::PATCH)
6059 .uri(url.as_str())
6060 .header(USER_AGENT, self.hub._user_agent.clone());
6061
6062 if let Some(token) = token.as_ref() {
6063 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6064 }
6065
6066 let request = req_builder
6067 .header(CONTENT_TYPE, json_mime_type.to_string())
6068 .header(CONTENT_LENGTH, request_size as u64)
6069 .body(common::to_body(
6070 request_value_reader.get_ref().clone().into(),
6071 ));
6072
6073 client.request(request.unwrap()).await
6074 };
6075
6076 match req_result {
6077 Err(err) => {
6078 if let common::Retry::After(d) = dlg.http_error(&err) {
6079 sleep(d).await;
6080 continue;
6081 }
6082 dlg.finished(false);
6083 return Err(common::Error::HttpError(err));
6084 }
6085 Ok(res) => {
6086 let (mut parts, body) = res.into_parts();
6087 let mut body = common::Body::new(body);
6088 if !parts.status.is_success() {
6089 let bytes = common::to_bytes(body).await.unwrap_or_default();
6090 let error = serde_json::from_str(&common::to_string(&bytes));
6091 let response = common::to_response(parts, bytes.into());
6092
6093 if let common::Retry::After(d) =
6094 dlg.http_failure(&response, error.as_ref().ok())
6095 {
6096 sleep(d).await;
6097 continue;
6098 }
6099
6100 dlg.finished(false);
6101
6102 return Err(match error {
6103 Ok(value) => common::Error::BadRequest(value),
6104 _ => common::Error::Failure(response),
6105 });
6106 }
6107 let response = {
6108 let bytes = common::to_bytes(body).await.unwrap_or_default();
6109 let encoded = common::to_string(&bytes);
6110 match serde_json::from_str(&encoded) {
6111 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6112 Err(error) => {
6113 dlg.response_json_decode_error(&encoded, &error);
6114 return Err(common::Error::JsonDecodeError(
6115 encoded.to_string(),
6116 error,
6117 ));
6118 }
6119 }
6120 };
6121
6122 dlg.finished(true);
6123 return Ok(response);
6124 }
6125 }
6126 }
6127 }
6128
6129 ///
6130 /// Sets the *request* property to the given value.
6131 ///
6132 /// Even though the property as already been set when instantiating this call,
6133 /// we provide this method for API completeness.
6134 pub fn request(mut self, new_value: Group) -> ProjectLocationGroupPatchCall<'a, C> {
6135 self._request = new_value;
6136 self
6137 }
6138 /// Output only. The Group name.
6139 ///
6140 /// Sets the *name* path property to the given value.
6141 ///
6142 /// Even though the property as already been set when instantiating this call,
6143 /// we provide this method for API completeness.
6144 pub fn name(mut self, new_value: &str) -> ProjectLocationGroupPatchCall<'a, C> {
6145 self._name = new_value.to_string();
6146 self
6147 }
6148 /// Field mask is used to specify the fields to be overwritten in the Group resource by the update. The fields specified in the update_mask are relative to the resource, not the full request. A field will be overwritten if it is in the mask. If the user does not provide a mask then all fields will be overwritten.
6149 ///
6150 /// Sets the *update mask* query property to the given value.
6151 pub fn update_mask(
6152 mut self,
6153 new_value: common::FieldMask,
6154 ) -> ProjectLocationGroupPatchCall<'a, C> {
6155 self._update_mask = Some(new_value);
6156 self
6157 }
6158 /// A request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes since the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
6159 ///
6160 /// Sets the *request id* query property to the given value.
6161 pub fn request_id(mut self, new_value: &str) -> ProjectLocationGroupPatchCall<'a, C> {
6162 self._request_id = Some(new_value.to_string());
6163 self
6164 }
6165 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6166 /// while executing the actual API request.
6167 ///
6168 /// ````text
6169 /// It should be used to handle progress information, and to implement a certain level of resilience.
6170 /// ````
6171 ///
6172 /// Sets the *delegate* property to the given value.
6173 pub fn delegate(
6174 mut self,
6175 new_value: &'a mut dyn common::Delegate,
6176 ) -> ProjectLocationGroupPatchCall<'a, C> {
6177 self._delegate = Some(new_value);
6178 self
6179 }
6180
6181 /// Set any additional parameter of the query string used in the request.
6182 /// It should be used to set parameters which are not yet available through their own
6183 /// setters.
6184 ///
6185 /// Please note that this method must not be used to set any of the known parameters
6186 /// which have their own setter method. If done anyway, the request will fail.
6187 ///
6188 /// # Additional Parameters
6189 ///
6190 /// * *$.xgafv* (query-string) - V1 error format.
6191 /// * *access_token* (query-string) - OAuth access token.
6192 /// * *alt* (query-string) - Data format for response.
6193 /// * *callback* (query-string) - JSONP
6194 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6195 /// * *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.
6196 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6197 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6198 /// * *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.
6199 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6200 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6201 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGroupPatchCall<'a, C>
6202 where
6203 T: AsRef<str>,
6204 {
6205 self._additional_params
6206 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6207 self
6208 }
6209
6210 /// Identifies the authorization scope for the method you are building.
6211 ///
6212 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6213 /// [`Scope::CloudPlatform`].
6214 ///
6215 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6216 /// tokens for more than one scope.
6217 ///
6218 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6219 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6220 /// sufficient, a read-write scope will do as well.
6221 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGroupPatchCall<'a, C>
6222 where
6223 St: AsRef<str>,
6224 {
6225 self._scopes.insert(String::from(scope.as_ref()));
6226 self
6227 }
6228 /// Identifies the authorization scope(s) for the method you are building.
6229 ///
6230 /// See [`Self::add_scope()`] for details.
6231 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGroupPatchCall<'a, C>
6232 where
6233 I: IntoIterator<Item = St>,
6234 St: AsRef<str>,
6235 {
6236 self._scopes
6237 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6238 self
6239 }
6240
6241 /// Removes all scopes, and no default scope will be used either.
6242 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6243 /// for details).
6244 pub fn clear_scopes(mut self) -> ProjectLocationGroupPatchCall<'a, C> {
6245 self._scopes.clear();
6246 self
6247 }
6248}
6249
6250/// Removes a MigratingVm from a Group.
6251///
6252/// A builder for the *locations.groups.removeGroupMigration* method supported by a *project* resource.
6253/// It is not used directly, but through a [`ProjectMethods`] instance.
6254///
6255/// # Example
6256///
6257/// Instantiate a resource method builder
6258///
6259/// ```test_harness,no_run
6260/// # extern crate hyper;
6261/// # extern crate hyper_rustls;
6262/// # extern crate google_vmmigration1 as vmmigration1;
6263/// use vmmigration1::api::RemoveGroupMigrationRequest;
6264/// # async fn dox() {
6265/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6266///
6267/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6268/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6269/// # secret,
6270/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6271/// # ).build().await.unwrap();
6272///
6273/// # let client = hyper_util::client::legacy::Client::builder(
6274/// # hyper_util::rt::TokioExecutor::new()
6275/// # )
6276/// # .build(
6277/// # hyper_rustls::HttpsConnectorBuilder::new()
6278/// # .with_native_roots()
6279/// # .unwrap()
6280/// # .https_or_http()
6281/// # .enable_http1()
6282/// # .build()
6283/// # );
6284/// # let mut hub = VMMigrationService::new(client, auth);
6285/// // As the method needs a request, you would usually fill it with the desired information
6286/// // into the respective structure. Some of the parts shown here might not be applicable !
6287/// // Values shown here are possibly random and not representative !
6288/// let mut req = RemoveGroupMigrationRequest::default();
6289///
6290/// // You can configure optional parameters by calling the respective setters at will, and
6291/// // execute the final call using `doit()`.
6292/// // Values shown here are possibly random and not representative !
6293/// let result = hub.projects().locations_groups_remove_group_migration(req, "group")
6294/// .doit().await;
6295/// # }
6296/// ```
6297pub struct ProjectLocationGroupRemoveGroupMigrationCall<'a, C>
6298where
6299 C: 'a,
6300{
6301 hub: &'a VMMigrationService<C>,
6302 _request: RemoveGroupMigrationRequest,
6303 _group: String,
6304 _delegate: Option<&'a mut dyn common::Delegate>,
6305 _additional_params: HashMap<String, String>,
6306 _scopes: BTreeSet<String>,
6307}
6308
6309impl<'a, C> common::CallBuilder for ProjectLocationGroupRemoveGroupMigrationCall<'a, C> {}
6310
6311impl<'a, C> ProjectLocationGroupRemoveGroupMigrationCall<'a, C>
6312where
6313 C: common::Connector,
6314{
6315 /// Perform the operation you have build so far.
6316 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6317 use std::borrow::Cow;
6318 use std::io::{Read, Seek};
6319
6320 use common::{url::Params, ToParts};
6321 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6322
6323 let mut dd = common::DefaultDelegate;
6324 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6325 dlg.begin(common::MethodInfo {
6326 id: "vmmigration.projects.locations.groups.removeGroupMigration",
6327 http_method: hyper::Method::POST,
6328 });
6329
6330 for &field in ["alt", "group"].iter() {
6331 if self._additional_params.contains_key(field) {
6332 dlg.finished(false);
6333 return Err(common::Error::FieldClash(field));
6334 }
6335 }
6336
6337 let mut params = Params::with_capacity(4 + self._additional_params.len());
6338 params.push("group", self._group);
6339
6340 params.extend(self._additional_params.iter());
6341
6342 params.push("alt", "json");
6343 let mut url = self.hub._base_url.clone() + "v1/{+group}:removeGroupMigration";
6344 if self._scopes.is_empty() {
6345 self._scopes
6346 .insert(Scope::CloudPlatform.as_ref().to_string());
6347 }
6348
6349 #[allow(clippy::single_element_loop)]
6350 for &(find_this, param_name) in [("{+group}", "group")].iter() {
6351 url = params.uri_replacement(url, param_name, find_this, true);
6352 }
6353 {
6354 let to_remove = ["group"];
6355 params.remove_params(&to_remove);
6356 }
6357
6358 let url = params.parse_with_url(&url);
6359
6360 let mut json_mime_type = mime::APPLICATION_JSON;
6361 let mut request_value_reader = {
6362 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6363 common::remove_json_null_values(&mut value);
6364 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6365 serde_json::to_writer(&mut dst, &value).unwrap();
6366 dst
6367 };
6368 let request_size = request_value_reader
6369 .seek(std::io::SeekFrom::End(0))
6370 .unwrap();
6371 request_value_reader
6372 .seek(std::io::SeekFrom::Start(0))
6373 .unwrap();
6374
6375 loop {
6376 let token = match self
6377 .hub
6378 .auth
6379 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6380 .await
6381 {
6382 Ok(token) => token,
6383 Err(e) => match dlg.token(e) {
6384 Ok(token) => token,
6385 Err(e) => {
6386 dlg.finished(false);
6387 return Err(common::Error::MissingToken(e));
6388 }
6389 },
6390 };
6391 request_value_reader
6392 .seek(std::io::SeekFrom::Start(0))
6393 .unwrap();
6394 let mut req_result = {
6395 let client = &self.hub.client;
6396 dlg.pre_request();
6397 let mut req_builder = hyper::Request::builder()
6398 .method(hyper::Method::POST)
6399 .uri(url.as_str())
6400 .header(USER_AGENT, self.hub._user_agent.clone());
6401
6402 if let Some(token) = token.as_ref() {
6403 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6404 }
6405
6406 let request = req_builder
6407 .header(CONTENT_TYPE, json_mime_type.to_string())
6408 .header(CONTENT_LENGTH, request_size as u64)
6409 .body(common::to_body(
6410 request_value_reader.get_ref().clone().into(),
6411 ));
6412
6413 client.request(request.unwrap()).await
6414 };
6415
6416 match req_result {
6417 Err(err) => {
6418 if let common::Retry::After(d) = dlg.http_error(&err) {
6419 sleep(d).await;
6420 continue;
6421 }
6422 dlg.finished(false);
6423 return Err(common::Error::HttpError(err));
6424 }
6425 Ok(res) => {
6426 let (mut parts, body) = res.into_parts();
6427 let mut body = common::Body::new(body);
6428 if !parts.status.is_success() {
6429 let bytes = common::to_bytes(body).await.unwrap_or_default();
6430 let error = serde_json::from_str(&common::to_string(&bytes));
6431 let response = common::to_response(parts, bytes.into());
6432
6433 if let common::Retry::After(d) =
6434 dlg.http_failure(&response, error.as_ref().ok())
6435 {
6436 sleep(d).await;
6437 continue;
6438 }
6439
6440 dlg.finished(false);
6441
6442 return Err(match error {
6443 Ok(value) => common::Error::BadRequest(value),
6444 _ => common::Error::Failure(response),
6445 });
6446 }
6447 let response = {
6448 let bytes = common::to_bytes(body).await.unwrap_or_default();
6449 let encoded = common::to_string(&bytes);
6450 match serde_json::from_str(&encoded) {
6451 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6452 Err(error) => {
6453 dlg.response_json_decode_error(&encoded, &error);
6454 return Err(common::Error::JsonDecodeError(
6455 encoded.to_string(),
6456 error,
6457 ));
6458 }
6459 }
6460 };
6461
6462 dlg.finished(true);
6463 return Ok(response);
6464 }
6465 }
6466 }
6467 }
6468
6469 ///
6470 /// Sets the *request* property to the given value.
6471 ///
6472 /// Even though the property as already been set when instantiating this call,
6473 /// we provide this method for API completeness.
6474 pub fn request(
6475 mut self,
6476 new_value: RemoveGroupMigrationRequest,
6477 ) -> ProjectLocationGroupRemoveGroupMigrationCall<'a, C> {
6478 self._request = new_value;
6479 self
6480 }
6481 /// Required. The name of the Group.
6482 ///
6483 /// Sets the *group* path property to the given value.
6484 ///
6485 /// Even though the property as already been set when instantiating this call,
6486 /// we provide this method for API completeness.
6487 pub fn group(mut self, new_value: &str) -> ProjectLocationGroupRemoveGroupMigrationCall<'a, C> {
6488 self._group = new_value.to_string();
6489 self
6490 }
6491 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6492 /// while executing the actual API request.
6493 ///
6494 /// ````text
6495 /// It should be used to handle progress information, and to implement a certain level of resilience.
6496 /// ````
6497 ///
6498 /// Sets the *delegate* property to the given value.
6499 pub fn delegate(
6500 mut self,
6501 new_value: &'a mut dyn common::Delegate,
6502 ) -> ProjectLocationGroupRemoveGroupMigrationCall<'a, C> {
6503 self._delegate = Some(new_value);
6504 self
6505 }
6506
6507 /// Set any additional parameter of the query string used in the request.
6508 /// It should be used to set parameters which are not yet available through their own
6509 /// setters.
6510 ///
6511 /// Please note that this method must not be used to set any of the known parameters
6512 /// which have their own setter method. If done anyway, the request will fail.
6513 ///
6514 /// # Additional Parameters
6515 ///
6516 /// * *$.xgafv* (query-string) - V1 error format.
6517 /// * *access_token* (query-string) - OAuth access token.
6518 /// * *alt* (query-string) - Data format for response.
6519 /// * *callback* (query-string) - JSONP
6520 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6521 /// * *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.
6522 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6523 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6524 /// * *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.
6525 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6526 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6527 pub fn param<T>(
6528 mut self,
6529 name: T,
6530 value: T,
6531 ) -> ProjectLocationGroupRemoveGroupMigrationCall<'a, C>
6532 where
6533 T: AsRef<str>,
6534 {
6535 self._additional_params
6536 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6537 self
6538 }
6539
6540 /// Identifies the authorization scope for the method you are building.
6541 ///
6542 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6543 /// [`Scope::CloudPlatform`].
6544 ///
6545 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6546 /// tokens for more than one scope.
6547 ///
6548 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6549 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6550 /// sufficient, a read-write scope will do as well.
6551 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGroupRemoveGroupMigrationCall<'a, C>
6552 where
6553 St: AsRef<str>,
6554 {
6555 self._scopes.insert(String::from(scope.as_ref()));
6556 self
6557 }
6558 /// Identifies the authorization scope(s) for the method you are building.
6559 ///
6560 /// See [`Self::add_scope()`] for details.
6561 pub fn add_scopes<I, St>(
6562 mut self,
6563 scopes: I,
6564 ) -> ProjectLocationGroupRemoveGroupMigrationCall<'a, C>
6565 where
6566 I: IntoIterator<Item = St>,
6567 St: AsRef<str>,
6568 {
6569 self._scopes
6570 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6571 self
6572 }
6573
6574 /// Removes all scopes, and no default scope will be used either.
6575 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6576 /// for details).
6577 pub fn clear_scopes(mut self) -> ProjectLocationGroupRemoveGroupMigrationCall<'a, C> {
6578 self._scopes.clear();
6579 self
6580 }
6581}
6582
6583/// Initiates the cancellation of a running clone job.
6584///
6585/// A builder for the *locations.imageImports.imageImportJobs.cancel* method supported by a *project* resource.
6586/// It is not used directly, but through a [`ProjectMethods`] instance.
6587///
6588/// # Example
6589///
6590/// Instantiate a resource method builder
6591///
6592/// ```test_harness,no_run
6593/// # extern crate hyper;
6594/// # extern crate hyper_rustls;
6595/// # extern crate google_vmmigration1 as vmmigration1;
6596/// use vmmigration1::api::CancelImageImportJobRequest;
6597/// # async fn dox() {
6598/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6599///
6600/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6601/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6602/// # secret,
6603/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6604/// # ).build().await.unwrap();
6605///
6606/// # let client = hyper_util::client::legacy::Client::builder(
6607/// # hyper_util::rt::TokioExecutor::new()
6608/// # )
6609/// # .build(
6610/// # hyper_rustls::HttpsConnectorBuilder::new()
6611/// # .with_native_roots()
6612/// # .unwrap()
6613/// # .https_or_http()
6614/// # .enable_http1()
6615/// # .build()
6616/// # );
6617/// # let mut hub = VMMigrationService::new(client, auth);
6618/// // As the method needs a request, you would usually fill it with the desired information
6619/// // into the respective structure. Some of the parts shown here might not be applicable !
6620/// // Values shown here are possibly random and not representative !
6621/// let mut req = CancelImageImportJobRequest::default();
6622///
6623/// // You can configure optional parameters by calling the respective setters at will, and
6624/// // execute the final call using `doit()`.
6625/// // Values shown here are possibly random and not representative !
6626/// let result = hub.projects().locations_image_imports_image_import_jobs_cancel(req, "name")
6627/// .doit().await;
6628/// # }
6629/// ```
6630pub struct ProjectLocationImageImportImageImportJobCancelCall<'a, C>
6631where
6632 C: 'a,
6633{
6634 hub: &'a VMMigrationService<C>,
6635 _request: CancelImageImportJobRequest,
6636 _name: String,
6637 _delegate: Option<&'a mut dyn common::Delegate>,
6638 _additional_params: HashMap<String, String>,
6639 _scopes: BTreeSet<String>,
6640}
6641
6642impl<'a, C> common::CallBuilder for ProjectLocationImageImportImageImportJobCancelCall<'a, C> {}
6643
6644impl<'a, C> ProjectLocationImageImportImageImportJobCancelCall<'a, C>
6645where
6646 C: common::Connector,
6647{
6648 /// Perform the operation you have build so far.
6649 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6650 use std::borrow::Cow;
6651 use std::io::{Read, Seek};
6652
6653 use common::{url::Params, ToParts};
6654 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6655
6656 let mut dd = common::DefaultDelegate;
6657 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6658 dlg.begin(common::MethodInfo {
6659 id: "vmmigration.projects.locations.imageImports.imageImportJobs.cancel",
6660 http_method: hyper::Method::POST,
6661 });
6662
6663 for &field in ["alt", "name"].iter() {
6664 if self._additional_params.contains_key(field) {
6665 dlg.finished(false);
6666 return Err(common::Error::FieldClash(field));
6667 }
6668 }
6669
6670 let mut params = Params::with_capacity(4 + self._additional_params.len());
6671 params.push("name", self._name);
6672
6673 params.extend(self._additional_params.iter());
6674
6675 params.push("alt", "json");
6676 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
6677 if self._scopes.is_empty() {
6678 self._scopes
6679 .insert(Scope::CloudPlatform.as_ref().to_string());
6680 }
6681
6682 #[allow(clippy::single_element_loop)]
6683 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6684 url = params.uri_replacement(url, param_name, find_this, true);
6685 }
6686 {
6687 let to_remove = ["name"];
6688 params.remove_params(&to_remove);
6689 }
6690
6691 let url = params.parse_with_url(&url);
6692
6693 let mut json_mime_type = mime::APPLICATION_JSON;
6694 let mut request_value_reader = {
6695 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6696 common::remove_json_null_values(&mut value);
6697 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6698 serde_json::to_writer(&mut dst, &value).unwrap();
6699 dst
6700 };
6701 let request_size = request_value_reader
6702 .seek(std::io::SeekFrom::End(0))
6703 .unwrap();
6704 request_value_reader
6705 .seek(std::io::SeekFrom::Start(0))
6706 .unwrap();
6707
6708 loop {
6709 let token = match self
6710 .hub
6711 .auth
6712 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6713 .await
6714 {
6715 Ok(token) => token,
6716 Err(e) => match dlg.token(e) {
6717 Ok(token) => token,
6718 Err(e) => {
6719 dlg.finished(false);
6720 return Err(common::Error::MissingToken(e));
6721 }
6722 },
6723 };
6724 request_value_reader
6725 .seek(std::io::SeekFrom::Start(0))
6726 .unwrap();
6727 let mut req_result = {
6728 let client = &self.hub.client;
6729 dlg.pre_request();
6730 let mut req_builder = hyper::Request::builder()
6731 .method(hyper::Method::POST)
6732 .uri(url.as_str())
6733 .header(USER_AGENT, self.hub._user_agent.clone());
6734
6735 if let Some(token) = token.as_ref() {
6736 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6737 }
6738
6739 let request = req_builder
6740 .header(CONTENT_TYPE, json_mime_type.to_string())
6741 .header(CONTENT_LENGTH, request_size as u64)
6742 .body(common::to_body(
6743 request_value_reader.get_ref().clone().into(),
6744 ));
6745
6746 client.request(request.unwrap()).await
6747 };
6748
6749 match req_result {
6750 Err(err) => {
6751 if let common::Retry::After(d) = dlg.http_error(&err) {
6752 sleep(d).await;
6753 continue;
6754 }
6755 dlg.finished(false);
6756 return Err(common::Error::HttpError(err));
6757 }
6758 Ok(res) => {
6759 let (mut parts, body) = res.into_parts();
6760 let mut body = common::Body::new(body);
6761 if !parts.status.is_success() {
6762 let bytes = common::to_bytes(body).await.unwrap_or_default();
6763 let error = serde_json::from_str(&common::to_string(&bytes));
6764 let response = common::to_response(parts, bytes.into());
6765
6766 if let common::Retry::After(d) =
6767 dlg.http_failure(&response, error.as_ref().ok())
6768 {
6769 sleep(d).await;
6770 continue;
6771 }
6772
6773 dlg.finished(false);
6774
6775 return Err(match error {
6776 Ok(value) => common::Error::BadRequest(value),
6777 _ => common::Error::Failure(response),
6778 });
6779 }
6780 let response = {
6781 let bytes = common::to_bytes(body).await.unwrap_or_default();
6782 let encoded = common::to_string(&bytes);
6783 match serde_json::from_str(&encoded) {
6784 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6785 Err(error) => {
6786 dlg.response_json_decode_error(&encoded, &error);
6787 return Err(common::Error::JsonDecodeError(
6788 encoded.to_string(),
6789 error,
6790 ));
6791 }
6792 }
6793 };
6794
6795 dlg.finished(true);
6796 return Ok(response);
6797 }
6798 }
6799 }
6800 }
6801
6802 ///
6803 /// Sets the *request* property to the given value.
6804 ///
6805 /// Even though the property as already been set when instantiating this call,
6806 /// we provide this method for API completeness.
6807 pub fn request(
6808 mut self,
6809 new_value: CancelImageImportJobRequest,
6810 ) -> ProjectLocationImageImportImageImportJobCancelCall<'a, C> {
6811 self._request = new_value;
6812 self
6813 }
6814 /// Required. The image import job id.
6815 ///
6816 /// Sets the *name* path property to the given value.
6817 ///
6818 /// Even though the property as already been set when instantiating this call,
6819 /// we provide this method for API completeness.
6820 pub fn name(
6821 mut self,
6822 new_value: &str,
6823 ) -> ProjectLocationImageImportImageImportJobCancelCall<'a, C> {
6824 self._name = new_value.to_string();
6825 self
6826 }
6827 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6828 /// while executing the actual API request.
6829 ///
6830 /// ````text
6831 /// It should be used to handle progress information, and to implement a certain level of resilience.
6832 /// ````
6833 ///
6834 /// Sets the *delegate* property to the given value.
6835 pub fn delegate(
6836 mut self,
6837 new_value: &'a mut dyn common::Delegate,
6838 ) -> ProjectLocationImageImportImageImportJobCancelCall<'a, C> {
6839 self._delegate = Some(new_value);
6840 self
6841 }
6842
6843 /// Set any additional parameter of the query string used in the request.
6844 /// It should be used to set parameters which are not yet available through their own
6845 /// setters.
6846 ///
6847 /// Please note that this method must not be used to set any of the known parameters
6848 /// which have their own setter method. If done anyway, the request will fail.
6849 ///
6850 /// # Additional Parameters
6851 ///
6852 /// * *$.xgafv* (query-string) - V1 error format.
6853 /// * *access_token* (query-string) - OAuth access token.
6854 /// * *alt* (query-string) - Data format for response.
6855 /// * *callback* (query-string) - JSONP
6856 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6857 /// * *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.
6858 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6859 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6860 /// * *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.
6861 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6862 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6863 pub fn param<T>(
6864 mut self,
6865 name: T,
6866 value: T,
6867 ) -> ProjectLocationImageImportImageImportJobCancelCall<'a, C>
6868 where
6869 T: AsRef<str>,
6870 {
6871 self._additional_params
6872 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6873 self
6874 }
6875
6876 /// Identifies the authorization scope for the method you are building.
6877 ///
6878 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6879 /// [`Scope::CloudPlatform`].
6880 ///
6881 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6882 /// tokens for more than one scope.
6883 ///
6884 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6885 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6886 /// sufficient, a read-write scope will do as well.
6887 pub fn add_scope<St>(
6888 mut self,
6889 scope: St,
6890 ) -> ProjectLocationImageImportImageImportJobCancelCall<'a, C>
6891 where
6892 St: AsRef<str>,
6893 {
6894 self._scopes.insert(String::from(scope.as_ref()));
6895 self
6896 }
6897 /// Identifies the authorization scope(s) for the method you are building.
6898 ///
6899 /// See [`Self::add_scope()`] for details.
6900 pub fn add_scopes<I, St>(
6901 mut self,
6902 scopes: I,
6903 ) -> ProjectLocationImageImportImageImportJobCancelCall<'a, C>
6904 where
6905 I: IntoIterator<Item = St>,
6906 St: AsRef<str>,
6907 {
6908 self._scopes
6909 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6910 self
6911 }
6912
6913 /// Removes all scopes, and no default scope will be used either.
6914 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6915 /// for details).
6916 pub fn clear_scopes(mut self) -> ProjectLocationImageImportImageImportJobCancelCall<'a, C> {
6917 self._scopes.clear();
6918 self
6919 }
6920}
6921
6922/// Gets details of a single ImageImportJob.
6923///
6924/// A builder for the *locations.imageImports.imageImportJobs.get* method supported by a *project* resource.
6925/// It is not used directly, but through a [`ProjectMethods`] instance.
6926///
6927/// # Example
6928///
6929/// Instantiate a resource method builder
6930///
6931/// ```test_harness,no_run
6932/// # extern crate hyper;
6933/// # extern crate hyper_rustls;
6934/// # extern crate google_vmmigration1 as vmmigration1;
6935/// # async fn dox() {
6936/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6937///
6938/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6939/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6940/// # secret,
6941/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6942/// # ).build().await.unwrap();
6943///
6944/// # let client = hyper_util::client::legacy::Client::builder(
6945/// # hyper_util::rt::TokioExecutor::new()
6946/// # )
6947/// # .build(
6948/// # hyper_rustls::HttpsConnectorBuilder::new()
6949/// # .with_native_roots()
6950/// # .unwrap()
6951/// # .https_or_http()
6952/// # .enable_http1()
6953/// # .build()
6954/// # );
6955/// # let mut hub = VMMigrationService::new(client, auth);
6956/// // You can configure optional parameters by calling the respective setters at will, and
6957/// // execute the final call using `doit()`.
6958/// // Values shown here are possibly random and not representative !
6959/// let result = hub.projects().locations_image_imports_image_import_jobs_get("name")
6960/// .doit().await;
6961/// # }
6962/// ```
6963pub struct ProjectLocationImageImportImageImportJobGetCall<'a, C>
6964where
6965 C: 'a,
6966{
6967 hub: &'a VMMigrationService<C>,
6968 _name: String,
6969 _delegate: Option<&'a mut dyn common::Delegate>,
6970 _additional_params: HashMap<String, String>,
6971 _scopes: BTreeSet<String>,
6972}
6973
6974impl<'a, C> common::CallBuilder for ProjectLocationImageImportImageImportJobGetCall<'a, C> {}
6975
6976impl<'a, C> ProjectLocationImageImportImageImportJobGetCall<'a, C>
6977where
6978 C: common::Connector,
6979{
6980 /// Perform the operation you have build so far.
6981 pub async fn doit(mut self) -> common::Result<(common::Response, ImageImportJob)> {
6982 use std::borrow::Cow;
6983 use std::io::{Read, Seek};
6984
6985 use common::{url::Params, ToParts};
6986 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6987
6988 let mut dd = common::DefaultDelegate;
6989 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6990 dlg.begin(common::MethodInfo {
6991 id: "vmmigration.projects.locations.imageImports.imageImportJobs.get",
6992 http_method: hyper::Method::GET,
6993 });
6994
6995 for &field in ["alt", "name"].iter() {
6996 if self._additional_params.contains_key(field) {
6997 dlg.finished(false);
6998 return Err(common::Error::FieldClash(field));
6999 }
7000 }
7001
7002 let mut params = Params::with_capacity(3 + self._additional_params.len());
7003 params.push("name", self._name);
7004
7005 params.extend(self._additional_params.iter());
7006
7007 params.push("alt", "json");
7008 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7009 if self._scopes.is_empty() {
7010 self._scopes
7011 .insert(Scope::CloudPlatform.as_ref().to_string());
7012 }
7013
7014 #[allow(clippy::single_element_loop)]
7015 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7016 url = params.uri_replacement(url, param_name, find_this, true);
7017 }
7018 {
7019 let to_remove = ["name"];
7020 params.remove_params(&to_remove);
7021 }
7022
7023 let url = params.parse_with_url(&url);
7024
7025 loop {
7026 let token = match self
7027 .hub
7028 .auth
7029 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7030 .await
7031 {
7032 Ok(token) => token,
7033 Err(e) => match dlg.token(e) {
7034 Ok(token) => token,
7035 Err(e) => {
7036 dlg.finished(false);
7037 return Err(common::Error::MissingToken(e));
7038 }
7039 },
7040 };
7041 let mut req_result = {
7042 let client = &self.hub.client;
7043 dlg.pre_request();
7044 let mut req_builder = hyper::Request::builder()
7045 .method(hyper::Method::GET)
7046 .uri(url.as_str())
7047 .header(USER_AGENT, self.hub._user_agent.clone());
7048
7049 if let Some(token) = token.as_ref() {
7050 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7051 }
7052
7053 let request = req_builder
7054 .header(CONTENT_LENGTH, 0_u64)
7055 .body(common::to_body::<String>(None));
7056
7057 client.request(request.unwrap()).await
7058 };
7059
7060 match req_result {
7061 Err(err) => {
7062 if let common::Retry::After(d) = dlg.http_error(&err) {
7063 sleep(d).await;
7064 continue;
7065 }
7066 dlg.finished(false);
7067 return Err(common::Error::HttpError(err));
7068 }
7069 Ok(res) => {
7070 let (mut parts, body) = res.into_parts();
7071 let mut body = common::Body::new(body);
7072 if !parts.status.is_success() {
7073 let bytes = common::to_bytes(body).await.unwrap_or_default();
7074 let error = serde_json::from_str(&common::to_string(&bytes));
7075 let response = common::to_response(parts, bytes.into());
7076
7077 if let common::Retry::After(d) =
7078 dlg.http_failure(&response, error.as_ref().ok())
7079 {
7080 sleep(d).await;
7081 continue;
7082 }
7083
7084 dlg.finished(false);
7085
7086 return Err(match error {
7087 Ok(value) => common::Error::BadRequest(value),
7088 _ => common::Error::Failure(response),
7089 });
7090 }
7091 let response = {
7092 let bytes = common::to_bytes(body).await.unwrap_or_default();
7093 let encoded = common::to_string(&bytes);
7094 match serde_json::from_str(&encoded) {
7095 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7096 Err(error) => {
7097 dlg.response_json_decode_error(&encoded, &error);
7098 return Err(common::Error::JsonDecodeError(
7099 encoded.to_string(),
7100 error,
7101 ));
7102 }
7103 }
7104 };
7105
7106 dlg.finished(true);
7107 return Ok(response);
7108 }
7109 }
7110 }
7111 }
7112
7113 /// Required. The ImageImportJob name.
7114 ///
7115 /// Sets the *name* path property to the given value.
7116 ///
7117 /// Even though the property as already been set when instantiating this call,
7118 /// we provide this method for API completeness.
7119 pub fn name(
7120 mut self,
7121 new_value: &str,
7122 ) -> ProjectLocationImageImportImageImportJobGetCall<'a, C> {
7123 self._name = new_value.to_string();
7124 self
7125 }
7126 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7127 /// while executing the actual API request.
7128 ///
7129 /// ````text
7130 /// It should be used to handle progress information, and to implement a certain level of resilience.
7131 /// ````
7132 ///
7133 /// Sets the *delegate* property to the given value.
7134 pub fn delegate(
7135 mut self,
7136 new_value: &'a mut dyn common::Delegate,
7137 ) -> ProjectLocationImageImportImageImportJobGetCall<'a, C> {
7138 self._delegate = Some(new_value);
7139 self
7140 }
7141
7142 /// Set any additional parameter of the query string used in the request.
7143 /// It should be used to set parameters which are not yet available through their own
7144 /// setters.
7145 ///
7146 /// Please note that this method must not be used to set any of the known parameters
7147 /// which have their own setter method. If done anyway, the request will fail.
7148 ///
7149 /// # Additional Parameters
7150 ///
7151 /// * *$.xgafv* (query-string) - V1 error format.
7152 /// * *access_token* (query-string) - OAuth access token.
7153 /// * *alt* (query-string) - Data format for response.
7154 /// * *callback* (query-string) - JSONP
7155 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7156 /// * *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.
7157 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7158 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7159 /// * *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.
7160 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7161 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7162 pub fn param<T>(
7163 mut self,
7164 name: T,
7165 value: T,
7166 ) -> ProjectLocationImageImportImageImportJobGetCall<'a, C>
7167 where
7168 T: AsRef<str>,
7169 {
7170 self._additional_params
7171 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7172 self
7173 }
7174
7175 /// Identifies the authorization scope for the method you are building.
7176 ///
7177 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7178 /// [`Scope::CloudPlatform`].
7179 ///
7180 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7181 /// tokens for more than one scope.
7182 ///
7183 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7184 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7185 /// sufficient, a read-write scope will do as well.
7186 pub fn add_scope<St>(
7187 mut self,
7188 scope: St,
7189 ) -> ProjectLocationImageImportImageImportJobGetCall<'a, C>
7190 where
7191 St: AsRef<str>,
7192 {
7193 self._scopes.insert(String::from(scope.as_ref()));
7194 self
7195 }
7196 /// Identifies the authorization scope(s) for the method you are building.
7197 ///
7198 /// See [`Self::add_scope()`] for details.
7199 pub fn add_scopes<I, St>(
7200 mut self,
7201 scopes: I,
7202 ) -> ProjectLocationImageImportImageImportJobGetCall<'a, C>
7203 where
7204 I: IntoIterator<Item = St>,
7205 St: AsRef<str>,
7206 {
7207 self._scopes
7208 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7209 self
7210 }
7211
7212 /// Removes all scopes, and no default scope will be used either.
7213 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7214 /// for details).
7215 pub fn clear_scopes(mut self) -> ProjectLocationImageImportImageImportJobGetCall<'a, C> {
7216 self._scopes.clear();
7217 self
7218 }
7219}
7220
7221/// Lists ImageImportJobs in a given project.
7222///
7223/// A builder for the *locations.imageImports.imageImportJobs.list* method supported by a *project* resource.
7224/// It is not used directly, but through a [`ProjectMethods`] instance.
7225///
7226/// # Example
7227///
7228/// Instantiate a resource method builder
7229///
7230/// ```test_harness,no_run
7231/// # extern crate hyper;
7232/// # extern crate hyper_rustls;
7233/// # extern crate google_vmmigration1 as vmmigration1;
7234/// # async fn dox() {
7235/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7236///
7237/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7238/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7239/// # secret,
7240/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7241/// # ).build().await.unwrap();
7242///
7243/// # let client = hyper_util::client::legacy::Client::builder(
7244/// # hyper_util::rt::TokioExecutor::new()
7245/// # )
7246/// # .build(
7247/// # hyper_rustls::HttpsConnectorBuilder::new()
7248/// # .with_native_roots()
7249/// # .unwrap()
7250/// # .https_or_http()
7251/// # .enable_http1()
7252/// # .build()
7253/// # );
7254/// # let mut hub = VMMigrationService::new(client, auth);
7255/// // You can configure optional parameters by calling the respective setters at will, and
7256/// // execute the final call using `doit()`.
7257/// // Values shown here are possibly random and not representative !
7258/// let result = hub.projects().locations_image_imports_image_import_jobs_list("parent")
7259/// .page_token("rebum.")
7260/// .page_size(-57)
7261/// .order_by("ipsum")
7262/// .filter("ipsum")
7263/// .doit().await;
7264/// # }
7265/// ```
7266pub struct ProjectLocationImageImportImageImportJobListCall<'a, C>
7267where
7268 C: 'a,
7269{
7270 hub: &'a VMMigrationService<C>,
7271 _parent: String,
7272 _page_token: Option<String>,
7273 _page_size: Option<i32>,
7274 _order_by: Option<String>,
7275 _filter: Option<String>,
7276 _delegate: Option<&'a mut dyn common::Delegate>,
7277 _additional_params: HashMap<String, String>,
7278 _scopes: BTreeSet<String>,
7279}
7280
7281impl<'a, C> common::CallBuilder for ProjectLocationImageImportImageImportJobListCall<'a, C> {}
7282
7283impl<'a, C> ProjectLocationImageImportImageImportJobListCall<'a, C>
7284where
7285 C: common::Connector,
7286{
7287 /// Perform the operation you have build so far.
7288 pub async fn doit(mut self) -> common::Result<(common::Response, ListImageImportJobsResponse)> {
7289 use std::borrow::Cow;
7290 use std::io::{Read, Seek};
7291
7292 use common::{url::Params, ToParts};
7293 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7294
7295 let mut dd = common::DefaultDelegate;
7296 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7297 dlg.begin(common::MethodInfo {
7298 id: "vmmigration.projects.locations.imageImports.imageImportJobs.list",
7299 http_method: hyper::Method::GET,
7300 });
7301
7302 for &field in [
7303 "alt",
7304 "parent",
7305 "pageToken",
7306 "pageSize",
7307 "orderBy",
7308 "filter",
7309 ]
7310 .iter()
7311 {
7312 if self._additional_params.contains_key(field) {
7313 dlg.finished(false);
7314 return Err(common::Error::FieldClash(field));
7315 }
7316 }
7317
7318 let mut params = Params::with_capacity(7 + self._additional_params.len());
7319 params.push("parent", self._parent);
7320 if let Some(value) = self._page_token.as_ref() {
7321 params.push("pageToken", value);
7322 }
7323 if let Some(value) = self._page_size.as_ref() {
7324 params.push("pageSize", value.to_string());
7325 }
7326 if let Some(value) = self._order_by.as_ref() {
7327 params.push("orderBy", value);
7328 }
7329 if let Some(value) = self._filter.as_ref() {
7330 params.push("filter", value);
7331 }
7332
7333 params.extend(self._additional_params.iter());
7334
7335 params.push("alt", "json");
7336 let mut url = self.hub._base_url.clone() + "v1/{+parent}/imageImportJobs";
7337 if self._scopes.is_empty() {
7338 self._scopes
7339 .insert(Scope::CloudPlatform.as_ref().to_string());
7340 }
7341
7342 #[allow(clippy::single_element_loop)]
7343 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7344 url = params.uri_replacement(url, param_name, find_this, true);
7345 }
7346 {
7347 let to_remove = ["parent"];
7348 params.remove_params(&to_remove);
7349 }
7350
7351 let url = params.parse_with_url(&url);
7352
7353 loop {
7354 let token = match self
7355 .hub
7356 .auth
7357 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7358 .await
7359 {
7360 Ok(token) => token,
7361 Err(e) => match dlg.token(e) {
7362 Ok(token) => token,
7363 Err(e) => {
7364 dlg.finished(false);
7365 return Err(common::Error::MissingToken(e));
7366 }
7367 },
7368 };
7369 let mut req_result = {
7370 let client = &self.hub.client;
7371 dlg.pre_request();
7372 let mut req_builder = hyper::Request::builder()
7373 .method(hyper::Method::GET)
7374 .uri(url.as_str())
7375 .header(USER_AGENT, self.hub._user_agent.clone());
7376
7377 if let Some(token) = token.as_ref() {
7378 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7379 }
7380
7381 let request = req_builder
7382 .header(CONTENT_LENGTH, 0_u64)
7383 .body(common::to_body::<String>(None));
7384
7385 client.request(request.unwrap()).await
7386 };
7387
7388 match req_result {
7389 Err(err) => {
7390 if let common::Retry::After(d) = dlg.http_error(&err) {
7391 sleep(d).await;
7392 continue;
7393 }
7394 dlg.finished(false);
7395 return Err(common::Error::HttpError(err));
7396 }
7397 Ok(res) => {
7398 let (mut parts, body) = res.into_parts();
7399 let mut body = common::Body::new(body);
7400 if !parts.status.is_success() {
7401 let bytes = common::to_bytes(body).await.unwrap_or_default();
7402 let error = serde_json::from_str(&common::to_string(&bytes));
7403 let response = common::to_response(parts, bytes.into());
7404
7405 if let common::Retry::After(d) =
7406 dlg.http_failure(&response, error.as_ref().ok())
7407 {
7408 sleep(d).await;
7409 continue;
7410 }
7411
7412 dlg.finished(false);
7413
7414 return Err(match error {
7415 Ok(value) => common::Error::BadRequest(value),
7416 _ => common::Error::Failure(response),
7417 });
7418 }
7419 let response = {
7420 let bytes = common::to_bytes(body).await.unwrap_or_default();
7421 let encoded = common::to_string(&bytes);
7422 match serde_json::from_str(&encoded) {
7423 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7424 Err(error) => {
7425 dlg.response_json_decode_error(&encoded, &error);
7426 return Err(common::Error::JsonDecodeError(
7427 encoded.to_string(),
7428 error,
7429 ));
7430 }
7431 }
7432 };
7433
7434 dlg.finished(true);
7435 return Ok(response);
7436 }
7437 }
7438 }
7439 }
7440
7441 /// Required. The parent, which owns this collection of targets.
7442 ///
7443 /// Sets the *parent* path property to the given value.
7444 ///
7445 /// Even though the property as already been set when instantiating this call,
7446 /// we provide this method for API completeness.
7447 pub fn parent(
7448 mut self,
7449 new_value: &str,
7450 ) -> ProjectLocationImageImportImageImportJobListCall<'a, C> {
7451 self._parent = new_value.to_string();
7452 self
7453 }
7454 /// Optional. A page token, received from a previous `ListImageImportJobs` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListImageImportJobs` must match the call that provided the page token.
7455 ///
7456 /// Sets the *page token* query property to the given value.
7457 pub fn page_token(
7458 mut self,
7459 new_value: &str,
7460 ) -> ProjectLocationImageImportImageImportJobListCall<'a, C> {
7461 self._page_token = Some(new_value.to_string());
7462 self
7463 }
7464 /// Optional. The maximum number of targets to return. The service may return fewer than this value. If unspecified, at most 500 targets will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
7465 ///
7466 /// Sets the *page size* query property to the given value.
7467 pub fn page_size(
7468 mut self,
7469 new_value: i32,
7470 ) -> ProjectLocationImageImportImageImportJobListCall<'a, C> {
7471 self._page_size = Some(new_value);
7472 self
7473 }
7474 /// Optional. The order by fields for the result (according to https://google.aip.dev/132#ordering). Currently ordering is only possible by "name" field.
7475 ///
7476 /// Sets the *order by* query property to the given value.
7477 pub fn order_by(
7478 mut self,
7479 new_value: &str,
7480 ) -> ProjectLocationImageImportImageImportJobListCall<'a, C> {
7481 self._order_by = Some(new_value.to_string());
7482 self
7483 }
7484 /// Optional. The filter request (according to https://google.aip.dev/160).
7485 ///
7486 /// Sets the *filter* query property to the given value.
7487 pub fn filter(
7488 mut self,
7489 new_value: &str,
7490 ) -> ProjectLocationImageImportImageImportJobListCall<'a, C> {
7491 self._filter = Some(new_value.to_string());
7492 self
7493 }
7494 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7495 /// while executing the actual API request.
7496 ///
7497 /// ````text
7498 /// It should be used to handle progress information, and to implement a certain level of resilience.
7499 /// ````
7500 ///
7501 /// Sets the *delegate* property to the given value.
7502 pub fn delegate(
7503 mut self,
7504 new_value: &'a mut dyn common::Delegate,
7505 ) -> ProjectLocationImageImportImageImportJobListCall<'a, C> {
7506 self._delegate = Some(new_value);
7507 self
7508 }
7509
7510 /// Set any additional parameter of the query string used in the request.
7511 /// It should be used to set parameters which are not yet available through their own
7512 /// setters.
7513 ///
7514 /// Please note that this method must not be used to set any of the known parameters
7515 /// which have their own setter method. If done anyway, the request will fail.
7516 ///
7517 /// # Additional Parameters
7518 ///
7519 /// * *$.xgafv* (query-string) - V1 error format.
7520 /// * *access_token* (query-string) - OAuth access token.
7521 /// * *alt* (query-string) - Data format for response.
7522 /// * *callback* (query-string) - JSONP
7523 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7524 /// * *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.
7525 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7526 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7527 /// * *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.
7528 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7529 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7530 pub fn param<T>(
7531 mut self,
7532 name: T,
7533 value: T,
7534 ) -> ProjectLocationImageImportImageImportJobListCall<'a, C>
7535 where
7536 T: AsRef<str>,
7537 {
7538 self._additional_params
7539 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7540 self
7541 }
7542
7543 /// Identifies the authorization scope for the method you are building.
7544 ///
7545 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7546 /// [`Scope::CloudPlatform`].
7547 ///
7548 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7549 /// tokens for more than one scope.
7550 ///
7551 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7552 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7553 /// sufficient, a read-write scope will do as well.
7554 pub fn add_scope<St>(
7555 mut self,
7556 scope: St,
7557 ) -> ProjectLocationImageImportImageImportJobListCall<'a, C>
7558 where
7559 St: AsRef<str>,
7560 {
7561 self._scopes.insert(String::from(scope.as_ref()));
7562 self
7563 }
7564 /// Identifies the authorization scope(s) for the method you are building.
7565 ///
7566 /// See [`Self::add_scope()`] for details.
7567 pub fn add_scopes<I, St>(
7568 mut self,
7569 scopes: I,
7570 ) -> ProjectLocationImageImportImageImportJobListCall<'a, C>
7571 where
7572 I: IntoIterator<Item = St>,
7573 St: AsRef<str>,
7574 {
7575 self._scopes
7576 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7577 self
7578 }
7579
7580 /// Removes all scopes, and no default scope will be used either.
7581 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7582 /// for details).
7583 pub fn clear_scopes(mut self) -> ProjectLocationImageImportImageImportJobListCall<'a, C> {
7584 self._scopes.clear();
7585 self
7586 }
7587}
7588
7589/// Creates a new ImageImport in a given project.
7590///
7591/// A builder for the *locations.imageImports.create* method supported by a *project* resource.
7592/// It is not used directly, but through a [`ProjectMethods`] instance.
7593///
7594/// # Example
7595///
7596/// Instantiate a resource method builder
7597///
7598/// ```test_harness,no_run
7599/// # extern crate hyper;
7600/// # extern crate hyper_rustls;
7601/// # extern crate google_vmmigration1 as vmmigration1;
7602/// use vmmigration1::api::ImageImport;
7603/// # async fn dox() {
7604/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7605///
7606/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7607/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7608/// # secret,
7609/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7610/// # ).build().await.unwrap();
7611///
7612/// # let client = hyper_util::client::legacy::Client::builder(
7613/// # hyper_util::rt::TokioExecutor::new()
7614/// # )
7615/// # .build(
7616/// # hyper_rustls::HttpsConnectorBuilder::new()
7617/// # .with_native_roots()
7618/// # .unwrap()
7619/// # .https_or_http()
7620/// # .enable_http1()
7621/// # .build()
7622/// # );
7623/// # let mut hub = VMMigrationService::new(client, auth);
7624/// // As the method needs a request, you would usually fill it with the desired information
7625/// // into the respective structure. Some of the parts shown here might not be applicable !
7626/// // Values shown here are possibly random and not representative !
7627/// let mut req = ImageImport::default();
7628///
7629/// // You can configure optional parameters by calling the respective setters at will, and
7630/// // execute the final call using `doit()`.
7631/// // Values shown here are possibly random and not representative !
7632/// let result = hub.projects().locations_image_imports_create(req, "parent")
7633/// .request_id("gubergren")
7634/// .image_import_id("ea")
7635/// .doit().await;
7636/// # }
7637/// ```
7638pub struct ProjectLocationImageImportCreateCall<'a, C>
7639where
7640 C: 'a,
7641{
7642 hub: &'a VMMigrationService<C>,
7643 _request: ImageImport,
7644 _parent: String,
7645 _request_id: Option<String>,
7646 _image_import_id: Option<String>,
7647 _delegate: Option<&'a mut dyn common::Delegate>,
7648 _additional_params: HashMap<String, String>,
7649 _scopes: BTreeSet<String>,
7650}
7651
7652impl<'a, C> common::CallBuilder for ProjectLocationImageImportCreateCall<'a, C> {}
7653
7654impl<'a, C> ProjectLocationImageImportCreateCall<'a, C>
7655where
7656 C: common::Connector,
7657{
7658 /// Perform the operation you have build so far.
7659 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7660 use std::borrow::Cow;
7661 use std::io::{Read, Seek};
7662
7663 use common::{url::Params, ToParts};
7664 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7665
7666 let mut dd = common::DefaultDelegate;
7667 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7668 dlg.begin(common::MethodInfo {
7669 id: "vmmigration.projects.locations.imageImports.create",
7670 http_method: hyper::Method::POST,
7671 });
7672
7673 for &field in ["alt", "parent", "requestId", "imageImportId"].iter() {
7674 if self._additional_params.contains_key(field) {
7675 dlg.finished(false);
7676 return Err(common::Error::FieldClash(field));
7677 }
7678 }
7679
7680 let mut params = Params::with_capacity(6 + self._additional_params.len());
7681 params.push("parent", self._parent);
7682 if let Some(value) = self._request_id.as_ref() {
7683 params.push("requestId", value);
7684 }
7685 if let Some(value) = self._image_import_id.as_ref() {
7686 params.push("imageImportId", value);
7687 }
7688
7689 params.extend(self._additional_params.iter());
7690
7691 params.push("alt", "json");
7692 let mut url = self.hub._base_url.clone() + "v1/{+parent}/imageImports";
7693 if self._scopes.is_empty() {
7694 self._scopes
7695 .insert(Scope::CloudPlatform.as_ref().to_string());
7696 }
7697
7698 #[allow(clippy::single_element_loop)]
7699 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7700 url = params.uri_replacement(url, param_name, find_this, true);
7701 }
7702 {
7703 let to_remove = ["parent"];
7704 params.remove_params(&to_remove);
7705 }
7706
7707 let url = params.parse_with_url(&url);
7708
7709 let mut json_mime_type = mime::APPLICATION_JSON;
7710 let mut request_value_reader = {
7711 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7712 common::remove_json_null_values(&mut value);
7713 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7714 serde_json::to_writer(&mut dst, &value).unwrap();
7715 dst
7716 };
7717 let request_size = request_value_reader
7718 .seek(std::io::SeekFrom::End(0))
7719 .unwrap();
7720 request_value_reader
7721 .seek(std::io::SeekFrom::Start(0))
7722 .unwrap();
7723
7724 loop {
7725 let token = match self
7726 .hub
7727 .auth
7728 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7729 .await
7730 {
7731 Ok(token) => token,
7732 Err(e) => match dlg.token(e) {
7733 Ok(token) => token,
7734 Err(e) => {
7735 dlg.finished(false);
7736 return Err(common::Error::MissingToken(e));
7737 }
7738 },
7739 };
7740 request_value_reader
7741 .seek(std::io::SeekFrom::Start(0))
7742 .unwrap();
7743 let mut req_result = {
7744 let client = &self.hub.client;
7745 dlg.pre_request();
7746 let mut req_builder = hyper::Request::builder()
7747 .method(hyper::Method::POST)
7748 .uri(url.as_str())
7749 .header(USER_AGENT, self.hub._user_agent.clone());
7750
7751 if let Some(token) = token.as_ref() {
7752 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7753 }
7754
7755 let request = req_builder
7756 .header(CONTENT_TYPE, json_mime_type.to_string())
7757 .header(CONTENT_LENGTH, request_size as u64)
7758 .body(common::to_body(
7759 request_value_reader.get_ref().clone().into(),
7760 ));
7761
7762 client.request(request.unwrap()).await
7763 };
7764
7765 match req_result {
7766 Err(err) => {
7767 if let common::Retry::After(d) = dlg.http_error(&err) {
7768 sleep(d).await;
7769 continue;
7770 }
7771 dlg.finished(false);
7772 return Err(common::Error::HttpError(err));
7773 }
7774 Ok(res) => {
7775 let (mut parts, body) = res.into_parts();
7776 let mut body = common::Body::new(body);
7777 if !parts.status.is_success() {
7778 let bytes = common::to_bytes(body).await.unwrap_or_default();
7779 let error = serde_json::from_str(&common::to_string(&bytes));
7780 let response = common::to_response(parts, bytes.into());
7781
7782 if let common::Retry::After(d) =
7783 dlg.http_failure(&response, error.as_ref().ok())
7784 {
7785 sleep(d).await;
7786 continue;
7787 }
7788
7789 dlg.finished(false);
7790
7791 return Err(match error {
7792 Ok(value) => common::Error::BadRequest(value),
7793 _ => common::Error::Failure(response),
7794 });
7795 }
7796 let response = {
7797 let bytes = common::to_bytes(body).await.unwrap_or_default();
7798 let encoded = common::to_string(&bytes);
7799 match serde_json::from_str(&encoded) {
7800 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7801 Err(error) => {
7802 dlg.response_json_decode_error(&encoded, &error);
7803 return Err(common::Error::JsonDecodeError(
7804 encoded.to_string(),
7805 error,
7806 ));
7807 }
7808 }
7809 };
7810
7811 dlg.finished(true);
7812 return Ok(response);
7813 }
7814 }
7815 }
7816 }
7817
7818 ///
7819 /// Sets the *request* property to the given value.
7820 ///
7821 /// Even though the property as already been set when instantiating this call,
7822 /// we provide this method for API completeness.
7823 pub fn request(
7824 mut self,
7825 new_value: ImageImport,
7826 ) -> ProjectLocationImageImportCreateCall<'a, C> {
7827 self._request = new_value;
7828 self
7829 }
7830 /// Required. The ImageImport's parent.
7831 ///
7832 /// Sets the *parent* path property to the given value.
7833 ///
7834 /// Even though the property as already been set when instantiating this call,
7835 /// we provide this method for API completeness.
7836 pub fn parent(mut self, new_value: &str) -> ProjectLocationImageImportCreateCall<'a, C> {
7837 self._parent = new_value.to_string();
7838 self
7839 }
7840 /// Optional. A request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes since the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
7841 ///
7842 /// Sets the *request id* query property to the given value.
7843 pub fn request_id(mut self, new_value: &str) -> ProjectLocationImageImportCreateCall<'a, C> {
7844 self._request_id = Some(new_value.to_string());
7845 self
7846 }
7847 /// Required. The image import identifier. This value maximum length is 63 characters, and valid characters are /a-z-/. It must start with an english letter and must not end with a hyphen.
7848 ///
7849 /// Sets the *image import id* query property to the given value.
7850 pub fn image_import_id(
7851 mut self,
7852 new_value: &str,
7853 ) -> ProjectLocationImageImportCreateCall<'a, C> {
7854 self._image_import_id = Some(new_value.to_string());
7855 self
7856 }
7857 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7858 /// while executing the actual API request.
7859 ///
7860 /// ````text
7861 /// It should be used to handle progress information, and to implement a certain level of resilience.
7862 /// ````
7863 ///
7864 /// Sets the *delegate* property to the given value.
7865 pub fn delegate(
7866 mut self,
7867 new_value: &'a mut dyn common::Delegate,
7868 ) -> ProjectLocationImageImportCreateCall<'a, C> {
7869 self._delegate = Some(new_value);
7870 self
7871 }
7872
7873 /// Set any additional parameter of the query string used in the request.
7874 /// It should be used to set parameters which are not yet available through their own
7875 /// setters.
7876 ///
7877 /// Please note that this method must not be used to set any of the known parameters
7878 /// which have their own setter method. If done anyway, the request will fail.
7879 ///
7880 /// # Additional Parameters
7881 ///
7882 /// * *$.xgafv* (query-string) - V1 error format.
7883 /// * *access_token* (query-string) - OAuth access token.
7884 /// * *alt* (query-string) - Data format for response.
7885 /// * *callback* (query-string) - JSONP
7886 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7887 /// * *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.
7888 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7889 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7890 /// * *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.
7891 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7892 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7893 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationImageImportCreateCall<'a, C>
7894 where
7895 T: AsRef<str>,
7896 {
7897 self._additional_params
7898 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7899 self
7900 }
7901
7902 /// Identifies the authorization scope for the method you are building.
7903 ///
7904 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7905 /// [`Scope::CloudPlatform`].
7906 ///
7907 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7908 /// tokens for more than one scope.
7909 ///
7910 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7911 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7912 /// sufficient, a read-write scope will do as well.
7913 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationImageImportCreateCall<'a, C>
7914 where
7915 St: AsRef<str>,
7916 {
7917 self._scopes.insert(String::from(scope.as_ref()));
7918 self
7919 }
7920 /// Identifies the authorization scope(s) for the method you are building.
7921 ///
7922 /// See [`Self::add_scope()`] for details.
7923 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationImageImportCreateCall<'a, C>
7924 where
7925 I: IntoIterator<Item = St>,
7926 St: AsRef<str>,
7927 {
7928 self._scopes
7929 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7930 self
7931 }
7932
7933 /// Removes all scopes, and no default scope will be used either.
7934 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7935 /// for details).
7936 pub fn clear_scopes(mut self) -> ProjectLocationImageImportCreateCall<'a, C> {
7937 self._scopes.clear();
7938 self
7939 }
7940}
7941
7942/// Deletes a single ImageImport.
7943///
7944/// A builder for the *locations.imageImports.delete* method supported by a *project* resource.
7945/// It is not used directly, but through a [`ProjectMethods`] instance.
7946///
7947/// # Example
7948///
7949/// Instantiate a resource method builder
7950///
7951/// ```test_harness,no_run
7952/// # extern crate hyper;
7953/// # extern crate hyper_rustls;
7954/// # extern crate google_vmmigration1 as vmmigration1;
7955/// # async fn dox() {
7956/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7957///
7958/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7959/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7960/// # secret,
7961/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7962/// # ).build().await.unwrap();
7963///
7964/// # let client = hyper_util::client::legacy::Client::builder(
7965/// # hyper_util::rt::TokioExecutor::new()
7966/// # )
7967/// # .build(
7968/// # hyper_rustls::HttpsConnectorBuilder::new()
7969/// # .with_native_roots()
7970/// # .unwrap()
7971/// # .https_or_http()
7972/// # .enable_http1()
7973/// # .build()
7974/// # );
7975/// # let mut hub = VMMigrationService::new(client, auth);
7976/// // You can configure optional parameters by calling the respective setters at will, and
7977/// // execute the final call using `doit()`.
7978/// // Values shown here are possibly random and not representative !
7979/// let result = hub.projects().locations_image_imports_delete("name")
7980/// .request_id("Lorem")
7981/// .doit().await;
7982/// # }
7983/// ```
7984pub struct ProjectLocationImageImportDeleteCall<'a, C>
7985where
7986 C: 'a,
7987{
7988 hub: &'a VMMigrationService<C>,
7989 _name: String,
7990 _request_id: Option<String>,
7991 _delegate: Option<&'a mut dyn common::Delegate>,
7992 _additional_params: HashMap<String, String>,
7993 _scopes: BTreeSet<String>,
7994}
7995
7996impl<'a, C> common::CallBuilder for ProjectLocationImageImportDeleteCall<'a, C> {}
7997
7998impl<'a, C> ProjectLocationImageImportDeleteCall<'a, C>
7999where
8000 C: common::Connector,
8001{
8002 /// Perform the operation you have build so far.
8003 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8004 use std::borrow::Cow;
8005 use std::io::{Read, Seek};
8006
8007 use common::{url::Params, ToParts};
8008 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8009
8010 let mut dd = common::DefaultDelegate;
8011 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8012 dlg.begin(common::MethodInfo {
8013 id: "vmmigration.projects.locations.imageImports.delete",
8014 http_method: hyper::Method::DELETE,
8015 });
8016
8017 for &field in ["alt", "name", "requestId"].iter() {
8018 if self._additional_params.contains_key(field) {
8019 dlg.finished(false);
8020 return Err(common::Error::FieldClash(field));
8021 }
8022 }
8023
8024 let mut params = Params::with_capacity(4 + self._additional_params.len());
8025 params.push("name", self._name);
8026 if let Some(value) = self._request_id.as_ref() {
8027 params.push("requestId", value);
8028 }
8029
8030 params.extend(self._additional_params.iter());
8031
8032 params.push("alt", "json");
8033 let mut url = self.hub._base_url.clone() + "v1/{+name}";
8034 if self._scopes.is_empty() {
8035 self._scopes
8036 .insert(Scope::CloudPlatform.as_ref().to_string());
8037 }
8038
8039 #[allow(clippy::single_element_loop)]
8040 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8041 url = params.uri_replacement(url, param_name, find_this, true);
8042 }
8043 {
8044 let to_remove = ["name"];
8045 params.remove_params(&to_remove);
8046 }
8047
8048 let url = params.parse_with_url(&url);
8049
8050 loop {
8051 let token = match self
8052 .hub
8053 .auth
8054 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8055 .await
8056 {
8057 Ok(token) => token,
8058 Err(e) => match dlg.token(e) {
8059 Ok(token) => token,
8060 Err(e) => {
8061 dlg.finished(false);
8062 return Err(common::Error::MissingToken(e));
8063 }
8064 },
8065 };
8066 let mut req_result = {
8067 let client = &self.hub.client;
8068 dlg.pre_request();
8069 let mut req_builder = hyper::Request::builder()
8070 .method(hyper::Method::DELETE)
8071 .uri(url.as_str())
8072 .header(USER_AGENT, self.hub._user_agent.clone());
8073
8074 if let Some(token) = token.as_ref() {
8075 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8076 }
8077
8078 let request = req_builder
8079 .header(CONTENT_LENGTH, 0_u64)
8080 .body(common::to_body::<String>(None));
8081
8082 client.request(request.unwrap()).await
8083 };
8084
8085 match req_result {
8086 Err(err) => {
8087 if let common::Retry::After(d) = dlg.http_error(&err) {
8088 sleep(d).await;
8089 continue;
8090 }
8091 dlg.finished(false);
8092 return Err(common::Error::HttpError(err));
8093 }
8094 Ok(res) => {
8095 let (mut parts, body) = res.into_parts();
8096 let mut body = common::Body::new(body);
8097 if !parts.status.is_success() {
8098 let bytes = common::to_bytes(body).await.unwrap_or_default();
8099 let error = serde_json::from_str(&common::to_string(&bytes));
8100 let response = common::to_response(parts, bytes.into());
8101
8102 if let common::Retry::After(d) =
8103 dlg.http_failure(&response, error.as_ref().ok())
8104 {
8105 sleep(d).await;
8106 continue;
8107 }
8108
8109 dlg.finished(false);
8110
8111 return Err(match error {
8112 Ok(value) => common::Error::BadRequest(value),
8113 _ => common::Error::Failure(response),
8114 });
8115 }
8116 let response = {
8117 let bytes = common::to_bytes(body).await.unwrap_or_default();
8118 let encoded = common::to_string(&bytes);
8119 match serde_json::from_str(&encoded) {
8120 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8121 Err(error) => {
8122 dlg.response_json_decode_error(&encoded, &error);
8123 return Err(common::Error::JsonDecodeError(
8124 encoded.to_string(),
8125 error,
8126 ));
8127 }
8128 }
8129 };
8130
8131 dlg.finished(true);
8132 return Ok(response);
8133 }
8134 }
8135 }
8136 }
8137
8138 /// Required. The ImageImport name.
8139 ///
8140 /// Sets the *name* path property to the given value.
8141 ///
8142 /// Even though the property as already been set when instantiating this call,
8143 /// we provide this method for API completeness.
8144 pub fn name(mut self, new_value: &str) -> ProjectLocationImageImportDeleteCall<'a, C> {
8145 self._name = new_value.to_string();
8146 self
8147 }
8148 /// Optional. A request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes after the first request. For example, consider a situation where you make an initial request and t he request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
8149 ///
8150 /// Sets the *request id* query property to the given value.
8151 pub fn request_id(mut self, new_value: &str) -> ProjectLocationImageImportDeleteCall<'a, C> {
8152 self._request_id = Some(new_value.to_string());
8153 self
8154 }
8155 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8156 /// while executing the actual API request.
8157 ///
8158 /// ````text
8159 /// It should be used to handle progress information, and to implement a certain level of resilience.
8160 /// ````
8161 ///
8162 /// Sets the *delegate* property to the given value.
8163 pub fn delegate(
8164 mut self,
8165 new_value: &'a mut dyn common::Delegate,
8166 ) -> ProjectLocationImageImportDeleteCall<'a, C> {
8167 self._delegate = Some(new_value);
8168 self
8169 }
8170
8171 /// Set any additional parameter of the query string used in the request.
8172 /// It should be used to set parameters which are not yet available through their own
8173 /// setters.
8174 ///
8175 /// Please note that this method must not be used to set any of the known parameters
8176 /// which have their own setter method. If done anyway, the request will fail.
8177 ///
8178 /// # Additional Parameters
8179 ///
8180 /// * *$.xgafv* (query-string) - V1 error format.
8181 /// * *access_token* (query-string) - OAuth access token.
8182 /// * *alt* (query-string) - Data format for response.
8183 /// * *callback* (query-string) - JSONP
8184 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8185 /// * *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.
8186 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8187 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8188 /// * *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.
8189 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8190 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8191 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationImageImportDeleteCall<'a, C>
8192 where
8193 T: AsRef<str>,
8194 {
8195 self._additional_params
8196 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8197 self
8198 }
8199
8200 /// Identifies the authorization scope for the method you are building.
8201 ///
8202 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8203 /// [`Scope::CloudPlatform`].
8204 ///
8205 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8206 /// tokens for more than one scope.
8207 ///
8208 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8209 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8210 /// sufficient, a read-write scope will do as well.
8211 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationImageImportDeleteCall<'a, C>
8212 where
8213 St: AsRef<str>,
8214 {
8215 self._scopes.insert(String::from(scope.as_ref()));
8216 self
8217 }
8218 /// Identifies the authorization scope(s) for the method you are building.
8219 ///
8220 /// See [`Self::add_scope()`] for details.
8221 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationImageImportDeleteCall<'a, C>
8222 where
8223 I: IntoIterator<Item = St>,
8224 St: AsRef<str>,
8225 {
8226 self._scopes
8227 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8228 self
8229 }
8230
8231 /// Removes all scopes, and no default scope will be used either.
8232 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8233 /// for details).
8234 pub fn clear_scopes(mut self) -> ProjectLocationImageImportDeleteCall<'a, C> {
8235 self._scopes.clear();
8236 self
8237 }
8238}
8239
8240/// Gets details of a single ImageImport.
8241///
8242/// A builder for the *locations.imageImports.get* method supported by a *project* resource.
8243/// It is not used directly, but through a [`ProjectMethods`] instance.
8244///
8245/// # Example
8246///
8247/// Instantiate a resource method builder
8248///
8249/// ```test_harness,no_run
8250/// # extern crate hyper;
8251/// # extern crate hyper_rustls;
8252/// # extern crate google_vmmigration1 as vmmigration1;
8253/// # async fn dox() {
8254/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8255///
8256/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8257/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8258/// # secret,
8259/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8260/// # ).build().await.unwrap();
8261///
8262/// # let client = hyper_util::client::legacy::Client::builder(
8263/// # hyper_util::rt::TokioExecutor::new()
8264/// # )
8265/// # .build(
8266/// # hyper_rustls::HttpsConnectorBuilder::new()
8267/// # .with_native_roots()
8268/// # .unwrap()
8269/// # .https_or_http()
8270/// # .enable_http1()
8271/// # .build()
8272/// # );
8273/// # let mut hub = VMMigrationService::new(client, auth);
8274/// // You can configure optional parameters by calling the respective setters at will, and
8275/// // execute the final call using `doit()`.
8276/// // Values shown here are possibly random and not representative !
8277/// let result = hub.projects().locations_image_imports_get("name")
8278/// .doit().await;
8279/// # }
8280/// ```
8281pub struct ProjectLocationImageImportGetCall<'a, C>
8282where
8283 C: 'a,
8284{
8285 hub: &'a VMMigrationService<C>,
8286 _name: String,
8287 _delegate: Option<&'a mut dyn common::Delegate>,
8288 _additional_params: HashMap<String, String>,
8289 _scopes: BTreeSet<String>,
8290}
8291
8292impl<'a, C> common::CallBuilder for ProjectLocationImageImportGetCall<'a, C> {}
8293
8294impl<'a, C> ProjectLocationImageImportGetCall<'a, C>
8295where
8296 C: common::Connector,
8297{
8298 /// Perform the operation you have build so far.
8299 pub async fn doit(mut self) -> common::Result<(common::Response, ImageImport)> {
8300 use std::borrow::Cow;
8301 use std::io::{Read, Seek};
8302
8303 use common::{url::Params, ToParts};
8304 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8305
8306 let mut dd = common::DefaultDelegate;
8307 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8308 dlg.begin(common::MethodInfo {
8309 id: "vmmigration.projects.locations.imageImports.get",
8310 http_method: hyper::Method::GET,
8311 });
8312
8313 for &field in ["alt", "name"].iter() {
8314 if self._additional_params.contains_key(field) {
8315 dlg.finished(false);
8316 return Err(common::Error::FieldClash(field));
8317 }
8318 }
8319
8320 let mut params = Params::with_capacity(3 + self._additional_params.len());
8321 params.push("name", self._name);
8322
8323 params.extend(self._additional_params.iter());
8324
8325 params.push("alt", "json");
8326 let mut url = self.hub._base_url.clone() + "v1/{+name}";
8327 if self._scopes.is_empty() {
8328 self._scopes
8329 .insert(Scope::CloudPlatform.as_ref().to_string());
8330 }
8331
8332 #[allow(clippy::single_element_loop)]
8333 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8334 url = params.uri_replacement(url, param_name, find_this, true);
8335 }
8336 {
8337 let to_remove = ["name"];
8338 params.remove_params(&to_remove);
8339 }
8340
8341 let url = params.parse_with_url(&url);
8342
8343 loop {
8344 let token = match self
8345 .hub
8346 .auth
8347 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8348 .await
8349 {
8350 Ok(token) => token,
8351 Err(e) => match dlg.token(e) {
8352 Ok(token) => token,
8353 Err(e) => {
8354 dlg.finished(false);
8355 return Err(common::Error::MissingToken(e));
8356 }
8357 },
8358 };
8359 let mut req_result = {
8360 let client = &self.hub.client;
8361 dlg.pre_request();
8362 let mut req_builder = hyper::Request::builder()
8363 .method(hyper::Method::GET)
8364 .uri(url.as_str())
8365 .header(USER_AGENT, self.hub._user_agent.clone());
8366
8367 if let Some(token) = token.as_ref() {
8368 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8369 }
8370
8371 let request = req_builder
8372 .header(CONTENT_LENGTH, 0_u64)
8373 .body(common::to_body::<String>(None));
8374
8375 client.request(request.unwrap()).await
8376 };
8377
8378 match req_result {
8379 Err(err) => {
8380 if let common::Retry::After(d) = dlg.http_error(&err) {
8381 sleep(d).await;
8382 continue;
8383 }
8384 dlg.finished(false);
8385 return Err(common::Error::HttpError(err));
8386 }
8387 Ok(res) => {
8388 let (mut parts, body) = res.into_parts();
8389 let mut body = common::Body::new(body);
8390 if !parts.status.is_success() {
8391 let bytes = common::to_bytes(body).await.unwrap_or_default();
8392 let error = serde_json::from_str(&common::to_string(&bytes));
8393 let response = common::to_response(parts, bytes.into());
8394
8395 if let common::Retry::After(d) =
8396 dlg.http_failure(&response, error.as_ref().ok())
8397 {
8398 sleep(d).await;
8399 continue;
8400 }
8401
8402 dlg.finished(false);
8403
8404 return Err(match error {
8405 Ok(value) => common::Error::BadRequest(value),
8406 _ => common::Error::Failure(response),
8407 });
8408 }
8409 let response = {
8410 let bytes = common::to_bytes(body).await.unwrap_or_default();
8411 let encoded = common::to_string(&bytes);
8412 match serde_json::from_str(&encoded) {
8413 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8414 Err(error) => {
8415 dlg.response_json_decode_error(&encoded, &error);
8416 return Err(common::Error::JsonDecodeError(
8417 encoded.to_string(),
8418 error,
8419 ));
8420 }
8421 }
8422 };
8423
8424 dlg.finished(true);
8425 return Ok(response);
8426 }
8427 }
8428 }
8429 }
8430
8431 /// Required. The ImageImport name.
8432 ///
8433 /// Sets the *name* path property to the given value.
8434 ///
8435 /// Even though the property as already been set when instantiating this call,
8436 /// we provide this method for API completeness.
8437 pub fn name(mut self, new_value: &str) -> ProjectLocationImageImportGetCall<'a, C> {
8438 self._name = new_value.to_string();
8439 self
8440 }
8441 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8442 /// while executing the actual API request.
8443 ///
8444 /// ````text
8445 /// It should be used to handle progress information, and to implement a certain level of resilience.
8446 /// ````
8447 ///
8448 /// Sets the *delegate* property to the given value.
8449 pub fn delegate(
8450 mut self,
8451 new_value: &'a mut dyn common::Delegate,
8452 ) -> ProjectLocationImageImportGetCall<'a, C> {
8453 self._delegate = Some(new_value);
8454 self
8455 }
8456
8457 /// Set any additional parameter of the query string used in the request.
8458 /// It should be used to set parameters which are not yet available through their own
8459 /// setters.
8460 ///
8461 /// Please note that this method must not be used to set any of the known parameters
8462 /// which have their own setter method. If done anyway, the request will fail.
8463 ///
8464 /// # Additional Parameters
8465 ///
8466 /// * *$.xgafv* (query-string) - V1 error format.
8467 /// * *access_token* (query-string) - OAuth access token.
8468 /// * *alt* (query-string) - Data format for response.
8469 /// * *callback* (query-string) - JSONP
8470 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8471 /// * *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.
8472 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8473 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8474 /// * *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.
8475 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8476 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8477 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationImageImportGetCall<'a, C>
8478 where
8479 T: AsRef<str>,
8480 {
8481 self._additional_params
8482 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8483 self
8484 }
8485
8486 /// Identifies the authorization scope for the method you are building.
8487 ///
8488 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8489 /// [`Scope::CloudPlatform`].
8490 ///
8491 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8492 /// tokens for more than one scope.
8493 ///
8494 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8495 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8496 /// sufficient, a read-write scope will do as well.
8497 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationImageImportGetCall<'a, C>
8498 where
8499 St: AsRef<str>,
8500 {
8501 self._scopes.insert(String::from(scope.as_ref()));
8502 self
8503 }
8504 /// Identifies the authorization scope(s) for the method you are building.
8505 ///
8506 /// See [`Self::add_scope()`] for details.
8507 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationImageImportGetCall<'a, C>
8508 where
8509 I: IntoIterator<Item = St>,
8510 St: AsRef<str>,
8511 {
8512 self._scopes
8513 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8514 self
8515 }
8516
8517 /// Removes all scopes, and no default scope will be used either.
8518 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8519 /// for details).
8520 pub fn clear_scopes(mut self) -> ProjectLocationImageImportGetCall<'a, C> {
8521 self._scopes.clear();
8522 self
8523 }
8524}
8525
8526/// Lists ImageImports in a given project.
8527///
8528/// A builder for the *locations.imageImports.list* method supported by a *project* resource.
8529/// It is not used directly, but through a [`ProjectMethods`] instance.
8530///
8531/// # Example
8532///
8533/// Instantiate a resource method builder
8534///
8535/// ```test_harness,no_run
8536/// # extern crate hyper;
8537/// # extern crate hyper_rustls;
8538/// # extern crate google_vmmigration1 as vmmigration1;
8539/// # async fn dox() {
8540/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8541///
8542/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8543/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8544/// # secret,
8545/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8546/// # ).build().await.unwrap();
8547///
8548/// # let client = hyper_util::client::legacy::Client::builder(
8549/// # hyper_util::rt::TokioExecutor::new()
8550/// # )
8551/// # .build(
8552/// # hyper_rustls::HttpsConnectorBuilder::new()
8553/// # .with_native_roots()
8554/// # .unwrap()
8555/// # .https_or_http()
8556/// # .enable_http1()
8557/// # .build()
8558/// # );
8559/// # let mut hub = VMMigrationService::new(client, auth);
8560/// // You can configure optional parameters by calling the respective setters at will, and
8561/// // execute the final call using `doit()`.
8562/// // Values shown here are possibly random and not representative !
8563/// let result = hub.projects().locations_image_imports_list("parent")
8564/// .page_token("sed")
8565/// .page_size(-70)
8566/// .order_by("sed")
8567/// .filter("no")
8568/// .doit().await;
8569/// # }
8570/// ```
8571pub struct ProjectLocationImageImportListCall<'a, C>
8572where
8573 C: 'a,
8574{
8575 hub: &'a VMMigrationService<C>,
8576 _parent: String,
8577 _page_token: Option<String>,
8578 _page_size: Option<i32>,
8579 _order_by: Option<String>,
8580 _filter: Option<String>,
8581 _delegate: Option<&'a mut dyn common::Delegate>,
8582 _additional_params: HashMap<String, String>,
8583 _scopes: BTreeSet<String>,
8584}
8585
8586impl<'a, C> common::CallBuilder for ProjectLocationImageImportListCall<'a, C> {}
8587
8588impl<'a, C> ProjectLocationImageImportListCall<'a, C>
8589where
8590 C: common::Connector,
8591{
8592 /// Perform the operation you have build so far.
8593 pub async fn doit(mut self) -> common::Result<(common::Response, ListImageImportsResponse)> {
8594 use std::borrow::Cow;
8595 use std::io::{Read, Seek};
8596
8597 use common::{url::Params, ToParts};
8598 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8599
8600 let mut dd = common::DefaultDelegate;
8601 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8602 dlg.begin(common::MethodInfo {
8603 id: "vmmigration.projects.locations.imageImports.list",
8604 http_method: hyper::Method::GET,
8605 });
8606
8607 for &field in [
8608 "alt",
8609 "parent",
8610 "pageToken",
8611 "pageSize",
8612 "orderBy",
8613 "filter",
8614 ]
8615 .iter()
8616 {
8617 if self._additional_params.contains_key(field) {
8618 dlg.finished(false);
8619 return Err(common::Error::FieldClash(field));
8620 }
8621 }
8622
8623 let mut params = Params::with_capacity(7 + self._additional_params.len());
8624 params.push("parent", self._parent);
8625 if let Some(value) = self._page_token.as_ref() {
8626 params.push("pageToken", value);
8627 }
8628 if let Some(value) = self._page_size.as_ref() {
8629 params.push("pageSize", value.to_string());
8630 }
8631 if let Some(value) = self._order_by.as_ref() {
8632 params.push("orderBy", value);
8633 }
8634 if let Some(value) = self._filter.as_ref() {
8635 params.push("filter", value);
8636 }
8637
8638 params.extend(self._additional_params.iter());
8639
8640 params.push("alt", "json");
8641 let mut url = self.hub._base_url.clone() + "v1/{+parent}/imageImports";
8642 if self._scopes.is_empty() {
8643 self._scopes
8644 .insert(Scope::CloudPlatform.as_ref().to_string());
8645 }
8646
8647 #[allow(clippy::single_element_loop)]
8648 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8649 url = params.uri_replacement(url, param_name, find_this, true);
8650 }
8651 {
8652 let to_remove = ["parent"];
8653 params.remove_params(&to_remove);
8654 }
8655
8656 let url = params.parse_with_url(&url);
8657
8658 loop {
8659 let token = match self
8660 .hub
8661 .auth
8662 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8663 .await
8664 {
8665 Ok(token) => token,
8666 Err(e) => match dlg.token(e) {
8667 Ok(token) => token,
8668 Err(e) => {
8669 dlg.finished(false);
8670 return Err(common::Error::MissingToken(e));
8671 }
8672 },
8673 };
8674 let mut req_result = {
8675 let client = &self.hub.client;
8676 dlg.pre_request();
8677 let mut req_builder = hyper::Request::builder()
8678 .method(hyper::Method::GET)
8679 .uri(url.as_str())
8680 .header(USER_AGENT, self.hub._user_agent.clone());
8681
8682 if let Some(token) = token.as_ref() {
8683 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8684 }
8685
8686 let request = req_builder
8687 .header(CONTENT_LENGTH, 0_u64)
8688 .body(common::to_body::<String>(None));
8689
8690 client.request(request.unwrap()).await
8691 };
8692
8693 match req_result {
8694 Err(err) => {
8695 if let common::Retry::After(d) = dlg.http_error(&err) {
8696 sleep(d).await;
8697 continue;
8698 }
8699 dlg.finished(false);
8700 return Err(common::Error::HttpError(err));
8701 }
8702 Ok(res) => {
8703 let (mut parts, body) = res.into_parts();
8704 let mut body = common::Body::new(body);
8705 if !parts.status.is_success() {
8706 let bytes = common::to_bytes(body).await.unwrap_or_default();
8707 let error = serde_json::from_str(&common::to_string(&bytes));
8708 let response = common::to_response(parts, bytes.into());
8709
8710 if let common::Retry::After(d) =
8711 dlg.http_failure(&response, error.as_ref().ok())
8712 {
8713 sleep(d).await;
8714 continue;
8715 }
8716
8717 dlg.finished(false);
8718
8719 return Err(match error {
8720 Ok(value) => common::Error::BadRequest(value),
8721 _ => common::Error::Failure(response),
8722 });
8723 }
8724 let response = {
8725 let bytes = common::to_bytes(body).await.unwrap_or_default();
8726 let encoded = common::to_string(&bytes);
8727 match serde_json::from_str(&encoded) {
8728 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8729 Err(error) => {
8730 dlg.response_json_decode_error(&encoded, &error);
8731 return Err(common::Error::JsonDecodeError(
8732 encoded.to_string(),
8733 error,
8734 ));
8735 }
8736 }
8737 };
8738
8739 dlg.finished(true);
8740 return Ok(response);
8741 }
8742 }
8743 }
8744 }
8745
8746 /// Required. The parent, which owns this collection of targets.
8747 ///
8748 /// Sets the *parent* path property to the given value.
8749 ///
8750 /// Even though the property as already been set when instantiating this call,
8751 /// we provide this method for API completeness.
8752 pub fn parent(mut self, new_value: &str) -> ProjectLocationImageImportListCall<'a, C> {
8753 self._parent = new_value.to_string();
8754 self
8755 }
8756 /// Optional. A page token, received from a previous `ListImageImports` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListImageImports` must match the call that provided the page token.
8757 ///
8758 /// Sets the *page token* query property to the given value.
8759 pub fn page_token(mut self, new_value: &str) -> ProjectLocationImageImportListCall<'a, C> {
8760 self._page_token = Some(new_value.to_string());
8761 self
8762 }
8763 /// Optional. The maximum number of targets to return. The service may return fewer than this value. If unspecified, at most 500 targets will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
8764 ///
8765 /// Sets the *page size* query property to the given value.
8766 pub fn page_size(mut self, new_value: i32) -> ProjectLocationImageImportListCall<'a, C> {
8767 self._page_size = Some(new_value);
8768 self
8769 }
8770 /// Optional. The order by fields for the result (according to https://google.aip.dev/132#ordering). Currently ordering is only possible by "name" field.
8771 ///
8772 /// Sets the *order by* query property to the given value.
8773 pub fn order_by(mut self, new_value: &str) -> ProjectLocationImageImportListCall<'a, C> {
8774 self._order_by = Some(new_value.to_string());
8775 self
8776 }
8777 /// Optional. The filter request (according to https://google.aip.dev/160).
8778 ///
8779 /// Sets the *filter* query property to the given value.
8780 pub fn filter(mut self, new_value: &str) -> ProjectLocationImageImportListCall<'a, C> {
8781 self._filter = Some(new_value.to_string());
8782 self
8783 }
8784 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8785 /// while executing the actual API request.
8786 ///
8787 /// ````text
8788 /// It should be used to handle progress information, and to implement a certain level of resilience.
8789 /// ````
8790 ///
8791 /// Sets the *delegate* property to the given value.
8792 pub fn delegate(
8793 mut self,
8794 new_value: &'a mut dyn common::Delegate,
8795 ) -> ProjectLocationImageImportListCall<'a, C> {
8796 self._delegate = Some(new_value);
8797 self
8798 }
8799
8800 /// Set any additional parameter of the query string used in the request.
8801 /// It should be used to set parameters which are not yet available through their own
8802 /// setters.
8803 ///
8804 /// Please note that this method must not be used to set any of the known parameters
8805 /// which have their own setter method. If done anyway, the request will fail.
8806 ///
8807 /// # Additional Parameters
8808 ///
8809 /// * *$.xgafv* (query-string) - V1 error format.
8810 /// * *access_token* (query-string) - OAuth access token.
8811 /// * *alt* (query-string) - Data format for response.
8812 /// * *callback* (query-string) - JSONP
8813 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8814 /// * *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.
8815 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8816 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8817 /// * *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.
8818 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8819 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8820 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationImageImportListCall<'a, C>
8821 where
8822 T: AsRef<str>,
8823 {
8824 self._additional_params
8825 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8826 self
8827 }
8828
8829 /// Identifies the authorization scope for the method you are building.
8830 ///
8831 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8832 /// [`Scope::CloudPlatform`].
8833 ///
8834 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8835 /// tokens for more than one scope.
8836 ///
8837 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8838 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8839 /// sufficient, a read-write scope will do as well.
8840 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationImageImportListCall<'a, C>
8841 where
8842 St: AsRef<str>,
8843 {
8844 self._scopes.insert(String::from(scope.as_ref()));
8845 self
8846 }
8847 /// Identifies the authorization scope(s) for the method you are building.
8848 ///
8849 /// See [`Self::add_scope()`] for details.
8850 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationImageImportListCall<'a, C>
8851 where
8852 I: IntoIterator<Item = St>,
8853 St: AsRef<str>,
8854 {
8855 self._scopes
8856 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8857 self
8858 }
8859
8860 /// Removes all scopes, and no default scope will be used either.
8861 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8862 /// for details).
8863 pub fn clear_scopes(mut self) -> ProjectLocationImageImportListCall<'a, C> {
8864 self._scopes.clear();
8865 self
8866 }
8867}
8868
8869/// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`.
8870///
8871/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
8872/// It is not used directly, but through a [`ProjectMethods`] instance.
8873///
8874/// # Example
8875///
8876/// Instantiate a resource method builder
8877///
8878/// ```test_harness,no_run
8879/// # extern crate hyper;
8880/// # extern crate hyper_rustls;
8881/// # extern crate google_vmmigration1 as vmmigration1;
8882/// use vmmigration1::api::CancelOperationRequest;
8883/// # async fn dox() {
8884/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8885///
8886/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8887/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8888/// # secret,
8889/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8890/// # ).build().await.unwrap();
8891///
8892/// # let client = hyper_util::client::legacy::Client::builder(
8893/// # hyper_util::rt::TokioExecutor::new()
8894/// # )
8895/// # .build(
8896/// # hyper_rustls::HttpsConnectorBuilder::new()
8897/// # .with_native_roots()
8898/// # .unwrap()
8899/// # .https_or_http()
8900/// # .enable_http1()
8901/// # .build()
8902/// # );
8903/// # let mut hub = VMMigrationService::new(client, auth);
8904/// // As the method needs a request, you would usually fill it with the desired information
8905/// // into the respective structure. Some of the parts shown here might not be applicable !
8906/// // Values shown here are possibly random and not representative !
8907/// let mut req = CancelOperationRequest::default();
8908///
8909/// // You can configure optional parameters by calling the respective setters at will, and
8910/// // execute the final call using `doit()`.
8911/// // Values shown here are possibly random and not representative !
8912/// let result = hub.projects().locations_operations_cancel(req, "name")
8913/// .doit().await;
8914/// # }
8915/// ```
8916pub struct ProjectLocationOperationCancelCall<'a, C>
8917where
8918 C: 'a,
8919{
8920 hub: &'a VMMigrationService<C>,
8921 _request: CancelOperationRequest,
8922 _name: String,
8923 _delegate: Option<&'a mut dyn common::Delegate>,
8924 _additional_params: HashMap<String, String>,
8925 _scopes: BTreeSet<String>,
8926}
8927
8928impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
8929
8930impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
8931where
8932 C: common::Connector,
8933{
8934 /// Perform the operation you have build so far.
8935 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
8936 use std::borrow::Cow;
8937 use std::io::{Read, Seek};
8938
8939 use common::{url::Params, ToParts};
8940 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8941
8942 let mut dd = common::DefaultDelegate;
8943 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8944 dlg.begin(common::MethodInfo {
8945 id: "vmmigration.projects.locations.operations.cancel",
8946 http_method: hyper::Method::POST,
8947 });
8948
8949 for &field in ["alt", "name"].iter() {
8950 if self._additional_params.contains_key(field) {
8951 dlg.finished(false);
8952 return Err(common::Error::FieldClash(field));
8953 }
8954 }
8955
8956 let mut params = Params::with_capacity(4 + self._additional_params.len());
8957 params.push("name", self._name);
8958
8959 params.extend(self._additional_params.iter());
8960
8961 params.push("alt", "json");
8962 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
8963 if self._scopes.is_empty() {
8964 self._scopes
8965 .insert(Scope::CloudPlatform.as_ref().to_string());
8966 }
8967
8968 #[allow(clippy::single_element_loop)]
8969 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8970 url = params.uri_replacement(url, param_name, find_this, true);
8971 }
8972 {
8973 let to_remove = ["name"];
8974 params.remove_params(&to_remove);
8975 }
8976
8977 let url = params.parse_with_url(&url);
8978
8979 let mut json_mime_type = mime::APPLICATION_JSON;
8980 let mut request_value_reader = {
8981 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8982 common::remove_json_null_values(&mut value);
8983 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8984 serde_json::to_writer(&mut dst, &value).unwrap();
8985 dst
8986 };
8987 let request_size = request_value_reader
8988 .seek(std::io::SeekFrom::End(0))
8989 .unwrap();
8990 request_value_reader
8991 .seek(std::io::SeekFrom::Start(0))
8992 .unwrap();
8993
8994 loop {
8995 let token = match self
8996 .hub
8997 .auth
8998 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8999 .await
9000 {
9001 Ok(token) => token,
9002 Err(e) => match dlg.token(e) {
9003 Ok(token) => token,
9004 Err(e) => {
9005 dlg.finished(false);
9006 return Err(common::Error::MissingToken(e));
9007 }
9008 },
9009 };
9010 request_value_reader
9011 .seek(std::io::SeekFrom::Start(0))
9012 .unwrap();
9013 let mut req_result = {
9014 let client = &self.hub.client;
9015 dlg.pre_request();
9016 let mut req_builder = hyper::Request::builder()
9017 .method(hyper::Method::POST)
9018 .uri(url.as_str())
9019 .header(USER_AGENT, self.hub._user_agent.clone());
9020
9021 if let Some(token) = token.as_ref() {
9022 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9023 }
9024
9025 let request = req_builder
9026 .header(CONTENT_TYPE, json_mime_type.to_string())
9027 .header(CONTENT_LENGTH, request_size as u64)
9028 .body(common::to_body(
9029 request_value_reader.get_ref().clone().into(),
9030 ));
9031
9032 client.request(request.unwrap()).await
9033 };
9034
9035 match req_result {
9036 Err(err) => {
9037 if let common::Retry::After(d) = dlg.http_error(&err) {
9038 sleep(d).await;
9039 continue;
9040 }
9041 dlg.finished(false);
9042 return Err(common::Error::HttpError(err));
9043 }
9044 Ok(res) => {
9045 let (mut parts, body) = res.into_parts();
9046 let mut body = common::Body::new(body);
9047 if !parts.status.is_success() {
9048 let bytes = common::to_bytes(body).await.unwrap_or_default();
9049 let error = serde_json::from_str(&common::to_string(&bytes));
9050 let response = common::to_response(parts, bytes.into());
9051
9052 if let common::Retry::After(d) =
9053 dlg.http_failure(&response, error.as_ref().ok())
9054 {
9055 sleep(d).await;
9056 continue;
9057 }
9058
9059 dlg.finished(false);
9060
9061 return Err(match error {
9062 Ok(value) => common::Error::BadRequest(value),
9063 _ => common::Error::Failure(response),
9064 });
9065 }
9066 let response = {
9067 let bytes = common::to_bytes(body).await.unwrap_or_default();
9068 let encoded = common::to_string(&bytes);
9069 match serde_json::from_str(&encoded) {
9070 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9071 Err(error) => {
9072 dlg.response_json_decode_error(&encoded, &error);
9073 return Err(common::Error::JsonDecodeError(
9074 encoded.to_string(),
9075 error,
9076 ));
9077 }
9078 }
9079 };
9080
9081 dlg.finished(true);
9082 return Ok(response);
9083 }
9084 }
9085 }
9086 }
9087
9088 ///
9089 /// Sets the *request* property to the given value.
9090 ///
9091 /// Even though the property as already been set when instantiating this call,
9092 /// we provide this method for API completeness.
9093 pub fn request(
9094 mut self,
9095 new_value: CancelOperationRequest,
9096 ) -> ProjectLocationOperationCancelCall<'a, C> {
9097 self._request = new_value;
9098 self
9099 }
9100 /// The name of the operation resource to be cancelled.
9101 ///
9102 /// Sets the *name* path property to the given value.
9103 ///
9104 /// Even though the property as already been set when instantiating this call,
9105 /// we provide this method for API completeness.
9106 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
9107 self._name = new_value.to_string();
9108 self
9109 }
9110 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9111 /// while executing the actual API request.
9112 ///
9113 /// ````text
9114 /// It should be used to handle progress information, and to implement a certain level of resilience.
9115 /// ````
9116 ///
9117 /// Sets the *delegate* property to the given value.
9118 pub fn delegate(
9119 mut self,
9120 new_value: &'a mut dyn common::Delegate,
9121 ) -> ProjectLocationOperationCancelCall<'a, C> {
9122 self._delegate = Some(new_value);
9123 self
9124 }
9125
9126 /// Set any additional parameter of the query string used in the request.
9127 /// It should be used to set parameters which are not yet available through their own
9128 /// setters.
9129 ///
9130 /// Please note that this method must not be used to set any of the known parameters
9131 /// which have their own setter method. If done anyway, the request will fail.
9132 ///
9133 /// # Additional Parameters
9134 ///
9135 /// * *$.xgafv* (query-string) - V1 error format.
9136 /// * *access_token* (query-string) - OAuth access token.
9137 /// * *alt* (query-string) - Data format for response.
9138 /// * *callback* (query-string) - JSONP
9139 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9140 /// * *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.
9141 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9142 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9143 /// * *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.
9144 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9145 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9146 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
9147 where
9148 T: AsRef<str>,
9149 {
9150 self._additional_params
9151 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9152 self
9153 }
9154
9155 /// Identifies the authorization scope for the method you are building.
9156 ///
9157 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9158 /// [`Scope::CloudPlatform`].
9159 ///
9160 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9161 /// tokens for more than one scope.
9162 ///
9163 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9164 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9165 /// sufficient, a read-write scope will do as well.
9166 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
9167 where
9168 St: AsRef<str>,
9169 {
9170 self._scopes.insert(String::from(scope.as_ref()));
9171 self
9172 }
9173 /// Identifies the authorization scope(s) for the method you are building.
9174 ///
9175 /// See [`Self::add_scope()`] for details.
9176 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
9177 where
9178 I: IntoIterator<Item = St>,
9179 St: AsRef<str>,
9180 {
9181 self._scopes
9182 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9183 self
9184 }
9185
9186 /// Removes all scopes, and no default scope will be used either.
9187 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9188 /// for details).
9189 pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
9190 self._scopes.clear();
9191 self
9192 }
9193}
9194
9195/// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
9196///
9197/// A builder for the *locations.operations.delete* method supported by a *project* resource.
9198/// It is not used directly, but through a [`ProjectMethods`] instance.
9199///
9200/// # Example
9201///
9202/// Instantiate a resource method builder
9203///
9204/// ```test_harness,no_run
9205/// # extern crate hyper;
9206/// # extern crate hyper_rustls;
9207/// # extern crate google_vmmigration1 as vmmigration1;
9208/// # async fn dox() {
9209/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9210///
9211/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9212/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9213/// # secret,
9214/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9215/// # ).build().await.unwrap();
9216///
9217/// # let client = hyper_util::client::legacy::Client::builder(
9218/// # hyper_util::rt::TokioExecutor::new()
9219/// # )
9220/// # .build(
9221/// # hyper_rustls::HttpsConnectorBuilder::new()
9222/// # .with_native_roots()
9223/// # .unwrap()
9224/// # .https_or_http()
9225/// # .enable_http1()
9226/// # .build()
9227/// # );
9228/// # let mut hub = VMMigrationService::new(client, auth);
9229/// // You can configure optional parameters by calling the respective setters at will, and
9230/// // execute the final call using `doit()`.
9231/// // Values shown here are possibly random and not representative !
9232/// let result = hub.projects().locations_operations_delete("name")
9233/// .doit().await;
9234/// # }
9235/// ```
9236pub struct ProjectLocationOperationDeleteCall<'a, C>
9237where
9238 C: 'a,
9239{
9240 hub: &'a VMMigrationService<C>,
9241 _name: String,
9242 _delegate: Option<&'a mut dyn common::Delegate>,
9243 _additional_params: HashMap<String, String>,
9244 _scopes: BTreeSet<String>,
9245}
9246
9247impl<'a, C> common::CallBuilder for ProjectLocationOperationDeleteCall<'a, C> {}
9248
9249impl<'a, C> ProjectLocationOperationDeleteCall<'a, C>
9250where
9251 C: common::Connector,
9252{
9253 /// Perform the operation you have build so far.
9254 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
9255 use std::borrow::Cow;
9256 use std::io::{Read, Seek};
9257
9258 use common::{url::Params, ToParts};
9259 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9260
9261 let mut dd = common::DefaultDelegate;
9262 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9263 dlg.begin(common::MethodInfo {
9264 id: "vmmigration.projects.locations.operations.delete",
9265 http_method: hyper::Method::DELETE,
9266 });
9267
9268 for &field in ["alt", "name"].iter() {
9269 if self._additional_params.contains_key(field) {
9270 dlg.finished(false);
9271 return Err(common::Error::FieldClash(field));
9272 }
9273 }
9274
9275 let mut params = Params::with_capacity(3 + self._additional_params.len());
9276 params.push("name", self._name);
9277
9278 params.extend(self._additional_params.iter());
9279
9280 params.push("alt", "json");
9281 let mut url = self.hub._base_url.clone() + "v1/{+name}";
9282 if self._scopes.is_empty() {
9283 self._scopes
9284 .insert(Scope::CloudPlatform.as_ref().to_string());
9285 }
9286
9287 #[allow(clippy::single_element_loop)]
9288 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9289 url = params.uri_replacement(url, param_name, find_this, true);
9290 }
9291 {
9292 let to_remove = ["name"];
9293 params.remove_params(&to_remove);
9294 }
9295
9296 let url = params.parse_with_url(&url);
9297
9298 loop {
9299 let token = match self
9300 .hub
9301 .auth
9302 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9303 .await
9304 {
9305 Ok(token) => token,
9306 Err(e) => match dlg.token(e) {
9307 Ok(token) => token,
9308 Err(e) => {
9309 dlg.finished(false);
9310 return Err(common::Error::MissingToken(e));
9311 }
9312 },
9313 };
9314 let mut req_result = {
9315 let client = &self.hub.client;
9316 dlg.pre_request();
9317 let mut req_builder = hyper::Request::builder()
9318 .method(hyper::Method::DELETE)
9319 .uri(url.as_str())
9320 .header(USER_AGENT, self.hub._user_agent.clone());
9321
9322 if let Some(token) = token.as_ref() {
9323 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9324 }
9325
9326 let request = req_builder
9327 .header(CONTENT_LENGTH, 0_u64)
9328 .body(common::to_body::<String>(None));
9329
9330 client.request(request.unwrap()).await
9331 };
9332
9333 match req_result {
9334 Err(err) => {
9335 if let common::Retry::After(d) = dlg.http_error(&err) {
9336 sleep(d).await;
9337 continue;
9338 }
9339 dlg.finished(false);
9340 return Err(common::Error::HttpError(err));
9341 }
9342 Ok(res) => {
9343 let (mut parts, body) = res.into_parts();
9344 let mut body = common::Body::new(body);
9345 if !parts.status.is_success() {
9346 let bytes = common::to_bytes(body).await.unwrap_or_default();
9347 let error = serde_json::from_str(&common::to_string(&bytes));
9348 let response = common::to_response(parts, bytes.into());
9349
9350 if let common::Retry::After(d) =
9351 dlg.http_failure(&response, error.as_ref().ok())
9352 {
9353 sleep(d).await;
9354 continue;
9355 }
9356
9357 dlg.finished(false);
9358
9359 return Err(match error {
9360 Ok(value) => common::Error::BadRequest(value),
9361 _ => common::Error::Failure(response),
9362 });
9363 }
9364 let response = {
9365 let bytes = common::to_bytes(body).await.unwrap_or_default();
9366 let encoded = common::to_string(&bytes);
9367 match serde_json::from_str(&encoded) {
9368 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9369 Err(error) => {
9370 dlg.response_json_decode_error(&encoded, &error);
9371 return Err(common::Error::JsonDecodeError(
9372 encoded.to_string(),
9373 error,
9374 ));
9375 }
9376 }
9377 };
9378
9379 dlg.finished(true);
9380 return Ok(response);
9381 }
9382 }
9383 }
9384 }
9385
9386 /// The name of the operation resource to be deleted.
9387 ///
9388 /// Sets the *name* path property to the given value.
9389 ///
9390 /// Even though the property as already been set when instantiating this call,
9391 /// we provide this method for API completeness.
9392 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationDeleteCall<'a, C> {
9393 self._name = new_value.to_string();
9394 self
9395 }
9396 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9397 /// while executing the actual API request.
9398 ///
9399 /// ````text
9400 /// It should be used to handle progress information, and to implement a certain level of resilience.
9401 /// ````
9402 ///
9403 /// Sets the *delegate* property to the given value.
9404 pub fn delegate(
9405 mut self,
9406 new_value: &'a mut dyn common::Delegate,
9407 ) -> ProjectLocationOperationDeleteCall<'a, C> {
9408 self._delegate = Some(new_value);
9409 self
9410 }
9411
9412 /// Set any additional parameter of the query string used in the request.
9413 /// It should be used to set parameters which are not yet available through their own
9414 /// setters.
9415 ///
9416 /// Please note that this method must not be used to set any of the known parameters
9417 /// which have their own setter method. If done anyway, the request will fail.
9418 ///
9419 /// # Additional Parameters
9420 ///
9421 /// * *$.xgafv* (query-string) - V1 error format.
9422 /// * *access_token* (query-string) - OAuth access token.
9423 /// * *alt* (query-string) - Data format for response.
9424 /// * *callback* (query-string) - JSONP
9425 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9426 /// * *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.
9427 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9428 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9429 /// * *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.
9430 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9431 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9432 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationDeleteCall<'a, C>
9433 where
9434 T: AsRef<str>,
9435 {
9436 self._additional_params
9437 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9438 self
9439 }
9440
9441 /// Identifies the authorization scope for the method you are building.
9442 ///
9443 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9444 /// [`Scope::CloudPlatform`].
9445 ///
9446 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9447 /// tokens for more than one scope.
9448 ///
9449 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9450 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9451 /// sufficient, a read-write scope will do as well.
9452 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationDeleteCall<'a, C>
9453 where
9454 St: AsRef<str>,
9455 {
9456 self._scopes.insert(String::from(scope.as_ref()));
9457 self
9458 }
9459 /// Identifies the authorization scope(s) for the method you are building.
9460 ///
9461 /// See [`Self::add_scope()`] for details.
9462 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationDeleteCall<'a, C>
9463 where
9464 I: IntoIterator<Item = St>,
9465 St: AsRef<str>,
9466 {
9467 self._scopes
9468 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9469 self
9470 }
9471
9472 /// Removes all scopes, and no default scope will be used either.
9473 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9474 /// for details).
9475 pub fn clear_scopes(mut self) -> ProjectLocationOperationDeleteCall<'a, C> {
9476 self._scopes.clear();
9477 self
9478 }
9479}
9480
9481/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
9482///
9483/// A builder for the *locations.operations.get* method supported by a *project* resource.
9484/// It is not used directly, but through a [`ProjectMethods`] instance.
9485///
9486/// # Example
9487///
9488/// Instantiate a resource method builder
9489///
9490/// ```test_harness,no_run
9491/// # extern crate hyper;
9492/// # extern crate hyper_rustls;
9493/// # extern crate google_vmmigration1 as vmmigration1;
9494/// # async fn dox() {
9495/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9496///
9497/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9498/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9499/// # secret,
9500/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9501/// # ).build().await.unwrap();
9502///
9503/// # let client = hyper_util::client::legacy::Client::builder(
9504/// # hyper_util::rt::TokioExecutor::new()
9505/// # )
9506/// # .build(
9507/// # hyper_rustls::HttpsConnectorBuilder::new()
9508/// # .with_native_roots()
9509/// # .unwrap()
9510/// # .https_or_http()
9511/// # .enable_http1()
9512/// # .build()
9513/// # );
9514/// # let mut hub = VMMigrationService::new(client, auth);
9515/// // You can configure optional parameters by calling the respective setters at will, and
9516/// // execute the final call using `doit()`.
9517/// // Values shown here are possibly random and not representative !
9518/// let result = hub.projects().locations_operations_get("name")
9519/// .doit().await;
9520/// # }
9521/// ```
9522pub struct ProjectLocationOperationGetCall<'a, C>
9523where
9524 C: 'a,
9525{
9526 hub: &'a VMMigrationService<C>,
9527 _name: String,
9528 _delegate: Option<&'a mut dyn common::Delegate>,
9529 _additional_params: HashMap<String, String>,
9530 _scopes: BTreeSet<String>,
9531}
9532
9533impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
9534
9535impl<'a, C> ProjectLocationOperationGetCall<'a, C>
9536where
9537 C: common::Connector,
9538{
9539 /// Perform the operation you have build so far.
9540 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9541 use std::borrow::Cow;
9542 use std::io::{Read, Seek};
9543
9544 use common::{url::Params, ToParts};
9545 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9546
9547 let mut dd = common::DefaultDelegate;
9548 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9549 dlg.begin(common::MethodInfo {
9550 id: "vmmigration.projects.locations.operations.get",
9551 http_method: hyper::Method::GET,
9552 });
9553
9554 for &field in ["alt", "name"].iter() {
9555 if self._additional_params.contains_key(field) {
9556 dlg.finished(false);
9557 return Err(common::Error::FieldClash(field));
9558 }
9559 }
9560
9561 let mut params = Params::with_capacity(3 + self._additional_params.len());
9562 params.push("name", self._name);
9563
9564 params.extend(self._additional_params.iter());
9565
9566 params.push("alt", "json");
9567 let mut url = self.hub._base_url.clone() + "v1/{+name}";
9568 if self._scopes.is_empty() {
9569 self._scopes
9570 .insert(Scope::CloudPlatform.as_ref().to_string());
9571 }
9572
9573 #[allow(clippy::single_element_loop)]
9574 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9575 url = params.uri_replacement(url, param_name, find_this, true);
9576 }
9577 {
9578 let to_remove = ["name"];
9579 params.remove_params(&to_remove);
9580 }
9581
9582 let url = params.parse_with_url(&url);
9583
9584 loop {
9585 let token = match self
9586 .hub
9587 .auth
9588 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9589 .await
9590 {
9591 Ok(token) => token,
9592 Err(e) => match dlg.token(e) {
9593 Ok(token) => token,
9594 Err(e) => {
9595 dlg.finished(false);
9596 return Err(common::Error::MissingToken(e));
9597 }
9598 },
9599 };
9600 let mut req_result = {
9601 let client = &self.hub.client;
9602 dlg.pre_request();
9603 let mut req_builder = hyper::Request::builder()
9604 .method(hyper::Method::GET)
9605 .uri(url.as_str())
9606 .header(USER_AGENT, self.hub._user_agent.clone());
9607
9608 if let Some(token) = token.as_ref() {
9609 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9610 }
9611
9612 let request = req_builder
9613 .header(CONTENT_LENGTH, 0_u64)
9614 .body(common::to_body::<String>(None));
9615
9616 client.request(request.unwrap()).await
9617 };
9618
9619 match req_result {
9620 Err(err) => {
9621 if let common::Retry::After(d) = dlg.http_error(&err) {
9622 sleep(d).await;
9623 continue;
9624 }
9625 dlg.finished(false);
9626 return Err(common::Error::HttpError(err));
9627 }
9628 Ok(res) => {
9629 let (mut parts, body) = res.into_parts();
9630 let mut body = common::Body::new(body);
9631 if !parts.status.is_success() {
9632 let bytes = common::to_bytes(body).await.unwrap_or_default();
9633 let error = serde_json::from_str(&common::to_string(&bytes));
9634 let response = common::to_response(parts, bytes.into());
9635
9636 if let common::Retry::After(d) =
9637 dlg.http_failure(&response, error.as_ref().ok())
9638 {
9639 sleep(d).await;
9640 continue;
9641 }
9642
9643 dlg.finished(false);
9644
9645 return Err(match error {
9646 Ok(value) => common::Error::BadRequest(value),
9647 _ => common::Error::Failure(response),
9648 });
9649 }
9650 let response = {
9651 let bytes = common::to_bytes(body).await.unwrap_or_default();
9652 let encoded = common::to_string(&bytes);
9653 match serde_json::from_str(&encoded) {
9654 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9655 Err(error) => {
9656 dlg.response_json_decode_error(&encoded, &error);
9657 return Err(common::Error::JsonDecodeError(
9658 encoded.to_string(),
9659 error,
9660 ));
9661 }
9662 }
9663 };
9664
9665 dlg.finished(true);
9666 return Ok(response);
9667 }
9668 }
9669 }
9670 }
9671
9672 /// The name of the operation resource.
9673 ///
9674 /// Sets the *name* path property to the given value.
9675 ///
9676 /// Even though the property as already been set when instantiating this call,
9677 /// we provide this method for API completeness.
9678 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
9679 self._name = new_value.to_string();
9680 self
9681 }
9682 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9683 /// while executing the actual API request.
9684 ///
9685 /// ````text
9686 /// It should be used to handle progress information, and to implement a certain level of resilience.
9687 /// ````
9688 ///
9689 /// Sets the *delegate* property to the given value.
9690 pub fn delegate(
9691 mut self,
9692 new_value: &'a mut dyn common::Delegate,
9693 ) -> ProjectLocationOperationGetCall<'a, C> {
9694 self._delegate = Some(new_value);
9695 self
9696 }
9697
9698 /// Set any additional parameter of the query string used in the request.
9699 /// It should be used to set parameters which are not yet available through their own
9700 /// setters.
9701 ///
9702 /// Please note that this method must not be used to set any of the known parameters
9703 /// which have their own setter method. If done anyway, the request will fail.
9704 ///
9705 /// # Additional Parameters
9706 ///
9707 /// * *$.xgafv* (query-string) - V1 error format.
9708 /// * *access_token* (query-string) - OAuth access token.
9709 /// * *alt* (query-string) - Data format for response.
9710 /// * *callback* (query-string) - JSONP
9711 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9712 /// * *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.
9713 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9714 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9715 /// * *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.
9716 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9717 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9718 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
9719 where
9720 T: AsRef<str>,
9721 {
9722 self._additional_params
9723 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9724 self
9725 }
9726
9727 /// Identifies the authorization scope for the method you are building.
9728 ///
9729 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9730 /// [`Scope::CloudPlatform`].
9731 ///
9732 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9733 /// tokens for more than one scope.
9734 ///
9735 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9736 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9737 /// sufficient, a read-write scope will do as well.
9738 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
9739 where
9740 St: AsRef<str>,
9741 {
9742 self._scopes.insert(String::from(scope.as_ref()));
9743 self
9744 }
9745 /// Identifies the authorization scope(s) for the method you are building.
9746 ///
9747 /// See [`Self::add_scope()`] for details.
9748 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
9749 where
9750 I: IntoIterator<Item = St>,
9751 St: AsRef<str>,
9752 {
9753 self._scopes
9754 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9755 self
9756 }
9757
9758 /// Removes all scopes, and no default scope will be used either.
9759 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9760 /// for details).
9761 pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
9762 self._scopes.clear();
9763 self
9764 }
9765}
9766
9767/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
9768///
9769/// A builder for the *locations.operations.list* method supported by a *project* resource.
9770/// It is not used directly, but through a [`ProjectMethods`] instance.
9771///
9772/// # Example
9773///
9774/// Instantiate a resource method builder
9775///
9776/// ```test_harness,no_run
9777/// # extern crate hyper;
9778/// # extern crate hyper_rustls;
9779/// # extern crate google_vmmigration1 as vmmigration1;
9780/// # async fn dox() {
9781/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9782///
9783/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9784/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9785/// # secret,
9786/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9787/// # ).build().await.unwrap();
9788///
9789/// # let client = hyper_util::client::legacy::Client::builder(
9790/// # hyper_util::rt::TokioExecutor::new()
9791/// # )
9792/// # .build(
9793/// # hyper_rustls::HttpsConnectorBuilder::new()
9794/// # .with_native_roots()
9795/// # .unwrap()
9796/// # .https_or_http()
9797/// # .enable_http1()
9798/// # .build()
9799/// # );
9800/// # let mut hub = VMMigrationService::new(client, auth);
9801/// // You can configure optional parameters by calling the respective setters at will, and
9802/// // execute the final call using `doit()`.
9803/// // Values shown here are possibly random and not representative !
9804/// let result = hub.projects().locations_operations_list("name")
9805/// .page_token("et")
9806/// .page_size(-68)
9807/// .filter("vero")
9808/// .doit().await;
9809/// # }
9810/// ```
9811pub struct ProjectLocationOperationListCall<'a, C>
9812where
9813 C: 'a,
9814{
9815 hub: &'a VMMigrationService<C>,
9816 _name: String,
9817 _page_token: Option<String>,
9818 _page_size: Option<i32>,
9819 _filter: Option<String>,
9820 _delegate: Option<&'a mut dyn common::Delegate>,
9821 _additional_params: HashMap<String, String>,
9822 _scopes: BTreeSet<String>,
9823}
9824
9825impl<'a, C> common::CallBuilder for ProjectLocationOperationListCall<'a, C> {}
9826
9827impl<'a, C> ProjectLocationOperationListCall<'a, C>
9828where
9829 C: common::Connector,
9830{
9831 /// Perform the operation you have build so far.
9832 pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
9833 use std::borrow::Cow;
9834 use std::io::{Read, Seek};
9835
9836 use common::{url::Params, ToParts};
9837 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9838
9839 let mut dd = common::DefaultDelegate;
9840 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9841 dlg.begin(common::MethodInfo {
9842 id: "vmmigration.projects.locations.operations.list",
9843 http_method: hyper::Method::GET,
9844 });
9845
9846 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
9847 if self._additional_params.contains_key(field) {
9848 dlg.finished(false);
9849 return Err(common::Error::FieldClash(field));
9850 }
9851 }
9852
9853 let mut params = Params::with_capacity(6 + self._additional_params.len());
9854 params.push("name", self._name);
9855 if let Some(value) = self._page_token.as_ref() {
9856 params.push("pageToken", value);
9857 }
9858 if let Some(value) = self._page_size.as_ref() {
9859 params.push("pageSize", value.to_string());
9860 }
9861 if let Some(value) = self._filter.as_ref() {
9862 params.push("filter", value);
9863 }
9864
9865 params.extend(self._additional_params.iter());
9866
9867 params.push("alt", "json");
9868 let mut url = self.hub._base_url.clone() + "v1/{+name}/operations";
9869 if self._scopes.is_empty() {
9870 self._scopes
9871 .insert(Scope::CloudPlatform.as_ref().to_string());
9872 }
9873
9874 #[allow(clippy::single_element_loop)]
9875 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9876 url = params.uri_replacement(url, param_name, find_this, true);
9877 }
9878 {
9879 let to_remove = ["name"];
9880 params.remove_params(&to_remove);
9881 }
9882
9883 let url = params.parse_with_url(&url);
9884
9885 loop {
9886 let token = match self
9887 .hub
9888 .auth
9889 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9890 .await
9891 {
9892 Ok(token) => token,
9893 Err(e) => match dlg.token(e) {
9894 Ok(token) => token,
9895 Err(e) => {
9896 dlg.finished(false);
9897 return Err(common::Error::MissingToken(e));
9898 }
9899 },
9900 };
9901 let mut req_result = {
9902 let client = &self.hub.client;
9903 dlg.pre_request();
9904 let mut req_builder = hyper::Request::builder()
9905 .method(hyper::Method::GET)
9906 .uri(url.as_str())
9907 .header(USER_AGENT, self.hub._user_agent.clone());
9908
9909 if let Some(token) = token.as_ref() {
9910 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9911 }
9912
9913 let request = req_builder
9914 .header(CONTENT_LENGTH, 0_u64)
9915 .body(common::to_body::<String>(None));
9916
9917 client.request(request.unwrap()).await
9918 };
9919
9920 match req_result {
9921 Err(err) => {
9922 if let common::Retry::After(d) = dlg.http_error(&err) {
9923 sleep(d).await;
9924 continue;
9925 }
9926 dlg.finished(false);
9927 return Err(common::Error::HttpError(err));
9928 }
9929 Ok(res) => {
9930 let (mut parts, body) = res.into_parts();
9931 let mut body = common::Body::new(body);
9932 if !parts.status.is_success() {
9933 let bytes = common::to_bytes(body).await.unwrap_or_default();
9934 let error = serde_json::from_str(&common::to_string(&bytes));
9935 let response = common::to_response(parts, bytes.into());
9936
9937 if let common::Retry::After(d) =
9938 dlg.http_failure(&response, error.as_ref().ok())
9939 {
9940 sleep(d).await;
9941 continue;
9942 }
9943
9944 dlg.finished(false);
9945
9946 return Err(match error {
9947 Ok(value) => common::Error::BadRequest(value),
9948 _ => common::Error::Failure(response),
9949 });
9950 }
9951 let response = {
9952 let bytes = common::to_bytes(body).await.unwrap_or_default();
9953 let encoded = common::to_string(&bytes);
9954 match serde_json::from_str(&encoded) {
9955 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9956 Err(error) => {
9957 dlg.response_json_decode_error(&encoded, &error);
9958 return Err(common::Error::JsonDecodeError(
9959 encoded.to_string(),
9960 error,
9961 ));
9962 }
9963 }
9964 };
9965
9966 dlg.finished(true);
9967 return Ok(response);
9968 }
9969 }
9970 }
9971 }
9972
9973 /// The name of the operation's parent resource.
9974 ///
9975 /// Sets the *name* path property to the given value.
9976 ///
9977 /// Even though the property as already been set when instantiating this call,
9978 /// we provide this method for API completeness.
9979 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
9980 self._name = new_value.to_string();
9981 self
9982 }
9983 /// The standard list page token.
9984 ///
9985 /// Sets the *page token* query property to the given value.
9986 pub fn page_token(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
9987 self._page_token = Some(new_value.to_string());
9988 self
9989 }
9990 /// The standard list page size.
9991 ///
9992 /// Sets the *page size* query property to the given value.
9993 pub fn page_size(mut self, new_value: i32) -> ProjectLocationOperationListCall<'a, C> {
9994 self._page_size = Some(new_value);
9995 self
9996 }
9997 /// The standard list filter.
9998 ///
9999 /// Sets the *filter* query property to the given value.
10000 pub fn filter(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
10001 self._filter = Some(new_value.to_string());
10002 self
10003 }
10004 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10005 /// while executing the actual API request.
10006 ///
10007 /// ````text
10008 /// It should be used to handle progress information, and to implement a certain level of resilience.
10009 /// ````
10010 ///
10011 /// Sets the *delegate* property to the given value.
10012 pub fn delegate(
10013 mut self,
10014 new_value: &'a mut dyn common::Delegate,
10015 ) -> ProjectLocationOperationListCall<'a, C> {
10016 self._delegate = Some(new_value);
10017 self
10018 }
10019
10020 /// Set any additional parameter of the query string used in the request.
10021 /// It should be used to set parameters which are not yet available through their own
10022 /// setters.
10023 ///
10024 /// Please note that this method must not be used to set any of the known parameters
10025 /// which have their own setter method. If done anyway, the request will fail.
10026 ///
10027 /// # Additional Parameters
10028 ///
10029 /// * *$.xgafv* (query-string) - V1 error format.
10030 /// * *access_token* (query-string) - OAuth access token.
10031 /// * *alt* (query-string) - Data format for response.
10032 /// * *callback* (query-string) - JSONP
10033 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10034 /// * *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.
10035 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10036 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10037 /// * *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.
10038 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10039 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10040 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationListCall<'a, C>
10041 where
10042 T: AsRef<str>,
10043 {
10044 self._additional_params
10045 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10046 self
10047 }
10048
10049 /// Identifies the authorization scope for the method you are building.
10050 ///
10051 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10052 /// [`Scope::CloudPlatform`].
10053 ///
10054 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10055 /// tokens for more than one scope.
10056 ///
10057 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10058 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10059 /// sufficient, a read-write scope will do as well.
10060 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationListCall<'a, C>
10061 where
10062 St: AsRef<str>,
10063 {
10064 self._scopes.insert(String::from(scope.as_ref()));
10065 self
10066 }
10067 /// Identifies the authorization scope(s) for the method you are building.
10068 ///
10069 /// See [`Self::add_scope()`] for details.
10070 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationListCall<'a, C>
10071 where
10072 I: IntoIterator<Item = St>,
10073 St: AsRef<str>,
10074 {
10075 self._scopes
10076 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10077 self
10078 }
10079
10080 /// Removes all scopes, and no default scope will be used either.
10081 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10082 /// for details).
10083 pub fn clear_scopes(mut self) -> ProjectLocationOperationListCall<'a, C> {
10084 self._scopes.clear();
10085 self
10086 }
10087}
10088
10089/// Creates a new DatacenterConnector in a given Source.
10090///
10091/// A builder for the *locations.sources.datacenterConnectors.create* method supported by a *project* resource.
10092/// It is not used directly, but through a [`ProjectMethods`] instance.
10093///
10094/// # Example
10095///
10096/// Instantiate a resource method builder
10097///
10098/// ```test_harness,no_run
10099/// # extern crate hyper;
10100/// # extern crate hyper_rustls;
10101/// # extern crate google_vmmigration1 as vmmigration1;
10102/// use vmmigration1::api::DatacenterConnector;
10103/// # async fn dox() {
10104/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10105///
10106/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10107/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10108/// # secret,
10109/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10110/// # ).build().await.unwrap();
10111///
10112/// # let client = hyper_util::client::legacy::Client::builder(
10113/// # hyper_util::rt::TokioExecutor::new()
10114/// # )
10115/// # .build(
10116/// # hyper_rustls::HttpsConnectorBuilder::new()
10117/// # .with_native_roots()
10118/// # .unwrap()
10119/// # .https_or_http()
10120/// # .enable_http1()
10121/// # .build()
10122/// # );
10123/// # let mut hub = VMMigrationService::new(client, auth);
10124/// // As the method needs a request, you would usually fill it with the desired information
10125/// // into the respective structure. Some of the parts shown here might not be applicable !
10126/// // Values shown here are possibly random and not representative !
10127/// let mut req = DatacenterConnector::default();
10128///
10129/// // You can configure optional parameters by calling the respective setters at will, and
10130/// // execute the final call using `doit()`.
10131/// // Values shown here are possibly random and not representative !
10132/// let result = hub.projects().locations_sources_datacenter_connectors_create(req, "parent")
10133/// .request_id("sed")
10134/// .datacenter_connector_id("duo")
10135/// .doit().await;
10136/// # }
10137/// ```
10138pub struct ProjectLocationSourceDatacenterConnectorCreateCall<'a, C>
10139where
10140 C: 'a,
10141{
10142 hub: &'a VMMigrationService<C>,
10143 _request: DatacenterConnector,
10144 _parent: String,
10145 _request_id: Option<String>,
10146 _datacenter_connector_id: Option<String>,
10147 _delegate: Option<&'a mut dyn common::Delegate>,
10148 _additional_params: HashMap<String, String>,
10149 _scopes: BTreeSet<String>,
10150}
10151
10152impl<'a, C> common::CallBuilder for ProjectLocationSourceDatacenterConnectorCreateCall<'a, C> {}
10153
10154impl<'a, C> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C>
10155where
10156 C: common::Connector,
10157{
10158 /// Perform the operation you have build so far.
10159 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10160 use std::borrow::Cow;
10161 use std::io::{Read, Seek};
10162
10163 use common::{url::Params, ToParts};
10164 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10165
10166 let mut dd = common::DefaultDelegate;
10167 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10168 dlg.begin(common::MethodInfo {
10169 id: "vmmigration.projects.locations.sources.datacenterConnectors.create",
10170 http_method: hyper::Method::POST,
10171 });
10172
10173 for &field in ["alt", "parent", "requestId", "datacenterConnectorId"].iter() {
10174 if self._additional_params.contains_key(field) {
10175 dlg.finished(false);
10176 return Err(common::Error::FieldClash(field));
10177 }
10178 }
10179
10180 let mut params = Params::with_capacity(6 + self._additional_params.len());
10181 params.push("parent", self._parent);
10182 if let Some(value) = self._request_id.as_ref() {
10183 params.push("requestId", value);
10184 }
10185 if let Some(value) = self._datacenter_connector_id.as_ref() {
10186 params.push("datacenterConnectorId", value);
10187 }
10188
10189 params.extend(self._additional_params.iter());
10190
10191 params.push("alt", "json");
10192 let mut url = self.hub._base_url.clone() + "v1/{+parent}/datacenterConnectors";
10193 if self._scopes.is_empty() {
10194 self._scopes
10195 .insert(Scope::CloudPlatform.as_ref().to_string());
10196 }
10197
10198 #[allow(clippy::single_element_loop)]
10199 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10200 url = params.uri_replacement(url, param_name, find_this, true);
10201 }
10202 {
10203 let to_remove = ["parent"];
10204 params.remove_params(&to_remove);
10205 }
10206
10207 let url = params.parse_with_url(&url);
10208
10209 let mut json_mime_type = mime::APPLICATION_JSON;
10210 let mut request_value_reader = {
10211 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10212 common::remove_json_null_values(&mut value);
10213 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10214 serde_json::to_writer(&mut dst, &value).unwrap();
10215 dst
10216 };
10217 let request_size = request_value_reader
10218 .seek(std::io::SeekFrom::End(0))
10219 .unwrap();
10220 request_value_reader
10221 .seek(std::io::SeekFrom::Start(0))
10222 .unwrap();
10223
10224 loop {
10225 let token = match self
10226 .hub
10227 .auth
10228 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10229 .await
10230 {
10231 Ok(token) => token,
10232 Err(e) => match dlg.token(e) {
10233 Ok(token) => token,
10234 Err(e) => {
10235 dlg.finished(false);
10236 return Err(common::Error::MissingToken(e));
10237 }
10238 },
10239 };
10240 request_value_reader
10241 .seek(std::io::SeekFrom::Start(0))
10242 .unwrap();
10243 let mut req_result = {
10244 let client = &self.hub.client;
10245 dlg.pre_request();
10246 let mut req_builder = hyper::Request::builder()
10247 .method(hyper::Method::POST)
10248 .uri(url.as_str())
10249 .header(USER_AGENT, self.hub._user_agent.clone());
10250
10251 if let Some(token) = token.as_ref() {
10252 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10253 }
10254
10255 let request = req_builder
10256 .header(CONTENT_TYPE, json_mime_type.to_string())
10257 .header(CONTENT_LENGTH, request_size as u64)
10258 .body(common::to_body(
10259 request_value_reader.get_ref().clone().into(),
10260 ));
10261
10262 client.request(request.unwrap()).await
10263 };
10264
10265 match req_result {
10266 Err(err) => {
10267 if let common::Retry::After(d) = dlg.http_error(&err) {
10268 sleep(d).await;
10269 continue;
10270 }
10271 dlg.finished(false);
10272 return Err(common::Error::HttpError(err));
10273 }
10274 Ok(res) => {
10275 let (mut parts, body) = res.into_parts();
10276 let mut body = common::Body::new(body);
10277 if !parts.status.is_success() {
10278 let bytes = common::to_bytes(body).await.unwrap_or_default();
10279 let error = serde_json::from_str(&common::to_string(&bytes));
10280 let response = common::to_response(parts, bytes.into());
10281
10282 if let common::Retry::After(d) =
10283 dlg.http_failure(&response, error.as_ref().ok())
10284 {
10285 sleep(d).await;
10286 continue;
10287 }
10288
10289 dlg.finished(false);
10290
10291 return Err(match error {
10292 Ok(value) => common::Error::BadRequest(value),
10293 _ => common::Error::Failure(response),
10294 });
10295 }
10296 let response = {
10297 let bytes = common::to_bytes(body).await.unwrap_or_default();
10298 let encoded = common::to_string(&bytes);
10299 match serde_json::from_str(&encoded) {
10300 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10301 Err(error) => {
10302 dlg.response_json_decode_error(&encoded, &error);
10303 return Err(common::Error::JsonDecodeError(
10304 encoded.to_string(),
10305 error,
10306 ));
10307 }
10308 }
10309 };
10310
10311 dlg.finished(true);
10312 return Ok(response);
10313 }
10314 }
10315 }
10316 }
10317
10318 ///
10319 /// Sets the *request* property to the given value.
10320 ///
10321 /// Even though the property as already been set when instantiating this call,
10322 /// we provide this method for API completeness.
10323 pub fn request(
10324 mut self,
10325 new_value: DatacenterConnector,
10326 ) -> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C> {
10327 self._request = new_value;
10328 self
10329 }
10330 /// Required. The DatacenterConnector's parent. Required. The Source in where the new DatacenterConnector will be created. For example: `projects/my-project/locations/us-central1/sources/my-source`
10331 ///
10332 /// Sets the *parent* path property to the given value.
10333 ///
10334 /// Even though the property as already been set when instantiating this call,
10335 /// we provide this method for API completeness.
10336 pub fn parent(
10337 mut self,
10338 new_value: &str,
10339 ) -> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C> {
10340 self._parent = new_value.to_string();
10341 self
10342 }
10343 /// A request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes since the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
10344 ///
10345 /// Sets the *request id* query property to the given value.
10346 pub fn request_id(
10347 mut self,
10348 new_value: &str,
10349 ) -> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C> {
10350 self._request_id = Some(new_value.to_string());
10351 self
10352 }
10353 /// Required. The datacenterConnector identifier.
10354 ///
10355 /// Sets the *datacenter connector id* query property to the given value.
10356 pub fn datacenter_connector_id(
10357 mut self,
10358 new_value: &str,
10359 ) -> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C> {
10360 self._datacenter_connector_id = Some(new_value.to_string());
10361 self
10362 }
10363 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10364 /// while executing the actual API request.
10365 ///
10366 /// ````text
10367 /// It should be used to handle progress information, and to implement a certain level of resilience.
10368 /// ````
10369 ///
10370 /// Sets the *delegate* property to the given value.
10371 pub fn delegate(
10372 mut self,
10373 new_value: &'a mut dyn common::Delegate,
10374 ) -> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C> {
10375 self._delegate = Some(new_value);
10376 self
10377 }
10378
10379 /// Set any additional parameter of the query string used in the request.
10380 /// It should be used to set parameters which are not yet available through their own
10381 /// setters.
10382 ///
10383 /// Please note that this method must not be used to set any of the known parameters
10384 /// which have their own setter method. If done anyway, the request will fail.
10385 ///
10386 /// # Additional Parameters
10387 ///
10388 /// * *$.xgafv* (query-string) - V1 error format.
10389 /// * *access_token* (query-string) - OAuth access token.
10390 /// * *alt* (query-string) - Data format for response.
10391 /// * *callback* (query-string) - JSONP
10392 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10393 /// * *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.
10394 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10395 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10396 /// * *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.
10397 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10398 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10399 pub fn param<T>(
10400 mut self,
10401 name: T,
10402 value: T,
10403 ) -> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C>
10404 where
10405 T: AsRef<str>,
10406 {
10407 self._additional_params
10408 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10409 self
10410 }
10411
10412 /// Identifies the authorization scope for the method you are building.
10413 ///
10414 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10415 /// [`Scope::CloudPlatform`].
10416 ///
10417 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10418 /// tokens for more than one scope.
10419 ///
10420 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10421 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10422 /// sufficient, a read-write scope will do as well.
10423 pub fn add_scope<St>(
10424 mut self,
10425 scope: St,
10426 ) -> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C>
10427 where
10428 St: AsRef<str>,
10429 {
10430 self._scopes.insert(String::from(scope.as_ref()));
10431 self
10432 }
10433 /// Identifies the authorization scope(s) for the method you are building.
10434 ///
10435 /// See [`Self::add_scope()`] for details.
10436 pub fn add_scopes<I, St>(
10437 mut self,
10438 scopes: I,
10439 ) -> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C>
10440 where
10441 I: IntoIterator<Item = St>,
10442 St: AsRef<str>,
10443 {
10444 self._scopes
10445 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10446 self
10447 }
10448
10449 /// Removes all scopes, and no default scope will be used either.
10450 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10451 /// for details).
10452 pub fn clear_scopes(mut self) -> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C> {
10453 self._scopes.clear();
10454 self
10455 }
10456}
10457
10458/// Deletes a single DatacenterConnector.
10459///
10460/// A builder for the *locations.sources.datacenterConnectors.delete* method supported by a *project* resource.
10461/// It is not used directly, but through a [`ProjectMethods`] instance.
10462///
10463/// # Example
10464///
10465/// Instantiate a resource method builder
10466///
10467/// ```test_harness,no_run
10468/// # extern crate hyper;
10469/// # extern crate hyper_rustls;
10470/// # extern crate google_vmmigration1 as vmmigration1;
10471/// # async fn dox() {
10472/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10473///
10474/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10475/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10476/// # secret,
10477/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10478/// # ).build().await.unwrap();
10479///
10480/// # let client = hyper_util::client::legacy::Client::builder(
10481/// # hyper_util::rt::TokioExecutor::new()
10482/// # )
10483/// # .build(
10484/// # hyper_rustls::HttpsConnectorBuilder::new()
10485/// # .with_native_roots()
10486/// # .unwrap()
10487/// # .https_or_http()
10488/// # .enable_http1()
10489/// # .build()
10490/// # );
10491/// # let mut hub = VMMigrationService::new(client, auth);
10492/// // You can configure optional parameters by calling the respective setters at will, and
10493/// // execute the final call using `doit()`.
10494/// // Values shown here are possibly random and not representative !
10495/// let result = hub.projects().locations_sources_datacenter_connectors_delete("name")
10496/// .request_id("et")
10497/// .doit().await;
10498/// # }
10499/// ```
10500pub struct ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C>
10501where
10502 C: 'a,
10503{
10504 hub: &'a VMMigrationService<C>,
10505 _name: String,
10506 _request_id: Option<String>,
10507 _delegate: Option<&'a mut dyn common::Delegate>,
10508 _additional_params: HashMap<String, String>,
10509 _scopes: BTreeSet<String>,
10510}
10511
10512impl<'a, C> common::CallBuilder for ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C> {}
10513
10514impl<'a, C> ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C>
10515where
10516 C: common::Connector,
10517{
10518 /// Perform the operation you have build so far.
10519 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10520 use std::borrow::Cow;
10521 use std::io::{Read, Seek};
10522
10523 use common::{url::Params, ToParts};
10524 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10525
10526 let mut dd = common::DefaultDelegate;
10527 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10528 dlg.begin(common::MethodInfo {
10529 id: "vmmigration.projects.locations.sources.datacenterConnectors.delete",
10530 http_method: hyper::Method::DELETE,
10531 });
10532
10533 for &field in ["alt", "name", "requestId"].iter() {
10534 if self._additional_params.contains_key(field) {
10535 dlg.finished(false);
10536 return Err(common::Error::FieldClash(field));
10537 }
10538 }
10539
10540 let mut params = Params::with_capacity(4 + self._additional_params.len());
10541 params.push("name", self._name);
10542 if let Some(value) = self._request_id.as_ref() {
10543 params.push("requestId", value);
10544 }
10545
10546 params.extend(self._additional_params.iter());
10547
10548 params.push("alt", "json");
10549 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10550 if self._scopes.is_empty() {
10551 self._scopes
10552 .insert(Scope::CloudPlatform.as_ref().to_string());
10553 }
10554
10555 #[allow(clippy::single_element_loop)]
10556 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10557 url = params.uri_replacement(url, param_name, find_this, true);
10558 }
10559 {
10560 let to_remove = ["name"];
10561 params.remove_params(&to_remove);
10562 }
10563
10564 let url = params.parse_with_url(&url);
10565
10566 loop {
10567 let token = match self
10568 .hub
10569 .auth
10570 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10571 .await
10572 {
10573 Ok(token) => token,
10574 Err(e) => match dlg.token(e) {
10575 Ok(token) => token,
10576 Err(e) => {
10577 dlg.finished(false);
10578 return Err(common::Error::MissingToken(e));
10579 }
10580 },
10581 };
10582 let mut req_result = {
10583 let client = &self.hub.client;
10584 dlg.pre_request();
10585 let mut req_builder = hyper::Request::builder()
10586 .method(hyper::Method::DELETE)
10587 .uri(url.as_str())
10588 .header(USER_AGENT, self.hub._user_agent.clone());
10589
10590 if let Some(token) = token.as_ref() {
10591 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10592 }
10593
10594 let request = req_builder
10595 .header(CONTENT_LENGTH, 0_u64)
10596 .body(common::to_body::<String>(None));
10597
10598 client.request(request.unwrap()).await
10599 };
10600
10601 match req_result {
10602 Err(err) => {
10603 if let common::Retry::After(d) = dlg.http_error(&err) {
10604 sleep(d).await;
10605 continue;
10606 }
10607 dlg.finished(false);
10608 return Err(common::Error::HttpError(err));
10609 }
10610 Ok(res) => {
10611 let (mut parts, body) = res.into_parts();
10612 let mut body = common::Body::new(body);
10613 if !parts.status.is_success() {
10614 let bytes = common::to_bytes(body).await.unwrap_or_default();
10615 let error = serde_json::from_str(&common::to_string(&bytes));
10616 let response = common::to_response(parts, bytes.into());
10617
10618 if let common::Retry::After(d) =
10619 dlg.http_failure(&response, error.as_ref().ok())
10620 {
10621 sleep(d).await;
10622 continue;
10623 }
10624
10625 dlg.finished(false);
10626
10627 return Err(match error {
10628 Ok(value) => common::Error::BadRequest(value),
10629 _ => common::Error::Failure(response),
10630 });
10631 }
10632 let response = {
10633 let bytes = common::to_bytes(body).await.unwrap_or_default();
10634 let encoded = common::to_string(&bytes);
10635 match serde_json::from_str(&encoded) {
10636 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10637 Err(error) => {
10638 dlg.response_json_decode_error(&encoded, &error);
10639 return Err(common::Error::JsonDecodeError(
10640 encoded.to_string(),
10641 error,
10642 ));
10643 }
10644 }
10645 };
10646
10647 dlg.finished(true);
10648 return Ok(response);
10649 }
10650 }
10651 }
10652 }
10653
10654 /// Required. The DatacenterConnector name.
10655 ///
10656 /// Sets the *name* path property to the given value.
10657 ///
10658 /// Even though the property as already been set when instantiating this call,
10659 /// we provide this method for API completeness.
10660 pub fn name(
10661 mut self,
10662 new_value: &str,
10663 ) -> ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C> {
10664 self._name = new_value.to_string();
10665 self
10666 }
10667 /// A request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes after the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
10668 ///
10669 /// Sets the *request id* query property to the given value.
10670 pub fn request_id(
10671 mut self,
10672 new_value: &str,
10673 ) -> ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C> {
10674 self._request_id = Some(new_value.to_string());
10675 self
10676 }
10677 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10678 /// while executing the actual API request.
10679 ///
10680 /// ````text
10681 /// It should be used to handle progress information, and to implement a certain level of resilience.
10682 /// ````
10683 ///
10684 /// Sets the *delegate* property to the given value.
10685 pub fn delegate(
10686 mut self,
10687 new_value: &'a mut dyn common::Delegate,
10688 ) -> ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C> {
10689 self._delegate = Some(new_value);
10690 self
10691 }
10692
10693 /// Set any additional parameter of the query string used in the request.
10694 /// It should be used to set parameters which are not yet available through their own
10695 /// setters.
10696 ///
10697 /// Please note that this method must not be used to set any of the known parameters
10698 /// which have their own setter method. If done anyway, the request will fail.
10699 ///
10700 /// # Additional Parameters
10701 ///
10702 /// * *$.xgafv* (query-string) - V1 error format.
10703 /// * *access_token* (query-string) - OAuth access token.
10704 /// * *alt* (query-string) - Data format for response.
10705 /// * *callback* (query-string) - JSONP
10706 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10707 /// * *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.
10708 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10709 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10710 /// * *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.
10711 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10712 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10713 pub fn param<T>(
10714 mut self,
10715 name: T,
10716 value: T,
10717 ) -> ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C>
10718 where
10719 T: AsRef<str>,
10720 {
10721 self._additional_params
10722 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10723 self
10724 }
10725
10726 /// Identifies the authorization scope for the method you are building.
10727 ///
10728 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10729 /// [`Scope::CloudPlatform`].
10730 ///
10731 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10732 /// tokens for more than one scope.
10733 ///
10734 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10735 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10736 /// sufficient, a read-write scope will do as well.
10737 pub fn add_scope<St>(
10738 mut self,
10739 scope: St,
10740 ) -> ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C>
10741 where
10742 St: AsRef<str>,
10743 {
10744 self._scopes.insert(String::from(scope.as_ref()));
10745 self
10746 }
10747 /// Identifies the authorization scope(s) for the method you are building.
10748 ///
10749 /// See [`Self::add_scope()`] for details.
10750 pub fn add_scopes<I, St>(
10751 mut self,
10752 scopes: I,
10753 ) -> ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C>
10754 where
10755 I: IntoIterator<Item = St>,
10756 St: AsRef<str>,
10757 {
10758 self._scopes
10759 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10760 self
10761 }
10762
10763 /// Removes all scopes, and no default scope will be used either.
10764 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10765 /// for details).
10766 pub fn clear_scopes(mut self) -> ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C> {
10767 self._scopes.clear();
10768 self
10769 }
10770}
10771
10772/// Gets details of a single DatacenterConnector.
10773///
10774/// A builder for the *locations.sources.datacenterConnectors.get* method supported by a *project* resource.
10775/// It is not used directly, but through a [`ProjectMethods`] instance.
10776///
10777/// # Example
10778///
10779/// Instantiate a resource method builder
10780///
10781/// ```test_harness,no_run
10782/// # extern crate hyper;
10783/// # extern crate hyper_rustls;
10784/// # extern crate google_vmmigration1 as vmmigration1;
10785/// # async fn dox() {
10786/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10787///
10788/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10789/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10790/// # secret,
10791/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10792/// # ).build().await.unwrap();
10793///
10794/// # let client = hyper_util::client::legacy::Client::builder(
10795/// # hyper_util::rt::TokioExecutor::new()
10796/// # )
10797/// # .build(
10798/// # hyper_rustls::HttpsConnectorBuilder::new()
10799/// # .with_native_roots()
10800/// # .unwrap()
10801/// # .https_or_http()
10802/// # .enable_http1()
10803/// # .build()
10804/// # );
10805/// # let mut hub = VMMigrationService::new(client, auth);
10806/// // You can configure optional parameters by calling the respective setters at will, and
10807/// // execute the final call using `doit()`.
10808/// // Values shown here are possibly random and not representative !
10809/// let result = hub.projects().locations_sources_datacenter_connectors_get("name")
10810/// .doit().await;
10811/// # }
10812/// ```
10813pub struct ProjectLocationSourceDatacenterConnectorGetCall<'a, C>
10814where
10815 C: 'a,
10816{
10817 hub: &'a VMMigrationService<C>,
10818 _name: String,
10819 _delegate: Option<&'a mut dyn common::Delegate>,
10820 _additional_params: HashMap<String, String>,
10821 _scopes: BTreeSet<String>,
10822}
10823
10824impl<'a, C> common::CallBuilder for ProjectLocationSourceDatacenterConnectorGetCall<'a, C> {}
10825
10826impl<'a, C> ProjectLocationSourceDatacenterConnectorGetCall<'a, C>
10827where
10828 C: common::Connector,
10829{
10830 /// Perform the operation you have build so far.
10831 pub async fn doit(mut self) -> common::Result<(common::Response, DatacenterConnector)> {
10832 use std::borrow::Cow;
10833 use std::io::{Read, Seek};
10834
10835 use common::{url::Params, ToParts};
10836 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10837
10838 let mut dd = common::DefaultDelegate;
10839 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10840 dlg.begin(common::MethodInfo {
10841 id: "vmmigration.projects.locations.sources.datacenterConnectors.get",
10842 http_method: hyper::Method::GET,
10843 });
10844
10845 for &field in ["alt", "name"].iter() {
10846 if self._additional_params.contains_key(field) {
10847 dlg.finished(false);
10848 return Err(common::Error::FieldClash(field));
10849 }
10850 }
10851
10852 let mut params = Params::with_capacity(3 + self._additional_params.len());
10853 params.push("name", self._name);
10854
10855 params.extend(self._additional_params.iter());
10856
10857 params.push("alt", "json");
10858 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10859 if self._scopes.is_empty() {
10860 self._scopes
10861 .insert(Scope::CloudPlatform.as_ref().to_string());
10862 }
10863
10864 #[allow(clippy::single_element_loop)]
10865 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10866 url = params.uri_replacement(url, param_name, find_this, true);
10867 }
10868 {
10869 let to_remove = ["name"];
10870 params.remove_params(&to_remove);
10871 }
10872
10873 let url = params.parse_with_url(&url);
10874
10875 loop {
10876 let token = match self
10877 .hub
10878 .auth
10879 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10880 .await
10881 {
10882 Ok(token) => token,
10883 Err(e) => match dlg.token(e) {
10884 Ok(token) => token,
10885 Err(e) => {
10886 dlg.finished(false);
10887 return Err(common::Error::MissingToken(e));
10888 }
10889 },
10890 };
10891 let mut req_result = {
10892 let client = &self.hub.client;
10893 dlg.pre_request();
10894 let mut req_builder = hyper::Request::builder()
10895 .method(hyper::Method::GET)
10896 .uri(url.as_str())
10897 .header(USER_AGENT, self.hub._user_agent.clone());
10898
10899 if let Some(token) = token.as_ref() {
10900 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10901 }
10902
10903 let request = req_builder
10904 .header(CONTENT_LENGTH, 0_u64)
10905 .body(common::to_body::<String>(None));
10906
10907 client.request(request.unwrap()).await
10908 };
10909
10910 match req_result {
10911 Err(err) => {
10912 if let common::Retry::After(d) = dlg.http_error(&err) {
10913 sleep(d).await;
10914 continue;
10915 }
10916 dlg.finished(false);
10917 return Err(common::Error::HttpError(err));
10918 }
10919 Ok(res) => {
10920 let (mut parts, body) = res.into_parts();
10921 let mut body = common::Body::new(body);
10922 if !parts.status.is_success() {
10923 let bytes = common::to_bytes(body).await.unwrap_or_default();
10924 let error = serde_json::from_str(&common::to_string(&bytes));
10925 let response = common::to_response(parts, bytes.into());
10926
10927 if let common::Retry::After(d) =
10928 dlg.http_failure(&response, error.as_ref().ok())
10929 {
10930 sleep(d).await;
10931 continue;
10932 }
10933
10934 dlg.finished(false);
10935
10936 return Err(match error {
10937 Ok(value) => common::Error::BadRequest(value),
10938 _ => common::Error::Failure(response),
10939 });
10940 }
10941 let response = {
10942 let bytes = common::to_bytes(body).await.unwrap_or_default();
10943 let encoded = common::to_string(&bytes);
10944 match serde_json::from_str(&encoded) {
10945 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10946 Err(error) => {
10947 dlg.response_json_decode_error(&encoded, &error);
10948 return Err(common::Error::JsonDecodeError(
10949 encoded.to_string(),
10950 error,
10951 ));
10952 }
10953 }
10954 };
10955
10956 dlg.finished(true);
10957 return Ok(response);
10958 }
10959 }
10960 }
10961 }
10962
10963 /// Required. The name of the DatacenterConnector.
10964 ///
10965 /// Sets the *name* path property to the given value.
10966 ///
10967 /// Even though the property as already been set when instantiating this call,
10968 /// we provide this method for API completeness.
10969 pub fn name(
10970 mut self,
10971 new_value: &str,
10972 ) -> ProjectLocationSourceDatacenterConnectorGetCall<'a, C> {
10973 self._name = new_value.to_string();
10974 self
10975 }
10976 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10977 /// while executing the actual API request.
10978 ///
10979 /// ````text
10980 /// It should be used to handle progress information, and to implement a certain level of resilience.
10981 /// ````
10982 ///
10983 /// Sets the *delegate* property to the given value.
10984 pub fn delegate(
10985 mut self,
10986 new_value: &'a mut dyn common::Delegate,
10987 ) -> ProjectLocationSourceDatacenterConnectorGetCall<'a, C> {
10988 self._delegate = Some(new_value);
10989 self
10990 }
10991
10992 /// Set any additional parameter of the query string used in the request.
10993 /// It should be used to set parameters which are not yet available through their own
10994 /// setters.
10995 ///
10996 /// Please note that this method must not be used to set any of the known parameters
10997 /// which have their own setter method. If done anyway, the request will fail.
10998 ///
10999 /// # Additional Parameters
11000 ///
11001 /// * *$.xgafv* (query-string) - V1 error format.
11002 /// * *access_token* (query-string) - OAuth access token.
11003 /// * *alt* (query-string) - Data format for response.
11004 /// * *callback* (query-string) - JSONP
11005 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11006 /// * *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.
11007 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11008 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11009 /// * *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.
11010 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11011 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11012 pub fn param<T>(
11013 mut self,
11014 name: T,
11015 value: T,
11016 ) -> ProjectLocationSourceDatacenterConnectorGetCall<'a, C>
11017 where
11018 T: AsRef<str>,
11019 {
11020 self._additional_params
11021 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11022 self
11023 }
11024
11025 /// Identifies the authorization scope for the method you are building.
11026 ///
11027 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11028 /// [`Scope::CloudPlatform`].
11029 ///
11030 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11031 /// tokens for more than one scope.
11032 ///
11033 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11034 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11035 /// sufficient, a read-write scope will do as well.
11036 pub fn add_scope<St>(
11037 mut self,
11038 scope: St,
11039 ) -> ProjectLocationSourceDatacenterConnectorGetCall<'a, C>
11040 where
11041 St: AsRef<str>,
11042 {
11043 self._scopes.insert(String::from(scope.as_ref()));
11044 self
11045 }
11046 /// Identifies the authorization scope(s) for the method you are building.
11047 ///
11048 /// See [`Self::add_scope()`] for details.
11049 pub fn add_scopes<I, St>(
11050 mut self,
11051 scopes: I,
11052 ) -> ProjectLocationSourceDatacenterConnectorGetCall<'a, C>
11053 where
11054 I: IntoIterator<Item = St>,
11055 St: AsRef<str>,
11056 {
11057 self._scopes
11058 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11059 self
11060 }
11061
11062 /// Removes all scopes, and no default scope will be used either.
11063 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11064 /// for details).
11065 pub fn clear_scopes(mut self) -> ProjectLocationSourceDatacenterConnectorGetCall<'a, C> {
11066 self._scopes.clear();
11067 self
11068 }
11069}
11070
11071/// Lists DatacenterConnectors in a given Source.
11072///
11073/// A builder for the *locations.sources.datacenterConnectors.list* method supported by a *project* resource.
11074/// It is not used directly, but through a [`ProjectMethods`] instance.
11075///
11076/// # Example
11077///
11078/// Instantiate a resource method builder
11079///
11080/// ```test_harness,no_run
11081/// # extern crate hyper;
11082/// # extern crate hyper_rustls;
11083/// # extern crate google_vmmigration1 as vmmigration1;
11084/// # async fn dox() {
11085/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11086///
11087/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11088/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11089/// # secret,
11090/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11091/// # ).build().await.unwrap();
11092///
11093/// # let client = hyper_util::client::legacy::Client::builder(
11094/// # hyper_util::rt::TokioExecutor::new()
11095/// # )
11096/// # .build(
11097/// # hyper_rustls::HttpsConnectorBuilder::new()
11098/// # .with_native_roots()
11099/// # .unwrap()
11100/// # .https_or_http()
11101/// # .enable_http1()
11102/// # .build()
11103/// # );
11104/// # let mut hub = VMMigrationService::new(client, auth);
11105/// // You can configure optional parameters by calling the respective setters at will, and
11106/// // execute the final call using `doit()`.
11107/// // Values shown here are possibly random and not representative !
11108/// let result = hub.projects().locations_sources_datacenter_connectors_list("parent")
11109/// .page_token("consetetur")
11110/// .page_size(-92)
11111/// .order_by("dolor")
11112/// .filter("et")
11113/// .doit().await;
11114/// # }
11115/// ```
11116pub struct ProjectLocationSourceDatacenterConnectorListCall<'a, C>
11117where
11118 C: 'a,
11119{
11120 hub: &'a VMMigrationService<C>,
11121 _parent: String,
11122 _page_token: Option<String>,
11123 _page_size: Option<i32>,
11124 _order_by: Option<String>,
11125 _filter: Option<String>,
11126 _delegate: Option<&'a mut dyn common::Delegate>,
11127 _additional_params: HashMap<String, String>,
11128 _scopes: BTreeSet<String>,
11129}
11130
11131impl<'a, C> common::CallBuilder for ProjectLocationSourceDatacenterConnectorListCall<'a, C> {}
11132
11133impl<'a, C> ProjectLocationSourceDatacenterConnectorListCall<'a, C>
11134where
11135 C: common::Connector,
11136{
11137 /// Perform the operation you have build so far.
11138 pub async fn doit(
11139 mut self,
11140 ) -> common::Result<(common::Response, ListDatacenterConnectorsResponse)> {
11141 use std::borrow::Cow;
11142 use std::io::{Read, Seek};
11143
11144 use common::{url::Params, ToParts};
11145 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11146
11147 let mut dd = common::DefaultDelegate;
11148 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11149 dlg.begin(common::MethodInfo {
11150 id: "vmmigration.projects.locations.sources.datacenterConnectors.list",
11151 http_method: hyper::Method::GET,
11152 });
11153
11154 for &field in [
11155 "alt",
11156 "parent",
11157 "pageToken",
11158 "pageSize",
11159 "orderBy",
11160 "filter",
11161 ]
11162 .iter()
11163 {
11164 if self._additional_params.contains_key(field) {
11165 dlg.finished(false);
11166 return Err(common::Error::FieldClash(field));
11167 }
11168 }
11169
11170 let mut params = Params::with_capacity(7 + self._additional_params.len());
11171 params.push("parent", self._parent);
11172 if let Some(value) = self._page_token.as_ref() {
11173 params.push("pageToken", value);
11174 }
11175 if let Some(value) = self._page_size.as_ref() {
11176 params.push("pageSize", value.to_string());
11177 }
11178 if let Some(value) = self._order_by.as_ref() {
11179 params.push("orderBy", value);
11180 }
11181 if let Some(value) = self._filter.as_ref() {
11182 params.push("filter", value);
11183 }
11184
11185 params.extend(self._additional_params.iter());
11186
11187 params.push("alt", "json");
11188 let mut url = self.hub._base_url.clone() + "v1/{+parent}/datacenterConnectors";
11189 if self._scopes.is_empty() {
11190 self._scopes
11191 .insert(Scope::CloudPlatform.as_ref().to_string());
11192 }
11193
11194 #[allow(clippy::single_element_loop)]
11195 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11196 url = params.uri_replacement(url, param_name, find_this, true);
11197 }
11198 {
11199 let to_remove = ["parent"];
11200 params.remove_params(&to_remove);
11201 }
11202
11203 let url = params.parse_with_url(&url);
11204
11205 loop {
11206 let token = match self
11207 .hub
11208 .auth
11209 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11210 .await
11211 {
11212 Ok(token) => token,
11213 Err(e) => match dlg.token(e) {
11214 Ok(token) => token,
11215 Err(e) => {
11216 dlg.finished(false);
11217 return Err(common::Error::MissingToken(e));
11218 }
11219 },
11220 };
11221 let mut req_result = {
11222 let client = &self.hub.client;
11223 dlg.pre_request();
11224 let mut req_builder = hyper::Request::builder()
11225 .method(hyper::Method::GET)
11226 .uri(url.as_str())
11227 .header(USER_AGENT, self.hub._user_agent.clone());
11228
11229 if let Some(token) = token.as_ref() {
11230 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11231 }
11232
11233 let request = req_builder
11234 .header(CONTENT_LENGTH, 0_u64)
11235 .body(common::to_body::<String>(None));
11236
11237 client.request(request.unwrap()).await
11238 };
11239
11240 match req_result {
11241 Err(err) => {
11242 if let common::Retry::After(d) = dlg.http_error(&err) {
11243 sleep(d).await;
11244 continue;
11245 }
11246 dlg.finished(false);
11247 return Err(common::Error::HttpError(err));
11248 }
11249 Ok(res) => {
11250 let (mut parts, body) = res.into_parts();
11251 let mut body = common::Body::new(body);
11252 if !parts.status.is_success() {
11253 let bytes = common::to_bytes(body).await.unwrap_or_default();
11254 let error = serde_json::from_str(&common::to_string(&bytes));
11255 let response = common::to_response(parts, bytes.into());
11256
11257 if let common::Retry::After(d) =
11258 dlg.http_failure(&response, error.as_ref().ok())
11259 {
11260 sleep(d).await;
11261 continue;
11262 }
11263
11264 dlg.finished(false);
11265
11266 return Err(match error {
11267 Ok(value) => common::Error::BadRequest(value),
11268 _ => common::Error::Failure(response),
11269 });
11270 }
11271 let response = {
11272 let bytes = common::to_bytes(body).await.unwrap_or_default();
11273 let encoded = common::to_string(&bytes);
11274 match serde_json::from_str(&encoded) {
11275 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11276 Err(error) => {
11277 dlg.response_json_decode_error(&encoded, &error);
11278 return Err(common::Error::JsonDecodeError(
11279 encoded.to_string(),
11280 error,
11281 ));
11282 }
11283 }
11284 };
11285
11286 dlg.finished(true);
11287 return Ok(response);
11288 }
11289 }
11290 }
11291 }
11292
11293 /// Required. The parent, which owns this collection of connectors.
11294 ///
11295 /// Sets the *parent* path property to the given value.
11296 ///
11297 /// Even though the property as already been set when instantiating this call,
11298 /// we provide this method for API completeness.
11299 pub fn parent(
11300 mut self,
11301 new_value: &str,
11302 ) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C> {
11303 self._parent = new_value.to_string();
11304 self
11305 }
11306 /// Required. A page token, received from a previous `ListDatacenterConnectors` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListDatacenterConnectors` must match the call that provided the page token.
11307 ///
11308 /// Sets the *page token* query property to the given value.
11309 pub fn page_token(
11310 mut self,
11311 new_value: &str,
11312 ) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C> {
11313 self._page_token = Some(new_value.to_string());
11314 self
11315 }
11316 /// Optional. The maximum number of connectors to return. The service may return fewer than this value. If unspecified, at most 500 sources will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
11317 ///
11318 /// Sets the *page size* query property to the given value.
11319 pub fn page_size(
11320 mut self,
11321 new_value: i32,
11322 ) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C> {
11323 self._page_size = Some(new_value);
11324 self
11325 }
11326 /// Optional. the order by fields for the result.
11327 ///
11328 /// Sets the *order by* query property to the given value.
11329 pub fn order_by(
11330 mut self,
11331 new_value: &str,
11332 ) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C> {
11333 self._order_by = Some(new_value.to_string());
11334 self
11335 }
11336 /// Optional. The filter request.
11337 ///
11338 /// Sets the *filter* query property to the given value.
11339 pub fn filter(
11340 mut self,
11341 new_value: &str,
11342 ) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C> {
11343 self._filter = Some(new_value.to_string());
11344 self
11345 }
11346 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11347 /// while executing the actual API request.
11348 ///
11349 /// ````text
11350 /// It should be used to handle progress information, and to implement a certain level of resilience.
11351 /// ````
11352 ///
11353 /// Sets the *delegate* property to the given value.
11354 pub fn delegate(
11355 mut self,
11356 new_value: &'a mut dyn common::Delegate,
11357 ) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C> {
11358 self._delegate = Some(new_value);
11359 self
11360 }
11361
11362 /// Set any additional parameter of the query string used in the request.
11363 /// It should be used to set parameters which are not yet available through their own
11364 /// setters.
11365 ///
11366 /// Please note that this method must not be used to set any of the known parameters
11367 /// which have their own setter method. If done anyway, the request will fail.
11368 ///
11369 /// # Additional Parameters
11370 ///
11371 /// * *$.xgafv* (query-string) - V1 error format.
11372 /// * *access_token* (query-string) - OAuth access token.
11373 /// * *alt* (query-string) - Data format for response.
11374 /// * *callback* (query-string) - JSONP
11375 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11376 /// * *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.
11377 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11378 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11379 /// * *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.
11380 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11381 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11382 pub fn param<T>(
11383 mut self,
11384 name: T,
11385 value: T,
11386 ) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C>
11387 where
11388 T: AsRef<str>,
11389 {
11390 self._additional_params
11391 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11392 self
11393 }
11394
11395 /// Identifies the authorization scope for the method you are building.
11396 ///
11397 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11398 /// [`Scope::CloudPlatform`].
11399 ///
11400 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11401 /// tokens for more than one scope.
11402 ///
11403 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11404 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11405 /// sufficient, a read-write scope will do as well.
11406 pub fn add_scope<St>(
11407 mut self,
11408 scope: St,
11409 ) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C>
11410 where
11411 St: AsRef<str>,
11412 {
11413 self._scopes.insert(String::from(scope.as_ref()));
11414 self
11415 }
11416 /// Identifies the authorization scope(s) for the method you are building.
11417 ///
11418 /// See [`Self::add_scope()`] for details.
11419 pub fn add_scopes<I, St>(
11420 mut self,
11421 scopes: I,
11422 ) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C>
11423 where
11424 I: IntoIterator<Item = St>,
11425 St: AsRef<str>,
11426 {
11427 self._scopes
11428 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11429 self
11430 }
11431
11432 /// Removes all scopes, and no default scope will be used either.
11433 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11434 /// for details).
11435 pub fn clear_scopes(mut self) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C> {
11436 self._scopes.clear();
11437 self
11438 }
11439}
11440
11441/// Upgrades the appliance relate to this DatacenterConnector to the in-place updateable version.
11442///
11443/// A builder for the *locations.sources.datacenterConnectors.upgradeAppliance* method supported by a *project* resource.
11444/// It is not used directly, but through a [`ProjectMethods`] instance.
11445///
11446/// # Example
11447///
11448/// Instantiate a resource method builder
11449///
11450/// ```test_harness,no_run
11451/// # extern crate hyper;
11452/// # extern crate hyper_rustls;
11453/// # extern crate google_vmmigration1 as vmmigration1;
11454/// use vmmigration1::api::UpgradeApplianceRequest;
11455/// # async fn dox() {
11456/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11457///
11458/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11459/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11460/// # secret,
11461/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11462/// # ).build().await.unwrap();
11463///
11464/// # let client = hyper_util::client::legacy::Client::builder(
11465/// # hyper_util::rt::TokioExecutor::new()
11466/// # )
11467/// # .build(
11468/// # hyper_rustls::HttpsConnectorBuilder::new()
11469/// # .with_native_roots()
11470/// # .unwrap()
11471/// # .https_or_http()
11472/// # .enable_http1()
11473/// # .build()
11474/// # );
11475/// # let mut hub = VMMigrationService::new(client, auth);
11476/// // As the method needs a request, you would usually fill it with the desired information
11477/// // into the respective structure. Some of the parts shown here might not be applicable !
11478/// // Values shown here are possibly random and not representative !
11479/// let mut req = UpgradeApplianceRequest::default();
11480///
11481/// // You can configure optional parameters by calling the respective setters at will, and
11482/// // execute the final call using `doit()`.
11483/// // Values shown here are possibly random and not representative !
11484/// let result = hub.projects().locations_sources_datacenter_connectors_upgrade_appliance(req, "datacenterConnector")
11485/// .doit().await;
11486/// # }
11487/// ```
11488pub struct ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C>
11489where
11490 C: 'a,
11491{
11492 hub: &'a VMMigrationService<C>,
11493 _request: UpgradeApplianceRequest,
11494 _datacenter_connector: String,
11495 _delegate: Option<&'a mut dyn common::Delegate>,
11496 _additional_params: HashMap<String, String>,
11497 _scopes: BTreeSet<String>,
11498}
11499
11500impl<'a, C> common::CallBuilder
11501 for ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C>
11502{
11503}
11504
11505impl<'a, C> ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C>
11506where
11507 C: common::Connector,
11508{
11509 /// Perform the operation you have build so far.
11510 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11511 use std::borrow::Cow;
11512 use std::io::{Read, Seek};
11513
11514 use common::{url::Params, ToParts};
11515 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11516
11517 let mut dd = common::DefaultDelegate;
11518 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11519 dlg.begin(common::MethodInfo {
11520 id: "vmmigration.projects.locations.sources.datacenterConnectors.upgradeAppliance",
11521 http_method: hyper::Method::POST,
11522 });
11523
11524 for &field in ["alt", "datacenterConnector"].iter() {
11525 if self._additional_params.contains_key(field) {
11526 dlg.finished(false);
11527 return Err(common::Error::FieldClash(field));
11528 }
11529 }
11530
11531 let mut params = Params::with_capacity(4 + self._additional_params.len());
11532 params.push("datacenterConnector", self._datacenter_connector);
11533
11534 params.extend(self._additional_params.iter());
11535
11536 params.push("alt", "json");
11537 let mut url = self.hub._base_url.clone() + "v1/{+datacenterConnector}:upgradeAppliance";
11538 if self._scopes.is_empty() {
11539 self._scopes
11540 .insert(Scope::CloudPlatform.as_ref().to_string());
11541 }
11542
11543 #[allow(clippy::single_element_loop)]
11544 for &(find_this, param_name) in [("{+datacenterConnector}", "datacenterConnector")].iter() {
11545 url = params.uri_replacement(url, param_name, find_this, true);
11546 }
11547 {
11548 let to_remove = ["datacenterConnector"];
11549 params.remove_params(&to_remove);
11550 }
11551
11552 let url = params.parse_with_url(&url);
11553
11554 let mut json_mime_type = mime::APPLICATION_JSON;
11555 let mut request_value_reader = {
11556 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11557 common::remove_json_null_values(&mut value);
11558 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11559 serde_json::to_writer(&mut dst, &value).unwrap();
11560 dst
11561 };
11562 let request_size = request_value_reader
11563 .seek(std::io::SeekFrom::End(0))
11564 .unwrap();
11565 request_value_reader
11566 .seek(std::io::SeekFrom::Start(0))
11567 .unwrap();
11568
11569 loop {
11570 let token = match self
11571 .hub
11572 .auth
11573 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11574 .await
11575 {
11576 Ok(token) => token,
11577 Err(e) => match dlg.token(e) {
11578 Ok(token) => token,
11579 Err(e) => {
11580 dlg.finished(false);
11581 return Err(common::Error::MissingToken(e));
11582 }
11583 },
11584 };
11585 request_value_reader
11586 .seek(std::io::SeekFrom::Start(0))
11587 .unwrap();
11588 let mut req_result = {
11589 let client = &self.hub.client;
11590 dlg.pre_request();
11591 let mut req_builder = hyper::Request::builder()
11592 .method(hyper::Method::POST)
11593 .uri(url.as_str())
11594 .header(USER_AGENT, self.hub._user_agent.clone());
11595
11596 if let Some(token) = token.as_ref() {
11597 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11598 }
11599
11600 let request = req_builder
11601 .header(CONTENT_TYPE, json_mime_type.to_string())
11602 .header(CONTENT_LENGTH, request_size as u64)
11603 .body(common::to_body(
11604 request_value_reader.get_ref().clone().into(),
11605 ));
11606
11607 client.request(request.unwrap()).await
11608 };
11609
11610 match req_result {
11611 Err(err) => {
11612 if let common::Retry::After(d) = dlg.http_error(&err) {
11613 sleep(d).await;
11614 continue;
11615 }
11616 dlg.finished(false);
11617 return Err(common::Error::HttpError(err));
11618 }
11619 Ok(res) => {
11620 let (mut parts, body) = res.into_parts();
11621 let mut body = common::Body::new(body);
11622 if !parts.status.is_success() {
11623 let bytes = common::to_bytes(body).await.unwrap_or_default();
11624 let error = serde_json::from_str(&common::to_string(&bytes));
11625 let response = common::to_response(parts, bytes.into());
11626
11627 if let common::Retry::After(d) =
11628 dlg.http_failure(&response, error.as_ref().ok())
11629 {
11630 sleep(d).await;
11631 continue;
11632 }
11633
11634 dlg.finished(false);
11635
11636 return Err(match error {
11637 Ok(value) => common::Error::BadRequest(value),
11638 _ => common::Error::Failure(response),
11639 });
11640 }
11641 let response = {
11642 let bytes = common::to_bytes(body).await.unwrap_or_default();
11643 let encoded = common::to_string(&bytes);
11644 match serde_json::from_str(&encoded) {
11645 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11646 Err(error) => {
11647 dlg.response_json_decode_error(&encoded, &error);
11648 return Err(common::Error::JsonDecodeError(
11649 encoded.to_string(),
11650 error,
11651 ));
11652 }
11653 }
11654 };
11655
11656 dlg.finished(true);
11657 return Ok(response);
11658 }
11659 }
11660 }
11661 }
11662
11663 ///
11664 /// Sets the *request* property to the given value.
11665 ///
11666 /// Even though the property as already been set when instantiating this call,
11667 /// we provide this method for API completeness.
11668 pub fn request(
11669 mut self,
11670 new_value: UpgradeApplianceRequest,
11671 ) -> ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C> {
11672 self._request = new_value;
11673 self
11674 }
11675 /// Required. The DatacenterConnector name.
11676 ///
11677 /// Sets the *datacenter connector* path property to the given value.
11678 ///
11679 /// Even though the property as already been set when instantiating this call,
11680 /// we provide this method for API completeness.
11681 pub fn datacenter_connector(
11682 mut self,
11683 new_value: &str,
11684 ) -> ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C> {
11685 self._datacenter_connector = new_value.to_string();
11686 self
11687 }
11688 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11689 /// while executing the actual API request.
11690 ///
11691 /// ````text
11692 /// It should be used to handle progress information, and to implement a certain level of resilience.
11693 /// ````
11694 ///
11695 /// Sets the *delegate* property to the given value.
11696 pub fn delegate(
11697 mut self,
11698 new_value: &'a mut dyn common::Delegate,
11699 ) -> ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C> {
11700 self._delegate = Some(new_value);
11701 self
11702 }
11703
11704 /// Set any additional parameter of the query string used in the request.
11705 /// It should be used to set parameters which are not yet available through their own
11706 /// setters.
11707 ///
11708 /// Please note that this method must not be used to set any of the known parameters
11709 /// which have their own setter method. If done anyway, the request will fail.
11710 ///
11711 /// # Additional Parameters
11712 ///
11713 /// * *$.xgafv* (query-string) - V1 error format.
11714 /// * *access_token* (query-string) - OAuth access token.
11715 /// * *alt* (query-string) - Data format for response.
11716 /// * *callback* (query-string) - JSONP
11717 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11718 /// * *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.
11719 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11720 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11721 /// * *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.
11722 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11723 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11724 pub fn param<T>(
11725 mut self,
11726 name: T,
11727 value: T,
11728 ) -> ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C>
11729 where
11730 T: AsRef<str>,
11731 {
11732 self._additional_params
11733 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11734 self
11735 }
11736
11737 /// Identifies the authorization scope for the method you are building.
11738 ///
11739 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11740 /// [`Scope::CloudPlatform`].
11741 ///
11742 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11743 /// tokens for more than one scope.
11744 ///
11745 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11746 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11747 /// sufficient, a read-write scope will do as well.
11748 pub fn add_scope<St>(
11749 mut self,
11750 scope: St,
11751 ) -> ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C>
11752 where
11753 St: AsRef<str>,
11754 {
11755 self._scopes.insert(String::from(scope.as_ref()));
11756 self
11757 }
11758 /// Identifies the authorization scope(s) for the method you are building.
11759 ///
11760 /// See [`Self::add_scope()`] for details.
11761 pub fn add_scopes<I, St>(
11762 mut self,
11763 scopes: I,
11764 ) -> ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C>
11765 where
11766 I: IntoIterator<Item = St>,
11767 St: AsRef<str>,
11768 {
11769 self._scopes
11770 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11771 self
11772 }
11773
11774 /// Removes all scopes, and no default scope will be used either.
11775 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11776 /// for details).
11777 pub fn clear_scopes(
11778 mut self,
11779 ) -> ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C> {
11780 self._scopes.clear();
11781 self
11782 }
11783}
11784
11785/// Initiates the cancellation of a running clone job.
11786///
11787/// A builder for the *locations.sources.migratingVms.cloneJobs.cancel* method supported by a *project* resource.
11788/// It is not used directly, but through a [`ProjectMethods`] instance.
11789///
11790/// # Example
11791///
11792/// Instantiate a resource method builder
11793///
11794/// ```test_harness,no_run
11795/// # extern crate hyper;
11796/// # extern crate hyper_rustls;
11797/// # extern crate google_vmmigration1 as vmmigration1;
11798/// use vmmigration1::api::CancelCloneJobRequest;
11799/// # async fn dox() {
11800/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11801///
11802/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11803/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11804/// # secret,
11805/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11806/// # ).build().await.unwrap();
11807///
11808/// # let client = hyper_util::client::legacy::Client::builder(
11809/// # hyper_util::rt::TokioExecutor::new()
11810/// # )
11811/// # .build(
11812/// # hyper_rustls::HttpsConnectorBuilder::new()
11813/// # .with_native_roots()
11814/// # .unwrap()
11815/// # .https_or_http()
11816/// # .enable_http1()
11817/// # .build()
11818/// # );
11819/// # let mut hub = VMMigrationService::new(client, auth);
11820/// // As the method needs a request, you would usually fill it with the desired information
11821/// // into the respective structure. Some of the parts shown here might not be applicable !
11822/// // Values shown here are possibly random and not representative !
11823/// let mut req = CancelCloneJobRequest::default();
11824///
11825/// // You can configure optional parameters by calling the respective setters at will, and
11826/// // execute the final call using `doit()`.
11827/// // Values shown here are possibly random and not representative !
11828/// let result = hub.projects().locations_sources_migrating_vms_clone_jobs_cancel(req, "name")
11829/// .doit().await;
11830/// # }
11831/// ```
11832pub struct ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C>
11833where
11834 C: 'a,
11835{
11836 hub: &'a VMMigrationService<C>,
11837 _request: CancelCloneJobRequest,
11838 _name: String,
11839 _delegate: Option<&'a mut dyn common::Delegate>,
11840 _additional_params: HashMap<String, String>,
11841 _scopes: BTreeSet<String>,
11842}
11843
11844impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C> {}
11845
11846impl<'a, C> ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C>
11847where
11848 C: common::Connector,
11849{
11850 /// Perform the operation you have build so far.
11851 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11852 use std::borrow::Cow;
11853 use std::io::{Read, Seek};
11854
11855 use common::{url::Params, ToParts};
11856 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11857
11858 let mut dd = common::DefaultDelegate;
11859 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11860 dlg.begin(common::MethodInfo {
11861 id: "vmmigration.projects.locations.sources.migratingVms.cloneJobs.cancel",
11862 http_method: hyper::Method::POST,
11863 });
11864
11865 for &field in ["alt", "name"].iter() {
11866 if self._additional_params.contains_key(field) {
11867 dlg.finished(false);
11868 return Err(common::Error::FieldClash(field));
11869 }
11870 }
11871
11872 let mut params = Params::with_capacity(4 + self._additional_params.len());
11873 params.push("name", self._name);
11874
11875 params.extend(self._additional_params.iter());
11876
11877 params.push("alt", "json");
11878 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
11879 if self._scopes.is_empty() {
11880 self._scopes
11881 .insert(Scope::CloudPlatform.as_ref().to_string());
11882 }
11883
11884 #[allow(clippy::single_element_loop)]
11885 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11886 url = params.uri_replacement(url, param_name, find_this, true);
11887 }
11888 {
11889 let to_remove = ["name"];
11890 params.remove_params(&to_remove);
11891 }
11892
11893 let url = params.parse_with_url(&url);
11894
11895 let mut json_mime_type = mime::APPLICATION_JSON;
11896 let mut request_value_reader = {
11897 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11898 common::remove_json_null_values(&mut value);
11899 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11900 serde_json::to_writer(&mut dst, &value).unwrap();
11901 dst
11902 };
11903 let request_size = request_value_reader
11904 .seek(std::io::SeekFrom::End(0))
11905 .unwrap();
11906 request_value_reader
11907 .seek(std::io::SeekFrom::Start(0))
11908 .unwrap();
11909
11910 loop {
11911 let token = match self
11912 .hub
11913 .auth
11914 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11915 .await
11916 {
11917 Ok(token) => token,
11918 Err(e) => match dlg.token(e) {
11919 Ok(token) => token,
11920 Err(e) => {
11921 dlg.finished(false);
11922 return Err(common::Error::MissingToken(e));
11923 }
11924 },
11925 };
11926 request_value_reader
11927 .seek(std::io::SeekFrom::Start(0))
11928 .unwrap();
11929 let mut req_result = {
11930 let client = &self.hub.client;
11931 dlg.pre_request();
11932 let mut req_builder = hyper::Request::builder()
11933 .method(hyper::Method::POST)
11934 .uri(url.as_str())
11935 .header(USER_AGENT, self.hub._user_agent.clone());
11936
11937 if let Some(token) = token.as_ref() {
11938 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11939 }
11940
11941 let request = req_builder
11942 .header(CONTENT_TYPE, json_mime_type.to_string())
11943 .header(CONTENT_LENGTH, request_size as u64)
11944 .body(common::to_body(
11945 request_value_reader.get_ref().clone().into(),
11946 ));
11947
11948 client.request(request.unwrap()).await
11949 };
11950
11951 match req_result {
11952 Err(err) => {
11953 if let common::Retry::After(d) = dlg.http_error(&err) {
11954 sleep(d).await;
11955 continue;
11956 }
11957 dlg.finished(false);
11958 return Err(common::Error::HttpError(err));
11959 }
11960 Ok(res) => {
11961 let (mut parts, body) = res.into_parts();
11962 let mut body = common::Body::new(body);
11963 if !parts.status.is_success() {
11964 let bytes = common::to_bytes(body).await.unwrap_or_default();
11965 let error = serde_json::from_str(&common::to_string(&bytes));
11966 let response = common::to_response(parts, bytes.into());
11967
11968 if let common::Retry::After(d) =
11969 dlg.http_failure(&response, error.as_ref().ok())
11970 {
11971 sleep(d).await;
11972 continue;
11973 }
11974
11975 dlg.finished(false);
11976
11977 return Err(match error {
11978 Ok(value) => common::Error::BadRequest(value),
11979 _ => common::Error::Failure(response),
11980 });
11981 }
11982 let response = {
11983 let bytes = common::to_bytes(body).await.unwrap_or_default();
11984 let encoded = common::to_string(&bytes);
11985 match serde_json::from_str(&encoded) {
11986 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11987 Err(error) => {
11988 dlg.response_json_decode_error(&encoded, &error);
11989 return Err(common::Error::JsonDecodeError(
11990 encoded.to_string(),
11991 error,
11992 ));
11993 }
11994 }
11995 };
11996
11997 dlg.finished(true);
11998 return Ok(response);
11999 }
12000 }
12001 }
12002 }
12003
12004 ///
12005 /// Sets the *request* property to the given value.
12006 ///
12007 /// Even though the property as already been set when instantiating this call,
12008 /// we provide this method for API completeness.
12009 pub fn request(
12010 mut self,
12011 new_value: CancelCloneJobRequest,
12012 ) -> ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C> {
12013 self._request = new_value;
12014 self
12015 }
12016 /// Required. The clone job id
12017 ///
12018 /// Sets the *name* path property to the given value.
12019 ///
12020 /// Even though the property as already been set when instantiating this call,
12021 /// we provide this method for API completeness.
12022 pub fn name(
12023 mut self,
12024 new_value: &str,
12025 ) -> ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C> {
12026 self._name = new_value.to_string();
12027 self
12028 }
12029 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12030 /// while executing the actual API request.
12031 ///
12032 /// ````text
12033 /// It should be used to handle progress information, and to implement a certain level of resilience.
12034 /// ````
12035 ///
12036 /// Sets the *delegate* property to the given value.
12037 pub fn delegate(
12038 mut self,
12039 new_value: &'a mut dyn common::Delegate,
12040 ) -> ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C> {
12041 self._delegate = Some(new_value);
12042 self
12043 }
12044
12045 /// Set any additional parameter of the query string used in the request.
12046 /// It should be used to set parameters which are not yet available through their own
12047 /// setters.
12048 ///
12049 /// Please note that this method must not be used to set any of the known parameters
12050 /// which have their own setter method. If done anyway, the request will fail.
12051 ///
12052 /// # Additional Parameters
12053 ///
12054 /// * *$.xgafv* (query-string) - V1 error format.
12055 /// * *access_token* (query-string) - OAuth access token.
12056 /// * *alt* (query-string) - Data format for response.
12057 /// * *callback* (query-string) - JSONP
12058 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12059 /// * *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.
12060 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12061 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12062 /// * *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.
12063 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12064 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12065 pub fn param<T>(
12066 mut self,
12067 name: T,
12068 value: T,
12069 ) -> ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C>
12070 where
12071 T: AsRef<str>,
12072 {
12073 self._additional_params
12074 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12075 self
12076 }
12077
12078 /// Identifies the authorization scope for the method you are building.
12079 ///
12080 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12081 /// [`Scope::CloudPlatform`].
12082 ///
12083 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12084 /// tokens for more than one scope.
12085 ///
12086 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12087 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12088 /// sufficient, a read-write scope will do as well.
12089 pub fn add_scope<St>(
12090 mut self,
12091 scope: St,
12092 ) -> ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C>
12093 where
12094 St: AsRef<str>,
12095 {
12096 self._scopes.insert(String::from(scope.as_ref()));
12097 self
12098 }
12099 /// Identifies the authorization scope(s) for the method you are building.
12100 ///
12101 /// See [`Self::add_scope()`] for details.
12102 pub fn add_scopes<I, St>(
12103 mut self,
12104 scopes: I,
12105 ) -> ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C>
12106 where
12107 I: IntoIterator<Item = St>,
12108 St: AsRef<str>,
12109 {
12110 self._scopes
12111 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12112 self
12113 }
12114
12115 /// Removes all scopes, and no default scope will be used either.
12116 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12117 /// for details).
12118 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C> {
12119 self._scopes.clear();
12120 self
12121 }
12122}
12123
12124/// Initiates a Clone of a specific migrating VM.
12125///
12126/// A builder for the *locations.sources.migratingVms.cloneJobs.create* method supported by a *project* resource.
12127/// It is not used directly, but through a [`ProjectMethods`] instance.
12128///
12129/// # Example
12130///
12131/// Instantiate a resource method builder
12132///
12133/// ```test_harness,no_run
12134/// # extern crate hyper;
12135/// # extern crate hyper_rustls;
12136/// # extern crate google_vmmigration1 as vmmigration1;
12137/// use vmmigration1::api::CloneJob;
12138/// # async fn dox() {
12139/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12140///
12141/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12142/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12143/// # secret,
12144/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12145/// # ).build().await.unwrap();
12146///
12147/// # let client = hyper_util::client::legacy::Client::builder(
12148/// # hyper_util::rt::TokioExecutor::new()
12149/// # )
12150/// # .build(
12151/// # hyper_rustls::HttpsConnectorBuilder::new()
12152/// # .with_native_roots()
12153/// # .unwrap()
12154/// # .https_or_http()
12155/// # .enable_http1()
12156/// # .build()
12157/// # );
12158/// # let mut hub = VMMigrationService::new(client, auth);
12159/// // As the method needs a request, you would usually fill it with the desired information
12160/// // into the respective structure. Some of the parts shown here might not be applicable !
12161/// // Values shown here are possibly random and not representative !
12162/// let mut req = CloneJob::default();
12163///
12164/// // You can configure optional parameters by calling the respective setters at will, and
12165/// // execute the final call using `doit()`.
12166/// // Values shown here are possibly random and not representative !
12167/// let result = hub.projects().locations_sources_migrating_vms_clone_jobs_create(req, "parent")
12168/// .request_id("dolor")
12169/// .clone_job_id("duo")
12170/// .doit().await;
12171/// # }
12172/// ```
12173pub struct ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C>
12174where
12175 C: 'a,
12176{
12177 hub: &'a VMMigrationService<C>,
12178 _request: CloneJob,
12179 _parent: String,
12180 _request_id: Option<String>,
12181 _clone_job_id: Option<String>,
12182 _delegate: Option<&'a mut dyn common::Delegate>,
12183 _additional_params: HashMap<String, String>,
12184 _scopes: BTreeSet<String>,
12185}
12186
12187impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C> {}
12188
12189impl<'a, C> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C>
12190where
12191 C: common::Connector,
12192{
12193 /// Perform the operation you have build so far.
12194 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12195 use std::borrow::Cow;
12196 use std::io::{Read, Seek};
12197
12198 use common::{url::Params, ToParts};
12199 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12200
12201 let mut dd = common::DefaultDelegate;
12202 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12203 dlg.begin(common::MethodInfo {
12204 id: "vmmigration.projects.locations.sources.migratingVms.cloneJobs.create",
12205 http_method: hyper::Method::POST,
12206 });
12207
12208 for &field in ["alt", "parent", "requestId", "cloneJobId"].iter() {
12209 if self._additional_params.contains_key(field) {
12210 dlg.finished(false);
12211 return Err(common::Error::FieldClash(field));
12212 }
12213 }
12214
12215 let mut params = Params::with_capacity(6 + self._additional_params.len());
12216 params.push("parent", self._parent);
12217 if let Some(value) = self._request_id.as_ref() {
12218 params.push("requestId", value);
12219 }
12220 if let Some(value) = self._clone_job_id.as_ref() {
12221 params.push("cloneJobId", value);
12222 }
12223
12224 params.extend(self._additional_params.iter());
12225
12226 params.push("alt", "json");
12227 let mut url = self.hub._base_url.clone() + "v1/{+parent}/cloneJobs";
12228 if self._scopes.is_empty() {
12229 self._scopes
12230 .insert(Scope::CloudPlatform.as_ref().to_string());
12231 }
12232
12233 #[allow(clippy::single_element_loop)]
12234 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12235 url = params.uri_replacement(url, param_name, find_this, true);
12236 }
12237 {
12238 let to_remove = ["parent"];
12239 params.remove_params(&to_remove);
12240 }
12241
12242 let url = params.parse_with_url(&url);
12243
12244 let mut json_mime_type = mime::APPLICATION_JSON;
12245 let mut request_value_reader = {
12246 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12247 common::remove_json_null_values(&mut value);
12248 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12249 serde_json::to_writer(&mut dst, &value).unwrap();
12250 dst
12251 };
12252 let request_size = request_value_reader
12253 .seek(std::io::SeekFrom::End(0))
12254 .unwrap();
12255 request_value_reader
12256 .seek(std::io::SeekFrom::Start(0))
12257 .unwrap();
12258
12259 loop {
12260 let token = match self
12261 .hub
12262 .auth
12263 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12264 .await
12265 {
12266 Ok(token) => token,
12267 Err(e) => match dlg.token(e) {
12268 Ok(token) => token,
12269 Err(e) => {
12270 dlg.finished(false);
12271 return Err(common::Error::MissingToken(e));
12272 }
12273 },
12274 };
12275 request_value_reader
12276 .seek(std::io::SeekFrom::Start(0))
12277 .unwrap();
12278 let mut req_result = {
12279 let client = &self.hub.client;
12280 dlg.pre_request();
12281 let mut req_builder = hyper::Request::builder()
12282 .method(hyper::Method::POST)
12283 .uri(url.as_str())
12284 .header(USER_AGENT, self.hub._user_agent.clone());
12285
12286 if let Some(token) = token.as_ref() {
12287 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12288 }
12289
12290 let request = req_builder
12291 .header(CONTENT_TYPE, json_mime_type.to_string())
12292 .header(CONTENT_LENGTH, request_size as u64)
12293 .body(common::to_body(
12294 request_value_reader.get_ref().clone().into(),
12295 ));
12296
12297 client.request(request.unwrap()).await
12298 };
12299
12300 match req_result {
12301 Err(err) => {
12302 if let common::Retry::After(d) = dlg.http_error(&err) {
12303 sleep(d).await;
12304 continue;
12305 }
12306 dlg.finished(false);
12307 return Err(common::Error::HttpError(err));
12308 }
12309 Ok(res) => {
12310 let (mut parts, body) = res.into_parts();
12311 let mut body = common::Body::new(body);
12312 if !parts.status.is_success() {
12313 let bytes = common::to_bytes(body).await.unwrap_or_default();
12314 let error = serde_json::from_str(&common::to_string(&bytes));
12315 let response = common::to_response(parts, bytes.into());
12316
12317 if let common::Retry::After(d) =
12318 dlg.http_failure(&response, error.as_ref().ok())
12319 {
12320 sleep(d).await;
12321 continue;
12322 }
12323
12324 dlg.finished(false);
12325
12326 return Err(match error {
12327 Ok(value) => common::Error::BadRequest(value),
12328 _ => common::Error::Failure(response),
12329 });
12330 }
12331 let response = {
12332 let bytes = common::to_bytes(body).await.unwrap_or_default();
12333 let encoded = common::to_string(&bytes);
12334 match serde_json::from_str(&encoded) {
12335 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12336 Err(error) => {
12337 dlg.response_json_decode_error(&encoded, &error);
12338 return Err(common::Error::JsonDecodeError(
12339 encoded.to_string(),
12340 error,
12341 ));
12342 }
12343 }
12344 };
12345
12346 dlg.finished(true);
12347 return Ok(response);
12348 }
12349 }
12350 }
12351 }
12352
12353 ///
12354 /// Sets the *request* property to the given value.
12355 ///
12356 /// Even though the property as already been set when instantiating this call,
12357 /// we provide this method for API completeness.
12358 pub fn request(
12359 mut self,
12360 new_value: CloneJob,
12361 ) -> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C> {
12362 self._request = new_value;
12363 self
12364 }
12365 /// Required. The Clone's parent.
12366 ///
12367 /// Sets the *parent* path property to the given value.
12368 ///
12369 /// Even though the property as already been set when instantiating this call,
12370 /// we provide this method for API completeness.
12371 pub fn parent(
12372 mut self,
12373 new_value: &str,
12374 ) -> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C> {
12375 self._parent = new_value.to_string();
12376 self
12377 }
12378 /// A request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes since the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
12379 ///
12380 /// Sets the *request id* query property to the given value.
12381 pub fn request_id(
12382 mut self,
12383 new_value: &str,
12384 ) -> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C> {
12385 self._request_id = Some(new_value.to_string());
12386 self
12387 }
12388 /// Required. The clone job identifier.
12389 ///
12390 /// Sets the *clone job id* query property to the given value.
12391 pub fn clone_job_id(
12392 mut self,
12393 new_value: &str,
12394 ) -> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C> {
12395 self._clone_job_id = Some(new_value.to_string());
12396 self
12397 }
12398 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12399 /// while executing the actual API request.
12400 ///
12401 /// ````text
12402 /// It should be used to handle progress information, and to implement a certain level of resilience.
12403 /// ````
12404 ///
12405 /// Sets the *delegate* property to the given value.
12406 pub fn delegate(
12407 mut self,
12408 new_value: &'a mut dyn common::Delegate,
12409 ) -> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C> {
12410 self._delegate = Some(new_value);
12411 self
12412 }
12413
12414 /// Set any additional parameter of the query string used in the request.
12415 /// It should be used to set parameters which are not yet available through their own
12416 /// setters.
12417 ///
12418 /// Please note that this method must not be used to set any of the known parameters
12419 /// which have their own setter method. If done anyway, the request will fail.
12420 ///
12421 /// # Additional Parameters
12422 ///
12423 /// * *$.xgafv* (query-string) - V1 error format.
12424 /// * *access_token* (query-string) - OAuth access token.
12425 /// * *alt* (query-string) - Data format for response.
12426 /// * *callback* (query-string) - JSONP
12427 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12428 /// * *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.
12429 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12430 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12431 /// * *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.
12432 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12433 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12434 pub fn param<T>(
12435 mut self,
12436 name: T,
12437 value: T,
12438 ) -> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C>
12439 where
12440 T: AsRef<str>,
12441 {
12442 self._additional_params
12443 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12444 self
12445 }
12446
12447 /// Identifies the authorization scope for the method you are building.
12448 ///
12449 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12450 /// [`Scope::CloudPlatform`].
12451 ///
12452 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12453 /// tokens for more than one scope.
12454 ///
12455 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12456 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12457 /// sufficient, a read-write scope will do as well.
12458 pub fn add_scope<St>(
12459 mut self,
12460 scope: St,
12461 ) -> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C>
12462 where
12463 St: AsRef<str>,
12464 {
12465 self._scopes.insert(String::from(scope.as_ref()));
12466 self
12467 }
12468 /// Identifies the authorization scope(s) for the method you are building.
12469 ///
12470 /// See [`Self::add_scope()`] for details.
12471 pub fn add_scopes<I, St>(
12472 mut self,
12473 scopes: I,
12474 ) -> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C>
12475 where
12476 I: IntoIterator<Item = St>,
12477 St: AsRef<str>,
12478 {
12479 self._scopes
12480 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12481 self
12482 }
12483
12484 /// Removes all scopes, and no default scope will be used either.
12485 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12486 /// for details).
12487 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C> {
12488 self._scopes.clear();
12489 self
12490 }
12491}
12492
12493/// Gets details of a single CloneJob.
12494///
12495/// A builder for the *locations.sources.migratingVms.cloneJobs.get* method supported by a *project* resource.
12496/// It is not used directly, but through a [`ProjectMethods`] instance.
12497///
12498/// # Example
12499///
12500/// Instantiate a resource method builder
12501///
12502/// ```test_harness,no_run
12503/// # extern crate hyper;
12504/// # extern crate hyper_rustls;
12505/// # extern crate google_vmmigration1 as vmmigration1;
12506/// # async fn dox() {
12507/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12508///
12509/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12510/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12511/// # secret,
12512/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12513/// # ).build().await.unwrap();
12514///
12515/// # let client = hyper_util::client::legacy::Client::builder(
12516/// # hyper_util::rt::TokioExecutor::new()
12517/// # )
12518/// # .build(
12519/// # hyper_rustls::HttpsConnectorBuilder::new()
12520/// # .with_native_roots()
12521/// # .unwrap()
12522/// # .https_or_http()
12523/// # .enable_http1()
12524/// # .build()
12525/// # );
12526/// # let mut hub = VMMigrationService::new(client, auth);
12527/// // You can configure optional parameters by calling the respective setters at will, and
12528/// // execute the final call using `doit()`.
12529/// // Values shown here are possibly random and not representative !
12530/// let result = hub.projects().locations_sources_migrating_vms_clone_jobs_get("name")
12531/// .doit().await;
12532/// # }
12533/// ```
12534pub struct ProjectLocationSourceMigratingVmCloneJobGetCall<'a, C>
12535where
12536 C: 'a,
12537{
12538 hub: &'a VMMigrationService<C>,
12539 _name: String,
12540 _delegate: Option<&'a mut dyn common::Delegate>,
12541 _additional_params: HashMap<String, String>,
12542 _scopes: BTreeSet<String>,
12543}
12544
12545impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmCloneJobGetCall<'a, C> {}
12546
12547impl<'a, C> ProjectLocationSourceMigratingVmCloneJobGetCall<'a, C>
12548where
12549 C: common::Connector,
12550{
12551 /// Perform the operation you have build so far.
12552 pub async fn doit(mut self) -> common::Result<(common::Response, CloneJob)> {
12553 use std::borrow::Cow;
12554 use std::io::{Read, Seek};
12555
12556 use common::{url::Params, ToParts};
12557 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12558
12559 let mut dd = common::DefaultDelegate;
12560 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12561 dlg.begin(common::MethodInfo {
12562 id: "vmmigration.projects.locations.sources.migratingVms.cloneJobs.get",
12563 http_method: hyper::Method::GET,
12564 });
12565
12566 for &field in ["alt", "name"].iter() {
12567 if self._additional_params.contains_key(field) {
12568 dlg.finished(false);
12569 return Err(common::Error::FieldClash(field));
12570 }
12571 }
12572
12573 let mut params = Params::with_capacity(3 + self._additional_params.len());
12574 params.push("name", self._name);
12575
12576 params.extend(self._additional_params.iter());
12577
12578 params.push("alt", "json");
12579 let mut url = self.hub._base_url.clone() + "v1/{+name}";
12580 if self._scopes.is_empty() {
12581 self._scopes
12582 .insert(Scope::CloudPlatform.as_ref().to_string());
12583 }
12584
12585 #[allow(clippy::single_element_loop)]
12586 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12587 url = params.uri_replacement(url, param_name, find_this, true);
12588 }
12589 {
12590 let to_remove = ["name"];
12591 params.remove_params(&to_remove);
12592 }
12593
12594 let url = params.parse_with_url(&url);
12595
12596 loop {
12597 let token = match self
12598 .hub
12599 .auth
12600 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12601 .await
12602 {
12603 Ok(token) => token,
12604 Err(e) => match dlg.token(e) {
12605 Ok(token) => token,
12606 Err(e) => {
12607 dlg.finished(false);
12608 return Err(common::Error::MissingToken(e));
12609 }
12610 },
12611 };
12612 let mut req_result = {
12613 let client = &self.hub.client;
12614 dlg.pre_request();
12615 let mut req_builder = hyper::Request::builder()
12616 .method(hyper::Method::GET)
12617 .uri(url.as_str())
12618 .header(USER_AGENT, self.hub._user_agent.clone());
12619
12620 if let Some(token) = token.as_ref() {
12621 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12622 }
12623
12624 let request = req_builder
12625 .header(CONTENT_LENGTH, 0_u64)
12626 .body(common::to_body::<String>(None));
12627
12628 client.request(request.unwrap()).await
12629 };
12630
12631 match req_result {
12632 Err(err) => {
12633 if let common::Retry::After(d) = dlg.http_error(&err) {
12634 sleep(d).await;
12635 continue;
12636 }
12637 dlg.finished(false);
12638 return Err(common::Error::HttpError(err));
12639 }
12640 Ok(res) => {
12641 let (mut parts, body) = res.into_parts();
12642 let mut body = common::Body::new(body);
12643 if !parts.status.is_success() {
12644 let bytes = common::to_bytes(body).await.unwrap_or_default();
12645 let error = serde_json::from_str(&common::to_string(&bytes));
12646 let response = common::to_response(parts, bytes.into());
12647
12648 if let common::Retry::After(d) =
12649 dlg.http_failure(&response, error.as_ref().ok())
12650 {
12651 sleep(d).await;
12652 continue;
12653 }
12654
12655 dlg.finished(false);
12656
12657 return Err(match error {
12658 Ok(value) => common::Error::BadRequest(value),
12659 _ => common::Error::Failure(response),
12660 });
12661 }
12662 let response = {
12663 let bytes = common::to_bytes(body).await.unwrap_or_default();
12664 let encoded = common::to_string(&bytes);
12665 match serde_json::from_str(&encoded) {
12666 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12667 Err(error) => {
12668 dlg.response_json_decode_error(&encoded, &error);
12669 return Err(common::Error::JsonDecodeError(
12670 encoded.to_string(),
12671 error,
12672 ));
12673 }
12674 }
12675 };
12676
12677 dlg.finished(true);
12678 return Ok(response);
12679 }
12680 }
12681 }
12682 }
12683
12684 /// Required. The name of the CloneJob.
12685 ///
12686 /// Sets the *name* path property to the given value.
12687 ///
12688 /// Even though the property as already been set when instantiating this call,
12689 /// we provide this method for API completeness.
12690 pub fn name(
12691 mut self,
12692 new_value: &str,
12693 ) -> ProjectLocationSourceMigratingVmCloneJobGetCall<'a, C> {
12694 self._name = new_value.to_string();
12695 self
12696 }
12697 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12698 /// while executing the actual API request.
12699 ///
12700 /// ````text
12701 /// It should be used to handle progress information, and to implement a certain level of resilience.
12702 /// ````
12703 ///
12704 /// Sets the *delegate* property to the given value.
12705 pub fn delegate(
12706 mut self,
12707 new_value: &'a mut dyn common::Delegate,
12708 ) -> ProjectLocationSourceMigratingVmCloneJobGetCall<'a, C> {
12709 self._delegate = Some(new_value);
12710 self
12711 }
12712
12713 /// Set any additional parameter of the query string used in the request.
12714 /// It should be used to set parameters which are not yet available through their own
12715 /// setters.
12716 ///
12717 /// Please note that this method must not be used to set any of the known parameters
12718 /// which have their own setter method. If done anyway, the request will fail.
12719 ///
12720 /// # Additional Parameters
12721 ///
12722 /// * *$.xgafv* (query-string) - V1 error format.
12723 /// * *access_token* (query-string) - OAuth access token.
12724 /// * *alt* (query-string) - Data format for response.
12725 /// * *callback* (query-string) - JSONP
12726 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12727 /// * *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.
12728 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12729 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12730 /// * *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.
12731 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12732 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12733 pub fn param<T>(
12734 mut self,
12735 name: T,
12736 value: T,
12737 ) -> ProjectLocationSourceMigratingVmCloneJobGetCall<'a, C>
12738 where
12739 T: AsRef<str>,
12740 {
12741 self._additional_params
12742 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12743 self
12744 }
12745
12746 /// Identifies the authorization scope for the method you are building.
12747 ///
12748 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12749 /// [`Scope::CloudPlatform`].
12750 ///
12751 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12752 /// tokens for more than one scope.
12753 ///
12754 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12755 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12756 /// sufficient, a read-write scope will do as well.
12757 pub fn add_scope<St>(
12758 mut self,
12759 scope: St,
12760 ) -> ProjectLocationSourceMigratingVmCloneJobGetCall<'a, C>
12761 where
12762 St: AsRef<str>,
12763 {
12764 self._scopes.insert(String::from(scope.as_ref()));
12765 self
12766 }
12767 /// Identifies the authorization scope(s) for the method you are building.
12768 ///
12769 /// See [`Self::add_scope()`] for details.
12770 pub fn add_scopes<I, St>(
12771 mut self,
12772 scopes: I,
12773 ) -> ProjectLocationSourceMigratingVmCloneJobGetCall<'a, C>
12774 where
12775 I: IntoIterator<Item = St>,
12776 St: AsRef<str>,
12777 {
12778 self._scopes
12779 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12780 self
12781 }
12782
12783 /// Removes all scopes, and no default scope will be used either.
12784 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12785 /// for details).
12786 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmCloneJobGetCall<'a, C> {
12787 self._scopes.clear();
12788 self
12789 }
12790}
12791
12792/// Lists the CloneJobs of a migrating VM. Only 25 most recent CloneJobs are listed.
12793///
12794/// A builder for the *locations.sources.migratingVms.cloneJobs.list* method supported by a *project* resource.
12795/// It is not used directly, but through a [`ProjectMethods`] instance.
12796///
12797/// # Example
12798///
12799/// Instantiate a resource method builder
12800///
12801/// ```test_harness,no_run
12802/// # extern crate hyper;
12803/// # extern crate hyper_rustls;
12804/// # extern crate google_vmmigration1 as vmmigration1;
12805/// # async fn dox() {
12806/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12807///
12808/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12809/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12810/// # secret,
12811/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12812/// # ).build().await.unwrap();
12813///
12814/// # let client = hyper_util::client::legacy::Client::builder(
12815/// # hyper_util::rt::TokioExecutor::new()
12816/// # )
12817/// # .build(
12818/// # hyper_rustls::HttpsConnectorBuilder::new()
12819/// # .with_native_roots()
12820/// # .unwrap()
12821/// # .https_or_http()
12822/// # .enable_http1()
12823/// # .build()
12824/// # );
12825/// # let mut hub = VMMigrationService::new(client, auth);
12826/// // You can configure optional parameters by calling the respective setters at will, and
12827/// // execute the final call using `doit()`.
12828/// // Values shown here are possibly random and not representative !
12829/// let result = hub.projects().locations_sources_migrating_vms_clone_jobs_list("parent")
12830/// .page_token("invidunt")
12831/// .page_size(-65)
12832/// .order_by("vero")
12833/// .filter("elitr")
12834/// .doit().await;
12835/// # }
12836/// ```
12837pub struct ProjectLocationSourceMigratingVmCloneJobListCall<'a, C>
12838where
12839 C: 'a,
12840{
12841 hub: &'a VMMigrationService<C>,
12842 _parent: String,
12843 _page_token: Option<String>,
12844 _page_size: Option<i32>,
12845 _order_by: Option<String>,
12846 _filter: Option<String>,
12847 _delegate: Option<&'a mut dyn common::Delegate>,
12848 _additional_params: HashMap<String, String>,
12849 _scopes: BTreeSet<String>,
12850}
12851
12852impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmCloneJobListCall<'a, C> {}
12853
12854impl<'a, C> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C>
12855where
12856 C: common::Connector,
12857{
12858 /// Perform the operation you have build so far.
12859 pub async fn doit(mut self) -> common::Result<(common::Response, ListCloneJobsResponse)> {
12860 use std::borrow::Cow;
12861 use std::io::{Read, Seek};
12862
12863 use common::{url::Params, ToParts};
12864 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12865
12866 let mut dd = common::DefaultDelegate;
12867 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12868 dlg.begin(common::MethodInfo {
12869 id: "vmmigration.projects.locations.sources.migratingVms.cloneJobs.list",
12870 http_method: hyper::Method::GET,
12871 });
12872
12873 for &field in [
12874 "alt",
12875 "parent",
12876 "pageToken",
12877 "pageSize",
12878 "orderBy",
12879 "filter",
12880 ]
12881 .iter()
12882 {
12883 if self._additional_params.contains_key(field) {
12884 dlg.finished(false);
12885 return Err(common::Error::FieldClash(field));
12886 }
12887 }
12888
12889 let mut params = Params::with_capacity(7 + self._additional_params.len());
12890 params.push("parent", self._parent);
12891 if let Some(value) = self._page_token.as_ref() {
12892 params.push("pageToken", value);
12893 }
12894 if let Some(value) = self._page_size.as_ref() {
12895 params.push("pageSize", value.to_string());
12896 }
12897 if let Some(value) = self._order_by.as_ref() {
12898 params.push("orderBy", value);
12899 }
12900 if let Some(value) = self._filter.as_ref() {
12901 params.push("filter", value);
12902 }
12903
12904 params.extend(self._additional_params.iter());
12905
12906 params.push("alt", "json");
12907 let mut url = self.hub._base_url.clone() + "v1/{+parent}/cloneJobs";
12908 if self._scopes.is_empty() {
12909 self._scopes
12910 .insert(Scope::CloudPlatform.as_ref().to_string());
12911 }
12912
12913 #[allow(clippy::single_element_loop)]
12914 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12915 url = params.uri_replacement(url, param_name, find_this, true);
12916 }
12917 {
12918 let to_remove = ["parent"];
12919 params.remove_params(&to_remove);
12920 }
12921
12922 let url = params.parse_with_url(&url);
12923
12924 loop {
12925 let token = match self
12926 .hub
12927 .auth
12928 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12929 .await
12930 {
12931 Ok(token) => token,
12932 Err(e) => match dlg.token(e) {
12933 Ok(token) => token,
12934 Err(e) => {
12935 dlg.finished(false);
12936 return Err(common::Error::MissingToken(e));
12937 }
12938 },
12939 };
12940 let mut req_result = {
12941 let client = &self.hub.client;
12942 dlg.pre_request();
12943 let mut req_builder = hyper::Request::builder()
12944 .method(hyper::Method::GET)
12945 .uri(url.as_str())
12946 .header(USER_AGENT, self.hub._user_agent.clone());
12947
12948 if let Some(token) = token.as_ref() {
12949 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12950 }
12951
12952 let request = req_builder
12953 .header(CONTENT_LENGTH, 0_u64)
12954 .body(common::to_body::<String>(None));
12955
12956 client.request(request.unwrap()).await
12957 };
12958
12959 match req_result {
12960 Err(err) => {
12961 if let common::Retry::After(d) = dlg.http_error(&err) {
12962 sleep(d).await;
12963 continue;
12964 }
12965 dlg.finished(false);
12966 return Err(common::Error::HttpError(err));
12967 }
12968 Ok(res) => {
12969 let (mut parts, body) = res.into_parts();
12970 let mut body = common::Body::new(body);
12971 if !parts.status.is_success() {
12972 let bytes = common::to_bytes(body).await.unwrap_or_default();
12973 let error = serde_json::from_str(&common::to_string(&bytes));
12974 let response = common::to_response(parts, bytes.into());
12975
12976 if let common::Retry::After(d) =
12977 dlg.http_failure(&response, error.as_ref().ok())
12978 {
12979 sleep(d).await;
12980 continue;
12981 }
12982
12983 dlg.finished(false);
12984
12985 return Err(match error {
12986 Ok(value) => common::Error::BadRequest(value),
12987 _ => common::Error::Failure(response),
12988 });
12989 }
12990 let response = {
12991 let bytes = common::to_bytes(body).await.unwrap_or_default();
12992 let encoded = common::to_string(&bytes);
12993 match serde_json::from_str(&encoded) {
12994 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12995 Err(error) => {
12996 dlg.response_json_decode_error(&encoded, &error);
12997 return Err(common::Error::JsonDecodeError(
12998 encoded.to_string(),
12999 error,
13000 ));
13001 }
13002 }
13003 };
13004
13005 dlg.finished(true);
13006 return Ok(response);
13007 }
13008 }
13009 }
13010 }
13011
13012 /// Required. The parent, which owns this collection of source VMs.
13013 ///
13014 /// Sets the *parent* path property to the given value.
13015 ///
13016 /// Even though the property as already been set when instantiating this call,
13017 /// we provide this method for API completeness.
13018 pub fn parent(
13019 mut self,
13020 new_value: &str,
13021 ) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C> {
13022 self._parent = new_value.to_string();
13023 self
13024 }
13025 /// Required. A page token, received from a previous `ListCloneJobs` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListCloneJobs` must match the call that provided the page token.
13026 ///
13027 /// Sets the *page token* query property to the given value.
13028 pub fn page_token(
13029 mut self,
13030 new_value: &str,
13031 ) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C> {
13032 self._page_token = Some(new_value.to_string());
13033 self
13034 }
13035 /// Optional. The maximum number of clone jobs to return. The service may return fewer than this value. If unspecified, at most 500 clone jobs will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
13036 ///
13037 /// Sets the *page size* query property to the given value.
13038 pub fn page_size(
13039 mut self,
13040 new_value: i32,
13041 ) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C> {
13042 self._page_size = Some(new_value);
13043 self
13044 }
13045 /// Optional. the order by fields for the result.
13046 ///
13047 /// Sets the *order by* query property to the given value.
13048 pub fn order_by(
13049 mut self,
13050 new_value: &str,
13051 ) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C> {
13052 self._order_by = Some(new_value.to_string());
13053 self
13054 }
13055 /// Optional. The filter request.
13056 ///
13057 /// Sets the *filter* query property to the given value.
13058 pub fn filter(
13059 mut self,
13060 new_value: &str,
13061 ) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C> {
13062 self._filter = Some(new_value.to_string());
13063 self
13064 }
13065 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13066 /// while executing the actual API request.
13067 ///
13068 /// ````text
13069 /// It should be used to handle progress information, and to implement a certain level of resilience.
13070 /// ````
13071 ///
13072 /// Sets the *delegate* property to the given value.
13073 pub fn delegate(
13074 mut self,
13075 new_value: &'a mut dyn common::Delegate,
13076 ) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C> {
13077 self._delegate = Some(new_value);
13078 self
13079 }
13080
13081 /// Set any additional parameter of the query string used in the request.
13082 /// It should be used to set parameters which are not yet available through their own
13083 /// setters.
13084 ///
13085 /// Please note that this method must not be used to set any of the known parameters
13086 /// which have their own setter method. If done anyway, the request will fail.
13087 ///
13088 /// # Additional Parameters
13089 ///
13090 /// * *$.xgafv* (query-string) - V1 error format.
13091 /// * *access_token* (query-string) - OAuth access token.
13092 /// * *alt* (query-string) - Data format for response.
13093 /// * *callback* (query-string) - JSONP
13094 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13095 /// * *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.
13096 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13097 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13098 /// * *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.
13099 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13100 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13101 pub fn param<T>(
13102 mut self,
13103 name: T,
13104 value: T,
13105 ) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C>
13106 where
13107 T: AsRef<str>,
13108 {
13109 self._additional_params
13110 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13111 self
13112 }
13113
13114 /// Identifies the authorization scope for the method you are building.
13115 ///
13116 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13117 /// [`Scope::CloudPlatform`].
13118 ///
13119 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13120 /// tokens for more than one scope.
13121 ///
13122 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13123 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13124 /// sufficient, a read-write scope will do as well.
13125 pub fn add_scope<St>(
13126 mut self,
13127 scope: St,
13128 ) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C>
13129 where
13130 St: AsRef<str>,
13131 {
13132 self._scopes.insert(String::from(scope.as_ref()));
13133 self
13134 }
13135 /// Identifies the authorization scope(s) for the method you are building.
13136 ///
13137 /// See [`Self::add_scope()`] for details.
13138 pub fn add_scopes<I, St>(
13139 mut self,
13140 scopes: I,
13141 ) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C>
13142 where
13143 I: IntoIterator<Item = St>,
13144 St: AsRef<str>,
13145 {
13146 self._scopes
13147 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13148 self
13149 }
13150
13151 /// Removes all scopes, and no default scope will be used either.
13152 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13153 /// for details).
13154 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C> {
13155 self._scopes.clear();
13156 self
13157 }
13158}
13159
13160/// Initiates the cancellation of a running cutover job.
13161///
13162/// A builder for the *locations.sources.migratingVms.cutoverJobs.cancel* method supported by a *project* resource.
13163/// It is not used directly, but through a [`ProjectMethods`] instance.
13164///
13165/// # Example
13166///
13167/// Instantiate a resource method builder
13168///
13169/// ```test_harness,no_run
13170/// # extern crate hyper;
13171/// # extern crate hyper_rustls;
13172/// # extern crate google_vmmigration1 as vmmigration1;
13173/// use vmmigration1::api::CancelCutoverJobRequest;
13174/// # async fn dox() {
13175/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13176///
13177/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13178/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13179/// # secret,
13180/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13181/// # ).build().await.unwrap();
13182///
13183/// # let client = hyper_util::client::legacy::Client::builder(
13184/// # hyper_util::rt::TokioExecutor::new()
13185/// # )
13186/// # .build(
13187/// # hyper_rustls::HttpsConnectorBuilder::new()
13188/// # .with_native_roots()
13189/// # .unwrap()
13190/// # .https_or_http()
13191/// # .enable_http1()
13192/// # .build()
13193/// # );
13194/// # let mut hub = VMMigrationService::new(client, auth);
13195/// // As the method needs a request, you would usually fill it with the desired information
13196/// // into the respective structure. Some of the parts shown here might not be applicable !
13197/// // Values shown here are possibly random and not representative !
13198/// let mut req = CancelCutoverJobRequest::default();
13199///
13200/// // You can configure optional parameters by calling the respective setters at will, and
13201/// // execute the final call using `doit()`.
13202/// // Values shown here are possibly random and not representative !
13203/// let result = hub.projects().locations_sources_migrating_vms_cutover_jobs_cancel(req, "name")
13204/// .doit().await;
13205/// # }
13206/// ```
13207pub struct ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C>
13208where
13209 C: 'a,
13210{
13211 hub: &'a VMMigrationService<C>,
13212 _request: CancelCutoverJobRequest,
13213 _name: String,
13214 _delegate: Option<&'a mut dyn common::Delegate>,
13215 _additional_params: HashMap<String, String>,
13216 _scopes: BTreeSet<String>,
13217}
13218
13219impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C> {}
13220
13221impl<'a, C> ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C>
13222where
13223 C: common::Connector,
13224{
13225 /// Perform the operation you have build so far.
13226 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13227 use std::borrow::Cow;
13228 use std::io::{Read, Seek};
13229
13230 use common::{url::Params, ToParts};
13231 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13232
13233 let mut dd = common::DefaultDelegate;
13234 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13235 dlg.begin(common::MethodInfo {
13236 id: "vmmigration.projects.locations.sources.migratingVms.cutoverJobs.cancel",
13237 http_method: hyper::Method::POST,
13238 });
13239
13240 for &field in ["alt", "name"].iter() {
13241 if self._additional_params.contains_key(field) {
13242 dlg.finished(false);
13243 return Err(common::Error::FieldClash(field));
13244 }
13245 }
13246
13247 let mut params = Params::with_capacity(4 + self._additional_params.len());
13248 params.push("name", self._name);
13249
13250 params.extend(self._additional_params.iter());
13251
13252 params.push("alt", "json");
13253 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
13254 if self._scopes.is_empty() {
13255 self._scopes
13256 .insert(Scope::CloudPlatform.as_ref().to_string());
13257 }
13258
13259 #[allow(clippy::single_element_loop)]
13260 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13261 url = params.uri_replacement(url, param_name, find_this, true);
13262 }
13263 {
13264 let to_remove = ["name"];
13265 params.remove_params(&to_remove);
13266 }
13267
13268 let url = params.parse_with_url(&url);
13269
13270 let mut json_mime_type = mime::APPLICATION_JSON;
13271 let mut request_value_reader = {
13272 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13273 common::remove_json_null_values(&mut value);
13274 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13275 serde_json::to_writer(&mut dst, &value).unwrap();
13276 dst
13277 };
13278 let request_size = request_value_reader
13279 .seek(std::io::SeekFrom::End(0))
13280 .unwrap();
13281 request_value_reader
13282 .seek(std::io::SeekFrom::Start(0))
13283 .unwrap();
13284
13285 loop {
13286 let token = match self
13287 .hub
13288 .auth
13289 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13290 .await
13291 {
13292 Ok(token) => token,
13293 Err(e) => match dlg.token(e) {
13294 Ok(token) => token,
13295 Err(e) => {
13296 dlg.finished(false);
13297 return Err(common::Error::MissingToken(e));
13298 }
13299 },
13300 };
13301 request_value_reader
13302 .seek(std::io::SeekFrom::Start(0))
13303 .unwrap();
13304 let mut req_result = {
13305 let client = &self.hub.client;
13306 dlg.pre_request();
13307 let mut req_builder = hyper::Request::builder()
13308 .method(hyper::Method::POST)
13309 .uri(url.as_str())
13310 .header(USER_AGENT, self.hub._user_agent.clone());
13311
13312 if let Some(token) = token.as_ref() {
13313 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13314 }
13315
13316 let request = req_builder
13317 .header(CONTENT_TYPE, json_mime_type.to_string())
13318 .header(CONTENT_LENGTH, request_size as u64)
13319 .body(common::to_body(
13320 request_value_reader.get_ref().clone().into(),
13321 ));
13322
13323 client.request(request.unwrap()).await
13324 };
13325
13326 match req_result {
13327 Err(err) => {
13328 if let common::Retry::After(d) = dlg.http_error(&err) {
13329 sleep(d).await;
13330 continue;
13331 }
13332 dlg.finished(false);
13333 return Err(common::Error::HttpError(err));
13334 }
13335 Ok(res) => {
13336 let (mut parts, body) = res.into_parts();
13337 let mut body = common::Body::new(body);
13338 if !parts.status.is_success() {
13339 let bytes = common::to_bytes(body).await.unwrap_or_default();
13340 let error = serde_json::from_str(&common::to_string(&bytes));
13341 let response = common::to_response(parts, bytes.into());
13342
13343 if let common::Retry::After(d) =
13344 dlg.http_failure(&response, error.as_ref().ok())
13345 {
13346 sleep(d).await;
13347 continue;
13348 }
13349
13350 dlg.finished(false);
13351
13352 return Err(match error {
13353 Ok(value) => common::Error::BadRequest(value),
13354 _ => common::Error::Failure(response),
13355 });
13356 }
13357 let response = {
13358 let bytes = common::to_bytes(body).await.unwrap_or_default();
13359 let encoded = common::to_string(&bytes);
13360 match serde_json::from_str(&encoded) {
13361 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13362 Err(error) => {
13363 dlg.response_json_decode_error(&encoded, &error);
13364 return Err(common::Error::JsonDecodeError(
13365 encoded.to_string(),
13366 error,
13367 ));
13368 }
13369 }
13370 };
13371
13372 dlg.finished(true);
13373 return Ok(response);
13374 }
13375 }
13376 }
13377 }
13378
13379 ///
13380 /// Sets the *request* property to the given value.
13381 ///
13382 /// Even though the property as already been set when instantiating this call,
13383 /// we provide this method for API completeness.
13384 pub fn request(
13385 mut self,
13386 new_value: CancelCutoverJobRequest,
13387 ) -> ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C> {
13388 self._request = new_value;
13389 self
13390 }
13391 /// Required. The cutover job id
13392 ///
13393 /// Sets the *name* path property to the given value.
13394 ///
13395 /// Even though the property as already been set when instantiating this call,
13396 /// we provide this method for API completeness.
13397 pub fn name(
13398 mut self,
13399 new_value: &str,
13400 ) -> ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C> {
13401 self._name = new_value.to_string();
13402 self
13403 }
13404 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13405 /// while executing the actual API request.
13406 ///
13407 /// ````text
13408 /// It should be used to handle progress information, and to implement a certain level of resilience.
13409 /// ````
13410 ///
13411 /// Sets the *delegate* property to the given value.
13412 pub fn delegate(
13413 mut self,
13414 new_value: &'a mut dyn common::Delegate,
13415 ) -> ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C> {
13416 self._delegate = Some(new_value);
13417 self
13418 }
13419
13420 /// Set any additional parameter of the query string used in the request.
13421 /// It should be used to set parameters which are not yet available through their own
13422 /// setters.
13423 ///
13424 /// Please note that this method must not be used to set any of the known parameters
13425 /// which have their own setter method. If done anyway, the request will fail.
13426 ///
13427 /// # Additional Parameters
13428 ///
13429 /// * *$.xgafv* (query-string) - V1 error format.
13430 /// * *access_token* (query-string) - OAuth access token.
13431 /// * *alt* (query-string) - Data format for response.
13432 /// * *callback* (query-string) - JSONP
13433 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13434 /// * *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.
13435 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13436 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13437 /// * *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.
13438 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13439 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13440 pub fn param<T>(
13441 mut self,
13442 name: T,
13443 value: T,
13444 ) -> ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C>
13445 where
13446 T: AsRef<str>,
13447 {
13448 self._additional_params
13449 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13450 self
13451 }
13452
13453 /// Identifies the authorization scope for the method you are building.
13454 ///
13455 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13456 /// [`Scope::CloudPlatform`].
13457 ///
13458 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13459 /// tokens for more than one scope.
13460 ///
13461 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13462 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13463 /// sufficient, a read-write scope will do as well.
13464 pub fn add_scope<St>(
13465 mut self,
13466 scope: St,
13467 ) -> ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C>
13468 where
13469 St: AsRef<str>,
13470 {
13471 self._scopes.insert(String::from(scope.as_ref()));
13472 self
13473 }
13474 /// Identifies the authorization scope(s) for the method you are building.
13475 ///
13476 /// See [`Self::add_scope()`] for details.
13477 pub fn add_scopes<I, St>(
13478 mut self,
13479 scopes: I,
13480 ) -> ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C>
13481 where
13482 I: IntoIterator<Item = St>,
13483 St: AsRef<str>,
13484 {
13485 self._scopes
13486 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13487 self
13488 }
13489
13490 /// Removes all scopes, and no default scope will be used either.
13491 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13492 /// for details).
13493 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C> {
13494 self._scopes.clear();
13495 self
13496 }
13497}
13498
13499/// Initiates a Cutover of a specific migrating VM. The returned LRO is completed when the cutover job resource is created and the job is initiated.
13500///
13501/// A builder for the *locations.sources.migratingVms.cutoverJobs.create* method supported by a *project* resource.
13502/// It is not used directly, but through a [`ProjectMethods`] instance.
13503///
13504/// # Example
13505///
13506/// Instantiate a resource method builder
13507///
13508/// ```test_harness,no_run
13509/// # extern crate hyper;
13510/// # extern crate hyper_rustls;
13511/// # extern crate google_vmmigration1 as vmmigration1;
13512/// use vmmigration1::api::CutoverJob;
13513/// # async fn dox() {
13514/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13515///
13516/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13517/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13518/// # secret,
13519/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13520/// # ).build().await.unwrap();
13521///
13522/// # let client = hyper_util::client::legacy::Client::builder(
13523/// # hyper_util::rt::TokioExecutor::new()
13524/// # )
13525/// # .build(
13526/// # hyper_rustls::HttpsConnectorBuilder::new()
13527/// # .with_native_roots()
13528/// # .unwrap()
13529/// # .https_or_http()
13530/// # .enable_http1()
13531/// # .build()
13532/// # );
13533/// # let mut hub = VMMigrationService::new(client, auth);
13534/// // As the method needs a request, you would usually fill it with the desired information
13535/// // into the respective structure. Some of the parts shown here might not be applicable !
13536/// // Values shown here are possibly random and not representative !
13537/// let mut req = CutoverJob::default();
13538///
13539/// // You can configure optional parameters by calling the respective setters at will, and
13540/// // execute the final call using `doit()`.
13541/// // Values shown here are possibly random and not representative !
13542/// let result = hub.projects().locations_sources_migrating_vms_cutover_jobs_create(req, "parent")
13543/// .request_id("no")
13544/// .cutover_job_id("ipsum")
13545/// .doit().await;
13546/// # }
13547/// ```
13548pub struct ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C>
13549where
13550 C: 'a,
13551{
13552 hub: &'a VMMigrationService<C>,
13553 _request: CutoverJob,
13554 _parent: String,
13555 _request_id: Option<String>,
13556 _cutover_job_id: Option<String>,
13557 _delegate: Option<&'a mut dyn common::Delegate>,
13558 _additional_params: HashMap<String, String>,
13559 _scopes: BTreeSet<String>,
13560}
13561
13562impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C> {}
13563
13564impl<'a, C> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C>
13565where
13566 C: common::Connector,
13567{
13568 /// Perform the operation you have build so far.
13569 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13570 use std::borrow::Cow;
13571 use std::io::{Read, Seek};
13572
13573 use common::{url::Params, ToParts};
13574 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13575
13576 let mut dd = common::DefaultDelegate;
13577 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13578 dlg.begin(common::MethodInfo {
13579 id: "vmmigration.projects.locations.sources.migratingVms.cutoverJobs.create",
13580 http_method: hyper::Method::POST,
13581 });
13582
13583 for &field in ["alt", "parent", "requestId", "cutoverJobId"].iter() {
13584 if self._additional_params.contains_key(field) {
13585 dlg.finished(false);
13586 return Err(common::Error::FieldClash(field));
13587 }
13588 }
13589
13590 let mut params = Params::with_capacity(6 + self._additional_params.len());
13591 params.push("parent", self._parent);
13592 if let Some(value) = self._request_id.as_ref() {
13593 params.push("requestId", value);
13594 }
13595 if let Some(value) = self._cutover_job_id.as_ref() {
13596 params.push("cutoverJobId", value);
13597 }
13598
13599 params.extend(self._additional_params.iter());
13600
13601 params.push("alt", "json");
13602 let mut url = self.hub._base_url.clone() + "v1/{+parent}/cutoverJobs";
13603 if self._scopes.is_empty() {
13604 self._scopes
13605 .insert(Scope::CloudPlatform.as_ref().to_string());
13606 }
13607
13608 #[allow(clippy::single_element_loop)]
13609 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13610 url = params.uri_replacement(url, param_name, find_this, true);
13611 }
13612 {
13613 let to_remove = ["parent"];
13614 params.remove_params(&to_remove);
13615 }
13616
13617 let url = params.parse_with_url(&url);
13618
13619 let mut json_mime_type = mime::APPLICATION_JSON;
13620 let mut request_value_reader = {
13621 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13622 common::remove_json_null_values(&mut value);
13623 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13624 serde_json::to_writer(&mut dst, &value).unwrap();
13625 dst
13626 };
13627 let request_size = request_value_reader
13628 .seek(std::io::SeekFrom::End(0))
13629 .unwrap();
13630 request_value_reader
13631 .seek(std::io::SeekFrom::Start(0))
13632 .unwrap();
13633
13634 loop {
13635 let token = match self
13636 .hub
13637 .auth
13638 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13639 .await
13640 {
13641 Ok(token) => token,
13642 Err(e) => match dlg.token(e) {
13643 Ok(token) => token,
13644 Err(e) => {
13645 dlg.finished(false);
13646 return Err(common::Error::MissingToken(e));
13647 }
13648 },
13649 };
13650 request_value_reader
13651 .seek(std::io::SeekFrom::Start(0))
13652 .unwrap();
13653 let mut req_result = {
13654 let client = &self.hub.client;
13655 dlg.pre_request();
13656 let mut req_builder = hyper::Request::builder()
13657 .method(hyper::Method::POST)
13658 .uri(url.as_str())
13659 .header(USER_AGENT, self.hub._user_agent.clone());
13660
13661 if let Some(token) = token.as_ref() {
13662 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13663 }
13664
13665 let request = req_builder
13666 .header(CONTENT_TYPE, json_mime_type.to_string())
13667 .header(CONTENT_LENGTH, request_size as u64)
13668 .body(common::to_body(
13669 request_value_reader.get_ref().clone().into(),
13670 ));
13671
13672 client.request(request.unwrap()).await
13673 };
13674
13675 match req_result {
13676 Err(err) => {
13677 if let common::Retry::After(d) = dlg.http_error(&err) {
13678 sleep(d).await;
13679 continue;
13680 }
13681 dlg.finished(false);
13682 return Err(common::Error::HttpError(err));
13683 }
13684 Ok(res) => {
13685 let (mut parts, body) = res.into_parts();
13686 let mut body = common::Body::new(body);
13687 if !parts.status.is_success() {
13688 let bytes = common::to_bytes(body).await.unwrap_or_default();
13689 let error = serde_json::from_str(&common::to_string(&bytes));
13690 let response = common::to_response(parts, bytes.into());
13691
13692 if let common::Retry::After(d) =
13693 dlg.http_failure(&response, error.as_ref().ok())
13694 {
13695 sleep(d).await;
13696 continue;
13697 }
13698
13699 dlg.finished(false);
13700
13701 return Err(match error {
13702 Ok(value) => common::Error::BadRequest(value),
13703 _ => common::Error::Failure(response),
13704 });
13705 }
13706 let response = {
13707 let bytes = common::to_bytes(body).await.unwrap_or_default();
13708 let encoded = common::to_string(&bytes);
13709 match serde_json::from_str(&encoded) {
13710 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13711 Err(error) => {
13712 dlg.response_json_decode_error(&encoded, &error);
13713 return Err(common::Error::JsonDecodeError(
13714 encoded.to_string(),
13715 error,
13716 ));
13717 }
13718 }
13719 };
13720
13721 dlg.finished(true);
13722 return Ok(response);
13723 }
13724 }
13725 }
13726 }
13727
13728 ///
13729 /// Sets the *request* property to the given value.
13730 ///
13731 /// Even though the property as already been set when instantiating this call,
13732 /// we provide this method for API completeness.
13733 pub fn request(
13734 mut self,
13735 new_value: CutoverJob,
13736 ) -> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C> {
13737 self._request = new_value;
13738 self
13739 }
13740 /// Required. The Cutover's parent.
13741 ///
13742 /// Sets the *parent* path property to the given value.
13743 ///
13744 /// Even though the property as already been set when instantiating this call,
13745 /// we provide this method for API completeness.
13746 pub fn parent(
13747 mut self,
13748 new_value: &str,
13749 ) -> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C> {
13750 self._parent = new_value.to_string();
13751 self
13752 }
13753 /// A request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes since the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
13754 ///
13755 /// Sets the *request id* query property to the given value.
13756 pub fn request_id(
13757 mut self,
13758 new_value: &str,
13759 ) -> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C> {
13760 self._request_id = Some(new_value.to_string());
13761 self
13762 }
13763 /// Required. The cutover job identifier.
13764 ///
13765 /// Sets the *cutover job id* query property to the given value.
13766 pub fn cutover_job_id(
13767 mut self,
13768 new_value: &str,
13769 ) -> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C> {
13770 self._cutover_job_id = Some(new_value.to_string());
13771 self
13772 }
13773 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13774 /// while executing the actual API request.
13775 ///
13776 /// ````text
13777 /// It should be used to handle progress information, and to implement a certain level of resilience.
13778 /// ````
13779 ///
13780 /// Sets the *delegate* property to the given value.
13781 pub fn delegate(
13782 mut self,
13783 new_value: &'a mut dyn common::Delegate,
13784 ) -> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C> {
13785 self._delegate = Some(new_value);
13786 self
13787 }
13788
13789 /// Set any additional parameter of the query string used in the request.
13790 /// It should be used to set parameters which are not yet available through their own
13791 /// setters.
13792 ///
13793 /// Please note that this method must not be used to set any of the known parameters
13794 /// which have their own setter method. If done anyway, the request will fail.
13795 ///
13796 /// # Additional Parameters
13797 ///
13798 /// * *$.xgafv* (query-string) - V1 error format.
13799 /// * *access_token* (query-string) - OAuth access token.
13800 /// * *alt* (query-string) - Data format for response.
13801 /// * *callback* (query-string) - JSONP
13802 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13803 /// * *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.
13804 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13805 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13806 /// * *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.
13807 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13808 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13809 pub fn param<T>(
13810 mut self,
13811 name: T,
13812 value: T,
13813 ) -> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C>
13814 where
13815 T: AsRef<str>,
13816 {
13817 self._additional_params
13818 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13819 self
13820 }
13821
13822 /// Identifies the authorization scope for the method you are building.
13823 ///
13824 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13825 /// [`Scope::CloudPlatform`].
13826 ///
13827 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13828 /// tokens for more than one scope.
13829 ///
13830 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13831 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13832 /// sufficient, a read-write scope will do as well.
13833 pub fn add_scope<St>(
13834 mut self,
13835 scope: St,
13836 ) -> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C>
13837 where
13838 St: AsRef<str>,
13839 {
13840 self._scopes.insert(String::from(scope.as_ref()));
13841 self
13842 }
13843 /// Identifies the authorization scope(s) for the method you are building.
13844 ///
13845 /// See [`Self::add_scope()`] for details.
13846 pub fn add_scopes<I, St>(
13847 mut self,
13848 scopes: I,
13849 ) -> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C>
13850 where
13851 I: IntoIterator<Item = St>,
13852 St: AsRef<str>,
13853 {
13854 self._scopes
13855 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13856 self
13857 }
13858
13859 /// Removes all scopes, and no default scope will be used either.
13860 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13861 /// for details).
13862 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C> {
13863 self._scopes.clear();
13864 self
13865 }
13866}
13867
13868/// Gets details of a single CutoverJob.
13869///
13870/// A builder for the *locations.sources.migratingVms.cutoverJobs.get* method supported by a *project* resource.
13871/// It is not used directly, but through a [`ProjectMethods`] instance.
13872///
13873/// # Example
13874///
13875/// Instantiate a resource method builder
13876///
13877/// ```test_harness,no_run
13878/// # extern crate hyper;
13879/// # extern crate hyper_rustls;
13880/// # extern crate google_vmmigration1 as vmmigration1;
13881/// # async fn dox() {
13882/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13883///
13884/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13885/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13886/// # secret,
13887/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13888/// # ).build().await.unwrap();
13889///
13890/// # let client = hyper_util::client::legacy::Client::builder(
13891/// # hyper_util::rt::TokioExecutor::new()
13892/// # )
13893/// # .build(
13894/// # hyper_rustls::HttpsConnectorBuilder::new()
13895/// # .with_native_roots()
13896/// # .unwrap()
13897/// # .https_or_http()
13898/// # .enable_http1()
13899/// # .build()
13900/// # );
13901/// # let mut hub = VMMigrationService::new(client, auth);
13902/// // You can configure optional parameters by calling the respective setters at will, and
13903/// // execute the final call using `doit()`.
13904/// // Values shown here are possibly random and not representative !
13905/// let result = hub.projects().locations_sources_migrating_vms_cutover_jobs_get("name")
13906/// .doit().await;
13907/// # }
13908/// ```
13909pub struct ProjectLocationSourceMigratingVmCutoverJobGetCall<'a, C>
13910where
13911 C: 'a,
13912{
13913 hub: &'a VMMigrationService<C>,
13914 _name: String,
13915 _delegate: Option<&'a mut dyn common::Delegate>,
13916 _additional_params: HashMap<String, String>,
13917 _scopes: BTreeSet<String>,
13918}
13919
13920impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmCutoverJobGetCall<'a, C> {}
13921
13922impl<'a, C> ProjectLocationSourceMigratingVmCutoverJobGetCall<'a, C>
13923where
13924 C: common::Connector,
13925{
13926 /// Perform the operation you have build so far.
13927 pub async fn doit(mut self) -> common::Result<(common::Response, CutoverJob)> {
13928 use std::borrow::Cow;
13929 use std::io::{Read, Seek};
13930
13931 use common::{url::Params, ToParts};
13932 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13933
13934 let mut dd = common::DefaultDelegate;
13935 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13936 dlg.begin(common::MethodInfo {
13937 id: "vmmigration.projects.locations.sources.migratingVms.cutoverJobs.get",
13938 http_method: hyper::Method::GET,
13939 });
13940
13941 for &field in ["alt", "name"].iter() {
13942 if self._additional_params.contains_key(field) {
13943 dlg.finished(false);
13944 return Err(common::Error::FieldClash(field));
13945 }
13946 }
13947
13948 let mut params = Params::with_capacity(3 + self._additional_params.len());
13949 params.push("name", self._name);
13950
13951 params.extend(self._additional_params.iter());
13952
13953 params.push("alt", "json");
13954 let mut url = self.hub._base_url.clone() + "v1/{+name}";
13955 if self._scopes.is_empty() {
13956 self._scopes
13957 .insert(Scope::CloudPlatform.as_ref().to_string());
13958 }
13959
13960 #[allow(clippy::single_element_loop)]
13961 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13962 url = params.uri_replacement(url, param_name, find_this, true);
13963 }
13964 {
13965 let to_remove = ["name"];
13966 params.remove_params(&to_remove);
13967 }
13968
13969 let url = params.parse_with_url(&url);
13970
13971 loop {
13972 let token = match self
13973 .hub
13974 .auth
13975 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13976 .await
13977 {
13978 Ok(token) => token,
13979 Err(e) => match dlg.token(e) {
13980 Ok(token) => token,
13981 Err(e) => {
13982 dlg.finished(false);
13983 return Err(common::Error::MissingToken(e));
13984 }
13985 },
13986 };
13987 let mut req_result = {
13988 let client = &self.hub.client;
13989 dlg.pre_request();
13990 let mut req_builder = hyper::Request::builder()
13991 .method(hyper::Method::GET)
13992 .uri(url.as_str())
13993 .header(USER_AGENT, self.hub._user_agent.clone());
13994
13995 if let Some(token) = token.as_ref() {
13996 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13997 }
13998
13999 let request = req_builder
14000 .header(CONTENT_LENGTH, 0_u64)
14001 .body(common::to_body::<String>(None));
14002
14003 client.request(request.unwrap()).await
14004 };
14005
14006 match req_result {
14007 Err(err) => {
14008 if let common::Retry::After(d) = dlg.http_error(&err) {
14009 sleep(d).await;
14010 continue;
14011 }
14012 dlg.finished(false);
14013 return Err(common::Error::HttpError(err));
14014 }
14015 Ok(res) => {
14016 let (mut parts, body) = res.into_parts();
14017 let mut body = common::Body::new(body);
14018 if !parts.status.is_success() {
14019 let bytes = common::to_bytes(body).await.unwrap_or_default();
14020 let error = serde_json::from_str(&common::to_string(&bytes));
14021 let response = common::to_response(parts, bytes.into());
14022
14023 if let common::Retry::After(d) =
14024 dlg.http_failure(&response, error.as_ref().ok())
14025 {
14026 sleep(d).await;
14027 continue;
14028 }
14029
14030 dlg.finished(false);
14031
14032 return Err(match error {
14033 Ok(value) => common::Error::BadRequest(value),
14034 _ => common::Error::Failure(response),
14035 });
14036 }
14037 let response = {
14038 let bytes = common::to_bytes(body).await.unwrap_or_default();
14039 let encoded = common::to_string(&bytes);
14040 match serde_json::from_str(&encoded) {
14041 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14042 Err(error) => {
14043 dlg.response_json_decode_error(&encoded, &error);
14044 return Err(common::Error::JsonDecodeError(
14045 encoded.to_string(),
14046 error,
14047 ));
14048 }
14049 }
14050 };
14051
14052 dlg.finished(true);
14053 return Ok(response);
14054 }
14055 }
14056 }
14057 }
14058
14059 /// Required. The name of the CutoverJob.
14060 ///
14061 /// Sets the *name* path property to the given value.
14062 ///
14063 /// Even though the property as already been set when instantiating this call,
14064 /// we provide this method for API completeness.
14065 pub fn name(
14066 mut self,
14067 new_value: &str,
14068 ) -> ProjectLocationSourceMigratingVmCutoverJobGetCall<'a, C> {
14069 self._name = new_value.to_string();
14070 self
14071 }
14072 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14073 /// while executing the actual API request.
14074 ///
14075 /// ````text
14076 /// It should be used to handle progress information, and to implement a certain level of resilience.
14077 /// ````
14078 ///
14079 /// Sets the *delegate* property to the given value.
14080 pub fn delegate(
14081 mut self,
14082 new_value: &'a mut dyn common::Delegate,
14083 ) -> ProjectLocationSourceMigratingVmCutoverJobGetCall<'a, C> {
14084 self._delegate = Some(new_value);
14085 self
14086 }
14087
14088 /// Set any additional parameter of the query string used in the request.
14089 /// It should be used to set parameters which are not yet available through their own
14090 /// setters.
14091 ///
14092 /// Please note that this method must not be used to set any of the known parameters
14093 /// which have their own setter method. If done anyway, the request will fail.
14094 ///
14095 /// # Additional Parameters
14096 ///
14097 /// * *$.xgafv* (query-string) - V1 error format.
14098 /// * *access_token* (query-string) - OAuth access token.
14099 /// * *alt* (query-string) - Data format for response.
14100 /// * *callback* (query-string) - JSONP
14101 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14102 /// * *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.
14103 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14104 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14105 /// * *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.
14106 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14107 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14108 pub fn param<T>(
14109 mut self,
14110 name: T,
14111 value: T,
14112 ) -> ProjectLocationSourceMigratingVmCutoverJobGetCall<'a, C>
14113 where
14114 T: AsRef<str>,
14115 {
14116 self._additional_params
14117 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14118 self
14119 }
14120
14121 /// Identifies the authorization scope for the method you are building.
14122 ///
14123 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14124 /// [`Scope::CloudPlatform`].
14125 ///
14126 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14127 /// tokens for more than one scope.
14128 ///
14129 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14130 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14131 /// sufficient, a read-write scope will do as well.
14132 pub fn add_scope<St>(
14133 mut self,
14134 scope: St,
14135 ) -> ProjectLocationSourceMigratingVmCutoverJobGetCall<'a, C>
14136 where
14137 St: AsRef<str>,
14138 {
14139 self._scopes.insert(String::from(scope.as_ref()));
14140 self
14141 }
14142 /// Identifies the authorization scope(s) for the method you are building.
14143 ///
14144 /// See [`Self::add_scope()`] for details.
14145 pub fn add_scopes<I, St>(
14146 mut self,
14147 scopes: I,
14148 ) -> ProjectLocationSourceMigratingVmCutoverJobGetCall<'a, C>
14149 where
14150 I: IntoIterator<Item = St>,
14151 St: AsRef<str>,
14152 {
14153 self._scopes
14154 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14155 self
14156 }
14157
14158 /// Removes all scopes, and no default scope will be used either.
14159 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14160 /// for details).
14161 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmCutoverJobGetCall<'a, C> {
14162 self._scopes.clear();
14163 self
14164 }
14165}
14166
14167/// Lists the CutoverJobs of a migrating VM. Only 25 most recent CutoverJobs are listed.
14168///
14169/// A builder for the *locations.sources.migratingVms.cutoverJobs.list* method supported by a *project* resource.
14170/// It is not used directly, but through a [`ProjectMethods`] instance.
14171///
14172/// # Example
14173///
14174/// Instantiate a resource method builder
14175///
14176/// ```test_harness,no_run
14177/// # extern crate hyper;
14178/// # extern crate hyper_rustls;
14179/// # extern crate google_vmmigration1 as vmmigration1;
14180/// # async fn dox() {
14181/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14182///
14183/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14184/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14185/// # secret,
14186/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14187/// # ).build().await.unwrap();
14188///
14189/// # let client = hyper_util::client::legacy::Client::builder(
14190/// # hyper_util::rt::TokioExecutor::new()
14191/// # )
14192/// # .build(
14193/// # hyper_rustls::HttpsConnectorBuilder::new()
14194/// # .with_native_roots()
14195/// # .unwrap()
14196/// # .https_or_http()
14197/// # .enable_http1()
14198/// # .build()
14199/// # );
14200/// # let mut hub = VMMigrationService::new(client, auth);
14201/// // You can configure optional parameters by calling the respective setters at will, and
14202/// // execute the final call using `doit()`.
14203/// // Values shown here are possibly random and not representative !
14204/// let result = hub.projects().locations_sources_migrating_vms_cutover_jobs_list("parent")
14205/// .page_token("consetetur")
14206/// .page_size(-28)
14207/// .order_by("et")
14208/// .filter("erat")
14209/// .doit().await;
14210/// # }
14211/// ```
14212pub struct ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C>
14213where
14214 C: 'a,
14215{
14216 hub: &'a VMMigrationService<C>,
14217 _parent: String,
14218 _page_token: Option<String>,
14219 _page_size: Option<i32>,
14220 _order_by: Option<String>,
14221 _filter: Option<String>,
14222 _delegate: Option<&'a mut dyn common::Delegate>,
14223 _additional_params: HashMap<String, String>,
14224 _scopes: BTreeSet<String>,
14225}
14226
14227impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C> {}
14228
14229impl<'a, C> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C>
14230where
14231 C: common::Connector,
14232{
14233 /// Perform the operation you have build so far.
14234 pub async fn doit(mut self) -> common::Result<(common::Response, ListCutoverJobsResponse)> {
14235 use std::borrow::Cow;
14236 use std::io::{Read, Seek};
14237
14238 use common::{url::Params, ToParts};
14239 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14240
14241 let mut dd = common::DefaultDelegate;
14242 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14243 dlg.begin(common::MethodInfo {
14244 id: "vmmigration.projects.locations.sources.migratingVms.cutoverJobs.list",
14245 http_method: hyper::Method::GET,
14246 });
14247
14248 for &field in [
14249 "alt",
14250 "parent",
14251 "pageToken",
14252 "pageSize",
14253 "orderBy",
14254 "filter",
14255 ]
14256 .iter()
14257 {
14258 if self._additional_params.contains_key(field) {
14259 dlg.finished(false);
14260 return Err(common::Error::FieldClash(field));
14261 }
14262 }
14263
14264 let mut params = Params::with_capacity(7 + self._additional_params.len());
14265 params.push("parent", self._parent);
14266 if let Some(value) = self._page_token.as_ref() {
14267 params.push("pageToken", value);
14268 }
14269 if let Some(value) = self._page_size.as_ref() {
14270 params.push("pageSize", value.to_string());
14271 }
14272 if let Some(value) = self._order_by.as_ref() {
14273 params.push("orderBy", value);
14274 }
14275 if let Some(value) = self._filter.as_ref() {
14276 params.push("filter", value);
14277 }
14278
14279 params.extend(self._additional_params.iter());
14280
14281 params.push("alt", "json");
14282 let mut url = self.hub._base_url.clone() + "v1/{+parent}/cutoverJobs";
14283 if self._scopes.is_empty() {
14284 self._scopes
14285 .insert(Scope::CloudPlatform.as_ref().to_string());
14286 }
14287
14288 #[allow(clippy::single_element_loop)]
14289 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14290 url = params.uri_replacement(url, param_name, find_this, true);
14291 }
14292 {
14293 let to_remove = ["parent"];
14294 params.remove_params(&to_remove);
14295 }
14296
14297 let url = params.parse_with_url(&url);
14298
14299 loop {
14300 let token = match self
14301 .hub
14302 .auth
14303 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14304 .await
14305 {
14306 Ok(token) => token,
14307 Err(e) => match dlg.token(e) {
14308 Ok(token) => token,
14309 Err(e) => {
14310 dlg.finished(false);
14311 return Err(common::Error::MissingToken(e));
14312 }
14313 },
14314 };
14315 let mut req_result = {
14316 let client = &self.hub.client;
14317 dlg.pre_request();
14318 let mut req_builder = hyper::Request::builder()
14319 .method(hyper::Method::GET)
14320 .uri(url.as_str())
14321 .header(USER_AGENT, self.hub._user_agent.clone());
14322
14323 if let Some(token) = token.as_ref() {
14324 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14325 }
14326
14327 let request = req_builder
14328 .header(CONTENT_LENGTH, 0_u64)
14329 .body(common::to_body::<String>(None));
14330
14331 client.request(request.unwrap()).await
14332 };
14333
14334 match req_result {
14335 Err(err) => {
14336 if let common::Retry::After(d) = dlg.http_error(&err) {
14337 sleep(d).await;
14338 continue;
14339 }
14340 dlg.finished(false);
14341 return Err(common::Error::HttpError(err));
14342 }
14343 Ok(res) => {
14344 let (mut parts, body) = res.into_parts();
14345 let mut body = common::Body::new(body);
14346 if !parts.status.is_success() {
14347 let bytes = common::to_bytes(body).await.unwrap_or_default();
14348 let error = serde_json::from_str(&common::to_string(&bytes));
14349 let response = common::to_response(parts, bytes.into());
14350
14351 if let common::Retry::After(d) =
14352 dlg.http_failure(&response, error.as_ref().ok())
14353 {
14354 sleep(d).await;
14355 continue;
14356 }
14357
14358 dlg.finished(false);
14359
14360 return Err(match error {
14361 Ok(value) => common::Error::BadRequest(value),
14362 _ => common::Error::Failure(response),
14363 });
14364 }
14365 let response = {
14366 let bytes = common::to_bytes(body).await.unwrap_or_default();
14367 let encoded = common::to_string(&bytes);
14368 match serde_json::from_str(&encoded) {
14369 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14370 Err(error) => {
14371 dlg.response_json_decode_error(&encoded, &error);
14372 return Err(common::Error::JsonDecodeError(
14373 encoded.to_string(),
14374 error,
14375 ));
14376 }
14377 }
14378 };
14379
14380 dlg.finished(true);
14381 return Ok(response);
14382 }
14383 }
14384 }
14385 }
14386
14387 /// Required. The parent, which owns this collection of migrating VMs.
14388 ///
14389 /// Sets the *parent* path property to the given value.
14390 ///
14391 /// Even though the property as already been set when instantiating this call,
14392 /// we provide this method for API completeness.
14393 pub fn parent(
14394 mut self,
14395 new_value: &str,
14396 ) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C> {
14397 self._parent = new_value.to_string();
14398 self
14399 }
14400 /// Required. A page token, received from a previous `ListCutoverJobs` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListCutoverJobs` must match the call that provided the page token.
14401 ///
14402 /// Sets the *page token* query property to the given value.
14403 pub fn page_token(
14404 mut self,
14405 new_value: &str,
14406 ) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C> {
14407 self._page_token = Some(new_value.to_string());
14408 self
14409 }
14410 /// Optional. The maximum number of cutover jobs to return. The service may return fewer than this value. If unspecified, at most 500 cutover jobs will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
14411 ///
14412 /// Sets the *page size* query property to the given value.
14413 pub fn page_size(
14414 mut self,
14415 new_value: i32,
14416 ) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C> {
14417 self._page_size = Some(new_value);
14418 self
14419 }
14420 /// Optional. the order by fields for the result.
14421 ///
14422 /// Sets the *order by* query property to the given value.
14423 pub fn order_by(
14424 mut self,
14425 new_value: &str,
14426 ) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C> {
14427 self._order_by = Some(new_value.to_string());
14428 self
14429 }
14430 /// Optional. The filter request.
14431 ///
14432 /// Sets the *filter* query property to the given value.
14433 pub fn filter(
14434 mut self,
14435 new_value: &str,
14436 ) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C> {
14437 self._filter = Some(new_value.to_string());
14438 self
14439 }
14440 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14441 /// while executing the actual API request.
14442 ///
14443 /// ````text
14444 /// It should be used to handle progress information, and to implement a certain level of resilience.
14445 /// ````
14446 ///
14447 /// Sets the *delegate* property to the given value.
14448 pub fn delegate(
14449 mut self,
14450 new_value: &'a mut dyn common::Delegate,
14451 ) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C> {
14452 self._delegate = Some(new_value);
14453 self
14454 }
14455
14456 /// Set any additional parameter of the query string used in the request.
14457 /// It should be used to set parameters which are not yet available through their own
14458 /// setters.
14459 ///
14460 /// Please note that this method must not be used to set any of the known parameters
14461 /// which have their own setter method. If done anyway, the request will fail.
14462 ///
14463 /// # Additional Parameters
14464 ///
14465 /// * *$.xgafv* (query-string) - V1 error format.
14466 /// * *access_token* (query-string) - OAuth access token.
14467 /// * *alt* (query-string) - Data format for response.
14468 /// * *callback* (query-string) - JSONP
14469 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14470 /// * *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.
14471 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14472 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14473 /// * *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.
14474 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14475 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14476 pub fn param<T>(
14477 mut self,
14478 name: T,
14479 value: T,
14480 ) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C>
14481 where
14482 T: AsRef<str>,
14483 {
14484 self._additional_params
14485 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14486 self
14487 }
14488
14489 /// Identifies the authorization scope for the method you are building.
14490 ///
14491 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14492 /// [`Scope::CloudPlatform`].
14493 ///
14494 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14495 /// tokens for more than one scope.
14496 ///
14497 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14498 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14499 /// sufficient, a read-write scope will do as well.
14500 pub fn add_scope<St>(
14501 mut self,
14502 scope: St,
14503 ) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C>
14504 where
14505 St: AsRef<str>,
14506 {
14507 self._scopes.insert(String::from(scope.as_ref()));
14508 self
14509 }
14510 /// Identifies the authorization scope(s) for the method you are building.
14511 ///
14512 /// See [`Self::add_scope()`] for details.
14513 pub fn add_scopes<I, St>(
14514 mut self,
14515 scopes: I,
14516 ) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C>
14517 where
14518 I: IntoIterator<Item = St>,
14519 St: AsRef<str>,
14520 {
14521 self._scopes
14522 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14523 self
14524 }
14525
14526 /// Removes all scopes, and no default scope will be used either.
14527 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14528 /// for details).
14529 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C> {
14530 self._scopes.clear();
14531 self
14532 }
14533}
14534
14535/// Gets details of a single ReplicationCycle.
14536///
14537/// A builder for the *locations.sources.migratingVms.replicationCycles.get* method supported by a *project* resource.
14538/// It is not used directly, but through a [`ProjectMethods`] instance.
14539///
14540/// # Example
14541///
14542/// Instantiate a resource method builder
14543///
14544/// ```test_harness,no_run
14545/// # extern crate hyper;
14546/// # extern crate hyper_rustls;
14547/// # extern crate google_vmmigration1 as vmmigration1;
14548/// # async fn dox() {
14549/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14550///
14551/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14552/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14553/// # secret,
14554/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14555/// # ).build().await.unwrap();
14556///
14557/// # let client = hyper_util::client::legacy::Client::builder(
14558/// # hyper_util::rt::TokioExecutor::new()
14559/// # )
14560/// # .build(
14561/// # hyper_rustls::HttpsConnectorBuilder::new()
14562/// # .with_native_roots()
14563/// # .unwrap()
14564/// # .https_or_http()
14565/// # .enable_http1()
14566/// # .build()
14567/// # );
14568/// # let mut hub = VMMigrationService::new(client, auth);
14569/// // You can configure optional parameters by calling the respective setters at will, and
14570/// // execute the final call using `doit()`.
14571/// // Values shown here are possibly random and not representative !
14572/// let result = hub.projects().locations_sources_migrating_vms_replication_cycles_get("name")
14573/// .doit().await;
14574/// # }
14575/// ```
14576pub struct ProjectLocationSourceMigratingVmReplicationCycleGetCall<'a, C>
14577where
14578 C: 'a,
14579{
14580 hub: &'a VMMigrationService<C>,
14581 _name: String,
14582 _delegate: Option<&'a mut dyn common::Delegate>,
14583 _additional_params: HashMap<String, String>,
14584 _scopes: BTreeSet<String>,
14585}
14586
14587impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmReplicationCycleGetCall<'a, C> {}
14588
14589impl<'a, C> ProjectLocationSourceMigratingVmReplicationCycleGetCall<'a, C>
14590where
14591 C: common::Connector,
14592{
14593 /// Perform the operation you have build so far.
14594 pub async fn doit(mut self) -> common::Result<(common::Response, ReplicationCycle)> {
14595 use std::borrow::Cow;
14596 use std::io::{Read, Seek};
14597
14598 use common::{url::Params, ToParts};
14599 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14600
14601 let mut dd = common::DefaultDelegate;
14602 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14603 dlg.begin(common::MethodInfo {
14604 id: "vmmigration.projects.locations.sources.migratingVms.replicationCycles.get",
14605 http_method: hyper::Method::GET,
14606 });
14607
14608 for &field in ["alt", "name"].iter() {
14609 if self._additional_params.contains_key(field) {
14610 dlg.finished(false);
14611 return Err(common::Error::FieldClash(field));
14612 }
14613 }
14614
14615 let mut params = Params::with_capacity(3 + self._additional_params.len());
14616 params.push("name", self._name);
14617
14618 params.extend(self._additional_params.iter());
14619
14620 params.push("alt", "json");
14621 let mut url = self.hub._base_url.clone() + "v1/{+name}";
14622 if self._scopes.is_empty() {
14623 self._scopes
14624 .insert(Scope::CloudPlatform.as_ref().to_string());
14625 }
14626
14627 #[allow(clippy::single_element_loop)]
14628 for &(find_this, param_name) in [("{+name}", "name")].iter() {
14629 url = params.uri_replacement(url, param_name, find_this, true);
14630 }
14631 {
14632 let to_remove = ["name"];
14633 params.remove_params(&to_remove);
14634 }
14635
14636 let url = params.parse_with_url(&url);
14637
14638 loop {
14639 let token = match self
14640 .hub
14641 .auth
14642 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14643 .await
14644 {
14645 Ok(token) => token,
14646 Err(e) => match dlg.token(e) {
14647 Ok(token) => token,
14648 Err(e) => {
14649 dlg.finished(false);
14650 return Err(common::Error::MissingToken(e));
14651 }
14652 },
14653 };
14654 let mut req_result = {
14655 let client = &self.hub.client;
14656 dlg.pre_request();
14657 let mut req_builder = hyper::Request::builder()
14658 .method(hyper::Method::GET)
14659 .uri(url.as_str())
14660 .header(USER_AGENT, self.hub._user_agent.clone());
14661
14662 if let Some(token) = token.as_ref() {
14663 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14664 }
14665
14666 let request = req_builder
14667 .header(CONTENT_LENGTH, 0_u64)
14668 .body(common::to_body::<String>(None));
14669
14670 client.request(request.unwrap()).await
14671 };
14672
14673 match req_result {
14674 Err(err) => {
14675 if let common::Retry::After(d) = dlg.http_error(&err) {
14676 sleep(d).await;
14677 continue;
14678 }
14679 dlg.finished(false);
14680 return Err(common::Error::HttpError(err));
14681 }
14682 Ok(res) => {
14683 let (mut parts, body) = res.into_parts();
14684 let mut body = common::Body::new(body);
14685 if !parts.status.is_success() {
14686 let bytes = common::to_bytes(body).await.unwrap_or_default();
14687 let error = serde_json::from_str(&common::to_string(&bytes));
14688 let response = common::to_response(parts, bytes.into());
14689
14690 if let common::Retry::After(d) =
14691 dlg.http_failure(&response, error.as_ref().ok())
14692 {
14693 sleep(d).await;
14694 continue;
14695 }
14696
14697 dlg.finished(false);
14698
14699 return Err(match error {
14700 Ok(value) => common::Error::BadRequest(value),
14701 _ => common::Error::Failure(response),
14702 });
14703 }
14704 let response = {
14705 let bytes = common::to_bytes(body).await.unwrap_or_default();
14706 let encoded = common::to_string(&bytes);
14707 match serde_json::from_str(&encoded) {
14708 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14709 Err(error) => {
14710 dlg.response_json_decode_error(&encoded, &error);
14711 return Err(common::Error::JsonDecodeError(
14712 encoded.to_string(),
14713 error,
14714 ));
14715 }
14716 }
14717 };
14718
14719 dlg.finished(true);
14720 return Ok(response);
14721 }
14722 }
14723 }
14724 }
14725
14726 /// Required. The name of the ReplicationCycle.
14727 ///
14728 /// Sets the *name* path property to the given value.
14729 ///
14730 /// Even though the property as already been set when instantiating this call,
14731 /// we provide this method for API completeness.
14732 pub fn name(
14733 mut self,
14734 new_value: &str,
14735 ) -> ProjectLocationSourceMigratingVmReplicationCycleGetCall<'a, C> {
14736 self._name = new_value.to_string();
14737 self
14738 }
14739 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14740 /// while executing the actual API request.
14741 ///
14742 /// ````text
14743 /// It should be used to handle progress information, and to implement a certain level of resilience.
14744 /// ````
14745 ///
14746 /// Sets the *delegate* property to the given value.
14747 pub fn delegate(
14748 mut self,
14749 new_value: &'a mut dyn common::Delegate,
14750 ) -> ProjectLocationSourceMigratingVmReplicationCycleGetCall<'a, C> {
14751 self._delegate = Some(new_value);
14752 self
14753 }
14754
14755 /// Set any additional parameter of the query string used in the request.
14756 /// It should be used to set parameters which are not yet available through their own
14757 /// setters.
14758 ///
14759 /// Please note that this method must not be used to set any of the known parameters
14760 /// which have their own setter method. If done anyway, the request will fail.
14761 ///
14762 /// # Additional Parameters
14763 ///
14764 /// * *$.xgafv* (query-string) - V1 error format.
14765 /// * *access_token* (query-string) - OAuth access token.
14766 /// * *alt* (query-string) - Data format for response.
14767 /// * *callback* (query-string) - JSONP
14768 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14769 /// * *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.
14770 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14771 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14772 /// * *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.
14773 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14774 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14775 pub fn param<T>(
14776 mut self,
14777 name: T,
14778 value: T,
14779 ) -> ProjectLocationSourceMigratingVmReplicationCycleGetCall<'a, C>
14780 where
14781 T: AsRef<str>,
14782 {
14783 self._additional_params
14784 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14785 self
14786 }
14787
14788 /// Identifies the authorization scope for the method you are building.
14789 ///
14790 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14791 /// [`Scope::CloudPlatform`].
14792 ///
14793 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14794 /// tokens for more than one scope.
14795 ///
14796 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14797 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14798 /// sufficient, a read-write scope will do as well.
14799 pub fn add_scope<St>(
14800 mut self,
14801 scope: St,
14802 ) -> ProjectLocationSourceMigratingVmReplicationCycleGetCall<'a, C>
14803 where
14804 St: AsRef<str>,
14805 {
14806 self._scopes.insert(String::from(scope.as_ref()));
14807 self
14808 }
14809 /// Identifies the authorization scope(s) for the method you are building.
14810 ///
14811 /// See [`Self::add_scope()`] for details.
14812 pub fn add_scopes<I, St>(
14813 mut self,
14814 scopes: I,
14815 ) -> ProjectLocationSourceMigratingVmReplicationCycleGetCall<'a, C>
14816 where
14817 I: IntoIterator<Item = St>,
14818 St: AsRef<str>,
14819 {
14820 self._scopes
14821 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14822 self
14823 }
14824
14825 /// Removes all scopes, and no default scope will be used either.
14826 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14827 /// for details).
14828 pub fn clear_scopes(
14829 mut self,
14830 ) -> ProjectLocationSourceMigratingVmReplicationCycleGetCall<'a, C> {
14831 self._scopes.clear();
14832 self
14833 }
14834}
14835
14836/// Lists ReplicationCycles in a given MigratingVM.
14837///
14838/// A builder for the *locations.sources.migratingVms.replicationCycles.list* method supported by a *project* resource.
14839/// It is not used directly, but through a [`ProjectMethods`] instance.
14840///
14841/// # Example
14842///
14843/// Instantiate a resource method builder
14844///
14845/// ```test_harness,no_run
14846/// # extern crate hyper;
14847/// # extern crate hyper_rustls;
14848/// # extern crate google_vmmigration1 as vmmigration1;
14849/// # async fn dox() {
14850/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14851///
14852/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14853/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14854/// # secret,
14855/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14856/// # ).build().await.unwrap();
14857///
14858/// # let client = hyper_util::client::legacy::Client::builder(
14859/// # hyper_util::rt::TokioExecutor::new()
14860/// # )
14861/// # .build(
14862/// # hyper_rustls::HttpsConnectorBuilder::new()
14863/// # .with_native_roots()
14864/// # .unwrap()
14865/// # .https_or_http()
14866/// # .enable_http1()
14867/// # .build()
14868/// # );
14869/// # let mut hub = VMMigrationService::new(client, auth);
14870/// // You can configure optional parameters by calling the respective setters at will, and
14871/// // execute the final call using `doit()`.
14872/// // Values shown here are possibly random and not representative !
14873/// let result = hub.projects().locations_sources_migrating_vms_replication_cycles_list("parent")
14874/// .page_token("sed")
14875/// .page_size(-9)
14876/// .order_by("dolores")
14877/// .filter("gubergren")
14878/// .doit().await;
14879/// # }
14880/// ```
14881pub struct ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C>
14882where
14883 C: 'a,
14884{
14885 hub: &'a VMMigrationService<C>,
14886 _parent: String,
14887 _page_token: Option<String>,
14888 _page_size: Option<i32>,
14889 _order_by: Option<String>,
14890 _filter: Option<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
14897 for ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C>
14898{
14899}
14900
14901impl<'a, C> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C>
14902where
14903 C: common::Connector,
14904{
14905 /// Perform the operation you have build so far.
14906 pub async fn doit(
14907 mut self,
14908 ) -> common::Result<(common::Response, ListReplicationCyclesResponse)> {
14909 use std::borrow::Cow;
14910 use std::io::{Read, Seek};
14911
14912 use common::{url::Params, ToParts};
14913 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14914
14915 let mut dd = common::DefaultDelegate;
14916 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14917 dlg.begin(common::MethodInfo {
14918 id: "vmmigration.projects.locations.sources.migratingVms.replicationCycles.list",
14919 http_method: hyper::Method::GET,
14920 });
14921
14922 for &field in [
14923 "alt",
14924 "parent",
14925 "pageToken",
14926 "pageSize",
14927 "orderBy",
14928 "filter",
14929 ]
14930 .iter()
14931 {
14932 if self._additional_params.contains_key(field) {
14933 dlg.finished(false);
14934 return Err(common::Error::FieldClash(field));
14935 }
14936 }
14937
14938 let mut params = Params::with_capacity(7 + self._additional_params.len());
14939 params.push("parent", self._parent);
14940 if let Some(value) = self._page_token.as_ref() {
14941 params.push("pageToken", value);
14942 }
14943 if let Some(value) = self._page_size.as_ref() {
14944 params.push("pageSize", value.to_string());
14945 }
14946 if let Some(value) = self._order_by.as_ref() {
14947 params.push("orderBy", value);
14948 }
14949 if let Some(value) = self._filter.as_ref() {
14950 params.push("filter", value);
14951 }
14952
14953 params.extend(self._additional_params.iter());
14954
14955 params.push("alt", "json");
14956 let mut url = self.hub._base_url.clone() + "v1/{+parent}/replicationCycles";
14957 if self._scopes.is_empty() {
14958 self._scopes
14959 .insert(Scope::CloudPlatform.as_ref().to_string());
14960 }
14961
14962 #[allow(clippy::single_element_loop)]
14963 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14964 url = params.uri_replacement(url, param_name, find_this, true);
14965 }
14966 {
14967 let to_remove = ["parent"];
14968 params.remove_params(&to_remove);
14969 }
14970
14971 let url = params.parse_with_url(&url);
14972
14973 loop {
14974 let token = match self
14975 .hub
14976 .auth
14977 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14978 .await
14979 {
14980 Ok(token) => token,
14981 Err(e) => match dlg.token(e) {
14982 Ok(token) => token,
14983 Err(e) => {
14984 dlg.finished(false);
14985 return Err(common::Error::MissingToken(e));
14986 }
14987 },
14988 };
14989 let mut req_result = {
14990 let client = &self.hub.client;
14991 dlg.pre_request();
14992 let mut req_builder = hyper::Request::builder()
14993 .method(hyper::Method::GET)
14994 .uri(url.as_str())
14995 .header(USER_AGENT, self.hub._user_agent.clone());
14996
14997 if let Some(token) = token.as_ref() {
14998 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14999 }
15000
15001 let request = req_builder
15002 .header(CONTENT_LENGTH, 0_u64)
15003 .body(common::to_body::<String>(None));
15004
15005 client.request(request.unwrap()).await
15006 };
15007
15008 match req_result {
15009 Err(err) => {
15010 if let common::Retry::After(d) = dlg.http_error(&err) {
15011 sleep(d).await;
15012 continue;
15013 }
15014 dlg.finished(false);
15015 return Err(common::Error::HttpError(err));
15016 }
15017 Ok(res) => {
15018 let (mut parts, body) = res.into_parts();
15019 let mut body = common::Body::new(body);
15020 if !parts.status.is_success() {
15021 let bytes = common::to_bytes(body).await.unwrap_or_default();
15022 let error = serde_json::from_str(&common::to_string(&bytes));
15023 let response = common::to_response(parts, bytes.into());
15024
15025 if let common::Retry::After(d) =
15026 dlg.http_failure(&response, error.as_ref().ok())
15027 {
15028 sleep(d).await;
15029 continue;
15030 }
15031
15032 dlg.finished(false);
15033
15034 return Err(match error {
15035 Ok(value) => common::Error::BadRequest(value),
15036 _ => common::Error::Failure(response),
15037 });
15038 }
15039 let response = {
15040 let bytes = common::to_bytes(body).await.unwrap_or_default();
15041 let encoded = common::to_string(&bytes);
15042 match serde_json::from_str(&encoded) {
15043 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15044 Err(error) => {
15045 dlg.response_json_decode_error(&encoded, &error);
15046 return Err(common::Error::JsonDecodeError(
15047 encoded.to_string(),
15048 error,
15049 ));
15050 }
15051 }
15052 };
15053
15054 dlg.finished(true);
15055 return Ok(response);
15056 }
15057 }
15058 }
15059 }
15060
15061 /// Required. The parent, which owns this collection of ReplicationCycles.
15062 ///
15063 /// Sets the *parent* path property to the given value.
15064 ///
15065 /// Even though the property as already been set when instantiating this call,
15066 /// we provide this method for API completeness.
15067 pub fn parent(
15068 mut self,
15069 new_value: &str,
15070 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C> {
15071 self._parent = new_value.to_string();
15072 self
15073 }
15074 /// Required. A page token, received from a previous `ListReplicationCycles` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListReplicationCycles` must match the call that provided the page token.
15075 ///
15076 /// Sets the *page token* query property to the given value.
15077 pub fn page_token(
15078 mut self,
15079 new_value: &str,
15080 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C> {
15081 self._page_token = Some(new_value.to_string());
15082 self
15083 }
15084 /// Optional. The maximum number of replication cycles to return. The service may return fewer than this value. If unspecified, at most 100 migrating VMs will be returned. The maximum value is 100; values above 100 will be coerced to 100.
15085 ///
15086 /// Sets the *page size* query property to the given value.
15087 pub fn page_size(
15088 mut self,
15089 new_value: i32,
15090 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C> {
15091 self._page_size = Some(new_value);
15092 self
15093 }
15094 /// Optional. the order by fields for the result.
15095 ///
15096 /// Sets the *order by* query property to the given value.
15097 pub fn order_by(
15098 mut self,
15099 new_value: &str,
15100 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C> {
15101 self._order_by = Some(new_value.to_string());
15102 self
15103 }
15104 /// Optional. The filter request.
15105 ///
15106 /// Sets the *filter* query property to the given value.
15107 pub fn filter(
15108 mut self,
15109 new_value: &str,
15110 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C> {
15111 self._filter = Some(new_value.to_string());
15112 self
15113 }
15114 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15115 /// while executing the actual API request.
15116 ///
15117 /// ````text
15118 /// It should be used to handle progress information, and to implement a certain level of resilience.
15119 /// ````
15120 ///
15121 /// Sets the *delegate* property to the given value.
15122 pub fn delegate(
15123 mut self,
15124 new_value: &'a mut dyn common::Delegate,
15125 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C> {
15126 self._delegate = Some(new_value);
15127 self
15128 }
15129
15130 /// Set any additional parameter of the query string used in the request.
15131 /// It should be used to set parameters which are not yet available through their own
15132 /// setters.
15133 ///
15134 /// Please note that this method must not be used to set any of the known parameters
15135 /// which have their own setter method. If done anyway, the request will fail.
15136 ///
15137 /// # Additional Parameters
15138 ///
15139 /// * *$.xgafv* (query-string) - V1 error format.
15140 /// * *access_token* (query-string) - OAuth access token.
15141 /// * *alt* (query-string) - Data format for response.
15142 /// * *callback* (query-string) - JSONP
15143 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15144 /// * *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.
15145 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15146 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15147 /// * *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.
15148 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15149 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15150 pub fn param<T>(
15151 mut self,
15152 name: T,
15153 value: T,
15154 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C>
15155 where
15156 T: AsRef<str>,
15157 {
15158 self._additional_params
15159 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15160 self
15161 }
15162
15163 /// Identifies the authorization scope for the method you are building.
15164 ///
15165 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15166 /// [`Scope::CloudPlatform`].
15167 ///
15168 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15169 /// tokens for more than one scope.
15170 ///
15171 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15172 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15173 /// sufficient, a read-write scope will do as well.
15174 pub fn add_scope<St>(
15175 mut self,
15176 scope: St,
15177 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C>
15178 where
15179 St: AsRef<str>,
15180 {
15181 self._scopes.insert(String::from(scope.as_ref()));
15182 self
15183 }
15184 /// Identifies the authorization scope(s) for the method you are building.
15185 ///
15186 /// See [`Self::add_scope()`] for details.
15187 pub fn add_scopes<I, St>(
15188 mut self,
15189 scopes: I,
15190 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C>
15191 where
15192 I: IntoIterator<Item = St>,
15193 St: AsRef<str>,
15194 {
15195 self._scopes
15196 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15197 self
15198 }
15199
15200 /// Removes all scopes, and no default scope will be used either.
15201 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15202 /// for details).
15203 pub fn clear_scopes(
15204 mut self,
15205 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C> {
15206 self._scopes.clear();
15207 self
15208 }
15209}
15210
15211/// Creates a new MigratingVm in a given Source.
15212///
15213/// A builder for the *locations.sources.migratingVms.create* method supported by a *project* resource.
15214/// It is not used directly, but through a [`ProjectMethods`] instance.
15215///
15216/// # Example
15217///
15218/// Instantiate a resource method builder
15219///
15220/// ```test_harness,no_run
15221/// # extern crate hyper;
15222/// # extern crate hyper_rustls;
15223/// # extern crate google_vmmigration1 as vmmigration1;
15224/// use vmmigration1::api::MigratingVm;
15225/// # async fn dox() {
15226/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15227///
15228/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15229/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15230/// # secret,
15231/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15232/// # ).build().await.unwrap();
15233///
15234/// # let client = hyper_util::client::legacy::Client::builder(
15235/// # hyper_util::rt::TokioExecutor::new()
15236/// # )
15237/// # .build(
15238/// # hyper_rustls::HttpsConnectorBuilder::new()
15239/// # .with_native_roots()
15240/// # .unwrap()
15241/// # .https_or_http()
15242/// # .enable_http1()
15243/// # .build()
15244/// # );
15245/// # let mut hub = VMMigrationService::new(client, auth);
15246/// // As the method needs a request, you would usually fill it with the desired information
15247/// // into the respective structure. Some of the parts shown here might not be applicable !
15248/// // Values shown here are possibly random and not representative !
15249/// let mut req = MigratingVm::default();
15250///
15251/// // You can configure optional parameters by calling the respective setters at will, and
15252/// // execute the final call using `doit()`.
15253/// // Values shown here are possibly random and not representative !
15254/// let result = hub.projects().locations_sources_migrating_vms_create(req, "parent")
15255/// .request_id("accusam")
15256/// .migrating_vm_id("voluptua.")
15257/// .doit().await;
15258/// # }
15259/// ```
15260pub struct ProjectLocationSourceMigratingVmCreateCall<'a, C>
15261where
15262 C: 'a,
15263{
15264 hub: &'a VMMigrationService<C>,
15265 _request: MigratingVm,
15266 _parent: String,
15267 _request_id: Option<String>,
15268 _migrating_vm_id: Option<String>,
15269 _delegate: Option<&'a mut dyn common::Delegate>,
15270 _additional_params: HashMap<String, String>,
15271 _scopes: BTreeSet<String>,
15272}
15273
15274impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmCreateCall<'a, C> {}
15275
15276impl<'a, C> ProjectLocationSourceMigratingVmCreateCall<'a, C>
15277where
15278 C: common::Connector,
15279{
15280 /// Perform the operation you have build so far.
15281 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15282 use std::borrow::Cow;
15283 use std::io::{Read, Seek};
15284
15285 use common::{url::Params, ToParts};
15286 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15287
15288 let mut dd = common::DefaultDelegate;
15289 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15290 dlg.begin(common::MethodInfo {
15291 id: "vmmigration.projects.locations.sources.migratingVms.create",
15292 http_method: hyper::Method::POST,
15293 });
15294
15295 for &field in ["alt", "parent", "requestId", "migratingVmId"].iter() {
15296 if self._additional_params.contains_key(field) {
15297 dlg.finished(false);
15298 return Err(common::Error::FieldClash(field));
15299 }
15300 }
15301
15302 let mut params = Params::with_capacity(6 + self._additional_params.len());
15303 params.push("parent", self._parent);
15304 if let Some(value) = self._request_id.as_ref() {
15305 params.push("requestId", value);
15306 }
15307 if let Some(value) = self._migrating_vm_id.as_ref() {
15308 params.push("migratingVmId", value);
15309 }
15310
15311 params.extend(self._additional_params.iter());
15312
15313 params.push("alt", "json");
15314 let mut url = self.hub._base_url.clone() + "v1/{+parent}/migratingVms";
15315 if self._scopes.is_empty() {
15316 self._scopes
15317 .insert(Scope::CloudPlatform.as_ref().to_string());
15318 }
15319
15320 #[allow(clippy::single_element_loop)]
15321 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
15322 url = params.uri_replacement(url, param_name, find_this, true);
15323 }
15324 {
15325 let to_remove = ["parent"];
15326 params.remove_params(&to_remove);
15327 }
15328
15329 let url = params.parse_with_url(&url);
15330
15331 let mut json_mime_type = mime::APPLICATION_JSON;
15332 let mut request_value_reader = {
15333 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15334 common::remove_json_null_values(&mut value);
15335 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15336 serde_json::to_writer(&mut dst, &value).unwrap();
15337 dst
15338 };
15339 let request_size = request_value_reader
15340 .seek(std::io::SeekFrom::End(0))
15341 .unwrap();
15342 request_value_reader
15343 .seek(std::io::SeekFrom::Start(0))
15344 .unwrap();
15345
15346 loop {
15347 let token = match self
15348 .hub
15349 .auth
15350 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15351 .await
15352 {
15353 Ok(token) => token,
15354 Err(e) => match dlg.token(e) {
15355 Ok(token) => token,
15356 Err(e) => {
15357 dlg.finished(false);
15358 return Err(common::Error::MissingToken(e));
15359 }
15360 },
15361 };
15362 request_value_reader
15363 .seek(std::io::SeekFrom::Start(0))
15364 .unwrap();
15365 let mut req_result = {
15366 let client = &self.hub.client;
15367 dlg.pre_request();
15368 let mut req_builder = hyper::Request::builder()
15369 .method(hyper::Method::POST)
15370 .uri(url.as_str())
15371 .header(USER_AGENT, self.hub._user_agent.clone());
15372
15373 if let Some(token) = token.as_ref() {
15374 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15375 }
15376
15377 let request = req_builder
15378 .header(CONTENT_TYPE, json_mime_type.to_string())
15379 .header(CONTENT_LENGTH, request_size as u64)
15380 .body(common::to_body(
15381 request_value_reader.get_ref().clone().into(),
15382 ));
15383
15384 client.request(request.unwrap()).await
15385 };
15386
15387 match req_result {
15388 Err(err) => {
15389 if let common::Retry::After(d) = dlg.http_error(&err) {
15390 sleep(d).await;
15391 continue;
15392 }
15393 dlg.finished(false);
15394 return Err(common::Error::HttpError(err));
15395 }
15396 Ok(res) => {
15397 let (mut parts, body) = res.into_parts();
15398 let mut body = common::Body::new(body);
15399 if !parts.status.is_success() {
15400 let bytes = common::to_bytes(body).await.unwrap_or_default();
15401 let error = serde_json::from_str(&common::to_string(&bytes));
15402 let response = common::to_response(parts, bytes.into());
15403
15404 if let common::Retry::After(d) =
15405 dlg.http_failure(&response, error.as_ref().ok())
15406 {
15407 sleep(d).await;
15408 continue;
15409 }
15410
15411 dlg.finished(false);
15412
15413 return Err(match error {
15414 Ok(value) => common::Error::BadRequest(value),
15415 _ => common::Error::Failure(response),
15416 });
15417 }
15418 let response = {
15419 let bytes = common::to_bytes(body).await.unwrap_or_default();
15420 let encoded = common::to_string(&bytes);
15421 match serde_json::from_str(&encoded) {
15422 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15423 Err(error) => {
15424 dlg.response_json_decode_error(&encoded, &error);
15425 return Err(common::Error::JsonDecodeError(
15426 encoded.to_string(),
15427 error,
15428 ));
15429 }
15430 }
15431 };
15432
15433 dlg.finished(true);
15434 return Ok(response);
15435 }
15436 }
15437 }
15438 }
15439
15440 ///
15441 /// Sets the *request* property to the given value.
15442 ///
15443 /// Even though the property as already been set when instantiating this call,
15444 /// we provide this method for API completeness.
15445 pub fn request(
15446 mut self,
15447 new_value: MigratingVm,
15448 ) -> ProjectLocationSourceMigratingVmCreateCall<'a, C> {
15449 self._request = new_value;
15450 self
15451 }
15452 /// Required. The MigratingVm's parent.
15453 ///
15454 /// Sets the *parent* path property to the given value.
15455 ///
15456 /// Even though the property as already been set when instantiating this call,
15457 /// we provide this method for API completeness.
15458 pub fn parent(mut self, new_value: &str) -> ProjectLocationSourceMigratingVmCreateCall<'a, C> {
15459 self._parent = new_value.to_string();
15460 self
15461 }
15462 /// A request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes since the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
15463 ///
15464 /// Sets the *request id* query property to the given value.
15465 pub fn request_id(
15466 mut self,
15467 new_value: &str,
15468 ) -> ProjectLocationSourceMigratingVmCreateCall<'a, C> {
15469 self._request_id = Some(new_value.to_string());
15470 self
15471 }
15472 /// Required. The migratingVm identifier.
15473 ///
15474 /// Sets the *migrating vm id* query property to the given value.
15475 pub fn migrating_vm_id(
15476 mut self,
15477 new_value: &str,
15478 ) -> ProjectLocationSourceMigratingVmCreateCall<'a, C> {
15479 self._migrating_vm_id = Some(new_value.to_string());
15480 self
15481 }
15482 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15483 /// while executing the actual API request.
15484 ///
15485 /// ````text
15486 /// It should be used to handle progress information, and to implement a certain level of resilience.
15487 /// ````
15488 ///
15489 /// Sets the *delegate* property to the given value.
15490 pub fn delegate(
15491 mut self,
15492 new_value: &'a mut dyn common::Delegate,
15493 ) -> ProjectLocationSourceMigratingVmCreateCall<'a, C> {
15494 self._delegate = Some(new_value);
15495 self
15496 }
15497
15498 /// Set any additional parameter of the query string used in the request.
15499 /// It should be used to set parameters which are not yet available through their own
15500 /// setters.
15501 ///
15502 /// Please note that this method must not be used to set any of the known parameters
15503 /// which have their own setter method. If done anyway, the request will fail.
15504 ///
15505 /// # Additional Parameters
15506 ///
15507 /// * *$.xgafv* (query-string) - V1 error format.
15508 /// * *access_token* (query-string) - OAuth access token.
15509 /// * *alt* (query-string) - Data format for response.
15510 /// * *callback* (query-string) - JSONP
15511 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15512 /// * *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.
15513 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15514 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15515 /// * *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.
15516 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15517 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15518 pub fn param<T>(
15519 mut self,
15520 name: T,
15521 value: T,
15522 ) -> ProjectLocationSourceMigratingVmCreateCall<'a, C>
15523 where
15524 T: AsRef<str>,
15525 {
15526 self._additional_params
15527 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15528 self
15529 }
15530
15531 /// Identifies the authorization scope for the method you are building.
15532 ///
15533 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15534 /// [`Scope::CloudPlatform`].
15535 ///
15536 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15537 /// tokens for more than one scope.
15538 ///
15539 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15540 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15541 /// sufficient, a read-write scope will do as well.
15542 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceMigratingVmCreateCall<'a, C>
15543 where
15544 St: AsRef<str>,
15545 {
15546 self._scopes.insert(String::from(scope.as_ref()));
15547 self
15548 }
15549 /// Identifies the authorization scope(s) for the method you are building.
15550 ///
15551 /// See [`Self::add_scope()`] for details.
15552 pub fn add_scopes<I, St>(
15553 mut self,
15554 scopes: I,
15555 ) -> ProjectLocationSourceMigratingVmCreateCall<'a, C>
15556 where
15557 I: IntoIterator<Item = St>,
15558 St: AsRef<str>,
15559 {
15560 self._scopes
15561 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15562 self
15563 }
15564
15565 /// Removes all scopes, and no default scope will be used either.
15566 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15567 /// for details).
15568 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmCreateCall<'a, C> {
15569 self._scopes.clear();
15570 self
15571 }
15572}
15573
15574/// Deletes a single MigratingVm.
15575///
15576/// A builder for the *locations.sources.migratingVms.delete* method supported by a *project* resource.
15577/// It is not used directly, but through a [`ProjectMethods`] instance.
15578///
15579/// # Example
15580///
15581/// Instantiate a resource method builder
15582///
15583/// ```test_harness,no_run
15584/// # extern crate hyper;
15585/// # extern crate hyper_rustls;
15586/// # extern crate google_vmmigration1 as vmmigration1;
15587/// # async fn dox() {
15588/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15589///
15590/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15591/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15592/// # secret,
15593/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15594/// # ).build().await.unwrap();
15595///
15596/// # let client = hyper_util::client::legacy::Client::builder(
15597/// # hyper_util::rt::TokioExecutor::new()
15598/// # )
15599/// # .build(
15600/// # hyper_rustls::HttpsConnectorBuilder::new()
15601/// # .with_native_roots()
15602/// # .unwrap()
15603/// # .https_or_http()
15604/// # .enable_http1()
15605/// # .build()
15606/// # );
15607/// # let mut hub = VMMigrationService::new(client, auth);
15608/// // You can configure optional parameters by calling the respective setters at will, and
15609/// // execute the final call using `doit()`.
15610/// // Values shown here are possibly random and not representative !
15611/// let result = hub.projects().locations_sources_migrating_vms_delete("name")
15612/// .doit().await;
15613/// # }
15614/// ```
15615pub struct ProjectLocationSourceMigratingVmDeleteCall<'a, C>
15616where
15617 C: 'a,
15618{
15619 hub: &'a VMMigrationService<C>,
15620 _name: String,
15621 _delegate: Option<&'a mut dyn common::Delegate>,
15622 _additional_params: HashMap<String, String>,
15623 _scopes: BTreeSet<String>,
15624}
15625
15626impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmDeleteCall<'a, C> {}
15627
15628impl<'a, C> ProjectLocationSourceMigratingVmDeleteCall<'a, C>
15629where
15630 C: common::Connector,
15631{
15632 /// Perform the operation you have build so far.
15633 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15634 use std::borrow::Cow;
15635 use std::io::{Read, Seek};
15636
15637 use common::{url::Params, ToParts};
15638 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15639
15640 let mut dd = common::DefaultDelegate;
15641 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15642 dlg.begin(common::MethodInfo {
15643 id: "vmmigration.projects.locations.sources.migratingVms.delete",
15644 http_method: hyper::Method::DELETE,
15645 });
15646
15647 for &field in ["alt", "name"].iter() {
15648 if self._additional_params.contains_key(field) {
15649 dlg.finished(false);
15650 return Err(common::Error::FieldClash(field));
15651 }
15652 }
15653
15654 let mut params = Params::with_capacity(3 + self._additional_params.len());
15655 params.push("name", self._name);
15656
15657 params.extend(self._additional_params.iter());
15658
15659 params.push("alt", "json");
15660 let mut url = self.hub._base_url.clone() + "v1/{+name}";
15661 if self._scopes.is_empty() {
15662 self._scopes
15663 .insert(Scope::CloudPlatform.as_ref().to_string());
15664 }
15665
15666 #[allow(clippy::single_element_loop)]
15667 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15668 url = params.uri_replacement(url, param_name, find_this, true);
15669 }
15670 {
15671 let to_remove = ["name"];
15672 params.remove_params(&to_remove);
15673 }
15674
15675 let url = params.parse_with_url(&url);
15676
15677 loop {
15678 let token = match self
15679 .hub
15680 .auth
15681 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15682 .await
15683 {
15684 Ok(token) => token,
15685 Err(e) => match dlg.token(e) {
15686 Ok(token) => token,
15687 Err(e) => {
15688 dlg.finished(false);
15689 return Err(common::Error::MissingToken(e));
15690 }
15691 },
15692 };
15693 let mut req_result = {
15694 let client = &self.hub.client;
15695 dlg.pre_request();
15696 let mut req_builder = hyper::Request::builder()
15697 .method(hyper::Method::DELETE)
15698 .uri(url.as_str())
15699 .header(USER_AGENT, self.hub._user_agent.clone());
15700
15701 if let Some(token) = token.as_ref() {
15702 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15703 }
15704
15705 let request = req_builder
15706 .header(CONTENT_LENGTH, 0_u64)
15707 .body(common::to_body::<String>(None));
15708
15709 client.request(request.unwrap()).await
15710 };
15711
15712 match req_result {
15713 Err(err) => {
15714 if let common::Retry::After(d) = dlg.http_error(&err) {
15715 sleep(d).await;
15716 continue;
15717 }
15718 dlg.finished(false);
15719 return Err(common::Error::HttpError(err));
15720 }
15721 Ok(res) => {
15722 let (mut parts, body) = res.into_parts();
15723 let mut body = common::Body::new(body);
15724 if !parts.status.is_success() {
15725 let bytes = common::to_bytes(body).await.unwrap_or_default();
15726 let error = serde_json::from_str(&common::to_string(&bytes));
15727 let response = common::to_response(parts, bytes.into());
15728
15729 if let common::Retry::After(d) =
15730 dlg.http_failure(&response, error.as_ref().ok())
15731 {
15732 sleep(d).await;
15733 continue;
15734 }
15735
15736 dlg.finished(false);
15737
15738 return Err(match error {
15739 Ok(value) => common::Error::BadRequest(value),
15740 _ => common::Error::Failure(response),
15741 });
15742 }
15743 let response = {
15744 let bytes = common::to_bytes(body).await.unwrap_or_default();
15745 let encoded = common::to_string(&bytes);
15746 match serde_json::from_str(&encoded) {
15747 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15748 Err(error) => {
15749 dlg.response_json_decode_error(&encoded, &error);
15750 return Err(common::Error::JsonDecodeError(
15751 encoded.to_string(),
15752 error,
15753 ));
15754 }
15755 }
15756 };
15757
15758 dlg.finished(true);
15759 return Ok(response);
15760 }
15761 }
15762 }
15763 }
15764
15765 /// Required. The name of the MigratingVm.
15766 ///
15767 /// Sets the *name* path property to the given value.
15768 ///
15769 /// Even though the property as already been set when instantiating this call,
15770 /// we provide this method for API completeness.
15771 pub fn name(mut self, new_value: &str) -> ProjectLocationSourceMigratingVmDeleteCall<'a, C> {
15772 self._name = new_value.to_string();
15773 self
15774 }
15775 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15776 /// while executing the actual API request.
15777 ///
15778 /// ````text
15779 /// It should be used to handle progress information, and to implement a certain level of resilience.
15780 /// ````
15781 ///
15782 /// Sets the *delegate* property to the given value.
15783 pub fn delegate(
15784 mut self,
15785 new_value: &'a mut dyn common::Delegate,
15786 ) -> ProjectLocationSourceMigratingVmDeleteCall<'a, C> {
15787 self._delegate = Some(new_value);
15788 self
15789 }
15790
15791 /// Set any additional parameter of the query string used in the request.
15792 /// It should be used to set parameters which are not yet available through their own
15793 /// setters.
15794 ///
15795 /// Please note that this method must not be used to set any of the known parameters
15796 /// which have their own setter method. If done anyway, the request will fail.
15797 ///
15798 /// # Additional Parameters
15799 ///
15800 /// * *$.xgafv* (query-string) - V1 error format.
15801 /// * *access_token* (query-string) - OAuth access token.
15802 /// * *alt* (query-string) - Data format for response.
15803 /// * *callback* (query-string) - JSONP
15804 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15805 /// * *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.
15806 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15807 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15808 /// * *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.
15809 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15810 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15811 pub fn param<T>(
15812 mut self,
15813 name: T,
15814 value: T,
15815 ) -> ProjectLocationSourceMigratingVmDeleteCall<'a, C>
15816 where
15817 T: AsRef<str>,
15818 {
15819 self._additional_params
15820 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15821 self
15822 }
15823
15824 /// Identifies the authorization scope for the method you are building.
15825 ///
15826 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15827 /// [`Scope::CloudPlatform`].
15828 ///
15829 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15830 /// tokens for more than one scope.
15831 ///
15832 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15833 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15834 /// sufficient, a read-write scope will do as well.
15835 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceMigratingVmDeleteCall<'a, C>
15836 where
15837 St: AsRef<str>,
15838 {
15839 self._scopes.insert(String::from(scope.as_ref()));
15840 self
15841 }
15842 /// Identifies the authorization scope(s) for the method you are building.
15843 ///
15844 /// See [`Self::add_scope()`] for details.
15845 pub fn add_scopes<I, St>(
15846 mut self,
15847 scopes: I,
15848 ) -> ProjectLocationSourceMigratingVmDeleteCall<'a, C>
15849 where
15850 I: IntoIterator<Item = St>,
15851 St: AsRef<str>,
15852 {
15853 self._scopes
15854 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15855 self
15856 }
15857
15858 /// Removes all scopes, and no default scope will be used either.
15859 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15860 /// for details).
15861 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmDeleteCall<'a, C> {
15862 self._scopes.clear();
15863 self
15864 }
15865}
15866
15867/// Marks a migration as completed, deleting migration resources that are no longer being used. Only applicable after cutover is done.
15868///
15869/// A builder for the *locations.sources.migratingVms.finalizeMigration* method supported by a *project* resource.
15870/// It is not used directly, but through a [`ProjectMethods`] instance.
15871///
15872/// # Example
15873///
15874/// Instantiate a resource method builder
15875///
15876/// ```test_harness,no_run
15877/// # extern crate hyper;
15878/// # extern crate hyper_rustls;
15879/// # extern crate google_vmmigration1 as vmmigration1;
15880/// use vmmigration1::api::FinalizeMigrationRequest;
15881/// # async fn dox() {
15882/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15883///
15884/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15885/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15886/// # secret,
15887/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15888/// # ).build().await.unwrap();
15889///
15890/// # let client = hyper_util::client::legacy::Client::builder(
15891/// # hyper_util::rt::TokioExecutor::new()
15892/// # )
15893/// # .build(
15894/// # hyper_rustls::HttpsConnectorBuilder::new()
15895/// # .with_native_roots()
15896/// # .unwrap()
15897/// # .https_or_http()
15898/// # .enable_http1()
15899/// # .build()
15900/// # );
15901/// # let mut hub = VMMigrationService::new(client, auth);
15902/// // As the method needs a request, you would usually fill it with the desired information
15903/// // into the respective structure. Some of the parts shown here might not be applicable !
15904/// // Values shown here are possibly random and not representative !
15905/// let mut req = FinalizeMigrationRequest::default();
15906///
15907/// // You can configure optional parameters by calling the respective setters at will, and
15908/// // execute the final call using `doit()`.
15909/// // Values shown here are possibly random and not representative !
15910/// let result = hub.projects().locations_sources_migrating_vms_finalize_migration(req, "migratingVm")
15911/// .doit().await;
15912/// # }
15913/// ```
15914pub struct ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C>
15915where
15916 C: 'a,
15917{
15918 hub: &'a VMMigrationService<C>,
15919 _request: FinalizeMigrationRequest,
15920 _migrating_vm: String,
15921 _delegate: Option<&'a mut dyn common::Delegate>,
15922 _additional_params: HashMap<String, String>,
15923 _scopes: BTreeSet<String>,
15924}
15925
15926impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C> {}
15927
15928impl<'a, C> ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C>
15929where
15930 C: common::Connector,
15931{
15932 /// Perform the operation you have build so far.
15933 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15934 use std::borrow::Cow;
15935 use std::io::{Read, Seek};
15936
15937 use common::{url::Params, ToParts};
15938 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15939
15940 let mut dd = common::DefaultDelegate;
15941 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15942 dlg.begin(common::MethodInfo {
15943 id: "vmmigration.projects.locations.sources.migratingVms.finalizeMigration",
15944 http_method: hyper::Method::POST,
15945 });
15946
15947 for &field in ["alt", "migratingVm"].iter() {
15948 if self._additional_params.contains_key(field) {
15949 dlg.finished(false);
15950 return Err(common::Error::FieldClash(field));
15951 }
15952 }
15953
15954 let mut params = Params::with_capacity(4 + self._additional_params.len());
15955 params.push("migratingVm", self._migrating_vm);
15956
15957 params.extend(self._additional_params.iter());
15958
15959 params.push("alt", "json");
15960 let mut url = self.hub._base_url.clone() + "v1/{+migratingVm}:finalizeMigration";
15961 if self._scopes.is_empty() {
15962 self._scopes
15963 .insert(Scope::CloudPlatform.as_ref().to_string());
15964 }
15965
15966 #[allow(clippy::single_element_loop)]
15967 for &(find_this, param_name) in [("{+migratingVm}", "migratingVm")].iter() {
15968 url = params.uri_replacement(url, param_name, find_this, true);
15969 }
15970 {
15971 let to_remove = ["migratingVm"];
15972 params.remove_params(&to_remove);
15973 }
15974
15975 let url = params.parse_with_url(&url);
15976
15977 let mut json_mime_type = mime::APPLICATION_JSON;
15978 let mut request_value_reader = {
15979 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15980 common::remove_json_null_values(&mut value);
15981 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15982 serde_json::to_writer(&mut dst, &value).unwrap();
15983 dst
15984 };
15985 let request_size = request_value_reader
15986 .seek(std::io::SeekFrom::End(0))
15987 .unwrap();
15988 request_value_reader
15989 .seek(std::io::SeekFrom::Start(0))
15990 .unwrap();
15991
15992 loop {
15993 let token = match self
15994 .hub
15995 .auth
15996 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15997 .await
15998 {
15999 Ok(token) => token,
16000 Err(e) => match dlg.token(e) {
16001 Ok(token) => token,
16002 Err(e) => {
16003 dlg.finished(false);
16004 return Err(common::Error::MissingToken(e));
16005 }
16006 },
16007 };
16008 request_value_reader
16009 .seek(std::io::SeekFrom::Start(0))
16010 .unwrap();
16011 let mut req_result = {
16012 let client = &self.hub.client;
16013 dlg.pre_request();
16014 let mut req_builder = hyper::Request::builder()
16015 .method(hyper::Method::POST)
16016 .uri(url.as_str())
16017 .header(USER_AGENT, self.hub._user_agent.clone());
16018
16019 if let Some(token) = token.as_ref() {
16020 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16021 }
16022
16023 let request = req_builder
16024 .header(CONTENT_TYPE, json_mime_type.to_string())
16025 .header(CONTENT_LENGTH, request_size as u64)
16026 .body(common::to_body(
16027 request_value_reader.get_ref().clone().into(),
16028 ));
16029
16030 client.request(request.unwrap()).await
16031 };
16032
16033 match req_result {
16034 Err(err) => {
16035 if let common::Retry::After(d) = dlg.http_error(&err) {
16036 sleep(d).await;
16037 continue;
16038 }
16039 dlg.finished(false);
16040 return Err(common::Error::HttpError(err));
16041 }
16042 Ok(res) => {
16043 let (mut parts, body) = res.into_parts();
16044 let mut body = common::Body::new(body);
16045 if !parts.status.is_success() {
16046 let bytes = common::to_bytes(body).await.unwrap_or_default();
16047 let error = serde_json::from_str(&common::to_string(&bytes));
16048 let response = common::to_response(parts, bytes.into());
16049
16050 if let common::Retry::After(d) =
16051 dlg.http_failure(&response, error.as_ref().ok())
16052 {
16053 sleep(d).await;
16054 continue;
16055 }
16056
16057 dlg.finished(false);
16058
16059 return Err(match error {
16060 Ok(value) => common::Error::BadRequest(value),
16061 _ => common::Error::Failure(response),
16062 });
16063 }
16064 let response = {
16065 let bytes = common::to_bytes(body).await.unwrap_or_default();
16066 let encoded = common::to_string(&bytes);
16067 match serde_json::from_str(&encoded) {
16068 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16069 Err(error) => {
16070 dlg.response_json_decode_error(&encoded, &error);
16071 return Err(common::Error::JsonDecodeError(
16072 encoded.to_string(),
16073 error,
16074 ));
16075 }
16076 }
16077 };
16078
16079 dlg.finished(true);
16080 return Ok(response);
16081 }
16082 }
16083 }
16084 }
16085
16086 ///
16087 /// Sets the *request* property to the given value.
16088 ///
16089 /// Even though the property as already been set when instantiating this call,
16090 /// we provide this method for API completeness.
16091 pub fn request(
16092 mut self,
16093 new_value: FinalizeMigrationRequest,
16094 ) -> ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C> {
16095 self._request = new_value;
16096 self
16097 }
16098 /// Required. The name of the MigratingVm.
16099 ///
16100 /// Sets the *migrating vm* path property to the given value.
16101 ///
16102 /// Even though the property as already been set when instantiating this call,
16103 /// we provide this method for API completeness.
16104 pub fn migrating_vm(
16105 mut self,
16106 new_value: &str,
16107 ) -> ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C> {
16108 self._migrating_vm = new_value.to_string();
16109 self
16110 }
16111 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16112 /// while executing the actual API request.
16113 ///
16114 /// ````text
16115 /// It should be used to handle progress information, and to implement a certain level of resilience.
16116 /// ````
16117 ///
16118 /// Sets the *delegate* property to the given value.
16119 pub fn delegate(
16120 mut self,
16121 new_value: &'a mut dyn common::Delegate,
16122 ) -> ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C> {
16123 self._delegate = Some(new_value);
16124 self
16125 }
16126
16127 /// Set any additional parameter of the query string used in the request.
16128 /// It should be used to set parameters which are not yet available through their own
16129 /// setters.
16130 ///
16131 /// Please note that this method must not be used to set any of the known parameters
16132 /// which have their own setter method. If done anyway, the request will fail.
16133 ///
16134 /// # Additional Parameters
16135 ///
16136 /// * *$.xgafv* (query-string) - V1 error format.
16137 /// * *access_token* (query-string) - OAuth access token.
16138 /// * *alt* (query-string) - Data format for response.
16139 /// * *callback* (query-string) - JSONP
16140 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16141 /// * *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.
16142 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16143 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16144 /// * *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.
16145 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16146 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16147 pub fn param<T>(
16148 mut self,
16149 name: T,
16150 value: T,
16151 ) -> ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C>
16152 where
16153 T: AsRef<str>,
16154 {
16155 self._additional_params
16156 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16157 self
16158 }
16159
16160 /// Identifies the authorization scope for the method you are building.
16161 ///
16162 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16163 /// [`Scope::CloudPlatform`].
16164 ///
16165 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16166 /// tokens for more than one scope.
16167 ///
16168 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16169 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16170 /// sufficient, a read-write scope will do as well.
16171 pub fn add_scope<St>(
16172 mut self,
16173 scope: St,
16174 ) -> ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C>
16175 where
16176 St: AsRef<str>,
16177 {
16178 self._scopes.insert(String::from(scope.as_ref()));
16179 self
16180 }
16181 /// Identifies the authorization scope(s) for the method you are building.
16182 ///
16183 /// See [`Self::add_scope()`] for details.
16184 pub fn add_scopes<I, St>(
16185 mut self,
16186 scopes: I,
16187 ) -> ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C>
16188 where
16189 I: IntoIterator<Item = St>,
16190 St: AsRef<str>,
16191 {
16192 self._scopes
16193 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16194 self
16195 }
16196
16197 /// Removes all scopes, and no default scope will be used either.
16198 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16199 /// for details).
16200 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C> {
16201 self._scopes.clear();
16202 self
16203 }
16204}
16205
16206/// Gets details of a single MigratingVm.
16207///
16208/// A builder for the *locations.sources.migratingVms.get* method supported by a *project* resource.
16209/// It is not used directly, but through a [`ProjectMethods`] instance.
16210///
16211/// # Example
16212///
16213/// Instantiate a resource method builder
16214///
16215/// ```test_harness,no_run
16216/// # extern crate hyper;
16217/// # extern crate hyper_rustls;
16218/// # extern crate google_vmmigration1 as vmmigration1;
16219/// # async fn dox() {
16220/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16221///
16222/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16223/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16224/// # secret,
16225/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16226/// # ).build().await.unwrap();
16227///
16228/// # let client = hyper_util::client::legacy::Client::builder(
16229/// # hyper_util::rt::TokioExecutor::new()
16230/// # )
16231/// # .build(
16232/// # hyper_rustls::HttpsConnectorBuilder::new()
16233/// # .with_native_roots()
16234/// # .unwrap()
16235/// # .https_or_http()
16236/// # .enable_http1()
16237/// # .build()
16238/// # );
16239/// # let mut hub = VMMigrationService::new(client, auth);
16240/// // You can configure optional parameters by calling the respective setters at will, and
16241/// // execute the final call using `doit()`.
16242/// // Values shown here are possibly random and not representative !
16243/// let result = hub.projects().locations_sources_migrating_vms_get("name")
16244/// .view("voluptua.")
16245/// .doit().await;
16246/// # }
16247/// ```
16248pub struct ProjectLocationSourceMigratingVmGetCall<'a, C>
16249where
16250 C: 'a,
16251{
16252 hub: &'a VMMigrationService<C>,
16253 _name: String,
16254 _view: Option<String>,
16255 _delegate: Option<&'a mut dyn common::Delegate>,
16256 _additional_params: HashMap<String, String>,
16257 _scopes: BTreeSet<String>,
16258}
16259
16260impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmGetCall<'a, C> {}
16261
16262impl<'a, C> ProjectLocationSourceMigratingVmGetCall<'a, C>
16263where
16264 C: common::Connector,
16265{
16266 /// Perform the operation you have build so far.
16267 pub async fn doit(mut self) -> common::Result<(common::Response, MigratingVm)> {
16268 use std::borrow::Cow;
16269 use std::io::{Read, Seek};
16270
16271 use common::{url::Params, ToParts};
16272 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16273
16274 let mut dd = common::DefaultDelegate;
16275 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16276 dlg.begin(common::MethodInfo {
16277 id: "vmmigration.projects.locations.sources.migratingVms.get",
16278 http_method: hyper::Method::GET,
16279 });
16280
16281 for &field in ["alt", "name", "view"].iter() {
16282 if self._additional_params.contains_key(field) {
16283 dlg.finished(false);
16284 return Err(common::Error::FieldClash(field));
16285 }
16286 }
16287
16288 let mut params = Params::with_capacity(4 + self._additional_params.len());
16289 params.push("name", self._name);
16290 if let Some(value) = self._view.as_ref() {
16291 params.push("view", value);
16292 }
16293
16294 params.extend(self._additional_params.iter());
16295
16296 params.push("alt", "json");
16297 let mut url = self.hub._base_url.clone() + "v1/{+name}";
16298 if self._scopes.is_empty() {
16299 self._scopes
16300 .insert(Scope::CloudPlatform.as_ref().to_string());
16301 }
16302
16303 #[allow(clippy::single_element_loop)]
16304 for &(find_this, param_name) in [("{+name}", "name")].iter() {
16305 url = params.uri_replacement(url, param_name, find_this, true);
16306 }
16307 {
16308 let to_remove = ["name"];
16309 params.remove_params(&to_remove);
16310 }
16311
16312 let url = params.parse_with_url(&url);
16313
16314 loop {
16315 let token = match self
16316 .hub
16317 .auth
16318 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16319 .await
16320 {
16321 Ok(token) => token,
16322 Err(e) => match dlg.token(e) {
16323 Ok(token) => token,
16324 Err(e) => {
16325 dlg.finished(false);
16326 return Err(common::Error::MissingToken(e));
16327 }
16328 },
16329 };
16330 let mut req_result = {
16331 let client = &self.hub.client;
16332 dlg.pre_request();
16333 let mut req_builder = hyper::Request::builder()
16334 .method(hyper::Method::GET)
16335 .uri(url.as_str())
16336 .header(USER_AGENT, self.hub._user_agent.clone());
16337
16338 if let Some(token) = token.as_ref() {
16339 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16340 }
16341
16342 let request = req_builder
16343 .header(CONTENT_LENGTH, 0_u64)
16344 .body(common::to_body::<String>(None));
16345
16346 client.request(request.unwrap()).await
16347 };
16348
16349 match req_result {
16350 Err(err) => {
16351 if let common::Retry::After(d) = dlg.http_error(&err) {
16352 sleep(d).await;
16353 continue;
16354 }
16355 dlg.finished(false);
16356 return Err(common::Error::HttpError(err));
16357 }
16358 Ok(res) => {
16359 let (mut parts, body) = res.into_parts();
16360 let mut body = common::Body::new(body);
16361 if !parts.status.is_success() {
16362 let bytes = common::to_bytes(body).await.unwrap_or_default();
16363 let error = serde_json::from_str(&common::to_string(&bytes));
16364 let response = common::to_response(parts, bytes.into());
16365
16366 if let common::Retry::After(d) =
16367 dlg.http_failure(&response, error.as_ref().ok())
16368 {
16369 sleep(d).await;
16370 continue;
16371 }
16372
16373 dlg.finished(false);
16374
16375 return Err(match error {
16376 Ok(value) => common::Error::BadRequest(value),
16377 _ => common::Error::Failure(response),
16378 });
16379 }
16380 let response = {
16381 let bytes = common::to_bytes(body).await.unwrap_or_default();
16382 let encoded = common::to_string(&bytes);
16383 match serde_json::from_str(&encoded) {
16384 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16385 Err(error) => {
16386 dlg.response_json_decode_error(&encoded, &error);
16387 return Err(common::Error::JsonDecodeError(
16388 encoded.to_string(),
16389 error,
16390 ));
16391 }
16392 }
16393 };
16394
16395 dlg.finished(true);
16396 return Ok(response);
16397 }
16398 }
16399 }
16400 }
16401
16402 /// Required. The name of the MigratingVm.
16403 ///
16404 /// Sets the *name* path property to the given value.
16405 ///
16406 /// Even though the property as already been set when instantiating this call,
16407 /// we provide this method for API completeness.
16408 pub fn name(mut self, new_value: &str) -> ProjectLocationSourceMigratingVmGetCall<'a, C> {
16409 self._name = new_value.to_string();
16410 self
16411 }
16412 /// Optional. The level of details of the migrating VM.
16413 ///
16414 /// Sets the *view* query property to the given value.
16415 pub fn view(mut self, new_value: &str) -> ProjectLocationSourceMigratingVmGetCall<'a, C> {
16416 self._view = Some(new_value.to_string());
16417 self
16418 }
16419 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16420 /// while executing the actual API request.
16421 ///
16422 /// ````text
16423 /// It should be used to handle progress information, and to implement a certain level of resilience.
16424 /// ````
16425 ///
16426 /// Sets the *delegate* property to the given value.
16427 pub fn delegate(
16428 mut self,
16429 new_value: &'a mut dyn common::Delegate,
16430 ) -> ProjectLocationSourceMigratingVmGetCall<'a, C> {
16431 self._delegate = Some(new_value);
16432 self
16433 }
16434
16435 /// Set any additional parameter of the query string used in the request.
16436 /// It should be used to set parameters which are not yet available through their own
16437 /// setters.
16438 ///
16439 /// Please note that this method must not be used to set any of the known parameters
16440 /// which have their own setter method. If done anyway, the request will fail.
16441 ///
16442 /// # Additional Parameters
16443 ///
16444 /// * *$.xgafv* (query-string) - V1 error format.
16445 /// * *access_token* (query-string) - OAuth access token.
16446 /// * *alt* (query-string) - Data format for response.
16447 /// * *callback* (query-string) - JSONP
16448 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16449 /// * *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.
16450 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16451 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16452 /// * *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.
16453 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16454 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16455 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSourceMigratingVmGetCall<'a, C>
16456 where
16457 T: AsRef<str>,
16458 {
16459 self._additional_params
16460 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16461 self
16462 }
16463
16464 /// Identifies the authorization scope for the method you are building.
16465 ///
16466 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16467 /// [`Scope::CloudPlatform`].
16468 ///
16469 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16470 /// tokens for more than one scope.
16471 ///
16472 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16473 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16474 /// sufficient, a read-write scope will do as well.
16475 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceMigratingVmGetCall<'a, C>
16476 where
16477 St: AsRef<str>,
16478 {
16479 self._scopes.insert(String::from(scope.as_ref()));
16480 self
16481 }
16482 /// Identifies the authorization scope(s) for the method you are building.
16483 ///
16484 /// See [`Self::add_scope()`] for details.
16485 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSourceMigratingVmGetCall<'a, C>
16486 where
16487 I: IntoIterator<Item = St>,
16488 St: AsRef<str>,
16489 {
16490 self._scopes
16491 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16492 self
16493 }
16494
16495 /// Removes all scopes, and no default scope will be used either.
16496 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16497 /// for details).
16498 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmGetCall<'a, C> {
16499 self._scopes.clear();
16500 self
16501 }
16502}
16503
16504/// Lists MigratingVms in a given Source.
16505///
16506/// A builder for the *locations.sources.migratingVms.list* method supported by a *project* resource.
16507/// It is not used directly, but through a [`ProjectMethods`] instance.
16508///
16509/// # Example
16510///
16511/// Instantiate a resource method builder
16512///
16513/// ```test_harness,no_run
16514/// # extern crate hyper;
16515/// # extern crate hyper_rustls;
16516/// # extern crate google_vmmigration1 as vmmigration1;
16517/// # async fn dox() {
16518/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16519///
16520/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16521/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16522/// # secret,
16523/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16524/// # ).build().await.unwrap();
16525///
16526/// # let client = hyper_util::client::legacy::Client::builder(
16527/// # hyper_util::rt::TokioExecutor::new()
16528/// # )
16529/// # .build(
16530/// # hyper_rustls::HttpsConnectorBuilder::new()
16531/// # .with_native_roots()
16532/// # .unwrap()
16533/// # .https_or_http()
16534/// # .enable_http1()
16535/// # .build()
16536/// # );
16537/// # let mut hub = VMMigrationService::new(client, auth);
16538/// // You can configure optional parameters by calling the respective setters at will, and
16539/// // execute the final call using `doit()`.
16540/// // Values shown here are possibly random and not representative !
16541/// let result = hub.projects().locations_sources_migrating_vms_list("parent")
16542/// .view("ea")
16543/// .page_token("sadipscing")
16544/// .page_size(-6)
16545/// .order_by("invidunt")
16546/// .filter("no")
16547/// .doit().await;
16548/// # }
16549/// ```
16550pub struct ProjectLocationSourceMigratingVmListCall<'a, C>
16551where
16552 C: 'a,
16553{
16554 hub: &'a VMMigrationService<C>,
16555 _parent: String,
16556 _view: Option<String>,
16557 _page_token: Option<String>,
16558 _page_size: Option<i32>,
16559 _order_by: Option<String>,
16560 _filter: Option<String>,
16561 _delegate: Option<&'a mut dyn common::Delegate>,
16562 _additional_params: HashMap<String, String>,
16563 _scopes: BTreeSet<String>,
16564}
16565
16566impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmListCall<'a, C> {}
16567
16568impl<'a, C> ProjectLocationSourceMigratingVmListCall<'a, C>
16569where
16570 C: common::Connector,
16571{
16572 /// Perform the operation you have build so far.
16573 pub async fn doit(mut self) -> common::Result<(common::Response, ListMigratingVmsResponse)> {
16574 use std::borrow::Cow;
16575 use std::io::{Read, Seek};
16576
16577 use common::{url::Params, ToParts};
16578 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16579
16580 let mut dd = common::DefaultDelegate;
16581 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16582 dlg.begin(common::MethodInfo {
16583 id: "vmmigration.projects.locations.sources.migratingVms.list",
16584 http_method: hyper::Method::GET,
16585 });
16586
16587 for &field in [
16588 "alt",
16589 "parent",
16590 "view",
16591 "pageToken",
16592 "pageSize",
16593 "orderBy",
16594 "filter",
16595 ]
16596 .iter()
16597 {
16598 if self._additional_params.contains_key(field) {
16599 dlg.finished(false);
16600 return Err(common::Error::FieldClash(field));
16601 }
16602 }
16603
16604 let mut params = Params::with_capacity(8 + self._additional_params.len());
16605 params.push("parent", self._parent);
16606 if let Some(value) = self._view.as_ref() {
16607 params.push("view", value);
16608 }
16609 if let Some(value) = self._page_token.as_ref() {
16610 params.push("pageToken", value);
16611 }
16612 if let Some(value) = self._page_size.as_ref() {
16613 params.push("pageSize", value.to_string());
16614 }
16615 if let Some(value) = self._order_by.as_ref() {
16616 params.push("orderBy", value);
16617 }
16618 if let Some(value) = self._filter.as_ref() {
16619 params.push("filter", value);
16620 }
16621
16622 params.extend(self._additional_params.iter());
16623
16624 params.push("alt", "json");
16625 let mut url = self.hub._base_url.clone() + "v1/{+parent}/migratingVms";
16626 if self._scopes.is_empty() {
16627 self._scopes
16628 .insert(Scope::CloudPlatform.as_ref().to_string());
16629 }
16630
16631 #[allow(clippy::single_element_loop)]
16632 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
16633 url = params.uri_replacement(url, param_name, find_this, true);
16634 }
16635 {
16636 let to_remove = ["parent"];
16637 params.remove_params(&to_remove);
16638 }
16639
16640 let url = params.parse_with_url(&url);
16641
16642 loop {
16643 let token = match self
16644 .hub
16645 .auth
16646 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16647 .await
16648 {
16649 Ok(token) => token,
16650 Err(e) => match dlg.token(e) {
16651 Ok(token) => token,
16652 Err(e) => {
16653 dlg.finished(false);
16654 return Err(common::Error::MissingToken(e));
16655 }
16656 },
16657 };
16658 let mut req_result = {
16659 let client = &self.hub.client;
16660 dlg.pre_request();
16661 let mut req_builder = hyper::Request::builder()
16662 .method(hyper::Method::GET)
16663 .uri(url.as_str())
16664 .header(USER_AGENT, self.hub._user_agent.clone());
16665
16666 if let Some(token) = token.as_ref() {
16667 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16668 }
16669
16670 let request = req_builder
16671 .header(CONTENT_LENGTH, 0_u64)
16672 .body(common::to_body::<String>(None));
16673
16674 client.request(request.unwrap()).await
16675 };
16676
16677 match req_result {
16678 Err(err) => {
16679 if let common::Retry::After(d) = dlg.http_error(&err) {
16680 sleep(d).await;
16681 continue;
16682 }
16683 dlg.finished(false);
16684 return Err(common::Error::HttpError(err));
16685 }
16686 Ok(res) => {
16687 let (mut parts, body) = res.into_parts();
16688 let mut body = common::Body::new(body);
16689 if !parts.status.is_success() {
16690 let bytes = common::to_bytes(body).await.unwrap_or_default();
16691 let error = serde_json::from_str(&common::to_string(&bytes));
16692 let response = common::to_response(parts, bytes.into());
16693
16694 if let common::Retry::After(d) =
16695 dlg.http_failure(&response, error.as_ref().ok())
16696 {
16697 sleep(d).await;
16698 continue;
16699 }
16700
16701 dlg.finished(false);
16702
16703 return Err(match error {
16704 Ok(value) => common::Error::BadRequest(value),
16705 _ => common::Error::Failure(response),
16706 });
16707 }
16708 let response = {
16709 let bytes = common::to_bytes(body).await.unwrap_or_default();
16710 let encoded = common::to_string(&bytes);
16711 match serde_json::from_str(&encoded) {
16712 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16713 Err(error) => {
16714 dlg.response_json_decode_error(&encoded, &error);
16715 return Err(common::Error::JsonDecodeError(
16716 encoded.to_string(),
16717 error,
16718 ));
16719 }
16720 }
16721 };
16722
16723 dlg.finished(true);
16724 return Ok(response);
16725 }
16726 }
16727 }
16728 }
16729
16730 /// Required. The parent, which owns this collection of MigratingVms.
16731 ///
16732 /// Sets the *parent* path property to the given value.
16733 ///
16734 /// Even though the property as already been set when instantiating this call,
16735 /// we provide this method for API completeness.
16736 pub fn parent(mut self, new_value: &str) -> ProjectLocationSourceMigratingVmListCall<'a, C> {
16737 self._parent = new_value.to_string();
16738 self
16739 }
16740 /// Optional. The level of details of each migrating VM.
16741 ///
16742 /// Sets the *view* query property to the given value.
16743 pub fn view(mut self, new_value: &str) -> ProjectLocationSourceMigratingVmListCall<'a, C> {
16744 self._view = Some(new_value.to_string());
16745 self
16746 }
16747 /// Required. A page token, received from a previous `ListMigratingVms` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListMigratingVms` must match the call that provided the page token.
16748 ///
16749 /// Sets the *page token* query property to the given value.
16750 pub fn page_token(
16751 mut self,
16752 new_value: &str,
16753 ) -> ProjectLocationSourceMigratingVmListCall<'a, C> {
16754 self._page_token = Some(new_value.to_string());
16755 self
16756 }
16757 /// Optional. The maximum number of migrating VMs to return. The service may return fewer than this value. If unspecified, at most 500 migrating VMs will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
16758 ///
16759 /// Sets the *page size* query property to the given value.
16760 pub fn page_size(mut self, new_value: i32) -> ProjectLocationSourceMigratingVmListCall<'a, C> {
16761 self._page_size = Some(new_value);
16762 self
16763 }
16764 /// Optional. the order by fields for the result.
16765 ///
16766 /// Sets the *order by* query property to the given value.
16767 pub fn order_by(mut self, new_value: &str) -> ProjectLocationSourceMigratingVmListCall<'a, C> {
16768 self._order_by = Some(new_value.to_string());
16769 self
16770 }
16771 /// Optional. The filter request.
16772 ///
16773 /// Sets the *filter* query property to the given value.
16774 pub fn filter(mut self, new_value: &str) -> ProjectLocationSourceMigratingVmListCall<'a, C> {
16775 self._filter = Some(new_value.to_string());
16776 self
16777 }
16778 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16779 /// while executing the actual API request.
16780 ///
16781 /// ````text
16782 /// It should be used to handle progress information, and to implement a certain level of resilience.
16783 /// ````
16784 ///
16785 /// Sets the *delegate* property to the given value.
16786 pub fn delegate(
16787 mut self,
16788 new_value: &'a mut dyn common::Delegate,
16789 ) -> ProjectLocationSourceMigratingVmListCall<'a, C> {
16790 self._delegate = Some(new_value);
16791 self
16792 }
16793
16794 /// Set any additional parameter of the query string used in the request.
16795 /// It should be used to set parameters which are not yet available through their own
16796 /// setters.
16797 ///
16798 /// Please note that this method must not be used to set any of the known parameters
16799 /// which have their own setter method. If done anyway, the request will fail.
16800 ///
16801 /// # Additional Parameters
16802 ///
16803 /// * *$.xgafv* (query-string) - V1 error format.
16804 /// * *access_token* (query-string) - OAuth access token.
16805 /// * *alt* (query-string) - Data format for response.
16806 /// * *callback* (query-string) - JSONP
16807 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16808 /// * *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.
16809 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16810 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16811 /// * *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.
16812 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16813 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16814 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSourceMigratingVmListCall<'a, C>
16815 where
16816 T: AsRef<str>,
16817 {
16818 self._additional_params
16819 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16820 self
16821 }
16822
16823 /// Identifies the authorization scope for the method you are building.
16824 ///
16825 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16826 /// [`Scope::CloudPlatform`].
16827 ///
16828 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16829 /// tokens for more than one scope.
16830 ///
16831 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16832 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16833 /// sufficient, a read-write scope will do as well.
16834 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceMigratingVmListCall<'a, C>
16835 where
16836 St: AsRef<str>,
16837 {
16838 self._scopes.insert(String::from(scope.as_ref()));
16839 self
16840 }
16841 /// Identifies the authorization scope(s) for the method you are building.
16842 ///
16843 /// See [`Self::add_scope()`] for details.
16844 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSourceMigratingVmListCall<'a, C>
16845 where
16846 I: IntoIterator<Item = St>,
16847 St: AsRef<str>,
16848 {
16849 self._scopes
16850 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16851 self
16852 }
16853
16854 /// Removes all scopes, and no default scope will be used either.
16855 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16856 /// for details).
16857 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmListCall<'a, C> {
16858 self._scopes.clear();
16859 self
16860 }
16861}
16862
16863/// Updates the parameters of a single MigratingVm.
16864///
16865/// A builder for the *locations.sources.migratingVms.patch* method supported by a *project* resource.
16866/// It is not used directly, but through a [`ProjectMethods`] instance.
16867///
16868/// # Example
16869///
16870/// Instantiate a resource method builder
16871///
16872/// ```test_harness,no_run
16873/// # extern crate hyper;
16874/// # extern crate hyper_rustls;
16875/// # extern crate google_vmmigration1 as vmmigration1;
16876/// use vmmigration1::api::MigratingVm;
16877/// # async fn dox() {
16878/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16879///
16880/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16881/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16882/// # secret,
16883/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16884/// # ).build().await.unwrap();
16885///
16886/// # let client = hyper_util::client::legacy::Client::builder(
16887/// # hyper_util::rt::TokioExecutor::new()
16888/// # )
16889/// # .build(
16890/// # hyper_rustls::HttpsConnectorBuilder::new()
16891/// # .with_native_roots()
16892/// # .unwrap()
16893/// # .https_or_http()
16894/// # .enable_http1()
16895/// # .build()
16896/// # );
16897/// # let mut hub = VMMigrationService::new(client, auth);
16898/// // As the method needs a request, you would usually fill it with the desired information
16899/// // into the respective structure. Some of the parts shown here might not be applicable !
16900/// // Values shown here are possibly random and not representative !
16901/// let mut req = MigratingVm::default();
16902///
16903/// // You can configure optional parameters by calling the respective setters at will, and
16904/// // execute the final call using `doit()`.
16905/// // Values shown here are possibly random and not representative !
16906/// let result = hub.projects().locations_sources_migrating_vms_patch(req, "name")
16907/// .update_mask(FieldMask::new::<&str>(&[]))
16908/// .request_id("At")
16909/// .doit().await;
16910/// # }
16911/// ```
16912pub struct ProjectLocationSourceMigratingVmPatchCall<'a, C>
16913where
16914 C: 'a,
16915{
16916 hub: &'a VMMigrationService<C>,
16917 _request: MigratingVm,
16918 _name: String,
16919 _update_mask: Option<common::FieldMask>,
16920 _request_id: Option<String>,
16921 _delegate: Option<&'a mut dyn common::Delegate>,
16922 _additional_params: HashMap<String, String>,
16923 _scopes: BTreeSet<String>,
16924}
16925
16926impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmPatchCall<'a, C> {}
16927
16928impl<'a, C> ProjectLocationSourceMigratingVmPatchCall<'a, C>
16929where
16930 C: common::Connector,
16931{
16932 /// Perform the operation you have build so far.
16933 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
16934 use std::borrow::Cow;
16935 use std::io::{Read, Seek};
16936
16937 use common::{url::Params, ToParts};
16938 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16939
16940 let mut dd = common::DefaultDelegate;
16941 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16942 dlg.begin(common::MethodInfo {
16943 id: "vmmigration.projects.locations.sources.migratingVms.patch",
16944 http_method: hyper::Method::PATCH,
16945 });
16946
16947 for &field in ["alt", "name", "updateMask", "requestId"].iter() {
16948 if self._additional_params.contains_key(field) {
16949 dlg.finished(false);
16950 return Err(common::Error::FieldClash(field));
16951 }
16952 }
16953
16954 let mut params = Params::with_capacity(6 + self._additional_params.len());
16955 params.push("name", self._name);
16956 if let Some(value) = self._update_mask.as_ref() {
16957 params.push("updateMask", value.to_string());
16958 }
16959 if let Some(value) = self._request_id.as_ref() {
16960 params.push("requestId", value);
16961 }
16962
16963 params.extend(self._additional_params.iter());
16964
16965 params.push("alt", "json");
16966 let mut url = self.hub._base_url.clone() + "v1/{+name}";
16967 if self._scopes.is_empty() {
16968 self._scopes
16969 .insert(Scope::CloudPlatform.as_ref().to_string());
16970 }
16971
16972 #[allow(clippy::single_element_loop)]
16973 for &(find_this, param_name) in [("{+name}", "name")].iter() {
16974 url = params.uri_replacement(url, param_name, find_this, true);
16975 }
16976 {
16977 let to_remove = ["name"];
16978 params.remove_params(&to_remove);
16979 }
16980
16981 let url = params.parse_with_url(&url);
16982
16983 let mut json_mime_type = mime::APPLICATION_JSON;
16984 let mut request_value_reader = {
16985 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16986 common::remove_json_null_values(&mut value);
16987 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16988 serde_json::to_writer(&mut dst, &value).unwrap();
16989 dst
16990 };
16991 let request_size = request_value_reader
16992 .seek(std::io::SeekFrom::End(0))
16993 .unwrap();
16994 request_value_reader
16995 .seek(std::io::SeekFrom::Start(0))
16996 .unwrap();
16997
16998 loop {
16999 let token = match self
17000 .hub
17001 .auth
17002 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17003 .await
17004 {
17005 Ok(token) => token,
17006 Err(e) => match dlg.token(e) {
17007 Ok(token) => token,
17008 Err(e) => {
17009 dlg.finished(false);
17010 return Err(common::Error::MissingToken(e));
17011 }
17012 },
17013 };
17014 request_value_reader
17015 .seek(std::io::SeekFrom::Start(0))
17016 .unwrap();
17017 let mut req_result = {
17018 let client = &self.hub.client;
17019 dlg.pre_request();
17020 let mut req_builder = hyper::Request::builder()
17021 .method(hyper::Method::PATCH)
17022 .uri(url.as_str())
17023 .header(USER_AGENT, self.hub._user_agent.clone());
17024
17025 if let Some(token) = token.as_ref() {
17026 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17027 }
17028
17029 let request = req_builder
17030 .header(CONTENT_TYPE, json_mime_type.to_string())
17031 .header(CONTENT_LENGTH, request_size as u64)
17032 .body(common::to_body(
17033 request_value_reader.get_ref().clone().into(),
17034 ));
17035
17036 client.request(request.unwrap()).await
17037 };
17038
17039 match req_result {
17040 Err(err) => {
17041 if let common::Retry::After(d) = dlg.http_error(&err) {
17042 sleep(d).await;
17043 continue;
17044 }
17045 dlg.finished(false);
17046 return Err(common::Error::HttpError(err));
17047 }
17048 Ok(res) => {
17049 let (mut parts, body) = res.into_parts();
17050 let mut body = common::Body::new(body);
17051 if !parts.status.is_success() {
17052 let bytes = common::to_bytes(body).await.unwrap_or_default();
17053 let error = serde_json::from_str(&common::to_string(&bytes));
17054 let response = common::to_response(parts, bytes.into());
17055
17056 if let common::Retry::After(d) =
17057 dlg.http_failure(&response, error.as_ref().ok())
17058 {
17059 sleep(d).await;
17060 continue;
17061 }
17062
17063 dlg.finished(false);
17064
17065 return Err(match error {
17066 Ok(value) => common::Error::BadRequest(value),
17067 _ => common::Error::Failure(response),
17068 });
17069 }
17070 let response = {
17071 let bytes = common::to_bytes(body).await.unwrap_or_default();
17072 let encoded = common::to_string(&bytes);
17073 match serde_json::from_str(&encoded) {
17074 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17075 Err(error) => {
17076 dlg.response_json_decode_error(&encoded, &error);
17077 return Err(common::Error::JsonDecodeError(
17078 encoded.to_string(),
17079 error,
17080 ));
17081 }
17082 }
17083 };
17084
17085 dlg.finished(true);
17086 return Ok(response);
17087 }
17088 }
17089 }
17090 }
17091
17092 ///
17093 /// Sets the *request* property to the given value.
17094 ///
17095 /// Even though the property as already been set when instantiating this call,
17096 /// we provide this method for API completeness.
17097 pub fn request(
17098 mut self,
17099 new_value: MigratingVm,
17100 ) -> ProjectLocationSourceMigratingVmPatchCall<'a, C> {
17101 self._request = new_value;
17102 self
17103 }
17104 /// Output only. The identifier of the MigratingVm.
17105 ///
17106 /// Sets the *name* path property to the given value.
17107 ///
17108 /// Even though the property as already been set when instantiating this call,
17109 /// we provide this method for API completeness.
17110 pub fn name(mut self, new_value: &str) -> ProjectLocationSourceMigratingVmPatchCall<'a, C> {
17111 self._name = new_value.to_string();
17112 self
17113 }
17114 /// Field mask is used to specify the fields to be overwritten in the MigratingVm resource by the update. The fields specified in the update_mask are relative to the resource, not the full request. A field will be overwritten if it is in the mask. If the user does not provide a mask then all fields will be overwritten.
17115 ///
17116 /// Sets the *update mask* query property to the given value.
17117 pub fn update_mask(
17118 mut self,
17119 new_value: common::FieldMask,
17120 ) -> ProjectLocationSourceMigratingVmPatchCall<'a, C> {
17121 self._update_mask = Some(new_value);
17122 self
17123 }
17124 /// A request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes since the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
17125 ///
17126 /// Sets the *request id* query property to the given value.
17127 pub fn request_id(
17128 mut self,
17129 new_value: &str,
17130 ) -> ProjectLocationSourceMigratingVmPatchCall<'a, C> {
17131 self._request_id = Some(new_value.to_string());
17132 self
17133 }
17134 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17135 /// while executing the actual API request.
17136 ///
17137 /// ````text
17138 /// It should be used to handle progress information, and to implement a certain level of resilience.
17139 /// ````
17140 ///
17141 /// Sets the *delegate* property to the given value.
17142 pub fn delegate(
17143 mut self,
17144 new_value: &'a mut dyn common::Delegate,
17145 ) -> ProjectLocationSourceMigratingVmPatchCall<'a, C> {
17146 self._delegate = Some(new_value);
17147 self
17148 }
17149
17150 /// Set any additional parameter of the query string used in the request.
17151 /// It should be used to set parameters which are not yet available through their own
17152 /// setters.
17153 ///
17154 /// Please note that this method must not be used to set any of the known parameters
17155 /// which have their own setter method. If done anyway, the request will fail.
17156 ///
17157 /// # Additional Parameters
17158 ///
17159 /// * *$.xgafv* (query-string) - V1 error format.
17160 /// * *access_token* (query-string) - OAuth access token.
17161 /// * *alt* (query-string) - Data format for response.
17162 /// * *callback* (query-string) - JSONP
17163 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17164 /// * *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.
17165 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17166 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17167 /// * *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.
17168 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17169 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17170 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSourceMigratingVmPatchCall<'a, C>
17171 where
17172 T: AsRef<str>,
17173 {
17174 self._additional_params
17175 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17176 self
17177 }
17178
17179 /// Identifies the authorization scope for the method you are building.
17180 ///
17181 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17182 /// [`Scope::CloudPlatform`].
17183 ///
17184 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17185 /// tokens for more than one scope.
17186 ///
17187 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17188 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17189 /// sufficient, a read-write scope will do as well.
17190 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceMigratingVmPatchCall<'a, C>
17191 where
17192 St: AsRef<str>,
17193 {
17194 self._scopes.insert(String::from(scope.as_ref()));
17195 self
17196 }
17197 /// Identifies the authorization scope(s) for the method you are building.
17198 ///
17199 /// See [`Self::add_scope()`] for details.
17200 pub fn add_scopes<I, St>(
17201 mut self,
17202 scopes: I,
17203 ) -> ProjectLocationSourceMigratingVmPatchCall<'a, C>
17204 where
17205 I: IntoIterator<Item = St>,
17206 St: AsRef<str>,
17207 {
17208 self._scopes
17209 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17210 self
17211 }
17212
17213 /// Removes all scopes, and no default scope will be used either.
17214 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17215 /// for details).
17216 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmPatchCall<'a, C> {
17217 self._scopes.clear();
17218 self
17219 }
17220}
17221
17222/// Pauses a migration for a VM. If cycle tasks are running they will be cancelled, preserving source task data. Further replication cycles will not be triggered while the VM is paused.
17223///
17224/// A builder for the *locations.sources.migratingVms.pauseMigration* method supported by a *project* resource.
17225/// It is not used directly, but through a [`ProjectMethods`] instance.
17226///
17227/// # Example
17228///
17229/// Instantiate a resource method builder
17230///
17231/// ```test_harness,no_run
17232/// # extern crate hyper;
17233/// # extern crate hyper_rustls;
17234/// # extern crate google_vmmigration1 as vmmigration1;
17235/// use vmmigration1::api::PauseMigrationRequest;
17236/// # async fn dox() {
17237/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17238///
17239/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17240/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17241/// # secret,
17242/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17243/// # ).build().await.unwrap();
17244///
17245/// # let client = hyper_util::client::legacy::Client::builder(
17246/// # hyper_util::rt::TokioExecutor::new()
17247/// # )
17248/// # .build(
17249/// # hyper_rustls::HttpsConnectorBuilder::new()
17250/// # .with_native_roots()
17251/// # .unwrap()
17252/// # .https_or_http()
17253/// # .enable_http1()
17254/// # .build()
17255/// # );
17256/// # let mut hub = VMMigrationService::new(client, auth);
17257/// // As the method needs a request, you would usually fill it with the desired information
17258/// // into the respective structure. Some of the parts shown here might not be applicable !
17259/// // Values shown here are possibly random and not representative !
17260/// let mut req = PauseMigrationRequest::default();
17261///
17262/// // You can configure optional parameters by calling the respective setters at will, and
17263/// // execute the final call using `doit()`.
17264/// // Values shown here are possibly random and not representative !
17265/// let result = hub.projects().locations_sources_migrating_vms_pause_migration(req, "migratingVm")
17266/// .doit().await;
17267/// # }
17268/// ```
17269pub struct ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C>
17270where
17271 C: 'a,
17272{
17273 hub: &'a VMMigrationService<C>,
17274 _request: PauseMigrationRequest,
17275 _migrating_vm: String,
17276 _delegate: Option<&'a mut dyn common::Delegate>,
17277 _additional_params: HashMap<String, String>,
17278 _scopes: BTreeSet<String>,
17279}
17280
17281impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C> {}
17282
17283impl<'a, C> ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C>
17284where
17285 C: common::Connector,
17286{
17287 /// Perform the operation you have build so far.
17288 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
17289 use std::borrow::Cow;
17290 use std::io::{Read, Seek};
17291
17292 use common::{url::Params, ToParts};
17293 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17294
17295 let mut dd = common::DefaultDelegate;
17296 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17297 dlg.begin(common::MethodInfo {
17298 id: "vmmigration.projects.locations.sources.migratingVms.pauseMigration",
17299 http_method: hyper::Method::POST,
17300 });
17301
17302 for &field in ["alt", "migratingVm"].iter() {
17303 if self._additional_params.contains_key(field) {
17304 dlg.finished(false);
17305 return Err(common::Error::FieldClash(field));
17306 }
17307 }
17308
17309 let mut params = Params::with_capacity(4 + self._additional_params.len());
17310 params.push("migratingVm", self._migrating_vm);
17311
17312 params.extend(self._additional_params.iter());
17313
17314 params.push("alt", "json");
17315 let mut url = self.hub._base_url.clone() + "v1/{+migratingVm}:pauseMigration";
17316 if self._scopes.is_empty() {
17317 self._scopes
17318 .insert(Scope::CloudPlatform.as_ref().to_string());
17319 }
17320
17321 #[allow(clippy::single_element_loop)]
17322 for &(find_this, param_name) in [("{+migratingVm}", "migratingVm")].iter() {
17323 url = params.uri_replacement(url, param_name, find_this, true);
17324 }
17325 {
17326 let to_remove = ["migratingVm"];
17327 params.remove_params(&to_remove);
17328 }
17329
17330 let url = params.parse_with_url(&url);
17331
17332 let mut json_mime_type = mime::APPLICATION_JSON;
17333 let mut request_value_reader = {
17334 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17335 common::remove_json_null_values(&mut value);
17336 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17337 serde_json::to_writer(&mut dst, &value).unwrap();
17338 dst
17339 };
17340 let request_size = request_value_reader
17341 .seek(std::io::SeekFrom::End(0))
17342 .unwrap();
17343 request_value_reader
17344 .seek(std::io::SeekFrom::Start(0))
17345 .unwrap();
17346
17347 loop {
17348 let token = match self
17349 .hub
17350 .auth
17351 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17352 .await
17353 {
17354 Ok(token) => token,
17355 Err(e) => match dlg.token(e) {
17356 Ok(token) => token,
17357 Err(e) => {
17358 dlg.finished(false);
17359 return Err(common::Error::MissingToken(e));
17360 }
17361 },
17362 };
17363 request_value_reader
17364 .seek(std::io::SeekFrom::Start(0))
17365 .unwrap();
17366 let mut req_result = {
17367 let client = &self.hub.client;
17368 dlg.pre_request();
17369 let mut req_builder = hyper::Request::builder()
17370 .method(hyper::Method::POST)
17371 .uri(url.as_str())
17372 .header(USER_AGENT, self.hub._user_agent.clone());
17373
17374 if let Some(token) = token.as_ref() {
17375 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17376 }
17377
17378 let request = req_builder
17379 .header(CONTENT_TYPE, json_mime_type.to_string())
17380 .header(CONTENT_LENGTH, request_size as u64)
17381 .body(common::to_body(
17382 request_value_reader.get_ref().clone().into(),
17383 ));
17384
17385 client.request(request.unwrap()).await
17386 };
17387
17388 match req_result {
17389 Err(err) => {
17390 if let common::Retry::After(d) = dlg.http_error(&err) {
17391 sleep(d).await;
17392 continue;
17393 }
17394 dlg.finished(false);
17395 return Err(common::Error::HttpError(err));
17396 }
17397 Ok(res) => {
17398 let (mut parts, body) = res.into_parts();
17399 let mut body = common::Body::new(body);
17400 if !parts.status.is_success() {
17401 let bytes = common::to_bytes(body).await.unwrap_or_default();
17402 let error = serde_json::from_str(&common::to_string(&bytes));
17403 let response = common::to_response(parts, bytes.into());
17404
17405 if let common::Retry::After(d) =
17406 dlg.http_failure(&response, error.as_ref().ok())
17407 {
17408 sleep(d).await;
17409 continue;
17410 }
17411
17412 dlg.finished(false);
17413
17414 return Err(match error {
17415 Ok(value) => common::Error::BadRequest(value),
17416 _ => common::Error::Failure(response),
17417 });
17418 }
17419 let response = {
17420 let bytes = common::to_bytes(body).await.unwrap_or_default();
17421 let encoded = common::to_string(&bytes);
17422 match serde_json::from_str(&encoded) {
17423 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17424 Err(error) => {
17425 dlg.response_json_decode_error(&encoded, &error);
17426 return Err(common::Error::JsonDecodeError(
17427 encoded.to_string(),
17428 error,
17429 ));
17430 }
17431 }
17432 };
17433
17434 dlg.finished(true);
17435 return Ok(response);
17436 }
17437 }
17438 }
17439 }
17440
17441 ///
17442 /// Sets the *request* property to the given value.
17443 ///
17444 /// Even though the property as already been set when instantiating this call,
17445 /// we provide this method for API completeness.
17446 pub fn request(
17447 mut self,
17448 new_value: PauseMigrationRequest,
17449 ) -> ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C> {
17450 self._request = new_value;
17451 self
17452 }
17453 /// Required. The name of the MigratingVm.
17454 ///
17455 /// Sets the *migrating vm* path property to the given value.
17456 ///
17457 /// Even though the property as already been set when instantiating this call,
17458 /// we provide this method for API completeness.
17459 pub fn migrating_vm(
17460 mut self,
17461 new_value: &str,
17462 ) -> ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C> {
17463 self._migrating_vm = new_value.to_string();
17464 self
17465 }
17466 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17467 /// while executing the actual API request.
17468 ///
17469 /// ````text
17470 /// It should be used to handle progress information, and to implement a certain level of resilience.
17471 /// ````
17472 ///
17473 /// Sets the *delegate* property to the given value.
17474 pub fn delegate(
17475 mut self,
17476 new_value: &'a mut dyn common::Delegate,
17477 ) -> ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C> {
17478 self._delegate = Some(new_value);
17479 self
17480 }
17481
17482 /// Set any additional parameter of the query string used in the request.
17483 /// It should be used to set parameters which are not yet available through their own
17484 /// setters.
17485 ///
17486 /// Please note that this method must not be used to set any of the known parameters
17487 /// which have their own setter method. If done anyway, the request will fail.
17488 ///
17489 /// # Additional Parameters
17490 ///
17491 /// * *$.xgafv* (query-string) - V1 error format.
17492 /// * *access_token* (query-string) - OAuth access token.
17493 /// * *alt* (query-string) - Data format for response.
17494 /// * *callback* (query-string) - JSONP
17495 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17496 /// * *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.
17497 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17498 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17499 /// * *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.
17500 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17501 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17502 pub fn param<T>(
17503 mut self,
17504 name: T,
17505 value: T,
17506 ) -> ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C>
17507 where
17508 T: AsRef<str>,
17509 {
17510 self._additional_params
17511 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17512 self
17513 }
17514
17515 /// Identifies the authorization scope for the method you are building.
17516 ///
17517 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17518 /// [`Scope::CloudPlatform`].
17519 ///
17520 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17521 /// tokens for more than one scope.
17522 ///
17523 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17524 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17525 /// sufficient, a read-write scope will do as well.
17526 pub fn add_scope<St>(
17527 mut self,
17528 scope: St,
17529 ) -> ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C>
17530 where
17531 St: AsRef<str>,
17532 {
17533 self._scopes.insert(String::from(scope.as_ref()));
17534 self
17535 }
17536 /// Identifies the authorization scope(s) for the method you are building.
17537 ///
17538 /// See [`Self::add_scope()`] for details.
17539 pub fn add_scopes<I, St>(
17540 mut self,
17541 scopes: I,
17542 ) -> ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C>
17543 where
17544 I: IntoIterator<Item = St>,
17545 St: AsRef<str>,
17546 {
17547 self._scopes
17548 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17549 self
17550 }
17551
17552 /// Removes all scopes, and no default scope will be used either.
17553 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17554 /// for details).
17555 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C> {
17556 self._scopes.clear();
17557 self
17558 }
17559}
17560
17561/// Resumes a migration for a VM. When called on a paused migration, will start the process of uploading data and creating snapshots; when called on a completed cut-over migration, will update the migration to active state and start the process of uploading data and creating snapshots.
17562///
17563/// A builder for the *locations.sources.migratingVms.resumeMigration* method supported by a *project* resource.
17564/// It is not used directly, but through a [`ProjectMethods`] instance.
17565///
17566/// # Example
17567///
17568/// Instantiate a resource method builder
17569///
17570/// ```test_harness,no_run
17571/// # extern crate hyper;
17572/// # extern crate hyper_rustls;
17573/// # extern crate google_vmmigration1 as vmmigration1;
17574/// use vmmigration1::api::ResumeMigrationRequest;
17575/// # async fn dox() {
17576/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17577///
17578/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17579/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17580/// # secret,
17581/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17582/// # ).build().await.unwrap();
17583///
17584/// # let client = hyper_util::client::legacy::Client::builder(
17585/// # hyper_util::rt::TokioExecutor::new()
17586/// # )
17587/// # .build(
17588/// # hyper_rustls::HttpsConnectorBuilder::new()
17589/// # .with_native_roots()
17590/// # .unwrap()
17591/// # .https_or_http()
17592/// # .enable_http1()
17593/// # .build()
17594/// # );
17595/// # let mut hub = VMMigrationService::new(client, auth);
17596/// // As the method needs a request, you would usually fill it with the desired information
17597/// // into the respective structure. Some of the parts shown here might not be applicable !
17598/// // Values shown here are possibly random and not representative !
17599/// let mut req = ResumeMigrationRequest::default();
17600///
17601/// // You can configure optional parameters by calling the respective setters at will, and
17602/// // execute the final call using `doit()`.
17603/// // Values shown here are possibly random and not representative !
17604/// let result = hub.projects().locations_sources_migrating_vms_resume_migration(req, "migratingVm")
17605/// .doit().await;
17606/// # }
17607/// ```
17608pub struct ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C>
17609where
17610 C: 'a,
17611{
17612 hub: &'a VMMigrationService<C>,
17613 _request: ResumeMigrationRequest,
17614 _migrating_vm: String,
17615 _delegate: Option<&'a mut dyn common::Delegate>,
17616 _additional_params: HashMap<String, String>,
17617 _scopes: BTreeSet<String>,
17618}
17619
17620impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C> {}
17621
17622impl<'a, C> ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C>
17623where
17624 C: common::Connector,
17625{
17626 /// Perform the operation you have build so far.
17627 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
17628 use std::borrow::Cow;
17629 use std::io::{Read, Seek};
17630
17631 use common::{url::Params, ToParts};
17632 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17633
17634 let mut dd = common::DefaultDelegate;
17635 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17636 dlg.begin(common::MethodInfo {
17637 id: "vmmigration.projects.locations.sources.migratingVms.resumeMigration",
17638 http_method: hyper::Method::POST,
17639 });
17640
17641 for &field in ["alt", "migratingVm"].iter() {
17642 if self._additional_params.contains_key(field) {
17643 dlg.finished(false);
17644 return Err(common::Error::FieldClash(field));
17645 }
17646 }
17647
17648 let mut params = Params::with_capacity(4 + self._additional_params.len());
17649 params.push("migratingVm", self._migrating_vm);
17650
17651 params.extend(self._additional_params.iter());
17652
17653 params.push("alt", "json");
17654 let mut url = self.hub._base_url.clone() + "v1/{+migratingVm}:resumeMigration";
17655 if self._scopes.is_empty() {
17656 self._scopes
17657 .insert(Scope::CloudPlatform.as_ref().to_string());
17658 }
17659
17660 #[allow(clippy::single_element_loop)]
17661 for &(find_this, param_name) in [("{+migratingVm}", "migratingVm")].iter() {
17662 url = params.uri_replacement(url, param_name, find_this, true);
17663 }
17664 {
17665 let to_remove = ["migratingVm"];
17666 params.remove_params(&to_remove);
17667 }
17668
17669 let url = params.parse_with_url(&url);
17670
17671 let mut json_mime_type = mime::APPLICATION_JSON;
17672 let mut request_value_reader = {
17673 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17674 common::remove_json_null_values(&mut value);
17675 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17676 serde_json::to_writer(&mut dst, &value).unwrap();
17677 dst
17678 };
17679 let request_size = request_value_reader
17680 .seek(std::io::SeekFrom::End(0))
17681 .unwrap();
17682 request_value_reader
17683 .seek(std::io::SeekFrom::Start(0))
17684 .unwrap();
17685
17686 loop {
17687 let token = match self
17688 .hub
17689 .auth
17690 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17691 .await
17692 {
17693 Ok(token) => token,
17694 Err(e) => match dlg.token(e) {
17695 Ok(token) => token,
17696 Err(e) => {
17697 dlg.finished(false);
17698 return Err(common::Error::MissingToken(e));
17699 }
17700 },
17701 };
17702 request_value_reader
17703 .seek(std::io::SeekFrom::Start(0))
17704 .unwrap();
17705 let mut req_result = {
17706 let client = &self.hub.client;
17707 dlg.pre_request();
17708 let mut req_builder = hyper::Request::builder()
17709 .method(hyper::Method::POST)
17710 .uri(url.as_str())
17711 .header(USER_AGENT, self.hub._user_agent.clone());
17712
17713 if let Some(token) = token.as_ref() {
17714 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17715 }
17716
17717 let request = req_builder
17718 .header(CONTENT_TYPE, json_mime_type.to_string())
17719 .header(CONTENT_LENGTH, request_size as u64)
17720 .body(common::to_body(
17721 request_value_reader.get_ref().clone().into(),
17722 ));
17723
17724 client.request(request.unwrap()).await
17725 };
17726
17727 match req_result {
17728 Err(err) => {
17729 if let common::Retry::After(d) = dlg.http_error(&err) {
17730 sleep(d).await;
17731 continue;
17732 }
17733 dlg.finished(false);
17734 return Err(common::Error::HttpError(err));
17735 }
17736 Ok(res) => {
17737 let (mut parts, body) = res.into_parts();
17738 let mut body = common::Body::new(body);
17739 if !parts.status.is_success() {
17740 let bytes = common::to_bytes(body).await.unwrap_or_default();
17741 let error = serde_json::from_str(&common::to_string(&bytes));
17742 let response = common::to_response(parts, bytes.into());
17743
17744 if let common::Retry::After(d) =
17745 dlg.http_failure(&response, error.as_ref().ok())
17746 {
17747 sleep(d).await;
17748 continue;
17749 }
17750
17751 dlg.finished(false);
17752
17753 return Err(match error {
17754 Ok(value) => common::Error::BadRequest(value),
17755 _ => common::Error::Failure(response),
17756 });
17757 }
17758 let response = {
17759 let bytes = common::to_bytes(body).await.unwrap_or_default();
17760 let encoded = common::to_string(&bytes);
17761 match serde_json::from_str(&encoded) {
17762 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17763 Err(error) => {
17764 dlg.response_json_decode_error(&encoded, &error);
17765 return Err(common::Error::JsonDecodeError(
17766 encoded.to_string(),
17767 error,
17768 ));
17769 }
17770 }
17771 };
17772
17773 dlg.finished(true);
17774 return Ok(response);
17775 }
17776 }
17777 }
17778 }
17779
17780 ///
17781 /// Sets the *request* property to the given value.
17782 ///
17783 /// Even though the property as already been set when instantiating this call,
17784 /// we provide this method for API completeness.
17785 pub fn request(
17786 mut self,
17787 new_value: ResumeMigrationRequest,
17788 ) -> ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C> {
17789 self._request = new_value;
17790 self
17791 }
17792 /// Required. The name of the MigratingVm.
17793 ///
17794 /// Sets the *migrating vm* path property to the given value.
17795 ///
17796 /// Even though the property as already been set when instantiating this call,
17797 /// we provide this method for API completeness.
17798 pub fn migrating_vm(
17799 mut self,
17800 new_value: &str,
17801 ) -> ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C> {
17802 self._migrating_vm = new_value.to_string();
17803 self
17804 }
17805 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17806 /// while executing the actual API request.
17807 ///
17808 /// ````text
17809 /// It should be used to handle progress information, and to implement a certain level of resilience.
17810 /// ````
17811 ///
17812 /// Sets the *delegate* property to the given value.
17813 pub fn delegate(
17814 mut self,
17815 new_value: &'a mut dyn common::Delegate,
17816 ) -> ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C> {
17817 self._delegate = Some(new_value);
17818 self
17819 }
17820
17821 /// Set any additional parameter of the query string used in the request.
17822 /// It should be used to set parameters which are not yet available through their own
17823 /// setters.
17824 ///
17825 /// Please note that this method must not be used to set any of the known parameters
17826 /// which have their own setter method. If done anyway, the request will fail.
17827 ///
17828 /// # Additional Parameters
17829 ///
17830 /// * *$.xgafv* (query-string) - V1 error format.
17831 /// * *access_token* (query-string) - OAuth access token.
17832 /// * *alt* (query-string) - Data format for response.
17833 /// * *callback* (query-string) - JSONP
17834 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17835 /// * *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.
17836 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17837 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17838 /// * *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.
17839 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17840 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17841 pub fn param<T>(
17842 mut self,
17843 name: T,
17844 value: T,
17845 ) -> ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C>
17846 where
17847 T: AsRef<str>,
17848 {
17849 self._additional_params
17850 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17851 self
17852 }
17853
17854 /// Identifies the authorization scope for the method you are building.
17855 ///
17856 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17857 /// [`Scope::CloudPlatform`].
17858 ///
17859 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17860 /// tokens for more than one scope.
17861 ///
17862 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17863 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17864 /// sufficient, a read-write scope will do as well.
17865 pub fn add_scope<St>(
17866 mut self,
17867 scope: St,
17868 ) -> ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C>
17869 where
17870 St: AsRef<str>,
17871 {
17872 self._scopes.insert(String::from(scope.as_ref()));
17873 self
17874 }
17875 /// Identifies the authorization scope(s) for the method you are building.
17876 ///
17877 /// See [`Self::add_scope()`] for details.
17878 pub fn add_scopes<I, St>(
17879 mut self,
17880 scopes: I,
17881 ) -> ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C>
17882 where
17883 I: IntoIterator<Item = St>,
17884 St: AsRef<str>,
17885 {
17886 self._scopes
17887 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17888 self
17889 }
17890
17891 /// Removes all scopes, and no default scope will be used either.
17892 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17893 /// for details).
17894 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C> {
17895 self._scopes.clear();
17896 self
17897 }
17898}
17899
17900/// Starts migration for a VM. Starts the process of uploading data and creating snapshots, in replication cycles scheduled by the policy.
17901///
17902/// A builder for the *locations.sources.migratingVms.startMigration* method supported by a *project* resource.
17903/// It is not used directly, but through a [`ProjectMethods`] instance.
17904///
17905/// # Example
17906///
17907/// Instantiate a resource method builder
17908///
17909/// ```test_harness,no_run
17910/// # extern crate hyper;
17911/// # extern crate hyper_rustls;
17912/// # extern crate google_vmmigration1 as vmmigration1;
17913/// use vmmigration1::api::StartMigrationRequest;
17914/// # async fn dox() {
17915/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17916///
17917/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17918/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17919/// # secret,
17920/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17921/// # ).build().await.unwrap();
17922///
17923/// # let client = hyper_util::client::legacy::Client::builder(
17924/// # hyper_util::rt::TokioExecutor::new()
17925/// # )
17926/// # .build(
17927/// # hyper_rustls::HttpsConnectorBuilder::new()
17928/// # .with_native_roots()
17929/// # .unwrap()
17930/// # .https_or_http()
17931/// # .enable_http1()
17932/// # .build()
17933/// # );
17934/// # let mut hub = VMMigrationService::new(client, auth);
17935/// // As the method needs a request, you would usually fill it with the desired information
17936/// // into the respective structure. Some of the parts shown here might not be applicable !
17937/// // Values shown here are possibly random and not representative !
17938/// let mut req = StartMigrationRequest::default();
17939///
17940/// // You can configure optional parameters by calling the respective setters at will, and
17941/// // execute the final call using `doit()`.
17942/// // Values shown here are possibly random and not representative !
17943/// let result = hub.projects().locations_sources_migrating_vms_start_migration(req, "migratingVm")
17944/// .doit().await;
17945/// # }
17946/// ```
17947pub struct ProjectLocationSourceMigratingVmStartMigrationCall<'a, C>
17948where
17949 C: 'a,
17950{
17951 hub: &'a VMMigrationService<C>,
17952 _request: StartMigrationRequest,
17953 _migrating_vm: String,
17954 _delegate: Option<&'a mut dyn common::Delegate>,
17955 _additional_params: HashMap<String, String>,
17956 _scopes: BTreeSet<String>,
17957}
17958
17959impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmStartMigrationCall<'a, C> {}
17960
17961impl<'a, C> ProjectLocationSourceMigratingVmStartMigrationCall<'a, C>
17962where
17963 C: common::Connector,
17964{
17965 /// Perform the operation you have build so far.
17966 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
17967 use std::borrow::Cow;
17968 use std::io::{Read, Seek};
17969
17970 use common::{url::Params, ToParts};
17971 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17972
17973 let mut dd = common::DefaultDelegate;
17974 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17975 dlg.begin(common::MethodInfo {
17976 id: "vmmigration.projects.locations.sources.migratingVms.startMigration",
17977 http_method: hyper::Method::POST,
17978 });
17979
17980 for &field in ["alt", "migratingVm"].iter() {
17981 if self._additional_params.contains_key(field) {
17982 dlg.finished(false);
17983 return Err(common::Error::FieldClash(field));
17984 }
17985 }
17986
17987 let mut params = Params::with_capacity(4 + self._additional_params.len());
17988 params.push("migratingVm", self._migrating_vm);
17989
17990 params.extend(self._additional_params.iter());
17991
17992 params.push("alt", "json");
17993 let mut url = self.hub._base_url.clone() + "v1/{+migratingVm}:startMigration";
17994 if self._scopes.is_empty() {
17995 self._scopes
17996 .insert(Scope::CloudPlatform.as_ref().to_string());
17997 }
17998
17999 #[allow(clippy::single_element_loop)]
18000 for &(find_this, param_name) in [("{+migratingVm}", "migratingVm")].iter() {
18001 url = params.uri_replacement(url, param_name, find_this, true);
18002 }
18003 {
18004 let to_remove = ["migratingVm"];
18005 params.remove_params(&to_remove);
18006 }
18007
18008 let url = params.parse_with_url(&url);
18009
18010 let mut json_mime_type = mime::APPLICATION_JSON;
18011 let mut request_value_reader = {
18012 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18013 common::remove_json_null_values(&mut value);
18014 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18015 serde_json::to_writer(&mut dst, &value).unwrap();
18016 dst
18017 };
18018 let request_size = request_value_reader
18019 .seek(std::io::SeekFrom::End(0))
18020 .unwrap();
18021 request_value_reader
18022 .seek(std::io::SeekFrom::Start(0))
18023 .unwrap();
18024
18025 loop {
18026 let token = match self
18027 .hub
18028 .auth
18029 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18030 .await
18031 {
18032 Ok(token) => token,
18033 Err(e) => match dlg.token(e) {
18034 Ok(token) => token,
18035 Err(e) => {
18036 dlg.finished(false);
18037 return Err(common::Error::MissingToken(e));
18038 }
18039 },
18040 };
18041 request_value_reader
18042 .seek(std::io::SeekFrom::Start(0))
18043 .unwrap();
18044 let mut req_result = {
18045 let client = &self.hub.client;
18046 dlg.pre_request();
18047 let mut req_builder = hyper::Request::builder()
18048 .method(hyper::Method::POST)
18049 .uri(url.as_str())
18050 .header(USER_AGENT, self.hub._user_agent.clone());
18051
18052 if let Some(token) = token.as_ref() {
18053 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18054 }
18055
18056 let request = req_builder
18057 .header(CONTENT_TYPE, json_mime_type.to_string())
18058 .header(CONTENT_LENGTH, request_size as u64)
18059 .body(common::to_body(
18060 request_value_reader.get_ref().clone().into(),
18061 ));
18062
18063 client.request(request.unwrap()).await
18064 };
18065
18066 match req_result {
18067 Err(err) => {
18068 if let common::Retry::After(d) = dlg.http_error(&err) {
18069 sleep(d).await;
18070 continue;
18071 }
18072 dlg.finished(false);
18073 return Err(common::Error::HttpError(err));
18074 }
18075 Ok(res) => {
18076 let (mut parts, body) = res.into_parts();
18077 let mut body = common::Body::new(body);
18078 if !parts.status.is_success() {
18079 let bytes = common::to_bytes(body).await.unwrap_or_default();
18080 let error = serde_json::from_str(&common::to_string(&bytes));
18081 let response = common::to_response(parts, bytes.into());
18082
18083 if let common::Retry::After(d) =
18084 dlg.http_failure(&response, error.as_ref().ok())
18085 {
18086 sleep(d).await;
18087 continue;
18088 }
18089
18090 dlg.finished(false);
18091
18092 return Err(match error {
18093 Ok(value) => common::Error::BadRequest(value),
18094 _ => common::Error::Failure(response),
18095 });
18096 }
18097 let response = {
18098 let bytes = common::to_bytes(body).await.unwrap_or_default();
18099 let encoded = common::to_string(&bytes);
18100 match serde_json::from_str(&encoded) {
18101 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18102 Err(error) => {
18103 dlg.response_json_decode_error(&encoded, &error);
18104 return Err(common::Error::JsonDecodeError(
18105 encoded.to_string(),
18106 error,
18107 ));
18108 }
18109 }
18110 };
18111
18112 dlg.finished(true);
18113 return Ok(response);
18114 }
18115 }
18116 }
18117 }
18118
18119 ///
18120 /// Sets the *request* property to the given value.
18121 ///
18122 /// Even though the property as already been set when instantiating this call,
18123 /// we provide this method for API completeness.
18124 pub fn request(
18125 mut self,
18126 new_value: StartMigrationRequest,
18127 ) -> ProjectLocationSourceMigratingVmStartMigrationCall<'a, C> {
18128 self._request = new_value;
18129 self
18130 }
18131 /// Required. The name of the MigratingVm.
18132 ///
18133 /// Sets the *migrating vm* path property to the given value.
18134 ///
18135 /// Even though the property as already been set when instantiating this call,
18136 /// we provide this method for API completeness.
18137 pub fn migrating_vm(
18138 mut self,
18139 new_value: &str,
18140 ) -> ProjectLocationSourceMigratingVmStartMigrationCall<'a, C> {
18141 self._migrating_vm = new_value.to_string();
18142 self
18143 }
18144 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18145 /// while executing the actual API request.
18146 ///
18147 /// ````text
18148 /// It should be used to handle progress information, and to implement a certain level of resilience.
18149 /// ````
18150 ///
18151 /// Sets the *delegate* property to the given value.
18152 pub fn delegate(
18153 mut self,
18154 new_value: &'a mut dyn common::Delegate,
18155 ) -> ProjectLocationSourceMigratingVmStartMigrationCall<'a, C> {
18156 self._delegate = Some(new_value);
18157 self
18158 }
18159
18160 /// Set any additional parameter of the query string used in the request.
18161 /// It should be used to set parameters which are not yet available through their own
18162 /// setters.
18163 ///
18164 /// Please note that this method must not be used to set any of the known parameters
18165 /// which have their own setter method. If done anyway, the request will fail.
18166 ///
18167 /// # Additional Parameters
18168 ///
18169 /// * *$.xgafv* (query-string) - V1 error format.
18170 /// * *access_token* (query-string) - OAuth access token.
18171 /// * *alt* (query-string) - Data format for response.
18172 /// * *callback* (query-string) - JSONP
18173 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18174 /// * *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.
18175 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18176 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18177 /// * *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.
18178 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18179 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18180 pub fn param<T>(
18181 mut self,
18182 name: T,
18183 value: T,
18184 ) -> ProjectLocationSourceMigratingVmStartMigrationCall<'a, C>
18185 where
18186 T: AsRef<str>,
18187 {
18188 self._additional_params
18189 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18190 self
18191 }
18192
18193 /// Identifies the authorization scope for the method you are building.
18194 ///
18195 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18196 /// [`Scope::CloudPlatform`].
18197 ///
18198 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18199 /// tokens for more than one scope.
18200 ///
18201 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18202 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18203 /// sufficient, a read-write scope will do as well.
18204 pub fn add_scope<St>(
18205 mut self,
18206 scope: St,
18207 ) -> ProjectLocationSourceMigratingVmStartMigrationCall<'a, C>
18208 where
18209 St: AsRef<str>,
18210 {
18211 self._scopes.insert(String::from(scope.as_ref()));
18212 self
18213 }
18214 /// Identifies the authorization scope(s) for the method you are building.
18215 ///
18216 /// See [`Self::add_scope()`] for details.
18217 pub fn add_scopes<I, St>(
18218 mut self,
18219 scopes: I,
18220 ) -> ProjectLocationSourceMigratingVmStartMigrationCall<'a, C>
18221 where
18222 I: IntoIterator<Item = St>,
18223 St: AsRef<str>,
18224 {
18225 self._scopes
18226 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18227 self
18228 }
18229
18230 /// Removes all scopes, and no default scope will be used either.
18231 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18232 /// for details).
18233 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmStartMigrationCall<'a, C> {
18234 self._scopes.clear();
18235 self
18236 }
18237}
18238
18239/// Creates a new UtilizationReport.
18240///
18241/// A builder for the *locations.sources.utilizationReports.create* method supported by a *project* resource.
18242/// It is not used directly, but through a [`ProjectMethods`] instance.
18243///
18244/// # Example
18245///
18246/// Instantiate a resource method builder
18247///
18248/// ```test_harness,no_run
18249/// # extern crate hyper;
18250/// # extern crate hyper_rustls;
18251/// # extern crate google_vmmigration1 as vmmigration1;
18252/// use vmmigration1::api::UtilizationReport;
18253/// # async fn dox() {
18254/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18255///
18256/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18257/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18258/// # secret,
18259/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18260/// # ).build().await.unwrap();
18261///
18262/// # let client = hyper_util::client::legacy::Client::builder(
18263/// # hyper_util::rt::TokioExecutor::new()
18264/// # )
18265/// # .build(
18266/// # hyper_rustls::HttpsConnectorBuilder::new()
18267/// # .with_native_roots()
18268/// # .unwrap()
18269/// # .https_or_http()
18270/// # .enable_http1()
18271/// # .build()
18272/// # );
18273/// # let mut hub = VMMigrationService::new(client, auth);
18274/// // As the method needs a request, you would usually fill it with the desired information
18275/// // into the respective structure. Some of the parts shown here might not be applicable !
18276/// // Values shown here are possibly random and not representative !
18277/// let mut req = UtilizationReport::default();
18278///
18279/// // You can configure optional parameters by calling the respective setters at will, and
18280/// // execute the final call using `doit()`.
18281/// // Values shown here are possibly random and not representative !
18282/// let result = hub.projects().locations_sources_utilization_reports_create(req, "parent")
18283/// .utilization_report_id("aliquyam")
18284/// .request_id("ipsum")
18285/// .doit().await;
18286/// # }
18287/// ```
18288pub struct ProjectLocationSourceUtilizationReportCreateCall<'a, C>
18289where
18290 C: 'a,
18291{
18292 hub: &'a VMMigrationService<C>,
18293 _request: UtilizationReport,
18294 _parent: String,
18295 _utilization_report_id: Option<String>,
18296 _request_id: Option<String>,
18297 _delegate: Option<&'a mut dyn common::Delegate>,
18298 _additional_params: HashMap<String, String>,
18299 _scopes: BTreeSet<String>,
18300}
18301
18302impl<'a, C> common::CallBuilder for ProjectLocationSourceUtilizationReportCreateCall<'a, C> {}
18303
18304impl<'a, C> ProjectLocationSourceUtilizationReportCreateCall<'a, C>
18305where
18306 C: common::Connector,
18307{
18308 /// Perform the operation you have build so far.
18309 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
18310 use std::borrow::Cow;
18311 use std::io::{Read, Seek};
18312
18313 use common::{url::Params, ToParts};
18314 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18315
18316 let mut dd = common::DefaultDelegate;
18317 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18318 dlg.begin(common::MethodInfo {
18319 id: "vmmigration.projects.locations.sources.utilizationReports.create",
18320 http_method: hyper::Method::POST,
18321 });
18322
18323 for &field in ["alt", "parent", "utilizationReportId", "requestId"].iter() {
18324 if self._additional_params.contains_key(field) {
18325 dlg.finished(false);
18326 return Err(common::Error::FieldClash(field));
18327 }
18328 }
18329
18330 let mut params = Params::with_capacity(6 + self._additional_params.len());
18331 params.push("parent", self._parent);
18332 if let Some(value) = self._utilization_report_id.as_ref() {
18333 params.push("utilizationReportId", value);
18334 }
18335 if let Some(value) = self._request_id.as_ref() {
18336 params.push("requestId", value);
18337 }
18338
18339 params.extend(self._additional_params.iter());
18340
18341 params.push("alt", "json");
18342 let mut url = self.hub._base_url.clone() + "v1/{+parent}/utilizationReports";
18343 if self._scopes.is_empty() {
18344 self._scopes
18345 .insert(Scope::CloudPlatform.as_ref().to_string());
18346 }
18347
18348 #[allow(clippy::single_element_loop)]
18349 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
18350 url = params.uri_replacement(url, param_name, find_this, true);
18351 }
18352 {
18353 let to_remove = ["parent"];
18354 params.remove_params(&to_remove);
18355 }
18356
18357 let url = params.parse_with_url(&url);
18358
18359 let mut json_mime_type = mime::APPLICATION_JSON;
18360 let mut request_value_reader = {
18361 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18362 common::remove_json_null_values(&mut value);
18363 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18364 serde_json::to_writer(&mut dst, &value).unwrap();
18365 dst
18366 };
18367 let request_size = request_value_reader
18368 .seek(std::io::SeekFrom::End(0))
18369 .unwrap();
18370 request_value_reader
18371 .seek(std::io::SeekFrom::Start(0))
18372 .unwrap();
18373
18374 loop {
18375 let token = match self
18376 .hub
18377 .auth
18378 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18379 .await
18380 {
18381 Ok(token) => token,
18382 Err(e) => match dlg.token(e) {
18383 Ok(token) => token,
18384 Err(e) => {
18385 dlg.finished(false);
18386 return Err(common::Error::MissingToken(e));
18387 }
18388 },
18389 };
18390 request_value_reader
18391 .seek(std::io::SeekFrom::Start(0))
18392 .unwrap();
18393 let mut req_result = {
18394 let client = &self.hub.client;
18395 dlg.pre_request();
18396 let mut req_builder = hyper::Request::builder()
18397 .method(hyper::Method::POST)
18398 .uri(url.as_str())
18399 .header(USER_AGENT, self.hub._user_agent.clone());
18400
18401 if let Some(token) = token.as_ref() {
18402 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18403 }
18404
18405 let request = req_builder
18406 .header(CONTENT_TYPE, json_mime_type.to_string())
18407 .header(CONTENT_LENGTH, request_size as u64)
18408 .body(common::to_body(
18409 request_value_reader.get_ref().clone().into(),
18410 ));
18411
18412 client.request(request.unwrap()).await
18413 };
18414
18415 match req_result {
18416 Err(err) => {
18417 if let common::Retry::After(d) = dlg.http_error(&err) {
18418 sleep(d).await;
18419 continue;
18420 }
18421 dlg.finished(false);
18422 return Err(common::Error::HttpError(err));
18423 }
18424 Ok(res) => {
18425 let (mut parts, body) = res.into_parts();
18426 let mut body = common::Body::new(body);
18427 if !parts.status.is_success() {
18428 let bytes = common::to_bytes(body).await.unwrap_or_default();
18429 let error = serde_json::from_str(&common::to_string(&bytes));
18430 let response = common::to_response(parts, bytes.into());
18431
18432 if let common::Retry::After(d) =
18433 dlg.http_failure(&response, error.as_ref().ok())
18434 {
18435 sleep(d).await;
18436 continue;
18437 }
18438
18439 dlg.finished(false);
18440
18441 return Err(match error {
18442 Ok(value) => common::Error::BadRequest(value),
18443 _ => common::Error::Failure(response),
18444 });
18445 }
18446 let response = {
18447 let bytes = common::to_bytes(body).await.unwrap_or_default();
18448 let encoded = common::to_string(&bytes);
18449 match serde_json::from_str(&encoded) {
18450 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18451 Err(error) => {
18452 dlg.response_json_decode_error(&encoded, &error);
18453 return Err(common::Error::JsonDecodeError(
18454 encoded.to_string(),
18455 error,
18456 ));
18457 }
18458 }
18459 };
18460
18461 dlg.finished(true);
18462 return Ok(response);
18463 }
18464 }
18465 }
18466 }
18467
18468 ///
18469 /// Sets the *request* property to the given value.
18470 ///
18471 /// Even though the property as already been set when instantiating this call,
18472 /// we provide this method for API completeness.
18473 pub fn request(
18474 mut self,
18475 new_value: UtilizationReport,
18476 ) -> ProjectLocationSourceUtilizationReportCreateCall<'a, C> {
18477 self._request = new_value;
18478 self
18479 }
18480 /// Required. The Utilization Report's parent.
18481 ///
18482 /// Sets the *parent* path property to the given value.
18483 ///
18484 /// Even though the property as already been set when instantiating this call,
18485 /// we provide this method for API completeness.
18486 pub fn parent(
18487 mut self,
18488 new_value: &str,
18489 ) -> ProjectLocationSourceUtilizationReportCreateCall<'a, C> {
18490 self._parent = new_value.to_string();
18491 self
18492 }
18493 /// Required. The ID to use for the report, which will become the final component of the reports's resource name. This value maximum length is 63 characters, and valid characters are /a-z-/. It must start with an english letter and must not end with a hyphen.
18494 ///
18495 /// Sets the *utilization report id* query property to the given value.
18496 pub fn utilization_report_id(
18497 mut self,
18498 new_value: &str,
18499 ) -> ProjectLocationSourceUtilizationReportCreateCall<'a, C> {
18500 self._utilization_report_id = Some(new_value.to_string());
18501 self
18502 }
18503 /// A request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes since the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
18504 ///
18505 /// Sets the *request id* query property to the given value.
18506 pub fn request_id(
18507 mut self,
18508 new_value: &str,
18509 ) -> ProjectLocationSourceUtilizationReportCreateCall<'a, C> {
18510 self._request_id = Some(new_value.to_string());
18511 self
18512 }
18513 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18514 /// while executing the actual API request.
18515 ///
18516 /// ````text
18517 /// It should be used to handle progress information, and to implement a certain level of resilience.
18518 /// ````
18519 ///
18520 /// Sets the *delegate* property to the given value.
18521 pub fn delegate(
18522 mut self,
18523 new_value: &'a mut dyn common::Delegate,
18524 ) -> ProjectLocationSourceUtilizationReportCreateCall<'a, C> {
18525 self._delegate = Some(new_value);
18526 self
18527 }
18528
18529 /// Set any additional parameter of the query string used in the request.
18530 /// It should be used to set parameters which are not yet available through their own
18531 /// setters.
18532 ///
18533 /// Please note that this method must not be used to set any of the known parameters
18534 /// which have their own setter method. If done anyway, the request will fail.
18535 ///
18536 /// # Additional Parameters
18537 ///
18538 /// * *$.xgafv* (query-string) - V1 error format.
18539 /// * *access_token* (query-string) - OAuth access token.
18540 /// * *alt* (query-string) - Data format for response.
18541 /// * *callback* (query-string) - JSONP
18542 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18543 /// * *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.
18544 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18545 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18546 /// * *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.
18547 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18548 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18549 pub fn param<T>(
18550 mut self,
18551 name: T,
18552 value: T,
18553 ) -> ProjectLocationSourceUtilizationReportCreateCall<'a, C>
18554 where
18555 T: AsRef<str>,
18556 {
18557 self._additional_params
18558 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18559 self
18560 }
18561
18562 /// Identifies the authorization scope for the method you are building.
18563 ///
18564 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18565 /// [`Scope::CloudPlatform`].
18566 ///
18567 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18568 /// tokens for more than one scope.
18569 ///
18570 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18571 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18572 /// sufficient, a read-write scope will do as well.
18573 pub fn add_scope<St>(
18574 mut self,
18575 scope: St,
18576 ) -> ProjectLocationSourceUtilizationReportCreateCall<'a, C>
18577 where
18578 St: AsRef<str>,
18579 {
18580 self._scopes.insert(String::from(scope.as_ref()));
18581 self
18582 }
18583 /// Identifies the authorization scope(s) for the method you are building.
18584 ///
18585 /// See [`Self::add_scope()`] for details.
18586 pub fn add_scopes<I, St>(
18587 mut self,
18588 scopes: I,
18589 ) -> ProjectLocationSourceUtilizationReportCreateCall<'a, C>
18590 where
18591 I: IntoIterator<Item = St>,
18592 St: AsRef<str>,
18593 {
18594 self._scopes
18595 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18596 self
18597 }
18598
18599 /// Removes all scopes, and no default scope will be used either.
18600 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18601 /// for details).
18602 pub fn clear_scopes(mut self) -> ProjectLocationSourceUtilizationReportCreateCall<'a, C> {
18603 self._scopes.clear();
18604 self
18605 }
18606}
18607
18608/// Deletes a single Utilization Report.
18609///
18610/// A builder for the *locations.sources.utilizationReports.delete* method supported by a *project* resource.
18611/// It is not used directly, but through a [`ProjectMethods`] instance.
18612///
18613/// # Example
18614///
18615/// Instantiate a resource method builder
18616///
18617/// ```test_harness,no_run
18618/// # extern crate hyper;
18619/// # extern crate hyper_rustls;
18620/// # extern crate google_vmmigration1 as vmmigration1;
18621/// # async fn dox() {
18622/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18623///
18624/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18625/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18626/// # secret,
18627/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18628/// # ).build().await.unwrap();
18629///
18630/// # let client = hyper_util::client::legacy::Client::builder(
18631/// # hyper_util::rt::TokioExecutor::new()
18632/// # )
18633/// # .build(
18634/// # hyper_rustls::HttpsConnectorBuilder::new()
18635/// # .with_native_roots()
18636/// # .unwrap()
18637/// # .https_or_http()
18638/// # .enable_http1()
18639/// # .build()
18640/// # );
18641/// # let mut hub = VMMigrationService::new(client, auth);
18642/// // You can configure optional parameters by calling the respective setters at will, and
18643/// // execute the final call using `doit()`.
18644/// // Values shown here are possibly random and not representative !
18645/// let result = hub.projects().locations_sources_utilization_reports_delete("name")
18646/// .request_id("sanctus")
18647/// .doit().await;
18648/// # }
18649/// ```
18650pub struct ProjectLocationSourceUtilizationReportDeleteCall<'a, C>
18651where
18652 C: 'a,
18653{
18654 hub: &'a VMMigrationService<C>,
18655 _name: String,
18656 _request_id: Option<String>,
18657 _delegate: Option<&'a mut dyn common::Delegate>,
18658 _additional_params: HashMap<String, String>,
18659 _scopes: BTreeSet<String>,
18660}
18661
18662impl<'a, C> common::CallBuilder for ProjectLocationSourceUtilizationReportDeleteCall<'a, C> {}
18663
18664impl<'a, C> ProjectLocationSourceUtilizationReportDeleteCall<'a, C>
18665where
18666 C: common::Connector,
18667{
18668 /// Perform the operation you have build so far.
18669 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
18670 use std::borrow::Cow;
18671 use std::io::{Read, Seek};
18672
18673 use common::{url::Params, ToParts};
18674 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18675
18676 let mut dd = common::DefaultDelegate;
18677 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18678 dlg.begin(common::MethodInfo {
18679 id: "vmmigration.projects.locations.sources.utilizationReports.delete",
18680 http_method: hyper::Method::DELETE,
18681 });
18682
18683 for &field in ["alt", "name", "requestId"].iter() {
18684 if self._additional_params.contains_key(field) {
18685 dlg.finished(false);
18686 return Err(common::Error::FieldClash(field));
18687 }
18688 }
18689
18690 let mut params = Params::with_capacity(4 + self._additional_params.len());
18691 params.push("name", self._name);
18692 if let Some(value) = self._request_id.as_ref() {
18693 params.push("requestId", value);
18694 }
18695
18696 params.extend(self._additional_params.iter());
18697
18698 params.push("alt", "json");
18699 let mut url = self.hub._base_url.clone() + "v1/{+name}";
18700 if self._scopes.is_empty() {
18701 self._scopes
18702 .insert(Scope::CloudPlatform.as_ref().to_string());
18703 }
18704
18705 #[allow(clippy::single_element_loop)]
18706 for &(find_this, param_name) in [("{+name}", "name")].iter() {
18707 url = params.uri_replacement(url, param_name, find_this, true);
18708 }
18709 {
18710 let to_remove = ["name"];
18711 params.remove_params(&to_remove);
18712 }
18713
18714 let url = params.parse_with_url(&url);
18715
18716 loop {
18717 let token = match self
18718 .hub
18719 .auth
18720 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18721 .await
18722 {
18723 Ok(token) => token,
18724 Err(e) => match dlg.token(e) {
18725 Ok(token) => token,
18726 Err(e) => {
18727 dlg.finished(false);
18728 return Err(common::Error::MissingToken(e));
18729 }
18730 },
18731 };
18732 let mut req_result = {
18733 let client = &self.hub.client;
18734 dlg.pre_request();
18735 let mut req_builder = hyper::Request::builder()
18736 .method(hyper::Method::DELETE)
18737 .uri(url.as_str())
18738 .header(USER_AGENT, self.hub._user_agent.clone());
18739
18740 if let Some(token) = token.as_ref() {
18741 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18742 }
18743
18744 let request = req_builder
18745 .header(CONTENT_LENGTH, 0_u64)
18746 .body(common::to_body::<String>(None));
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 /// Required. The Utilization Report name.
18805 ///
18806 /// Sets the *name* path property to the given value.
18807 ///
18808 /// Even though the property as already been set when instantiating this call,
18809 /// we provide this method for API completeness.
18810 pub fn name(
18811 mut self,
18812 new_value: &str,
18813 ) -> ProjectLocationSourceUtilizationReportDeleteCall<'a, C> {
18814 self._name = new_value.to_string();
18815 self
18816 }
18817 /// Optional. A request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes after the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
18818 ///
18819 /// Sets the *request id* query property to the given value.
18820 pub fn request_id(
18821 mut self,
18822 new_value: &str,
18823 ) -> ProjectLocationSourceUtilizationReportDeleteCall<'a, C> {
18824 self._request_id = Some(new_value.to_string());
18825 self
18826 }
18827 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18828 /// while executing the actual API request.
18829 ///
18830 /// ````text
18831 /// It should be used to handle progress information, and to implement a certain level of resilience.
18832 /// ````
18833 ///
18834 /// Sets the *delegate* property to the given value.
18835 pub fn delegate(
18836 mut self,
18837 new_value: &'a mut dyn common::Delegate,
18838 ) -> ProjectLocationSourceUtilizationReportDeleteCall<'a, C> {
18839 self._delegate = Some(new_value);
18840 self
18841 }
18842
18843 /// Set any additional parameter of the query string used in the request.
18844 /// It should be used to set parameters which are not yet available through their own
18845 /// setters.
18846 ///
18847 /// Please note that this method must not be used to set any of the known parameters
18848 /// which have their own setter method. If done anyway, the request will fail.
18849 ///
18850 /// # Additional Parameters
18851 ///
18852 /// * *$.xgafv* (query-string) - V1 error format.
18853 /// * *access_token* (query-string) - OAuth access token.
18854 /// * *alt* (query-string) - Data format for response.
18855 /// * *callback* (query-string) - JSONP
18856 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18857 /// * *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.
18858 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18859 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18860 /// * *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.
18861 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18862 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18863 pub fn param<T>(
18864 mut self,
18865 name: T,
18866 value: T,
18867 ) -> ProjectLocationSourceUtilizationReportDeleteCall<'a, C>
18868 where
18869 T: AsRef<str>,
18870 {
18871 self._additional_params
18872 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18873 self
18874 }
18875
18876 /// Identifies the authorization scope for the method you are building.
18877 ///
18878 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18879 /// [`Scope::CloudPlatform`].
18880 ///
18881 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18882 /// tokens for more than one scope.
18883 ///
18884 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18885 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18886 /// sufficient, a read-write scope will do as well.
18887 pub fn add_scope<St>(
18888 mut self,
18889 scope: St,
18890 ) -> ProjectLocationSourceUtilizationReportDeleteCall<'a, C>
18891 where
18892 St: AsRef<str>,
18893 {
18894 self._scopes.insert(String::from(scope.as_ref()));
18895 self
18896 }
18897 /// Identifies the authorization scope(s) for the method you are building.
18898 ///
18899 /// See [`Self::add_scope()`] for details.
18900 pub fn add_scopes<I, St>(
18901 mut self,
18902 scopes: I,
18903 ) -> ProjectLocationSourceUtilizationReportDeleteCall<'a, C>
18904 where
18905 I: IntoIterator<Item = St>,
18906 St: AsRef<str>,
18907 {
18908 self._scopes
18909 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18910 self
18911 }
18912
18913 /// Removes all scopes, and no default scope will be used either.
18914 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18915 /// for details).
18916 pub fn clear_scopes(mut self) -> ProjectLocationSourceUtilizationReportDeleteCall<'a, C> {
18917 self._scopes.clear();
18918 self
18919 }
18920}
18921
18922/// Gets a single Utilization Report.
18923///
18924/// A builder for the *locations.sources.utilizationReports.get* method supported by a *project* resource.
18925/// It is not used directly, but through a [`ProjectMethods`] instance.
18926///
18927/// # Example
18928///
18929/// Instantiate a resource method builder
18930///
18931/// ```test_harness,no_run
18932/// # extern crate hyper;
18933/// # extern crate hyper_rustls;
18934/// # extern crate google_vmmigration1 as vmmigration1;
18935/// # async fn dox() {
18936/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18937///
18938/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18939/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18940/// # secret,
18941/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18942/// # ).build().await.unwrap();
18943///
18944/// # let client = hyper_util::client::legacy::Client::builder(
18945/// # hyper_util::rt::TokioExecutor::new()
18946/// # )
18947/// # .build(
18948/// # hyper_rustls::HttpsConnectorBuilder::new()
18949/// # .with_native_roots()
18950/// # .unwrap()
18951/// # .https_or_http()
18952/// # .enable_http1()
18953/// # .build()
18954/// # );
18955/// # let mut hub = VMMigrationService::new(client, auth);
18956/// // You can configure optional parameters by calling the respective setters at will, and
18957/// // execute the final call using `doit()`.
18958/// // Values shown here are possibly random and not representative !
18959/// let result = hub.projects().locations_sources_utilization_reports_get("name")
18960/// .view("est")
18961/// .doit().await;
18962/// # }
18963/// ```
18964pub struct ProjectLocationSourceUtilizationReportGetCall<'a, C>
18965where
18966 C: 'a,
18967{
18968 hub: &'a VMMigrationService<C>,
18969 _name: String,
18970 _view: Option<String>,
18971 _delegate: Option<&'a mut dyn common::Delegate>,
18972 _additional_params: HashMap<String, String>,
18973 _scopes: BTreeSet<String>,
18974}
18975
18976impl<'a, C> common::CallBuilder for ProjectLocationSourceUtilizationReportGetCall<'a, C> {}
18977
18978impl<'a, C> ProjectLocationSourceUtilizationReportGetCall<'a, C>
18979where
18980 C: common::Connector,
18981{
18982 /// Perform the operation you have build so far.
18983 pub async fn doit(mut self) -> common::Result<(common::Response, UtilizationReport)> {
18984 use std::borrow::Cow;
18985 use std::io::{Read, Seek};
18986
18987 use common::{url::Params, ToParts};
18988 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18989
18990 let mut dd = common::DefaultDelegate;
18991 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18992 dlg.begin(common::MethodInfo {
18993 id: "vmmigration.projects.locations.sources.utilizationReports.get",
18994 http_method: hyper::Method::GET,
18995 });
18996
18997 for &field in ["alt", "name", "view"].iter() {
18998 if self._additional_params.contains_key(field) {
18999 dlg.finished(false);
19000 return Err(common::Error::FieldClash(field));
19001 }
19002 }
19003
19004 let mut params = Params::with_capacity(4 + self._additional_params.len());
19005 params.push("name", self._name);
19006 if let Some(value) = self._view.as_ref() {
19007 params.push("view", value);
19008 }
19009
19010 params.extend(self._additional_params.iter());
19011
19012 params.push("alt", "json");
19013 let mut url = self.hub._base_url.clone() + "v1/{+name}";
19014 if self._scopes.is_empty() {
19015 self._scopes
19016 .insert(Scope::CloudPlatform.as_ref().to_string());
19017 }
19018
19019 #[allow(clippy::single_element_loop)]
19020 for &(find_this, param_name) in [("{+name}", "name")].iter() {
19021 url = params.uri_replacement(url, param_name, find_this, true);
19022 }
19023 {
19024 let to_remove = ["name"];
19025 params.remove_params(&to_remove);
19026 }
19027
19028 let url = params.parse_with_url(&url);
19029
19030 loop {
19031 let token = match self
19032 .hub
19033 .auth
19034 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19035 .await
19036 {
19037 Ok(token) => token,
19038 Err(e) => match dlg.token(e) {
19039 Ok(token) => token,
19040 Err(e) => {
19041 dlg.finished(false);
19042 return Err(common::Error::MissingToken(e));
19043 }
19044 },
19045 };
19046 let mut req_result = {
19047 let client = &self.hub.client;
19048 dlg.pre_request();
19049 let mut req_builder = hyper::Request::builder()
19050 .method(hyper::Method::GET)
19051 .uri(url.as_str())
19052 .header(USER_AGENT, self.hub._user_agent.clone());
19053
19054 if let Some(token) = token.as_ref() {
19055 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19056 }
19057
19058 let request = req_builder
19059 .header(CONTENT_LENGTH, 0_u64)
19060 .body(common::to_body::<String>(None));
19061
19062 client.request(request.unwrap()).await
19063 };
19064
19065 match req_result {
19066 Err(err) => {
19067 if let common::Retry::After(d) = dlg.http_error(&err) {
19068 sleep(d).await;
19069 continue;
19070 }
19071 dlg.finished(false);
19072 return Err(common::Error::HttpError(err));
19073 }
19074 Ok(res) => {
19075 let (mut parts, body) = res.into_parts();
19076 let mut body = common::Body::new(body);
19077 if !parts.status.is_success() {
19078 let bytes = common::to_bytes(body).await.unwrap_or_default();
19079 let error = serde_json::from_str(&common::to_string(&bytes));
19080 let response = common::to_response(parts, bytes.into());
19081
19082 if let common::Retry::After(d) =
19083 dlg.http_failure(&response, error.as_ref().ok())
19084 {
19085 sleep(d).await;
19086 continue;
19087 }
19088
19089 dlg.finished(false);
19090
19091 return Err(match error {
19092 Ok(value) => common::Error::BadRequest(value),
19093 _ => common::Error::Failure(response),
19094 });
19095 }
19096 let response = {
19097 let bytes = common::to_bytes(body).await.unwrap_or_default();
19098 let encoded = common::to_string(&bytes);
19099 match serde_json::from_str(&encoded) {
19100 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19101 Err(error) => {
19102 dlg.response_json_decode_error(&encoded, &error);
19103 return Err(common::Error::JsonDecodeError(
19104 encoded.to_string(),
19105 error,
19106 ));
19107 }
19108 }
19109 };
19110
19111 dlg.finished(true);
19112 return Ok(response);
19113 }
19114 }
19115 }
19116 }
19117
19118 /// Required. The Utilization Report name.
19119 ///
19120 /// Sets the *name* path property to the given value.
19121 ///
19122 /// Even though the property as already been set when instantiating this call,
19123 /// we provide this method for API completeness.
19124 pub fn name(mut self, new_value: &str) -> ProjectLocationSourceUtilizationReportGetCall<'a, C> {
19125 self._name = new_value.to_string();
19126 self
19127 }
19128 /// Optional. The level of details of the report. Defaults to FULL
19129 ///
19130 /// Sets the *view* query property to the given value.
19131 pub fn view(mut self, new_value: &str) -> ProjectLocationSourceUtilizationReportGetCall<'a, C> {
19132 self._view = Some(new_value.to_string());
19133 self
19134 }
19135 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19136 /// while executing the actual API request.
19137 ///
19138 /// ````text
19139 /// It should be used to handle progress information, and to implement a certain level of resilience.
19140 /// ````
19141 ///
19142 /// Sets the *delegate* property to the given value.
19143 pub fn delegate(
19144 mut self,
19145 new_value: &'a mut dyn common::Delegate,
19146 ) -> ProjectLocationSourceUtilizationReportGetCall<'a, C> {
19147 self._delegate = Some(new_value);
19148 self
19149 }
19150
19151 /// Set any additional parameter of the query string used in the request.
19152 /// It should be used to set parameters which are not yet available through their own
19153 /// setters.
19154 ///
19155 /// Please note that this method must not be used to set any of the known parameters
19156 /// which have their own setter method. If done anyway, the request will fail.
19157 ///
19158 /// # Additional Parameters
19159 ///
19160 /// * *$.xgafv* (query-string) - V1 error format.
19161 /// * *access_token* (query-string) - OAuth access token.
19162 /// * *alt* (query-string) - Data format for response.
19163 /// * *callback* (query-string) - JSONP
19164 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19165 /// * *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.
19166 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19167 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19168 /// * *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.
19169 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19170 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19171 pub fn param<T>(
19172 mut self,
19173 name: T,
19174 value: T,
19175 ) -> ProjectLocationSourceUtilizationReportGetCall<'a, C>
19176 where
19177 T: AsRef<str>,
19178 {
19179 self._additional_params
19180 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19181 self
19182 }
19183
19184 /// Identifies the authorization scope for the method you are building.
19185 ///
19186 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19187 /// [`Scope::CloudPlatform`].
19188 ///
19189 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19190 /// tokens for more than one scope.
19191 ///
19192 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19193 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19194 /// sufficient, a read-write scope will do as well.
19195 pub fn add_scope<St>(
19196 mut self,
19197 scope: St,
19198 ) -> ProjectLocationSourceUtilizationReportGetCall<'a, C>
19199 where
19200 St: AsRef<str>,
19201 {
19202 self._scopes.insert(String::from(scope.as_ref()));
19203 self
19204 }
19205 /// Identifies the authorization scope(s) for the method you are building.
19206 ///
19207 /// See [`Self::add_scope()`] for details.
19208 pub fn add_scopes<I, St>(
19209 mut self,
19210 scopes: I,
19211 ) -> ProjectLocationSourceUtilizationReportGetCall<'a, C>
19212 where
19213 I: IntoIterator<Item = St>,
19214 St: AsRef<str>,
19215 {
19216 self._scopes
19217 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19218 self
19219 }
19220
19221 /// Removes all scopes, and no default scope will be used either.
19222 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19223 /// for details).
19224 pub fn clear_scopes(mut self) -> ProjectLocationSourceUtilizationReportGetCall<'a, C> {
19225 self._scopes.clear();
19226 self
19227 }
19228}
19229
19230/// Lists Utilization Reports of the given Source.
19231///
19232/// A builder for the *locations.sources.utilizationReports.list* method supported by a *project* resource.
19233/// It is not used directly, but through a [`ProjectMethods`] instance.
19234///
19235/// # Example
19236///
19237/// Instantiate a resource method builder
19238///
19239/// ```test_harness,no_run
19240/// # extern crate hyper;
19241/// # extern crate hyper_rustls;
19242/// # extern crate google_vmmigration1 as vmmigration1;
19243/// # async fn dox() {
19244/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19245///
19246/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19247/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19248/// # secret,
19249/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19250/// # ).build().await.unwrap();
19251///
19252/// # let client = hyper_util::client::legacy::Client::builder(
19253/// # hyper_util::rt::TokioExecutor::new()
19254/// # )
19255/// # .build(
19256/// # hyper_rustls::HttpsConnectorBuilder::new()
19257/// # .with_native_roots()
19258/// # .unwrap()
19259/// # .https_or_http()
19260/// # .enable_http1()
19261/// # .build()
19262/// # );
19263/// # let mut hub = VMMigrationService::new(client, auth);
19264/// // You can configure optional parameters by calling the respective setters at will, and
19265/// // execute the final call using `doit()`.
19266/// // Values shown here are possibly random and not representative !
19267/// let result = hub.projects().locations_sources_utilization_reports_list("parent")
19268/// .view("diam")
19269/// .page_token("dolores")
19270/// .page_size(-69)
19271/// .order_by("et")
19272/// .filter("sed")
19273/// .doit().await;
19274/// # }
19275/// ```
19276pub struct ProjectLocationSourceUtilizationReportListCall<'a, C>
19277where
19278 C: 'a,
19279{
19280 hub: &'a VMMigrationService<C>,
19281 _parent: String,
19282 _view: Option<String>,
19283 _page_token: Option<String>,
19284 _page_size: Option<i32>,
19285 _order_by: Option<String>,
19286 _filter: Option<String>,
19287 _delegate: Option<&'a mut dyn common::Delegate>,
19288 _additional_params: HashMap<String, String>,
19289 _scopes: BTreeSet<String>,
19290}
19291
19292impl<'a, C> common::CallBuilder for ProjectLocationSourceUtilizationReportListCall<'a, C> {}
19293
19294impl<'a, C> ProjectLocationSourceUtilizationReportListCall<'a, C>
19295where
19296 C: common::Connector,
19297{
19298 /// Perform the operation you have build so far.
19299 pub async fn doit(
19300 mut self,
19301 ) -> common::Result<(common::Response, ListUtilizationReportsResponse)> {
19302 use std::borrow::Cow;
19303 use std::io::{Read, Seek};
19304
19305 use common::{url::Params, ToParts};
19306 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19307
19308 let mut dd = common::DefaultDelegate;
19309 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19310 dlg.begin(common::MethodInfo {
19311 id: "vmmigration.projects.locations.sources.utilizationReports.list",
19312 http_method: hyper::Method::GET,
19313 });
19314
19315 for &field in [
19316 "alt",
19317 "parent",
19318 "view",
19319 "pageToken",
19320 "pageSize",
19321 "orderBy",
19322 "filter",
19323 ]
19324 .iter()
19325 {
19326 if self._additional_params.contains_key(field) {
19327 dlg.finished(false);
19328 return Err(common::Error::FieldClash(field));
19329 }
19330 }
19331
19332 let mut params = Params::with_capacity(8 + self._additional_params.len());
19333 params.push("parent", self._parent);
19334 if let Some(value) = self._view.as_ref() {
19335 params.push("view", value);
19336 }
19337 if let Some(value) = self._page_token.as_ref() {
19338 params.push("pageToken", value);
19339 }
19340 if let Some(value) = self._page_size.as_ref() {
19341 params.push("pageSize", value.to_string());
19342 }
19343 if let Some(value) = self._order_by.as_ref() {
19344 params.push("orderBy", value);
19345 }
19346 if let Some(value) = self._filter.as_ref() {
19347 params.push("filter", value);
19348 }
19349
19350 params.extend(self._additional_params.iter());
19351
19352 params.push("alt", "json");
19353 let mut url = self.hub._base_url.clone() + "v1/{+parent}/utilizationReports";
19354 if self._scopes.is_empty() {
19355 self._scopes
19356 .insert(Scope::CloudPlatform.as_ref().to_string());
19357 }
19358
19359 #[allow(clippy::single_element_loop)]
19360 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
19361 url = params.uri_replacement(url, param_name, find_this, true);
19362 }
19363 {
19364 let to_remove = ["parent"];
19365 params.remove_params(&to_remove);
19366 }
19367
19368 let url = params.parse_with_url(&url);
19369
19370 loop {
19371 let token = match self
19372 .hub
19373 .auth
19374 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19375 .await
19376 {
19377 Ok(token) => token,
19378 Err(e) => match dlg.token(e) {
19379 Ok(token) => token,
19380 Err(e) => {
19381 dlg.finished(false);
19382 return Err(common::Error::MissingToken(e));
19383 }
19384 },
19385 };
19386 let mut req_result = {
19387 let client = &self.hub.client;
19388 dlg.pre_request();
19389 let mut req_builder = hyper::Request::builder()
19390 .method(hyper::Method::GET)
19391 .uri(url.as_str())
19392 .header(USER_AGENT, self.hub._user_agent.clone());
19393
19394 if let Some(token) = token.as_ref() {
19395 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19396 }
19397
19398 let request = req_builder
19399 .header(CONTENT_LENGTH, 0_u64)
19400 .body(common::to_body::<String>(None));
19401
19402 client.request(request.unwrap()).await
19403 };
19404
19405 match req_result {
19406 Err(err) => {
19407 if let common::Retry::After(d) = dlg.http_error(&err) {
19408 sleep(d).await;
19409 continue;
19410 }
19411 dlg.finished(false);
19412 return Err(common::Error::HttpError(err));
19413 }
19414 Ok(res) => {
19415 let (mut parts, body) = res.into_parts();
19416 let mut body = common::Body::new(body);
19417 if !parts.status.is_success() {
19418 let bytes = common::to_bytes(body).await.unwrap_or_default();
19419 let error = serde_json::from_str(&common::to_string(&bytes));
19420 let response = common::to_response(parts, bytes.into());
19421
19422 if let common::Retry::After(d) =
19423 dlg.http_failure(&response, error.as_ref().ok())
19424 {
19425 sleep(d).await;
19426 continue;
19427 }
19428
19429 dlg.finished(false);
19430
19431 return Err(match error {
19432 Ok(value) => common::Error::BadRequest(value),
19433 _ => common::Error::Failure(response),
19434 });
19435 }
19436 let response = {
19437 let bytes = common::to_bytes(body).await.unwrap_or_default();
19438 let encoded = common::to_string(&bytes);
19439 match serde_json::from_str(&encoded) {
19440 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19441 Err(error) => {
19442 dlg.response_json_decode_error(&encoded, &error);
19443 return Err(common::Error::JsonDecodeError(
19444 encoded.to_string(),
19445 error,
19446 ));
19447 }
19448 }
19449 };
19450
19451 dlg.finished(true);
19452 return Ok(response);
19453 }
19454 }
19455 }
19456 }
19457
19458 /// Required. The Utilization Reports parent.
19459 ///
19460 /// Sets the *parent* path property to the given value.
19461 ///
19462 /// Even though the property as already been set when instantiating this call,
19463 /// we provide this method for API completeness.
19464 pub fn parent(
19465 mut self,
19466 new_value: &str,
19467 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C> {
19468 self._parent = new_value.to_string();
19469 self
19470 }
19471 /// Optional. The level of details of each report. Defaults to BASIC.
19472 ///
19473 /// Sets the *view* query property to the given value.
19474 pub fn view(
19475 mut self,
19476 new_value: &str,
19477 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C> {
19478 self._view = Some(new_value.to_string());
19479 self
19480 }
19481 /// Required. A page token, received from a previous `ListUtilizationReports` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListUtilizationReports` must match the call that provided the page token.
19482 ///
19483 /// Sets the *page token* query property to the given value.
19484 pub fn page_token(
19485 mut self,
19486 new_value: &str,
19487 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C> {
19488 self._page_token = Some(new_value.to_string());
19489 self
19490 }
19491 /// Optional. The maximum number of reports to return. The service may return fewer than this value. If unspecified, at most 500 reports will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
19492 ///
19493 /// Sets the *page size* query property to the given value.
19494 pub fn page_size(
19495 mut self,
19496 new_value: i32,
19497 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C> {
19498 self._page_size = Some(new_value);
19499 self
19500 }
19501 /// Optional. the order by fields for the result.
19502 ///
19503 /// Sets the *order by* query property to the given value.
19504 pub fn order_by(
19505 mut self,
19506 new_value: &str,
19507 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C> {
19508 self._order_by = Some(new_value.to_string());
19509 self
19510 }
19511 /// Optional. The filter request.
19512 ///
19513 /// Sets the *filter* query property to the given value.
19514 pub fn filter(
19515 mut self,
19516 new_value: &str,
19517 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C> {
19518 self._filter = Some(new_value.to_string());
19519 self
19520 }
19521 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19522 /// while executing the actual API request.
19523 ///
19524 /// ````text
19525 /// It should be used to handle progress information, and to implement a certain level of resilience.
19526 /// ````
19527 ///
19528 /// Sets the *delegate* property to the given value.
19529 pub fn delegate(
19530 mut self,
19531 new_value: &'a mut dyn common::Delegate,
19532 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C> {
19533 self._delegate = Some(new_value);
19534 self
19535 }
19536
19537 /// Set any additional parameter of the query string used in the request.
19538 /// It should be used to set parameters which are not yet available through their own
19539 /// setters.
19540 ///
19541 /// Please note that this method must not be used to set any of the known parameters
19542 /// which have their own setter method. If done anyway, the request will fail.
19543 ///
19544 /// # Additional Parameters
19545 ///
19546 /// * *$.xgafv* (query-string) - V1 error format.
19547 /// * *access_token* (query-string) - OAuth access token.
19548 /// * *alt* (query-string) - Data format for response.
19549 /// * *callback* (query-string) - JSONP
19550 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19551 /// * *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.
19552 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19553 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19554 /// * *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.
19555 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19556 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19557 pub fn param<T>(
19558 mut self,
19559 name: T,
19560 value: T,
19561 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C>
19562 where
19563 T: AsRef<str>,
19564 {
19565 self._additional_params
19566 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19567 self
19568 }
19569
19570 /// Identifies the authorization scope for the method you are building.
19571 ///
19572 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19573 /// [`Scope::CloudPlatform`].
19574 ///
19575 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19576 /// tokens for more than one scope.
19577 ///
19578 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19579 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19580 /// sufficient, a read-write scope will do as well.
19581 pub fn add_scope<St>(
19582 mut self,
19583 scope: St,
19584 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C>
19585 where
19586 St: AsRef<str>,
19587 {
19588 self._scopes.insert(String::from(scope.as_ref()));
19589 self
19590 }
19591 /// Identifies the authorization scope(s) for the method you are building.
19592 ///
19593 /// See [`Self::add_scope()`] for details.
19594 pub fn add_scopes<I, St>(
19595 mut self,
19596 scopes: I,
19597 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C>
19598 where
19599 I: IntoIterator<Item = St>,
19600 St: AsRef<str>,
19601 {
19602 self._scopes
19603 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19604 self
19605 }
19606
19607 /// Removes all scopes, and no default scope will be used either.
19608 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19609 /// for details).
19610 pub fn clear_scopes(mut self) -> ProjectLocationSourceUtilizationReportListCall<'a, C> {
19611 self._scopes.clear();
19612 self
19613 }
19614}
19615
19616/// Creates a new Source in a given project and location.
19617///
19618/// A builder for the *locations.sources.create* method supported by a *project* resource.
19619/// It is not used directly, but through a [`ProjectMethods`] instance.
19620///
19621/// # Example
19622///
19623/// Instantiate a resource method builder
19624///
19625/// ```test_harness,no_run
19626/// # extern crate hyper;
19627/// # extern crate hyper_rustls;
19628/// # extern crate google_vmmigration1 as vmmigration1;
19629/// use vmmigration1::api::Source;
19630/// # async fn dox() {
19631/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19632///
19633/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19634/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19635/// # secret,
19636/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19637/// # ).build().await.unwrap();
19638///
19639/// # let client = hyper_util::client::legacy::Client::builder(
19640/// # hyper_util::rt::TokioExecutor::new()
19641/// # )
19642/// # .build(
19643/// # hyper_rustls::HttpsConnectorBuilder::new()
19644/// # .with_native_roots()
19645/// # .unwrap()
19646/// # .https_or_http()
19647/// # .enable_http1()
19648/// # .build()
19649/// # );
19650/// # let mut hub = VMMigrationService::new(client, auth);
19651/// // As the method needs a request, you would usually fill it with the desired information
19652/// // into the respective structure. Some of the parts shown here might not be applicable !
19653/// // Values shown here are possibly random and not representative !
19654/// let mut req = Source::default();
19655///
19656/// // You can configure optional parameters by calling the respective setters at will, and
19657/// // execute the final call using `doit()`.
19658/// // Values shown here are possibly random and not representative !
19659/// let result = hub.projects().locations_sources_create(req, "parent")
19660/// .source_id("et")
19661/// .request_id("elitr")
19662/// .doit().await;
19663/// # }
19664/// ```
19665pub struct ProjectLocationSourceCreateCall<'a, C>
19666where
19667 C: 'a,
19668{
19669 hub: &'a VMMigrationService<C>,
19670 _request: Source,
19671 _parent: String,
19672 _source_id: Option<String>,
19673 _request_id: Option<String>,
19674 _delegate: Option<&'a mut dyn common::Delegate>,
19675 _additional_params: HashMap<String, String>,
19676 _scopes: BTreeSet<String>,
19677}
19678
19679impl<'a, C> common::CallBuilder for ProjectLocationSourceCreateCall<'a, C> {}
19680
19681impl<'a, C> ProjectLocationSourceCreateCall<'a, C>
19682where
19683 C: common::Connector,
19684{
19685 /// Perform the operation you have build so far.
19686 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
19687 use std::borrow::Cow;
19688 use std::io::{Read, Seek};
19689
19690 use common::{url::Params, ToParts};
19691 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19692
19693 let mut dd = common::DefaultDelegate;
19694 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19695 dlg.begin(common::MethodInfo {
19696 id: "vmmigration.projects.locations.sources.create",
19697 http_method: hyper::Method::POST,
19698 });
19699
19700 for &field in ["alt", "parent", "sourceId", "requestId"].iter() {
19701 if self._additional_params.contains_key(field) {
19702 dlg.finished(false);
19703 return Err(common::Error::FieldClash(field));
19704 }
19705 }
19706
19707 let mut params = Params::with_capacity(6 + self._additional_params.len());
19708 params.push("parent", self._parent);
19709 if let Some(value) = self._source_id.as_ref() {
19710 params.push("sourceId", value);
19711 }
19712 if let Some(value) = self._request_id.as_ref() {
19713 params.push("requestId", value);
19714 }
19715
19716 params.extend(self._additional_params.iter());
19717
19718 params.push("alt", "json");
19719 let mut url = self.hub._base_url.clone() + "v1/{+parent}/sources";
19720 if self._scopes.is_empty() {
19721 self._scopes
19722 .insert(Scope::CloudPlatform.as_ref().to_string());
19723 }
19724
19725 #[allow(clippy::single_element_loop)]
19726 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
19727 url = params.uri_replacement(url, param_name, find_this, true);
19728 }
19729 {
19730 let to_remove = ["parent"];
19731 params.remove_params(&to_remove);
19732 }
19733
19734 let url = params.parse_with_url(&url);
19735
19736 let mut json_mime_type = mime::APPLICATION_JSON;
19737 let mut request_value_reader = {
19738 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19739 common::remove_json_null_values(&mut value);
19740 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19741 serde_json::to_writer(&mut dst, &value).unwrap();
19742 dst
19743 };
19744 let request_size = request_value_reader
19745 .seek(std::io::SeekFrom::End(0))
19746 .unwrap();
19747 request_value_reader
19748 .seek(std::io::SeekFrom::Start(0))
19749 .unwrap();
19750
19751 loop {
19752 let token = match self
19753 .hub
19754 .auth
19755 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19756 .await
19757 {
19758 Ok(token) => token,
19759 Err(e) => match dlg.token(e) {
19760 Ok(token) => token,
19761 Err(e) => {
19762 dlg.finished(false);
19763 return Err(common::Error::MissingToken(e));
19764 }
19765 },
19766 };
19767 request_value_reader
19768 .seek(std::io::SeekFrom::Start(0))
19769 .unwrap();
19770 let mut req_result = {
19771 let client = &self.hub.client;
19772 dlg.pre_request();
19773 let mut req_builder = hyper::Request::builder()
19774 .method(hyper::Method::POST)
19775 .uri(url.as_str())
19776 .header(USER_AGENT, self.hub._user_agent.clone());
19777
19778 if let Some(token) = token.as_ref() {
19779 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19780 }
19781
19782 let request = req_builder
19783 .header(CONTENT_TYPE, json_mime_type.to_string())
19784 .header(CONTENT_LENGTH, request_size as u64)
19785 .body(common::to_body(
19786 request_value_reader.get_ref().clone().into(),
19787 ));
19788
19789 client.request(request.unwrap()).await
19790 };
19791
19792 match req_result {
19793 Err(err) => {
19794 if let common::Retry::After(d) = dlg.http_error(&err) {
19795 sleep(d).await;
19796 continue;
19797 }
19798 dlg.finished(false);
19799 return Err(common::Error::HttpError(err));
19800 }
19801 Ok(res) => {
19802 let (mut parts, body) = res.into_parts();
19803 let mut body = common::Body::new(body);
19804 if !parts.status.is_success() {
19805 let bytes = common::to_bytes(body).await.unwrap_or_default();
19806 let error = serde_json::from_str(&common::to_string(&bytes));
19807 let response = common::to_response(parts, bytes.into());
19808
19809 if let common::Retry::After(d) =
19810 dlg.http_failure(&response, error.as_ref().ok())
19811 {
19812 sleep(d).await;
19813 continue;
19814 }
19815
19816 dlg.finished(false);
19817
19818 return Err(match error {
19819 Ok(value) => common::Error::BadRequest(value),
19820 _ => common::Error::Failure(response),
19821 });
19822 }
19823 let response = {
19824 let bytes = common::to_bytes(body).await.unwrap_or_default();
19825 let encoded = common::to_string(&bytes);
19826 match serde_json::from_str(&encoded) {
19827 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19828 Err(error) => {
19829 dlg.response_json_decode_error(&encoded, &error);
19830 return Err(common::Error::JsonDecodeError(
19831 encoded.to_string(),
19832 error,
19833 ));
19834 }
19835 }
19836 };
19837
19838 dlg.finished(true);
19839 return Ok(response);
19840 }
19841 }
19842 }
19843 }
19844
19845 ///
19846 /// Sets the *request* property to the given value.
19847 ///
19848 /// Even though the property as already been set when instantiating this call,
19849 /// we provide this method for API completeness.
19850 pub fn request(mut self, new_value: Source) -> ProjectLocationSourceCreateCall<'a, C> {
19851 self._request = new_value;
19852 self
19853 }
19854 /// Required. The Source's parent.
19855 ///
19856 /// Sets the *parent* path property to the given value.
19857 ///
19858 /// Even though the property as already been set when instantiating this call,
19859 /// we provide this method for API completeness.
19860 pub fn parent(mut self, new_value: &str) -> ProjectLocationSourceCreateCall<'a, C> {
19861 self._parent = new_value.to_string();
19862 self
19863 }
19864 /// Required. The source identifier.
19865 ///
19866 /// Sets the *source id* query property to the given value.
19867 pub fn source_id(mut self, new_value: &str) -> ProjectLocationSourceCreateCall<'a, C> {
19868 self._source_id = Some(new_value.to_string());
19869 self
19870 }
19871 /// A request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes since the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
19872 ///
19873 /// Sets the *request id* query property to the given value.
19874 pub fn request_id(mut self, new_value: &str) -> ProjectLocationSourceCreateCall<'a, C> {
19875 self._request_id = Some(new_value.to_string());
19876 self
19877 }
19878 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19879 /// while executing the actual API request.
19880 ///
19881 /// ````text
19882 /// It should be used to handle progress information, and to implement a certain level of resilience.
19883 /// ````
19884 ///
19885 /// Sets the *delegate* property to the given value.
19886 pub fn delegate(
19887 mut self,
19888 new_value: &'a mut dyn common::Delegate,
19889 ) -> ProjectLocationSourceCreateCall<'a, C> {
19890 self._delegate = Some(new_value);
19891 self
19892 }
19893
19894 /// Set any additional parameter of the query string used in the request.
19895 /// It should be used to set parameters which are not yet available through their own
19896 /// setters.
19897 ///
19898 /// Please note that this method must not be used to set any of the known parameters
19899 /// which have their own setter method. If done anyway, the request will fail.
19900 ///
19901 /// # Additional Parameters
19902 ///
19903 /// * *$.xgafv* (query-string) - V1 error format.
19904 /// * *access_token* (query-string) - OAuth access token.
19905 /// * *alt* (query-string) - Data format for response.
19906 /// * *callback* (query-string) - JSONP
19907 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19908 /// * *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.
19909 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19910 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19911 /// * *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.
19912 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19913 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19914 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSourceCreateCall<'a, C>
19915 where
19916 T: AsRef<str>,
19917 {
19918 self._additional_params
19919 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19920 self
19921 }
19922
19923 /// Identifies the authorization scope for the method you are building.
19924 ///
19925 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19926 /// [`Scope::CloudPlatform`].
19927 ///
19928 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19929 /// tokens for more than one scope.
19930 ///
19931 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19932 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19933 /// sufficient, a read-write scope will do as well.
19934 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceCreateCall<'a, C>
19935 where
19936 St: AsRef<str>,
19937 {
19938 self._scopes.insert(String::from(scope.as_ref()));
19939 self
19940 }
19941 /// Identifies the authorization scope(s) for the method you are building.
19942 ///
19943 /// See [`Self::add_scope()`] for details.
19944 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSourceCreateCall<'a, C>
19945 where
19946 I: IntoIterator<Item = St>,
19947 St: AsRef<str>,
19948 {
19949 self._scopes
19950 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19951 self
19952 }
19953
19954 /// Removes all scopes, and no default scope will be used either.
19955 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19956 /// for details).
19957 pub fn clear_scopes(mut self) -> ProjectLocationSourceCreateCall<'a, C> {
19958 self._scopes.clear();
19959 self
19960 }
19961}
19962
19963/// Deletes a single Source.
19964///
19965/// A builder for the *locations.sources.delete* method supported by a *project* resource.
19966/// It is not used directly, but through a [`ProjectMethods`] instance.
19967///
19968/// # Example
19969///
19970/// Instantiate a resource method builder
19971///
19972/// ```test_harness,no_run
19973/// # extern crate hyper;
19974/// # extern crate hyper_rustls;
19975/// # extern crate google_vmmigration1 as vmmigration1;
19976/// # async fn dox() {
19977/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19978///
19979/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19980/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19981/// # secret,
19982/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19983/// # ).build().await.unwrap();
19984///
19985/// # let client = hyper_util::client::legacy::Client::builder(
19986/// # hyper_util::rt::TokioExecutor::new()
19987/// # )
19988/// # .build(
19989/// # hyper_rustls::HttpsConnectorBuilder::new()
19990/// # .with_native_roots()
19991/// # .unwrap()
19992/// # .https_or_http()
19993/// # .enable_http1()
19994/// # .build()
19995/// # );
19996/// # let mut hub = VMMigrationService::new(client, auth);
19997/// // You can configure optional parameters by calling the respective setters at will, and
19998/// // execute the final call using `doit()`.
19999/// // Values shown here are possibly random and not representative !
20000/// let result = hub.projects().locations_sources_delete("name")
20001/// .request_id("no")
20002/// .doit().await;
20003/// # }
20004/// ```
20005pub struct ProjectLocationSourceDeleteCall<'a, C>
20006where
20007 C: 'a,
20008{
20009 hub: &'a VMMigrationService<C>,
20010 _name: String,
20011 _request_id: Option<String>,
20012 _delegate: Option<&'a mut dyn common::Delegate>,
20013 _additional_params: HashMap<String, String>,
20014 _scopes: BTreeSet<String>,
20015}
20016
20017impl<'a, C> common::CallBuilder for ProjectLocationSourceDeleteCall<'a, C> {}
20018
20019impl<'a, C> ProjectLocationSourceDeleteCall<'a, C>
20020where
20021 C: common::Connector,
20022{
20023 /// Perform the operation you have build so far.
20024 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
20025 use std::borrow::Cow;
20026 use std::io::{Read, Seek};
20027
20028 use common::{url::Params, ToParts};
20029 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20030
20031 let mut dd = common::DefaultDelegate;
20032 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20033 dlg.begin(common::MethodInfo {
20034 id: "vmmigration.projects.locations.sources.delete",
20035 http_method: hyper::Method::DELETE,
20036 });
20037
20038 for &field in ["alt", "name", "requestId"].iter() {
20039 if self._additional_params.contains_key(field) {
20040 dlg.finished(false);
20041 return Err(common::Error::FieldClash(field));
20042 }
20043 }
20044
20045 let mut params = Params::with_capacity(4 + self._additional_params.len());
20046 params.push("name", self._name);
20047 if let Some(value) = self._request_id.as_ref() {
20048 params.push("requestId", value);
20049 }
20050
20051 params.extend(self._additional_params.iter());
20052
20053 params.push("alt", "json");
20054 let mut url = self.hub._base_url.clone() + "v1/{+name}";
20055 if self._scopes.is_empty() {
20056 self._scopes
20057 .insert(Scope::CloudPlatform.as_ref().to_string());
20058 }
20059
20060 #[allow(clippy::single_element_loop)]
20061 for &(find_this, param_name) in [("{+name}", "name")].iter() {
20062 url = params.uri_replacement(url, param_name, find_this, true);
20063 }
20064 {
20065 let to_remove = ["name"];
20066 params.remove_params(&to_remove);
20067 }
20068
20069 let url = params.parse_with_url(&url);
20070
20071 loop {
20072 let token = match self
20073 .hub
20074 .auth
20075 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20076 .await
20077 {
20078 Ok(token) => token,
20079 Err(e) => match dlg.token(e) {
20080 Ok(token) => token,
20081 Err(e) => {
20082 dlg.finished(false);
20083 return Err(common::Error::MissingToken(e));
20084 }
20085 },
20086 };
20087 let mut req_result = {
20088 let client = &self.hub.client;
20089 dlg.pre_request();
20090 let mut req_builder = hyper::Request::builder()
20091 .method(hyper::Method::DELETE)
20092 .uri(url.as_str())
20093 .header(USER_AGENT, self.hub._user_agent.clone());
20094
20095 if let Some(token) = token.as_ref() {
20096 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20097 }
20098
20099 let request = req_builder
20100 .header(CONTENT_LENGTH, 0_u64)
20101 .body(common::to_body::<String>(None));
20102
20103 client.request(request.unwrap()).await
20104 };
20105
20106 match req_result {
20107 Err(err) => {
20108 if let common::Retry::After(d) = dlg.http_error(&err) {
20109 sleep(d).await;
20110 continue;
20111 }
20112 dlg.finished(false);
20113 return Err(common::Error::HttpError(err));
20114 }
20115 Ok(res) => {
20116 let (mut parts, body) = res.into_parts();
20117 let mut body = common::Body::new(body);
20118 if !parts.status.is_success() {
20119 let bytes = common::to_bytes(body).await.unwrap_or_default();
20120 let error = serde_json::from_str(&common::to_string(&bytes));
20121 let response = common::to_response(parts, bytes.into());
20122
20123 if let common::Retry::After(d) =
20124 dlg.http_failure(&response, error.as_ref().ok())
20125 {
20126 sleep(d).await;
20127 continue;
20128 }
20129
20130 dlg.finished(false);
20131
20132 return Err(match error {
20133 Ok(value) => common::Error::BadRequest(value),
20134 _ => common::Error::Failure(response),
20135 });
20136 }
20137 let response = {
20138 let bytes = common::to_bytes(body).await.unwrap_or_default();
20139 let encoded = common::to_string(&bytes);
20140 match serde_json::from_str(&encoded) {
20141 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20142 Err(error) => {
20143 dlg.response_json_decode_error(&encoded, &error);
20144 return Err(common::Error::JsonDecodeError(
20145 encoded.to_string(),
20146 error,
20147 ));
20148 }
20149 }
20150 };
20151
20152 dlg.finished(true);
20153 return Ok(response);
20154 }
20155 }
20156 }
20157 }
20158
20159 /// Required. The Source name.
20160 ///
20161 /// Sets the *name* path property to the given value.
20162 ///
20163 /// Even though the property as already been set when instantiating this call,
20164 /// we provide this method for API completeness.
20165 pub fn name(mut self, new_value: &str) -> ProjectLocationSourceDeleteCall<'a, C> {
20166 self._name = new_value.to_string();
20167 self
20168 }
20169 /// Optional. A request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes after the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
20170 ///
20171 /// Sets the *request id* query property to the given value.
20172 pub fn request_id(mut self, new_value: &str) -> ProjectLocationSourceDeleteCall<'a, C> {
20173 self._request_id = Some(new_value.to_string());
20174 self
20175 }
20176 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20177 /// while executing the actual API request.
20178 ///
20179 /// ````text
20180 /// It should be used to handle progress information, and to implement a certain level of resilience.
20181 /// ````
20182 ///
20183 /// Sets the *delegate* property to the given value.
20184 pub fn delegate(
20185 mut self,
20186 new_value: &'a mut dyn common::Delegate,
20187 ) -> ProjectLocationSourceDeleteCall<'a, C> {
20188 self._delegate = Some(new_value);
20189 self
20190 }
20191
20192 /// Set any additional parameter of the query string used in the request.
20193 /// It should be used to set parameters which are not yet available through their own
20194 /// setters.
20195 ///
20196 /// Please note that this method must not be used to set any of the known parameters
20197 /// which have their own setter method. If done anyway, the request will fail.
20198 ///
20199 /// # Additional Parameters
20200 ///
20201 /// * *$.xgafv* (query-string) - V1 error format.
20202 /// * *access_token* (query-string) - OAuth access token.
20203 /// * *alt* (query-string) - Data format for response.
20204 /// * *callback* (query-string) - JSONP
20205 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20206 /// * *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.
20207 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20208 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20209 /// * *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.
20210 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20211 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20212 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSourceDeleteCall<'a, C>
20213 where
20214 T: AsRef<str>,
20215 {
20216 self._additional_params
20217 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20218 self
20219 }
20220
20221 /// Identifies the authorization scope for the method you are building.
20222 ///
20223 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20224 /// [`Scope::CloudPlatform`].
20225 ///
20226 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20227 /// tokens for more than one scope.
20228 ///
20229 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20230 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20231 /// sufficient, a read-write scope will do as well.
20232 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceDeleteCall<'a, C>
20233 where
20234 St: AsRef<str>,
20235 {
20236 self._scopes.insert(String::from(scope.as_ref()));
20237 self
20238 }
20239 /// Identifies the authorization scope(s) for the method you are building.
20240 ///
20241 /// See [`Self::add_scope()`] for details.
20242 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSourceDeleteCall<'a, C>
20243 where
20244 I: IntoIterator<Item = St>,
20245 St: AsRef<str>,
20246 {
20247 self._scopes
20248 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20249 self
20250 }
20251
20252 /// Removes all scopes, and no default scope will be used either.
20253 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20254 /// for details).
20255 pub fn clear_scopes(mut self) -> ProjectLocationSourceDeleteCall<'a, C> {
20256 self._scopes.clear();
20257 self
20258 }
20259}
20260
20261/// List remote source's inventory of VMs. The remote source is the onprem vCenter (remote in the sense it's not in Compute Engine). The inventory describes the list of existing VMs in that source. Note that this operation lists the VMs on the remote source, as opposed to listing the MigratingVms resources in the vmmigration service.
20262///
20263/// A builder for the *locations.sources.fetchInventory* method supported by a *project* resource.
20264/// It is not used directly, but through a [`ProjectMethods`] instance.
20265///
20266/// # Example
20267///
20268/// Instantiate a resource method builder
20269///
20270/// ```test_harness,no_run
20271/// # extern crate hyper;
20272/// # extern crate hyper_rustls;
20273/// # extern crate google_vmmigration1 as vmmigration1;
20274/// # async fn dox() {
20275/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20276///
20277/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20278/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20279/// # secret,
20280/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20281/// # ).build().await.unwrap();
20282///
20283/// # let client = hyper_util::client::legacy::Client::builder(
20284/// # hyper_util::rt::TokioExecutor::new()
20285/// # )
20286/// # .build(
20287/// # hyper_rustls::HttpsConnectorBuilder::new()
20288/// # .with_native_roots()
20289/// # .unwrap()
20290/// # .https_or_http()
20291/// # .enable_http1()
20292/// # .build()
20293/// # );
20294/// # let mut hub = VMMigrationService::new(client, auth);
20295/// // You can configure optional parameters by calling the respective setters at will, and
20296/// // execute the final call using `doit()`.
20297/// // Values shown here are possibly random and not representative !
20298/// let result = hub.projects().locations_sources_fetch_inventory("source")
20299/// .page_token("At")
20300/// .page_size(-45)
20301/// .force_refresh(true)
20302/// .doit().await;
20303/// # }
20304/// ```
20305pub struct ProjectLocationSourceFetchInventoryCall<'a, C>
20306where
20307 C: 'a,
20308{
20309 hub: &'a VMMigrationService<C>,
20310 _source: String,
20311 _page_token: Option<String>,
20312 _page_size: Option<i32>,
20313 _force_refresh: Option<bool>,
20314 _delegate: Option<&'a mut dyn common::Delegate>,
20315 _additional_params: HashMap<String, String>,
20316 _scopes: BTreeSet<String>,
20317}
20318
20319impl<'a, C> common::CallBuilder for ProjectLocationSourceFetchInventoryCall<'a, C> {}
20320
20321impl<'a, C> ProjectLocationSourceFetchInventoryCall<'a, C>
20322where
20323 C: common::Connector,
20324{
20325 /// Perform the operation you have build so far.
20326 pub async fn doit(mut self) -> common::Result<(common::Response, FetchInventoryResponse)> {
20327 use std::borrow::Cow;
20328 use std::io::{Read, Seek};
20329
20330 use common::{url::Params, ToParts};
20331 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20332
20333 let mut dd = common::DefaultDelegate;
20334 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20335 dlg.begin(common::MethodInfo {
20336 id: "vmmigration.projects.locations.sources.fetchInventory",
20337 http_method: hyper::Method::GET,
20338 });
20339
20340 for &field in ["alt", "source", "pageToken", "pageSize", "forceRefresh"].iter() {
20341 if self._additional_params.contains_key(field) {
20342 dlg.finished(false);
20343 return Err(common::Error::FieldClash(field));
20344 }
20345 }
20346
20347 let mut params = Params::with_capacity(6 + self._additional_params.len());
20348 params.push("source", self._source);
20349 if let Some(value) = self._page_token.as_ref() {
20350 params.push("pageToken", value);
20351 }
20352 if let Some(value) = self._page_size.as_ref() {
20353 params.push("pageSize", value.to_string());
20354 }
20355 if let Some(value) = self._force_refresh.as_ref() {
20356 params.push("forceRefresh", value.to_string());
20357 }
20358
20359 params.extend(self._additional_params.iter());
20360
20361 params.push("alt", "json");
20362 let mut url = self.hub._base_url.clone() + "v1/{+source}:fetchInventory";
20363 if self._scopes.is_empty() {
20364 self._scopes
20365 .insert(Scope::CloudPlatform.as_ref().to_string());
20366 }
20367
20368 #[allow(clippy::single_element_loop)]
20369 for &(find_this, param_name) in [("{+source}", "source")].iter() {
20370 url = params.uri_replacement(url, param_name, find_this, true);
20371 }
20372 {
20373 let to_remove = ["source"];
20374 params.remove_params(&to_remove);
20375 }
20376
20377 let url = params.parse_with_url(&url);
20378
20379 loop {
20380 let token = match self
20381 .hub
20382 .auth
20383 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20384 .await
20385 {
20386 Ok(token) => token,
20387 Err(e) => match dlg.token(e) {
20388 Ok(token) => token,
20389 Err(e) => {
20390 dlg.finished(false);
20391 return Err(common::Error::MissingToken(e));
20392 }
20393 },
20394 };
20395 let mut req_result = {
20396 let client = &self.hub.client;
20397 dlg.pre_request();
20398 let mut req_builder = hyper::Request::builder()
20399 .method(hyper::Method::GET)
20400 .uri(url.as_str())
20401 .header(USER_AGENT, self.hub._user_agent.clone());
20402
20403 if let Some(token) = token.as_ref() {
20404 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20405 }
20406
20407 let request = req_builder
20408 .header(CONTENT_LENGTH, 0_u64)
20409 .body(common::to_body::<String>(None));
20410
20411 client.request(request.unwrap()).await
20412 };
20413
20414 match req_result {
20415 Err(err) => {
20416 if let common::Retry::After(d) = dlg.http_error(&err) {
20417 sleep(d).await;
20418 continue;
20419 }
20420 dlg.finished(false);
20421 return Err(common::Error::HttpError(err));
20422 }
20423 Ok(res) => {
20424 let (mut parts, body) = res.into_parts();
20425 let mut body = common::Body::new(body);
20426 if !parts.status.is_success() {
20427 let bytes = common::to_bytes(body).await.unwrap_or_default();
20428 let error = serde_json::from_str(&common::to_string(&bytes));
20429 let response = common::to_response(parts, bytes.into());
20430
20431 if let common::Retry::After(d) =
20432 dlg.http_failure(&response, error.as_ref().ok())
20433 {
20434 sleep(d).await;
20435 continue;
20436 }
20437
20438 dlg.finished(false);
20439
20440 return Err(match error {
20441 Ok(value) => common::Error::BadRequest(value),
20442 _ => common::Error::Failure(response),
20443 });
20444 }
20445 let response = {
20446 let bytes = common::to_bytes(body).await.unwrap_or_default();
20447 let encoded = common::to_string(&bytes);
20448 match serde_json::from_str(&encoded) {
20449 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20450 Err(error) => {
20451 dlg.response_json_decode_error(&encoded, &error);
20452 return Err(common::Error::JsonDecodeError(
20453 encoded.to_string(),
20454 error,
20455 ));
20456 }
20457 }
20458 };
20459
20460 dlg.finished(true);
20461 return Ok(response);
20462 }
20463 }
20464 }
20465 }
20466
20467 /// Required. The name of the Source.
20468 ///
20469 /// Sets the *source* path property to the given value.
20470 ///
20471 /// Even though the property as already been set when instantiating this call,
20472 /// we provide this method for API completeness.
20473 pub fn source(mut self, new_value: &str) -> ProjectLocationSourceFetchInventoryCall<'a, C> {
20474 self._source = new_value.to_string();
20475 self
20476 }
20477 /// A page token, received from a previous `FetchInventory` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `FetchInventory` must match the call that provided the page token.
20478 ///
20479 /// Sets the *page token* query property to the given value.
20480 pub fn page_token(mut self, new_value: &str) -> ProjectLocationSourceFetchInventoryCall<'a, C> {
20481 self._page_token = Some(new_value.to_string());
20482 self
20483 }
20484 /// The maximum number of VMs to return. The service may return fewer than this value. For AWS source: If unspecified, at most 500 VMs will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000. For VMWare source: If unspecified, all VMs will be returned. There is no limit for maximum value.
20485 ///
20486 /// Sets the *page size* query property to the given value.
20487 pub fn page_size(mut self, new_value: i32) -> ProjectLocationSourceFetchInventoryCall<'a, C> {
20488 self._page_size = Some(new_value);
20489 self
20490 }
20491 /// If this flag is set to true, the source will be queried instead of using cached results. Using this flag will make the call slower.
20492 ///
20493 /// Sets the *force refresh* query property to the given value.
20494 pub fn force_refresh(
20495 mut self,
20496 new_value: bool,
20497 ) -> ProjectLocationSourceFetchInventoryCall<'a, C> {
20498 self._force_refresh = Some(new_value);
20499 self
20500 }
20501 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20502 /// while executing the actual API request.
20503 ///
20504 /// ````text
20505 /// It should be used to handle progress information, and to implement a certain level of resilience.
20506 /// ````
20507 ///
20508 /// Sets the *delegate* property to the given value.
20509 pub fn delegate(
20510 mut self,
20511 new_value: &'a mut dyn common::Delegate,
20512 ) -> ProjectLocationSourceFetchInventoryCall<'a, C> {
20513 self._delegate = Some(new_value);
20514 self
20515 }
20516
20517 /// Set any additional parameter of the query string used in the request.
20518 /// It should be used to set parameters which are not yet available through their own
20519 /// setters.
20520 ///
20521 /// Please note that this method must not be used to set any of the known parameters
20522 /// which have their own setter method. If done anyway, the request will fail.
20523 ///
20524 /// # Additional Parameters
20525 ///
20526 /// * *$.xgafv* (query-string) - V1 error format.
20527 /// * *access_token* (query-string) - OAuth access token.
20528 /// * *alt* (query-string) - Data format for response.
20529 /// * *callback* (query-string) - JSONP
20530 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20531 /// * *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.
20532 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20533 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20534 /// * *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.
20535 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20536 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20537 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSourceFetchInventoryCall<'a, C>
20538 where
20539 T: AsRef<str>,
20540 {
20541 self._additional_params
20542 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20543 self
20544 }
20545
20546 /// Identifies the authorization scope for the method you are building.
20547 ///
20548 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20549 /// [`Scope::CloudPlatform`].
20550 ///
20551 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20552 /// tokens for more than one scope.
20553 ///
20554 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20555 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20556 /// sufficient, a read-write scope will do as well.
20557 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceFetchInventoryCall<'a, C>
20558 where
20559 St: AsRef<str>,
20560 {
20561 self._scopes.insert(String::from(scope.as_ref()));
20562 self
20563 }
20564 /// Identifies the authorization scope(s) for the method you are building.
20565 ///
20566 /// See [`Self::add_scope()`] for details.
20567 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSourceFetchInventoryCall<'a, C>
20568 where
20569 I: IntoIterator<Item = St>,
20570 St: AsRef<str>,
20571 {
20572 self._scopes
20573 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20574 self
20575 }
20576
20577 /// Removes all scopes, and no default scope will be used either.
20578 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20579 /// for details).
20580 pub fn clear_scopes(mut self) -> ProjectLocationSourceFetchInventoryCall<'a, C> {
20581 self._scopes.clear();
20582 self
20583 }
20584}
20585
20586/// Gets details of a single Source.
20587///
20588/// A builder for the *locations.sources.get* method supported by a *project* resource.
20589/// It is not used directly, but through a [`ProjectMethods`] instance.
20590///
20591/// # Example
20592///
20593/// Instantiate a resource method builder
20594///
20595/// ```test_harness,no_run
20596/// # extern crate hyper;
20597/// # extern crate hyper_rustls;
20598/// # extern crate google_vmmigration1 as vmmigration1;
20599/// # async fn dox() {
20600/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20601///
20602/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20603/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20604/// # secret,
20605/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20606/// # ).build().await.unwrap();
20607///
20608/// # let client = hyper_util::client::legacy::Client::builder(
20609/// # hyper_util::rt::TokioExecutor::new()
20610/// # )
20611/// # .build(
20612/// # hyper_rustls::HttpsConnectorBuilder::new()
20613/// # .with_native_roots()
20614/// # .unwrap()
20615/// # .https_or_http()
20616/// # .enable_http1()
20617/// # .build()
20618/// # );
20619/// # let mut hub = VMMigrationService::new(client, auth);
20620/// // You can configure optional parameters by calling the respective setters at will, and
20621/// // execute the final call using `doit()`.
20622/// // Values shown here are possibly random and not representative !
20623/// let result = hub.projects().locations_sources_get("name")
20624/// .doit().await;
20625/// # }
20626/// ```
20627pub struct ProjectLocationSourceGetCall<'a, C>
20628where
20629 C: 'a,
20630{
20631 hub: &'a VMMigrationService<C>,
20632 _name: String,
20633 _delegate: Option<&'a mut dyn common::Delegate>,
20634 _additional_params: HashMap<String, String>,
20635 _scopes: BTreeSet<String>,
20636}
20637
20638impl<'a, C> common::CallBuilder for ProjectLocationSourceGetCall<'a, C> {}
20639
20640impl<'a, C> ProjectLocationSourceGetCall<'a, C>
20641where
20642 C: common::Connector,
20643{
20644 /// Perform the operation you have build so far.
20645 pub async fn doit(mut self) -> common::Result<(common::Response, Source)> {
20646 use std::borrow::Cow;
20647 use std::io::{Read, Seek};
20648
20649 use common::{url::Params, ToParts};
20650 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20651
20652 let mut dd = common::DefaultDelegate;
20653 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20654 dlg.begin(common::MethodInfo {
20655 id: "vmmigration.projects.locations.sources.get",
20656 http_method: hyper::Method::GET,
20657 });
20658
20659 for &field in ["alt", "name"].iter() {
20660 if self._additional_params.contains_key(field) {
20661 dlg.finished(false);
20662 return Err(common::Error::FieldClash(field));
20663 }
20664 }
20665
20666 let mut params = Params::with_capacity(3 + self._additional_params.len());
20667 params.push("name", self._name);
20668
20669 params.extend(self._additional_params.iter());
20670
20671 params.push("alt", "json");
20672 let mut url = self.hub._base_url.clone() + "v1/{+name}";
20673 if self._scopes.is_empty() {
20674 self._scopes
20675 .insert(Scope::CloudPlatform.as_ref().to_string());
20676 }
20677
20678 #[allow(clippy::single_element_loop)]
20679 for &(find_this, param_name) in [("{+name}", "name")].iter() {
20680 url = params.uri_replacement(url, param_name, find_this, true);
20681 }
20682 {
20683 let to_remove = ["name"];
20684 params.remove_params(&to_remove);
20685 }
20686
20687 let url = params.parse_with_url(&url);
20688
20689 loop {
20690 let token = match self
20691 .hub
20692 .auth
20693 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20694 .await
20695 {
20696 Ok(token) => token,
20697 Err(e) => match dlg.token(e) {
20698 Ok(token) => token,
20699 Err(e) => {
20700 dlg.finished(false);
20701 return Err(common::Error::MissingToken(e));
20702 }
20703 },
20704 };
20705 let mut req_result = {
20706 let client = &self.hub.client;
20707 dlg.pre_request();
20708 let mut req_builder = hyper::Request::builder()
20709 .method(hyper::Method::GET)
20710 .uri(url.as_str())
20711 .header(USER_AGENT, self.hub._user_agent.clone());
20712
20713 if let Some(token) = token.as_ref() {
20714 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20715 }
20716
20717 let request = req_builder
20718 .header(CONTENT_LENGTH, 0_u64)
20719 .body(common::to_body::<String>(None));
20720
20721 client.request(request.unwrap()).await
20722 };
20723
20724 match req_result {
20725 Err(err) => {
20726 if let common::Retry::After(d) = dlg.http_error(&err) {
20727 sleep(d).await;
20728 continue;
20729 }
20730 dlg.finished(false);
20731 return Err(common::Error::HttpError(err));
20732 }
20733 Ok(res) => {
20734 let (mut parts, body) = res.into_parts();
20735 let mut body = common::Body::new(body);
20736 if !parts.status.is_success() {
20737 let bytes = common::to_bytes(body).await.unwrap_or_default();
20738 let error = serde_json::from_str(&common::to_string(&bytes));
20739 let response = common::to_response(parts, bytes.into());
20740
20741 if let common::Retry::After(d) =
20742 dlg.http_failure(&response, error.as_ref().ok())
20743 {
20744 sleep(d).await;
20745 continue;
20746 }
20747
20748 dlg.finished(false);
20749
20750 return Err(match error {
20751 Ok(value) => common::Error::BadRequest(value),
20752 _ => common::Error::Failure(response),
20753 });
20754 }
20755 let response = {
20756 let bytes = common::to_bytes(body).await.unwrap_or_default();
20757 let encoded = common::to_string(&bytes);
20758 match serde_json::from_str(&encoded) {
20759 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20760 Err(error) => {
20761 dlg.response_json_decode_error(&encoded, &error);
20762 return Err(common::Error::JsonDecodeError(
20763 encoded.to_string(),
20764 error,
20765 ));
20766 }
20767 }
20768 };
20769
20770 dlg.finished(true);
20771 return Ok(response);
20772 }
20773 }
20774 }
20775 }
20776
20777 /// Required. The Source name.
20778 ///
20779 /// Sets the *name* path property to the given value.
20780 ///
20781 /// Even though the property as already been set when instantiating this call,
20782 /// we provide this method for API completeness.
20783 pub fn name(mut self, new_value: &str) -> ProjectLocationSourceGetCall<'a, C> {
20784 self._name = new_value.to_string();
20785 self
20786 }
20787 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20788 /// while executing the actual API request.
20789 ///
20790 /// ````text
20791 /// It should be used to handle progress information, and to implement a certain level of resilience.
20792 /// ````
20793 ///
20794 /// Sets the *delegate* property to the given value.
20795 pub fn delegate(
20796 mut self,
20797 new_value: &'a mut dyn common::Delegate,
20798 ) -> ProjectLocationSourceGetCall<'a, C> {
20799 self._delegate = Some(new_value);
20800 self
20801 }
20802
20803 /// Set any additional parameter of the query string used in the request.
20804 /// It should be used to set parameters which are not yet available through their own
20805 /// setters.
20806 ///
20807 /// Please note that this method must not be used to set any of the known parameters
20808 /// which have their own setter method. If done anyway, the request will fail.
20809 ///
20810 /// # Additional Parameters
20811 ///
20812 /// * *$.xgafv* (query-string) - V1 error format.
20813 /// * *access_token* (query-string) - OAuth access token.
20814 /// * *alt* (query-string) - Data format for response.
20815 /// * *callback* (query-string) - JSONP
20816 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20817 /// * *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.
20818 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20819 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20820 /// * *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.
20821 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20822 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20823 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSourceGetCall<'a, C>
20824 where
20825 T: AsRef<str>,
20826 {
20827 self._additional_params
20828 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20829 self
20830 }
20831
20832 /// Identifies the authorization scope for the method you are building.
20833 ///
20834 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20835 /// [`Scope::CloudPlatform`].
20836 ///
20837 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20838 /// tokens for more than one scope.
20839 ///
20840 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20841 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20842 /// sufficient, a read-write scope will do as well.
20843 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceGetCall<'a, C>
20844 where
20845 St: AsRef<str>,
20846 {
20847 self._scopes.insert(String::from(scope.as_ref()));
20848 self
20849 }
20850 /// Identifies the authorization scope(s) for the method you are building.
20851 ///
20852 /// See [`Self::add_scope()`] for details.
20853 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSourceGetCall<'a, C>
20854 where
20855 I: IntoIterator<Item = St>,
20856 St: AsRef<str>,
20857 {
20858 self._scopes
20859 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20860 self
20861 }
20862
20863 /// Removes all scopes, and no default scope will be used either.
20864 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20865 /// for details).
20866 pub fn clear_scopes(mut self) -> ProjectLocationSourceGetCall<'a, C> {
20867 self._scopes.clear();
20868 self
20869 }
20870}
20871
20872/// Lists Sources in a given project and location.
20873///
20874/// A builder for the *locations.sources.list* method supported by a *project* resource.
20875/// It is not used directly, but through a [`ProjectMethods`] instance.
20876///
20877/// # Example
20878///
20879/// Instantiate a resource method builder
20880///
20881/// ```test_harness,no_run
20882/// # extern crate hyper;
20883/// # extern crate hyper_rustls;
20884/// # extern crate google_vmmigration1 as vmmigration1;
20885/// # async fn dox() {
20886/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20887///
20888/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20889/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20890/// # secret,
20891/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20892/// # ).build().await.unwrap();
20893///
20894/// # let client = hyper_util::client::legacy::Client::builder(
20895/// # hyper_util::rt::TokioExecutor::new()
20896/// # )
20897/// # .build(
20898/// # hyper_rustls::HttpsConnectorBuilder::new()
20899/// # .with_native_roots()
20900/// # .unwrap()
20901/// # .https_or_http()
20902/// # .enable_http1()
20903/// # .build()
20904/// # );
20905/// # let mut hub = VMMigrationService::new(client, auth);
20906/// // You can configure optional parameters by calling the respective setters at will, and
20907/// // execute the final call using `doit()`.
20908/// // Values shown here are possibly random and not representative !
20909/// let result = hub.projects().locations_sources_list("parent")
20910/// .page_token("aliquyam")
20911/// .page_size(-47)
20912/// .order_by("est")
20913/// .filter("et")
20914/// .doit().await;
20915/// # }
20916/// ```
20917pub struct ProjectLocationSourceListCall<'a, C>
20918where
20919 C: 'a,
20920{
20921 hub: &'a VMMigrationService<C>,
20922 _parent: String,
20923 _page_token: Option<String>,
20924 _page_size: Option<i32>,
20925 _order_by: Option<String>,
20926 _filter: Option<String>,
20927 _delegate: Option<&'a mut dyn common::Delegate>,
20928 _additional_params: HashMap<String, String>,
20929 _scopes: BTreeSet<String>,
20930}
20931
20932impl<'a, C> common::CallBuilder for ProjectLocationSourceListCall<'a, C> {}
20933
20934impl<'a, C> ProjectLocationSourceListCall<'a, C>
20935where
20936 C: common::Connector,
20937{
20938 /// Perform the operation you have build so far.
20939 pub async fn doit(mut self) -> common::Result<(common::Response, ListSourcesResponse)> {
20940 use std::borrow::Cow;
20941 use std::io::{Read, Seek};
20942
20943 use common::{url::Params, ToParts};
20944 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20945
20946 let mut dd = common::DefaultDelegate;
20947 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20948 dlg.begin(common::MethodInfo {
20949 id: "vmmigration.projects.locations.sources.list",
20950 http_method: hyper::Method::GET,
20951 });
20952
20953 for &field in [
20954 "alt",
20955 "parent",
20956 "pageToken",
20957 "pageSize",
20958 "orderBy",
20959 "filter",
20960 ]
20961 .iter()
20962 {
20963 if self._additional_params.contains_key(field) {
20964 dlg.finished(false);
20965 return Err(common::Error::FieldClash(field));
20966 }
20967 }
20968
20969 let mut params = Params::with_capacity(7 + self._additional_params.len());
20970 params.push("parent", self._parent);
20971 if let Some(value) = self._page_token.as_ref() {
20972 params.push("pageToken", value);
20973 }
20974 if let Some(value) = self._page_size.as_ref() {
20975 params.push("pageSize", value.to_string());
20976 }
20977 if let Some(value) = self._order_by.as_ref() {
20978 params.push("orderBy", value);
20979 }
20980 if let Some(value) = self._filter.as_ref() {
20981 params.push("filter", value);
20982 }
20983
20984 params.extend(self._additional_params.iter());
20985
20986 params.push("alt", "json");
20987 let mut url = self.hub._base_url.clone() + "v1/{+parent}/sources";
20988 if self._scopes.is_empty() {
20989 self._scopes
20990 .insert(Scope::CloudPlatform.as_ref().to_string());
20991 }
20992
20993 #[allow(clippy::single_element_loop)]
20994 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
20995 url = params.uri_replacement(url, param_name, find_this, true);
20996 }
20997 {
20998 let to_remove = ["parent"];
20999 params.remove_params(&to_remove);
21000 }
21001
21002 let url = params.parse_with_url(&url);
21003
21004 loop {
21005 let token = match self
21006 .hub
21007 .auth
21008 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21009 .await
21010 {
21011 Ok(token) => token,
21012 Err(e) => match dlg.token(e) {
21013 Ok(token) => token,
21014 Err(e) => {
21015 dlg.finished(false);
21016 return Err(common::Error::MissingToken(e));
21017 }
21018 },
21019 };
21020 let mut req_result = {
21021 let client = &self.hub.client;
21022 dlg.pre_request();
21023 let mut req_builder = hyper::Request::builder()
21024 .method(hyper::Method::GET)
21025 .uri(url.as_str())
21026 .header(USER_AGENT, self.hub._user_agent.clone());
21027
21028 if let Some(token) = token.as_ref() {
21029 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21030 }
21031
21032 let request = req_builder
21033 .header(CONTENT_LENGTH, 0_u64)
21034 .body(common::to_body::<String>(None));
21035
21036 client.request(request.unwrap()).await
21037 };
21038
21039 match req_result {
21040 Err(err) => {
21041 if let common::Retry::After(d) = dlg.http_error(&err) {
21042 sleep(d).await;
21043 continue;
21044 }
21045 dlg.finished(false);
21046 return Err(common::Error::HttpError(err));
21047 }
21048 Ok(res) => {
21049 let (mut parts, body) = res.into_parts();
21050 let mut body = common::Body::new(body);
21051 if !parts.status.is_success() {
21052 let bytes = common::to_bytes(body).await.unwrap_or_default();
21053 let error = serde_json::from_str(&common::to_string(&bytes));
21054 let response = common::to_response(parts, bytes.into());
21055
21056 if let common::Retry::After(d) =
21057 dlg.http_failure(&response, error.as_ref().ok())
21058 {
21059 sleep(d).await;
21060 continue;
21061 }
21062
21063 dlg.finished(false);
21064
21065 return Err(match error {
21066 Ok(value) => common::Error::BadRequest(value),
21067 _ => common::Error::Failure(response),
21068 });
21069 }
21070 let response = {
21071 let bytes = common::to_bytes(body).await.unwrap_or_default();
21072 let encoded = common::to_string(&bytes);
21073 match serde_json::from_str(&encoded) {
21074 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21075 Err(error) => {
21076 dlg.response_json_decode_error(&encoded, &error);
21077 return Err(common::Error::JsonDecodeError(
21078 encoded.to_string(),
21079 error,
21080 ));
21081 }
21082 }
21083 };
21084
21085 dlg.finished(true);
21086 return Ok(response);
21087 }
21088 }
21089 }
21090 }
21091
21092 /// Required. The parent, which owns this collection of sources.
21093 ///
21094 /// Sets the *parent* path property to the given value.
21095 ///
21096 /// Even though the property as already been set when instantiating this call,
21097 /// we provide this method for API completeness.
21098 pub fn parent(mut self, new_value: &str) -> ProjectLocationSourceListCall<'a, C> {
21099 self._parent = new_value.to_string();
21100 self
21101 }
21102 /// Required. A page token, received from a previous `ListSources` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListSources` must match the call that provided the page token.
21103 ///
21104 /// Sets the *page token* query property to the given value.
21105 pub fn page_token(mut self, new_value: &str) -> ProjectLocationSourceListCall<'a, C> {
21106 self._page_token = Some(new_value.to_string());
21107 self
21108 }
21109 /// Optional. The maximum number of sources to return. The service may return fewer than this value. If unspecified, at most 500 sources will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
21110 ///
21111 /// Sets the *page size* query property to the given value.
21112 pub fn page_size(mut self, new_value: i32) -> ProjectLocationSourceListCall<'a, C> {
21113 self._page_size = Some(new_value);
21114 self
21115 }
21116 /// Optional. the order by fields for the result.
21117 ///
21118 /// Sets the *order by* query property to the given value.
21119 pub fn order_by(mut self, new_value: &str) -> ProjectLocationSourceListCall<'a, C> {
21120 self._order_by = Some(new_value.to_string());
21121 self
21122 }
21123 /// Optional. The filter request.
21124 ///
21125 /// Sets the *filter* query property to the given value.
21126 pub fn filter(mut self, new_value: &str) -> ProjectLocationSourceListCall<'a, C> {
21127 self._filter = Some(new_value.to_string());
21128 self
21129 }
21130 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21131 /// while executing the actual API request.
21132 ///
21133 /// ````text
21134 /// It should be used to handle progress information, and to implement a certain level of resilience.
21135 /// ````
21136 ///
21137 /// Sets the *delegate* property to the given value.
21138 pub fn delegate(
21139 mut self,
21140 new_value: &'a mut dyn common::Delegate,
21141 ) -> ProjectLocationSourceListCall<'a, C> {
21142 self._delegate = Some(new_value);
21143 self
21144 }
21145
21146 /// Set any additional parameter of the query string used in the request.
21147 /// It should be used to set parameters which are not yet available through their own
21148 /// setters.
21149 ///
21150 /// Please note that this method must not be used to set any of the known parameters
21151 /// which have their own setter method. If done anyway, the request will fail.
21152 ///
21153 /// # Additional Parameters
21154 ///
21155 /// * *$.xgafv* (query-string) - V1 error format.
21156 /// * *access_token* (query-string) - OAuth access token.
21157 /// * *alt* (query-string) - Data format for response.
21158 /// * *callback* (query-string) - JSONP
21159 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21160 /// * *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.
21161 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21162 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21163 /// * *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.
21164 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21165 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21166 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSourceListCall<'a, C>
21167 where
21168 T: AsRef<str>,
21169 {
21170 self._additional_params
21171 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21172 self
21173 }
21174
21175 /// Identifies the authorization scope for the method you are building.
21176 ///
21177 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21178 /// [`Scope::CloudPlatform`].
21179 ///
21180 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21181 /// tokens for more than one scope.
21182 ///
21183 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21184 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21185 /// sufficient, a read-write scope will do as well.
21186 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceListCall<'a, C>
21187 where
21188 St: AsRef<str>,
21189 {
21190 self._scopes.insert(String::from(scope.as_ref()));
21191 self
21192 }
21193 /// Identifies the authorization scope(s) for the method you are building.
21194 ///
21195 /// See [`Self::add_scope()`] for details.
21196 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSourceListCall<'a, C>
21197 where
21198 I: IntoIterator<Item = St>,
21199 St: AsRef<str>,
21200 {
21201 self._scopes
21202 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21203 self
21204 }
21205
21206 /// Removes all scopes, and no default scope will be used either.
21207 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21208 /// for details).
21209 pub fn clear_scopes(mut self) -> ProjectLocationSourceListCall<'a, C> {
21210 self._scopes.clear();
21211 self
21212 }
21213}
21214
21215/// Updates the parameters of a single Source.
21216///
21217/// A builder for the *locations.sources.patch* method supported by a *project* resource.
21218/// It is not used directly, but through a [`ProjectMethods`] instance.
21219///
21220/// # Example
21221///
21222/// Instantiate a resource method builder
21223///
21224/// ```test_harness,no_run
21225/// # extern crate hyper;
21226/// # extern crate hyper_rustls;
21227/// # extern crate google_vmmigration1 as vmmigration1;
21228/// use vmmigration1::api::Source;
21229/// # async fn dox() {
21230/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21231///
21232/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21233/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21234/// # secret,
21235/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21236/// # ).build().await.unwrap();
21237///
21238/// # let client = hyper_util::client::legacy::Client::builder(
21239/// # hyper_util::rt::TokioExecutor::new()
21240/// # )
21241/// # .build(
21242/// # hyper_rustls::HttpsConnectorBuilder::new()
21243/// # .with_native_roots()
21244/// # .unwrap()
21245/// # .https_or_http()
21246/// # .enable_http1()
21247/// # .build()
21248/// # );
21249/// # let mut hub = VMMigrationService::new(client, auth);
21250/// // As the method needs a request, you would usually fill it with the desired information
21251/// // into the respective structure. Some of the parts shown here might not be applicable !
21252/// // Values shown here are possibly random and not representative !
21253/// let mut req = Source::default();
21254///
21255/// // You can configure optional parameters by calling the respective setters at will, and
21256/// // execute the final call using `doit()`.
21257/// // Values shown here are possibly random and not representative !
21258/// let result = hub.projects().locations_sources_patch(req, "name")
21259/// .update_mask(FieldMask::new::<&str>(&[]))
21260/// .request_id("consetetur")
21261/// .doit().await;
21262/// # }
21263/// ```
21264pub struct ProjectLocationSourcePatchCall<'a, C>
21265where
21266 C: 'a,
21267{
21268 hub: &'a VMMigrationService<C>,
21269 _request: Source,
21270 _name: String,
21271 _update_mask: Option<common::FieldMask>,
21272 _request_id: Option<String>,
21273 _delegate: Option<&'a mut dyn common::Delegate>,
21274 _additional_params: HashMap<String, String>,
21275 _scopes: BTreeSet<String>,
21276}
21277
21278impl<'a, C> common::CallBuilder for ProjectLocationSourcePatchCall<'a, C> {}
21279
21280impl<'a, C> ProjectLocationSourcePatchCall<'a, C>
21281where
21282 C: common::Connector,
21283{
21284 /// Perform the operation you have build so far.
21285 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
21286 use std::borrow::Cow;
21287 use std::io::{Read, Seek};
21288
21289 use common::{url::Params, ToParts};
21290 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21291
21292 let mut dd = common::DefaultDelegate;
21293 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21294 dlg.begin(common::MethodInfo {
21295 id: "vmmigration.projects.locations.sources.patch",
21296 http_method: hyper::Method::PATCH,
21297 });
21298
21299 for &field in ["alt", "name", "updateMask", "requestId"].iter() {
21300 if self._additional_params.contains_key(field) {
21301 dlg.finished(false);
21302 return Err(common::Error::FieldClash(field));
21303 }
21304 }
21305
21306 let mut params = Params::with_capacity(6 + self._additional_params.len());
21307 params.push("name", self._name);
21308 if let Some(value) = self._update_mask.as_ref() {
21309 params.push("updateMask", value.to_string());
21310 }
21311 if let Some(value) = self._request_id.as_ref() {
21312 params.push("requestId", value);
21313 }
21314
21315 params.extend(self._additional_params.iter());
21316
21317 params.push("alt", "json");
21318 let mut url = self.hub._base_url.clone() + "v1/{+name}";
21319 if self._scopes.is_empty() {
21320 self._scopes
21321 .insert(Scope::CloudPlatform.as_ref().to_string());
21322 }
21323
21324 #[allow(clippy::single_element_loop)]
21325 for &(find_this, param_name) in [("{+name}", "name")].iter() {
21326 url = params.uri_replacement(url, param_name, find_this, true);
21327 }
21328 {
21329 let to_remove = ["name"];
21330 params.remove_params(&to_remove);
21331 }
21332
21333 let url = params.parse_with_url(&url);
21334
21335 let mut json_mime_type = mime::APPLICATION_JSON;
21336 let mut request_value_reader = {
21337 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21338 common::remove_json_null_values(&mut value);
21339 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21340 serde_json::to_writer(&mut dst, &value).unwrap();
21341 dst
21342 };
21343 let request_size = request_value_reader
21344 .seek(std::io::SeekFrom::End(0))
21345 .unwrap();
21346 request_value_reader
21347 .seek(std::io::SeekFrom::Start(0))
21348 .unwrap();
21349
21350 loop {
21351 let token = match self
21352 .hub
21353 .auth
21354 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21355 .await
21356 {
21357 Ok(token) => token,
21358 Err(e) => match dlg.token(e) {
21359 Ok(token) => token,
21360 Err(e) => {
21361 dlg.finished(false);
21362 return Err(common::Error::MissingToken(e));
21363 }
21364 },
21365 };
21366 request_value_reader
21367 .seek(std::io::SeekFrom::Start(0))
21368 .unwrap();
21369 let mut req_result = {
21370 let client = &self.hub.client;
21371 dlg.pre_request();
21372 let mut req_builder = hyper::Request::builder()
21373 .method(hyper::Method::PATCH)
21374 .uri(url.as_str())
21375 .header(USER_AGENT, self.hub._user_agent.clone());
21376
21377 if let Some(token) = token.as_ref() {
21378 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21379 }
21380
21381 let request = req_builder
21382 .header(CONTENT_TYPE, json_mime_type.to_string())
21383 .header(CONTENT_LENGTH, request_size as u64)
21384 .body(common::to_body(
21385 request_value_reader.get_ref().clone().into(),
21386 ));
21387
21388 client.request(request.unwrap()).await
21389 };
21390
21391 match req_result {
21392 Err(err) => {
21393 if let common::Retry::After(d) = dlg.http_error(&err) {
21394 sleep(d).await;
21395 continue;
21396 }
21397 dlg.finished(false);
21398 return Err(common::Error::HttpError(err));
21399 }
21400 Ok(res) => {
21401 let (mut parts, body) = res.into_parts();
21402 let mut body = common::Body::new(body);
21403 if !parts.status.is_success() {
21404 let bytes = common::to_bytes(body).await.unwrap_or_default();
21405 let error = serde_json::from_str(&common::to_string(&bytes));
21406 let response = common::to_response(parts, bytes.into());
21407
21408 if let common::Retry::After(d) =
21409 dlg.http_failure(&response, error.as_ref().ok())
21410 {
21411 sleep(d).await;
21412 continue;
21413 }
21414
21415 dlg.finished(false);
21416
21417 return Err(match error {
21418 Ok(value) => common::Error::BadRequest(value),
21419 _ => common::Error::Failure(response),
21420 });
21421 }
21422 let response = {
21423 let bytes = common::to_bytes(body).await.unwrap_or_default();
21424 let encoded = common::to_string(&bytes);
21425 match serde_json::from_str(&encoded) {
21426 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21427 Err(error) => {
21428 dlg.response_json_decode_error(&encoded, &error);
21429 return Err(common::Error::JsonDecodeError(
21430 encoded.to_string(),
21431 error,
21432 ));
21433 }
21434 }
21435 };
21436
21437 dlg.finished(true);
21438 return Ok(response);
21439 }
21440 }
21441 }
21442 }
21443
21444 ///
21445 /// Sets the *request* property to the given value.
21446 ///
21447 /// Even though the property as already been set when instantiating this call,
21448 /// we provide this method for API completeness.
21449 pub fn request(mut self, new_value: Source) -> ProjectLocationSourcePatchCall<'a, C> {
21450 self._request = new_value;
21451 self
21452 }
21453 /// Output only. The Source name.
21454 ///
21455 /// Sets the *name* path property to the given value.
21456 ///
21457 /// Even though the property as already been set when instantiating this call,
21458 /// we provide this method for API completeness.
21459 pub fn name(mut self, new_value: &str) -> ProjectLocationSourcePatchCall<'a, C> {
21460 self._name = new_value.to_string();
21461 self
21462 }
21463 /// Field mask is used to specify the fields to be overwritten in the Source resource by the update. The fields specified in the update_mask are relative to the resource, not the full request. A field will be overwritten if it is in the mask. If the user does not provide a mask then all fields will be overwritten.
21464 ///
21465 /// Sets the *update mask* query property to the given value.
21466 pub fn update_mask(
21467 mut self,
21468 new_value: common::FieldMask,
21469 ) -> ProjectLocationSourcePatchCall<'a, C> {
21470 self._update_mask = Some(new_value);
21471 self
21472 }
21473 /// A request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes since the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
21474 ///
21475 /// Sets the *request id* query property to the given value.
21476 pub fn request_id(mut self, new_value: &str) -> ProjectLocationSourcePatchCall<'a, C> {
21477 self._request_id = Some(new_value.to_string());
21478 self
21479 }
21480 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21481 /// while executing the actual API request.
21482 ///
21483 /// ````text
21484 /// It should be used to handle progress information, and to implement a certain level of resilience.
21485 /// ````
21486 ///
21487 /// Sets the *delegate* property to the given value.
21488 pub fn delegate(
21489 mut self,
21490 new_value: &'a mut dyn common::Delegate,
21491 ) -> ProjectLocationSourcePatchCall<'a, C> {
21492 self._delegate = Some(new_value);
21493 self
21494 }
21495
21496 /// Set any additional parameter of the query string used in the request.
21497 /// It should be used to set parameters which are not yet available through their own
21498 /// setters.
21499 ///
21500 /// Please note that this method must not be used to set any of the known parameters
21501 /// which have their own setter method. If done anyway, the request will fail.
21502 ///
21503 /// # Additional Parameters
21504 ///
21505 /// * *$.xgafv* (query-string) - V1 error format.
21506 /// * *access_token* (query-string) - OAuth access token.
21507 /// * *alt* (query-string) - Data format for response.
21508 /// * *callback* (query-string) - JSONP
21509 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21510 /// * *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.
21511 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21512 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21513 /// * *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.
21514 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21515 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21516 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSourcePatchCall<'a, C>
21517 where
21518 T: AsRef<str>,
21519 {
21520 self._additional_params
21521 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21522 self
21523 }
21524
21525 /// Identifies the authorization scope for the method you are building.
21526 ///
21527 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21528 /// [`Scope::CloudPlatform`].
21529 ///
21530 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21531 /// tokens for more than one scope.
21532 ///
21533 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21534 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21535 /// sufficient, a read-write scope will do as well.
21536 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourcePatchCall<'a, C>
21537 where
21538 St: AsRef<str>,
21539 {
21540 self._scopes.insert(String::from(scope.as_ref()));
21541 self
21542 }
21543 /// Identifies the authorization scope(s) for the method you are building.
21544 ///
21545 /// See [`Self::add_scope()`] for details.
21546 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSourcePatchCall<'a, C>
21547 where
21548 I: IntoIterator<Item = St>,
21549 St: AsRef<str>,
21550 {
21551 self._scopes
21552 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21553 self
21554 }
21555
21556 /// Removes all scopes, and no default scope will be used either.
21557 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21558 /// for details).
21559 pub fn clear_scopes(mut self) -> ProjectLocationSourcePatchCall<'a, C> {
21560 self._scopes.clear();
21561 self
21562 }
21563}
21564
21565/// Creates a new TargetProject in a given project. NOTE: TargetProject is a global resource; hence the only supported value for location is `global`.
21566///
21567/// A builder for the *locations.targetProjects.create* method supported by a *project* resource.
21568/// It is not used directly, but through a [`ProjectMethods`] instance.
21569///
21570/// # Example
21571///
21572/// Instantiate a resource method builder
21573///
21574/// ```test_harness,no_run
21575/// # extern crate hyper;
21576/// # extern crate hyper_rustls;
21577/// # extern crate google_vmmigration1 as vmmigration1;
21578/// use vmmigration1::api::TargetProject;
21579/// # async fn dox() {
21580/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21581///
21582/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21583/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21584/// # secret,
21585/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21586/// # ).build().await.unwrap();
21587///
21588/// # let client = hyper_util::client::legacy::Client::builder(
21589/// # hyper_util::rt::TokioExecutor::new()
21590/// # )
21591/// # .build(
21592/// # hyper_rustls::HttpsConnectorBuilder::new()
21593/// # .with_native_roots()
21594/// # .unwrap()
21595/// # .https_or_http()
21596/// # .enable_http1()
21597/// # .build()
21598/// # );
21599/// # let mut hub = VMMigrationService::new(client, auth);
21600/// // As the method needs a request, you would usually fill it with the desired information
21601/// // into the respective structure. Some of the parts shown here might not be applicable !
21602/// // Values shown here are possibly random and not representative !
21603/// let mut req = TargetProject::default();
21604///
21605/// // You can configure optional parameters by calling the respective setters at will, and
21606/// // execute the final call using `doit()`.
21607/// // Values shown here are possibly random and not representative !
21608/// let result = hub.projects().locations_target_projects_create(req, "parent")
21609/// .target_project_id("Stet")
21610/// .request_id("est")
21611/// .doit().await;
21612/// # }
21613/// ```
21614pub struct ProjectLocationTargetProjectCreateCall<'a, C>
21615where
21616 C: 'a,
21617{
21618 hub: &'a VMMigrationService<C>,
21619 _request: TargetProject,
21620 _parent: String,
21621 _target_project_id: Option<String>,
21622 _request_id: Option<String>,
21623 _delegate: Option<&'a mut dyn common::Delegate>,
21624 _additional_params: HashMap<String, String>,
21625 _scopes: BTreeSet<String>,
21626}
21627
21628impl<'a, C> common::CallBuilder for ProjectLocationTargetProjectCreateCall<'a, C> {}
21629
21630impl<'a, C> ProjectLocationTargetProjectCreateCall<'a, C>
21631where
21632 C: common::Connector,
21633{
21634 /// Perform the operation you have build so far.
21635 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
21636 use std::borrow::Cow;
21637 use std::io::{Read, Seek};
21638
21639 use common::{url::Params, ToParts};
21640 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21641
21642 let mut dd = common::DefaultDelegate;
21643 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21644 dlg.begin(common::MethodInfo {
21645 id: "vmmigration.projects.locations.targetProjects.create",
21646 http_method: hyper::Method::POST,
21647 });
21648
21649 for &field in ["alt", "parent", "targetProjectId", "requestId"].iter() {
21650 if self._additional_params.contains_key(field) {
21651 dlg.finished(false);
21652 return Err(common::Error::FieldClash(field));
21653 }
21654 }
21655
21656 let mut params = Params::with_capacity(6 + self._additional_params.len());
21657 params.push("parent", self._parent);
21658 if let Some(value) = self._target_project_id.as_ref() {
21659 params.push("targetProjectId", value);
21660 }
21661 if let Some(value) = self._request_id.as_ref() {
21662 params.push("requestId", value);
21663 }
21664
21665 params.extend(self._additional_params.iter());
21666
21667 params.push("alt", "json");
21668 let mut url = self.hub._base_url.clone() + "v1/{+parent}/targetProjects";
21669 if self._scopes.is_empty() {
21670 self._scopes
21671 .insert(Scope::CloudPlatform.as_ref().to_string());
21672 }
21673
21674 #[allow(clippy::single_element_loop)]
21675 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
21676 url = params.uri_replacement(url, param_name, find_this, true);
21677 }
21678 {
21679 let to_remove = ["parent"];
21680 params.remove_params(&to_remove);
21681 }
21682
21683 let url = params.parse_with_url(&url);
21684
21685 let mut json_mime_type = mime::APPLICATION_JSON;
21686 let mut request_value_reader = {
21687 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21688 common::remove_json_null_values(&mut value);
21689 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21690 serde_json::to_writer(&mut dst, &value).unwrap();
21691 dst
21692 };
21693 let request_size = request_value_reader
21694 .seek(std::io::SeekFrom::End(0))
21695 .unwrap();
21696 request_value_reader
21697 .seek(std::io::SeekFrom::Start(0))
21698 .unwrap();
21699
21700 loop {
21701 let token = match self
21702 .hub
21703 .auth
21704 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21705 .await
21706 {
21707 Ok(token) => token,
21708 Err(e) => match dlg.token(e) {
21709 Ok(token) => token,
21710 Err(e) => {
21711 dlg.finished(false);
21712 return Err(common::Error::MissingToken(e));
21713 }
21714 },
21715 };
21716 request_value_reader
21717 .seek(std::io::SeekFrom::Start(0))
21718 .unwrap();
21719 let mut req_result = {
21720 let client = &self.hub.client;
21721 dlg.pre_request();
21722 let mut req_builder = hyper::Request::builder()
21723 .method(hyper::Method::POST)
21724 .uri(url.as_str())
21725 .header(USER_AGENT, self.hub._user_agent.clone());
21726
21727 if let Some(token) = token.as_ref() {
21728 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21729 }
21730
21731 let request = req_builder
21732 .header(CONTENT_TYPE, json_mime_type.to_string())
21733 .header(CONTENT_LENGTH, request_size as u64)
21734 .body(common::to_body(
21735 request_value_reader.get_ref().clone().into(),
21736 ));
21737
21738 client.request(request.unwrap()).await
21739 };
21740
21741 match req_result {
21742 Err(err) => {
21743 if let common::Retry::After(d) = dlg.http_error(&err) {
21744 sleep(d).await;
21745 continue;
21746 }
21747 dlg.finished(false);
21748 return Err(common::Error::HttpError(err));
21749 }
21750 Ok(res) => {
21751 let (mut parts, body) = res.into_parts();
21752 let mut body = common::Body::new(body);
21753 if !parts.status.is_success() {
21754 let bytes = common::to_bytes(body).await.unwrap_or_default();
21755 let error = serde_json::from_str(&common::to_string(&bytes));
21756 let response = common::to_response(parts, bytes.into());
21757
21758 if let common::Retry::After(d) =
21759 dlg.http_failure(&response, error.as_ref().ok())
21760 {
21761 sleep(d).await;
21762 continue;
21763 }
21764
21765 dlg.finished(false);
21766
21767 return Err(match error {
21768 Ok(value) => common::Error::BadRequest(value),
21769 _ => common::Error::Failure(response),
21770 });
21771 }
21772 let response = {
21773 let bytes = common::to_bytes(body).await.unwrap_or_default();
21774 let encoded = common::to_string(&bytes);
21775 match serde_json::from_str(&encoded) {
21776 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21777 Err(error) => {
21778 dlg.response_json_decode_error(&encoded, &error);
21779 return Err(common::Error::JsonDecodeError(
21780 encoded.to_string(),
21781 error,
21782 ));
21783 }
21784 }
21785 };
21786
21787 dlg.finished(true);
21788 return Ok(response);
21789 }
21790 }
21791 }
21792 }
21793
21794 ///
21795 /// Sets the *request* property to the given value.
21796 ///
21797 /// Even though the property as already been set when instantiating this call,
21798 /// we provide this method for API completeness.
21799 pub fn request(
21800 mut self,
21801 new_value: TargetProject,
21802 ) -> ProjectLocationTargetProjectCreateCall<'a, C> {
21803 self._request = new_value;
21804 self
21805 }
21806 /// Required. The TargetProject's parent.
21807 ///
21808 /// Sets the *parent* path property to the given value.
21809 ///
21810 /// Even though the property as already been set when instantiating this call,
21811 /// we provide this method for API completeness.
21812 pub fn parent(mut self, new_value: &str) -> ProjectLocationTargetProjectCreateCall<'a, C> {
21813 self._parent = new_value.to_string();
21814 self
21815 }
21816 /// Required. The target_project identifier.
21817 ///
21818 /// Sets the *target project id* query property to the given value.
21819 pub fn target_project_id(
21820 mut self,
21821 new_value: &str,
21822 ) -> ProjectLocationTargetProjectCreateCall<'a, C> {
21823 self._target_project_id = Some(new_value.to_string());
21824 self
21825 }
21826 /// A request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes since the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
21827 ///
21828 /// Sets the *request id* query property to the given value.
21829 pub fn request_id(mut self, new_value: &str) -> ProjectLocationTargetProjectCreateCall<'a, C> {
21830 self._request_id = Some(new_value.to_string());
21831 self
21832 }
21833 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21834 /// while executing the actual API request.
21835 ///
21836 /// ````text
21837 /// It should be used to handle progress information, and to implement a certain level of resilience.
21838 /// ````
21839 ///
21840 /// Sets the *delegate* property to the given value.
21841 pub fn delegate(
21842 mut self,
21843 new_value: &'a mut dyn common::Delegate,
21844 ) -> ProjectLocationTargetProjectCreateCall<'a, C> {
21845 self._delegate = Some(new_value);
21846 self
21847 }
21848
21849 /// Set any additional parameter of the query string used in the request.
21850 /// It should be used to set parameters which are not yet available through their own
21851 /// setters.
21852 ///
21853 /// Please note that this method must not be used to set any of the known parameters
21854 /// which have their own setter method. If done anyway, the request will fail.
21855 ///
21856 /// # Additional Parameters
21857 ///
21858 /// * *$.xgafv* (query-string) - V1 error format.
21859 /// * *access_token* (query-string) - OAuth access token.
21860 /// * *alt* (query-string) - Data format for response.
21861 /// * *callback* (query-string) - JSONP
21862 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21863 /// * *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.
21864 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21865 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21866 /// * *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.
21867 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21868 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21869 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTargetProjectCreateCall<'a, C>
21870 where
21871 T: AsRef<str>,
21872 {
21873 self._additional_params
21874 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21875 self
21876 }
21877
21878 /// Identifies the authorization scope for the method you are building.
21879 ///
21880 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21881 /// [`Scope::CloudPlatform`].
21882 ///
21883 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21884 /// tokens for more than one scope.
21885 ///
21886 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21887 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21888 /// sufficient, a read-write scope will do as well.
21889 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTargetProjectCreateCall<'a, C>
21890 where
21891 St: AsRef<str>,
21892 {
21893 self._scopes.insert(String::from(scope.as_ref()));
21894 self
21895 }
21896 /// Identifies the authorization scope(s) for the method you are building.
21897 ///
21898 /// See [`Self::add_scope()`] for details.
21899 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTargetProjectCreateCall<'a, C>
21900 where
21901 I: IntoIterator<Item = St>,
21902 St: AsRef<str>,
21903 {
21904 self._scopes
21905 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21906 self
21907 }
21908
21909 /// Removes all scopes, and no default scope will be used either.
21910 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21911 /// for details).
21912 pub fn clear_scopes(mut self) -> ProjectLocationTargetProjectCreateCall<'a, C> {
21913 self._scopes.clear();
21914 self
21915 }
21916}
21917
21918/// Deletes a single TargetProject. NOTE: TargetProject is a global resource; hence the only supported value for location is `global`.
21919///
21920/// A builder for the *locations.targetProjects.delete* method supported by a *project* resource.
21921/// It is not used directly, but through a [`ProjectMethods`] instance.
21922///
21923/// # Example
21924///
21925/// Instantiate a resource method builder
21926///
21927/// ```test_harness,no_run
21928/// # extern crate hyper;
21929/// # extern crate hyper_rustls;
21930/// # extern crate google_vmmigration1 as vmmigration1;
21931/// # async fn dox() {
21932/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21933///
21934/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21935/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21936/// # secret,
21937/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21938/// # ).build().await.unwrap();
21939///
21940/// # let client = hyper_util::client::legacy::Client::builder(
21941/// # hyper_util::rt::TokioExecutor::new()
21942/// # )
21943/// # .build(
21944/// # hyper_rustls::HttpsConnectorBuilder::new()
21945/// # .with_native_roots()
21946/// # .unwrap()
21947/// # .https_or_http()
21948/// # .enable_http1()
21949/// # .build()
21950/// # );
21951/// # let mut hub = VMMigrationService::new(client, auth);
21952/// // You can configure optional parameters by calling the respective setters at will, and
21953/// // execute the final call using `doit()`.
21954/// // Values shown here are possibly random and not representative !
21955/// let result = hub.projects().locations_target_projects_delete("name")
21956/// .request_id("elitr")
21957/// .doit().await;
21958/// # }
21959/// ```
21960pub struct ProjectLocationTargetProjectDeleteCall<'a, C>
21961where
21962 C: 'a,
21963{
21964 hub: &'a VMMigrationService<C>,
21965 _name: String,
21966 _request_id: Option<String>,
21967 _delegate: Option<&'a mut dyn common::Delegate>,
21968 _additional_params: HashMap<String, String>,
21969 _scopes: BTreeSet<String>,
21970}
21971
21972impl<'a, C> common::CallBuilder for ProjectLocationTargetProjectDeleteCall<'a, C> {}
21973
21974impl<'a, C> ProjectLocationTargetProjectDeleteCall<'a, C>
21975where
21976 C: common::Connector,
21977{
21978 /// Perform the operation you have build so far.
21979 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
21980 use std::borrow::Cow;
21981 use std::io::{Read, Seek};
21982
21983 use common::{url::Params, ToParts};
21984 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21985
21986 let mut dd = common::DefaultDelegate;
21987 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21988 dlg.begin(common::MethodInfo {
21989 id: "vmmigration.projects.locations.targetProjects.delete",
21990 http_method: hyper::Method::DELETE,
21991 });
21992
21993 for &field in ["alt", "name", "requestId"].iter() {
21994 if self._additional_params.contains_key(field) {
21995 dlg.finished(false);
21996 return Err(common::Error::FieldClash(field));
21997 }
21998 }
21999
22000 let mut params = Params::with_capacity(4 + self._additional_params.len());
22001 params.push("name", self._name);
22002 if let Some(value) = self._request_id.as_ref() {
22003 params.push("requestId", value);
22004 }
22005
22006 params.extend(self._additional_params.iter());
22007
22008 params.push("alt", "json");
22009 let mut url = self.hub._base_url.clone() + "v1/{+name}";
22010 if self._scopes.is_empty() {
22011 self._scopes
22012 .insert(Scope::CloudPlatform.as_ref().to_string());
22013 }
22014
22015 #[allow(clippy::single_element_loop)]
22016 for &(find_this, param_name) in [("{+name}", "name")].iter() {
22017 url = params.uri_replacement(url, param_name, find_this, true);
22018 }
22019 {
22020 let to_remove = ["name"];
22021 params.remove_params(&to_remove);
22022 }
22023
22024 let url = params.parse_with_url(&url);
22025
22026 loop {
22027 let token = match self
22028 .hub
22029 .auth
22030 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22031 .await
22032 {
22033 Ok(token) => token,
22034 Err(e) => match dlg.token(e) {
22035 Ok(token) => token,
22036 Err(e) => {
22037 dlg.finished(false);
22038 return Err(common::Error::MissingToken(e));
22039 }
22040 },
22041 };
22042 let mut req_result = {
22043 let client = &self.hub.client;
22044 dlg.pre_request();
22045 let mut req_builder = hyper::Request::builder()
22046 .method(hyper::Method::DELETE)
22047 .uri(url.as_str())
22048 .header(USER_AGENT, self.hub._user_agent.clone());
22049
22050 if let Some(token) = token.as_ref() {
22051 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22052 }
22053
22054 let request = req_builder
22055 .header(CONTENT_LENGTH, 0_u64)
22056 .body(common::to_body::<String>(None));
22057
22058 client.request(request.unwrap()).await
22059 };
22060
22061 match req_result {
22062 Err(err) => {
22063 if let common::Retry::After(d) = dlg.http_error(&err) {
22064 sleep(d).await;
22065 continue;
22066 }
22067 dlg.finished(false);
22068 return Err(common::Error::HttpError(err));
22069 }
22070 Ok(res) => {
22071 let (mut parts, body) = res.into_parts();
22072 let mut body = common::Body::new(body);
22073 if !parts.status.is_success() {
22074 let bytes = common::to_bytes(body).await.unwrap_or_default();
22075 let error = serde_json::from_str(&common::to_string(&bytes));
22076 let response = common::to_response(parts, bytes.into());
22077
22078 if let common::Retry::After(d) =
22079 dlg.http_failure(&response, error.as_ref().ok())
22080 {
22081 sleep(d).await;
22082 continue;
22083 }
22084
22085 dlg.finished(false);
22086
22087 return Err(match error {
22088 Ok(value) => common::Error::BadRequest(value),
22089 _ => common::Error::Failure(response),
22090 });
22091 }
22092 let response = {
22093 let bytes = common::to_bytes(body).await.unwrap_or_default();
22094 let encoded = common::to_string(&bytes);
22095 match serde_json::from_str(&encoded) {
22096 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22097 Err(error) => {
22098 dlg.response_json_decode_error(&encoded, &error);
22099 return Err(common::Error::JsonDecodeError(
22100 encoded.to_string(),
22101 error,
22102 ));
22103 }
22104 }
22105 };
22106
22107 dlg.finished(true);
22108 return Ok(response);
22109 }
22110 }
22111 }
22112 }
22113
22114 /// Required. The TargetProject name.
22115 ///
22116 /// Sets the *name* path property to the given value.
22117 ///
22118 /// Even though the property as already been set when instantiating this call,
22119 /// we provide this method for API completeness.
22120 pub fn name(mut self, new_value: &str) -> ProjectLocationTargetProjectDeleteCall<'a, C> {
22121 self._name = new_value.to_string();
22122 self
22123 }
22124 /// Optional. A request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes after the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
22125 ///
22126 /// Sets the *request id* query property to the given value.
22127 pub fn request_id(mut self, new_value: &str) -> ProjectLocationTargetProjectDeleteCall<'a, C> {
22128 self._request_id = Some(new_value.to_string());
22129 self
22130 }
22131 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22132 /// while executing the actual API request.
22133 ///
22134 /// ````text
22135 /// It should be used to handle progress information, and to implement a certain level of resilience.
22136 /// ````
22137 ///
22138 /// Sets the *delegate* property to the given value.
22139 pub fn delegate(
22140 mut self,
22141 new_value: &'a mut dyn common::Delegate,
22142 ) -> ProjectLocationTargetProjectDeleteCall<'a, C> {
22143 self._delegate = Some(new_value);
22144 self
22145 }
22146
22147 /// Set any additional parameter of the query string used in the request.
22148 /// It should be used to set parameters which are not yet available through their own
22149 /// setters.
22150 ///
22151 /// Please note that this method must not be used to set any of the known parameters
22152 /// which have their own setter method. If done anyway, the request will fail.
22153 ///
22154 /// # Additional Parameters
22155 ///
22156 /// * *$.xgafv* (query-string) - V1 error format.
22157 /// * *access_token* (query-string) - OAuth access token.
22158 /// * *alt* (query-string) - Data format for response.
22159 /// * *callback* (query-string) - JSONP
22160 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22161 /// * *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.
22162 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22163 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22164 /// * *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.
22165 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22166 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22167 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTargetProjectDeleteCall<'a, C>
22168 where
22169 T: AsRef<str>,
22170 {
22171 self._additional_params
22172 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22173 self
22174 }
22175
22176 /// Identifies the authorization scope for the method you are building.
22177 ///
22178 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22179 /// [`Scope::CloudPlatform`].
22180 ///
22181 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22182 /// tokens for more than one scope.
22183 ///
22184 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22185 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22186 /// sufficient, a read-write scope will do as well.
22187 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTargetProjectDeleteCall<'a, C>
22188 where
22189 St: AsRef<str>,
22190 {
22191 self._scopes.insert(String::from(scope.as_ref()));
22192 self
22193 }
22194 /// Identifies the authorization scope(s) for the method you are building.
22195 ///
22196 /// See [`Self::add_scope()`] for details.
22197 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTargetProjectDeleteCall<'a, C>
22198 where
22199 I: IntoIterator<Item = St>,
22200 St: AsRef<str>,
22201 {
22202 self._scopes
22203 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22204 self
22205 }
22206
22207 /// Removes all scopes, and no default scope will be used either.
22208 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22209 /// for details).
22210 pub fn clear_scopes(mut self) -> ProjectLocationTargetProjectDeleteCall<'a, C> {
22211 self._scopes.clear();
22212 self
22213 }
22214}
22215
22216/// Gets details of a single TargetProject. NOTE: TargetProject is a global resource; hence the only supported value for location is `global`.
22217///
22218/// A builder for the *locations.targetProjects.get* method supported by a *project* resource.
22219/// It is not used directly, but through a [`ProjectMethods`] instance.
22220///
22221/// # Example
22222///
22223/// Instantiate a resource method builder
22224///
22225/// ```test_harness,no_run
22226/// # extern crate hyper;
22227/// # extern crate hyper_rustls;
22228/// # extern crate google_vmmigration1 as vmmigration1;
22229/// # async fn dox() {
22230/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22231///
22232/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22233/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22234/// # secret,
22235/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22236/// # ).build().await.unwrap();
22237///
22238/// # let client = hyper_util::client::legacy::Client::builder(
22239/// # hyper_util::rt::TokioExecutor::new()
22240/// # )
22241/// # .build(
22242/// # hyper_rustls::HttpsConnectorBuilder::new()
22243/// # .with_native_roots()
22244/// # .unwrap()
22245/// # .https_or_http()
22246/// # .enable_http1()
22247/// # .build()
22248/// # );
22249/// # let mut hub = VMMigrationService::new(client, auth);
22250/// // You can configure optional parameters by calling the respective setters at will, and
22251/// // execute the final call using `doit()`.
22252/// // Values shown here are possibly random and not representative !
22253/// let result = hub.projects().locations_target_projects_get("name")
22254/// .doit().await;
22255/// # }
22256/// ```
22257pub struct ProjectLocationTargetProjectGetCall<'a, C>
22258where
22259 C: 'a,
22260{
22261 hub: &'a VMMigrationService<C>,
22262 _name: String,
22263 _delegate: Option<&'a mut dyn common::Delegate>,
22264 _additional_params: HashMap<String, String>,
22265 _scopes: BTreeSet<String>,
22266}
22267
22268impl<'a, C> common::CallBuilder for ProjectLocationTargetProjectGetCall<'a, C> {}
22269
22270impl<'a, C> ProjectLocationTargetProjectGetCall<'a, C>
22271where
22272 C: common::Connector,
22273{
22274 /// Perform the operation you have build so far.
22275 pub async fn doit(mut self) -> common::Result<(common::Response, TargetProject)> {
22276 use std::borrow::Cow;
22277 use std::io::{Read, Seek};
22278
22279 use common::{url::Params, ToParts};
22280 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22281
22282 let mut dd = common::DefaultDelegate;
22283 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22284 dlg.begin(common::MethodInfo {
22285 id: "vmmigration.projects.locations.targetProjects.get",
22286 http_method: hyper::Method::GET,
22287 });
22288
22289 for &field in ["alt", "name"].iter() {
22290 if self._additional_params.contains_key(field) {
22291 dlg.finished(false);
22292 return Err(common::Error::FieldClash(field));
22293 }
22294 }
22295
22296 let mut params = Params::with_capacity(3 + self._additional_params.len());
22297 params.push("name", self._name);
22298
22299 params.extend(self._additional_params.iter());
22300
22301 params.push("alt", "json");
22302 let mut url = self.hub._base_url.clone() + "v1/{+name}";
22303 if self._scopes.is_empty() {
22304 self._scopes
22305 .insert(Scope::CloudPlatform.as_ref().to_string());
22306 }
22307
22308 #[allow(clippy::single_element_loop)]
22309 for &(find_this, param_name) in [("{+name}", "name")].iter() {
22310 url = params.uri_replacement(url, param_name, find_this, true);
22311 }
22312 {
22313 let to_remove = ["name"];
22314 params.remove_params(&to_remove);
22315 }
22316
22317 let url = params.parse_with_url(&url);
22318
22319 loop {
22320 let token = match self
22321 .hub
22322 .auth
22323 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22324 .await
22325 {
22326 Ok(token) => token,
22327 Err(e) => match dlg.token(e) {
22328 Ok(token) => token,
22329 Err(e) => {
22330 dlg.finished(false);
22331 return Err(common::Error::MissingToken(e));
22332 }
22333 },
22334 };
22335 let mut req_result = {
22336 let client = &self.hub.client;
22337 dlg.pre_request();
22338 let mut req_builder = hyper::Request::builder()
22339 .method(hyper::Method::GET)
22340 .uri(url.as_str())
22341 .header(USER_AGENT, self.hub._user_agent.clone());
22342
22343 if let Some(token) = token.as_ref() {
22344 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22345 }
22346
22347 let request = req_builder
22348 .header(CONTENT_LENGTH, 0_u64)
22349 .body(common::to_body::<String>(None));
22350
22351 client.request(request.unwrap()).await
22352 };
22353
22354 match req_result {
22355 Err(err) => {
22356 if let common::Retry::After(d) = dlg.http_error(&err) {
22357 sleep(d).await;
22358 continue;
22359 }
22360 dlg.finished(false);
22361 return Err(common::Error::HttpError(err));
22362 }
22363 Ok(res) => {
22364 let (mut parts, body) = res.into_parts();
22365 let mut body = common::Body::new(body);
22366 if !parts.status.is_success() {
22367 let bytes = common::to_bytes(body).await.unwrap_or_default();
22368 let error = serde_json::from_str(&common::to_string(&bytes));
22369 let response = common::to_response(parts, bytes.into());
22370
22371 if let common::Retry::After(d) =
22372 dlg.http_failure(&response, error.as_ref().ok())
22373 {
22374 sleep(d).await;
22375 continue;
22376 }
22377
22378 dlg.finished(false);
22379
22380 return Err(match error {
22381 Ok(value) => common::Error::BadRequest(value),
22382 _ => common::Error::Failure(response),
22383 });
22384 }
22385 let response = {
22386 let bytes = common::to_bytes(body).await.unwrap_or_default();
22387 let encoded = common::to_string(&bytes);
22388 match serde_json::from_str(&encoded) {
22389 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22390 Err(error) => {
22391 dlg.response_json_decode_error(&encoded, &error);
22392 return Err(common::Error::JsonDecodeError(
22393 encoded.to_string(),
22394 error,
22395 ));
22396 }
22397 }
22398 };
22399
22400 dlg.finished(true);
22401 return Ok(response);
22402 }
22403 }
22404 }
22405 }
22406
22407 /// Required. The TargetProject name.
22408 ///
22409 /// Sets the *name* path property to the given value.
22410 ///
22411 /// Even though the property as already been set when instantiating this call,
22412 /// we provide this method for API completeness.
22413 pub fn name(mut self, new_value: &str) -> ProjectLocationTargetProjectGetCall<'a, C> {
22414 self._name = new_value.to_string();
22415 self
22416 }
22417 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22418 /// while executing the actual API request.
22419 ///
22420 /// ````text
22421 /// It should be used to handle progress information, and to implement a certain level of resilience.
22422 /// ````
22423 ///
22424 /// Sets the *delegate* property to the given value.
22425 pub fn delegate(
22426 mut self,
22427 new_value: &'a mut dyn common::Delegate,
22428 ) -> ProjectLocationTargetProjectGetCall<'a, C> {
22429 self._delegate = Some(new_value);
22430 self
22431 }
22432
22433 /// Set any additional parameter of the query string used in the request.
22434 /// It should be used to set parameters which are not yet available through their own
22435 /// setters.
22436 ///
22437 /// Please note that this method must not be used to set any of the known parameters
22438 /// which have their own setter method. If done anyway, the request will fail.
22439 ///
22440 /// # Additional Parameters
22441 ///
22442 /// * *$.xgafv* (query-string) - V1 error format.
22443 /// * *access_token* (query-string) - OAuth access token.
22444 /// * *alt* (query-string) - Data format for response.
22445 /// * *callback* (query-string) - JSONP
22446 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22447 /// * *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.
22448 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22449 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22450 /// * *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.
22451 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22452 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22453 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTargetProjectGetCall<'a, C>
22454 where
22455 T: AsRef<str>,
22456 {
22457 self._additional_params
22458 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22459 self
22460 }
22461
22462 /// Identifies the authorization scope for the method you are building.
22463 ///
22464 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22465 /// [`Scope::CloudPlatform`].
22466 ///
22467 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22468 /// tokens for more than one scope.
22469 ///
22470 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22471 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22472 /// sufficient, a read-write scope will do as well.
22473 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTargetProjectGetCall<'a, C>
22474 where
22475 St: AsRef<str>,
22476 {
22477 self._scopes.insert(String::from(scope.as_ref()));
22478 self
22479 }
22480 /// Identifies the authorization scope(s) for the method you are building.
22481 ///
22482 /// See [`Self::add_scope()`] for details.
22483 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTargetProjectGetCall<'a, C>
22484 where
22485 I: IntoIterator<Item = St>,
22486 St: AsRef<str>,
22487 {
22488 self._scopes
22489 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22490 self
22491 }
22492
22493 /// Removes all scopes, and no default scope will be used either.
22494 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22495 /// for details).
22496 pub fn clear_scopes(mut self) -> ProjectLocationTargetProjectGetCall<'a, C> {
22497 self._scopes.clear();
22498 self
22499 }
22500}
22501
22502/// Lists TargetProjects in a given project. NOTE: TargetProject is a global resource; hence the only supported value for location is `global`.
22503///
22504/// A builder for the *locations.targetProjects.list* method supported by a *project* resource.
22505/// It is not used directly, but through a [`ProjectMethods`] instance.
22506///
22507/// # Example
22508///
22509/// Instantiate a resource method builder
22510///
22511/// ```test_harness,no_run
22512/// # extern crate hyper;
22513/// # extern crate hyper_rustls;
22514/// # extern crate google_vmmigration1 as vmmigration1;
22515/// # async fn dox() {
22516/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22517///
22518/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22519/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22520/// # secret,
22521/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22522/// # ).build().await.unwrap();
22523///
22524/// # let client = hyper_util::client::legacy::Client::builder(
22525/// # hyper_util::rt::TokioExecutor::new()
22526/// # )
22527/// # .build(
22528/// # hyper_rustls::HttpsConnectorBuilder::new()
22529/// # .with_native_roots()
22530/// # .unwrap()
22531/// # .https_or_http()
22532/// # .enable_http1()
22533/// # .build()
22534/// # );
22535/// # let mut hub = VMMigrationService::new(client, auth);
22536/// // You can configure optional parameters by calling the respective setters at will, and
22537/// // execute the final call using `doit()`.
22538/// // Values shown here are possibly random and not representative !
22539/// let result = hub.projects().locations_target_projects_list("parent")
22540/// .page_token("est")
22541/// .page_size(-53)
22542/// .order_by("sed")
22543/// .filter("eos")
22544/// .doit().await;
22545/// # }
22546/// ```
22547pub struct ProjectLocationTargetProjectListCall<'a, C>
22548where
22549 C: 'a,
22550{
22551 hub: &'a VMMigrationService<C>,
22552 _parent: String,
22553 _page_token: Option<String>,
22554 _page_size: Option<i32>,
22555 _order_by: Option<String>,
22556 _filter: Option<String>,
22557 _delegate: Option<&'a mut dyn common::Delegate>,
22558 _additional_params: HashMap<String, String>,
22559 _scopes: BTreeSet<String>,
22560}
22561
22562impl<'a, C> common::CallBuilder for ProjectLocationTargetProjectListCall<'a, C> {}
22563
22564impl<'a, C> ProjectLocationTargetProjectListCall<'a, C>
22565where
22566 C: common::Connector,
22567{
22568 /// Perform the operation you have build so far.
22569 pub async fn doit(mut self) -> common::Result<(common::Response, ListTargetProjectsResponse)> {
22570 use std::borrow::Cow;
22571 use std::io::{Read, Seek};
22572
22573 use common::{url::Params, ToParts};
22574 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22575
22576 let mut dd = common::DefaultDelegate;
22577 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22578 dlg.begin(common::MethodInfo {
22579 id: "vmmigration.projects.locations.targetProjects.list",
22580 http_method: hyper::Method::GET,
22581 });
22582
22583 for &field in [
22584 "alt",
22585 "parent",
22586 "pageToken",
22587 "pageSize",
22588 "orderBy",
22589 "filter",
22590 ]
22591 .iter()
22592 {
22593 if self._additional_params.contains_key(field) {
22594 dlg.finished(false);
22595 return Err(common::Error::FieldClash(field));
22596 }
22597 }
22598
22599 let mut params = Params::with_capacity(7 + self._additional_params.len());
22600 params.push("parent", self._parent);
22601 if let Some(value) = self._page_token.as_ref() {
22602 params.push("pageToken", value);
22603 }
22604 if let Some(value) = self._page_size.as_ref() {
22605 params.push("pageSize", value.to_string());
22606 }
22607 if let Some(value) = self._order_by.as_ref() {
22608 params.push("orderBy", value);
22609 }
22610 if let Some(value) = self._filter.as_ref() {
22611 params.push("filter", value);
22612 }
22613
22614 params.extend(self._additional_params.iter());
22615
22616 params.push("alt", "json");
22617 let mut url = self.hub._base_url.clone() + "v1/{+parent}/targetProjects";
22618 if self._scopes.is_empty() {
22619 self._scopes
22620 .insert(Scope::CloudPlatform.as_ref().to_string());
22621 }
22622
22623 #[allow(clippy::single_element_loop)]
22624 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
22625 url = params.uri_replacement(url, param_name, find_this, true);
22626 }
22627 {
22628 let to_remove = ["parent"];
22629 params.remove_params(&to_remove);
22630 }
22631
22632 let url = params.parse_with_url(&url);
22633
22634 loop {
22635 let token = match self
22636 .hub
22637 .auth
22638 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22639 .await
22640 {
22641 Ok(token) => token,
22642 Err(e) => match dlg.token(e) {
22643 Ok(token) => token,
22644 Err(e) => {
22645 dlg.finished(false);
22646 return Err(common::Error::MissingToken(e));
22647 }
22648 },
22649 };
22650 let mut req_result = {
22651 let client = &self.hub.client;
22652 dlg.pre_request();
22653 let mut req_builder = hyper::Request::builder()
22654 .method(hyper::Method::GET)
22655 .uri(url.as_str())
22656 .header(USER_AGENT, self.hub._user_agent.clone());
22657
22658 if let Some(token) = token.as_ref() {
22659 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22660 }
22661
22662 let request = req_builder
22663 .header(CONTENT_LENGTH, 0_u64)
22664 .body(common::to_body::<String>(None));
22665
22666 client.request(request.unwrap()).await
22667 };
22668
22669 match req_result {
22670 Err(err) => {
22671 if let common::Retry::After(d) = dlg.http_error(&err) {
22672 sleep(d).await;
22673 continue;
22674 }
22675 dlg.finished(false);
22676 return Err(common::Error::HttpError(err));
22677 }
22678 Ok(res) => {
22679 let (mut parts, body) = res.into_parts();
22680 let mut body = common::Body::new(body);
22681 if !parts.status.is_success() {
22682 let bytes = common::to_bytes(body).await.unwrap_or_default();
22683 let error = serde_json::from_str(&common::to_string(&bytes));
22684 let response = common::to_response(parts, bytes.into());
22685
22686 if let common::Retry::After(d) =
22687 dlg.http_failure(&response, error.as_ref().ok())
22688 {
22689 sleep(d).await;
22690 continue;
22691 }
22692
22693 dlg.finished(false);
22694
22695 return Err(match error {
22696 Ok(value) => common::Error::BadRequest(value),
22697 _ => common::Error::Failure(response),
22698 });
22699 }
22700 let response = {
22701 let bytes = common::to_bytes(body).await.unwrap_or_default();
22702 let encoded = common::to_string(&bytes);
22703 match serde_json::from_str(&encoded) {
22704 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22705 Err(error) => {
22706 dlg.response_json_decode_error(&encoded, &error);
22707 return Err(common::Error::JsonDecodeError(
22708 encoded.to_string(),
22709 error,
22710 ));
22711 }
22712 }
22713 };
22714
22715 dlg.finished(true);
22716 return Ok(response);
22717 }
22718 }
22719 }
22720 }
22721
22722 /// Required. The parent, which owns this collection of targets.
22723 ///
22724 /// Sets the *parent* path property to the given value.
22725 ///
22726 /// Even though the property as already been set when instantiating this call,
22727 /// we provide this method for API completeness.
22728 pub fn parent(mut self, new_value: &str) -> ProjectLocationTargetProjectListCall<'a, C> {
22729 self._parent = new_value.to_string();
22730 self
22731 }
22732 /// Required. A page token, received from a previous `ListTargets` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListTargets` must match the call that provided the page token.
22733 ///
22734 /// Sets the *page token* query property to the given value.
22735 pub fn page_token(mut self, new_value: &str) -> ProjectLocationTargetProjectListCall<'a, C> {
22736 self._page_token = Some(new_value.to_string());
22737 self
22738 }
22739 /// Optional. The maximum number of targets to return. The service may return fewer than this value. If unspecified, at most 500 targets will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
22740 ///
22741 /// Sets the *page size* query property to the given value.
22742 pub fn page_size(mut self, new_value: i32) -> ProjectLocationTargetProjectListCall<'a, C> {
22743 self._page_size = Some(new_value);
22744 self
22745 }
22746 /// Optional. the order by fields for the result.
22747 ///
22748 /// Sets the *order by* query property to the given value.
22749 pub fn order_by(mut self, new_value: &str) -> ProjectLocationTargetProjectListCall<'a, C> {
22750 self._order_by = Some(new_value.to_string());
22751 self
22752 }
22753 /// Optional. The filter request.
22754 ///
22755 /// Sets the *filter* query property to the given value.
22756 pub fn filter(mut self, new_value: &str) -> ProjectLocationTargetProjectListCall<'a, C> {
22757 self._filter = Some(new_value.to_string());
22758 self
22759 }
22760 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22761 /// while executing the actual API request.
22762 ///
22763 /// ````text
22764 /// It should be used to handle progress information, and to implement a certain level of resilience.
22765 /// ````
22766 ///
22767 /// Sets the *delegate* property to the given value.
22768 pub fn delegate(
22769 mut self,
22770 new_value: &'a mut dyn common::Delegate,
22771 ) -> ProjectLocationTargetProjectListCall<'a, C> {
22772 self._delegate = Some(new_value);
22773 self
22774 }
22775
22776 /// Set any additional parameter of the query string used in the request.
22777 /// It should be used to set parameters which are not yet available through their own
22778 /// setters.
22779 ///
22780 /// Please note that this method must not be used to set any of the known parameters
22781 /// which have their own setter method. If done anyway, the request will fail.
22782 ///
22783 /// # Additional Parameters
22784 ///
22785 /// * *$.xgafv* (query-string) - V1 error format.
22786 /// * *access_token* (query-string) - OAuth access token.
22787 /// * *alt* (query-string) - Data format for response.
22788 /// * *callback* (query-string) - JSONP
22789 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22790 /// * *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.
22791 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22792 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22793 /// * *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.
22794 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22795 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22796 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTargetProjectListCall<'a, C>
22797 where
22798 T: AsRef<str>,
22799 {
22800 self._additional_params
22801 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22802 self
22803 }
22804
22805 /// Identifies the authorization scope for the method you are building.
22806 ///
22807 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22808 /// [`Scope::CloudPlatform`].
22809 ///
22810 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22811 /// tokens for more than one scope.
22812 ///
22813 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22814 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22815 /// sufficient, a read-write scope will do as well.
22816 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTargetProjectListCall<'a, C>
22817 where
22818 St: AsRef<str>,
22819 {
22820 self._scopes.insert(String::from(scope.as_ref()));
22821 self
22822 }
22823 /// Identifies the authorization scope(s) for the method you are building.
22824 ///
22825 /// See [`Self::add_scope()`] for details.
22826 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTargetProjectListCall<'a, C>
22827 where
22828 I: IntoIterator<Item = St>,
22829 St: AsRef<str>,
22830 {
22831 self._scopes
22832 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22833 self
22834 }
22835
22836 /// Removes all scopes, and no default scope will be used either.
22837 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22838 /// for details).
22839 pub fn clear_scopes(mut self) -> ProjectLocationTargetProjectListCall<'a, C> {
22840 self._scopes.clear();
22841 self
22842 }
22843}
22844
22845/// Updates the parameters of a single TargetProject. NOTE: TargetProject is a global resource; hence the only supported value for location is `global`.
22846///
22847/// A builder for the *locations.targetProjects.patch* method supported by a *project* resource.
22848/// It is not used directly, but through a [`ProjectMethods`] instance.
22849///
22850/// # Example
22851///
22852/// Instantiate a resource method builder
22853///
22854/// ```test_harness,no_run
22855/// # extern crate hyper;
22856/// # extern crate hyper_rustls;
22857/// # extern crate google_vmmigration1 as vmmigration1;
22858/// use vmmigration1::api::TargetProject;
22859/// # async fn dox() {
22860/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22861///
22862/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22863/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22864/// # secret,
22865/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22866/// # ).build().await.unwrap();
22867///
22868/// # let client = hyper_util::client::legacy::Client::builder(
22869/// # hyper_util::rt::TokioExecutor::new()
22870/// # )
22871/// # .build(
22872/// # hyper_rustls::HttpsConnectorBuilder::new()
22873/// # .with_native_roots()
22874/// # .unwrap()
22875/// # .https_or_http()
22876/// # .enable_http1()
22877/// # .build()
22878/// # );
22879/// # let mut hub = VMMigrationService::new(client, auth);
22880/// // As the method needs a request, you would usually fill it with the desired information
22881/// // into the respective structure. Some of the parts shown here might not be applicable !
22882/// // Values shown here are possibly random and not representative !
22883/// let mut req = TargetProject::default();
22884///
22885/// // You can configure optional parameters by calling the respective setters at will, and
22886/// // execute the final call using `doit()`.
22887/// // Values shown here are possibly random and not representative !
22888/// let result = hub.projects().locations_target_projects_patch(req, "name")
22889/// .update_mask(FieldMask::new::<&str>(&[]))
22890/// .request_id("ea")
22891/// .doit().await;
22892/// # }
22893/// ```
22894pub struct ProjectLocationTargetProjectPatchCall<'a, C>
22895where
22896 C: 'a,
22897{
22898 hub: &'a VMMigrationService<C>,
22899 _request: TargetProject,
22900 _name: String,
22901 _update_mask: Option<common::FieldMask>,
22902 _request_id: Option<String>,
22903 _delegate: Option<&'a mut dyn common::Delegate>,
22904 _additional_params: HashMap<String, String>,
22905 _scopes: BTreeSet<String>,
22906}
22907
22908impl<'a, C> common::CallBuilder for ProjectLocationTargetProjectPatchCall<'a, C> {}
22909
22910impl<'a, C> ProjectLocationTargetProjectPatchCall<'a, C>
22911where
22912 C: common::Connector,
22913{
22914 /// Perform the operation you have build so far.
22915 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
22916 use std::borrow::Cow;
22917 use std::io::{Read, Seek};
22918
22919 use common::{url::Params, ToParts};
22920 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22921
22922 let mut dd = common::DefaultDelegate;
22923 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22924 dlg.begin(common::MethodInfo {
22925 id: "vmmigration.projects.locations.targetProjects.patch",
22926 http_method: hyper::Method::PATCH,
22927 });
22928
22929 for &field in ["alt", "name", "updateMask", "requestId"].iter() {
22930 if self._additional_params.contains_key(field) {
22931 dlg.finished(false);
22932 return Err(common::Error::FieldClash(field));
22933 }
22934 }
22935
22936 let mut params = Params::with_capacity(6 + self._additional_params.len());
22937 params.push("name", self._name);
22938 if let Some(value) = self._update_mask.as_ref() {
22939 params.push("updateMask", value.to_string());
22940 }
22941 if let Some(value) = self._request_id.as_ref() {
22942 params.push("requestId", value);
22943 }
22944
22945 params.extend(self._additional_params.iter());
22946
22947 params.push("alt", "json");
22948 let mut url = self.hub._base_url.clone() + "v1/{+name}";
22949 if self._scopes.is_empty() {
22950 self._scopes
22951 .insert(Scope::CloudPlatform.as_ref().to_string());
22952 }
22953
22954 #[allow(clippy::single_element_loop)]
22955 for &(find_this, param_name) in [("{+name}", "name")].iter() {
22956 url = params.uri_replacement(url, param_name, find_this, true);
22957 }
22958 {
22959 let to_remove = ["name"];
22960 params.remove_params(&to_remove);
22961 }
22962
22963 let url = params.parse_with_url(&url);
22964
22965 let mut json_mime_type = mime::APPLICATION_JSON;
22966 let mut request_value_reader = {
22967 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22968 common::remove_json_null_values(&mut value);
22969 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22970 serde_json::to_writer(&mut dst, &value).unwrap();
22971 dst
22972 };
22973 let request_size = request_value_reader
22974 .seek(std::io::SeekFrom::End(0))
22975 .unwrap();
22976 request_value_reader
22977 .seek(std::io::SeekFrom::Start(0))
22978 .unwrap();
22979
22980 loop {
22981 let token = match self
22982 .hub
22983 .auth
22984 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22985 .await
22986 {
22987 Ok(token) => token,
22988 Err(e) => match dlg.token(e) {
22989 Ok(token) => token,
22990 Err(e) => {
22991 dlg.finished(false);
22992 return Err(common::Error::MissingToken(e));
22993 }
22994 },
22995 };
22996 request_value_reader
22997 .seek(std::io::SeekFrom::Start(0))
22998 .unwrap();
22999 let mut req_result = {
23000 let client = &self.hub.client;
23001 dlg.pre_request();
23002 let mut req_builder = hyper::Request::builder()
23003 .method(hyper::Method::PATCH)
23004 .uri(url.as_str())
23005 .header(USER_AGENT, self.hub._user_agent.clone());
23006
23007 if let Some(token) = token.as_ref() {
23008 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23009 }
23010
23011 let request = req_builder
23012 .header(CONTENT_TYPE, json_mime_type.to_string())
23013 .header(CONTENT_LENGTH, request_size as u64)
23014 .body(common::to_body(
23015 request_value_reader.get_ref().clone().into(),
23016 ));
23017
23018 client.request(request.unwrap()).await
23019 };
23020
23021 match req_result {
23022 Err(err) => {
23023 if let common::Retry::After(d) = dlg.http_error(&err) {
23024 sleep(d).await;
23025 continue;
23026 }
23027 dlg.finished(false);
23028 return Err(common::Error::HttpError(err));
23029 }
23030 Ok(res) => {
23031 let (mut parts, body) = res.into_parts();
23032 let mut body = common::Body::new(body);
23033 if !parts.status.is_success() {
23034 let bytes = common::to_bytes(body).await.unwrap_or_default();
23035 let error = serde_json::from_str(&common::to_string(&bytes));
23036 let response = common::to_response(parts, bytes.into());
23037
23038 if let common::Retry::After(d) =
23039 dlg.http_failure(&response, error.as_ref().ok())
23040 {
23041 sleep(d).await;
23042 continue;
23043 }
23044
23045 dlg.finished(false);
23046
23047 return Err(match error {
23048 Ok(value) => common::Error::BadRequest(value),
23049 _ => common::Error::Failure(response),
23050 });
23051 }
23052 let response = {
23053 let bytes = common::to_bytes(body).await.unwrap_or_default();
23054 let encoded = common::to_string(&bytes);
23055 match serde_json::from_str(&encoded) {
23056 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23057 Err(error) => {
23058 dlg.response_json_decode_error(&encoded, &error);
23059 return Err(common::Error::JsonDecodeError(
23060 encoded.to_string(),
23061 error,
23062 ));
23063 }
23064 }
23065 };
23066
23067 dlg.finished(true);
23068 return Ok(response);
23069 }
23070 }
23071 }
23072 }
23073
23074 ///
23075 /// Sets the *request* property to the given value.
23076 ///
23077 /// Even though the property as already been set when instantiating this call,
23078 /// we provide this method for API completeness.
23079 pub fn request(
23080 mut self,
23081 new_value: TargetProject,
23082 ) -> ProjectLocationTargetProjectPatchCall<'a, C> {
23083 self._request = new_value;
23084 self
23085 }
23086 /// Output only. The name of the target project.
23087 ///
23088 /// Sets the *name* path property to the given value.
23089 ///
23090 /// Even though the property as already been set when instantiating this call,
23091 /// we provide this method for API completeness.
23092 pub fn name(mut self, new_value: &str) -> ProjectLocationTargetProjectPatchCall<'a, C> {
23093 self._name = new_value.to_string();
23094 self
23095 }
23096 /// Field mask is used to specify the fields to be overwritten in the TargetProject resource by the update. The fields specified in the update_mask are relative to the resource, not the full request. A field will be overwritten if it is in the mask. If the user does not provide a mask then all fields will be overwritten.
23097 ///
23098 /// Sets the *update mask* query property to the given value.
23099 pub fn update_mask(
23100 mut self,
23101 new_value: common::FieldMask,
23102 ) -> ProjectLocationTargetProjectPatchCall<'a, C> {
23103 self._update_mask = Some(new_value);
23104 self
23105 }
23106 /// A request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. The server will guarantee that for at least 60 minutes since the first request. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
23107 ///
23108 /// Sets the *request id* query property to the given value.
23109 pub fn request_id(mut self, new_value: &str) -> ProjectLocationTargetProjectPatchCall<'a, C> {
23110 self._request_id = Some(new_value.to_string());
23111 self
23112 }
23113 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23114 /// while executing the actual API request.
23115 ///
23116 /// ````text
23117 /// It should be used to handle progress information, and to implement a certain level of resilience.
23118 /// ````
23119 ///
23120 /// Sets the *delegate* property to the given value.
23121 pub fn delegate(
23122 mut self,
23123 new_value: &'a mut dyn common::Delegate,
23124 ) -> ProjectLocationTargetProjectPatchCall<'a, C> {
23125 self._delegate = Some(new_value);
23126 self
23127 }
23128
23129 /// Set any additional parameter of the query string used in the request.
23130 /// It should be used to set parameters which are not yet available through their own
23131 /// setters.
23132 ///
23133 /// Please note that this method must not be used to set any of the known parameters
23134 /// which have their own setter method. If done anyway, the request will fail.
23135 ///
23136 /// # Additional Parameters
23137 ///
23138 /// * *$.xgafv* (query-string) - V1 error format.
23139 /// * *access_token* (query-string) - OAuth access token.
23140 /// * *alt* (query-string) - Data format for response.
23141 /// * *callback* (query-string) - JSONP
23142 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23143 /// * *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.
23144 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23145 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23146 /// * *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.
23147 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23148 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23149 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTargetProjectPatchCall<'a, C>
23150 where
23151 T: AsRef<str>,
23152 {
23153 self._additional_params
23154 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23155 self
23156 }
23157
23158 /// Identifies the authorization scope for the method you are building.
23159 ///
23160 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23161 /// [`Scope::CloudPlatform`].
23162 ///
23163 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23164 /// tokens for more than one scope.
23165 ///
23166 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23167 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23168 /// sufficient, a read-write scope will do as well.
23169 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTargetProjectPatchCall<'a, C>
23170 where
23171 St: AsRef<str>,
23172 {
23173 self._scopes.insert(String::from(scope.as_ref()));
23174 self
23175 }
23176 /// Identifies the authorization scope(s) for the method you are building.
23177 ///
23178 /// See [`Self::add_scope()`] for details.
23179 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTargetProjectPatchCall<'a, C>
23180 where
23181 I: IntoIterator<Item = St>,
23182 St: AsRef<str>,
23183 {
23184 self._scopes
23185 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23186 self
23187 }
23188
23189 /// Removes all scopes, and no default scope will be used either.
23190 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23191 /// for details).
23192 pub fn clear_scopes(mut self) -> ProjectLocationTargetProjectPatchCall<'a, C> {
23193 self._scopes.clear();
23194 self
23195 }
23196}
23197
23198/// Gets information about a location.
23199///
23200/// A builder for the *locations.get* method supported by a *project* resource.
23201/// It is not used directly, but through a [`ProjectMethods`] instance.
23202///
23203/// # Example
23204///
23205/// Instantiate a resource method builder
23206///
23207/// ```test_harness,no_run
23208/// # extern crate hyper;
23209/// # extern crate hyper_rustls;
23210/// # extern crate google_vmmigration1 as vmmigration1;
23211/// # async fn dox() {
23212/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23213///
23214/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23215/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23216/// # secret,
23217/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23218/// # ).build().await.unwrap();
23219///
23220/// # let client = hyper_util::client::legacy::Client::builder(
23221/// # hyper_util::rt::TokioExecutor::new()
23222/// # )
23223/// # .build(
23224/// # hyper_rustls::HttpsConnectorBuilder::new()
23225/// # .with_native_roots()
23226/// # .unwrap()
23227/// # .https_or_http()
23228/// # .enable_http1()
23229/// # .build()
23230/// # );
23231/// # let mut hub = VMMigrationService::new(client, auth);
23232/// // You can configure optional parameters by calling the respective setters at will, and
23233/// // execute the final call using `doit()`.
23234/// // Values shown here are possibly random and not representative !
23235/// let result = hub.projects().locations_get("name")
23236/// .doit().await;
23237/// # }
23238/// ```
23239pub struct ProjectLocationGetCall<'a, C>
23240where
23241 C: 'a,
23242{
23243 hub: &'a VMMigrationService<C>,
23244 _name: String,
23245 _delegate: Option<&'a mut dyn common::Delegate>,
23246 _additional_params: HashMap<String, String>,
23247 _scopes: BTreeSet<String>,
23248}
23249
23250impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
23251
23252impl<'a, C> ProjectLocationGetCall<'a, C>
23253where
23254 C: common::Connector,
23255{
23256 /// Perform the operation you have build so far.
23257 pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
23258 use std::borrow::Cow;
23259 use std::io::{Read, Seek};
23260
23261 use common::{url::Params, ToParts};
23262 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23263
23264 let mut dd = common::DefaultDelegate;
23265 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23266 dlg.begin(common::MethodInfo {
23267 id: "vmmigration.projects.locations.get",
23268 http_method: hyper::Method::GET,
23269 });
23270
23271 for &field in ["alt", "name"].iter() {
23272 if self._additional_params.contains_key(field) {
23273 dlg.finished(false);
23274 return Err(common::Error::FieldClash(field));
23275 }
23276 }
23277
23278 let mut params = Params::with_capacity(3 + self._additional_params.len());
23279 params.push("name", self._name);
23280
23281 params.extend(self._additional_params.iter());
23282
23283 params.push("alt", "json");
23284 let mut url = self.hub._base_url.clone() + "v1/{+name}";
23285 if self._scopes.is_empty() {
23286 self._scopes
23287 .insert(Scope::CloudPlatform.as_ref().to_string());
23288 }
23289
23290 #[allow(clippy::single_element_loop)]
23291 for &(find_this, param_name) in [("{+name}", "name")].iter() {
23292 url = params.uri_replacement(url, param_name, find_this, true);
23293 }
23294 {
23295 let to_remove = ["name"];
23296 params.remove_params(&to_remove);
23297 }
23298
23299 let url = params.parse_with_url(&url);
23300
23301 loop {
23302 let token = match self
23303 .hub
23304 .auth
23305 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23306 .await
23307 {
23308 Ok(token) => token,
23309 Err(e) => match dlg.token(e) {
23310 Ok(token) => token,
23311 Err(e) => {
23312 dlg.finished(false);
23313 return Err(common::Error::MissingToken(e));
23314 }
23315 },
23316 };
23317 let mut req_result = {
23318 let client = &self.hub.client;
23319 dlg.pre_request();
23320 let mut req_builder = hyper::Request::builder()
23321 .method(hyper::Method::GET)
23322 .uri(url.as_str())
23323 .header(USER_AGENT, self.hub._user_agent.clone());
23324
23325 if let Some(token) = token.as_ref() {
23326 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23327 }
23328
23329 let request = req_builder
23330 .header(CONTENT_LENGTH, 0_u64)
23331 .body(common::to_body::<String>(None));
23332
23333 client.request(request.unwrap()).await
23334 };
23335
23336 match req_result {
23337 Err(err) => {
23338 if let common::Retry::After(d) = dlg.http_error(&err) {
23339 sleep(d).await;
23340 continue;
23341 }
23342 dlg.finished(false);
23343 return Err(common::Error::HttpError(err));
23344 }
23345 Ok(res) => {
23346 let (mut parts, body) = res.into_parts();
23347 let mut body = common::Body::new(body);
23348 if !parts.status.is_success() {
23349 let bytes = common::to_bytes(body).await.unwrap_or_default();
23350 let error = serde_json::from_str(&common::to_string(&bytes));
23351 let response = common::to_response(parts, bytes.into());
23352
23353 if let common::Retry::After(d) =
23354 dlg.http_failure(&response, error.as_ref().ok())
23355 {
23356 sleep(d).await;
23357 continue;
23358 }
23359
23360 dlg.finished(false);
23361
23362 return Err(match error {
23363 Ok(value) => common::Error::BadRequest(value),
23364 _ => common::Error::Failure(response),
23365 });
23366 }
23367 let response = {
23368 let bytes = common::to_bytes(body).await.unwrap_or_default();
23369 let encoded = common::to_string(&bytes);
23370 match serde_json::from_str(&encoded) {
23371 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23372 Err(error) => {
23373 dlg.response_json_decode_error(&encoded, &error);
23374 return Err(common::Error::JsonDecodeError(
23375 encoded.to_string(),
23376 error,
23377 ));
23378 }
23379 }
23380 };
23381
23382 dlg.finished(true);
23383 return Ok(response);
23384 }
23385 }
23386 }
23387 }
23388
23389 /// Resource name for the location.
23390 ///
23391 /// Sets the *name* path property to the given value.
23392 ///
23393 /// Even though the property as already been set when instantiating this call,
23394 /// we provide this method for API completeness.
23395 pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
23396 self._name = new_value.to_string();
23397 self
23398 }
23399 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23400 /// while executing the actual API request.
23401 ///
23402 /// ````text
23403 /// It should be used to handle progress information, and to implement a certain level of resilience.
23404 /// ````
23405 ///
23406 /// Sets the *delegate* property to the given value.
23407 pub fn delegate(
23408 mut self,
23409 new_value: &'a mut dyn common::Delegate,
23410 ) -> ProjectLocationGetCall<'a, C> {
23411 self._delegate = Some(new_value);
23412 self
23413 }
23414
23415 /// Set any additional parameter of the query string used in the request.
23416 /// It should be used to set parameters which are not yet available through their own
23417 /// setters.
23418 ///
23419 /// Please note that this method must not be used to set any of the known parameters
23420 /// which have their own setter method. If done anyway, the request will fail.
23421 ///
23422 /// # Additional Parameters
23423 ///
23424 /// * *$.xgafv* (query-string) - V1 error format.
23425 /// * *access_token* (query-string) - OAuth access token.
23426 /// * *alt* (query-string) - Data format for response.
23427 /// * *callback* (query-string) - JSONP
23428 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23429 /// * *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.
23430 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23431 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23432 /// * *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.
23433 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23434 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23435 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
23436 where
23437 T: AsRef<str>,
23438 {
23439 self._additional_params
23440 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23441 self
23442 }
23443
23444 /// Identifies the authorization scope for the method you are building.
23445 ///
23446 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23447 /// [`Scope::CloudPlatform`].
23448 ///
23449 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23450 /// tokens for more than one scope.
23451 ///
23452 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23453 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23454 /// sufficient, a read-write scope will do as well.
23455 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
23456 where
23457 St: AsRef<str>,
23458 {
23459 self._scopes.insert(String::from(scope.as_ref()));
23460 self
23461 }
23462 /// Identifies the authorization scope(s) for the method you are building.
23463 ///
23464 /// See [`Self::add_scope()`] for details.
23465 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
23466 where
23467 I: IntoIterator<Item = St>,
23468 St: AsRef<str>,
23469 {
23470 self._scopes
23471 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23472 self
23473 }
23474
23475 /// Removes all scopes, and no default scope will be used either.
23476 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23477 /// for details).
23478 pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
23479 self._scopes.clear();
23480 self
23481 }
23482}
23483
23484/// Lists information about the supported locations for this service.
23485///
23486/// A builder for the *locations.list* method supported by a *project* resource.
23487/// It is not used directly, but through a [`ProjectMethods`] instance.
23488///
23489/// # Example
23490///
23491/// Instantiate a resource method builder
23492///
23493/// ```test_harness,no_run
23494/// # extern crate hyper;
23495/// # extern crate hyper_rustls;
23496/// # extern crate google_vmmigration1 as vmmigration1;
23497/// # async fn dox() {
23498/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23499///
23500/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23501/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23502/// # secret,
23503/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23504/// # ).build().await.unwrap();
23505///
23506/// # let client = hyper_util::client::legacy::Client::builder(
23507/// # hyper_util::rt::TokioExecutor::new()
23508/// # )
23509/// # .build(
23510/// # hyper_rustls::HttpsConnectorBuilder::new()
23511/// # .with_native_roots()
23512/// # .unwrap()
23513/// # .https_or_http()
23514/// # .enable_http1()
23515/// # .build()
23516/// # );
23517/// # let mut hub = VMMigrationService::new(client, auth);
23518/// // You can configure optional parameters by calling the respective setters at will, and
23519/// // execute the final call using `doit()`.
23520/// // Values shown here are possibly random and not representative !
23521/// let result = hub.projects().locations_list("name")
23522/// .page_token("eos")
23523/// .page_size(-68)
23524/// .filter("sea")
23525/// .doit().await;
23526/// # }
23527/// ```
23528pub struct ProjectLocationListCall<'a, C>
23529where
23530 C: 'a,
23531{
23532 hub: &'a VMMigrationService<C>,
23533 _name: String,
23534 _page_token: Option<String>,
23535 _page_size: Option<i32>,
23536 _filter: Option<String>,
23537 _delegate: Option<&'a mut dyn common::Delegate>,
23538 _additional_params: HashMap<String, String>,
23539 _scopes: BTreeSet<String>,
23540}
23541
23542impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
23543
23544impl<'a, C> ProjectLocationListCall<'a, C>
23545where
23546 C: common::Connector,
23547{
23548 /// Perform the operation you have build so far.
23549 pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
23550 use std::borrow::Cow;
23551 use std::io::{Read, Seek};
23552
23553 use common::{url::Params, ToParts};
23554 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23555
23556 let mut dd = common::DefaultDelegate;
23557 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23558 dlg.begin(common::MethodInfo {
23559 id: "vmmigration.projects.locations.list",
23560 http_method: hyper::Method::GET,
23561 });
23562
23563 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
23564 if self._additional_params.contains_key(field) {
23565 dlg.finished(false);
23566 return Err(common::Error::FieldClash(field));
23567 }
23568 }
23569
23570 let mut params = Params::with_capacity(6 + self._additional_params.len());
23571 params.push("name", self._name);
23572 if let Some(value) = self._page_token.as_ref() {
23573 params.push("pageToken", value);
23574 }
23575 if let Some(value) = self._page_size.as_ref() {
23576 params.push("pageSize", value.to_string());
23577 }
23578 if let Some(value) = self._filter.as_ref() {
23579 params.push("filter", value);
23580 }
23581
23582 params.extend(self._additional_params.iter());
23583
23584 params.push("alt", "json");
23585 let mut url = self.hub._base_url.clone() + "v1/{+name}/locations";
23586 if self._scopes.is_empty() {
23587 self._scopes
23588 .insert(Scope::CloudPlatform.as_ref().to_string());
23589 }
23590
23591 #[allow(clippy::single_element_loop)]
23592 for &(find_this, param_name) in [("{+name}", "name")].iter() {
23593 url = params.uri_replacement(url, param_name, find_this, true);
23594 }
23595 {
23596 let to_remove = ["name"];
23597 params.remove_params(&to_remove);
23598 }
23599
23600 let url = params.parse_with_url(&url);
23601
23602 loop {
23603 let token = match self
23604 .hub
23605 .auth
23606 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23607 .await
23608 {
23609 Ok(token) => token,
23610 Err(e) => match dlg.token(e) {
23611 Ok(token) => token,
23612 Err(e) => {
23613 dlg.finished(false);
23614 return Err(common::Error::MissingToken(e));
23615 }
23616 },
23617 };
23618 let mut req_result = {
23619 let client = &self.hub.client;
23620 dlg.pre_request();
23621 let mut req_builder = hyper::Request::builder()
23622 .method(hyper::Method::GET)
23623 .uri(url.as_str())
23624 .header(USER_AGENT, self.hub._user_agent.clone());
23625
23626 if let Some(token) = token.as_ref() {
23627 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23628 }
23629
23630 let request = req_builder
23631 .header(CONTENT_LENGTH, 0_u64)
23632 .body(common::to_body::<String>(None));
23633
23634 client.request(request.unwrap()).await
23635 };
23636
23637 match req_result {
23638 Err(err) => {
23639 if let common::Retry::After(d) = dlg.http_error(&err) {
23640 sleep(d).await;
23641 continue;
23642 }
23643 dlg.finished(false);
23644 return Err(common::Error::HttpError(err));
23645 }
23646 Ok(res) => {
23647 let (mut parts, body) = res.into_parts();
23648 let mut body = common::Body::new(body);
23649 if !parts.status.is_success() {
23650 let bytes = common::to_bytes(body).await.unwrap_or_default();
23651 let error = serde_json::from_str(&common::to_string(&bytes));
23652 let response = common::to_response(parts, bytes.into());
23653
23654 if let common::Retry::After(d) =
23655 dlg.http_failure(&response, error.as_ref().ok())
23656 {
23657 sleep(d).await;
23658 continue;
23659 }
23660
23661 dlg.finished(false);
23662
23663 return Err(match error {
23664 Ok(value) => common::Error::BadRequest(value),
23665 _ => common::Error::Failure(response),
23666 });
23667 }
23668 let response = {
23669 let bytes = common::to_bytes(body).await.unwrap_or_default();
23670 let encoded = common::to_string(&bytes);
23671 match serde_json::from_str(&encoded) {
23672 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23673 Err(error) => {
23674 dlg.response_json_decode_error(&encoded, &error);
23675 return Err(common::Error::JsonDecodeError(
23676 encoded.to_string(),
23677 error,
23678 ));
23679 }
23680 }
23681 };
23682
23683 dlg.finished(true);
23684 return Ok(response);
23685 }
23686 }
23687 }
23688 }
23689
23690 /// The resource that owns the locations collection, if applicable.
23691 ///
23692 /// Sets the *name* path property to the given value.
23693 ///
23694 /// Even though the property as already been set when instantiating this call,
23695 /// we provide this method for API completeness.
23696 pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
23697 self._name = new_value.to_string();
23698 self
23699 }
23700 /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
23701 ///
23702 /// Sets the *page token* query property to the given value.
23703 pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
23704 self._page_token = Some(new_value.to_string());
23705 self
23706 }
23707 /// The maximum number of results to return. If not set, the service selects a default.
23708 ///
23709 /// Sets the *page size* query property to the given value.
23710 pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
23711 self._page_size = Some(new_value);
23712 self
23713 }
23714 /// 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).
23715 ///
23716 /// Sets the *filter* query property to the given value.
23717 pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
23718 self._filter = Some(new_value.to_string());
23719 self
23720 }
23721 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23722 /// while executing the actual API request.
23723 ///
23724 /// ````text
23725 /// It should be used to handle progress information, and to implement a certain level of resilience.
23726 /// ````
23727 ///
23728 /// Sets the *delegate* property to the given value.
23729 pub fn delegate(
23730 mut self,
23731 new_value: &'a mut dyn common::Delegate,
23732 ) -> ProjectLocationListCall<'a, C> {
23733 self._delegate = Some(new_value);
23734 self
23735 }
23736
23737 /// Set any additional parameter of the query string used in the request.
23738 /// It should be used to set parameters which are not yet available through their own
23739 /// setters.
23740 ///
23741 /// Please note that this method must not be used to set any of the known parameters
23742 /// which have their own setter method. If done anyway, the request will fail.
23743 ///
23744 /// # Additional Parameters
23745 ///
23746 /// * *$.xgafv* (query-string) - V1 error format.
23747 /// * *access_token* (query-string) - OAuth access token.
23748 /// * *alt* (query-string) - Data format for response.
23749 /// * *callback* (query-string) - JSONP
23750 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23751 /// * *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.
23752 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23753 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23754 /// * *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.
23755 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23756 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23757 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
23758 where
23759 T: AsRef<str>,
23760 {
23761 self._additional_params
23762 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23763 self
23764 }
23765
23766 /// Identifies the authorization scope for the method you are building.
23767 ///
23768 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23769 /// [`Scope::CloudPlatform`].
23770 ///
23771 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23772 /// tokens for more than one scope.
23773 ///
23774 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23775 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23776 /// sufficient, a read-write scope will do as well.
23777 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
23778 where
23779 St: AsRef<str>,
23780 {
23781 self._scopes.insert(String::from(scope.as_ref()));
23782 self
23783 }
23784 /// Identifies the authorization scope(s) for the method you are building.
23785 ///
23786 /// See [`Self::add_scope()`] for details.
23787 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
23788 where
23789 I: IntoIterator<Item = St>,
23790 St: AsRef<str>,
23791 {
23792 self._scopes
23793 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23794 self
23795 }
23796
23797 /// Removes all scopes, and no default scope will be used either.
23798 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23799 /// for details).
23800 pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
23801 self._scopes.clear();
23802 self
23803 }
23804}