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 connector = hyper_rustls::HttpsConnectorBuilder::new()
63/// .with_native_roots()
64/// .unwrap()
65/// .https_only()
66/// .enable_http2()
67/// .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71/// secret,
72/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73/// yup_oauth2::client::CustomHyperClientBuilder::from(
74/// hyper_util::client::legacy::Client::builder(executor).build(connector),
75/// ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79/// hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82/// hyper_rustls::HttpsConnectorBuilder::new()
83/// .with_native_roots()
84/// .unwrap()
85/// .https_or_http()
86/// .enable_http2()
87/// .build()
88/// );
89/// let mut hub = VMMigrationService::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = Group::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.projects().locations_groups_create(req, "parent")
99/// .request_id("sed")
100/// .group_id("amet.")
101/// .doit().await;
102///
103/// match result {
104/// Err(e) => match e {
105/// // The Error enum provides details about what exactly happened.
106/// // You can also just use its `Debug`, `Display` or `Error` traits
107/// Error::HttpError(_)
108/// |Error::Io(_)
109/// |Error::MissingAPIKey
110/// |Error::MissingToken(_)
111/// |Error::Cancelled
112/// |Error::UploadSizeLimitExceeded(_, _)
113/// |Error::Failure(_)
114/// |Error::BadRequest(_)
115/// |Error::FieldClash(_)
116/// |Error::JsonDecodeError(_, _) => println!("{}", e),
117/// },
118/// Ok(res) => println!("Success: {:?}", res),
119/// }
120/// # }
121/// ```
122#[derive(Clone)]
123pub struct VMMigrationService<C> {
124 pub client: common::Client<C>,
125 pub auth: Box<dyn common::GetToken>,
126 _user_agent: String,
127 _base_url: String,
128 _root_url: String,
129}
130
131impl<C> common::Hub for VMMigrationService<C> {}
132
133impl<'a, C> VMMigrationService<C> {
134 pub fn new<A: 'static + common::GetToken>(
135 client: common::Client<C>,
136 auth: A,
137 ) -> VMMigrationService<C> {
138 VMMigrationService {
139 client,
140 auth: Box::new(auth),
141 _user_agent: "google-api-rust-client/7.0.0".to_string(),
142 _base_url: "https://vmmigration.googleapis.com/".to_string(),
143 _root_url: "https://vmmigration.googleapis.com/".to_string(),
144 }
145 }
146
147 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
148 ProjectMethods { hub: self }
149 }
150
151 /// Set the user-agent header field to use in all requests to the server.
152 /// It defaults to `google-api-rust-client/7.0.0`.
153 ///
154 /// Returns the previously set user-agent.
155 pub fn user_agent(&mut self, agent_name: String) -> String {
156 std::mem::replace(&mut self._user_agent, agent_name)
157 }
158
159 /// Set the base url to use in all requests to the server.
160 /// It defaults to `https://vmmigration.googleapis.com/`.
161 ///
162 /// Returns the previously set base url.
163 pub fn base_url(&mut self, new_base_url: String) -> String {
164 std::mem::replace(&mut self._base_url, new_base_url)
165 }
166
167 /// Set the root url to use in all requests to the server.
168 /// It defaults to `https://vmmigration.googleapis.com/`.
169 ///
170 /// Returns the previously set root url.
171 pub fn root_url(&mut self, new_root_url: String) -> String {
172 std::mem::replace(&mut self._root_url, new_root_url)
173 }
174}
175
176// ############
177// SCHEMAS ###
178// ##########
179/// Message describing AWS Credentials using access key id and secret.
180///
181/// This type is not used in any activity, and only used as *part* of another schema.
182///
183#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
184#[serde_with::serde_as]
185#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
186pub struct AccessKeyCredentials {
187 /// AWS access key ID.
188 #[serde(rename = "accessKeyId")]
189 pub access_key_id: Option<String>,
190 /// Input only. AWS secret access key.
191 #[serde(rename = "secretAccessKey")]
192 pub secret_access_key: Option<String>,
193 /// Input only. AWS session token. Used only when AWS security token service (STS) is responsible for creating the temporary credentials.
194 #[serde(rename = "sessionToken")]
195 pub session_token: Option<String>,
196}
197
198impl common::Part for AccessKeyCredentials {}
199
200/// AdaptationModifier a modifier to be used for configuration of the OS adaptation process.
201///
202/// This type is not used in any activity, and only used as *part* of another schema.
203///
204#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
205#[serde_with::serde_as]
206#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
207pub struct AdaptationModifier {
208 /// Optional. The modifier name.
209 pub modifier: Option<String>,
210 /// Optional. The value of the modifier. The actual value depends on the modifier and can also be empty.
211 pub value: Option<String>,
212}
213
214impl common::Part for AdaptationModifier {}
215
216/// AdaptingOSStep contains specific step details.
217///
218/// This type is not used in any activity, and only used as *part* of another schema.
219///
220#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
221#[serde_with::serde_as]
222#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
223pub struct AdaptingOSStep {
224 _never_set: Option<bool>,
225}
226
227impl common::Part for AdaptingOSStep {}
228
229/// Request message for ‘AddGroupMigration’ request.
230///
231/// # Activities
232///
233/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
234/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
235///
236/// * [locations groups add group migration projects](ProjectLocationGroupAddGroupMigrationCall) (request)
237#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
238#[serde_with::serde_as]
239#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
240pub struct AddGroupMigrationRequest {
241 /// The full path name of the MigratingVm to add.
242 #[serde(rename = "migratingVm")]
243 pub migrating_vm: Option<String>,
244}
245
246impl common::RequestValue for AddGroupMigrationRequest {}
247
248/// Describes an appliance version.
249///
250/// This type is not used in any activity, and only used as *part* of another schema.
251///
252#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
253#[serde_with::serde_as]
254#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
255pub struct ApplianceVersion {
256 /// Determine whether it's critical to upgrade the appliance to this version.
257 pub critical: Option<bool>,
258 /// Link to a page that contains the version release notes.
259 #[serde(rename = "releaseNotesUri")]
260 pub release_notes_uri: Option<String>,
261 /// A link for downloading the version.
262 pub uri: Option<String>,
263 /// The appliance version.
264 pub version: Option<String>,
265}
266
267impl common::Part for ApplianceVersion {}
268
269/// AppliedLicense holds the license data returned by adaptation module report.
270///
271/// This type is not used in any activity, and only used as *part* of another schema.
272///
273#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
274#[serde_with::serde_as]
275#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
276pub struct AppliedLicense {
277 /// The OS license returned from the adaptation module's report.
278 #[serde(rename = "osLicense")]
279 pub os_license: Option<String>,
280 /// The license type that was used in OS adaptation.
281 #[serde(rename = "type")]
282 pub type_: Option<String>,
283}
284
285impl common::Part for AppliedLicense {}
286
287/// Holds information about the available versions for upgrade.
288///
289/// This type is not used in any activity, and only used as *part* of another schema.
290///
291#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
292#[serde_with::serde_as]
293#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
294pub struct AvailableUpdates {
295 /// The latest version for in place update. The current appliance can be updated to this version using the API or m4c CLI.
296 #[serde(rename = "inPlaceUpdate")]
297 pub in_place_update: Option<ApplianceVersion>,
298 /// 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.
299 #[serde(rename = "newDeployableAppliance")]
300 pub new_deployable_appliance: Option<ApplianceVersion>,
301}
302
303impl common::Part for AvailableUpdates {}
304
305/// The details of an AWS instance disk.
306///
307/// This type is not used in any activity, and only used as *part* of another schema.
308///
309#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
310#[serde_with::serde_as]
311#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
312pub struct AwsDiskDetails {
313 /// Output only. The ordinal number of the disk.
314 #[serde(rename = "diskNumber")]
315 pub disk_number: Option<i32>,
316 /// Output only. Size in GB.
317 #[serde(rename = "sizeGb")]
318 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
319 pub size_gb: Option<i64>,
320 /// Output only. AWS volume ID.
321 #[serde(rename = "volumeId")]
322 pub volume_id: Option<String>,
323}
324
325impl common::Part for AwsDiskDetails {}
326
327/// AwsSecurityGroup describes a security group of an AWS VM.
328///
329/// This type is not used in any activity, and only used as *part* of another schema.
330///
331#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
332#[serde_with::serde_as]
333#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
334pub struct AwsSecurityGroup {
335 /// The AWS security group id.
336 pub id: Option<String>,
337 /// The AWS security group name.
338 pub name: Option<String>,
339}
340
341impl common::Part for AwsSecurityGroup {}
342
343/// AwsSourceDetails message describes a specific source details for the AWS source type.
344///
345/// This type is not used in any activity, and only used as *part* of another schema.
346///
347#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
348#[serde_with::serde_as]
349#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
350pub struct AwsSourceDetails {
351 /// AWS Credentials using access key id and secret.
352 #[serde(rename = "accessKeyCreds")]
353 pub access_key_creds: Option<AccessKeyCredentials>,
354 /// Immutable. The AWS region that the source VMs will be migrated from.
355 #[serde(rename = "awsRegion")]
356 pub aws_region: Option<String>,
357 /// Output only. Provides details on the state of the Source in case of an error.
358 pub error: Option<Status>,
359 /// AWS security group names to limit the scope of the source inventory.
360 #[serde(rename = "inventorySecurityGroupNames")]
361 pub inventory_security_group_names: Option<Vec<String>>,
362 /// AWS resource tags to limit the scope of the source inventory.
363 #[serde(rename = "inventoryTagList")]
364 pub inventory_tag_list: Option<Vec<Tag>>,
365 /// 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`.
366 #[serde(rename = "migrationResourcesUserTags")]
367 pub migration_resources_user_tags: Option<HashMap<String, String>>,
368 /// Output only. The source's public IP. All communication initiated by this source will originate from this IP.
369 #[serde(rename = "publicIp")]
370 pub public_ip: Option<String>,
371 /// Output only. State of the source as determined by the health check.
372 pub state: Option<String>,
373}
374
375impl common::Part for AwsSourceDetails {}
376
377/// Represents the source AWS Disk details.
378///
379/// This type is not used in any activity, and only used as *part* of another schema.
380///
381#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
382#[serde_with::serde_as]
383#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
384pub struct AwsSourceDiskDetails {
385 /// Optional. Output only. Disk type.
386 #[serde(rename = "diskType")]
387 pub disk_type: Option<String>,
388 /// Output only. Size in GiB.
389 #[serde(rename = "sizeGib")]
390 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
391 pub size_gib: Option<i64>,
392 /// Optional. Output only. A map of AWS volume tags.
393 pub tags: Option<HashMap<String, String>>,
394 /// Required. AWS volume ID.
395 #[serde(rename = "volumeId")]
396 pub volume_id: Option<String>,
397}
398
399impl common::Part for AwsSourceDiskDetails {}
400
401/// Represent the source AWS VM details.
402///
403/// This type is not used in any activity, and only used as *part* of another schema.
404///
405#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
406#[serde_with::serde_as]
407#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
408pub struct AwsSourceVmDetails {
409 /// Output only. The VM architecture.
410 pub architecture: Option<String>,
411 /// Output only. The total size of the disks being migrated in bytes.
412 #[serde(rename = "committedStorageBytes")]
413 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
414 pub committed_storage_bytes: Option<i64>,
415 /// Output only. The disks attached to the source VM.
416 pub disks: Option<Vec<AwsDiskDetails>>,
417 /// Output only. The firmware type of the source VM.
418 pub firmware: Option<String>,
419 /// Output only. Information about VM capabilities needed for some Compute Engine features.
420 #[serde(rename = "vmCapabilitiesInfo")]
421 pub vm_capabilities_info: Option<VmCapabilities>,
422}
423
424impl common::Part for AwsSourceVmDetails {}
425
426/// AwsVmDetails describes a VM in AWS.
427///
428/// This type is not used in any activity, and only used as *part* of another schema.
429///
430#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
431#[serde_with::serde_as]
432#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
433pub struct AwsVmDetails {
434 /// The CPU architecture.
435 pub architecture: Option<String>,
436 /// The VM Boot Option.
437 #[serde(rename = "bootOption")]
438 pub boot_option: Option<String>,
439 /// The total size of the storage allocated to the VM in MB.
440 #[serde(rename = "committedStorageMb")]
441 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
442 pub committed_storage_mb: Option<i64>,
443 /// The number of CPU cores the VM has.
444 #[serde(rename = "cpuCount")]
445 pub cpu_count: Option<i32>,
446 /// The number of disks the VM has.
447 #[serde(rename = "diskCount")]
448 pub disk_count: Option<i32>,
449 /// The display name of the VM. Note that this value is not necessarily unique.
450 #[serde(rename = "displayName")]
451 pub display_name: Option<String>,
452 /// The instance type of the VM.
453 #[serde(rename = "instanceType")]
454 pub instance_type: Option<String>,
455 /// The memory size of the VM in MB.
456 #[serde(rename = "memoryMb")]
457 pub memory_mb: Option<i32>,
458 /// The VM's OS.
459 #[serde(rename = "osDescription")]
460 pub os_description: Option<String>,
461 /// Output only. The power state of the VM at the moment list was taken.
462 #[serde(rename = "powerState")]
463 pub power_state: Option<String>,
464 /// The security groups the VM belongs to.
465 #[serde(rename = "securityGroups")]
466 pub security_groups: Option<Vec<AwsSecurityGroup>>,
467 /// The descriptive name of the AWS's source this VM is connected to.
468 #[serde(rename = "sourceDescription")]
469 pub source_description: Option<String>,
470 /// The id of the AWS's source this VM is connected to.
471 #[serde(rename = "sourceId")]
472 pub source_id: Option<String>,
473 /// The tags of the VM.
474 pub tags: Option<HashMap<String, String>>,
475 /// The number of vCPUs the VM has. It is calculated as the number of CPU cores * threads per CPU the VM has.
476 #[serde(rename = "vcpuCount")]
477 pub vcpu_count: Option<i32>,
478 /// The virtualization type.
479 #[serde(rename = "virtualizationType")]
480 pub virtualization_type: Option<String>,
481 /// The VM ID in AWS.
482 #[serde(rename = "vmId")]
483 pub vm_id: Option<String>,
484 /// The VPC ID the VM belongs to.
485 #[serde(rename = "vpcId")]
486 pub vpc_id: Option<String>,
487 /// The AWS zone of the VM.
488 pub zone: Option<String>,
489}
490
491impl common::Part for AwsVmDetails {}
492
493/// AWSVmsDetails describes VMs in AWS.
494///
495/// This type is not used in any activity, and only used as *part* of another schema.
496///
497#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
498#[serde_with::serde_as]
499#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
500pub struct AwsVmsDetails {
501 /// The details of the AWS VMs.
502 pub details: Option<Vec<AwsVmDetails>>,
503}
504
505impl common::Part for AwsVmsDetails {}
506
507/// The details of an Azure VM disk.
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 AzureDiskDetails {
515 /// Output only. Azure disk ID.
516 #[serde(rename = "diskId")]
517 pub disk_id: Option<String>,
518 /// Output only. The ordinal number of the disk.
519 #[serde(rename = "diskNumber")]
520 pub disk_number: Option<i32>,
521 /// Output only. Size in GB.
522 #[serde(rename = "sizeGb")]
523 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
524 pub size_gb: Option<i64>,
525}
526
527impl common::Part for AzureDiskDetails {}
528
529/// AzureSourceDetails message describes a specific source details for the Azure source type.
530///
531/// This type is not used in any activity, and only used as *part* of another schema.
532///
533#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
534#[serde_with::serde_as]
535#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
536pub struct AzureSourceDetails {
537 /// Immutable. The Azure location (region) that the source VMs will be migrated from.
538 #[serde(rename = "azureLocation")]
539 pub azure_location: Option<String>,
540 /// Azure Credentials using tenant ID, client ID and secret.
541 #[serde(rename = "clientSecretCreds")]
542 pub client_secret_creds: Option<ClientSecretCredentials>,
543 /// Output only. Provides details on the state of the Source in case of an error.
544 pub error: Option<Status>,
545 /// 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`.
546 #[serde(rename = "migrationResourcesUserTags")]
547 pub migration_resources_user_tags: Option<HashMap<String, String>>,
548 /// Output only. The ID of the Azure resource group that contains all resources related to the migration process of this source.
549 #[serde(rename = "resourceGroupId")]
550 pub resource_group_id: Option<String>,
551 /// Output only. State of the source as determined by the health check.
552 pub state: Option<String>,
553 /// Immutable. Azure subscription ID.
554 #[serde(rename = "subscriptionId")]
555 pub subscription_id: Option<String>,
556}
557
558impl common::Part for AzureSourceDetails {}
559
560/// Represent the source Azure VM details.
561///
562/// This type is not used in any activity, and only used as *part* of another schema.
563///
564#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
565#[serde_with::serde_as]
566#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
567pub struct AzureSourceVmDetails {
568 /// Output only. The VM architecture.
569 pub architecture: Option<String>,
570 /// Output only. The total size of the disks being migrated in bytes.
571 #[serde(rename = "committedStorageBytes")]
572 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
573 pub committed_storage_bytes: Option<i64>,
574 /// Output only. The disks attached to the source VM.
575 pub disks: Option<Vec<AzureDiskDetails>>,
576 /// Output only. The firmware type of the source VM.
577 pub firmware: Option<String>,
578 /// Output only. Information about VM capabilities needed for some Compute Engine features.
579 #[serde(rename = "vmCapabilitiesInfo")]
580 pub vm_capabilities_info: Option<VmCapabilities>,
581}
582
583impl common::Part for AzureSourceVmDetails {}
584
585/// AzureVmDetails describes a VM in Azure.
586///
587/// This type is not used in any activity, and only used as *part* of another schema.
588///
589#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
590#[serde_with::serde_as]
591#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
592pub struct AzureVmDetails {
593 /// The CPU architecture.
594 pub architecture: Option<String>,
595 /// The VM Boot Option.
596 #[serde(rename = "bootOption")]
597 pub boot_option: Option<String>,
598 /// The total size of the storage allocated to the VM in MB.
599 #[serde(rename = "committedStorageMb")]
600 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
601 pub committed_storage_mb: Option<i64>,
602 /// The VM's ComputerName.
603 #[serde(rename = "computerName")]
604 pub computer_name: Option<String>,
605 /// The number of cpus the VM has.
606 #[serde(rename = "cpuCount")]
607 pub cpu_count: Option<i32>,
608 /// The number of disks the VM has, including OS disk.
609 #[serde(rename = "diskCount")]
610 pub disk_count: Option<i32>,
611 /// Description of the data disks.
612 pub disks: Option<Vec<Disk>>,
613 /// The memory size of the VM in MB.
614 #[serde(rename = "memoryMb")]
615 pub memory_mb: Option<i32>,
616 /// Description of the OS.
617 #[serde(rename = "osDescription")]
618 pub os_description: Option<OSDescription>,
619 /// Description of the OS disk.
620 #[serde(rename = "osDisk")]
621 pub os_disk: Option<OSDisk>,
622 /// The power state of the VM at the moment list was taken.
623 #[serde(rename = "powerState")]
624 pub power_state: Option<String>,
625 /// The tags of the VM.
626 pub tags: Option<HashMap<String, String>>,
627 /// The VM full path in Azure.
628 #[serde(rename = "vmId")]
629 pub vm_id: Option<String>,
630 /// VM size as configured in Azure. Determines the VM's hardware spec.
631 #[serde(rename = "vmSize")]
632 pub vm_size: Option<String>,
633}
634
635impl common::Part for AzureVmDetails {}
636
637/// AzureVmsDetails describes VMs in Azure.
638///
639/// This type is not used in any activity, and only used as *part* of another schema.
640///
641#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
642#[serde_with::serde_as]
643#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
644pub struct AzureVmsDetails {
645 /// The details of the Azure VMs.
646 pub details: Option<Vec<AzureVmDetails>>,
647}
648
649impl common::Part for AzureVmsDetails {}
650
651/// BootDiskDefaults hold information about the boot disk of a VM.
652///
653/// This type is not used in any activity, and only used as *part* of another schema.
654///
655#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
656#[serde_with::serde_as]
657#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
658pub struct BootDiskDefaults {
659 /// 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.
660 #[serde(rename = "deviceName")]
661 pub device_name: Option<String>,
662 /// Optional. The name of the disk.
663 #[serde(rename = "diskName")]
664 pub disk_name: Option<String>,
665 /// Optional. The type of disk provisioning to use for the VM.
666 #[serde(rename = "diskType")]
667 pub disk_type: Option<String>,
668 /// Optional. The encryption to apply to the boot disk.
669 pub encryption: Option<Encryption>,
670 /// The image to use when creating the disk.
671 pub image: Option<DiskImageDefaults>,
672}
673
674impl common::Part for BootDiskDefaults {}
675
676/// Request message for ‘CancelCloneJob’ request.
677///
678/// # Activities
679///
680/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
681/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
682///
683/// * [locations sources migrating vms clone jobs cancel projects](ProjectLocationSourceMigratingVmCloneJobCancelCall) (request)
684#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
685#[serde_with::serde_as]
686#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
687pub struct CancelCloneJobRequest {
688 _never_set: Option<bool>,
689}
690
691impl common::RequestValue for CancelCloneJobRequest {}
692
693/// Request message for ‘CancelCutoverJob’ request.
694///
695/// # Activities
696///
697/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
698/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
699///
700/// * [locations sources migrating vms cutover jobs cancel projects](ProjectLocationSourceMigratingVmCutoverJobCancelCall) (request)
701#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
702#[serde_with::serde_as]
703#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
704pub struct CancelCutoverJobRequest {
705 _never_set: Option<bool>,
706}
707
708impl common::RequestValue for CancelCutoverJobRequest {}
709
710/// Request message for ‘CancelDiskMigrationJob’ request.
711///
712/// # Activities
713///
714/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
715/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
716///
717/// * [locations sources disk migration jobs cancel projects](ProjectLocationSourceDiskMigrationJobCancelCall) (request)
718#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
719#[serde_with::serde_as]
720#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
721pub struct CancelDiskMigrationJobRequest {
722 _never_set: Option<bool>,
723}
724
725impl common::RequestValue for CancelDiskMigrationJobRequest {}
726
727/// Request message for ‘CancelImageImportJob’ request.
728///
729/// # Activities
730///
731/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
732/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
733///
734/// * [locations image imports image import jobs cancel projects](ProjectLocationImageImportImageImportJobCancelCall) (request)
735#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
736#[serde_with::serde_as]
737#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
738pub struct CancelImageImportJobRequest {
739 _never_set: Option<bool>,
740}
741
742impl common::RequestValue for CancelImageImportJobRequest {}
743
744/// The request message for Operations.CancelOperation.
745///
746/// # Activities
747///
748/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
749/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
750///
751/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (request)
752#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
753#[serde_with::serde_as]
754#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
755pub struct CancelOperationRequest {
756 _never_set: Option<bool>,
757}
758
759impl common::RequestValue for CancelOperationRequest {}
760
761/// Message describing Azure Credentials using tenant ID, client ID and secret.
762///
763/// This type is not used in any activity, and only used as *part* of another schema.
764///
765#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
766#[serde_with::serde_as]
767#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
768pub struct ClientSecretCredentials {
769 /// Azure client ID.
770 #[serde(rename = "clientId")]
771 pub client_id: Option<String>,
772 /// Input only. Azure client secret.
773 #[serde(rename = "clientSecret")]
774 pub client_secret: Option<String>,
775 /// Azure tenant ID.
776 #[serde(rename = "tenantId")]
777 pub tenant_id: Option<String>,
778}
779
780impl common::Part for ClientSecretCredentials {}
781
782/// 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.
783///
784/// # Activities
785///
786/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
787/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
788///
789/// * [locations sources migrating vms clone jobs create projects](ProjectLocationSourceMigratingVmCloneJobCreateCall) (request)
790/// * [locations sources migrating vms clone jobs get projects](ProjectLocationSourceMigratingVmCloneJobGetCall) (response)
791#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
792#[serde_with::serde_as]
793#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
794pub struct CloneJob {
795 /// Output only. Details of the target Persistent Disks in Compute Engine.
796 #[serde(rename = "computeEngineDisksTargetDetails")]
797 pub compute_engine_disks_target_details: Option<ComputeEngineDisksTargetDetails>,
798 /// Output only. Details of the target VM in Compute Engine.
799 #[serde(rename = "computeEngineTargetDetails")]
800 pub compute_engine_target_details: Option<ComputeEngineTargetDetails>,
801 /// Output only. The time the clone job was created (as an API call, not when it was actually created in the target).
802 #[serde(rename = "createTime")]
803 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
804 /// Output only. The time the clone job was ended.
805 #[serde(rename = "endTime")]
806 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
807 /// Output only. Provides details for the errors that led to the Clone Job's state.
808 pub error: Option<Status>,
809 /// Output only. The name of the clone.
810 pub name: Option<String>,
811 /// Output only. State of the clone job.
812 pub state: Option<String>,
813 /// Output only. The time the state was last updated.
814 #[serde(rename = "stateTime")]
815 pub state_time: Option<chrono::DateTime<chrono::offset::Utc>>,
816 /// Output only. The clone steps list representing its progress.
817 pub steps: Option<Vec<CloneStep>>,
818}
819
820impl common::RequestValue for CloneJob {}
821impl common::ResponseResult for CloneJob {}
822
823/// CloneStep holds information about the clone step progress.
824///
825/// This type is not used in any activity, and only used as *part* of another schema.
826///
827#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
828#[serde_with::serde_as]
829#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
830pub struct CloneStep {
831 /// Adapting OS step.
832 #[serde(rename = "adaptingOs")]
833 pub adapting_os: Option<AdaptingOSStep>,
834 /// The time the step has ended.
835 #[serde(rename = "endTime")]
836 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
837 /// Instantiating migrated VM step.
838 #[serde(rename = "instantiatingMigratedVm")]
839 pub instantiating_migrated_vm: Option<InstantiatingMigratedVMStep>,
840 /// Preparing VM disks step.
841 #[serde(rename = "preparingVmDisks")]
842 pub preparing_vm_disks: Option<PreparingVMDisksStep>,
843 /// The time the step has started.
844 #[serde(rename = "startTime")]
845 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
846}
847
848impl common::Part for CloneStep {}
849
850/// Compute Engine disk target details.
851///
852/// This type is not used in any activity, and only used as *part* of another schema.
853///
854#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
855#[serde_with::serde_as]
856#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
857pub struct ComputeEngineDisk {
858 /// Optional. Target Compute Engine Disk ID. This is the resource ID segment of the Compute Engine Disk to create. In the resource name compute/v1/projects/{project}/zones/{zone}/disks/disk1 "disk1" is the resource ID for the disk.
859 #[serde(rename = "diskId")]
860 pub disk_id: Option<String>,
861 /// Required. The disk type to use.
862 #[serde(rename = "diskType")]
863 pub disk_type: Option<String>,
864 /// Optional. Replication zones of the regional disk. Should be of the form: projects/{target-project}/locations/{replica-zone} Currently only one replica zone is supported.
865 #[serde(rename = "replicaZones")]
866 pub replica_zones: Option<Vec<String>>,
867 /// Required. The Compute Engine zone in which to create the disk. Should be of the form: projects/{target-project}/locations/{zone}
868 pub zone: Option<String>,
869}
870
871impl common::Part for ComputeEngineDisk {}
872
873/// ComputeEngineDisksTargetDefaults is a collection of details for creating Persistent Disks in a target Compute Engine project.
874///
875/// This type is not used in any activity, and only used as *part* of another schema.
876///
877#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
878#[serde_with::serde_as]
879#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
880pub struct ComputeEngineDisksTargetDefaults {
881 /// The details of each Persistent Disk to create.
882 pub disks: Option<Vec<PersistentDiskDefaults>>,
883 /// Details of the disk only migration target.
884 #[serde(rename = "disksTargetDefaults")]
885 pub disks_target_defaults: Option<DisksMigrationDisksTargetDefaults>,
886 /// The full path of the resource of type TargetProject which represents the Compute Engine project in which to create the Persistent Disks.
887 #[serde(rename = "targetProject")]
888 pub target_project: Option<String>,
889 /// Details of the VM migration target.
890 #[serde(rename = "vmTargetDefaults")]
891 pub vm_target_defaults: Option<DisksMigrationVmTargetDefaults>,
892 /// The zone in which to create the Persistent Disks.
893 pub zone: Option<String>,
894}
895
896impl common::Part for ComputeEngineDisksTargetDefaults {}
897
898/// ComputeEngineDisksTargetDetails is a collection of created Persistent Disks details.
899///
900/// This type is not used in any activity, and only used as *part* of another schema.
901///
902#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
903#[serde_with::serde_as]
904#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
905pub struct ComputeEngineDisksTargetDetails {
906 /// The details of each created Persistent Disk.
907 pub disks: Option<Vec<PersistentDisk>>,
908 /// Details of the disks-only migration target.
909 #[serde(rename = "disksTargetDetails")]
910 pub disks_target_details: Option<DisksMigrationDisksTargetDetails>,
911 /// Details for the VM the migrated data disks are attached to.
912 #[serde(rename = "vmTargetDetails")]
913 pub vm_target_details: Option<DisksMigrationVmTargetDetails>,
914}
915
916impl common::Part for ComputeEngineDisksTargetDetails {}
917
918/// ComputeEngineTargetDefaults is a collection of details for creating a VM in a target Compute Engine project.
919///
920/// This type is not used in any activity, and only used as *part* of another schema.
921///
922#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
923#[serde_with::serde_as]
924#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
925pub struct ComputeEngineTargetDefaults {
926 /// Optional. AdaptationModifiers are the set of modifiers used during OS adaptation.
927 #[serde(rename = "adaptationModifiers")]
928 pub adaptation_modifiers: Option<Vec<AdaptationModifier>>,
929 /// Additional licenses to assign to the VM.
930 #[serde(rename = "additionalLicenses")]
931 pub additional_licenses: Option<Vec<String>>,
932 /// Output only. The OS license returned from the adaptation module report.
933 #[serde(rename = "appliedLicense")]
934 pub applied_license: Option<AppliedLicense>,
935 /// Optional. By default the virtual machine will keep its existing boot option. Setting this property will trigger an internal process which will convert the virtual machine from using the existing boot option to another.
936 #[serde(rename = "bootConversion")]
937 pub boot_conversion: Option<String>,
938 /// Output only. The VM Boot Option, as set in the source VM.
939 #[serde(rename = "bootOption")]
940 pub boot_option: Option<String>,
941 /// Compute instance scheduling information (if empty default is used).
942 #[serde(rename = "computeScheduling")]
943 pub compute_scheduling: Option<ComputeScheduling>,
944 /// Optional. Additional replica zones of the target regional disks. If this list is not empty a regional disk will be created. The first supported zone would be the one stated in the zone field. The rest are taken from this list. Please refer to the [regional disk creation API](https://cloud.google.com/compute/docs/regions-zones/global-regional-zonal-resources) for further details about regional vs zonal disks. If not specified, a zonal disk will be created in the same zone the VM is created.
945 #[serde(rename = "diskReplicaZones")]
946 pub disk_replica_zones: Option<Vec<String>>,
947 /// The disk type to use in the VM.
948 #[serde(rename = "diskType")]
949 pub disk_type: Option<String>,
950 /// Optional. Defines whether the instance has integrity monitoring enabled. This can be set to true only if the VM boot option is EFI, and vTPM is enabled.
951 #[serde(rename = "enableIntegrityMonitoring")]
952 pub enable_integrity_monitoring: Option<bool>,
953 /// Optional. Defines whether the instance has vTPM enabled. This can be set to true only if the VM boot option is EFI.
954 #[serde(rename = "enableVtpm")]
955 pub enable_vtpm: Option<bool>,
956 /// Optional. Immutable. The encryption to apply to the VM disks.
957 pub encryption: Option<Encryption>,
958 /// The hostname to assign to the VM.
959 pub hostname: Option<String>,
960 /// A map of labels to associate with the VM.
961 pub labels: Option<HashMap<String, String>>,
962 /// The license type to use in OS adaptation.
963 #[serde(rename = "licenseType")]
964 pub license_type: Option<String>,
965 /// The machine type to create the VM with.
966 #[serde(rename = "machineType")]
967 pub machine_type: Option<String>,
968 /// The machine type series to create the VM with.
969 #[serde(rename = "machineTypeSeries")]
970 pub machine_type_series: Option<String>,
971 /// The metadata key/value pairs to assign to the VM.
972 pub metadata: Option<HashMap<String, String>>,
973 /// List of NICs connected to this VM.
974 #[serde(rename = "networkInterfaces")]
975 pub network_interfaces: Option<Vec<NetworkInterface>>,
976 /// A list of network tags to associate with the VM.
977 #[serde(rename = "networkTags")]
978 pub network_tags: Option<Vec<String>>,
979 /// Defines whether the instance has Secure Boot enabled. This can be set to true only if the VM boot option is EFI.
980 #[serde(rename = "secureBoot")]
981 pub secure_boot: Option<bool>,
982 /// Optional. The service account to associate the VM with.
983 #[serde(rename = "serviceAccount")]
984 pub service_account: Option<String>,
985 /// Optional. If specified this will be the storage pool in which the disk is created. This is the full path of the storage pool resource, for example: "projects/my-project/zones/us-central1-a/storagePools/my-storage-pool". The storage pool must be in the same project and zone as the target disks. The storage pool's type must match the disk type.
986 #[serde(rename = "storagePool")]
987 pub storage_pool: Option<String>,
988 /// The full path of the resource of type TargetProject which represents the Compute Engine project in which to create this VM.
989 #[serde(rename = "targetProject")]
990 pub target_project: Option<String>,
991 /// The name of the VM to create.
992 #[serde(rename = "vmName")]
993 pub vm_name: Option<String>,
994 /// The zone in which to create the VM.
995 pub zone: Option<String>,
996}
997
998impl common::Part for ComputeEngineTargetDefaults {}
999
1000/// ComputeEngineTargetDetails is a collection of details for creating a VM in a target Compute Engine project.
1001///
1002/// This type is not used in any activity, and only used as *part* of another schema.
1003///
1004#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1005#[serde_with::serde_as]
1006#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1007pub struct ComputeEngineTargetDetails {
1008 /// Optional. Modifiers to be used as configuration of the OS adaptation process.
1009 #[serde(rename = "adaptationModifiers")]
1010 pub adaptation_modifiers: Option<Vec<AdaptationModifier>>,
1011 /// Additional licenses to assign to the VM.
1012 #[serde(rename = "additionalLicenses")]
1013 pub additional_licenses: Option<Vec<String>>,
1014 /// The OS license returned from the adaptation module report.
1015 #[serde(rename = "appliedLicense")]
1016 pub applied_license: Option<AppliedLicense>,
1017 /// Optional. By default the virtual machine will keep its existing boot option. Setting this property will trigger an internal process which will convert the virtual machine from using the existing boot option to another.
1018 #[serde(rename = "bootConversion")]
1019 pub boot_conversion: Option<String>,
1020 /// The VM Boot Option, as set in the source VM.
1021 #[serde(rename = "bootOption")]
1022 pub boot_option: Option<String>,
1023 /// Compute instance scheduling information (if empty default is used).
1024 #[serde(rename = "computeScheduling")]
1025 pub compute_scheduling: Option<ComputeScheduling>,
1026 /// Optional. Additional replica zones of the target regional disks. If this list is not empty a regional disk will be created. The first supported zone would be the one stated in the zone field. The rest are taken from this list. Please refer to the [regional disk creation API](https://cloud.google.com/compute/docs/regions-zones/global-regional-zonal-resources) for further details about regional vs zonal disks. If not specified, a zonal disk will be created in the same zone the VM is created.
1027 #[serde(rename = "diskReplicaZones")]
1028 pub disk_replica_zones: Option<Vec<String>>,
1029 /// The disk type to use in the VM.
1030 #[serde(rename = "diskType")]
1031 pub disk_type: Option<String>,
1032 /// Optional. Defines whether the instance has integrity monitoring enabled.
1033 #[serde(rename = "enableIntegrityMonitoring")]
1034 pub enable_integrity_monitoring: Option<bool>,
1035 /// Optional. Defines whether the instance has vTPM enabled.
1036 #[serde(rename = "enableVtpm")]
1037 pub enable_vtpm: Option<bool>,
1038 /// Optional. The encryption to apply to the VM disks.
1039 pub encryption: Option<Encryption>,
1040 /// The hostname to assign to the VM.
1041 pub hostname: Option<String>,
1042 /// A map of labels to associate with the VM.
1043 pub labels: Option<HashMap<String, String>>,
1044 /// The license type to use in OS adaptation.
1045 #[serde(rename = "licenseType")]
1046 pub license_type: Option<String>,
1047 /// The machine type to create the VM with.
1048 #[serde(rename = "machineType")]
1049 pub machine_type: Option<String>,
1050 /// The machine type series to create the VM with.
1051 #[serde(rename = "machineTypeSeries")]
1052 pub machine_type_series: Option<String>,
1053 /// The metadata key/value pairs to assign to the VM.
1054 pub metadata: Option<HashMap<String, String>>,
1055 /// List of NICs connected to this VM.
1056 #[serde(rename = "networkInterfaces")]
1057 pub network_interfaces: Option<Vec<NetworkInterface>>,
1058 /// A list of network tags to associate with the VM.
1059 #[serde(rename = "networkTags")]
1060 pub network_tags: Option<Vec<String>>,
1061 /// The Google Cloud target project ID or project name.
1062 pub project: Option<String>,
1063 /// Defines whether the instance has Secure Boot enabled. This can be set to true only if the VM boot option is EFI.
1064 #[serde(rename = "secureBoot")]
1065 pub secure_boot: Option<bool>,
1066 /// The service account to associate the VM with.
1067 #[serde(rename = "serviceAccount")]
1068 pub service_account: Option<String>,
1069 /// Optional. The storage pool used for the VM disks. If specified this will be the storage pool in which the disk is created. This is the full path of the storage pool resource, for example: "projects/my-project/zones/us-central1-a/storagePools/my-storage-pool". The storage pool must be in the same project and zone as the target disks. The storage pool's type must match the disk type.
1070 #[serde(rename = "storagePool")]
1071 pub storage_pool: Option<String>,
1072 /// The name of the VM to create.
1073 #[serde(rename = "vmName")]
1074 pub vm_name: Option<String>,
1075 /// The zone in which to create the VM.
1076 pub zone: Option<String>,
1077}
1078
1079impl common::Part for ComputeEngineTargetDetails {}
1080
1081/// Scheduling information for VM on maintenance/restart behaviour and node allocation in sole tenant nodes. Options for instance behavior when the host machine undergoes maintenance that may temporarily impact instance performance.
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 ComputeScheduling {
1089 /// The minimum number of virtual CPUs this instance will consume when running on a sole-tenant node. Ignored if no node_affinites are configured.
1090 #[serde(rename = "minNodeCpus")]
1091 pub min_node_cpus: Option<i32>,
1092 /// A set of node affinity and anti-affinity configurations for sole tenant nodes.
1093 #[serde(rename = "nodeAffinities")]
1094 pub node_affinities: Option<Vec<SchedulingNodeAffinity>>,
1095 /// How the instance should behave when the host machine undergoes maintenance that may temporarily impact instance performance.
1096 #[serde(rename = "onHostMaintenance")]
1097 pub on_host_maintenance: Option<String>,
1098 /// 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.
1099 #[serde(rename = "restartType")]
1100 pub restart_type: Option<String>,
1101}
1102
1103impl common::Part for ComputeScheduling {}
1104
1105/// CopyingSourceDiskSnapshotStep contains specific step details.
1106///
1107/// This type is not used in any activity, and only used as *part* of another schema.
1108///
1109#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1110#[serde_with::serde_as]
1111#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1112pub struct CopyingSourceDiskSnapshotStep {
1113 _never_set: Option<bool>,
1114}
1115
1116impl common::Part for CopyingSourceDiskSnapshotStep {}
1117
1118/// CreatingImageStep contains specific step details.
1119///
1120/// This type is not used in any activity, and only used as *part* of another schema.
1121///
1122#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1123#[serde_with::serde_as]
1124#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1125pub struct CreatingImageStep {
1126 _never_set: Option<bool>,
1127}
1128
1129impl common::Part for CreatingImageStep {}
1130
1131/// CreatingSourceDiskSnapshotStep contains specific step details.
1132///
1133/// This type is not used in any activity, and only used as *part* of another schema.
1134///
1135#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1136#[serde_with::serde_as]
1137#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1138pub struct CreatingSourceDiskSnapshotStep {
1139 _never_set: Option<bool>,
1140}
1141
1142impl common::Part for CreatingSourceDiskSnapshotStep {}
1143
1144/// CutoverForecast holds information about future CutoverJobs of a MigratingVm.
1145///
1146/// This type is not used in any activity, and only used as *part* of another schema.
1147///
1148#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1149#[serde_with::serde_as]
1150#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1151pub struct CutoverForecast {
1152 /// Output only. Estimation of the CutoverJob duration.
1153 #[serde(rename = "estimatedCutoverJobDuration")]
1154 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1155 pub estimated_cutover_job_duration: Option<chrono::Duration>,
1156}
1157
1158impl common::Part for CutoverForecast {}
1159
1160/// CutoverJob message describes a cutover of a migrating VM. The CutoverJob is the operation of shutting down the VM, creating a snapshot and cloning the VM using the replicated snapshot.
1161///
1162/// # Activities
1163///
1164/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1165/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1166///
1167/// * [locations sources migrating vms cutover jobs create projects](ProjectLocationSourceMigratingVmCutoverJobCreateCall) (request)
1168/// * [locations sources migrating vms cutover jobs get projects](ProjectLocationSourceMigratingVmCutoverJobGetCall) (response)
1169#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1170#[serde_with::serde_as]
1171#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1172pub struct CutoverJob {
1173 /// Output only. Details of the target Persistent Disks in Compute Engine.
1174 #[serde(rename = "computeEngineDisksTargetDetails")]
1175 pub compute_engine_disks_target_details: Option<ComputeEngineDisksTargetDetails>,
1176 /// Output only. Details of the target VM in Compute Engine.
1177 #[serde(rename = "computeEngineTargetDetails")]
1178 pub compute_engine_target_details: Option<ComputeEngineTargetDetails>,
1179 /// Output only. The time the cutover job was created (as an API call, not when it was actually created in the target).
1180 #[serde(rename = "createTime")]
1181 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1182 /// Output only. The time the cutover job had finished.
1183 #[serde(rename = "endTime")]
1184 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1185 /// Output only. Provides details for the errors that led to the Cutover Job's state.
1186 pub error: Option<Status>,
1187 /// Output only. The name of the cutover job.
1188 pub name: Option<String>,
1189 /// Output only. The current progress in percentage of the cutover job.
1190 #[serde(rename = "progressPercent")]
1191 pub progress_percent: Option<i32>,
1192 /// Output only. State of the cutover job.
1193 pub state: Option<String>,
1194 /// Output only. A message providing possible extra details about the current state.
1195 #[serde(rename = "stateMessage")]
1196 pub state_message: Option<String>,
1197 /// Output only. The time the state was last updated.
1198 #[serde(rename = "stateTime")]
1199 pub state_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1200 /// Output only. The cutover steps list representing its progress.
1201 pub steps: Option<Vec<CutoverStep>>,
1202}
1203
1204impl common::RequestValue for CutoverJob {}
1205impl common::ResponseResult for CutoverJob {}
1206
1207/// CutoverStep holds information about the cutover step progress.
1208///
1209/// This type is not used in any activity, and only used as *part* of another schema.
1210///
1211#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1212#[serde_with::serde_as]
1213#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1214pub struct CutoverStep {
1215 /// The time the step has ended.
1216 #[serde(rename = "endTime")]
1217 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1218 /// Final sync step.
1219 #[serde(rename = "finalSync")]
1220 pub final_sync: Option<ReplicationCycle>,
1221 /// Instantiating migrated VM step.
1222 #[serde(rename = "instantiatingMigratedVm")]
1223 pub instantiating_migrated_vm: Option<InstantiatingMigratedVMStep>,
1224 /// Preparing VM disks step.
1225 #[serde(rename = "preparingVmDisks")]
1226 pub preparing_vm_disks: Option<PreparingVMDisksStep>,
1227 /// A replication cycle prior cutover step.
1228 #[serde(rename = "previousReplicationCycle")]
1229 pub previous_replication_cycle: Option<ReplicationCycle>,
1230 /// Shutting down VM step.
1231 #[serde(rename = "shuttingDownSourceVm")]
1232 pub shutting_down_source_vm: Option<ShuttingDownSourceVMStep>,
1233 /// The time the step has started.
1234 #[serde(rename = "startTime")]
1235 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1236}
1237
1238impl common::Part for CutoverStep {}
1239
1240/// CycleStep holds information about a step progress.
1241///
1242/// This type is not used in any activity, and only used as *part* of another schema.
1243///
1244#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1245#[serde_with::serde_as]
1246#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1247pub struct CycleStep {
1248 /// The time the cycle step has ended.
1249 #[serde(rename = "endTime")]
1250 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1251 /// Initializing replication step.
1252 #[serde(rename = "initializingReplication")]
1253 pub initializing_replication: Option<InitializingReplicationStep>,
1254 /// Post processing step.
1255 #[serde(rename = "postProcessing")]
1256 pub post_processing: Option<PostProcessingStep>,
1257 /// Replicating step.
1258 pub replicating: Option<ReplicatingStep>,
1259 /// The time the cycle step has started.
1260 #[serde(rename = "startTime")]
1261 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1262}
1263
1264impl common::Part for CycleStep {}
1265
1266/// Used when the image import is not using OS adaptation process.
1267///
1268/// This type is not used in any activity, and only used as *part* of another schema.
1269///
1270#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1271#[serde_with::serde_as]
1272#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1273pub struct DataDiskImageImport {
1274 /// Optional. A list of guest OS features to apply to the imported image. These features are flags that are used by Compute Engine to enable certain capabilities for virtual machine instances that are created from the image. This field does not change the OS of the image; it only marks the image with the specified features. The user must ensure that the OS is compatible with the features. For a list of available features, see https://cloud.google.com/compute/docs/images/create-custom#guest-os-features.
1275 #[serde(rename = "guestOsFeatures")]
1276 pub guest_os_features: Option<Vec<String>>,
1277}
1278
1279impl common::Part for DataDiskImageImport {}
1280
1281/// 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.
1282///
1283/// # Activities
1284///
1285/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1286/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1287///
1288/// * [locations sources datacenter connectors create projects](ProjectLocationSourceDatacenterConnectorCreateCall) (request)
1289/// * [locations sources datacenter connectors get projects](ProjectLocationSourceDatacenterConnectorGetCall) (response)
1290#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1291#[serde_with::serde_as]
1292#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1293pub struct DatacenterConnector {
1294 /// 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.
1295 #[serde(rename = "applianceInfrastructureVersion")]
1296 pub appliance_infrastructure_version: Option<String>,
1297 /// Output only. Appliance last installed update bundle version. This is the version of the automatically updatable components on the appliance.
1298 #[serde(rename = "applianceSoftwareVersion")]
1299 pub appliance_software_version: Option<String>,
1300 /// Output only. The available versions for updating this appliance.
1301 #[serde(rename = "availableVersions")]
1302 pub available_versions: Option<AvailableUpdates>,
1303 /// Output only. The communication channel between the datacenter connector and Google Cloud.
1304 pub bucket: Option<String>,
1305 /// Output only. The time the connector was created (as an API call, not when it was actually installed).
1306 #[serde(rename = "createTime")]
1307 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1308 /// Output only. Provides details on the state of the Datacenter Connector in case of an error.
1309 pub error: Option<Status>,
1310 /// Output only. The connector's name.
1311 pub name: Option<String>,
1312 /// 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.
1313 #[serde(rename = "registrationId")]
1314 pub registration_id: Option<String>,
1315 /// The service account to use in the connector when communicating with the cloud.
1316 #[serde(rename = "serviceAccount")]
1317 pub service_account: Option<String>,
1318 /// Output only. State of the DatacenterConnector, as determined by the health checks.
1319 pub state: Option<String>,
1320 /// Output only. The time the state was last set.
1321 #[serde(rename = "stateTime")]
1322 pub state_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1323 /// Output only. The last time the connector was updated with an API call.
1324 #[serde(rename = "updateTime")]
1325 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1326 /// Output only. The status of the current / last upgradeAppliance operation.
1327 #[serde(rename = "upgradeStatus")]
1328 pub upgrade_status: Option<UpgradeStatus>,
1329 /// The version running in the DatacenterConnector. This is supplied by the OVA connector during the registration process and can not be modified.
1330 pub version: Option<String>,
1331}
1332
1333impl common::RequestValue for DatacenterConnector {}
1334impl common::ResponseResult for DatacenterConnector {}
1335
1336/// A message describing a data disk.
1337///
1338/// This type is not used in any activity, and only used as *part* of another schema.
1339///
1340#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1341#[serde_with::serde_as]
1342#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1343pub struct Disk {
1344 /// The disk's Logical Unit Number (LUN).
1345 pub lun: Option<i32>,
1346 /// The disk name.
1347 pub name: Option<String>,
1348 /// The disk size in GB.
1349 #[serde(rename = "sizeGb")]
1350 pub size_gb: Option<i32>,
1351}
1352
1353impl common::Part for Disk {}
1354
1355/// Contains details about the image source used to create the disk.
1356///
1357/// This type is not used in any activity, and only used as *part* of another schema.
1358///
1359#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1360#[serde_with::serde_as]
1361#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1362pub struct DiskImageDefaults {
1363 /// Required. The Image resource used when creating the disk.
1364 #[serde(rename = "sourceImage")]
1365 pub source_image: Option<String>,
1366}
1367
1368impl common::Part for DiskImageDefaults {}
1369
1370/// The target details of the image resource that will be created by the import job.
1371///
1372/// This type is not used in any activity, and only used as *part* of another schema.
1373///
1374#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1375#[serde_with::serde_as]
1376#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1377pub struct DiskImageTargetDetails {
1378 /// Optional. Additional licenses to assign to the image. Format: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/licenses/LICENSE_NAME Or https://www.googleapis.com/compute/beta/projects/PROJECT_ID/global/licenses/LICENSE_NAME
1379 #[serde(rename = "additionalLicenses")]
1380 pub additional_licenses: Option<Vec<String>>,
1381 /// Optional. Use to skip OS adaptation process.
1382 #[serde(rename = "dataDiskImageImport")]
1383 pub data_disk_image_import: Option<DataDiskImageImport>,
1384 /// Optional. An optional description of the image.
1385 pub description: Option<String>,
1386 /// Immutable. The encryption to apply to the image.
1387 pub encryption: Option<Encryption>,
1388 /// Optional. The name of the image family to which the new image belongs.
1389 #[serde(rename = "familyName")]
1390 pub family_name: Option<String>,
1391 /// Required. The name of the image to be created.
1392 #[serde(rename = "imageName")]
1393 pub image_name: Option<String>,
1394 /// Optional. A map of labels to associate with the image.
1395 pub labels: Option<HashMap<String, String>>,
1396 /// Optional. Use to set the parameters relevant for the OS adaptation process.
1397 #[serde(rename = "osAdaptationParameters")]
1398 pub os_adaptation_parameters: Option<ImageImportOsAdaptationParameters>,
1399 /// 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.
1400 #[serde(rename = "singleRegionStorage")]
1401 pub single_region_storage: Option<bool>,
1402 /// Required. Reference to the TargetProject resource that represents the target project in which the imported image will be created.
1403 #[serde(rename = "targetProject")]
1404 pub target_project: Option<String>,
1405}
1406
1407impl common::Part for DiskImageTargetDetails {}
1408
1409/// Describes the disk which will be migrated from the source environment. The source disk has to be unattached.
1410///
1411/// # Activities
1412///
1413/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1414/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1415///
1416/// * [locations sources disk migration jobs create projects](ProjectLocationSourceDiskMigrationJobCreateCall) (request)
1417/// * [locations sources disk migration jobs get projects](ProjectLocationSourceDiskMigrationJobGetCall) (response)
1418/// * [locations sources disk migration jobs patch projects](ProjectLocationSourceDiskMigrationJobPatchCall) (request)
1419#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1420#[serde_with::serde_as]
1421#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1422pub struct DiskMigrationJob {
1423 /// Details of the unattached AWS source disk.
1424 #[serde(rename = "awsSourceDiskDetails")]
1425 pub aws_source_disk_details: Option<AwsSourceDiskDetails>,
1426 /// Output only. The time the DiskMigrationJob resource was created.
1427 #[serde(rename = "createTime")]
1428 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1429 /// Output only. Provides details on the errors that led to the disk migration job's state in case of an error.
1430 pub errors: Option<Vec<Status>>,
1431 /// Output only. Identifier. The identifier of the DiskMigrationJob.
1432 pub name: Option<String>,
1433 /// Output only. State of the DiskMigrationJob.
1434 pub state: Option<String>,
1435 /// Output only. The disk migration steps list representing its progress.
1436 pub steps: Option<Vec<DiskMigrationStep>>,
1437 /// Required. Details of the target Disk in Compute Engine.
1438 #[serde(rename = "targetDetails")]
1439 pub target_details: Option<DiskMigrationJobTargetDetails>,
1440 /// Output only. The last time the DiskMigrationJob resource was updated.
1441 #[serde(rename = "updateTime")]
1442 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1443}
1444
1445impl common::RequestValue for DiskMigrationJob {}
1446impl common::ResponseResult for DiskMigrationJob {}
1447
1448/// Details of the target disk in Compute Engine.
1449///
1450/// This type is not used in any activity, and only used as *part* of another schema.
1451///
1452#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1453#[serde_with::serde_as]
1454#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1455pub struct DiskMigrationJobTargetDetails {
1456 /// Optional. The encryption to apply to the disk. If the DiskMigrationJob parent Source resource has an encryption, this field must be set to the same encryption key.
1457 pub encryption: Option<Encryption>,
1458 /// Optional. A map of labels to associate with the disk.
1459 pub labels: Option<HashMap<String, String>>,
1460 /// Required. The target disk.
1461 #[serde(rename = "targetDisk")]
1462 pub target_disk: Option<ComputeEngineDisk>,
1463 /// Required. The name of the resource of type TargetProject which represents the Compute Engine project in which to create the disk. Should be of the form: projects/{project}/locations/global/targetProjects/{target-project}
1464 #[serde(rename = "targetProject")]
1465 pub target_project: Option<String>,
1466}
1467
1468impl common::Part for DiskMigrationJobTargetDetails {}
1469
1470/// DiskMigrationStep holds information about the disk migration step progress.
1471///
1472/// This type is not used in any activity, and only used as *part* of another schema.
1473///
1474#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1475#[serde_with::serde_as]
1476#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1477pub struct DiskMigrationStep {
1478 /// Copying source disk snapshot step.
1479 #[serde(rename = "copyingSourceDiskSnapshot")]
1480 pub copying_source_disk_snapshot: Option<CopyingSourceDiskSnapshotStep>,
1481 /// Creating source disk snapshot step.
1482 #[serde(rename = "creatingSourceDiskSnapshot")]
1483 pub creating_source_disk_snapshot: Option<CreatingSourceDiskSnapshotStep>,
1484 /// Output only. The time the step has ended.
1485 #[serde(rename = "endTime")]
1486 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1487 /// Creating target disk step.
1488 #[serde(rename = "provisioningTargetDisk")]
1489 pub provisioning_target_disk: Option<ProvisioningTargetDiskStep>,
1490 /// Output only. The time the step has started.
1491 #[serde(rename = "startTime")]
1492 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1493}
1494
1495impl common::Part for DiskMigrationStep {}
1496
1497/// Details for a disk only migration.
1498///
1499/// This type is not used in any activity, and only used as *part* of another schema.
1500///
1501#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1502#[serde_with::serde_as]
1503#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1504pub struct DisksMigrationDisksTargetDefaults {
1505 _never_set: Option<bool>,
1506}
1507
1508impl common::Part for DisksMigrationDisksTargetDefaults {}
1509
1510/// Details for a disks-only migration.
1511///
1512/// This type is not used in any activity, and only used as *part* of another schema.
1513///
1514#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1515#[serde_with::serde_as]
1516#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1517pub struct DisksMigrationDisksTargetDetails {
1518 _never_set: Option<bool>,
1519}
1520
1521impl common::Part for DisksMigrationDisksTargetDetails {}
1522
1523/// Details for creation of a VM that migrated data disks will be attached to.
1524///
1525/// This type is not used in any activity, and only used as *part* of another schema.
1526///
1527#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1528#[serde_with::serde_as]
1529#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1530pub struct DisksMigrationVmTargetDefaults {
1531 /// Optional. Additional licenses to assign to the VM.
1532 #[serde(rename = "additionalLicenses")]
1533 pub additional_licenses: Option<Vec<String>>,
1534 /// Optional. Details of the boot disk of the VM.
1535 #[serde(rename = "bootDiskDefaults")]
1536 pub boot_disk_defaults: Option<BootDiskDefaults>,
1537 /// Optional. Compute instance scheduling information (if empty default is used).
1538 #[serde(rename = "computeScheduling")]
1539 pub compute_scheduling: Option<ComputeScheduling>,
1540 /// Optional. Defines whether the instance has integrity monitoring enabled.
1541 #[serde(rename = "enableIntegrityMonitoring")]
1542 pub enable_integrity_monitoring: Option<bool>,
1543 /// Optional. Defines whether the instance has vTPM enabled.
1544 #[serde(rename = "enableVtpm")]
1545 pub enable_vtpm: Option<bool>,
1546 /// Optional. The encryption to apply to the VM.
1547 pub encryption: Option<Encryption>,
1548 /// Optional. The hostname to assign to the VM.
1549 pub hostname: Option<String>,
1550 /// Optional. A map of labels to associate with the VM.
1551 pub labels: Option<HashMap<String, String>>,
1552 /// Required. The machine type to create the VM with.
1553 #[serde(rename = "machineType")]
1554 pub machine_type: Option<String>,
1555 /// Optional. The machine type series to create the VM with. For presentation only.
1556 #[serde(rename = "machineTypeSeries")]
1557 pub machine_type_series: Option<String>,
1558 /// Optional. The metadata key/value pairs to assign to the VM.
1559 pub metadata: Option<HashMap<String, String>>,
1560 /// Optional. NICs to attach to the VM.
1561 #[serde(rename = "networkInterfaces")]
1562 pub network_interfaces: Option<Vec<NetworkInterface>>,
1563 /// Optional. A list of network tags to associate with the VM.
1564 #[serde(rename = "networkTags")]
1565 pub network_tags: Option<Vec<String>>,
1566 /// Optional. Defines whether the instance has Secure Boot enabled. This can be set to true only if the VM boot option is EFI.
1567 #[serde(rename = "secureBoot")]
1568 pub secure_boot: Option<bool>,
1569 /// Optional. The service account to associate the VM with.
1570 #[serde(rename = "serviceAccount")]
1571 pub service_account: Option<String>,
1572 /// Required. The name of the VM to create.
1573 #[serde(rename = "vmName")]
1574 pub vm_name: Option<String>,
1575}
1576
1577impl common::Part for DisksMigrationVmTargetDefaults {}
1578
1579/// Details for the VM created VM as part of disks migration.
1580///
1581/// This type is not used in any activity, and only used as *part* of another schema.
1582///
1583#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1584#[serde_with::serde_as]
1585#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1586pub struct DisksMigrationVmTargetDetails {
1587 /// Output only. The URI of the Compute Engine VM.
1588 #[serde(rename = "vmUri")]
1589 pub vm_uri: Option<String>,
1590}
1591
1592impl common::Part for DisksMigrationVmTargetDetails {}
1593
1594/// 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); }
1595///
1596/// # Activities
1597///
1598/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1599/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1600///
1601/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
1602/// * [locations operations delete projects](ProjectLocationOperationDeleteCall) (response)
1603#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1604#[serde_with::serde_as]
1605#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1606pub struct Empty {
1607 _never_set: Option<bool>,
1608}
1609
1610impl common::ResponseResult for Empty {}
1611
1612/// Encryption message describes the details of the applied encryption.
1613///
1614/// This type is not used in any activity, and only used as *part* of another schema.
1615///
1616#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1617#[serde_with::serde_as]
1618#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1619pub struct Encryption {
1620 /// Required. The name of the encryption key that is stored in Google Cloud KMS.
1621 #[serde(rename = "kmsKey")]
1622 pub kms_key: Option<String>,
1623}
1624
1625impl common::Part for Encryption {}
1626
1627/// Expiration holds information about the expiration of a MigratingVm.
1628///
1629/// This type is not used in any activity, and only used as *part* of another schema.
1630///
1631#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1632#[serde_with::serde_as]
1633#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1634pub struct Expiration {
1635 /// Output only. Timestamp of when this resource is considered expired.
1636 #[serde(rename = "expireTime")]
1637 pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1638 /// Output only. Describes whether the expiration can be extended.
1639 pub extendable: Option<bool>,
1640 /// Output only. The number of times expiration was extended.
1641 #[serde(rename = "extensionCount")]
1642 pub extension_count: Option<i32>,
1643}
1644
1645impl common::Part for Expiration {}
1646
1647/// Request message for ‘ExtendMigrationRequest’ request.
1648///
1649/// # Activities
1650///
1651/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1652/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1653///
1654/// * [locations sources migrating vms extend migration projects](ProjectLocationSourceMigratingVmExtendMigrationCall) (request)
1655#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1656#[serde_with::serde_as]
1657#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1658pub struct ExtendMigrationRequest {
1659 _never_set: Option<bool>,
1660}
1661
1662impl common::RequestValue for ExtendMigrationRequest {}
1663
1664/// Response message for fetchInventory.
1665///
1666/// # Activities
1667///
1668/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1669/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1670///
1671/// * [locations sources fetch inventory projects](ProjectLocationSourceFetchInventoryCall) (response)
1672#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1673#[serde_with::serde_as]
1674#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1675pub struct FetchInventoryResponse {
1676 /// The description of the VMs in a Source of type AWS.
1677 #[serde(rename = "awsVms")]
1678 pub aws_vms: Option<AwsVmsDetails>,
1679 /// The description of the VMs in a Source of type Azure.
1680 #[serde(rename = "azureVms")]
1681 pub azure_vms: Option<AzureVmsDetails>,
1682 /// 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.
1683 #[serde(rename = "nextPageToken")]
1684 pub next_page_token: Option<String>,
1685 /// Output only. The timestamp when the source was last queried (if the result is from the cache).
1686 #[serde(rename = "updateTime")]
1687 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1688 /// The description of the VMs in a Source of type Vmware.
1689 #[serde(rename = "vmwareVms")]
1690 pub vmware_vms: Option<VmwareVmsDetails>,
1691}
1692
1693impl common::ResponseResult for FetchInventoryResponse {}
1694
1695/// Response message for fetchStorageInventory.
1696///
1697/// # Activities
1698///
1699/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1700/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1701///
1702/// * [locations sources fetch storage inventory projects](ProjectLocationSourceFetchStorageInventoryCall) (response)
1703#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1704#[serde_with::serde_as]
1705#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1706pub struct FetchStorageInventoryResponse {
1707 /// 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.
1708 #[serde(rename = "nextPageToken")]
1709 pub next_page_token: Option<String>,
1710 /// The list of storage resources in the source.
1711 pub resources: Option<Vec<SourceStorageResource>>,
1712 /// Output only. The timestamp when the source was last queried (if the result is from the cache).
1713 #[serde(rename = "updateTime")]
1714 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1715}
1716
1717impl common::ResponseResult for FetchStorageInventoryResponse {}
1718
1719/// Request message for ‘FinalizeMigration’ request.
1720///
1721/// # Activities
1722///
1723/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1724/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1725///
1726/// * [locations sources migrating vms finalize migration projects](ProjectLocationSourceMigratingVmFinalizeMigrationCall) (request)
1727#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1728#[serde_with::serde_as]
1729#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1730pub struct FinalizeMigrationRequest {
1731 _never_set: Option<bool>,
1732}
1733
1734impl common::RequestValue for FinalizeMigrationRequest {}
1735
1736/// Describes message for ‘Group’ resource. The Group is a collections of several MigratingVms.
1737///
1738/// # Activities
1739///
1740/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1741/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1742///
1743/// * [locations groups create projects](ProjectLocationGroupCreateCall) (request)
1744/// * [locations groups get projects](ProjectLocationGroupGetCall) (response)
1745/// * [locations groups patch projects](ProjectLocationGroupPatchCall) (request)
1746#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1747#[serde_with::serde_as]
1748#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1749pub struct Group {
1750 /// Output only. The create time timestamp.
1751 #[serde(rename = "createTime")]
1752 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1753 /// User-provided description of the group.
1754 pub description: Option<String>,
1755 /// Display name is a user defined name for this group which can be updated.
1756 #[serde(rename = "displayName")]
1757 pub display_name: Option<String>,
1758 /// Immutable. The target type of this group.
1759 #[serde(rename = "migrationTargetType")]
1760 pub migration_target_type: Option<String>,
1761 /// Output only. The Group name.
1762 pub name: Option<String>,
1763 /// Output only. The update time timestamp.
1764 #[serde(rename = "updateTime")]
1765 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1766}
1767
1768impl common::RequestValue for Group {}
1769impl common::ResponseResult for Group {}
1770
1771/// ImageImport describes the configuration of the image import to run.
1772///
1773/// # Activities
1774///
1775/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1776/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1777///
1778/// * [locations image imports create projects](ProjectLocationImageImportCreateCall) (request)
1779/// * [locations image imports get projects](ProjectLocationImageImportGetCall) (response)
1780#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1781#[serde_with::serde_as]
1782#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1783pub struct ImageImport {
1784 /// Immutable. The path to the Cloud Storage file from which the image should be imported.
1785 #[serde(rename = "cloudStorageUri")]
1786 pub cloud_storage_uri: Option<String>,
1787 /// Output only. The time the image import was created.
1788 #[serde(rename = "createTime")]
1789 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1790 /// Immutable. Target details for importing a disk image, will be used by ImageImportJob.
1791 #[serde(rename = "diskImageTargetDefaults")]
1792 pub disk_image_target_defaults: Option<DiskImageTargetDetails>,
1793 /// Immutable. The encryption details used by the image import process during the image adaptation for Compute Engine.
1794 pub encryption: Option<Encryption>,
1795 /// Immutable. Target details for importing a machine image, will be used by ImageImportJob.
1796 #[serde(rename = "machineImageTargetDefaults")]
1797 pub machine_image_target_defaults: Option<MachineImageTargetDetails>,
1798 /// Output only. The resource path of the ImageImport.
1799 pub name: Option<String>,
1800 /// Output only. The result of the most recent runs for this ImageImport. All jobs for this ImageImport can be listed via ListImageImportJobs.
1801 #[serde(rename = "recentImageImportJobs")]
1802 pub recent_image_import_jobs: Option<Vec<ImageImportJob>>,
1803}
1804
1805impl common::RequestValue for ImageImport {}
1806impl common::ResponseResult for ImageImport {}
1807
1808/// ImageImportJob describes the progress and result of an image import.
1809///
1810/// # Activities
1811///
1812/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1813/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1814///
1815/// * [locations image imports image import jobs get projects](ProjectLocationImageImportImageImportJobGetCall) (response)
1816#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1817#[serde_with::serde_as]
1818#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1819pub struct ImageImportJob {
1820 /// Output only. The path to the Cloud Storage file from which the image should be imported.
1821 #[serde(rename = "cloudStorageUri")]
1822 pub cloud_storage_uri: Option<String>,
1823 /// Output only. The time the image import was created (as an API call, not when it was actually created in the target).
1824 #[serde(rename = "createTime")]
1825 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1826 /// Output only. The resource paths of the resources created by the image import job.
1827 #[serde(rename = "createdResources")]
1828 pub created_resources: Option<Vec<String>>,
1829 /// Output only. Target details used to import a disk image.
1830 #[serde(rename = "diskImageTargetDetails")]
1831 pub disk_image_target_details: Option<DiskImageTargetDetails>,
1832 /// Output only. The time the image import was ended.
1833 #[serde(rename = "endTime")]
1834 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1835 /// Output only. Provides details on the error that led to the image import state in case of an error.
1836 pub errors: Option<Vec<Status>>,
1837 /// Output only. Target details used to import a machine image.
1838 #[serde(rename = "machineImageTargetDetails")]
1839 pub machine_image_target_details: Option<MachineImageTargetDetails>,
1840 /// Output only. The resource path of the ImageImportJob.
1841 pub name: Option<String>,
1842 /// Output only. The state of the image import.
1843 pub state: Option<String>,
1844 /// Output only. The image import steps list representing its progress.
1845 pub steps: Option<Vec<ImageImportStep>>,
1846 /// Output only. Warnings that occurred during the image import.
1847 pub warnings: Option<Vec<MigrationWarning>>,
1848}
1849
1850impl common::ResponseResult for ImageImportJob {}
1851
1852/// Parameters affecting the OS adaptation process.
1853///
1854/// This type is not used in any activity, and only used as *part* of another schema.
1855///
1856#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1857#[serde_with::serde_as]
1858#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1859pub struct ImageImportOsAdaptationParameters {
1860 /// Optional. Modifiers to be used as configuration of the OS adaptation process.
1861 #[serde(rename = "adaptationModifiers")]
1862 pub adaptation_modifiers: Option<Vec<AdaptationModifier>>,
1863 /// Optional. By default the image will keep its existing boot option. Setting this property will trigger an internal process which will convert the image from using the existing boot option to another. The size of the boot disk might be increased to allow the conversion
1864 #[serde(rename = "bootConversion")]
1865 pub boot_conversion: Option<String>,
1866 /// 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).
1867 pub generalize: Option<bool>,
1868 /// Optional. Choose which type of license to apply to the imported image.
1869 #[serde(rename = "licenseType")]
1870 pub license_type: Option<String>,
1871}
1872
1873impl common::Part for ImageImportOsAdaptationParameters {}
1874
1875/// ImageImportStep holds information about the image import step progress.
1876///
1877/// This type is not used in any activity, and only used as *part* of another schema.
1878///
1879#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1880#[serde_with::serde_as]
1881#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1882pub struct ImageImportStep {
1883 /// Adapting OS step.
1884 #[serde(rename = "adaptingOs")]
1885 pub adapting_os: Option<AdaptingOSStep>,
1886 /// Creating image step.
1887 #[serde(rename = "creatingImage")]
1888 pub creating_image: Option<CreatingImageStep>,
1889 /// Output only. The time the step has ended.
1890 #[serde(rename = "endTime")]
1891 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1892 /// Initializing step.
1893 pub initializing: Option<InitializingImageImportStep>,
1894 /// Loading source files step.
1895 #[serde(rename = "loadingSourceFiles")]
1896 pub loading_source_files: Option<LoadingImageSourceFilesStep>,
1897 /// Output only. The time the step has started.
1898 #[serde(rename = "startTime")]
1899 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1900}
1901
1902impl common::Part for ImageImportStep {}
1903
1904/// InitializingImageImportStep contains specific step details.
1905///
1906/// This type is not used in any activity, and only used as *part* of another schema.
1907///
1908#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1909#[serde_with::serde_as]
1910#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1911pub struct InitializingImageImportStep {
1912 _never_set: Option<bool>,
1913}
1914
1915impl common::Part for InitializingImageImportStep {}
1916
1917/// InitializingReplicationStep contains specific step details.
1918///
1919/// This type is not used in any activity, and only used as *part* of another schema.
1920///
1921#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1922#[serde_with::serde_as]
1923#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1924pub struct InitializingReplicationStep {
1925 _never_set: Option<bool>,
1926}
1927
1928impl common::Part for InitializingReplicationStep {}
1929
1930/// InstantiatingMigratedVMStep contains specific step details.
1931///
1932/// This type is not used in any activity, and only used as *part* of another schema.
1933///
1934#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1935#[serde_with::serde_as]
1936#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1937pub struct InstantiatingMigratedVMStep {
1938 _never_set: Option<bool>,
1939}
1940
1941impl common::Part for InstantiatingMigratedVMStep {}
1942
1943/// Describes a URL link.
1944///
1945/// This type is not used in any activity, and only used as *part* of another schema.
1946///
1947#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1948#[serde_with::serde_as]
1949#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1950pub struct Link {
1951 /// Describes what the link offers.
1952 pub description: Option<String>,
1953 /// The URL of the link.
1954 pub url: Option<String>,
1955}
1956
1957impl common::Part for Link {}
1958
1959/// Response message for ‘ListCloneJobs’ request.
1960///
1961/// # Activities
1962///
1963/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1964/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1965///
1966/// * [locations sources migrating vms clone jobs list projects](ProjectLocationSourceMigratingVmCloneJobListCall) (response)
1967#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1968#[serde_with::serde_as]
1969#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1970pub struct ListCloneJobsResponse {
1971 /// Output only. The list of clone jobs response.
1972 #[serde(rename = "cloneJobs")]
1973 pub clone_jobs: Option<Vec<CloneJob>>,
1974 /// 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.
1975 #[serde(rename = "nextPageToken")]
1976 pub next_page_token: Option<String>,
1977 /// Output only. Locations that could not be reached.
1978 pub unreachable: Option<Vec<String>>,
1979}
1980
1981impl common::ResponseResult for ListCloneJobsResponse {}
1982
1983/// Response message for ‘ListCutoverJobs’ request.
1984///
1985/// # Activities
1986///
1987/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1988/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1989///
1990/// * [locations sources migrating vms cutover jobs list projects](ProjectLocationSourceMigratingVmCutoverJobListCall) (response)
1991#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1992#[serde_with::serde_as]
1993#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1994pub struct ListCutoverJobsResponse {
1995 /// Output only. The list of cutover jobs response.
1996 #[serde(rename = "cutoverJobs")]
1997 pub cutover_jobs: Option<Vec<CutoverJob>>,
1998 /// 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.
1999 #[serde(rename = "nextPageToken")]
2000 pub next_page_token: Option<String>,
2001 /// Output only. Locations that could not be reached.
2002 pub unreachable: Option<Vec<String>>,
2003}
2004
2005impl common::ResponseResult for ListCutoverJobsResponse {}
2006
2007/// Response message for ‘ListDatacenterConnectors’ request.
2008///
2009/// # Activities
2010///
2011/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2012/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2013///
2014/// * [locations sources datacenter connectors list projects](ProjectLocationSourceDatacenterConnectorListCall) (response)
2015#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2016#[serde_with::serde_as]
2017#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2018pub struct ListDatacenterConnectorsResponse {
2019 /// Output only. The list of sources response.
2020 #[serde(rename = "datacenterConnectors")]
2021 pub datacenter_connectors: Option<Vec<DatacenterConnector>>,
2022 /// 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.
2023 #[serde(rename = "nextPageToken")]
2024 pub next_page_token: Option<String>,
2025 /// Output only. Locations that could not be reached.
2026 pub unreachable: Option<Vec<String>>,
2027}
2028
2029impl common::ResponseResult for ListDatacenterConnectorsResponse {}
2030
2031/// Response message for ‘ListDiskMigrationJobs’ request.
2032///
2033/// # Activities
2034///
2035/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2036/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2037///
2038/// * [locations sources disk migration jobs list projects](ProjectLocationSourceDiskMigrationJobListCall) (response)
2039#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2040#[serde_with::serde_as]
2041#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2042pub struct ListDiskMigrationJobsResponse {
2043 /// Output only. The list of the disk migration jobs.
2044 #[serde(rename = "diskMigrationJobs")]
2045 pub disk_migration_jobs: Option<Vec<DiskMigrationJob>>,
2046 /// Optional. 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.
2047 #[serde(rename = "nextPageToken")]
2048 pub next_page_token: Option<String>,
2049 /// Output only. Locations that could not be reached.
2050 pub unreachable: Option<Vec<String>>,
2051}
2052
2053impl common::ResponseResult for ListDiskMigrationJobsResponse {}
2054
2055/// Response message for ‘ListGroups’ request.
2056///
2057/// # Activities
2058///
2059/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2060/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2061///
2062/// * [locations groups list projects](ProjectLocationGroupListCall) (response)
2063#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2064#[serde_with::serde_as]
2065#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2066pub struct ListGroupsResponse {
2067 /// Output only. The list of groups response.
2068 pub groups: Option<Vec<Group>>,
2069 /// 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.
2070 #[serde(rename = "nextPageToken")]
2071 pub next_page_token: Option<String>,
2072 /// Output only. Locations that could not be reached.
2073 pub unreachable: Option<Vec<String>>,
2074}
2075
2076impl common::ResponseResult for ListGroupsResponse {}
2077
2078/// Response message for ‘ListImageImportJobs’ call.
2079///
2080/// # Activities
2081///
2082/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2083/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2084///
2085/// * [locations image imports image import jobs list projects](ProjectLocationImageImportImageImportJobListCall) (response)
2086#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2087#[serde_with::serde_as]
2088#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2089pub struct ListImageImportJobsResponse {
2090 /// Output only. The list of target response.
2091 #[serde(rename = "imageImportJobs")]
2092 pub image_import_jobs: Option<Vec<ImageImportJob>>,
2093 /// 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.
2094 #[serde(rename = "nextPageToken")]
2095 pub next_page_token: Option<String>,
2096 /// Output only. Locations that could not be reached.
2097 pub unreachable: Option<Vec<String>>,
2098}
2099
2100impl common::ResponseResult for ListImageImportJobsResponse {}
2101
2102/// Response message for ‘ListImageImports’ call.
2103///
2104/// # Activities
2105///
2106/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2107/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2108///
2109/// * [locations image imports list projects](ProjectLocationImageImportListCall) (response)
2110#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2111#[serde_with::serde_as]
2112#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2113pub struct ListImageImportsResponse {
2114 /// Output only. The list of target response.
2115 #[serde(rename = "imageImports")]
2116 pub image_imports: Option<Vec<ImageImport>>,
2117 /// 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.
2118 #[serde(rename = "nextPageToken")]
2119 pub next_page_token: Option<String>,
2120 /// Output only. Locations that could not be reached.
2121 pub unreachable: Option<Vec<String>>,
2122}
2123
2124impl common::ResponseResult for ListImageImportsResponse {}
2125
2126/// The response message for Locations.ListLocations.
2127///
2128/// # Activities
2129///
2130/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2131/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2132///
2133/// * [locations list projects](ProjectLocationListCall) (response)
2134#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2135#[serde_with::serde_as]
2136#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2137pub struct ListLocationsResponse {
2138 /// A list of locations that matches the specified filter in the request.
2139 pub locations: Option<Vec<Location>>,
2140 /// The standard List next-page token.
2141 #[serde(rename = "nextPageToken")]
2142 pub next_page_token: Option<String>,
2143}
2144
2145impl common::ResponseResult for ListLocationsResponse {}
2146
2147/// Response message for ‘ListMigratingVms’ request.
2148///
2149/// # Activities
2150///
2151/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2152/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2153///
2154/// * [locations sources migrating vms list projects](ProjectLocationSourceMigratingVmListCall) (response)
2155#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2156#[serde_with::serde_as]
2157#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2158pub struct ListMigratingVmsResponse {
2159 /// Output only. The list of Migrating VMs response.
2160 #[serde(rename = "migratingVms")]
2161 pub migrating_vms: Option<Vec<MigratingVm>>,
2162 /// 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.
2163 #[serde(rename = "nextPageToken")]
2164 pub next_page_token: Option<String>,
2165 /// Output only. Locations that could not be reached.
2166 pub unreachable: Option<Vec<String>>,
2167}
2168
2169impl common::ResponseResult for ListMigratingVmsResponse {}
2170
2171/// The response message for Operations.ListOperations.
2172///
2173/// # Activities
2174///
2175/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2176/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2177///
2178/// * [locations operations list projects](ProjectLocationOperationListCall) (response)
2179#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2180#[serde_with::serde_as]
2181#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2182pub struct ListOperationsResponse {
2183 /// The standard List next-page token.
2184 #[serde(rename = "nextPageToken")]
2185 pub next_page_token: Option<String>,
2186 /// A list of operations that matches the specified filter in the request.
2187 pub operations: Option<Vec<Operation>>,
2188 /// Unordered list. Unreachable resources. Populated when the request sets `ListOperationsRequest.return_partial_success` and reads across collections. For example, when attempting to list all resources across all supported locations.
2189 pub unreachable: Option<Vec<String>>,
2190}
2191
2192impl common::ResponseResult for ListOperationsResponse {}
2193
2194/// Response message for ‘ListReplicationCycles’ request.
2195///
2196/// # Activities
2197///
2198/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2199/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2200///
2201/// * [locations sources migrating vms replication cycles list projects](ProjectLocationSourceMigratingVmReplicationCycleListCall) (response)
2202#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2203#[serde_with::serde_as]
2204#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2205pub struct ListReplicationCyclesResponse {
2206 /// 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.
2207 #[serde(rename = "nextPageToken")]
2208 pub next_page_token: Option<String>,
2209 /// Output only. The list of replication cycles response.
2210 #[serde(rename = "replicationCycles")]
2211 pub replication_cycles: Option<Vec<ReplicationCycle>>,
2212 /// Output only. Locations that could not be reached.
2213 pub unreachable: Option<Vec<String>>,
2214}
2215
2216impl common::ResponseResult for ListReplicationCyclesResponse {}
2217
2218/// Response message for ‘ListSources’ request.
2219///
2220/// # Activities
2221///
2222/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2223/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2224///
2225/// * [locations sources list projects](ProjectLocationSourceListCall) (response)
2226#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2227#[serde_with::serde_as]
2228#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2229pub struct ListSourcesResponse {
2230 /// 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.
2231 #[serde(rename = "nextPageToken")]
2232 pub next_page_token: Option<String>,
2233 /// Output only. The list of sources response.
2234 pub sources: Option<Vec<Source>>,
2235 /// Output only. Locations that could not be reached.
2236 pub unreachable: Option<Vec<String>>,
2237}
2238
2239impl common::ResponseResult for ListSourcesResponse {}
2240
2241/// Response message for ‘ListTargetProjects’ call.
2242///
2243/// # Activities
2244///
2245/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2246/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2247///
2248/// * [locations target projects list projects](ProjectLocationTargetProjectListCall) (response)
2249#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2250#[serde_with::serde_as]
2251#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2252pub struct ListTargetProjectsResponse {
2253 /// 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.
2254 #[serde(rename = "nextPageToken")]
2255 pub next_page_token: Option<String>,
2256 /// Output only. The list of target response.
2257 #[serde(rename = "targetProjects")]
2258 pub target_projects: Option<Vec<TargetProject>>,
2259 /// Output only. Locations that could not be reached.
2260 pub unreachable: Option<Vec<String>>,
2261}
2262
2263impl common::ResponseResult for ListTargetProjectsResponse {}
2264
2265/// Response message for ‘ListUtilizationReports’ request.
2266///
2267/// # Activities
2268///
2269/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2270/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2271///
2272/// * [locations sources utilization reports list projects](ProjectLocationSourceUtilizationReportListCall) (response)
2273#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2274#[serde_with::serde_as]
2275#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2276pub struct ListUtilizationReportsResponse {
2277 /// 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.
2278 #[serde(rename = "nextPageToken")]
2279 pub next_page_token: Option<String>,
2280 /// Output only. Locations that could not be reached.
2281 pub unreachable: Option<Vec<String>>,
2282 /// Output only. The list of reports.
2283 #[serde(rename = "utilizationReports")]
2284 pub utilization_reports: Option<Vec<UtilizationReport>>,
2285}
2286
2287impl common::ResponseResult for ListUtilizationReportsResponse {}
2288
2289/// LoadingImageSourceFilesStep contains specific step details.
2290///
2291/// This type is not used in any activity, and only used as *part* of another schema.
2292///
2293#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2294#[serde_with::serde_as]
2295#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2296pub struct LoadingImageSourceFilesStep {
2297 _never_set: Option<bool>,
2298}
2299
2300impl common::Part for LoadingImageSourceFilesStep {}
2301
2302/// Provides a localized error message that is safe to return to the user which can be attached to an RPC error.
2303///
2304/// This type is not used in any activity, and only used as *part* of another schema.
2305///
2306#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2307#[serde_with::serde_as]
2308#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2309pub struct LocalizedMessage {
2310 /// 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"
2311 pub locale: Option<String>,
2312 /// The localized error message in the above locale.
2313 pub message: Option<String>,
2314}
2315
2316impl common::Part for LocalizedMessage {}
2317
2318/// A resource that represents a Google Cloud location.
2319///
2320/// # Activities
2321///
2322/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2323/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2324///
2325/// * [locations get projects](ProjectLocationGetCall) (response)
2326#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2327#[serde_with::serde_as]
2328#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2329pub struct Location {
2330 /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
2331 #[serde(rename = "displayName")]
2332 pub display_name: Option<String>,
2333 /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
2334 pub labels: Option<HashMap<String, String>>,
2335 /// The canonical id for this location. For example: `"us-east1"`.
2336 #[serde(rename = "locationId")]
2337 pub location_id: Option<String>,
2338 /// Service-specific metadata. For example the available capacity at the given location.
2339 pub metadata: Option<HashMap<String, serde_json::Value>>,
2340 /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
2341 pub name: Option<String>,
2342}
2343
2344impl common::ResponseResult for Location {}
2345
2346/// Parameters overriding decisions based on the source machine image configurations.
2347///
2348/// This type is not used in any activity, and only used as *part* of another schema.
2349///
2350#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2351#[serde_with::serde_as]
2352#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2353pub struct MachineImageParametersOverrides {
2354 /// Optional. The machine type to create the MachineImage with. If empty, the service will choose a relevant machine type based on the information from the source image. For more information about machine types, please refer to https://cloud.google.com/compute/docs/machine-resource.
2355 #[serde(rename = "machineType")]
2356 pub machine_type: Option<String>,
2357}
2358
2359impl common::Part for MachineImageParametersOverrides {}
2360
2361/// The target details of the machine image resource that will be created by the image import job.
2362///
2363/// This type is not used in any activity, and only used as *part* of another schema.
2364///
2365#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2366#[serde_with::serde_as]
2367#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2368pub struct MachineImageTargetDetails {
2369 /// Optional. Additional licenses to assign to the instance created by the machine image. Format: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/licenses/LICENSE_NAME Or https://www.googleapis.com/compute/beta/projects/PROJECT_ID/global/licenses/LICENSE_NAME
2370 #[serde(rename = "additionalLicenses")]
2371 pub additional_licenses: Option<Vec<String>>,
2372 /// Optional. An optional description of the machine image.
2373 pub description: Option<String>,
2374 /// Immutable. The encryption to apply to the machine image. If the Image Import resource has an encryption, this field must be set to the same encryption key.
2375 pub encryption: Option<Encryption>,
2376 /// Optional. The labels to apply to the instance created by the machine image.
2377 pub labels: Option<HashMap<String, String>>,
2378 /// Required. The name of the machine image to be created.
2379 #[serde(rename = "machineImageName")]
2380 pub machine_image_name: Option<String>,
2381 /// Optional. Parameters overriding decisions based on the source machine image configurations.
2382 #[serde(rename = "machineImageParametersOverrides")]
2383 pub machine_image_parameters_overrides: Option<MachineImageParametersOverrides>,
2384 /// Optional. The network interfaces to create with the instance created by the machine image. Internal and external IP addresses, and network tiers are ignored for machine image import.
2385 #[serde(rename = "networkInterfaces")]
2386 pub network_interfaces: Option<Vec<NetworkInterface>>,
2387 /// Optional. Use to set the parameters relevant for the OS adaptation process.
2388 #[serde(rename = "osAdaptationParameters")]
2389 pub os_adaptation_parameters: Option<ImageImportOsAdaptationParameters>,
2390 /// Optional. The service account to assign to the instance created by the machine image.
2391 #[serde(rename = "serviceAccount")]
2392 pub service_account: Option<ServiceAccount>,
2393 /// Optional. Shielded instance configuration.
2394 #[serde(rename = "shieldedInstanceConfig")]
2395 pub shielded_instance_config: Option<ShieldedInstanceConfig>,
2396 /// Optional. Set to true to set the machine image storageLocations to the single region of the import job. When false, the closest multi-region is selected.
2397 #[serde(rename = "singleRegionStorage")]
2398 pub single_region_storage: Option<bool>,
2399 /// Optional. Use to skip OS adaptation process.
2400 #[serde(rename = "skipOsAdaptation")]
2401 pub skip_os_adaptation: Option<SkipOsAdaptation>,
2402 /// Optional. The tags to apply to the instance created by the machine image.
2403 pub tags: Option<Vec<String>>,
2404 /// Required. Reference to the TargetProject resource that represents the target project in which the imported machine image will be created.
2405 #[serde(rename = "targetProject")]
2406 pub target_project: Option<String>,
2407}
2408
2409impl common::Part for MachineImageTargetDetails {}
2410
2411/// MigratingVm describes the VM that will be migrated from a Source environment and its replication state.
2412///
2413/// # Activities
2414///
2415/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2416/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2417///
2418/// * [locations sources migrating vms create projects](ProjectLocationSourceMigratingVmCreateCall) (request)
2419/// * [locations sources migrating vms get projects](ProjectLocationSourceMigratingVmGetCall) (response)
2420/// * [locations sources migrating vms patch projects](ProjectLocationSourceMigratingVmPatchCall) (request)
2421#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2422#[serde_with::serde_as]
2423#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2424pub struct MigratingVm {
2425 /// Output only. Details of the VM from an AWS source.
2426 #[serde(rename = "awsSourceVmDetails")]
2427 pub aws_source_vm_details: Option<AwsSourceVmDetails>,
2428 /// Output only. Details of the VM from an Azure source.
2429 #[serde(rename = "azureSourceVmDetails")]
2430 pub azure_source_vm_details: Option<AzureSourceVmDetails>,
2431 /// Details of the target Persistent Disks in Compute Engine.
2432 #[serde(rename = "computeEngineDisksTargetDefaults")]
2433 pub compute_engine_disks_target_defaults: Option<ComputeEngineDisksTargetDefaults>,
2434 /// Details of the target VM in Compute Engine.
2435 #[serde(rename = "computeEngineTargetDefaults")]
2436 pub compute_engine_target_defaults: Option<ComputeEngineTargetDefaults>,
2437 /// 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).
2438 #[serde(rename = "createTime")]
2439 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2440 /// Output only. Details of the current running replication cycle.
2441 #[serde(rename = "currentSyncInfo")]
2442 pub current_sync_info: Option<ReplicationCycle>,
2443 /// Output only. Provides details of future CutoverJobs of a MigratingVm. Set to empty when cutover forecast is unavailable.
2444 #[serde(rename = "cutoverForecast")]
2445 pub cutover_forecast: Option<CutoverForecast>,
2446 /// The description attached to the migrating VM by the user.
2447 pub description: Option<String>,
2448 /// The display name attached to the MigratingVm by the user.
2449 #[serde(rename = "displayName")]
2450 pub display_name: Option<String>,
2451 /// Output only. Provides details on the state of the Migrating VM in case of an error in replication.
2452 pub error: Option<Status>,
2453 /// Output only. Provides details about the expiration state of the migrating VM.
2454 pub expiration: Option<Expiration>,
2455 /// 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.
2456 pub group: Option<String>,
2457 /// The labels of the migrating VM.
2458 pub labels: Option<HashMap<String, String>>,
2459 /// 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.
2460 #[serde(rename = "lastReplicationCycle")]
2461 pub last_replication_cycle: Option<ReplicationCycle>,
2462 /// Output only. The most updated snapshot created time in the source that finished replication.
2463 #[serde(rename = "lastSync")]
2464 pub last_sync: Option<ReplicationSync>,
2465 /// Output only. The identifier of the MigratingVm.
2466 pub name: Option<String>,
2467 /// The replication schedule policy.
2468 pub policy: Option<SchedulePolicy>,
2469 /// 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.
2470 #[serde(rename = "recentCloneJobs")]
2471 pub recent_clone_jobs: Option<Vec<CloneJob>>,
2472 /// 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.
2473 #[serde(rename = "recentCutoverJobs")]
2474 pub recent_cutover_jobs: Option<Vec<CutoverJob>>,
2475 /// 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-.
2476 #[serde(rename = "sourceVmId")]
2477 pub source_vm_id: Option<String>,
2478 /// Output only. State of the MigratingVm.
2479 pub state: Option<String>,
2480 /// Output only. The last time the migrating VM state was updated.
2481 #[serde(rename = "stateTime")]
2482 pub state_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2483 /// Output only. The last time the migrating VM resource was updated.
2484 #[serde(rename = "updateTime")]
2485 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2486 /// Output only. Details of the VM from a Vmware source.
2487 #[serde(rename = "vmwareSourceVmDetails")]
2488 pub vmware_source_vm_details: Option<VmwareSourceVmDetails>,
2489}
2490
2491impl common::RequestValue for MigratingVm {}
2492impl common::ResponseResult for MigratingVm {}
2493
2494/// 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.
2495///
2496/// This type is not used in any activity, and only used as *part* of another schema.
2497///
2498#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2499#[serde_with::serde_as]
2500#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2501pub struct MigrationWarning {
2502 /// Output only. Suggested action for solving the warning.
2503 #[serde(rename = "actionItem")]
2504 pub action_item: Option<LocalizedMessage>,
2505 /// The warning code.
2506 pub code: Option<String>,
2507 /// Output only. URL(s) pointing to additional information on handling the current warning.
2508 #[serde(rename = "helpLinks")]
2509 pub help_links: Option<Vec<Link>>,
2510 /// Output only. The localized warning message.
2511 #[serde(rename = "warningMessage")]
2512 pub warning_message: Option<LocalizedMessage>,
2513 /// The time the warning occurred.
2514 #[serde(rename = "warningTime")]
2515 pub warning_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2516}
2517
2518impl common::Part for MigrationWarning {}
2519
2520/// NetworkInterface represents a NIC of a VM.
2521///
2522/// This type is not used in any activity, and only used as *part* of another schema.
2523///
2524#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2525#[serde_with::serde_as]
2526#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2527pub struct NetworkInterface {
2528 /// Optional. The external IP to define in the NIC.
2529 #[serde(rename = "externalIp")]
2530 pub external_ip: Option<String>,
2531 /// Optional. The internal IP to define in the NIC. The formats accepted are: `ephemeral` \ ipv4 address \ a named address resource full path.
2532 #[serde(rename = "internalIp")]
2533 pub internal_ip: Option<String>,
2534 /// Optional. The network to connect the NIC to.
2535 pub network: Option<String>,
2536 /// Optional. The networking tier used for optimizing connectivity between instances and systems on the internet. Applies only for external ephemeral IP addresses. If left empty, will default to PREMIUM.
2537 #[serde(rename = "networkTier")]
2538 pub network_tier: Option<String>,
2539 /// Optional. The subnetwork to connect the NIC to.
2540 pub subnetwork: Option<String>,
2541}
2542
2543impl common::Part for NetworkInterface {}
2544
2545/// A message describing the VM's OS. Including OS, Publisher, Offer and Plan if applicable.
2546///
2547/// This type is not used in any activity, and only used as *part* of another schema.
2548///
2549#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2550#[serde_with::serde_as]
2551#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2552pub struct OSDescription {
2553 /// OS offer.
2554 pub offer: Option<String>,
2555 /// OS plan.
2556 pub plan: Option<String>,
2557 /// OS publisher.
2558 pub publisher: Option<String>,
2559 /// OS type.
2560 #[serde(rename = "type")]
2561 pub type_: Option<String>,
2562}
2563
2564impl common::Part for OSDescription {}
2565
2566/// A message describing the OS disk.
2567///
2568/// This type is not used in any activity, and only used as *part* of another schema.
2569///
2570#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2571#[serde_with::serde_as]
2572#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2573pub struct OSDisk {
2574 /// The disk's full name.
2575 pub name: Option<String>,
2576 /// The disk's size in GB.
2577 #[serde(rename = "sizeGb")]
2578 pub size_gb: Option<i32>,
2579 /// The disk's type.
2580 #[serde(rename = "type")]
2581 pub type_: Option<String>,
2582}
2583
2584impl common::Part for OSDisk {}
2585
2586/// This resource represents a long-running operation that is the result of a network API call.
2587///
2588/// # Activities
2589///
2590/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2591/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2592///
2593/// * [locations groups add group migration projects](ProjectLocationGroupAddGroupMigrationCall) (response)
2594/// * [locations groups create projects](ProjectLocationGroupCreateCall) (response)
2595/// * [locations groups delete projects](ProjectLocationGroupDeleteCall) (response)
2596/// * [locations groups patch projects](ProjectLocationGroupPatchCall) (response)
2597/// * [locations groups remove group migration projects](ProjectLocationGroupRemoveGroupMigrationCall) (response)
2598/// * [locations image imports image import jobs cancel projects](ProjectLocationImageImportImageImportJobCancelCall) (response)
2599/// * [locations image imports create projects](ProjectLocationImageImportCreateCall) (response)
2600/// * [locations image imports delete projects](ProjectLocationImageImportDeleteCall) (response)
2601/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
2602/// * [locations sources datacenter connectors create projects](ProjectLocationSourceDatacenterConnectorCreateCall) (response)
2603/// * [locations sources datacenter connectors delete projects](ProjectLocationSourceDatacenterConnectorDeleteCall) (response)
2604/// * [locations sources datacenter connectors upgrade appliance projects](ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall) (response)
2605/// * [locations sources disk migration jobs cancel projects](ProjectLocationSourceDiskMigrationJobCancelCall) (response)
2606/// * [locations sources disk migration jobs create projects](ProjectLocationSourceDiskMigrationJobCreateCall) (response)
2607/// * [locations sources disk migration jobs delete projects](ProjectLocationSourceDiskMigrationJobDeleteCall) (response)
2608/// * [locations sources disk migration jobs patch projects](ProjectLocationSourceDiskMigrationJobPatchCall) (response)
2609/// * [locations sources disk migration jobs run projects](ProjectLocationSourceDiskMigrationJobRunCall) (response)
2610/// * [locations sources migrating vms clone jobs cancel projects](ProjectLocationSourceMigratingVmCloneJobCancelCall) (response)
2611/// * [locations sources migrating vms clone jobs create projects](ProjectLocationSourceMigratingVmCloneJobCreateCall) (response)
2612/// * [locations sources migrating vms cutover jobs cancel projects](ProjectLocationSourceMigratingVmCutoverJobCancelCall) (response)
2613/// * [locations sources migrating vms cutover jobs create projects](ProjectLocationSourceMigratingVmCutoverJobCreateCall) (response)
2614/// * [locations sources migrating vms create projects](ProjectLocationSourceMigratingVmCreateCall) (response)
2615/// * [locations sources migrating vms delete projects](ProjectLocationSourceMigratingVmDeleteCall) (response)
2616/// * [locations sources migrating vms extend migration projects](ProjectLocationSourceMigratingVmExtendMigrationCall) (response)
2617/// * [locations sources migrating vms finalize migration projects](ProjectLocationSourceMigratingVmFinalizeMigrationCall) (response)
2618/// * [locations sources migrating vms patch projects](ProjectLocationSourceMigratingVmPatchCall) (response)
2619/// * [locations sources migrating vms pause migration projects](ProjectLocationSourceMigratingVmPauseMigrationCall) (response)
2620/// * [locations sources migrating vms resume migration projects](ProjectLocationSourceMigratingVmResumeMigrationCall) (response)
2621/// * [locations sources migrating vms start migration projects](ProjectLocationSourceMigratingVmStartMigrationCall) (response)
2622/// * [locations sources utilization reports create projects](ProjectLocationSourceUtilizationReportCreateCall) (response)
2623/// * [locations sources utilization reports delete projects](ProjectLocationSourceUtilizationReportDeleteCall) (response)
2624/// * [locations sources create projects](ProjectLocationSourceCreateCall) (response)
2625/// * [locations sources delete projects](ProjectLocationSourceDeleteCall) (response)
2626/// * [locations sources patch projects](ProjectLocationSourcePatchCall) (response)
2627/// * [locations target projects create projects](ProjectLocationTargetProjectCreateCall) (response)
2628/// * [locations target projects delete projects](ProjectLocationTargetProjectDeleteCall) (response)
2629/// * [locations target projects patch projects](ProjectLocationTargetProjectPatchCall) (response)
2630#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2631#[serde_with::serde_as]
2632#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2633pub struct Operation {
2634 /// 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.
2635 pub done: Option<bool>,
2636 /// The error result of the operation in case of failure or cancellation.
2637 pub error: Option<Status>,
2638 /// 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.
2639 pub metadata: Option<HashMap<String, serde_json::Value>>,
2640 /// 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}`.
2641 pub name: Option<String>,
2642 /// 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`.
2643 pub response: Option<HashMap<String, serde_json::Value>>,
2644}
2645
2646impl common::ResponseResult for Operation {}
2647
2648/// Request message for ‘PauseMigration’ request.
2649///
2650/// # Activities
2651///
2652/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2653/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2654///
2655/// * [locations sources migrating vms pause migration projects](ProjectLocationSourceMigratingVmPauseMigrationCall) (request)
2656#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2657#[serde_with::serde_as]
2658#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2659pub struct PauseMigrationRequest {
2660 _never_set: Option<bool>,
2661}
2662
2663impl common::RequestValue for PauseMigrationRequest {}
2664
2665/// Details of a created Persistent Disk.
2666///
2667/// This type is not used in any activity, and only used as *part* of another schema.
2668///
2669#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2670#[serde_with::serde_as]
2671#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2672pub struct PersistentDisk {
2673 /// The URI of the Persistent Disk.
2674 #[serde(rename = "diskUri")]
2675 pub disk_uri: Option<String>,
2676 /// The ordinal number of the source VM disk.
2677 #[serde(rename = "sourceDiskNumber")]
2678 pub source_disk_number: Option<i32>,
2679}
2680
2681impl common::Part for PersistentDisk {}
2682
2683/// Details for creation of a Persistent Disk.
2684///
2685/// This type is not used in any activity, and only used as *part* of another schema.
2686///
2687#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2688#[serde_with::serde_as]
2689#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2690pub struct PersistentDiskDefaults {
2691 /// A map of labels to associate with the Persistent Disk.
2692 #[serde(rename = "additionalLabels")]
2693 pub additional_labels: Option<HashMap<String, String>>,
2694 /// Optional. The name of the Persistent Disk to create.
2695 #[serde(rename = "diskName")]
2696 pub disk_name: Option<String>,
2697 /// The disk type to use.
2698 #[serde(rename = "diskType")]
2699 pub disk_type: Option<String>,
2700 /// Optional. The encryption to apply to the disk.
2701 pub encryption: Option<Encryption>,
2702 /// Required. The ordinal number of the source VM disk.
2703 #[serde(rename = "sourceDiskNumber")]
2704 pub source_disk_number: Option<i32>,
2705 /// Optional. Details for attachment of the disk to a VM. Used when the disk is set to be attached to a target VM.
2706 #[serde(rename = "vmAttachmentDetails")]
2707 pub vm_attachment_details: Option<VmAttachmentDetails>,
2708}
2709
2710impl common::Part for PersistentDiskDefaults {}
2711
2712/// PostProcessingStep contains specific step details.
2713///
2714/// This type is not used in any activity, and only used as *part* of another schema.
2715///
2716#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2717#[serde_with::serde_as]
2718#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2719pub struct PostProcessingStep {
2720 _never_set: Option<bool>,
2721}
2722
2723impl common::Part for PostProcessingStep {}
2724
2725/// PreparingVMDisksStep contains specific step details.
2726///
2727/// This type is not used in any activity, and only used as *part* of another schema.
2728///
2729#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2730#[serde_with::serde_as]
2731#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2732pub struct PreparingVMDisksStep {
2733 _never_set: Option<bool>,
2734}
2735
2736impl common::Part for PreparingVMDisksStep {}
2737
2738/// ProvisioningTargetDiskStep contains specific step details.
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 ProvisioningTargetDiskStep {
2746 _never_set: Option<bool>,
2747}
2748
2749impl common::Part for ProvisioningTargetDiskStep {}
2750
2751/// Request message for ‘RemoveMigration’ request.
2752///
2753/// # Activities
2754///
2755/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2756/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2757///
2758/// * [locations groups remove group migration projects](ProjectLocationGroupRemoveGroupMigrationCall) (request)
2759#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2760#[serde_with::serde_as]
2761#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2762pub struct RemoveGroupMigrationRequest {
2763 /// The MigratingVm to remove.
2764 #[serde(rename = "migratingVm")]
2765 pub migrating_vm: Option<String>,
2766}
2767
2768impl common::RequestValue for RemoveGroupMigrationRequest {}
2769
2770/// ReplicatingStep contains specific step details.
2771///
2772/// This type is not used in any activity, and only used as *part* of another schema.
2773///
2774#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2775#[serde_with::serde_as]
2776#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2777pub struct ReplicatingStep {
2778 /// The source disks replication rate for the last 30 minutes in bytes per second.
2779 #[serde(rename = "lastThirtyMinutesAverageBytesPerSecond")]
2780 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2781 pub last_thirty_minutes_average_bytes_per_second: Option<i64>,
2782 /// The source disks replication rate for the last 2 minutes in bytes per second.
2783 #[serde(rename = "lastTwoMinutesAverageBytesPerSecond")]
2784 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2785 pub last_two_minutes_average_bytes_per_second: Option<i64>,
2786 /// Replicated bytes in the step.
2787 #[serde(rename = "replicatedBytes")]
2788 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2789 pub replicated_bytes: Option<i64>,
2790 /// Total bytes to be handled in the step.
2791 #[serde(rename = "totalBytes")]
2792 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2793 pub total_bytes: Option<i64>,
2794}
2795
2796impl common::Part for ReplicatingStep {}
2797
2798/// ReplicationCycle contains information about the current replication cycle status.
2799///
2800/// # Activities
2801///
2802/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2803/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2804///
2805/// * [locations sources migrating vms replication cycles get projects](ProjectLocationSourceMigratingVmReplicationCycleGetCall) (response)
2806#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2807#[serde_with::serde_as]
2808#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2809pub struct ReplicationCycle {
2810 /// The cycle's ordinal number.
2811 #[serde(rename = "cycleNumber")]
2812 pub cycle_number: Option<i32>,
2813 /// The time the replication cycle has ended.
2814 #[serde(rename = "endTime")]
2815 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2816 /// Output only. Provides details on the state of the cycle in case of an error.
2817 pub error: Option<Status>,
2818 /// The identifier of the ReplicationCycle.
2819 pub name: Option<String>,
2820 /// The current progress in percentage of this cycle. Was replaced by 'steps' field, which breaks down the cycle progression more accurately.
2821 #[serde(rename = "progressPercent")]
2822 pub progress_percent: Option<i32>,
2823 /// The time the replication cycle has started.
2824 #[serde(rename = "startTime")]
2825 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2826 /// State of the ReplicationCycle.
2827 pub state: Option<String>,
2828 /// The cycle's steps list representing its progress.
2829 pub steps: Option<Vec<CycleStep>>,
2830 /// The accumulated duration the replication cycle was paused.
2831 #[serde(rename = "totalPauseDuration")]
2832 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
2833 pub total_pause_duration: Option<chrono::Duration>,
2834 /// Output only. Warnings that occurred during the cycle.
2835 pub warnings: Option<Vec<MigrationWarning>>,
2836}
2837
2838impl common::ResponseResult for ReplicationCycle {}
2839
2840/// ReplicationSync contain information about the last replica sync to the cloud.
2841///
2842/// This type is not used in any activity, and only used as *part* of another schema.
2843///
2844#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2845#[serde_with::serde_as]
2846#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2847pub struct ReplicationSync {
2848 /// The most updated snapshot created time in the source that finished replication.
2849 #[serde(rename = "lastSyncTime")]
2850 pub last_sync_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2851}
2852
2853impl common::Part for ReplicationSync {}
2854
2855/// Request message for ‘ResumeMigration’ request.
2856///
2857/// # Activities
2858///
2859/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2860/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2861///
2862/// * [locations sources migrating vms resume migration projects](ProjectLocationSourceMigratingVmResumeMigrationCall) (request)
2863#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2864#[serde_with::serde_as]
2865#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2866pub struct ResumeMigrationRequest {
2867 _never_set: Option<bool>,
2868}
2869
2870impl common::RequestValue for ResumeMigrationRequest {}
2871
2872/// Request message for ‘RunDiskMigrationJobRequest’ request.
2873///
2874/// # Activities
2875///
2876/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2877/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2878///
2879/// * [locations sources disk migration jobs run projects](ProjectLocationSourceDiskMigrationJobRunCall) (request)
2880#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2881#[serde_with::serde_as]
2882#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2883pub struct RunDiskMigrationJobRequest {
2884 _never_set: Option<bool>,
2885}
2886
2887impl common::RequestValue for RunDiskMigrationJobRequest {}
2888
2889/// A policy for scheduling replications.
2890///
2891/// This type is not used in any activity, and only used as *part* of another schema.
2892///
2893#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2894#[serde_with::serde_as]
2895#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2896pub struct SchedulePolicy {
2897 /// The idle duration between replication stages.
2898 #[serde(rename = "idleDuration")]
2899 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
2900 pub idle_duration: Option<chrono::Duration>,
2901 /// 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.
2902 #[serde(rename = "skipOsAdaptation")]
2903 pub skip_os_adaptation: Option<bool>,
2904}
2905
2906impl common::Part for SchedulePolicy {}
2907
2908/// 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
2909///
2910/// This type is not used in any activity, and only used as *part* of another schema.
2911///
2912#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2913#[serde_with::serde_as]
2914#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2915pub struct SchedulingNodeAffinity {
2916 /// The label key of Node resource to reference.
2917 pub key: Option<String>,
2918 /// The operator to use for the node resources specified in the `values` parameter.
2919 pub operator: Option<String>,
2920 /// Corresponds to the label values of Node resource.
2921 pub values: Option<Vec<String>>,
2922}
2923
2924impl common::Part for SchedulingNodeAffinity {}
2925
2926/// Service account to assign to the instance created by the machine image.
2927///
2928/// This type is not used in any activity, and only used as *part* of another schema.
2929///
2930#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2931#[serde_with::serde_as]
2932#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2933pub struct ServiceAccount {
2934 /// Required. The email address of the service account.
2935 pub email: Option<String>,
2936 /// Optional. The list of scopes to be made available for this service account.
2937 pub scopes: Option<Vec<String>>,
2938}
2939
2940impl common::Part for ServiceAccount {}
2941
2942/// Shielded instance configuration.
2943///
2944/// This type is not used in any activity, and only used as *part* of another schema.
2945///
2946#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2947#[serde_with::serde_as]
2948#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2949pub struct ShieldedInstanceConfig {
2950 /// Optional. Defines whether the instance created by the machine image has integrity monitoring enabled. This can be set to true only if the image boot option is EFI, and vTPM is enabled.
2951 #[serde(rename = "enableIntegrityMonitoring")]
2952 pub enable_integrity_monitoring: Option<bool>,
2953 /// Optional. Defines whether the instance created by the machine image has vTPM enabled. This can be set to true only if the image boot option is EFI.
2954 #[serde(rename = "enableVtpm")]
2955 pub enable_vtpm: Option<bool>,
2956 /// Optional. Defines whether the instance created by the machine image has Secure Boot enabled. This can be set to true only if the image boot option is EFI.
2957 #[serde(rename = "secureBoot")]
2958 pub secure_boot: Option<String>,
2959}
2960
2961impl common::Part for ShieldedInstanceConfig {}
2962
2963/// ShuttingDownSourceVMStep contains specific step details.
2964///
2965/// This type is not used in any activity, and only used as *part* of another schema.
2966///
2967#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2968#[serde_with::serde_as]
2969#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2970pub struct ShuttingDownSourceVMStep {
2971 _never_set: Option<bool>,
2972}
2973
2974impl common::Part for ShuttingDownSourceVMStep {}
2975
2976/// Mentions that the machine image import is not using OS adaptation process.
2977///
2978/// This type is not used in any activity, and only used as *part* of another schema.
2979///
2980#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2981#[serde_with::serde_as]
2982#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2983pub struct SkipOsAdaptation {
2984 _never_set: Option<bool>,
2985}
2986
2987impl common::Part for SkipOsAdaptation {}
2988
2989/// Source message describes a specific vm migration Source resource. It contains the source environment information.
2990///
2991/// # Activities
2992///
2993/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2994/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2995///
2996/// * [locations sources create projects](ProjectLocationSourceCreateCall) (request)
2997/// * [locations sources get projects](ProjectLocationSourceGetCall) (response)
2998/// * [locations sources patch projects](ProjectLocationSourcePatchCall) (request)
2999#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3000#[serde_with::serde_as]
3001#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3002pub struct Source {
3003 /// AWS type source details.
3004 pub aws: Option<AwsSourceDetails>,
3005 /// Azure type source details.
3006 pub azure: Option<AzureSourceDetails>,
3007 /// Output only. The create time timestamp.
3008 #[serde(rename = "createTime")]
3009 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3010 /// User-provided description of the source.
3011 pub description: Option<String>,
3012 /// Optional. Immutable. The encryption details of the source data stored by the service.
3013 pub encryption: Option<Encryption>,
3014 /// The labels of the source.
3015 pub labels: Option<HashMap<String, String>>,
3016 /// Output only. The Source name.
3017 pub name: Option<String>,
3018 /// Output only. The update time timestamp.
3019 #[serde(rename = "updateTime")]
3020 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3021 /// Vmware type source details.
3022 pub vmware: Option<VmwareSourceDetails>,
3023}
3024
3025impl common::RequestValue for Source {}
3026impl common::ResponseResult for Source {}
3027
3028/// SourceStorageResource describes a storage resource in the source.
3029///
3030/// This type is not used in any activity, and only used as *part* of another schema.
3031///
3032#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3033#[serde_with::serde_as]
3034#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3035pub struct SourceStorageResource {
3036 /// Source AWS volume details.
3037 #[serde(rename = "awsDiskDetails")]
3038 pub aws_disk_details: Option<AwsSourceDiskDetails>,
3039}
3040
3041impl common::Part for SourceStorageResource {}
3042
3043/// Request message for ‘StartMigrationRequest’ request.
3044///
3045/// # Activities
3046///
3047/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3048/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3049///
3050/// * [locations sources migrating vms start migration projects](ProjectLocationSourceMigratingVmStartMigrationCall) (request)
3051#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3052#[serde_with::serde_as]
3053#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3054pub struct StartMigrationRequest {
3055 _never_set: Option<bool>,
3056}
3057
3058impl common::RequestValue for StartMigrationRequest {}
3059
3060/// 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).
3061///
3062/// This type is not used in any activity, and only used as *part* of another schema.
3063///
3064#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3065#[serde_with::serde_as]
3066#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3067pub struct Status {
3068 /// The status code, which should be an enum value of google.rpc.Code.
3069 pub code: Option<i32>,
3070 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
3071 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
3072 /// 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.
3073 pub message: Option<String>,
3074}
3075
3076impl common::Part for Status {}
3077
3078/// Tag is an AWS tag representation.
3079///
3080/// This type is not used in any activity, and only used as *part* of another schema.
3081///
3082#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3083#[serde_with::serde_as]
3084#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3085pub struct Tag {
3086 /// Required. Key of tag.
3087 pub key: Option<String>,
3088 /// Required. Value of tag.
3089 pub value: Option<String>,
3090}
3091
3092impl common::Part for Tag {}
3093
3094/// TargetProject message represents a target Compute Engine project for a migration or a clone.
3095///
3096/// # Activities
3097///
3098/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3099/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3100///
3101/// * [locations target projects create projects](ProjectLocationTargetProjectCreateCall) (request)
3102/// * [locations target projects get projects](ProjectLocationTargetProjectGetCall) (response)
3103/// * [locations target projects patch projects](ProjectLocationTargetProjectPatchCall) (request)
3104#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3105#[serde_with::serde_as]
3106#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3107pub struct TargetProject {
3108 /// Output only. The time this target project resource was created (not related to when the Compute Engine project it points to was created).
3109 #[serde(rename = "createTime")]
3110 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3111 /// The target project's description.
3112 pub description: Option<String>,
3113 /// Output only. The name of the target project.
3114 pub name: Option<String>,
3115 /// Required. The target project ID (number) or project name.
3116 pub project: Option<String>,
3117 /// Output only. The last time the target project resource was updated.
3118 #[serde(rename = "updateTime")]
3119 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3120}
3121
3122impl common::RequestValue for TargetProject {}
3123impl common::ResponseResult for TargetProject {}
3124
3125/// Request message for ‘UpgradeAppliance’ request.
3126///
3127/// # Activities
3128///
3129/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3130/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3131///
3132/// * [locations sources datacenter connectors upgrade appliance projects](ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall) (request)
3133#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3134#[serde_with::serde_as]
3135#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3136pub struct UpgradeApplianceRequest {
3137 /// 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).
3138 #[serde(rename = "requestId")]
3139 pub request_id: Option<String>,
3140}
3141
3142impl common::RequestValue for UpgradeApplianceRequest {}
3143
3144/// UpgradeStatus contains information about upgradeAppliance operation.
3145///
3146/// This type is not used in any activity, and only used as *part* of another schema.
3147///
3148#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3149#[serde_with::serde_as]
3150#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3151pub struct UpgradeStatus {
3152 /// Output only. Provides details on the state of the upgrade operation in case of an error.
3153 pub error: Option<Status>,
3154 /// The version from which we upgraded.
3155 #[serde(rename = "previousVersion")]
3156 pub previous_version: Option<String>,
3157 /// The time the operation was started.
3158 #[serde(rename = "startTime")]
3159 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3160 /// The state of the upgradeAppliance operation.
3161 pub state: Option<String>,
3162 /// The version to upgrade to.
3163 pub version: Option<String>,
3164}
3165
3166impl common::Part for UpgradeStatus {}
3167
3168/// Utilization report details the utilization (CPU, memory, etc.) of selected source VMs.
3169///
3170/// # Activities
3171///
3172/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3173/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3174///
3175/// * [locations sources utilization reports create projects](ProjectLocationSourceUtilizationReportCreateCall) (request)
3176/// * [locations sources utilization reports get projects](ProjectLocationSourceUtilizationReportGetCall) (response)
3177#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3178#[serde_with::serde_as]
3179#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3180pub struct UtilizationReport {
3181 /// Output only. The time the report was created (this refers to the time of the request, not the time the report creation completed).
3182 #[serde(rename = "createTime")]
3183 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3184 /// The report display name, as assigned by the user.
3185 #[serde(rename = "displayName")]
3186 pub display_name: Option<String>,
3187 /// Output only. Provides details on the state of the report in case of an error.
3188 pub error: Option<Status>,
3189 /// 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.
3190 #[serde(rename = "frameEndTime")]
3191 pub frame_end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3192 /// Output only. The report unique name.
3193 pub name: Option<String>,
3194 /// Output only. Current state of the report.
3195 pub state: Option<String>,
3196 /// Output only. The time the state was last set.
3197 #[serde(rename = "stateTime")]
3198 pub state_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3199 /// Time frame of the report.
3200 #[serde(rename = "timeFrame")]
3201 pub time_frame: Option<String>,
3202 /// Output only. Total number of VMs included in the report.
3203 #[serde(rename = "vmCount")]
3204 pub vm_count: Option<i32>,
3205 /// 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.
3206 pub vms: Option<Vec<VmUtilizationInfo>>,
3207}
3208
3209impl common::RequestValue for UtilizationReport {}
3210impl common::ResponseResult for UtilizationReport {}
3211
3212/// Details for attachment of the disk to a VM.
3213///
3214/// This type is not used in any activity, and only used as *part* of another schema.
3215///
3216#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3217#[serde_with::serde_as]
3218#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3219pub struct VmAttachmentDetails {
3220 /// 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.
3221 #[serde(rename = "deviceName")]
3222 pub device_name: Option<String>,
3223}
3224
3225impl common::Part for VmAttachmentDetails {}
3226
3227/// Migrating VM source information about the VM capabilities needed for some Compute Engine features.
3228///
3229/// This type is not used in any activity, and only used as *part* of another schema.
3230///
3231#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3232#[serde_with::serde_as]
3233#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3234pub struct VmCapabilities {
3235 /// Output only. The last time OS capabilities list was updated.
3236 #[serde(rename = "lastOsCapabilitiesUpdateTime")]
3237 pub last_os_capabilities_update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3238 /// Output only. Unordered list. List of certain VM OS capabilities needed for some Compute Engine features.
3239 #[serde(rename = "osCapabilities")]
3240 pub os_capabilities: Option<Vec<String>>,
3241}
3242
3243impl common::Part for VmCapabilities {}
3244
3245/// Utilization information of a single VM.
3246///
3247/// This type is not used in any activity, and only used as *part* of another schema.
3248///
3249#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3250#[serde_with::serde_as]
3251#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3252pub struct VmUtilizationInfo {
3253 /// Utilization metrics for this VM.
3254 pub utilization: Option<VmUtilizationMetrics>,
3255 /// The VM's ID in the source.
3256 #[serde(rename = "vmId")]
3257 pub vm_id: Option<String>,
3258 /// The description of the VM in a Source of type Vmware.
3259 #[serde(rename = "vmwareVmDetails")]
3260 pub vmware_vm_details: Option<VmwareVmDetails>,
3261}
3262
3263impl common::Part for VmUtilizationInfo {}
3264
3265/// Utilization metrics values for a single VM.
3266///
3267/// This type is not used in any activity, and only used as *part* of another schema.
3268///
3269#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3270#[serde_with::serde_as]
3271#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3272pub struct VmUtilizationMetrics {
3273 /// Average CPU usage, percent.
3274 #[serde(rename = "cpuAveragePercent")]
3275 pub cpu_average_percent: Option<i32>,
3276 /// Max CPU usage, percent.
3277 #[serde(rename = "cpuMaxPercent")]
3278 pub cpu_max_percent: Option<i32>,
3279 /// Average disk IO rate, in kilobytes per second.
3280 #[serde(rename = "diskIoRateAverageKbps")]
3281 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3282 pub disk_io_rate_average_kbps: Option<i64>,
3283 /// Max disk IO rate, in kilobytes per second.
3284 #[serde(rename = "diskIoRateMaxKbps")]
3285 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3286 pub disk_io_rate_max_kbps: Option<i64>,
3287 /// Average memory usage, percent.
3288 #[serde(rename = "memoryAveragePercent")]
3289 pub memory_average_percent: Option<i32>,
3290 /// Max memory usage, percent.
3291 #[serde(rename = "memoryMaxPercent")]
3292 pub memory_max_percent: Option<i32>,
3293 /// Average network throughput (combined transmit-rates and receive-rates), in kilobytes per second.
3294 #[serde(rename = "networkThroughputAverageKbps")]
3295 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3296 pub network_throughput_average_kbps: Option<i64>,
3297 /// Max network throughput (combined transmit-rates and receive-rates), in kilobytes per second.
3298 #[serde(rename = "networkThroughputMaxKbps")]
3299 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3300 pub network_throughput_max_kbps: Option<i64>,
3301}
3302
3303impl common::Part for VmUtilizationMetrics {}
3304
3305/// The details of a Vmware VM disk.
3306///
3307/// This type is not used in any activity, and only used as *part* of another schema.
3308///
3309#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3310#[serde_with::serde_as]
3311#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3312pub struct VmwareDiskDetails {
3313 /// Output only. The ordinal number of the disk.
3314 #[serde(rename = "diskNumber")]
3315 pub disk_number: Option<i32>,
3316 /// Output only. The disk label.
3317 pub label: Option<String>,
3318 /// Output only. Size in GB.
3319 #[serde(rename = "sizeGb")]
3320 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3321 pub size_gb: Option<i64>,
3322}
3323
3324impl common::Part for VmwareDiskDetails {}
3325
3326/// VmwareSourceDetails message describes a specific source details for the vmware source type.
3327///
3328/// This type is not used in any activity, and only used as *part* of another schema.
3329///
3330#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3331#[serde_with::serde_as]
3332#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3333pub struct VmwareSourceDetails {
3334 /// Input only. The credentials password. This is write only and can not be read in a GET operation.
3335 pub password: Option<String>,
3336 /// The hostname of the vcenter.
3337 #[serde(rename = "resolvedVcenterHost")]
3338 pub resolved_vcenter_host: Option<String>,
3339 /// The thumbprint representing the certificate for the vcenter.
3340 pub thumbprint: Option<String>,
3341 /// The credentials username.
3342 pub username: Option<String>,
3343 /// The ip address of the vcenter this Source represents.
3344 #[serde(rename = "vcenterIp")]
3345 pub vcenter_ip: Option<String>,
3346}
3347
3348impl common::Part for VmwareSourceDetails {}
3349
3350/// Represent the source Vmware VM details.
3351///
3352/// This type is not used in any activity, and only used as *part* of another schema.
3353///
3354#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3355#[serde_with::serde_as]
3356#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3357pub struct VmwareSourceVmDetails {
3358 /// Output only. The VM architecture.
3359 pub architecture: Option<String>,
3360 /// Output only. The total size of the disks being migrated in bytes.
3361 #[serde(rename = "committedStorageBytes")]
3362 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3363 pub committed_storage_bytes: Option<i64>,
3364 /// Output only. The disks attached to the source VM.
3365 pub disks: Option<Vec<VmwareDiskDetails>>,
3366 /// Output only. The firmware type of the source VM.
3367 pub firmware: Option<String>,
3368 /// Output only. Information about VM capabilities needed for some Compute Engine features.
3369 #[serde(rename = "vmCapabilitiesInfo")]
3370 pub vm_capabilities_info: Option<VmCapabilities>,
3371}
3372
3373impl common::Part for VmwareSourceVmDetails {}
3374
3375/// VmwareVmDetails describes a VM in vCenter.
3376///
3377/// This type is not used in any activity, and only used as *part* of another schema.
3378///
3379#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3380#[serde_with::serde_as]
3381#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3382pub struct VmwareVmDetails {
3383 /// Output only. The CPU architecture.
3384 pub architecture: Option<String>,
3385 /// Output only. The VM Boot Option.
3386 #[serde(rename = "bootOption")]
3387 pub boot_option: Option<String>,
3388 /// The total size of the storage allocated to the VM in MB.
3389 #[serde(rename = "committedStorageMb")]
3390 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3391 pub committed_storage_mb: Option<i64>,
3392 /// The number of cpus in the VM.
3393 #[serde(rename = "cpuCount")]
3394 pub cpu_count: Option<i32>,
3395 /// The descriptive name of the vCenter's datacenter this VM is contained in.
3396 #[serde(rename = "datacenterDescription")]
3397 pub datacenter_description: Option<String>,
3398 /// The id of the vCenter's datacenter this VM is contained in.
3399 #[serde(rename = "datacenterId")]
3400 pub datacenter_id: Option<String>,
3401 /// The number of disks the VM has.
3402 #[serde(rename = "diskCount")]
3403 pub disk_count: Option<i32>,
3404 /// The display name of the VM. Note that this is not necessarily unique.
3405 #[serde(rename = "displayName")]
3406 pub display_name: Option<String>,
3407 /// 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.
3408 #[serde(rename = "guestDescription")]
3409 pub guest_description: Option<String>,
3410 /// The size of the memory of the VM in MB.
3411 #[serde(rename = "memoryMb")]
3412 pub memory_mb: Option<i32>,
3413 /// The power state of the VM at the moment list was taken.
3414 #[serde(rename = "powerState")]
3415 pub power_state: Option<String>,
3416 /// The unique identifier of the VM in vCenter.
3417 pub uuid: Option<String>,
3418 /// The VM's id in the source (note that this is not the MigratingVm's id). This is the moref id of the VM.
3419 #[serde(rename = "vmId")]
3420 pub vm_id: Option<String>,
3421}
3422
3423impl common::Part for VmwareVmDetails {}
3424
3425/// VmwareVmsDetails describes VMs in vCenter.
3426///
3427/// This type is not used in any activity, and only used as *part* of another schema.
3428///
3429#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3430#[serde_with::serde_as]
3431#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3432pub struct VmwareVmsDetails {
3433 /// The details of the vmware VMs.
3434 pub details: Option<Vec<VmwareVmDetails>>,
3435}
3436
3437impl common::Part for VmwareVmsDetails {}
3438
3439// ###################
3440// MethodBuilders ###
3441// #################
3442
3443/// A builder providing access to all methods supported on *project* resources.
3444/// It is not used directly, but through the [`VMMigrationService`] hub.
3445///
3446/// # Example
3447///
3448/// Instantiate a resource builder
3449///
3450/// ```test_harness,no_run
3451/// extern crate hyper;
3452/// extern crate hyper_rustls;
3453/// extern crate google_vmmigration1 as vmmigration1;
3454///
3455/// # async fn dox() {
3456/// use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3457///
3458/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3459/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3460/// .with_native_roots()
3461/// .unwrap()
3462/// .https_only()
3463/// .enable_http2()
3464/// .build();
3465///
3466/// let executor = hyper_util::rt::TokioExecutor::new();
3467/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3468/// secret,
3469/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3470/// yup_oauth2::client::CustomHyperClientBuilder::from(
3471/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3472/// ),
3473/// ).build().await.unwrap();
3474///
3475/// let client = hyper_util::client::legacy::Client::builder(
3476/// hyper_util::rt::TokioExecutor::new()
3477/// )
3478/// .build(
3479/// hyper_rustls::HttpsConnectorBuilder::new()
3480/// .with_native_roots()
3481/// .unwrap()
3482/// .https_or_http()
3483/// .enable_http2()
3484/// .build()
3485/// );
3486/// let mut hub = VMMigrationService::new(client, auth);
3487/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3488/// // 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_disk_migration_jobs_cancel(...)`, `locations_sources_disk_migration_jobs_create(...)`, `locations_sources_disk_migration_jobs_delete(...)`, `locations_sources_disk_migration_jobs_get(...)`, `locations_sources_disk_migration_jobs_list(...)`, `locations_sources_disk_migration_jobs_patch(...)`, `locations_sources_disk_migration_jobs_run(...)`, `locations_sources_fetch_inventory(...)`, `locations_sources_fetch_storage_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_extend_migration(...)`, `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(...)`
3489/// // to build up your call.
3490/// let rb = hub.projects();
3491/// # }
3492/// ```
3493pub struct ProjectMethods<'a, C>
3494where
3495 C: 'a,
3496{
3497 hub: &'a VMMigrationService<C>,
3498}
3499
3500impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
3501
3502impl<'a, C> ProjectMethods<'a, C> {
3503 /// Create a builder to help you perform the following task:
3504 ///
3505 /// Adds a MigratingVm to a Group.
3506 ///
3507 /// # Arguments
3508 ///
3509 /// * `request` - No description provided.
3510 /// * `group` - Required. The full path name of the Group to add to.
3511 pub fn locations_groups_add_group_migration(
3512 &self,
3513 request: AddGroupMigrationRequest,
3514 group: &str,
3515 ) -> ProjectLocationGroupAddGroupMigrationCall<'a, C> {
3516 ProjectLocationGroupAddGroupMigrationCall {
3517 hub: self.hub,
3518 _request: request,
3519 _group: group.to_string(),
3520 _delegate: Default::default(),
3521 _additional_params: Default::default(),
3522 _scopes: Default::default(),
3523 }
3524 }
3525
3526 /// Create a builder to help you perform the following task:
3527 ///
3528 /// Creates a new Group in a given project and location.
3529 ///
3530 /// # Arguments
3531 ///
3532 /// * `request` - No description provided.
3533 /// * `parent` - Required. The Group's parent.
3534 pub fn locations_groups_create(
3535 &self,
3536 request: Group,
3537 parent: &str,
3538 ) -> ProjectLocationGroupCreateCall<'a, C> {
3539 ProjectLocationGroupCreateCall {
3540 hub: self.hub,
3541 _request: request,
3542 _parent: parent.to_string(),
3543 _request_id: Default::default(),
3544 _group_id: Default::default(),
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 /// Deletes a single Group.
3554 ///
3555 /// # Arguments
3556 ///
3557 /// * `name` - Required. The Group name.
3558 pub fn locations_groups_delete(&self, name: &str) -> ProjectLocationGroupDeleteCall<'a, C> {
3559 ProjectLocationGroupDeleteCall {
3560 hub: self.hub,
3561 _name: name.to_string(),
3562 _request_id: Default::default(),
3563 _delegate: Default::default(),
3564 _additional_params: Default::default(),
3565 _scopes: Default::default(),
3566 }
3567 }
3568
3569 /// Create a builder to help you perform the following task:
3570 ///
3571 /// Gets details of a single Group.
3572 ///
3573 /// # Arguments
3574 ///
3575 /// * `name` - Required. The group name.
3576 pub fn locations_groups_get(&self, name: &str) -> ProjectLocationGroupGetCall<'a, C> {
3577 ProjectLocationGroupGetCall {
3578 hub: self.hub,
3579 _name: name.to_string(),
3580 _delegate: Default::default(),
3581 _additional_params: Default::default(),
3582 _scopes: Default::default(),
3583 }
3584 }
3585
3586 /// Create a builder to help you perform the following task:
3587 ///
3588 /// Lists Groups in a given project and location.
3589 ///
3590 /// # Arguments
3591 ///
3592 /// * `parent` - Required. The parent, which owns this collection of groups.
3593 pub fn locations_groups_list(&self, parent: &str) -> ProjectLocationGroupListCall<'a, C> {
3594 ProjectLocationGroupListCall {
3595 hub: self.hub,
3596 _parent: parent.to_string(),
3597 _page_token: Default::default(),
3598 _page_size: Default::default(),
3599 _order_by: Default::default(),
3600 _filter: Default::default(),
3601 _delegate: Default::default(),
3602 _additional_params: Default::default(),
3603 _scopes: Default::default(),
3604 }
3605 }
3606
3607 /// Create a builder to help you perform the following task:
3608 ///
3609 /// Updates the parameters of a single Group.
3610 ///
3611 /// # Arguments
3612 ///
3613 /// * `request` - No description provided.
3614 /// * `name` - Output only. The Group name.
3615 pub fn locations_groups_patch(
3616 &self,
3617 request: Group,
3618 name: &str,
3619 ) -> ProjectLocationGroupPatchCall<'a, C> {
3620 ProjectLocationGroupPatchCall {
3621 hub: self.hub,
3622 _request: request,
3623 _name: name.to_string(),
3624 _update_mask: Default::default(),
3625 _request_id: Default::default(),
3626 _delegate: Default::default(),
3627 _additional_params: Default::default(),
3628 _scopes: Default::default(),
3629 }
3630 }
3631
3632 /// Create a builder to help you perform the following task:
3633 ///
3634 /// Removes a MigratingVm from a Group.
3635 ///
3636 /// # Arguments
3637 ///
3638 /// * `request` - No description provided.
3639 /// * `group` - Required. The name of the Group.
3640 pub fn locations_groups_remove_group_migration(
3641 &self,
3642 request: RemoveGroupMigrationRequest,
3643 group: &str,
3644 ) -> ProjectLocationGroupRemoveGroupMigrationCall<'a, C> {
3645 ProjectLocationGroupRemoveGroupMigrationCall {
3646 hub: self.hub,
3647 _request: request,
3648 _group: group.to_string(),
3649 _delegate: Default::default(),
3650 _additional_params: Default::default(),
3651 _scopes: Default::default(),
3652 }
3653 }
3654
3655 /// Create a builder to help you perform the following task:
3656 ///
3657 /// Initiates the cancellation of a running ImageImportJob.
3658 ///
3659 /// # Arguments
3660 ///
3661 /// * `request` - No description provided.
3662 /// * `name` - Required. The image import job id.
3663 pub fn locations_image_imports_image_import_jobs_cancel(
3664 &self,
3665 request: CancelImageImportJobRequest,
3666 name: &str,
3667 ) -> ProjectLocationImageImportImageImportJobCancelCall<'a, C> {
3668 ProjectLocationImageImportImageImportJobCancelCall {
3669 hub: self.hub,
3670 _request: request,
3671 _name: name.to_string(),
3672 _delegate: Default::default(),
3673 _additional_params: Default::default(),
3674 _scopes: Default::default(),
3675 }
3676 }
3677
3678 /// Create a builder to help you perform the following task:
3679 ///
3680 /// Gets details of a single ImageImportJob.
3681 ///
3682 /// # Arguments
3683 ///
3684 /// * `name` - Required. The ImageImportJob name.
3685 pub fn locations_image_imports_image_import_jobs_get(
3686 &self,
3687 name: &str,
3688 ) -> ProjectLocationImageImportImageImportJobGetCall<'a, C> {
3689 ProjectLocationImageImportImageImportJobGetCall {
3690 hub: self.hub,
3691 _name: name.to_string(),
3692 _delegate: Default::default(),
3693 _additional_params: Default::default(),
3694 _scopes: Default::default(),
3695 }
3696 }
3697
3698 /// Create a builder to help you perform the following task:
3699 ///
3700 /// Lists ImageImportJobs in a given project.
3701 ///
3702 /// # Arguments
3703 ///
3704 /// * `parent` - Required. The parent, which owns this collection of targets.
3705 pub fn locations_image_imports_image_import_jobs_list(
3706 &self,
3707 parent: &str,
3708 ) -> ProjectLocationImageImportImageImportJobListCall<'a, C> {
3709 ProjectLocationImageImportImageImportJobListCall {
3710 hub: self.hub,
3711 _parent: parent.to_string(),
3712 _page_token: Default::default(),
3713 _page_size: Default::default(),
3714 _order_by: Default::default(),
3715 _filter: Default::default(),
3716 _delegate: Default::default(),
3717 _additional_params: Default::default(),
3718 _scopes: Default::default(),
3719 }
3720 }
3721
3722 /// Create a builder to help you perform the following task:
3723 ///
3724 /// Creates a new ImageImport in a given project.
3725 ///
3726 /// # Arguments
3727 ///
3728 /// * `request` - No description provided.
3729 /// * `parent` - Required. The ImageImport's parent.
3730 pub fn locations_image_imports_create(
3731 &self,
3732 request: ImageImport,
3733 parent: &str,
3734 ) -> ProjectLocationImageImportCreateCall<'a, C> {
3735 ProjectLocationImageImportCreateCall {
3736 hub: self.hub,
3737 _request: request,
3738 _parent: parent.to_string(),
3739 _request_id: Default::default(),
3740 _image_import_id: Default::default(),
3741 _delegate: Default::default(),
3742 _additional_params: Default::default(),
3743 _scopes: Default::default(),
3744 }
3745 }
3746
3747 /// Create a builder to help you perform the following task:
3748 ///
3749 /// Deletes a single ImageImport.
3750 ///
3751 /// # Arguments
3752 ///
3753 /// * `name` - Required. The ImageImport name.
3754 pub fn locations_image_imports_delete(
3755 &self,
3756 name: &str,
3757 ) -> ProjectLocationImageImportDeleteCall<'a, C> {
3758 ProjectLocationImageImportDeleteCall {
3759 hub: self.hub,
3760 _name: name.to_string(),
3761 _request_id: Default::default(),
3762 _delegate: Default::default(),
3763 _additional_params: Default::default(),
3764 _scopes: Default::default(),
3765 }
3766 }
3767
3768 /// Create a builder to help you perform the following task:
3769 ///
3770 /// Gets details of a single ImageImport.
3771 ///
3772 /// # Arguments
3773 ///
3774 /// * `name` - Required. The ImageImport name.
3775 pub fn locations_image_imports_get(
3776 &self,
3777 name: &str,
3778 ) -> ProjectLocationImageImportGetCall<'a, C> {
3779 ProjectLocationImageImportGetCall {
3780 hub: self.hub,
3781 _name: name.to_string(),
3782 _delegate: Default::default(),
3783 _additional_params: Default::default(),
3784 _scopes: Default::default(),
3785 }
3786 }
3787
3788 /// Create a builder to help you perform the following task:
3789 ///
3790 /// Lists ImageImports in a given project.
3791 ///
3792 /// # Arguments
3793 ///
3794 /// * `parent` - Required. The parent, which owns this collection of targets.
3795 pub fn locations_image_imports_list(
3796 &self,
3797 parent: &str,
3798 ) -> ProjectLocationImageImportListCall<'a, C> {
3799 ProjectLocationImageImportListCall {
3800 hub: self.hub,
3801 _parent: parent.to_string(),
3802 _page_token: Default::default(),
3803 _page_size: Default::default(),
3804 _order_by: Default::default(),
3805 _filter: Default::default(),
3806 _delegate: Default::default(),
3807 _additional_params: Default::default(),
3808 _scopes: Default::default(),
3809 }
3810 }
3811
3812 /// Create a builder to help you perform the following task:
3813 ///
3814 /// 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`.
3815 ///
3816 /// # Arguments
3817 ///
3818 /// * `request` - No description provided.
3819 /// * `name` - The name of the operation resource to be cancelled.
3820 pub fn locations_operations_cancel(
3821 &self,
3822 request: CancelOperationRequest,
3823 name: &str,
3824 ) -> ProjectLocationOperationCancelCall<'a, C> {
3825 ProjectLocationOperationCancelCall {
3826 hub: self.hub,
3827 _request: request,
3828 _name: name.to_string(),
3829 _delegate: Default::default(),
3830 _additional_params: Default::default(),
3831 _scopes: Default::default(),
3832 }
3833 }
3834
3835 /// Create a builder to help you perform the following task:
3836 ///
3837 /// 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`.
3838 ///
3839 /// # Arguments
3840 ///
3841 /// * `name` - The name of the operation resource to be deleted.
3842 pub fn locations_operations_delete(
3843 &self,
3844 name: &str,
3845 ) -> ProjectLocationOperationDeleteCall<'a, C> {
3846 ProjectLocationOperationDeleteCall {
3847 hub: self.hub,
3848 _name: name.to_string(),
3849 _delegate: Default::default(),
3850 _additional_params: Default::default(),
3851 _scopes: Default::default(),
3852 }
3853 }
3854
3855 /// Create a builder to help you perform the following task:
3856 ///
3857 /// 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.
3858 ///
3859 /// # Arguments
3860 ///
3861 /// * `name` - The name of the operation resource.
3862 pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
3863 ProjectLocationOperationGetCall {
3864 hub: self.hub,
3865 _name: name.to_string(),
3866 _delegate: Default::default(),
3867 _additional_params: Default::default(),
3868 _scopes: Default::default(),
3869 }
3870 }
3871
3872 /// Create a builder to help you perform the following task:
3873 ///
3874 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
3875 ///
3876 /// # Arguments
3877 ///
3878 /// * `name` - The name of the operation's parent resource.
3879 pub fn locations_operations_list(&self, name: &str) -> ProjectLocationOperationListCall<'a, C> {
3880 ProjectLocationOperationListCall {
3881 hub: self.hub,
3882 _name: name.to_string(),
3883 _return_partial_success: Default::default(),
3884 _page_token: Default::default(),
3885 _page_size: Default::default(),
3886 _filter: Default::default(),
3887 _delegate: Default::default(),
3888 _additional_params: Default::default(),
3889 _scopes: Default::default(),
3890 }
3891 }
3892
3893 /// Create a builder to help you perform the following task:
3894 ///
3895 /// Creates a new DatacenterConnector in a given Source.
3896 ///
3897 /// # Arguments
3898 ///
3899 /// * `request` - No description provided.
3900 /// * `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`
3901 pub fn locations_sources_datacenter_connectors_create(
3902 &self,
3903 request: DatacenterConnector,
3904 parent: &str,
3905 ) -> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C> {
3906 ProjectLocationSourceDatacenterConnectorCreateCall {
3907 hub: self.hub,
3908 _request: request,
3909 _parent: parent.to_string(),
3910 _request_id: Default::default(),
3911 _datacenter_connector_id: Default::default(),
3912 _delegate: Default::default(),
3913 _additional_params: Default::default(),
3914 _scopes: Default::default(),
3915 }
3916 }
3917
3918 /// Create a builder to help you perform the following task:
3919 ///
3920 /// Deletes a single DatacenterConnector.
3921 ///
3922 /// # Arguments
3923 ///
3924 /// * `name` - Required. The DatacenterConnector name.
3925 pub fn locations_sources_datacenter_connectors_delete(
3926 &self,
3927 name: &str,
3928 ) -> ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C> {
3929 ProjectLocationSourceDatacenterConnectorDeleteCall {
3930 hub: self.hub,
3931 _name: name.to_string(),
3932 _request_id: Default::default(),
3933 _delegate: Default::default(),
3934 _additional_params: Default::default(),
3935 _scopes: Default::default(),
3936 }
3937 }
3938
3939 /// Create a builder to help you perform the following task:
3940 ///
3941 /// Gets details of a single DatacenterConnector.
3942 ///
3943 /// # Arguments
3944 ///
3945 /// * `name` - Required. The name of the DatacenterConnector.
3946 pub fn locations_sources_datacenter_connectors_get(
3947 &self,
3948 name: &str,
3949 ) -> ProjectLocationSourceDatacenterConnectorGetCall<'a, C> {
3950 ProjectLocationSourceDatacenterConnectorGetCall {
3951 hub: self.hub,
3952 _name: name.to_string(),
3953 _delegate: Default::default(),
3954 _additional_params: Default::default(),
3955 _scopes: Default::default(),
3956 }
3957 }
3958
3959 /// Create a builder to help you perform the following task:
3960 ///
3961 /// Lists DatacenterConnectors in a given Source.
3962 ///
3963 /// # Arguments
3964 ///
3965 /// * `parent` - Required. The parent, which owns this collection of connectors.
3966 pub fn locations_sources_datacenter_connectors_list(
3967 &self,
3968 parent: &str,
3969 ) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C> {
3970 ProjectLocationSourceDatacenterConnectorListCall {
3971 hub: self.hub,
3972 _parent: parent.to_string(),
3973 _page_token: Default::default(),
3974 _page_size: Default::default(),
3975 _order_by: Default::default(),
3976 _filter: Default::default(),
3977 _delegate: Default::default(),
3978 _additional_params: Default::default(),
3979 _scopes: Default::default(),
3980 }
3981 }
3982
3983 /// Create a builder to help you perform the following task:
3984 ///
3985 /// Upgrades the appliance relate to this DatacenterConnector to the in-place updateable version.
3986 ///
3987 /// # Arguments
3988 ///
3989 /// * `request` - No description provided.
3990 /// * `datacenterConnector` - Required. The DatacenterConnector name.
3991 pub fn locations_sources_datacenter_connectors_upgrade_appliance(
3992 &self,
3993 request: UpgradeApplianceRequest,
3994 datacenter_connector: &str,
3995 ) -> ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C> {
3996 ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall {
3997 hub: self.hub,
3998 _request: request,
3999 _datacenter_connector: datacenter_connector.to_string(),
4000 _delegate: Default::default(),
4001 _additional_params: Default::default(),
4002 _scopes: Default::default(),
4003 }
4004 }
4005
4006 /// Create a builder to help you perform the following task:
4007 ///
4008 /// Cancels the disk migration job.
4009 ///
4010 /// # Arguments
4011 ///
4012 /// * `request` - No description provided.
4013 /// * `name` - Required. The name of the DiskMigrationJob.
4014 pub fn locations_sources_disk_migration_jobs_cancel(
4015 &self,
4016 request: CancelDiskMigrationJobRequest,
4017 name: &str,
4018 ) -> ProjectLocationSourceDiskMigrationJobCancelCall<'a, C> {
4019 ProjectLocationSourceDiskMigrationJobCancelCall {
4020 hub: self.hub,
4021 _request: request,
4022 _name: name.to_string(),
4023 _delegate: Default::default(),
4024 _additional_params: Default::default(),
4025 _scopes: Default::default(),
4026 }
4027 }
4028
4029 /// Create a builder to help you perform the following task:
4030 ///
4031 /// Creates a new disk migration job in a given Source.
4032 ///
4033 /// # Arguments
4034 ///
4035 /// * `request` - No description provided.
4036 /// * `parent` - Required. The DiskMigrationJob's parent.
4037 pub fn locations_sources_disk_migration_jobs_create(
4038 &self,
4039 request: DiskMigrationJob,
4040 parent: &str,
4041 ) -> ProjectLocationSourceDiskMigrationJobCreateCall<'a, C> {
4042 ProjectLocationSourceDiskMigrationJobCreateCall {
4043 hub: self.hub,
4044 _request: request,
4045 _parent: parent.to_string(),
4046 _request_id: Default::default(),
4047 _disk_migration_job_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 /// Deletes a single DiskMigrationJob.
4057 ///
4058 /// # Arguments
4059 ///
4060 /// * `name` - Required. The name of the DiskMigrationJob.
4061 pub fn locations_sources_disk_migration_jobs_delete(
4062 &self,
4063 name: &str,
4064 ) -> ProjectLocationSourceDiskMigrationJobDeleteCall<'a, C> {
4065 ProjectLocationSourceDiskMigrationJobDeleteCall {
4066 hub: self.hub,
4067 _name: name.to_string(),
4068 _delegate: Default::default(),
4069 _additional_params: Default::default(),
4070 _scopes: Default::default(),
4071 }
4072 }
4073
4074 /// Create a builder to help you perform the following task:
4075 ///
4076 /// Gets details of a single DiskMigrationJob.
4077 ///
4078 /// # Arguments
4079 ///
4080 /// * `name` - Required. The name of the DiskMigrationJob.
4081 pub fn locations_sources_disk_migration_jobs_get(
4082 &self,
4083 name: &str,
4084 ) -> ProjectLocationSourceDiskMigrationJobGetCall<'a, C> {
4085 ProjectLocationSourceDiskMigrationJobGetCall {
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 DiskMigrationJobs in a given Source.
4097 ///
4098 /// # Arguments
4099 ///
4100 /// * `parent` - Required. The parent, which owns this collection of DiskMigrationJobs.
4101 pub fn locations_sources_disk_migration_jobs_list(
4102 &self,
4103 parent: &str,
4104 ) -> ProjectLocationSourceDiskMigrationJobListCall<'a, C> {
4105 ProjectLocationSourceDiskMigrationJobListCall {
4106 hub: self.hub,
4107 _parent: parent.to_string(),
4108 _page_token: Default::default(),
4109 _page_size: Default::default(),
4110 _order_by: Default::default(),
4111 _filter: Default::default(),
4112 _delegate: Default::default(),
4113 _additional_params: Default::default(),
4114 _scopes: Default::default(),
4115 }
4116 }
4117
4118 /// Create a builder to help you perform the following task:
4119 ///
4120 /// Updates the parameters of a single DiskMigrationJob.
4121 ///
4122 /// # Arguments
4123 ///
4124 /// * `request` - No description provided.
4125 /// * `name` - Output only. Identifier. The identifier of the DiskMigrationJob.
4126 pub fn locations_sources_disk_migration_jobs_patch(
4127 &self,
4128 request: DiskMigrationJob,
4129 name: &str,
4130 ) -> ProjectLocationSourceDiskMigrationJobPatchCall<'a, C> {
4131 ProjectLocationSourceDiskMigrationJobPatchCall {
4132 hub: self.hub,
4133 _request: request,
4134 _name: name.to_string(),
4135 _update_mask: Default::default(),
4136 _request_id: Default::default(),
4137 _delegate: Default::default(),
4138 _additional_params: Default::default(),
4139 _scopes: Default::default(),
4140 }
4141 }
4142
4143 /// Create a builder to help you perform the following task:
4144 ///
4145 /// Runs the disk migration job.
4146 ///
4147 /// # Arguments
4148 ///
4149 /// * `request` - No description provided.
4150 /// * `name` - Required. The name of the DiskMigrationJob.
4151 pub fn locations_sources_disk_migration_jobs_run(
4152 &self,
4153 request: RunDiskMigrationJobRequest,
4154 name: &str,
4155 ) -> ProjectLocationSourceDiskMigrationJobRunCall<'a, C> {
4156 ProjectLocationSourceDiskMigrationJobRunCall {
4157 hub: self.hub,
4158 _request: request,
4159 _name: name.to_string(),
4160 _delegate: Default::default(),
4161 _additional_params: Default::default(),
4162 _scopes: Default::default(),
4163 }
4164 }
4165
4166 /// Create a builder to help you perform the following task:
4167 ///
4168 /// Initiates the cancellation of a running clone job.
4169 ///
4170 /// # Arguments
4171 ///
4172 /// * `request` - No description provided.
4173 /// * `name` - Required. The clone job id
4174 pub fn locations_sources_migrating_vms_clone_jobs_cancel(
4175 &self,
4176 request: CancelCloneJobRequest,
4177 name: &str,
4178 ) -> ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C> {
4179 ProjectLocationSourceMigratingVmCloneJobCancelCall {
4180 hub: self.hub,
4181 _request: request,
4182 _name: name.to_string(),
4183 _delegate: Default::default(),
4184 _additional_params: Default::default(),
4185 _scopes: Default::default(),
4186 }
4187 }
4188
4189 /// Create a builder to help you perform the following task:
4190 ///
4191 /// Initiates a Clone of a specific migrating VM.
4192 ///
4193 /// # Arguments
4194 ///
4195 /// * `request` - No description provided.
4196 /// * `parent` - Required. The Clone's parent.
4197 pub fn locations_sources_migrating_vms_clone_jobs_create(
4198 &self,
4199 request: CloneJob,
4200 parent: &str,
4201 ) -> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C> {
4202 ProjectLocationSourceMigratingVmCloneJobCreateCall {
4203 hub: self.hub,
4204 _request: request,
4205 _parent: parent.to_string(),
4206 _request_id: Default::default(),
4207 _clone_job_id: Default::default(),
4208 _delegate: Default::default(),
4209 _additional_params: Default::default(),
4210 _scopes: Default::default(),
4211 }
4212 }
4213
4214 /// Create a builder to help you perform the following task:
4215 ///
4216 /// Gets details of a single CloneJob.
4217 ///
4218 /// # Arguments
4219 ///
4220 /// * `name` - Required. The name of the CloneJob.
4221 pub fn locations_sources_migrating_vms_clone_jobs_get(
4222 &self,
4223 name: &str,
4224 ) -> ProjectLocationSourceMigratingVmCloneJobGetCall<'a, C> {
4225 ProjectLocationSourceMigratingVmCloneJobGetCall {
4226 hub: self.hub,
4227 _name: name.to_string(),
4228 _delegate: Default::default(),
4229 _additional_params: Default::default(),
4230 _scopes: Default::default(),
4231 }
4232 }
4233
4234 /// Create a builder to help you perform the following task:
4235 ///
4236 /// Lists the CloneJobs of a migrating VM. Only 25 most recent CloneJobs are listed.
4237 ///
4238 /// # Arguments
4239 ///
4240 /// * `parent` - Required. The parent, which owns this collection of source VMs.
4241 pub fn locations_sources_migrating_vms_clone_jobs_list(
4242 &self,
4243 parent: &str,
4244 ) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C> {
4245 ProjectLocationSourceMigratingVmCloneJobListCall {
4246 hub: self.hub,
4247 _parent: parent.to_string(),
4248 _page_token: Default::default(),
4249 _page_size: Default::default(),
4250 _order_by: Default::default(),
4251 _filter: Default::default(),
4252 _delegate: Default::default(),
4253 _additional_params: Default::default(),
4254 _scopes: Default::default(),
4255 }
4256 }
4257
4258 /// Create a builder to help you perform the following task:
4259 ///
4260 /// Initiates the cancellation of a running cutover job.
4261 ///
4262 /// # Arguments
4263 ///
4264 /// * `request` - No description provided.
4265 /// * `name` - Required. The cutover job id
4266 pub fn locations_sources_migrating_vms_cutover_jobs_cancel(
4267 &self,
4268 request: CancelCutoverJobRequest,
4269 name: &str,
4270 ) -> ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C> {
4271 ProjectLocationSourceMigratingVmCutoverJobCancelCall {
4272 hub: self.hub,
4273 _request: request,
4274 _name: name.to_string(),
4275 _delegate: Default::default(),
4276 _additional_params: Default::default(),
4277 _scopes: Default::default(),
4278 }
4279 }
4280
4281 /// Create a builder to help you perform the following task:
4282 ///
4283 /// 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.
4284 ///
4285 /// # Arguments
4286 ///
4287 /// * `request` - No description provided.
4288 /// * `parent` - Required. The Cutover's parent.
4289 pub fn locations_sources_migrating_vms_cutover_jobs_create(
4290 &self,
4291 request: CutoverJob,
4292 parent: &str,
4293 ) -> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C> {
4294 ProjectLocationSourceMigratingVmCutoverJobCreateCall {
4295 hub: self.hub,
4296 _request: request,
4297 _parent: parent.to_string(),
4298 _request_id: Default::default(),
4299 _cutover_job_id: Default::default(),
4300 _delegate: Default::default(),
4301 _additional_params: Default::default(),
4302 _scopes: Default::default(),
4303 }
4304 }
4305
4306 /// Create a builder to help you perform the following task:
4307 ///
4308 /// Gets details of a single CutoverJob.
4309 ///
4310 /// # Arguments
4311 ///
4312 /// * `name` - Required. The name of the CutoverJob.
4313 pub fn locations_sources_migrating_vms_cutover_jobs_get(
4314 &self,
4315 name: &str,
4316 ) -> ProjectLocationSourceMigratingVmCutoverJobGetCall<'a, C> {
4317 ProjectLocationSourceMigratingVmCutoverJobGetCall {
4318 hub: self.hub,
4319 _name: name.to_string(),
4320 _delegate: Default::default(),
4321 _additional_params: Default::default(),
4322 _scopes: Default::default(),
4323 }
4324 }
4325
4326 /// Create a builder to help you perform the following task:
4327 ///
4328 /// Lists the CutoverJobs of a migrating VM. Only 25 most recent CutoverJobs are listed.
4329 ///
4330 /// # Arguments
4331 ///
4332 /// * `parent` - Required. The parent, which owns this collection of migrating VMs.
4333 pub fn locations_sources_migrating_vms_cutover_jobs_list(
4334 &self,
4335 parent: &str,
4336 ) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C> {
4337 ProjectLocationSourceMigratingVmCutoverJobListCall {
4338 hub: self.hub,
4339 _parent: parent.to_string(),
4340 _page_token: Default::default(),
4341 _page_size: Default::default(),
4342 _order_by: Default::default(),
4343 _filter: Default::default(),
4344 _delegate: Default::default(),
4345 _additional_params: Default::default(),
4346 _scopes: Default::default(),
4347 }
4348 }
4349
4350 /// Create a builder to help you perform the following task:
4351 ///
4352 /// Gets details of a single ReplicationCycle.
4353 ///
4354 /// # Arguments
4355 ///
4356 /// * `name` - Required. The name of the ReplicationCycle.
4357 pub fn locations_sources_migrating_vms_replication_cycles_get(
4358 &self,
4359 name: &str,
4360 ) -> ProjectLocationSourceMigratingVmReplicationCycleGetCall<'a, C> {
4361 ProjectLocationSourceMigratingVmReplicationCycleGetCall {
4362 hub: self.hub,
4363 _name: name.to_string(),
4364 _delegate: Default::default(),
4365 _additional_params: Default::default(),
4366 _scopes: Default::default(),
4367 }
4368 }
4369
4370 /// Create a builder to help you perform the following task:
4371 ///
4372 /// Lists ReplicationCycles in a given MigratingVM.
4373 ///
4374 /// # Arguments
4375 ///
4376 /// * `parent` - Required. The parent, which owns this collection of ReplicationCycles.
4377 pub fn locations_sources_migrating_vms_replication_cycles_list(
4378 &self,
4379 parent: &str,
4380 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C> {
4381 ProjectLocationSourceMigratingVmReplicationCycleListCall {
4382 hub: self.hub,
4383 _parent: parent.to_string(),
4384 _page_token: Default::default(),
4385 _page_size: Default::default(),
4386 _order_by: Default::default(),
4387 _filter: Default::default(),
4388 _delegate: Default::default(),
4389 _additional_params: Default::default(),
4390 _scopes: Default::default(),
4391 }
4392 }
4393
4394 /// Create a builder to help you perform the following task:
4395 ///
4396 /// Creates a new MigratingVm in a given Source.
4397 ///
4398 /// # Arguments
4399 ///
4400 /// * `request` - No description provided.
4401 /// * `parent` - Required. The MigratingVm's parent.
4402 pub fn locations_sources_migrating_vms_create(
4403 &self,
4404 request: MigratingVm,
4405 parent: &str,
4406 ) -> ProjectLocationSourceMigratingVmCreateCall<'a, C> {
4407 ProjectLocationSourceMigratingVmCreateCall {
4408 hub: self.hub,
4409 _request: request,
4410 _parent: parent.to_string(),
4411 _request_id: Default::default(),
4412 _migrating_vm_id: Default::default(),
4413 _delegate: Default::default(),
4414 _additional_params: Default::default(),
4415 _scopes: Default::default(),
4416 }
4417 }
4418
4419 /// Create a builder to help you perform the following task:
4420 ///
4421 /// Deletes a single MigratingVm.
4422 ///
4423 /// # Arguments
4424 ///
4425 /// * `name` - Required. The name of the MigratingVm.
4426 pub fn locations_sources_migrating_vms_delete(
4427 &self,
4428 name: &str,
4429 ) -> ProjectLocationSourceMigratingVmDeleteCall<'a, C> {
4430 ProjectLocationSourceMigratingVmDeleteCall {
4431 hub: self.hub,
4432 _name: name.to_string(),
4433 _delegate: Default::default(),
4434 _additional_params: Default::default(),
4435 _scopes: Default::default(),
4436 }
4437 }
4438
4439 /// Create a builder to help you perform the following task:
4440 ///
4441 /// Extend the migrating VM time to live.
4442 ///
4443 /// # Arguments
4444 ///
4445 /// * `request` - No description provided.
4446 /// * `migratingVm` - Required. The name of the MigratingVm.
4447 pub fn locations_sources_migrating_vms_extend_migration(
4448 &self,
4449 request: ExtendMigrationRequest,
4450 migrating_vm: &str,
4451 ) -> ProjectLocationSourceMigratingVmExtendMigrationCall<'a, C> {
4452 ProjectLocationSourceMigratingVmExtendMigrationCall {
4453 hub: self.hub,
4454 _request: request,
4455 _migrating_vm: migrating_vm.to_string(),
4456 _delegate: Default::default(),
4457 _additional_params: Default::default(),
4458 _scopes: Default::default(),
4459 }
4460 }
4461
4462 /// Create a builder to help you perform the following task:
4463 ///
4464 /// Marks a migration as completed, deleting migration resources that are no longer being used. Only applicable after cutover is done.
4465 ///
4466 /// # Arguments
4467 ///
4468 /// * `request` - No description provided.
4469 /// * `migratingVm` - Required. The name of the MigratingVm.
4470 pub fn locations_sources_migrating_vms_finalize_migration(
4471 &self,
4472 request: FinalizeMigrationRequest,
4473 migrating_vm: &str,
4474 ) -> ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C> {
4475 ProjectLocationSourceMigratingVmFinalizeMigrationCall {
4476 hub: self.hub,
4477 _request: request,
4478 _migrating_vm: migrating_vm.to_string(),
4479 _delegate: Default::default(),
4480 _additional_params: Default::default(),
4481 _scopes: Default::default(),
4482 }
4483 }
4484
4485 /// Create a builder to help you perform the following task:
4486 ///
4487 /// Gets details of a single MigratingVm.
4488 ///
4489 /// # Arguments
4490 ///
4491 /// * `name` - Required. The name of the MigratingVm.
4492 pub fn locations_sources_migrating_vms_get(
4493 &self,
4494 name: &str,
4495 ) -> ProjectLocationSourceMigratingVmGetCall<'a, C> {
4496 ProjectLocationSourceMigratingVmGetCall {
4497 hub: self.hub,
4498 _name: name.to_string(),
4499 _view: Default::default(),
4500 _delegate: Default::default(),
4501 _additional_params: Default::default(),
4502 _scopes: Default::default(),
4503 }
4504 }
4505
4506 /// Create a builder to help you perform the following task:
4507 ///
4508 /// Lists MigratingVms in a given Source.
4509 ///
4510 /// # Arguments
4511 ///
4512 /// * `parent` - Required. The parent, which owns this collection of MigratingVms.
4513 pub fn locations_sources_migrating_vms_list(
4514 &self,
4515 parent: &str,
4516 ) -> ProjectLocationSourceMigratingVmListCall<'a, C> {
4517 ProjectLocationSourceMigratingVmListCall {
4518 hub: self.hub,
4519 _parent: parent.to_string(),
4520 _view: Default::default(),
4521 _page_token: Default::default(),
4522 _page_size: Default::default(),
4523 _order_by: Default::default(),
4524 _filter: Default::default(),
4525 _delegate: Default::default(),
4526 _additional_params: Default::default(),
4527 _scopes: Default::default(),
4528 }
4529 }
4530
4531 /// Create a builder to help you perform the following task:
4532 ///
4533 /// Updates the parameters of a single MigratingVm.
4534 ///
4535 /// # Arguments
4536 ///
4537 /// * `request` - No description provided.
4538 /// * `name` - Output only. The identifier of the MigratingVm.
4539 pub fn locations_sources_migrating_vms_patch(
4540 &self,
4541 request: MigratingVm,
4542 name: &str,
4543 ) -> ProjectLocationSourceMigratingVmPatchCall<'a, C> {
4544 ProjectLocationSourceMigratingVmPatchCall {
4545 hub: self.hub,
4546 _request: request,
4547 _name: name.to_string(),
4548 _update_mask: Default::default(),
4549 _request_id: Default::default(),
4550 _delegate: Default::default(),
4551 _additional_params: Default::default(),
4552 _scopes: Default::default(),
4553 }
4554 }
4555
4556 /// Create a builder to help you perform the following task:
4557 ///
4558 /// 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.
4559 ///
4560 /// # Arguments
4561 ///
4562 /// * `request` - No description provided.
4563 /// * `migratingVm` - Required. The name of the MigratingVm.
4564 pub fn locations_sources_migrating_vms_pause_migration(
4565 &self,
4566 request: PauseMigrationRequest,
4567 migrating_vm: &str,
4568 ) -> ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C> {
4569 ProjectLocationSourceMigratingVmPauseMigrationCall {
4570 hub: self.hub,
4571 _request: request,
4572 _migrating_vm: migrating_vm.to_string(),
4573 _delegate: Default::default(),
4574 _additional_params: Default::default(),
4575 _scopes: Default::default(),
4576 }
4577 }
4578
4579 /// Create a builder to help you perform the following task:
4580 ///
4581 /// 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.
4582 ///
4583 /// # Arguments
4584 ///
4585 /// * `request` - No description provided.
4586 /// * `migratingVm` - Required. The name of the MigratingVm.
4587 pub fn locations_sources_migrating_vms_resume_migration(
4588 &self,
4589 request: ResumeMigrationRequest,
4590 migrating_vm: &str,
4591 ) -> ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C> {
4592 ProjectLocationSourceMigratingVmResumeMigrationCall {
4593 hub: self.hub,
4594 _request: request,
4595 _migrating_vm: migrating_vm.to_string(),
4596 _delegate: Default::default(),
4597 _additional_params: Default::default(),
4598 _scopes: Default::default(),
4599 }
4600 }
4601
4602 /// Create a builder to help you perform the following task:
4603 ///
4604 /// Starts migration for a VM. Starts the process of uploading data and creating snapshots, in replication cycles scheduled by the policy.
4605 ///
4606 /// # Arguments
4607 ///
4608 /// * `request` - No description provided.
4609 /// * `migratingVm` - Required. The name of the MigratingVm.
4610 pub fn locations_sources_migrating_vms_start_migration(
4611 &self,
4612 request: StartMigrationRequest,
4613 migrating_vm: &str,
4614 ) -> ProjectLocationSourceMigratingVmStartMigrationCall<'a, C> {
4615 ProjectLocationSourceMigratingVmStartMigrationCall {
4616 hub: self.hub,
4617 _request: request,
4618 _migrating_vm: migrating_vm.to_string(),
4619 _delegate: Default::default(),
4620 _additional_params: Default::default(),
4621 _scopes: Default::default(),
4622 }
4623 }
4624
4625 /// Create a builder to help you perform the following task:
4626 ///
4627 /// Creates a new UtilizationReport.
4628 ///
4629 /// # Arguments
4630 ///
4631 /// * `request` - No description provided.
4632 /// * `parent` - Required. The Utilization Report's parent.
4633 pub fn locations_sources_utilization_reports_create(
4634 &self,
4635 request: UtilizationReport,
4636 parent: &str,
4637 ) -> ProjectLocationSourceUtilizationReportCreateCall<'a, C> {
4638 ProjectLocationSourceUtilizationReportCreateCall {
4639 hub: self.hub,
4640 _request: request,
4641 _parent: parent.to_string(),
4642 _utilization_report_id: Default::default(),
4643 _request_id: Default::default(),
4644 _delegate: Default::default(),
4645 _additional_params: Default::default(),
4646 _scopes: Default::default(),
4647 }
4648 }
4649
4650 /// Create a builder to help you perform the following task:
4651 ///
4652 /// Deletes a single Utilization Report.
4653 ///
4654 /// # Arguments
4655 ///
4656 /// * `name` - Required. The Utilization Report name.
4657 pub fn locations_sources_utilization_reports_delete(
4658 &self,
4659 name: &str,
4660 ) -> ProjectLocationSourceUtilizationReportDeleteCall<'a, C> {
4661 ProjectLocationSourceUtilizationReportDeleteCall {
4662 hub: self.hub,
4663 _name: name.to_string(),
4664 _request_id: Default::default(),
4665 _delegate: Default::default(),
4666 _additional_params: Default::default(),
4667 _scopes: Default::default(),
4668 }
4669 }
4670
4671 /// Create a builder to help you perform the following task:
4672 ///
4673 /// Gets a single Utilization Report.
4674 ///
4675 /// # Arguments
4676 ///
4677 /// * `name` - Required. The Utilization Report name.
4678 pub fn locations_sources_utilization_reports_get(
4679 &self,
4680 name: &str,
4681 ) -> ProjectLocationSourceUtilizationReportGetCall<'a, C> {
4682 ProjectLocationSourceUtilizationReportGetCall {
4683 hub: self.hub,
4684 _name: name.to_string(),
4685 _view: Default::default(),
4686 _delegate: Default::default(),
4687 _additional_params: Default::default(),
4688 _scopes: Default::default(),
4689 }
4690 }
4691
4692 /// Create a builder to help you perform the following task:
4693 ///
4694 /// Lists Utilization Reports of the given Source.
4695 ///
4696 /// # Arguments
4697 ///
4698 /// * `parent` - Required. The Utilization Reports parent.
4699 pub fn locations_sources_utilization_reports_list(
4700 &self,
4701 parent: &str,
4702 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C> {
4703 ProjectLocationSourceUtilizationReportListCall {
4704 hub: self.hub,
4705 _parent: parent.to_string(),
4706 _view: Default::default(),
4707 _page_token: Default::default(),
4708 _page_size: Default::default(),
4709 _order_by: Default::default(),
4710 _filter: Default::default(),
4711 _delegate: Default::default(),
4712 _additional_params: Default::default(),
4713 _scopes: Default::default(),
4714 }
4715 }
4716
4717 /// Create a builder to help you perform the following task:
4718 ///
4719 /// Creates a new Source in a given project and location.
4720 ///
4721 /// # Arguments
4722 ///
4723 /// * `request` - No description provided.
4724 /// * `parent` - Required. The Source's parent.
4725 pub fn locations_sources_create(
4726 &self,
4727 request: Source,
4728 parent: &str,
4729 ) -> ProjectLocationSourceCreateCall<'a, C> {
4730 ProjectLocationSourceCreateCall {
4731 hub: self.hub,
4732 _request: request,
4733 _parent: parent.to_string(),
4734 _source_id: Default::default(),
4735 _request_id: Default::default(),
4736 _delegate: Default::default(),
4737 _additional_params: Default::default(),
4738 _scopes: Default::default(),
4739 }
4740 }
4741
4742 /// Create a builder to help you perform the following task:
4743 ///
4744 /// Deletes a single Source.
4745 ///
4746 /// # Arguments
4747 ///
4748 /// * `name` - Required. The Source name.
4749 pub fn locations_sources_delete(&self, name: &str) -> ProjectLocationSourceDeleteCall<'a, C> {
4750 ProjectLocationSourceDeleteCall {
4751 hub: self.hub,
4752 _name: name.to_string(),
4753 _request_id: Default::default(),
4754 _delegate: Default::default(),
4755 _additional_params: Default::default(),
4756 _scopes: Default::default(),
4757 }
4758 }
4759
4760 /// Create a builder to help you perform the following task:
4761 ///
4762 /// 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.
4763 ///
4764 /// # Arguments
4765 ///
4766 /// * `source` - Required. The name of the Source.
4767 pub fn locations_sources_fetch_inventory(
4768 &self,
4769 source: &str,
4770 ) -> ProjectLocationSourceFetchInventoryCall<'a, C> {
4771 ProjectLocationSourceFetchInventoryCall {
4772 hub: self.hub,
4773 _source: source.to_string(),
4774 _page_token: Default::default(),
4775 _page_size: Default::default(),
4776 _force_refresh: Default::default(),
4777 _delegate: Default::default(),
4778 _additional_params: Default::default(),
4779 _scopes: Default::default(),
4780 }
4781 }
4782
4783 /// Create a builder to help you perform the following task:
4784 ///
4785 /// List remote source's inventory of storage resources. The remote source is another cloud vendor (e.g. AWS, Azure). The inventory describes the list of existing storage resources in that source. Note that this operation lists the resources on the remote source, as opposed to listing the MigratingVms resources in the vmmigration service.
4786 ///
4787 /// # Arguments
4788 ///
4789 /// * `source` - Required. The name of the Source.
4790 pub fn locations_sources_fetch_storage_inventory(
4791 &self,
4792 source: &str,
4793 ) -> ProjectLocationSourceFetchStorageInventoryCall<'a, C> {
4794 ProjectLocationSourceFetchStorageInventoryCall {
4795 hub: self.hub,
4796 _source: source.to_string(),
4797 _type_: Default::default(),
4798 _page_token: Default::default(),
4799 _page_size: Default::default(),
4800 _force_refresh: Default::default(),
4801 _delegate: Default::default(),
4802 _additional_params: Default::default(),
4803 _scopes: Default::default(),
4804 }
4805 }
4806
4807 /// Create a builder to help you perform the following task:
4808 ///
4809 /// Gets details of a single Source.
4810 ///
4811 /// # Arguments
4812 ///
4813 /// * `name` - Required. The Source name.
4814 pub fn locations_sources_get(&self, name: &str) -> ProjectLocationSourceGetCall<'a, C> {
4815 ProjectLocationSourceGetCall {
4816 hub: self.hub,
4817 _name: name.to_string(),
4818 _delegate: Default::default(),
4819 _additional_params: Default::default(),
4820 _scopes: Default::default(),
4821 }
4822 }
4823
4824 /// Create a builder to help you perform the following task:
4825 ///
4826 /// Lists Sources in a given project and location.
4827 ///
4828 /// # Arguments
4829 ///
4830 /// * `parent` - Required. The parent, which owns this collection of sources.
4831 pub fn locations_sources_list(&self, parent: &str) -> ProjectLocationSourceListCall<'a, C> {
4832 ProjectLocationSourceListCall {
4833 hub: self.hub,
4834 _parent: parent.to_string(),
4835 _page_token: Default::default(),
4836 _page_size: Default::default(),
4837 _order_by: Default::default(),
4838 _filter: Default::default(),
4839 _delegate: Default::default(),
4840 _additional_params: Default::default(),
4841 _scopes: Default::default(),
4842 }
4843 }
4844
4845 /// Create a builder to help you perform the following task:
4846 ///
4847 /// Updates the parameters of a single Source.
4848 ///
4849 /// # Arguments
4850 ///
4851 /// * `request` - No description provided.
4852 /// * `name` - Output only. The Source name.
4853 pub fn locations_sources_patch(
4854 &self,
4855 request: Source,
4856 name: &str,
4857 ) -> ProjectLocationSourcePatchCall<'a, C> {
4858 ProjectLocationSourcePatchCall {
4859 hub: self.hub,
4860 _request: request,
4861 _name: name.to_string(),
4862 _update_mask: Default::default(),
4863 _request_id: Default::default(),
4864 _delegate: Default::default(),
4865 _additional_params: Default::default(),
4866 _scopes: Default::default(),
4867 }
4868 }
4869
4870 /// Create a builder to help you perform the following task:
4871 ///
4872 /// Creates a new TargetProject in a given project. NOTE: TargetProject is a global resource; hence the only supported value for location is `global`.
4873 ///
4874 /// # Arguments
4875 ///
4876 /// * `request` - No description provided.
4877 /// * `parent` - Required. The TargetProject's parent.
4878 pub fn locations_target_projects_create(
4879 &self,
4880 request: TargetProject,
4881 parent: &str,
4882 ) -> ProjectLocationTargetProjectCreateCall<'a, C> {
4883 ProjectLocationTargetProjectCreateCall {
4884 hub: self.hub,
4885 _request: request,
4886 _parent: parent.to_string(),
4887 _target_project_id: Default::default(),
4888 _request_id: Default::default(),
4889 _delegate: Default::default(),
4890 _additional_params: Default::default(),
4891 _scopes: Default::default(),
4892 }
4893 }
4894
4895 /// Create a builder to help you perform the following task:
4896 ///
4897 /// Deletes a single TargetProject. NOTE: TargetProject is a global resource; hence the only supported value for location is `global`.
4898 ///
4899 /// # Arguments
4900 ///
4901 /// * `name` - Required. The TargetProject name.
4902 pub fn locations_target_projects_delete(
4903 &self,
4904 name: &str,
4905 ) -> ProjectLocationTargetProjectDeleteCall<'a, C> {
4906 ProjectLocationTargetProjectDeleteCall {
4907 hub: self.hub,
4908 _name: name.to_string(),
4909 _request_id: Default::default(),
4910 _delegate: Default::default(),
4911 _additional_params: Default::default(),
4912 _scopes: Default::default(),
4913 }
4914 }
4915
4916 /// Create a builder to help you perform the following task:
4917 ///
4918 /// Gets details of a single TargetProject. NOTE: TargetProject is a global resource; hence the only supported value for location is `global`.
4919 ///
4920 /// # Arguments
4921 ///
4922 /// * `name` - Required. The TargetProject name.
4923 pub fn locations_target_projects_get(
4924 &self,
4925 name: &str,
4926 ) -> ProjectLocationTargetProjectGetCall<'a, C> {
4927 ProjectLocationTargetProjectGetCall {
4928 hub: self.hub,
4929 _name: name.to_string(),
4930 _delegate: Default::default(),
4931 _additional_params: Default::default(),
4932 _scopes: Default::default(),
4933 }
4934 }
4935
4936 /// Create a builder to help you perform the following task:
4937 ///
4938 /// Lists TargetProjects in a given project. NOTE: TargetProject is a global resource; hence the only supported value for location is `global`.
4939 ///
4940 /// # Arguments
4941 ///
4942 /// * `parent` - Required. The parent, which owns this collection of targets.
4943 pub fn locations_target_projects_list(
4944 &self,
4945 parent: &str,
4946 ) -> ProjectLocationTargetProjectListCall<'a, C> {
4947 ProjectLocationTargetProjectListCall {
4948 hub: self.hub,
4949 _parent: parent.to_string(),
4950 _page_token: Default::default(),
4951 _page_size: Default::default(),
4952 _order_by: Default::default(),
4953 _filter: Default::default(),
4954 _delegate: Default::default(),
4955 _additional_params: Default::default(),
4956 _scopes: Default::default(),
4957 }
4958 }
4959
4960 /// Create a builder to help you perform the following task:
4961 ///
4962 /// Updates the parameters of a single TargetProject. NOTE: TargetProject is a global resource; hence the only supported value for location is `global`.
4963 ///
4964 /// # Arguments
4965 ///
4966 /// * `request` - No description provided.
4967 /// * `name` - Output only. The name of the target project.
4968 pub fn locations_target_projects_patch(
4969 &self,
4970 request: TargetProject,
4971 name: &str,
4972 ) -> ProjectLocationTargetProjectPatchCall<'a, C> {
4973 ProjectLocationTargetProjectPatchCall {
4974 hub: self.hub,
4975 _request: request,
4976 _name: name.to_string(),
4977 _update_mask: Default::default(),
4978 _request_id: Default::default(),
4979 _delegate: Default::default(),
4980 _additional_params: Default::default(),
4981 _scopes: Default::default(),
4982 }
4983 }
4984
4985 /// Create a builder to help you perform the following task:
4986 ///
4987 /// Gets information about a location.
4988 ///
4989 /// # Arguments
4990 ///
4991 /// * `name` - Resource name for the location.
4992 pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
4993 ProjectLocationGetCall {
4994 hub: self.hub,
4995 _name: name.to_string(),
4996 _delegate: Default::default(),
4997 _additional_params: Default::default(),
4998 _scopes: Default::default(),
4999 }
5000 }
5001
5002 /// Create a builder to help you perform the following task:
5003 ///
5004 /// Lists information about the supported locations for this service.
5005 ///
5006 /// # Arguments
5007 ///
5008 /// * `name` - The resource that owns the locations collection, if applicable.
5009 pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
5010 ProjectLocationListCall {
5011 hub: self.hub,
5012 _name: name.to_string(),
5013 _page_token: Default::default(),
5014 _page_size: Default::default(),
5015 _filter: Default::default(),
5016 _extra_location_types: Default::default(),
5017 _delegate: Default::default(),
5018 _additional_params: Default::default(),
5019 _scopes: Default::default(),
5020 }
5021 }
5022}
5023
5024// ###################
5025// CallBuilders ###
5026// #################
5027
5028/// Adds a MigratingVm to a Group.
5029///
5030/// A builder for the *locations.groups.addGroupMigration* method supported by a *project* resource.
5031/// It is not used directly, but through a [`ProjectMethods`] instance.
5032///
5033/// # Example
5034///
5035/// Instantiate a resource method builder
5036///
5037/// ```test_harness,no_run
5038/// # extern crate hyper;
5039/// # extern crate hyper_rustls;
5040/// # extern crate google_vmmigration1 as vmmigration1;
5041/// use vmmigration1::api::AddGroupMigrationRequest;
5042/// # async fn dox() {
5043/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5044///
5045/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5046/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5047/// # .with_native_roots()
5048/// # .unwrap()
5049/// # .https_only()
5050/// # .enable_http2()
5051/// # .build();
5052///
5053/// # let executor = hyper_util::rt::TokioExecutor::new();
5054/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5055/// # secret,
5056/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5057/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5058/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5059/// # ),
5060/// # ).build().await.unwrap();
5061///
5062/// # let client = hyper_util::client::legacy::Client::builder(
5063/// # hyper_util::rt::TokioExecutor::new()
5064/// # )
5065/// # .build(
5066/// # hyper_rustls::HttpsConnectorBuilder::new()
5067/// # .with_native_roots()
5068/// # .unwrap()
5069/// # .https_or_http()
5070/// # .enable_http2()
5071/// # .build()
5072/// # );
5073/// # let mut hub = VMMigrationService::new(client, auth);
5074/// // As the method needs a request, you would usually fill it with the desired information
5075/// // into the respective structure. Some of the parts shown here might not be applicable !
5076/// // Values shown here are possibly random and not representative !
5077/// let mut req = AddGroupMigrationRequest::default();
5078///
5079/// // You can configure optional parameters by calling the respective setters at will, and
5080/// // execute the final call using `doit()`.
5081/// // Values shown here are possibly random and not representative !
5082/// let result = hub.projects().locations_groups_add_group_migration(req, "group")
5083/// .doit().await;
5084/// # }
5085/// ```
5086pub struct ProjectLocationGroupAddGroupMigrationCall<'a, C>
5087where
5088 C: 'a,
5089{
5090 hub: &'a VMMigrationService<C>,
5091 _request: AddGroupMigrationRequest,
5092 _group: String,
5093 _delegate: Option<&'a mut dyn common::Delegate>,
5094 _additional_params: HashMap<String, String>,
5095 _scopes: BTreeSet<String>,
5096}
5097
5098impl<'a, C> common::CallBuilder for ProjectLocationGroupAddGroupMigrationCall<'a, C> {}
5099
5100impl<'a, C> ProjectLocationGroupAddGroupMigrationCall<'a, C>
5101where
5102 C: common::Connector,
5103{
5104 /// Perform the operation you have build so far.
5105 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5106 use std::borrow::Cow;
5107 use std::io::{Read, Seek};
5108
5109 use common::{url::Params, ToParts};
5110 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5111
5112 let mut dd = common::DefaultDelegate;
5113 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5114 dlg.begin(common::MethodInfo {
5115 id: "vmmigration.projects.locations.groups.addGroupMigration",
5116 http_method: hyper::Method::POST,
5117 });
5118
5119 for &field in ["alt", "group"].iter() {
5120 if self._additional_params.contains_key(field) {
5121 dlg.finished(false);
5122 return Err(common::Error::FieldClash(field));
5123 }
5124 }
5125
5126 let mut params = Params::with_capacity(4 + self._additional_params.len());
5127 params.push("group", self._group);
5128
5129 params.extend(self._additional_params.iter());
5130
5131 params.push("alt", "json");
5132 let mut url = self.hub._base_url.clone() + "v1/{+group}:addGroupMigration";
5133 if self._scopes.is_empty() {
5134 self._scopes
5135 .insert(Scope::CloudPlatform.as_ref().to_string());
5136 }
5137
5138 #[allow(clippy::single_element_loop)]
5139 for &(find_this, param_name) in [("{+group}", "group")].iter() {
5140 url = params.uri_replacement(url, param_name, find_this, true);
5141 }
5142 {
5143 let to_remove = ["group"];
5144 params.remove_params(&to_remove);
5145 }
5146
5147 let url = params.parse_with_url(&url);
5148
5149 let mut json_mime_type = mime::APPLICATION_JSON;
5150 let mut request_value_reader = {
5151 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5152 common::remove_json_null_values(&mut value);
5153 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5154 serde_json::to_writer(&mut dst, &value).unwrap();
5155 dst
5156 };
5157 let request_size = request_value_reader
5158 .seek(std::io::SeekFrom::End(0))
5159 .unwrap();
5160 request_value_reader
5161 .seek(std::io::SeekFrom::Start(0))
5162 .unwrap();
5163
5164 loop {
5165 let token = match self
5166 .hub
5167 .auth
5168 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5169 .await
5170 {
5171 Ok(token) => token,
5172 Err(e) => match dlg.token(e) {
5173 Ok(token) => token,
5174 Err(e) => {
5175 dlg.finished(false);
5176 return Err(common::Error::MissingToken(e));
5177 }
5178 },
5179 };
5180 request_value_reader
5181 .seek(std::io::SeekFrom::Start(0))
5182 .unwrap();
5183 let mut req_result = {
5184 let client = &self.hub.client;
5185 dlg.pre_request();
5186 let mut req_builder = hyper::Request::builder()
5187 .method(hyper::Method::POST)
5188 .uri(url.as_str())
5189 .header(USER_AGENT, self.hub._user_agent.clone());
5190
5191 if let Some(token) = token.as_ref() {
5192 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5193 }
5194
5195 let request = req_builder
5196 .header(CONTENT_TYPE, json_mime_type.to_string())
5197 .header(CONTENT_LENGTH, request_size as u64)
5198 .body(common::to_body(
5199 request_value_reader.get_ref().clone().into(),
5200 ));
5201
5202 client.request(request.unwrap()).await
5203 };
5204
5205 match req_result {
5206 Err(err) => {
5207 if let common::Retry::After(d) = dlg.http_error(&err) {
5208 sleep(d).await;
5209 continue;
5210 }
5211 dlg.finished(false);
5212 return Err(common::Error::HttpError(err));
5213 }
5214 Ok(res) => {
5215 let (mut parts, body) = res.into_parts();
5216 let mut body = common::Body::new(body);
5217 if !parts.status.is_success() {
5218 let bytes = common::to_bytes(body).await.unwrap_or_default();
5219 let error = serde_json::from_str(&common::to_string(&bytes));
5220 let response = common::to_response(parts, bytes.into());
5221
5222 if let common::Retry::After(d) =
5223 dlg.http_failure(&response, error.as_ref().ok())
5224 {
5225 sleep(d).await;
5226 continue;
5227 }
5228
5229 dlg.finished(false);
5230
5231 return Err(match error {
5232 Ok(value) => common::Error::BadRequest(value),
5233 _ => common::Error::Failure(response),
5234 });
5235 }
5236 let response = {
5237 let bytes = common::to_bytes(body).await.unwrap_or_default();
5238 let encoded = common::to_string(&bytes);
5239 match serde_json::from_str(&encoded) {
5240 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5241 Err(error) => {
5242 dlg.response_json_decode_error(&encoded, &error);
5243 return Err(common::Error::JsonDecodeError(
5244 encoded.to_string(),
5245 error,
5246 ));
5247 }
5248 }
5249 };
5250
5251 dlg.finished(true);
5252 return Ok(response);
5253 }
5254 }
5255 }
5256 }
5257
5258 ///
5259 /// Sets the *request* property to the given value.
5260 ///
5261 /// Even though the property as already been set when instantiating this call,
5262 /// we provide this method for API completeness.
5263 pub fn request(
5264 mut self,
5265 new_value: AddGroupMigrationRequest,
5266 ) -> ProjectLocationGroupAddGroupMigrationCall<'a, C> {
5267 self._request = new_value;
5268 self
5269 }
5270 /// Required. The full path name of the Group to add to.
5271 ///
5272 /// Sets the *group* path property to the given value.
5273 ///
5274 /// Even though the property as already been set when instantiating this call,
5275 /// we provide this method for API completeness.
5276 pub fn group(mut self, new_value: &str) -> ProjectLocationGroupAddGroupMigrationCall<'a, C> {
5277 self._group = new_value.to_string();
5278 self
5279 }
5280 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5281 /// while executing the actual API request.
5282 ///
5283 /// ````text
5284 /// It should be used to handle progress information, and to implement a certain level of resilience.
5285 /// ````
5286 ///
5287 /// Sets the *delegate* property to the given value.
5288 pub fn delegate(
5289 mut self,
5290 new_value: &'a mut dyn common::Delegate,
5291 ) -> ProjectLocationGroupAddGroupMigrationCall<'a, C> {
5292 self._delegate = Some(new_value);
5293 self
5294 }
5295
5296 /// Set any additional parameter of the query string used in the request.
5297 /// It should be used to set parameters which are not yet available through their own
5298 /// setters.
5299 ///
5300 /// Please note that this method must not be used to set any of the known parameters
5301 /// which have their own setter method. If done anyway, the request will fail.
5302 ///
5303 /// # Additional Parameters
5304 ///
5305 /// * *$.xgafv* (query-string) - V1 error format.
5306 /// * *access_token* (query-string) - OAuth access token.
5307 /// * *alt* (query-string) - Data format for response.
5308 /// * *callback* (query-string) - JSONP
5309 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5310 /// * *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.
5311 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5312 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5313 /// * *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.
5314 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5315 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5316 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGroupAddGroupMigrationCall<'a, C>
5317 where
5318 T: AsRef<str>,
5319 {
5320 self._additional_params
5321 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5322 self
5323 }
5324
5325 /// Identifies the authorization scope for the method you are building.
5326 ///
5327 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5328 /// [`Scope::CloudPlatform`].
5329 ///
5330 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5331 /// tokens for more than one scope.
5332 ///
5333 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5334 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5335 /// sufficient, a read-write scope will do as well.
5336 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGroupAddGroupMigrationCall<'a, C>
5337 where
5338 St: AsRef<str>,
5339 {
5340 self._scopes.insert(String::from(scope.as_ref()));
5341 self
5342 }
5343 /// Identifies the authorization scope(s) for the method you are building.
5344 ///
5345 /// See [`Self::add_scope()`] for details.
5346 pub fn add_scopes<I, St>(
5347 mut self,
5348 scopes: I,
5349 ) -> ProjectLocationGroupAddGroupMigrationCall<'a, C>
5350 where
5351 I: IntoIterator<Item = St>,
5352 St: AsRef<str>,
5353 {
5354 self._scopes
5355 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5356 self
5357 }
5358
5359 /// Removes all scopes, and no default scope will be used either.
5360 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5361 /// for details).
5362 pub fn clear_scopes(mut self) -> ProjectLocationGroupAddGroupMigrationCall<'a, C> {
5363 self._scopes.clear();
5364 self
5365 }
5366}
5367
5368/// Creates a new Group in a given project and location.
5369///
5370/// A builder for the *locations.groups.create* method supported by a *project* resource.
5371/// It is not used directly, but through a [`ProjectMethods`] instance.
5372///
5373/// # Example
5374///
5375/// Instantiate a resource method builder
5376///
5377/// ```test_harness,no_run
5378/// # extern crate hyper;
5379/// # extern crate hyper_rustls;
5380/// # extern crate google_vmmigration1 as vmmigration1;
5381/// use vmmigration1::api::Group;
5382/// # async fn dox() {
5383/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5384///
5385/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5386/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5387/// # .with_native_roots()
5388/// # .unwrap()
5389/// # .https_only()
5390/// # .enable_http2()
5391/// # .build();
5392///
5393/// # let executor = hyper_util::rt::TokioExecutor::new();
5394/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5395/// # secret,
5396/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5397/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5398/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5399/// # ),
5400/// # ).build().await.unwrap();
5401///
5402/// # let client = hyper_util::client::legacy::Client::builder(
5403/// # hyper_util::rt::TokioExecutor::new()
5404/// # )
5405/// # .build(
5406/// # hyper_rustls::HttpsConnectorBuilder::new()
5407/// # .with_native_roots()
5408/// # .unwrap()
5409/// # .https_or_http()
5410/// # .enable_http2()
5411/// # .build()
5412/// # );
5413/// # let mut hub = VMMigrationService::new(client, auth);
5414/// // As the method needs a request, you would usually fill it with the desired information
5415/// // into the respective structure. Some of the parts shown here might not be applicable !
5416/// // Values shown here are possibly random and not representative !
5417/// let mut req = Group::default();
5418///
5419/// // You can configure optional parameters by calling the respective setters at will, and
5420/// // execute the final call using `doit()`.
5421/// // Values shown here are possibly random and not representative !
5422/// let result = hub.projects().locations_groups_create(req, "parent")
5423/// .request_id("duo")
5424/// .group_id("ipsum")
5425/// .doit().await;
5426/// # }
5427/// ```
5428pub struct ProjectLocationGroupCreateCall<'a, C>
5429where
5430 C: 'a,
5431{
5432 hub: &'a VMMigrationService<C>,
5433 _request: Group,
5434 _parent: String,
5435 _request_id: Option<String>,
5436 _group_id: Option<String>,
5437 _delegate: Option<&'a mut dyn common::Delegate>,
5438 _additional_params: HashMap<String, String>,
5439 _scopes: BTreeSet<String>,
5440}
5441
5442impl<'a, C> common::CallBuilder for ProjectLocationGroupCreateCall<'a, C> {}
5443
5444impl<'a, C> ProjectLocationGroupCreateCall<'a, C>
5445where
5446 C: common::Connector,
5447{
5448 /// Perform the operation you have build so far.
5449 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5450 use std::borrow::Cow;
5451 use std::io::{Read, Seek};
5452
5453 use common::{url::Params, ToParts};
5454 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5455
5456 let mut dd = common::DefaultDelegate;
5457 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5458 dlg.begin(common::MethodInfo {
5459 id: "vmmigration.projects.locations.groups.create",
5460 http_method: hyper::Method::POST,
5461 });
5462
5463 for &field in ["alt", "parent", "requestId", "groupId"].iter() {
5464 if self._additional_params.contains_key(field) {
5465 dlg.finished(false);
5466 return Err(common::Error::FieldClash(field));
5467 }
5468 }
5469
5470 let mut params = Params::with_capacity(6 + self._additional_params.len());
5471 params.push("parent", self._parent);
5472 if let Some(value) = self._request_id.as_ref() {
5473 params.push("requestId", value);
5474 }
5475 if let Some(value) = self._group_id.as_ref() {
5476 params.push("groupId", value);
5477 }
5478
5479 params.extend(self._additional_params.iter());
5480
5481 params.push("alt", "json");
5482 let mut url = self.hub._base_url.clone() + "v1/{+parent}/groups";
5483 if self._scopes.is_empty() {
5484 self._scopes
5485 .insert(Scope::CloudPlatform.as_ref().to_string());
5486 }
5487
5488 #[allow(clippy::single_element_loop)]
5489 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5490 url = params.uri_replacement(url, param_name, find_this, true);
5491 }
5492 {
5493 let to_remove = ["parent"];
5494 params.remove_params(&to_remove);
5495 }
5496
5497 let url = params.parse_with_url(&url);
5498
5499 let mut json_mime_type = mime::APPLICATION_JSON;
5500 let mut request_value_reader = {
5501 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5502 common::remove_json_null_values(&mut value);
5503 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5504 serde_json::to_writer(&mut dst, &value).unwrap();
5505 dst
5506 };
5507 let request_size = request_value_reader
5508 .seek(std::io::SeekFrom::End(0))
5509 .unwrap();
5510 request_value_reader
5511 .seek(std::io::SeekFrom::Start(0))
5512 .unwrap();
5513
5514 loop {
5515 let token = match self
5516 .hub
5517 .auth
5518 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5519 .await
5520 {
5521 Ok(token) => token,
5522 Err(e) => match dlg.token(e) {
5523 Ok(token) => token,
5524 Err(e) => {
5525 dlg.finished(false);
5526 return Err(common::Error::MissingToken(e));
5527 }
5528 },
5529 };
5530 request_value_reader
5531 .seek(std::io::SeekFrom::Start(0))
5532 .unwrap();
5533 let mut req_result = {
5534 let client = &self.hub.client;
5535 dlg.pre_request();
5536 let mut req_builder = hyper::Request::builder()
5537 .method(hyper::Method::POST)
5538 .uri(url.as_str())
5539 .header(USER_AGENT, self.hub._user_agent.clone());
5540
5541 if let Some(token) = token.as_ref() {
5542 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5543 }
5544
5545 let request = req_builder
5546 .header(CONTENT_TYPE, json_mime_type.to_string())
5547 .header(CONTENT_LENGTH, request_size as u64)
5548 .body(common::to_body(
5549 request_value_reader.get_ref().clone().into(),
5550 ));
5551
5552 client.request(request.unwrap()).await
5553 };
5554
5555 match req_result {
5556 Err(err) => {
5557 if let common::Retry::After(d) = dlg.http_error(&err) {
5558 sleep(d).await;
5559 continue;
5560 }
5561 dlg.finished(false);
5562 return Err(common::Error::HttpError(err));
5563 }
5564 Ok(res) => {
5565 let (mut parts, body) = res.into_parts();
5566 let mut body = common::Body::new(body);
5567 if !parts.status.is_success() {
5568 let bytes = common::to_bytes(body).await.unwrap_or_default();
5569 let error = serde_json::from_str(&common::to_string(&bytes));
5570 let response = common::to_response(parts, bytes.into());
5571
5572 if let common::Retry::After(d) =
5573 dlg.http_failure(&response, error.as_ref().ok())
5574 {
5575 sleep(d).await;
5576 continue;
5577 }
5578
5579 dlg.finished(false);
5580
5581 return Err(match error {
5582 Ok(value) => common::Error::BadRequest(value),
5583 _ => common::Error::Failure(response),
5584 });
5585 }
5586 let response = {
5587 let bytes = common::to_bytes(body).await.unwrap_or_default();
5588 let encoded = common::to_string(&bytes);
5589 match serde_json::from_str(&encoded) {
5590 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5591 Err(error) => {
5592 dlg.response_json_decode_error(&encoded, &error);
5593 return Err(common::Error::JsonDecodeError(
5594 encoded.to_string(),
5595 error,
5596 ));
5597 }
5598 }
5599 };
5600
5601 dlg.finished(true);
5602 return Ok(response);
5603 }
5604 }
5605 }
5606 }
5607
5608 ///
5609 /// Sets the *request* property to the given value.
5610 ///
5611 /// Even though the property as already been set when instantiating this call,
5612 /// we provide this method for API completeness.
5613 pub fn request(mut self, new_value: Group) -> ProjectLocationGroupCreateCall<'a, C> {
5614 self._request = new_value;
5615 self
5616 }
5617 /// Required. The Group's parent.
5618 ///
5619 /// Sets the *parent* path property to the given value.
5620 ///
5621 /// Even though the property as already been set when instantiating this call,
5622 /// we provide this method for API completeness.
5623 pub fn parent(mut self, new_value: &str) -> ProjectLocationGroupCreateCall<'a, C> {
5624 self._parent = new_value.to_string();
5625 self
5626 }
5627 /// 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).
5628 ///
5629 /// Sets the *request id* query property to the given value.
5630 pub fn request_id(mut self, new_value: &str) -> ProjectLocationGroupCreateCall<'a, C> {
5631 self._request_id = Some(new_value.to_string());
5632 self
5633 }
5634 /// Required. The group identifier.
5635 ///
5636 /// Sets the *group id* query property to the given value.
5637 pub fn group_id(mut self, new_value: &str) -> ProjectLocationGroupCreateCall<'a, C> {
5638 self._group_id = Some(new_value.to_string());
5639 self
5640 }
5641 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5642 /// while executing the actual API request.
5643 ///
5644 /// ````text
5645 /// It should be used to handle progress information, and to implement a certain level of resilience.
5646 /// ````
5647 ///
5648 /// Sets the *delegate* property to the given value.
5649 pub fn delegate(
5650 mut self,
5651 new_value: &'a mut dyn common::Delegate,
5652 ) -> ProjectLocationGroupCreateCall<'a, C> {
5653 self._delegate = Some(new_value);
5654 self
5655 }
5656
5657 /// Set any additional parameter of the query string used in the request.
5658 /// It should be used to set parameters which are not yet available through their own
5659 /// setters.
5660 ///
5661 /// Please note that this method must not be used to set any of the known parameters
5662 /// which have their own setter method. If done anyway, the request will fail.
5663 ///
5664 /// # Additional Parameters
5665 ///
5666 /// * *$.xgafv* (query-string) - V1 error format.
5667 /// * *access_token* (query-string) - OAuth access token.
5668 /// * *alt* (query-string) - Data format for response.
5669 /// * *callback* (query-string) - JSONP
5670 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5671 /// * *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.
5672 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5673 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5674 /// * *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.
5675 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5676 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5677 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGroupCreateCall<'a, C>
5678 where
5679 T: AsRef<str>,
5680 {
5681 self._additional_params
5682 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5683 self
5684 }
5685
5686 /// Identifies the authorization scope for the method you are building.
5687 ///
5688 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5689 /// [`Scope::CloudPlatform`].
5690 ///
5691 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5692 /// tokens for more than one scope.
5693 ///
5694 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5695 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5696 /// sufficient, a read-write scope will do as well.
5697 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGroupCreateCall<'a, C>
5698 where
5699 St: AsRef<str>,
5700 {
5701 self._scopes.insert(String::from(scope.as_ref()));
5702 self
5703 }
5704 /// Identifies the authorization scope(s) for the method you are building.
5705 ///
5706 /// See [`Self::add_scope()`] for details.
5707 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGroupCreateCall<'a, C>
5708 where
5709 I: IntoIterator<Item = St>,
5710 St: AsRef<str>,
5711 {
5712 self._scopes
5713 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5714 self
5715 }
5716
5717 /// Removes all scopes, and no default scope will be used either.
5718 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5719 /// for details).
5720 pub fn clear_scopes(mut self) -> ProjectLocationGroupCreateCall<'a, C> {
5721 self._scopes.clear();
5722 self
5723 }
5724}
5725
5726/// Deletes a single Group.
5727///
5728/// A builder for the *locations.groups.delete* method supported by a *project* resource.
5729/// It is not used directly, but through a [`ProjectMethods`] instance.
5730///
5731/// # Example
5732///
5733/// Instantiate a resource method builder
5734///
5735/// ```test_harness,no_run
5736/// # extern crate hyper;
5737/// # extern crate hyper_rustls;
5738/// # extern crate google_vmmigration1 as vmmigration1;
5739/// # async fn dox() {
5740/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5741///
5742/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5743/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5744/// # .with_native_roots()
5745/// # .unwrap()
5746/// # .https_only()
5747/// # .enable_http2()
5748/// # .build();
5749///
5750/// # let executor = hyper_util::rt::TokioExecutor::new();
5751/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5752/// # secret,
5753/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5754/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5755/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5756/// # ),
5757/// # ).build().await.unwrap();
5758///
5759/// # let client = hyper_util::client::legacy::Client::builder(
5760/// # hyper_util::rt::TokioExecutor::new()
5761/// # )
5762/// # .build(
5763/// # hyper_rustls::HttpsConnectorBuilder::new()
5764/// # .with_native_roots()
5765/// # .unwrap()
5766/// # .https_or_http()
5767/// # .enable_http2()
5768/// # .build()
5769/// # );
5770/// # let mut hub = VMMigrationService::new(client, auth);
5771/// // You can configure optional parameters by calling the respective setters at will, and
5772/// // execute the final call using `doit()`.
5773/// // Values shown here are possibly random and not representative !
5774/// let result = hub.projects().locations_groups_delete("name")
5775/// .request_id("Lorem")
5776/// .doit().await;
5777/// # }
5778/// ```
5779pub struct ProjectLocationGroupDeleteCall<'a, C>
5780where
5781 C: 'a,
5782{
5783 hub: &'a VMMigrationService<C>,
5784 _name: String,
5785 _request_id: Option<String>,
5786 _delegate: Option<&'a mut dyn common::Delegate>,
5787 _additional_params: HashMap<String, String>,
5788 _scopes: BTreeSet<String>,
5789}
5790
5791impl<'a, C> common::CallBuilder for ProjectLocationGroupDeleteCall<'a, C> {}
5792
5793impl<'a, C> ProjectLocationGroupDeleteCall<'a, C>
5794where
5795 C: common::Connector,
5796{
5797 /// Perform the operation you have build so far.
5798 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5799 use std::borrow::Cow;
5800 use std::io::{Read, Seek};
5801
5802 use common::{url::Params, ToParts};
5803 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5804
5805 let mut dd = common::DefaultDelegate;
5806 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5807 dlg.begin(common::MethodInfo {
5808 id: "vmmigration.projects.locations.groups.delete",
5809 http_method: hyper::Method::DELETE,
5810 });
5811
5812 for &field in ["alt", "name", "requestId"].iter() {
5813 if self._additional_params.contains_key(field) {
5814 dlg.finished(false);
5815 return Err(common::Error::FieldClash(field));
5816 }
5817 }
5818
5819 let mut params = Params::with_capacity(4 + self._additional_params.len());
5820 params.push("name", self._name);
5821 if let Some(value) = self._request_id.as_ref() {
5822 params.push("requestId", value);
5823 }
5824
5825 params.extend(self._additional_params.iter());
5826
5827 params.push("alt", "json");
5828 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5829 if self._scopes.is_empty() {
5830 self._scopes
5831 .insert(Scope::CloudPlatform.as_ref().to_string());
5832 }
5833
5834 #[allow(clippy::single_element_loop)]
5835 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5836 url = params.uri_replacement(url, param_name, find_this, true);
5837 }
5838 {
5839 let to_remove = ["name"];
5840 params.remove_params(&to_remove);
5841 }
5842
5843 let url = params.parse_with_url(&url);
5844
5845 loop {
5846 let token = match self
5847 .hub
5848 .auth
5849 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5850 .await
5851 {
5852 Ok(token) => token,
5853 Err(e) => match dlg.token(e) {
5854 Ok(token) => token,
5855 Err(e) => {
5856 dlg.finished(false);
5857 return Err(common::Error::MissingToken(e));
5858 }
5859 },
5860 };
5861 let mut req_result = {
5862 let client = &self.hub.client;
5863 dlg.pre_request();
5864 let mut req_builder = hyper::Request::builder()
5865 .method(hyper::Method::DELETE)
5866 .uri(url.as_str())
5867 .header(USER_AGENT, self.hub._user_agent.clone());
5868
5869 if let Some(token) = token.as_ref() {
5870 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5871 }
5872
5873 let request = req_builder
5874 .header(CONTENT_LENGTH, 0_u64)
5875 .body(common::to_body::<String>(None));
5876
5877 client.request(request.unwrap()).await
5878 };
5879
5880 match req_result {
5881 Err(err) => {
5882 if let common::Retry::After(d) = dlg.http_error(&err) {
5883 sleep(d).await;
5884 continue;
5885 }
5886 dlg.finished(false);
5887 return Err(common::Error::HttpError(err));
5888 }
5889 Ok(res) => {
5890 let (mut parts, body) = res.into_parts();
5891 let mut body = common::Body::new(body);
5892 if !parts.status.is_success() {
5893 let bytes = common::to_bytes(body).await.unwrap_or_default();
5894 let error = serde_json::from_str(&common::to_string(&bytes));
5895 let response = common::to_response(parts, bytes.into());
5896
5897 if let common::Retry::After(d) =
5898 dlg.http_failure(&response, error.as_ref().ok())
5899 {
5900 sleep(d).await;
5901 continue;
5902 }
5903
5904 dlg.finished(false);
5905
5906 return Err(match error {
5907 Ok(value) => common::Error::BadRequest(value),
5908 _ => common::Error::Failure(response),
5909 });
5910 }
5911 let response = {
5912 let bytes = common::to_bytes(body).await.unwrap_or_default();
5913 let encoded = common::to_string(&bytes);
5914 match serde_json::from_str(&encoded) {
5915 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5916 Err(error) => {
5917 dlg.response_json_decode_error(&encoded, &error);
5918 return Err(common::Error::JsonDecodeError(
5919 encoded.to_string(),
5920 error,
5921 ));
5922 }
5923 }
5924 };
5925
5926 dlg.finished(true);
5927 return Ok(response);
5928 }
5929 }
5930 }
5931 }
5932
5933 /// Required. The Group name.
5934 ///
5935 /// Sets the *name* path property to the given value.
5936 ///
5937 /// Even though the property as already been set when instantiating this call,
5938 /// we provide this method for API completeness.
5939 pub fn name(mut self, new_value: &str) -> ProjectLocationGroupDeleteCall<'a, C> {
5940 self._name = new_value.to_string();
5941 self
5942 }
5943 /// 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).
5944 ///
5945 /// Sets the *request id* query property to the given value.
5946 pub fn request_id(mut self, new_value: &str) -> ProjectLocationGroupDeleteCall<'a, C> {
5947 self._request_id = Some(new_value.to_string());
5948 self
5949 }
5950 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5951 /// while executing the actual API request.
5952 ///
5953 /// ````text
5954 /// It should be used to handle progress information, and to implement a certain level of resilience.
5955 /// ````
5956 ///
5957 /// Sets the *delegate* property to the given value.
5958 pub fn delegate(
5959 mut self,
5960 new_value: &'a mut dyn common::Delegate,
5961 ) -> ProjectLocationGroupDeleteCall<'a, C> {
5962 self._delegate = Some(new_value);
5963 self
5964 }
5965
5966 /// Set any additional parameter of the query string used in the request.
5967 /// It should be used to set parameters which are not yet available through their own
5968 /// setters.
5969 ///
5970 /// Please note that this method must not be used to set any of the known parameters
5971 /// which have their own setter method. If done anyway, the request will fail.
5972 ///
5973 /// # Additional Parameters
5974 ///
5975 /// * *$.xgafv* (query-string) - V1 error format.
5976 /// * *access_token* (query-string) - OAuth access token.
5977 /// * *alt* (query-string) - Data format for response.
5978 /// * *callback* (query-string) - JSONP
5979 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5980 /// * *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.
5981 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5982 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5983 /// * *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.
5984 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5985 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5986 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGroupDeleteCall<'a, C>
5987 where
5988 T: AsRef<str>,
5989 {
5990 self._additional_params
5991 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5992 self
5993 }
5994
5995 /// Identifies the authorization scope for the method you are building.
5996 ///
5997 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5998 /// [`Scope::CloudPlatform`].
5999 ///
6000 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6001 /// tokens for more than one scope.
6002 ///
6003 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6004 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6005 /// sufficient, a read-write scope will do as well.
6006 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGroupDeleteCall<'a, C>
6007 where
6008 St: AsRef<str>,
6009 {
6010 self._scopes.insert(String::from(scope.as_ref()));
6011 self
6012 }
6013 /// Identifies the authorization scope(s) for the method you are building.
6014 ///
6015 /// See [`Self::add_scope()`] for details.
6016 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGroupDeleteCall<'a, C>
6017 where
6018 I: IntoIterator<Item = St>,
6019 St: AsRef<str>,
6020 {
6021 self._scopes
6022 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6023 self
6024 }
6025
6026 /// Removes all scopes, and no default scope will be used either.
6027 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6028 /// for details).
6029 pub fn clear_scopes(mut self) -> ProjectLocationGroupDeleteCall<'a, C> {
6030 self._scopes.clear();
6031 self
6032 }
6033}
6034
6035/// Gets details of a single Group.
6036///
6037/// A builder for the *locations.groups.get* method supported by a *project* resource.
6038/// It is not used directly, but through a [`ProjectMethods`] instance.
6039///
6040/// # Example
6041///
6042/// Instantiate a resource method builder
6043///
6044/// ```test_harness,no_run
6045/// # extern crate hyper;
6046/// # extern crate hyper_rustls;
6047/// # extern crate google_vmmigration1 as vmmigration1;
6048/// # async fn dox() {
6049/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6050///
6051/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6052/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6053/// # .with_native_roots()
6054/// # .unwrap()
6055/// # .https_only()
6056/// # .enable_http2()
6057/// # .build();
6058///
6059/// # let executor = hyper_util::rt::TokioExecutor::new();
6060/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6061/// # secret,
6062/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6063/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6064/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6065/// # ),
6066/// # ).build().await.unwrap();
6067///
6068/// # let client = hyper_util::client::legacy::Client::builder(
6069/// # hyper_util::rt::TokioExecutor::new()
6070/// # )
6071/// # .build(
6072/// # hyper_rustls::HttpsConnectorBuilder::new()
6073/// # .with_native_roots()
6074/// # .unwrap()
6075/// # .https_or_http()
6076/// # .enable_http2()
6077/// # .build()
6078/// # );
6079/// # let mut hub = VMMigrationService::new(client, auth);
6080/// // You can configure optional parameters by calling the respective setters at will, and
6081/// // execute the final call using `doit()`.
6082/// // Values shown here are possibly random and not representative !
6083/// let result = hub.projects().locations_groups_get("name")
6084/// .doit().await;
6085/// # }
6086/// ```
6087pub struct ProjectLocationGroupGetCall<'a, C>
6088where
6089 C: 'a,
6090{
6091 hub: &'a VMMigrationService<C>,
6092 _name: String,
6093 _delegate: Option<&'a mut dyn common::Delegate>,
6094 _additional_params: HashMap<String, String>,
6095 _scopes: BTreeSet<String>,
6096}
6097
6098impl<'a, C> common::CallBuilder for ProjectLocationGroupGetCall<'a, C> {}
6099
6100impl<'a, C> ProjectLocationGroupGetCall<'a, C>
6101where
6102 C: common::Connector,
6103{
6104 /// Perform the operation you have build so far.
6105 pub async fn doit(mut self) -> common::Result<(common::Response, Group)> {
6106 use std::borrow::Cow;
6107 use std::io::{Read, Seek};
6108
6109 use common::{url::Params, ToParts};
6110 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6111
6112 let mut dd = common::DefaultDelegate;
6113 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6114 dlg.begin(common::MethodInfo {
6115 id: "vmmigration.projects.locations.groups.get",
6116 http_method: hyper::Method::GET,
6117 });
6118
6119 for &field in ["alt", "name"].iter() {
6120 if self._additional_params.contains_key(field) {
6121 dlg.finished(false);
6122 return Err(common::Error::FieldClash(field));
6123 }
6124 }
6125
6126 let mut params = Params::with_capacity(3 + self._additional_params.len());
6127 params.push("name", self._name);
6128
6129 params.extend(self._additional_params.iter());
6130
6131 params.push("alt", "json");
6132 let mut url = self.hub._base_url.clone() + "v1/{+name}";
6133 if self._scopes.is_empty() {
6134 self._scopes
6135 .insert(Scope::CloudPlatform.as_ref().to_string());
6136 }
6137
6138 #[allow(clippy::single_element_loop)]
6139 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6140 url = params.uri_replacement(url, param_name, find_this, true);
6141 }
6142 {
6143 let to_remove = ["name"];
6144 params.remove_params(&to_remove);
6145 }
6146
6147 let url = params.parse_with_url(&url);
6148
6149 loop {
6150 let token = match self
6151 .hub
6152 .auth
6153 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6154 .await
6155 {
6156 Ok(token) => token,
6157 Err(e) => match dlg.token(e) {
6158 Ok(token) => token,
6159 Err(e) => {
6160 dlg.finished(false);
6161 return Err(common::Error::MissingToken(e));
6162 }
6163 },
6164 };
6165 let mut req_result = {
6166 let client = &self.hub.client;
6167 dlg.pre_request();
6168 let mut req_builder = hyper::Request::builder()
6169 .method(hyper::Method::GET)
6170 .uri(url.as_str())
6171 .header(USER_AGENT, self.hub._user_agent.clone());
6172
6173 if let Some(token) = token.as_ref() {
6174 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6175 }
6176
6177 let request = req_builder
6178 .header(CONTENT_LENGTH, 0_u64)
6179 .body(common::to_body::<String>(None));
6180
6181 client.request(request.unwrap()).await
6182 };
6183
6184 match req_result {
6185 Err(err) => {
6186 if let common::Retry::After(d) = dlg.http_error(&err) {
6187 sleep(d).await;
6188 continue;
6189 }
6190 dlg.finished(false);
6191 return Err(common::Error::HttpError(err));
6192 }
6193 Ok(res) => {
6194 let (mut parts, body) = res.into_parts();
6195 let mut body = common::Body::new(body);
6196 if !parts.status.is_success() {
6197 let bytes = common::to_bytes(body).await.unwrap_or_default();
6198 let error = serde_json::from_str(&common::to_string(&bytes));
6199 let response = common::to_response(parts, bytes.into());
6200
6201 if let common::Retry::After(d) =
6202 dlg.http_failure(&response, error.as_ref().ok())
6203 {
6204 sleep(d).await;
6205 continue;
6206 }
6207
6208 dlg.finished(false);
6209
6210 return Err(match error {
6211 Ok(value) => common::Error::BadRequest(value),
6212 _ => common::Error::Failure(response),
6213 });
6214 }
6215 let response = {
6216 let bytes = common::to_bytes(body).await.unwrap_or_default();
6217 let encoded = common::to_string(&bytes);
6218 match serde_json::from_str(&encoded) {
6219 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6220 Err(error) => {
6221 dlg.response_json_decode_error(&encoded, &error);
6222 return Err(common::Error::JsonDecodeError(
6223 encoded.to_string(),
6224 error,
6225 ));
6226 }
6227 }
6228 };
6229
6230 dlg.finished(true);
6231 return Ok(response);
6232 }
6233 }
6234 }
6235 }
6236
6237 /// Required. The group name.
6238 ///
6239 /// Sets the *name* path property to the given value.
6240 ///
6241 /// Even though the property as already been set when instantiating this call,
6242 /// we provide this method for API completeness.
6243 pub fn name(mut self, new_value: &str) -> ProjectLocationGroupGetCall<'a, C> {
6244 self._name = new_value.to_string();
6245 self
6246 }
6247 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6248 /// while executing the actual API request.
6249 ///
6250 /// ````text
6251 /// It should be used to handle progress information, and to implement a certain level of resilience.
6252 /// ````
6253 ///
6254 /// Sets the *delegate* property to the given value.
6255 pub fn delegate(
6256 mut self,
6257 new_value: &'a mut dyn common::Delegate,
6258 ) -> ProjectLocationGroupGetCall<'a, C> {
6259 self._delegate = Some(new_value);
6260 self
6261 }
6262
6263 /// Set any additional parameter of the query string used in the request.
6264 /// It should be used to set parameters which are not yet available through their own
6265 /// setters.
6266 ///
6267 /// Please note that this method must not be used to set any of the known parameters
6268 /// which have their own setter method. If done anyway, the request will fail.
6269 ///
6270 /// # Additional Parameters
6271 ///
6272 /// * *$.xgafv* (query-string) - V1 error format.
6273 /// * *access_token* (query-string) - OAuth access token.
6274 /// * *alt* (query-string) - Data format for response.
6275 /// * *callback* (query-string) - JSONP
6276 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6277 /// * *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.
6278 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6279 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6280 /// * *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.
6281 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6282 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6283 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGroupGetCall<'a, C>
6284 where
6285 T: AsRef<str>,
6286 {
6287 self._additional_params
6288 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6289 self
6290 }
6291
6292 /// Identifies the authorization scope for the method you are building.
6293 ///
6294 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6295 /// [`Scope::CloudPlatform`].
6296 ///
6297 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6298 /// tokens for more than one scope.
6299 ///
6300 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6301 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6302 /// sufficient, a read-write scope will do as well.
6303 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGroupGetCall<'a, C>
6304 where
6305 St: AsRef<str>,
6306 {
6307 self._scopes.insert(String::from(scope.as_ref()));
6308 self
6309 }
6310 /// Identifies the authorization scope(s) for the method you are building.
6311 ///
6312 /// See [`Self::add_scope()`] for details.
6313 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGroupGetCall<'a, C>
6314 where
6315 I: IntoIterator<Item = St>,
6316 St: AsRef<str>,
6317 {
6318 self._scopes
6319 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6320 self
6321 }
6322
6323 /// Removes all scopes, and no default scope will be used either.
6324 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6325 /// for details).
6326 pub fn clear_scopes(mut self) -> ProjectLocationGroupGetCall<'a, C> {
6327 self._scopes.clear();
6328 self
6329 }
6330}
6331
6332/// Lists Groups in a given project and location.
6333///
6334/// A builder for the *locations.groups.list* method supported by a *project* resource.
6335/// It is not used directly, but through a [`ProjectMethods`] instance.
6336///
6337/// # Example
6338///
6339/// Instantiate a resource method builder
6340///
6341/// ```test_harness,no_run
6342/// # extern crate hyper;
6343/// # extern crate hyper_rustls;
6344/// # extern crate google_vmmigration1 as vmmigration1;
6345/// # async fn dox() {
6346/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6347///
6348/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6349/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6350/// # .with_native_roots()
6351/// # .unwrap()
6352/// # .https_only()
6353/// # .enable_http2()
6354/// # .build();
6355///
6356/// # let executor = hyper_util::rt::TokioExecutor::new();
6357/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6358/// # secret,
6359/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6360/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6361/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6362/// # ),
6363/// # ).build().await.unwrap();
6364///
6365/// # let client = hyper_util::client::legacy::Client::builder(
6366/// # hyper_util::rt::TokioExecutor::new()
6367/// # )
6368/// # .build(
6369/// # hyper_rustls::HttpsConnectorBuilder::new()
6370/// # .with_native_roots()
6371/// # .unwrap()
6372/// # .https_or_http()
6373/// # .enable_http2()
6374/// # .build()
6375/// # );
6376/// # let mut hub = VMMigrationService::new(client, auth);
6377/// // You can configure optional parameters by calling the respective setters at will, and
6378/// // execute the final call using `doit()`.
6379/// // Values shown here are possibly random and not representative !
6380/// let result = hub.projects().locations_groups_list("parent")
6381/// .page_token("dolor")
6382/// .page_size(-17)
6383/// .order_by("ipsum")
6384/// .filter("invidunt")
6385/// .doit().await;
6386/// # }
6387/// ```
6388pub struct ProjectLocationGroupListCall<'a, C>
6389where
6390 C: 'a,
6391{
6392 hub: &'a VMMigrationService<C>,
6393 _parent: String,
6394 _page_token: Option<String>,
6395 _page_size: Option<i32>,
6396 _order_by: Option<String>,
6397 _filter: Option<String>,
6398 _delegate: Option<&'a mut dyn common::Delegate>,
6399 _additional_params: HashMap<String, String>,
6400 _scopes: BTreeSet<String>,
6401}
6402
6403impl<'a, C> common::CallBuilder for ProjectLocationGroupListCall<'a, C> {}
6404
6405impl<'a, C> ProjectLocationGroupListCall<'a, C>
6406where
6407 C: common::Connector,
6408{
6409 /// Perform the operation you have build so far.
6410 pub async fn doit(mut self) -> common::Result<(common::Response, ListGroupsResponse)> {
6411 use std::borrow::Cow;
6412 use std::io::{Read, Seek};
6413
6414 use common::{url::Params, ToParts};
6415 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6416
6417 let mut dd = common::DefaultDelegate;
6418 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6419 dlg.begin(common::MethodInfo {
6420 id: "vmmigration.projects.locations.groups.list",
6421 http_method: hyper::Method::GET,
6422 });
6423
6424 for &field in [
6425 "alt",
6426 "parent",
6427 "pageToken",
6428 "pageSize",
6429 "orderBy",
6430 "filter",
6431 ]
6432 .iter()
6433 {
6434 if self._additional_params.contains_key(field) {
6435 dlg.finished(false);
6436 return Err(common::Error::FieldClash(field));
6437 }
6438 }
6439
6440 let mut params = Params::with_capacity(7 + self._additional_params.len());
6441 params.push("parent", self._parent);
6442 if let Some(value) = self._page_token.as_ref() {
6443 params.push("pageToken", value);
6444 }
6445 if let Some(value) = self._page_size.as_ref() {
6446 params.push("pageSize", value.to_string());
6447 }
6448 if let Some(value) = self._order_by.as_ref() {
6449 params.push("orderBy", value);
6450 }
6451 if let Some(value) = self._filter.as_ref() {
6452 params.push("filter", value);
6453 }
6454
6455 params.extend(self._additional_params.iter());
6456
6457 params.push("alt", "json");
6458 let mut url = self.hub._base_url.clone() + "v1/{+parent}/groups";
6459 if self._scopes.is_empty() {
6460 self._scopes
6461 .insert(Scope::CloudPlatform.as_ref().to_string());
6462 }
6463
6464 #[allow(clippy::single_element_loop)]
6465 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6466 url = params.uri_replacement(url, param_name, find_this, true);
6467 }
6468 {
6469 let to_remove = ["parent"];
6470 params.remove_params(&to_remove);
6471 }
6472
6473 let url = params.parse_with_url(&url);
6474
6475 loop {
6476 let token = match self
6477 .hub
6478 .auth
6479 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6480 .await
6481 {
6482 Ok(token) => token,
6483 Err(e) => match dlg.token(e) {
6484 Ok(token) => token,
6485 Err(e) => {
6486 dlg.finished(false);
6487 return Err(common::Error::MissingToken(e));
6488 }
6489 },
6490 };
6491 let mut req_result = {
6492 let client = &self.hub.client;
6493 dlg.pre_request();
6494 let mut req_builder = hyper::Request::builder()
6495 .method(hyper::Method::GET)
6496 .uri(url.as_str())
6497 .header(USER_AGENT, self.hub._user_agent.clone());
6498
6499 if let Some(token) = token.as_ref() {
6500 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6501 }
6502
6503 let request = req_builder
6504 .header(CONTENT_LENGTH, 0_u64)
6505 .body(common::to_body::<String>(None));
6506
6507 client.request(request.unwrap()).await
6508 };
6509
6510 match req_result {
6511 Err(err) => {
6512 if let common::Retry::After(d) = dlg.http_error(&err) {
6513 sleep(d).await;
6514 continue;
6515 }
6516 dlg.finished(false);
6517 return Err(common::Error::HttpError(err));
6518 }
6519 Ok(res) => {
6520 let (mut parts, body) = res.into_parts();
6521 let mut body = common::Body::new(body);
6522 if !parts.status.is_success() {
6523 let bytes = common::to_bytes(body).await.unwrap_or_default();
6524 let error = serde_json::from_str(&common::to_string(&bytes));
6525 let response = common::to_response(parts, bytes.into());
6526
6527 if let common::Retry::After(d) =
6528 dlg.http_failure(&response, error.as_ref().ok())
6529 {
6530 sleep(d).await;
6531 continue;
6532 }
6533
6534 dlg.finished(false);
6535
6536 return Err(match error {
6537 Ok(value) => common::Error::BadRequest(value),
6538 _ => common::Error::Failure(response),
6539 });
6540 }
6541 let response = {
6542 let bytes = common::to_bytes(body).await.unwrap_or_default();
6543 let encoded = common::to_string(&bytes);
6544 match serde_json::from_str(&encoded) {
6545 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6546 Err(error) => {
6547 dlg.response_json_decode_error(&encoded, &error);
6548 return Err(common::Error::JsonDecodeError(
6549 encoded.to_string(),
6550 error,
6551 ));
6552 }
6553 }
6554 };
6555
6556 dlg.finished(true);
6557 return Ok(response);
6558 }
6559 }
6560 }
6561 }
6562
6563 /// Required. The parent, which owns this collection of groups.
6564 ///
6565 /// Sets the *parent* path property to the given value.
6566 ///
6567 /// Even though the property as already been set when instantiating this call,
6568 /// we provide this method for API completeness.
6569 pub fn parent(mut self, new_value: &str) -> ProjectLocationGroupListCall<'a, C> {
6570 self._parent = new_value.to_string();
6571 self
6572 }
6573 /// 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.
6574 ///
6575 /// Sets the *page token* query property to the given value.
6576 pub fn page_token(mut self, new_value: &str) -> ProjectLocationGroupListCall<'a, C> {
6577 self._page_token = Some(new_value.to_string());
6578 self
6579 }
6580 /// 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.
6581 ///
6582 /// Sets the *page size* query property to the given value.
6583 pub fn page_size(mut self, new_value: i32) -> ProjectLocationGroupListCall<'a, C> {
6584 self._page_size = Some(new_value);
6585 self
6586 }
6587 /// Optional. the order by fields for the result.
6588 ///
6589 /// Sets the *order by* query property to the given value.
6590 pub fn order_by(mut self, new_value: &str) -> ProjectLocationGroupListCall<'a, C> {
6591 self._order_by = Some(new_value.to_string());
6592 self
6593 }
6594 /// Optional. The filter request.
6595 ///
6596 /// Sets the *filter* query property to the given value.
6597 pub fn filter(mut self, new_value: &str) -> ProjectLocationGroupListCall<'a, C> {
6598 self._filter = Some(new_value.to_string());
6599 self
6600 }
6601 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6602 /// while executing the actual API request.
6603 ///
6604 /// ````text
6605 /// It should be used to handle progress information, and to implement a certain level of resilience.
6606 /// ````
6607 ///
6608 /// Sets the *delegate* property to the given value.
6609 pub fn delegate(
6610 mut self,
6611 new_value: &'a mut dyn common::Delegate,
6612 ) -> ProjectLocationGroupListCall<'a, C> {
6613 self._delegate = Some(new_value);
6614 self
6615 }
6616
6617 /// Set any additional parameter of the query string used in the request.
6618 /// It should be used to set parameters which are not yet available through their own
6619 /// setters.
6620 ///
6621 /// Please note that this method must not be used to set any of the known parameters
6622 /// which have their own setter method. If done anyway, the request will fail.
6623 ///
6624 /// # Additional Parameters
6625 ///
6626 /// * *$.xgafv* (query-string) - V1 error format.
6627 /// * *access_token* (query-string) - OAuth access token.
6628 /// * *alt* (query-string) - Data format for response.
6629 /// * *callback* (query-string) - JSONP
6630 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6631 /// * *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.
6632 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6633 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6634 /// * *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.
6635 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6636 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6637 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGroupListCall<'a, C>
6638 where
6639 T: AsRef<str>,
6640 {
6641 self._additional_params
6642 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6643 self
6644 }
6645
6646 /// Identifies the authorization scope for the method you are building.
6647 ///
6648 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6649 /// [`Scope::CloudPlatform`].
6650 ///
6651 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6652 /// tokens for more than one scope.
6653 ///
6654 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6655 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6656 /// sufficient, a read-write scope will do as well.
6657 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGroupListCall<'a, C>
6658 where
6659 St: AsRef<str>,
6660 {
6661 self._scopes.insert(String::from(scope.as_ref()));
6662 self
6663 }
6664 /// Identifies the authorization scope(s) for the method you are building.
6665 ///
6666 /// See [`Self::add_scope()`] for details.
6667 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGroupListCall<'a, C>
6668 where
6669 I: IntoIterator<Item = St>,
6670 St: AsRef<str>,
6671 {
6672 self._scopes
6673 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6674 self
6675 }
6676
6677 /// Removes all scopes, and no default scope will be used either.
6678 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6679 /// for details).
6680 pub fn clear_scopes(mut self) -> ProjectLocationGroupListCall<'a, C> {
6681 self._scopes.clear();
6682 self
6683 }
6684}
6685
6686/// Updates the parameters of a single Group.
6687///
6688/// A builder for the *locations.groups.patch* method supported by a *project* resource.
6689/// It is not used directly, but through a [`ProjectMethods`] instance.
6690///
6691/// # Example
6692///
6693/// Instantiate a resource method builder
6694///
6695/// ```test_harness,no_run
6696/// # extern crate hyper;
6697/// # extern crate hyper_rustls;
6698/// # extern crate google_vmmigration1 as vmmigration1;
6699/// use vmmigration1::api::Group;
6700/// # async fn dox() {
6701/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6702///
6703/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6704/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6705/// # .with_native_roots()
6706/// # .unwrap()
6707/// # .https_only()
6708/// # .enable_http2()
6709/// # .build();
6710///
6711/// # let executor = hyper_util::rt::TokioExecutor::new();
6712/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6713/// # secret,
6714/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6715/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6716/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6717/// # ),
6718/// # ).build().await.unwrap();
6719///
6720/// # let client = hyper_util::client::legacy::Client::builder(
6721/// # hyper_util::rt::TokioExecutor::new()
6722/// # )
6723/// # .build(
6724/// # hyper_rustls::HttpsConnectorBuilder::new()
6725/// # .with_native_roots()
6726/// # .unwrap()
6727/// # .https_or_http()
6728/// # .enable_http2()
6729/// # .build()
6730/// # );
6731/// # let mut hub = VMMigrationService::new(client, auth);
6732/// // As the method needs a request, you would usually fill it with the desired information
6733/// // into the respective structure. Some of the parts shown here might not be applicable !
6734/// // Values shown here are possibly random and not representative !
6735/// let mut req = Group::default();
6736///
6737/// // You can configure optional parameters by calling the respective setters at will, and
6738/// // execute the final call using `doit()`.
6739/// // Values shown here are possibly random and not representative !
6740/// let result = hub.projects().locations_groups_patch(req, "name")
6741/// .update_mask(FieldMask::new::<&str>(&[]))
6742/// .request_id("duo")
6743/// .doit().await;
6744/// # }
6745/// ```
6746pub struct ProjectLocationGroupPatchCall<'a, C>
6747where
6748 C: 'a,
6749{
6750 hub: &'a VMMigrationService<C>,
6751 _request: Group,
6752 _name: String,
6753 _update_mask: Option<common::FieldMask>,
6754 _request_id: Option<String>,
6755 _delegate: Option<&'a mut dyn common::Delegate>,
6756 _additional_params: HashMap<String, String>,
6757 _scopes: BTreeSet<String>,
6758}
6759
6760impl<'a, C> common::CallBuilder for ProjectLocationGroupPatchCall<'a, C> {}
6761
6762impl<'a, C> ProjectLocationGroupPatchCall<'a, C>
6763where
6764 C: common::Connector,
6765{
6766 /// Perform the operation you have build so far.
6767 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6768 use std::borrow::Cow;
6769 use std::io::{Read, Seek};
6770
6771 use common::{url::Params, ToParts};
6772 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6773
6774 let mut dd = common::DefaultDelegate;
6775 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6776 dlg.begin(common::MethodInfo {
6777 id: "vmmigration.projects.locations.groups.patch",
6778 http_method: hyper::Method::PATCH,
6779 });
6780
6781 for &field in ["alt", "name", "updateMask", "requestId"].iter() {
6782 if self._additional_params.contains_key(field) {
6783 dlg.finished(false);
6784 return Err(common::Error::FieldClash(field));
6785 }
6786 }
6787
6788 let mut params = Params::with_capacity(6 + self._additional_params.len());
6789 params.push("name", self._name);
6790 if let Some(value) = self._update_mask.as_ref() {
6791 params.push("updateMask", value.to_string());
6792 }
6793 if let Some(value) = self._request_id.as_ref() {
6794 params.push("requestId", value);
6795 }
6796
6797 params.extend(self._additional_params.iter());
6798
6799 params.push("alt", "json");
6800 let mut url = self.hub._base_url.clone() + "v1/{+name}";
6801 if self._scopes.is_empty() {
6802 self._scopes
6803 .insert(Scope::CloudPlatform.as_ref().to_string());
6804 }
6805
6806 #[allow(clippy::single_element_loop)]
6807 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6808 url = params.uri_replacement(url, param_name, find_this, true);
6809 }
6810 {
6811 let to_remove = ["name"];
6812 params.remove_params(&to_remove);
6813 }
6814
6815 let url = params.parse_with_url(&url);
6816
6817 let mut json_mime_type = mime::APPLICATION_JSON;
6818 let mut request_value_reader = {
6819 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6820 common::remove_json_null_values(&mut value);
6821 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6822 serde_json::to_writer(&mut dst, &value).unwrap();
6823 dst
6824 };
6825 let request_size = request_value_reader
6826 .seek(std::io::SeekFrom::End(0))
6827 .unwrap();
6828 request_value_reader
6829 .seek(std::io::SeekFrom::Start(0))
6830 .unwrap();
6831
6832 loop {
6833 let token = match self
6834 .hub
6835 .auth
6836 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6837 .await
6838 {
6839 Ok(token) => token,
6840 Err(e) => match dlg.token(e) {
6841 Ok(token) => token,
6842 Err(e) => {
6843 dlg.finished(false);
6844 return Err(common::Error::MissingToken(e));
6845 }
6846 },
6847 };
6848 request_value_reader
6849 .seek(std::io::SeekFrom::Start(0))
6850 .unwrap();
6851 let mut req_result = {
6852 let client = &self.hub.client;
6853 dlg.pre_request();
6854 let mut req_builder = hyper::Request::builder()
6855 .method(hyper::Method::PATCH)
6856 .uri(url.as_str())
6857 .header(USER_AGENT, self.hub._user_agent.clone());
6858
6859 if let Some(token) = token.as_ref() {
6860 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6861 }
6862
6863 let request = req_builder
6864 .header(CONTENT_TYPE, json_mime_type.to_string())
6865 .header(CONTENT_LENGTH, request_size as u64)
6866 .body(common::to_body(
6867 request_value_reader.get_ref().clone().into(),
6868 ));
6869
6870 client.request(request.unwrap()).await
6871 };
6872
6873 match req_result {
6874 Err(err) => {
6875 if let common::Retry::After(d) = dlg.http_error(&err) {
6876 sleep(d).await;
6877 continue;
6878 }
6879 dlg.finished(false);
6880 return Err(common::Error::HttpError(err));
6881 }
6882 Ok(res) => {
6883 let (mut parts, body) = res.into_parts();
6884 let mut body = common::Body::new(body);
6885 if !parts.status.is_success() {
6886 let bytes = common::to_bytes(body).await.unwrap_or_default();
6887 let error = serde_json::from_str(&common::to_string(&bytes));
6888 let response = common::to_response(parts, bytes.into());
6889
6890 if let common::Retry::After(d) =
6891 dlg.http_failure(&response, error.as_ref().ok())
6892 {
6893 sleep(d).await;
6894 continue;
6895 }
6896
6897 dlg.finished(false);
6898
6899 return Err(match error {
6900 Ok(value) => common::Error::BadRequest(value),
6901 _ => common::Error::Failure(response),
6902 });
6903 }
6904 let response = {
6905 let bytes = common::to_bytes(body).await.unwrap_or_default();
6906 let encoded = common::to_string(&bytes);
6907 match serde_json::from_str(&encoded) {
6908 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6909 Err(error) => {
6910 dlg.response_json_decode_error(&encoded, &error);
6911 return Err(common::Error::JsonDecodeError(
6912 encoded.to_string(),
6913 error,
6914 ));
6915 }
6916 }
6917 };
6918
6919 dlg.finished(true);
6920 return Ok(response);
6921 }
6922 }
6923 }
6924 }
6925
6926 ///
6927 /// Sets the *request* property to the given value.
6928 ///
6929 /// Even though the property as already been set when instantiating this call,
6930 /// we provide this method for API completeness.
6931 pub fn request(mut self, new_value: Group) -> ProjectLocationGroupPatchCall<'a, C> {
6932 self._request = new_value;
6933 self
6934 }
6935 /// Output only. The Group name.
6936 ///
6937 /// Sets the *name* path property to the given value.
6938 ///
6939 /// Even though the property as already been set when instantiating this call,
6940 /// we provide this method for API completeness.
6941 pub fn name(mut self, new_value: &str) -> ProjectLocationGroupPatchCall<'a, C> {
6942 self._name = new_value.to_string();
6943 self
6944 }
6945 /// 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.
6946 ///
6947 /// Sets the *update mask* query property to the given value.
6948 pub fn update_mask(
6949 mut self,
6950 new_value: common::FieldMask,
6951 ) -> ProjectLocationGroupPatchCall<'a, C> {
6952 self._update_mask = Some(new_value);
6953 self
6954 }
6955 /// 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).
6956 ///
6957 /// Sets the *request id* query property to the given value.
6958 pub fn request_id(mut self, new_value: &str) -> ProjectLocationGroupPatchCall<'a, C> {
6959 self._request_id = Some(new_value.to_string());
6960 self
6961 }
6962 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6963 /// while executing the actual API request.
6964 ///
6965 /// ````text
6966 /// It should be used to handle progress information, and to implement a certain level of resilience.
6967 /// ````
6968 ///
6969 /// Sets the *delegate* property to the given value.
6970 pub fn delegate(
6971 mut self,
6972 new_value: &'a mut dyn common::Delegate,
6973 ) -> ProjectLocationGroupPatchCall<'a, C> {
6974 self._delegate = Some(new_value);
6975 self
6976 }
6977
6978 /// Set any additional parameter of the query string used in the request.
6979 /// It should be used to set parameters which are not yet available through their own
6980 /// setters.
6981 ///
6982 /// Please note that this method must not be used to set any of the known parameters
6983 /// which have their own setter method. If done anyway, the request will fail.
6984 ///
6985 /// # Additional Parameters
6986 ///
6987 /// * *$.xgafv* (query-string) - V1 error format.
6988 /// * *access_token* (query-string) - OAuth access token.
6989 /// * *alt* (query-string) - Data format for response.
6990 /// * *callback* (query-string) - JSONP
6991 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6992 /// * *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.
6993 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6994 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6995 /// * *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.
6996 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6997 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6998 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGroupPatchCall<'a, C>
6999 where
7000 T: AsRef<str>,
7001 {
7002 self._additional_params
7003 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7004 self
7005 }
7006
7007 /// Identifies the authorization scope for the method you are building.
7008 ///
7009 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7010 /// [`Scope::CloudPlatform`].
7011 ///
7012 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7013 /// tokens for more than one scope.
7014 ///
7015 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7016 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7017 /// sufficient, a read-write scope will do as well.
7018 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGroupPatchCall<'a, C>
7019 where
7020 St: AsRef<str>,
7021 {
7022 self._scopes.insert(String::from(scope.as_ref()));
7023 self
7024 }
7025 /// Identifies the authorization scope(s) for the method you are building.
7026 ///
7027 /// See [`Self::add_scope()`] for details.
7028 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGroupPatchCall<'a, C>
7029 where
7030 I: IntoIterator<Item = St>,
7031 St: AsRef<str>,
7032 {
7033 self._scopes
7034 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7035 self
7036 }
7037
7038 /// Removes all scopes, and no default scope will be used either.
7039 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7040 /// for details).
7041 pub fn clear_scopes(mut self) -> ProjectLocationGroupPatchCall<'a, C> {
7042 self._scopes.clear();
7043 self
7044 }
7045}
7046
7047/// Removes a MigratingVm from a Group.
7048///
7049/// A builder for the *locations.groups.removeGroupMigration* method supported by a *project* resource.
7050/// It is not used directly, but through a [`ProjectMethods`] instance.
7051///
7052/// # Example
7053///
7054/// Instantiate a resource method builder
7055///
7056/// ```test_harness,no_run
7057/// # extern crate hyper;
7058/// # extern crate hyper_rustls;
7059/// # extern crate google_vmmigration1 as vmmigration1;
7060/// use vmmigration1::api::RemoveGroupMigrationRequest;
7061/// # async fn dox() {
7062/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7063///
7064/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7065/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7066/// # .with_native_roots()
7067/// # .unwrap()
7068/// # .https_only()
7069/// # .enable_http2()
7070/// # .build();
7071///
7072/// # let executor = hyper_util::rt::TokioExecutor::new();
7073/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7074/// # secret,
7075/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7076/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7077/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7078/// # ),
7079/// # ).build().await.unwrap();
7080///
7081/// # let client = hyper_util::client::legacy::Client::builder(
7082/// # hyper_util::rt::TokioExecutor::new()
7083/// # )
7084/// # .build(
7085/// # hyper_rustls::HttpsConnectorBuilder::new()
7086/// # .with_native_roots()
7087/// # .unwrap()
7088/// # .https_or_http()
7089/// # .enable_http2()
7090/// # .build()
7091/// # );
7092/// # let mut hub = VMMigrationService::new(client, auth);
7093/// // As the method needs a request, you would usually fill it with the desired information
7094/// // into the respective structure. Some of the parts shown here might not be applicable !
7095/// // Values shown here are possibly random and not representative !
7096/// let mut req = RemoveGroupMigrationRequest::default();
7097///
7098/// // You can configure optional parameters by calling the respective setters at will, and
7099/// // execute the final call using `doit()`.
7100/// // Values shown here are possibly random and not representative !
7101/// let result = hub.projects().locations_groups_remove_group_migration(req, "group")
7102/// .doit().await;
7103/// # }
7104/// ```
7105pub struct ProjectLocationGroupRemoveGroupMigrationCall<'a, C>
7106where
7107 C: 'a,
7108{
7109 hub: &'a VMMigrationService<C>,
7110 _request: RemoveGroupMigrationRequest,
7111 _group: String,
7112 _delegate: Option<&'a mut dyn common::Delegate>,
7113 _additional_params: HashMap<String, String>,
7114 _scopes: BTreeSet<String>,
7115}
7116
7117impl<'a, C> common::CallBuilder for ProjectLocationGroupRemoveGroupMigrationCall<'a, C> {}
7118
7119impl<'a, C> ProjectLocationGroupRemoveGroupMigrationCall<'a, C>
7120where
7121 C: common::Connector,
7122{
7123 /// Perform the operation you have build so far.
7124 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7125 use std::borrow::Cow;
7126 use std::io::{Read, Seek};
7127
7128 use common::{url::Params, ToParts};
7129 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7130
7131 let mut dd = common::DefaultDelegate;
7132 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7133 dlg.begin(common::MethodInfo {
7134 id: "vmmigration.projects.locations.groups.removeGroupMigration",
7135 http_method: hyper::Method::POST,
7136 });
7137
7138 for &field in ["alt", "group"].iter() {
7139 if self._additional_params.contains_key(field) {
7140 dlg.finished(false);
7141 return Err(common::Error::FieldClash(field));
7142 }
7143 }
7144
7145 let mut params = Params::with_capacity(4 + self._additional_params.len());
7146 params.push("group", self._group);
7147
7148 params.extend(self._additional_params.iter());
7149
7150 params.push("alt", "json");
7151 let mut url = self.hub._base_url.clone() + "v1/{+group}:removeGroupMigration";
7152 if self._scopes.is_empty() {
7153 self._scopes
7154 .insert(Scope::CloudPlatform.as_ref().to_string());
7155 }
7156
7157 #[allow(clippy::single_element_loop)]
7158 for &(find_this, param_name) in [("{+group}", "group")].iter() {
7159 url = params.uri_replacement(url, param_name, find_this, true);
7160 }
7161 {
7162 let to_remove = ["group"];
7163 params.remove_params(&to_remove);
7164 }
7165
7166 let url = params.parse_with_url(&url);
7167
7168 let mut json_mime_type = mime::APPLICATION_JSON;
7169 let mut request_value_reader = {
7170 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7171 common::remove_json_null_values(&mut value);
7172 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7173 serde_json::to_writer(&mut dst, &value).unwrap();
7174 dst
7175 };
7176 let request_size = request_value_reader
7177 .seek(std::io::SeekFrom::End(0))
7178 .unwrap();
7179 request_value_reader
7180 .seek(std::io::SeekFrom::Start(0))
7181 .unwrap();
7182
7183 loop {
7184 let token = match self
7185 .hub
7186 .auth
7187 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7188 .await
7189 {
7190 Ok(token) => token,
7191 Err(e) => match dlg.token(e) {
7192 Ok(token) => token,
7193 Err(e) => {
7194 dlg.finished(false);
7195 return Err(common::Error::MissingToken(e));
7196 }
7197 },
7198 };
7199 request_value_reader
7200 .seek(std::io::SeekFrom::Start(0))
7201 .unwrap();
7202 let mut req_result = {
7203 let client = &self.hub.client;
7204 dlg.pre_request();
7205 let mut req_builder = hyper::Request::builder()
7206 .method(hyper::Method::POST)
7207 .uri(url.as_str())
7208 .header(USER_AGENT, self.hub._user_agent.clone());
7209
7210 if let Some(token) = token.as_ref() {
7211 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7212 }
7213
7214 let request = req_builder
7215 .header(CONTENT_TYPE, json_mime_type.to_string())
7216 .header(CONTENT_LENGTH, request_size as u64)
7217 .body(common::to_body(
7218 request_value_reader.get_ref().clone().into(),
7219 ));
7220
7221 client.request(request.unwrap()).await
7222 };
7223
7224 match req_result {
7225 Err(err) => {
7226 if let common::Retry::After(d) = dlg.http_error(&err) {
7227 sleep(d).await;
7228 continue;
7229 }
7230 dlg.finished(false);
7231 return Err(common::Error::HttpError(err));
7232 }
7233 Ok(res) => {
7234 let (mut parts, body) = res.into_parts();
7235 let mut body = common::Body::new(body);
7236 if !parts.status.is_success() {
7237 let bytes = common::to_bytes(body).await.unwrap_or_default();
7238 let error = serde_json::from_str(&common::to_string(&bytes));
7239 let response = common::to_response(parts, bytes.into());
7240
7241 if let common::Retry::After(d) =
7242 dlg.http_failure(&response, error.as_ref().ok())
7243 {
7244 sleep(d).await;
7245 continue;
7246 }
7247
7248 dlg.finished(false);
7249
7250 return Err(match error {
7251 Ok(value) => common::Error::BadRequest(value),
7252 _ => common::Error::Failure(response),
7253 });
7254 }
7255 let response = {
7256 let bytes = common::to_bytes(body).await.unwrap_or_default();
7257 let encoded = common::to_string(&bytes);
7258 match serde_json::from_str(&encoded) {
7259 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7260 Err(error) => {
7261 dlg.response_json_decode_error(&encoded, &error);
7262 return Err(common::Error::JsonDecodeError(
7263 encoded.to_string(),
7264 error,
7265 ));
7266 }
7267 }
7268 };
7269
7270 dlg.finished(true);
7271 return Ok(response);
7272 }
7273 }
7274 }
7275 }
7276
7277 ///
7278 /// Sets the *request* property to the given value.
7279 ///
7280 /// Even though the property as already been set when instantiating this call,
7281 /// we provide this method for API completeness.
7282 pub fn request(
7283 mut self,
7284 new_value: RemoveGroupMigrationRequest,
7285 ) -> ProjectLocationGroupRemoveGroupMigrationCall<'a, C> {
7286 self._request = new_value;
7287 self
7288 }
7289 /// Required. The name of the Group.
7290 ///
7291 /// Sets the *group* path property to the given value.
7292 ///
7293 /// Even though the property as already been set when instantiating this call,
7294 /// we provide this method for API completeness.
7295 pub fn group(mut self, new_value: &str) -> ProjectLocationGroupRemoveGroupMigrationCall<'a, C> {
7296 self._group = new_value.to_string();
7297 self
7298 }
7299 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7300 /// while executing the actual API request.
7301 ///
7302 /// ````text
7303 /// It should be used to handle progress information, and to implement a certain level of resilience.
7304 /// ````
7305 ///
7306 /// Sets the *delegate* property to the given value.
7307 pub fn delegate(
7308 mut self,
7309 new_value: &'a mut dyn common::Delegate,
7310 ) -> ProjectLocationGroupRemoveGroupMigrationCall<'a, C> {
7311 self._delegate = Some(new_value);
7312 self
7313 }
7314
7315 /// Set any additional parameter of the query string used in the request.
7316 /// It should be used to set parameters which are not yet available through their own
7317 /// setters.
7318 ///
7319 /// Please note that this method must not be used to set any of the known parameters
7320 /// which have their own setter method. If done anyway, the request will fail.
7321 ///
7322 /// # Additional Parameters
7323 ///
7324 /// * *$.xgafv* (query-string) - V1 error format.
7325 /// * *access_token* (query-string) - OAuth access token.
7326 /// * *alt* (query-string) - Data format for response.
7327 /// * *callback* (query-string) - JSONP
7328 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7329 /// * *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.
7330 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7331 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7332 /// * *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.
7333 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7334 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7335 pub fn param<T>(
7336 mut self,
7337 name: T,
7338 value: T,
7339 ) -> ProjectLocationGroupRemoveGroupMigrationCall<'a, C>
7340 where
7341 T: AsRef<str>,
7342 {
7343 self._additional_params
7344 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7345 self
7346 }
7347
7348 /// Identifies the authorization scope for the method you are building.
7349 ///
7350 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7351 /// [`Scope::CloudPlatform`].
7352 ///
7353 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7354 /// tokens for more than one scope.
7355 ///
7356 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7357 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7358 /// sufficient, a read-write scope will do as well.
7359 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGroupRemoveGroupMigrationCall<'a, C>
7360 where
7361 St: AsRef<str>,
7362 {
7363 self._scopes.insert(String::from(scope.as_ref()));
7364 self
7365 }
7366 /// Identifies the authorization scope(s) for the method you are building.
7367 ///
7368 /// See [`Self::add_scope()`] for details.
7369 pub fn add_scopes<I, St>(
7370 mut self,
7371 scopes: I,
7372 ) -> ProjectLocationGroupRemoveGroupMigrationCall<'a, C>
7373 where
7374 I: IntoIterator<Item = St>,
7375 St: AsRef<str>,
7376 {
7377 self._scopes
7378 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7379 self
7380 }
7381
7382 /// Removes all scopes, and no default scope will be used either.
7383 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7384 /// for details).
7385 pub fn clear_scopes(mut self) -> ProjectLocationGroupRemoveGroupMigrationCall<'a, C> {
7386 self._scopes.clear();
7387 self
7388 }
7389}
7390
7391/// Initiates the cancellation of a running ImageImportJob.
7392///
7393/// A builder for the *locations.imageImports.imageImportJobs.cancel* method supported by a *project* resource.
7394/// It is not used directly, but through a [`ProjectMethods`] instance.
7395///
7396/// # Example
7397///
7398/// Instantiate a resource method builder
7399///
7400/// ```test_harness,no_run
7401/// # extern crate hyper;
7402/// # extern crate hyper_rustls;
7403/// # extern crate google_vmmigration1 as vmmigration1;
7404/// use vmmigration1::api::CancelImageImportJobRequest;
7405/// # async fn dox() {
7406/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7407///
7408/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7409/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7410/// # .with_native_roots()
7411/// # .unwrap()
7412/// # .https_only()
7413/// # .enable_http2()
7414/// # .build();
7415///
7416/// # let executor = hyper_util::rt::TokioExecutor::new();
7417/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7418/// # secret,
7419/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7420/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7421/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7422/// # ),
7423/// # ).build().await.unwrap();
7424///
7425/// # let client = hyper_util::client::legacy::Client::builder(
7426/// # hyper_util::rt::TokioExecutor::new()
7427/// # )
7428/// # .build(
7429/// # hyper_rustls::HttpsConnectorBuilder::new()
7430/// # .with_native_roots()
7431/// # .unwrap()
7432/// # .https_or_http()
7433/// # .enable_http2()
7434/// # .build()
7435/// # );
7436/// # let mut hub = VMMigrationService::new(client, auth);
7437/// // As the method needs a request, you would usually fill it with the desired information
7438/// // into the respective structure. Some of the parts shown here might not be applicable !
7439/// // Values shown here are possibly random and not representative !
7440/// let mut req = CancelImageImportJobRequest::default();
7441///
7442/// // You can configure optional parameters by calling the respective setters at will, and
7443/// // execute the final call using `doit()`.
7444/// // Values shown here are possibly random and not representative !
7445/// let result = hub.projects().locations_image_imports_image_import_jobs_cancel(req, "name")
7446/// .doit().await;
7447/// # }
7448/// ```
7449pub struct ProjectLocationImageImportImageImportJobCancelCall<'a, C>
7450where
7451 C: 'a,
7452{
7453 hub: &'a VMMigrationService<C>,
7454 _request: CancelImageImportJobRequest,
7455 _name: String,
7456 _delegate: Option<&'a mut dyn common::Delegate>,
7457 _additional_params: HashMap<String, String>,
7458 _scopes: BTreeSet<String>,
7459}
7460
7461impl<'a, C> common::CallBuilder for ProjectLocationImageImportImageImportJobCancelCall<'a, C> {}
7462
7463impl<'a, C> ProjectLocationImageImportImageImportJobCancelCall<'a, C>
7464where
7465 C: common::Connector,
7466{
7467 /// Perform the operation you have build so far.
7468 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7469 use std::borrow::Cow;
7470 use std::io::{Read, Seek};
7471
7472 use common::{url::Params, ToParts};
7473 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7474
7475 let mut dd = common::DefaultDelegate;
7476 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7477 dlg.begin(common::MethodInfo {
7478 id: "vmmigration.projects.locations.imageImports.imageImportJobs.cancel",
7479 http_method: hyper::Method::POST,
7480 });
7481
7482 for &field in ["alt", "name"].iter() {
7483 if self._additional_params.contains_key(field) {
7484 dlg.finished(false);
7485 return Err(common::Error::FieldClash(field));
7486 }
7487 }
7488
7489 let mut params = Params::with_capacity(4 + self._additional_params.len());
7490 params.push("name", self._name);
7491
7492 params.extend(self._additional_params.iter());
7493
7494 params.push("alt", "json");
7495 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
7496 if self._scopes.is_empty() {
7497 self._scopes
7498 .insert(Scope::CloudPlatform.as_ref().to_string());
7499 }
7500
7501 #[allow(clippy::single_element_loop)]
7502 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7503 url = params.uri_replacement(url, param_name, find_this, true);
7504 }
7505 {
7506 let to_remove = ["name"];
7507 params.remove_params(&to_remove);
7508 }
7509
7510 let url = params.parse_with_url(&url);
7511
7512 let mut json_mime_type = mime::APPLICATION_JSON;
7513 let mut request_value_reader = {
7514 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7515 common::remove_json_null_values(&mut value);
7516 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7517 serde_json::to_writer(&mut dst, &value).unwrap();
7518 dst
7519 };
7520 let request_size = request_value_reader
7521 .seek(std::io::SeekFrom::End(0))
7522 .unwrap();
7523 request_value_reader
7524 .seek(std::io::SeekFrom::Start(0))
7525 .unwrap();
7526
7527 loop {
7528 let token = match self
7529 .hub
7530 .auth
7531 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7532 .await
7533 {
7534 Ok(token) => token,
7535 Err(e) => match dlg.token(e) {
7536 Ok(token) => token,
7537 Err(e) => {
7538 dlg.finished(false);
7539 return Err(common::Error::MissingToken(e));
7540 }
7541 },
7542 };
7543 request_value_reader
7544 .seek(std::io::SeekFrom::Start(0))
7545 .unwrap();
7546 let mut req_result = {
7547 let client = &self.hub.client;
7548 dlg.pre_request();
7549 let mut req_builder = hyper::Request::builder()
7550 .method(hyper::Method::POST)
7551 .uri(url.as_str())
7552 .header(USER_AGENT, self.hub._user_agent.clone());
7553
7554 if let Some(token) = token.as_ref() {
7555 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7556 }
7557
7558 let request = req_builder
7559 .header(CONTENT_TYPE, json_mime_type.to_string())
7560 .header(CONTENT_LENGTH, request_size as u64)
7561 .body(common::to_body(
7562 request_value_reader.get_ref().clone().into(),
7563 ));
7564
7565 client.request(request.unwrap()).await
7566 };
7567
7568 match req_result {
7569 Err(err) => {
7570 if let common::Retry::After(d) = dlg.http_error(&err) {
7571 sleep(d).await;
7572 continue;
7573 }
7574 dlg.finished(false);
7575 return Err(common::Error::HttpError(err));
7576 }
7577 Ok(res) => {
7578 let (mut parts, body) = res.into_parts();
7579 let mut body = common::Body::new(body);
7580 if !parts.status.is_success() {
7581 let bytes = common::to_bytes(body).await.unwrap_or_default();
7582 let error = serde_json::from_str(&common::to_string(&bytes));
7583 let response = common::to_response(parts, bytes.into());
7584
7585 if let common::Retry::After(d) =
7586 dlg.http_failure(&response, error.as_ref().ok())
7587 {
7588 sleep(d).await;
7589 continue;
7590 }
7591
7592 dlg.finished(false);
7593
7594 return Err(match error {
7595 Ok(value) => common::Error::BadRequest(value),
7596 _ => common::Error::Failure(response),
7597 });
7598 }
7599 let response = {
7600 let bytes = common::to_bytes(body).await.unwrap_or_default();
7601 let encoded = common::to_string(&bytes);
7602 match serde_json::from_str(&encoded) {
7603 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7604 Err(error) => {
7605 dlg.response_json_decode_error(&encoded, &error);
7606 return Err(common::Error::JsonDecodeError(
7607 encoded.to_string(),
7608 error,
7609 ));
7610 }
7611 }
7612 };
7613
7614 dlg.finished(true);
7615 return Ok(response);
7616 }
7617 }
7618 }
7619 }
7620
7621 ///
7622 /// Sets the *request* property to the given value.
7623 ///
7624 /// Even though the property as already been set when instantiating this call,
7625 /// we provide this method for API completeness.
7626 pub fn request(
7627 mut self,
7628 new_value: CancelImageImportJobRequest,
7629 ) -> ProjectLocationImageImportImageImportJobCancelCall<'a, C> {
7630 self._request = new_value;
7631 self
7632 }
7633 /// Required. The image import job id.
7634 ///
7635 /// Sets the *name* path property to the given value.
7636 ///
7637 /// Even though the property as already been set when instantiating this call,
7638 /// we provide this method for API completeness.
7639 pub fn name(
7640 mut self,
7641 new_value: &str,
7642 ) -> ProjectLocationImageImportImageImportJobCancelCall<'a, C> {
7643 self._name = new_value.to_string();
7644 self
7645 }
7646 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7647 /// while executing the actual API request.
7648 ///
7649 /// ````text
7650 /// It should be used to handle progress information, and to implement a certain level of resilience.
7651 /// ````
7652 ///
7653 /// Sets the *delegate* property to the given value.
7654 pub fn delegate(
7655 mut self,
7656 new_value: &'a mut dyn common::Delegate,
7657 ) -> ProjectLocationImageImportImageImportJobCancelCall<'a, C> {
7658 self._delegate = Some(new_value);
7659 self
7660 }
7661
7662 /// Set any additional parameter of the query string used in the request.
7663 /// It should be used to set parameters which are not yet available through their own
7664 /// setters.
7665 ///
7666 /// Please note that this method must not be used to set any of the known parameters
7667 /// which have their own setter method. If done anyway, the request will fail.
7668 ///
7669 /// # Additional Parameters
7670 ///
7671 /// * *$.xgafv* (query-string) - V1 error format.
7672 /// * *access_token* (query-string) - OAuth access token.
7673 /// * *alt* (query-string) - Data format for response.
7674 /// * *callback* (query-string) - JSONP
7675 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7676 /// * *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.
7677 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7678 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7679 /// * *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.
7680 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7681 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7682 pub fn param<T>(
7683 mut self,
7684 name: T,
7685 value: T,
7686 ) -> ProjectLocationImageImportImageImportJobCancelCall<'a, C>
7687 where
7688 T: AsRef<str>,
7689 {
7690 self._additional_params
7691 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7692 self
7693 }
7694
7695 /// Identifies the authorization scope for the method you are building.
7696 ///
7697 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7698 /// [`Scope::CloudPlatform`].
7699 ///
7700 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7701 /// tokens for more than one scope.
7702 ///
7703 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7704 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7705 /// sufficient, a read-write scope will do as well.
7706 pub fn add_scope<St>(
7707 mut self,
7708 scope: St,
7709 ) -> ProjectLocationImageImportImageImportJobCancelCall<'a, C>
7710 where
7711 St: AsRef<str>,
7712 {
7713 self._scopes.insert(String::from(scope.as_ref()));
7714 self
7715 }
7716 /// Identifies the authorization scope(s) for the method you are building.
7717 ///
7718 /// See [`Self::add_scope()`] for details.
7719 pub fn add_scopes<I, St>(
7720 mut self,
7721 scopes: I,
7722 ) -> ProjectLocationImageImportImageImportJobCancelCall<'a, C>
7723 where
7724 I: IntoIterator<Item = St>,
7725 St: AsRef<str>,
7726 {
7727 self._scopes
7728 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7729 self
7730 }
7731
7732 /// Removes all scopes, and no default scope will be used either.
7733 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7734 /// for details).
7735 pub fn clear_scopes(mut self) -> ProjectLocationImageImportImageImportJobCancelCall<'a, C> {
7736 self._scopes.clear();
7737 self
7738 }
7739}
7740
7741/// Gets details of a single ImageImportJob.
7742///
7743/// A builder for the *locations.imageImports.imageImportJobs.get* method supported by a *project* resource.
7744/// It is not used directly, but through a [`ProjectMethods`] instance.
7745///
7746/// # Example
7747///
7748/// Instantiate a resource method builder
7749///
7750/// ```test_harness,no_run
7751/// # extern crate hyper;
7752/// # extern crate hyper_rustls;
7753/// # extern crate google_vmmigration1 as vmmigration1;
7754/// # async fn dox() {
7755/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7756///
7757/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7758/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7759/// # .with_native_roots()
7760/// # .unwrap()
7761/// # .https_only()
7762/// # .enable_http2()
7763/// # .build();
7764///
7765/// # let executor = hyper_util::rt::TokioExecutor::new();
7766/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7767/// # secret,
7768/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7769/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7770/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7771/// # ),
7772/// # ).build().await.unwrap();
7773///
7774/// # let client = hyper_util::client::legacy::Client::builder(
7775/// # hyper_util::rt::TokioExecutor::new()
7776/// # )
7777/// # .build(
7778/// # hyper_rustls::HttpsConnectorBuilder::new()
7779/// # .with_native_roots()
7780/// # .unwrap()
7781/// # .https_or_http()
7782/// # .enable_http2()
7783/// # .build()
7784/// # );
7785/// # let mut hub = VMMigrationService::new(client, auth);
7786/// // You can configure optional parameters by calling the respective setters at will, and
7787/// // execute the final call using `doit()`.
7788/// // Values shown here are possibly random and not representative !
7789/// let result = hub.projects().locations_image_imports_image_import_jobs_get("name")
7790/// .doit().await;
7791/// # }
7792/// ```
7793pub struct ProjectLocationImageImportImageImportJobGetCall<'a, C>
7794where
7795 C: 'a,
7796{
7797 hub: &'a VMMigrationService<C>,
7798 _name: String,
7799 _delegate: Option<&'a mut dyn common::Delegate>,
7800 _additional_params: HashMap<String, String>,
7801 _scopes: BTreeSet<String>,
7802}
7803
7804impl<'a, C> common::CallBuilder for ProjectLocationImageImportImageImportJobGetCall<'a, C> {}
7805
7806impl<'a, C> ProjectLocationImageImportImageImportJobGetCall<'a, C>
7807where
7808 C: common::Connector,
7809{
7810 /// Perform the operation you have build so far.
7811 pub async fn doit(mut self) -> common::Result<(common::Response, ImageImportJob)> {
7812 use std::borrow::Cow;
7813 use std::io::{Read, Seek};
7814
7815 use common::{url::Params, ToParts};
7816 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7817
7818 let mut dd = common::DefaultDelegate;
7819 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7820 dlg.begin(common::MethodInfo {
7821 id: "vmmigration.projects.locations.imageImports.imageImportJobs.get",
7822 http_method: hyper::Method::GET,
7823 });
7824
7825 for &field in ["alt", "name"].iter() {
7826 if self._additional_params.contains_key(field) {
7827 dlg.finished(false);
7828 return Err(common::Error::FieldClash(field));
7829 }
7830 }
7831
7832 let mut params = Params::with_capacity(3 + self._additional_params.len());
7833 params.push("name", self._name);
7834
7835 params.extend(self._additional_params.iter());
7836
7837 params.push("alt", "json");
7838 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7839 if self._scopes.is_empty() {
7840 self._scopes
7841 .insert(Scope::CloudPlatform.as_ref().to_string());
7842 }
7843
7844 #[allow(clippy::single_element_loop)]
7845 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7846 url = params.uri_replacement(url, param_name, find_this, true);
7847 }
7848 {
7849 let to_remove = ["name"];
7850 params.remove_params(&to_remove);
7851 }
7852
7853 let url = params.parse_with_url(&url);
7854
7855 loop {
7856 let token = match self
7857 .hub
7858 .auth
7859 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7860 .await
7861 {
7862 Ok(token) => token,
7863 Err(e) => match dlg.token(e) {
7864 Ok(token) => token,
7865 Err(e) => {
7866 dlg.finished(false);
7867 return Err(common::Error::MissingToken(e));
7868 }
7869 },
7870 };
7871 let mut req_result = {
7872 let client = &self.hub.client;
7873 dlg.pre_request();
7874 let mut req_builder = hyper::Request::builder()
7875 .method(hyper::Method::GET)
7876 .uri(url.as_str())
7877 .header(USER_AGENT, self.hub._user_agent.clone());
7878
7879 if let Some(token) = token.as_ref() {
7880 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7881 }
7882
7883 let request = req_builder
7884 .header(CONTENT_LENGTH, 0_u64)
7885 .body(common::to_body::<String>(None));
7886
7887 client.request(request.unwrap()).await
7888 };
7889
7890 match req_result {
7891 Err(err) => {
7892 if let common::Retry::After(d) = dlg.http_error(&err) {
7893 sleep(d).await;
7894 continue;
7895 }
7896 dlg.finished(false);
7897 return Err(common::Error::HttpError(err));
7898 }
7899 Ok(res) => {
7900 let (mut parts, body) = res.into_parts();
7901 let mut body = common::Body::new(body);
7902 if !parts.status.is_success() {
7903 let bytes = common::to_bytes(body).await.unwrap_or_default();
7904 let error = serde_json::from_str(&common::to_string(&bytes));
7905 let response = common::to_response(parts, bytes.into());
7906
7907 if let common::Retry::After(d) =
7908 dlg.http_failure(&response, error.as_ref().ok())
7909 {
7910 sleep(d).await;
7911 continue;
7912 }
7913
7914 dlg.finished(false);
7915
7916 return Err(match error {
7917 Ok(value) => common::Error::BadRequest(value),
7918 _ => common::Error::Failure(response),
7919 });
7920 }
7921 let response = {
7922 let bytes = common::to_bytes(body).await.unwrap_or_default();
7923 let encoded = common::to_string(&bytes);
7924 match serde_json::from_str(&encoded) {
7925 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7926 Err(error) => {
7927 dlg.response_json_decode_error(&encoded, &error);
7928 return Err(common::Error::JsonDecodeError(
7929 encoded.to_string(),
7930 error,
7931 ));
7932 }
7933 }
7934 };
7935
7936 dlg.finished(true);
7937 return Ok(response);
7938 }
7939 }
7940 }
7941 }
7942
7943 /// Required. The ImageImportJob name.
7944 ///
7945 /// Sets the *name* path property to the given value.
7946 ///
7947 /// Even though the property as already been set when instantiating this call,
7948 /// we provide this method for API completeness.
7949 pub fn name(
7950 mut self,
7951 new_value: &str,
7952 ) -> ProjectLocationImageImportImageImportJobGetCall<'a, C> {
7953 self._name = new_value.to_string();
7954 self
7955 }
7956 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7957 /// while executing the actual API request.
7958 ///
7959 /// ````text
7960 /// It should be used to handle progress information, and to implement a certain level of resilience.
7961 /// ````
7962 ///
7963 /// Sets the *delegate* property to the given value.
7964 pub fn delegate(
7965 mut self,
7966 new_value: &'a mut dyn common::Delegate,
7967 ) -> ProjectLocationImageImportImageImportJobGetCall<'a, C> {
7968 self._delegate = Some(new_value);
7969 self
7970 }
7971
7972 /// Set any additional parameter of the query string used in the request.
7973 /// It should be used to set parameters which are not yet available through their own
7974 /// setters.
7975 ///
7976 /// Please note that this method must not be used to set any of the known parameters
7977 /// which have their own setter method. If done anyway, the request will fail.
7978 ///
7979 /// # Additional Parameters
7980 ///
7981 /// * *$.xgafv* (query-string) - V1 error format.
7982 /// * *access_token* (query-string) - OAuth access token.
7983 /// * *alt* (query-string) - Data format for response.
7984 /// * *callback* (query-string) - JSONP
7985 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7986 /// * *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.
7987 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7988 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7989 /// * *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.
7990 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7991 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7992 pub fn param<T>(
7993 mut self,
7994 name: T,
7995 value: T,
7996 ) -> ProjectLocationImageImportImageImportJobGetCall<'a, C>
7997 where
7998 T: AsRef<str>,
7999 {
8000 self._additional_params
8001 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8002 self
8003 }
8004
8005 /// Identifies the authorization scope for the method you are building.
8006 ///
8007 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8008 /// [`Scope::CloudPlatform`].
8009 ///
8010 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8011 /// tokens for more than one scope.
8012 ///
8013 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8014 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8015 /// sufficient, a read-write scope will do as well.
8016 pub fn add_scope<St>(
8017 mut self,
8018 scope: St,
8019 ) -> ProjectLocationImageImportImageImportJobGetCall<'a, C>
8020 where
8021 St: AsRef<str>,
8022 {
8023 self._scopes.insert(String::from(scope.as_ref()));
8024 self
8025 }
8026 /// Identifies the authorization scope(s) for the method you are building.
8027 ///
8028 /// See [`Self::add_scope()`] for details.
8029 pub fn add_scopes<I, St>(
8030 mut self,
8031 scopes: I,
8032 ) -> ProjectLocationImageImportImageImportJobGetCall<'a, C>
8033 where
8034 I: IntoIterator<Item = St>,
8035 St: AsRef<str>,
8036 {
8037 self._scopes
8038 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8039 self
8040 }
8041
8042 /// Removes all scopes, and no default scope will be used either.
8043 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8044 /// for details).
8045 pub fn clear_scopes(mut self) -> ProjectLocationImageImportImageImportJobGetCall<'a, C> {
8046 self._scopes.clear();
8047 self
8048 }
8049}
8050
8051/// Lists ImageImportJobs in a given project.
8052///
8053/// A builder for the *locations.imageImports.imageImportJobs.list* method supported by a *project* resource.
8054/// It is not used directly, but through a [`ProjectMethods`] instance.
8055///
8056/// # Example
8057///
8058/// Instantiate a resource method builder
8059///
8060/// ```test_harness,no_run
8061/// # extern crate hyper;
8062/// # extern crate hyper_rustls;
8063/// # extern crate google_vmmigration1 as vmmigration1;
8064/// # async fn dox() {
8065/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8066///
8067/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8068/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8069/// # .with_native_roots()
8070/// # .unwrap()
8071/// # .https_only()
8072/// # .enable_http2()
8073/// # .build();
8074///
8075/// # let executor = hyper_util::rt::TokioExecutor::new();
8076/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8077/// # secret,
8078/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8079/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8080/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8081/// # ),
8082/// # ).build().await.unwrap();
8083///
8084/// # let client = hyper_util::client::legacy::Client::builder(
8085/// # hyper_util::rt::TokioExecutor::new()
8086/// # )
8087/// # .build(
8088/// # hyper_rustls::HttpsConnectorBuilder::new()
8089/// # .with_native_roots()
8090/// # .unwrap()
8091/// # .https_or_http()
8092/// # .enable_http2()
8093/// # .build()
8094/// # );
8095/// # let mut hub = VMMigrationService::new(client, auth);
8096/// // You can configure optional parameters by calling the respective setters at will, and
8097/// // execute the final call using `doit()`.
8098/// // Values shown here are possibly random and not representative !
8099/// let result = hub.projects().locations_image_imports_image_import_jobs_list("parent")
8100/// .page_token("rebum.")
8101/// .page_size(-57)
8102/// .order_by("ipsum")
8103/// .filter("ipsum")
8104/// .doit().await;
8105/// # }
8106/// ```
8107pub struct ProjectLocationImageImportImageImportJobListCall<'a, C>
8108where
8109 C: 'a,
8110{
8111 hub: &'a VMMigrationService<C>,
8112 _parent: String,
8113 _page_token: Option<String>,
8114 _page_size: Option<i32>,
8115 _order_by: Option<String>,
8116 _filter: Option<String>,
8117 _delegate: Option<&'a mut dyn common::Delegate>,
8118 _additional_params: HashMap<String, String>,
8119 _scopes: BTreeSet<String>,
8120}
8121
8122impl<'a, C> common::CallBuilder for ProjectLocationImageImportImageImportJobListCall<'a, C> {}
8123
8124impl<'a, C> ProjectLocationImageImportImageImportJobListCall<'a, C>
8125where
8126 C: common::Connector,
8127{
8128 /// Perform the operation you have build so far.
8129 pub async fn doit(mut self) -> common::Result<(common::Response, ListImageImportJobsResponse)> {
8130 use std::borrow::Cow;
8131 use std::io::{Read, Seek};
8132
8133 use common::{url::Params, ToParts};
8134 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8135
8136 let mut dd = common::DefaultDelegate;
8137 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8138 dlg.begin(common::MethodInfo {
8139 id: "vmmigration.projects.locations.imageImports.imageImportJobs.list",
8140 http_method: hyper::Method::GET,
8141 });
8142
8143 for &field in [
8144 "alt",
8145 "parent",
8146 "pageToken",
8147 "pageSize",
8148 "orderBy",
8149 "filter",
8150 ]
8151 .iter()
8152 {
8153 if self._additional_params.contains_key(field) {
8154 dlg.finished(false);
8155 return Err(common::Error::FieldClash(field));
8156 }
8157 }
8158
8159 let mut params = Params::with_capacity(7 + self._additional_params.len());
8160 params.push("parent", self._parent);
8161 if let Some(value) = self._page_token.as_ref() {
8162 params.push("pageToken", value);
8163 }
8164 if let Some(value) = self._page_size.as_ref() {
8165 params.push("pageSize", value.to_string());
8166 }
8167 if let Some(value) = self._order_by.as_ref() {
8168 params.push("orderBy", value);
8169 }
8170 if let Some(value) = self._filter.as_ref() {
8171 params.push("filter", value);
8172 }
8173
8174 params.extend(self._additional_params.iter());
8175
8176 params.push("alt", "json");
8177 let mut url = self.hub._base_url.clone() + "v1/{+parent}/imageImportJobs";
8178 if self._scopes.is_empty() {
8179 self._scopes
8180 .insert(Scope::CloudPlatform.as_ref().to_string());
8181 }
8182
8183 #[allow(clippy::single_element_loop)]
8184 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8185 url = params.uri_replacement(url, param_name, find_this, true);
8186 }
8187 {
8188 let to_remove = ["parent"];
8189 params.remove_params(&to_remove);
8190 }
8191
8192 let url = params.parse_with_url(&url);
8193
8194 loop {
8195 let token = match self
8196 .hub
8197 .auth
8198 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8199 .await
8200 {
8201 Ok(token) => token,
8202 Err(e) => match dlg.token(e) {
8203 Ok(token) => token,
8204 Err(e) => {
8205 dlg.finished(false);
8206 return Err(common::Error::MissingToken(e));
8207 }
8208 },
8209 };
8210 let mut req_result = {
8211 let client = &self.hub.client;
8212 dlg.pre_request();
8213 let mut req_builder = hyper::Request::builder()
8214 .method(hyper::Method::GET)
8215 .uri(url.as_str())
8216 .header(USER_AGENT, self.hub._user_agent.clone());
8217
8218 if let Some(token) = token.as_ref() {
8219 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8220 }
8221
8222 let request = req_builder
8223 .header(CONTENT_LENGTH, 0_u64)
8224 .body(common::to_body::<String>(None));
8225
8226 client.request(request.unwrap()).await
8227 };
8228
8229 match req_result {
8230 Err(err) => {
8231 if let common::Retry::After(d) = dlg.http_error(&err) {
8232 sleep(d).await;
8233 continue;
8234 }
8235 dlg.finished(false);
8236 return Err(common::Error::HttpError(err));
8237 }
8238 Ok(res) => {
8239 let (mut parts, body) = res.into_parts();
8240 let mut body = common::Body::new(body);
8241 if !parts.status.is_success() {
8242 let bytes = common::to_bytes(body).await.unwrap_or_default();
8243 let error = serde_json::from_str(&common::to_string(&bytes));
8244 let response = common::to_response(parts, bytes.into());
8245
8246 if let common::Retry::After(d) =
8247 dlg.http_failure(&response, error.as_ref().ok())
8248 {
8249 sleep(d).await;
8250 continue;
8251 }
8252
8253 dlg.finished(false);
8254
8255 return Err(match error {
8256 Ok(value) => common::Error::BadRequest(value),
8257 _ => common::Error::Failure(response),
8258 });
8259 }
8260 let response = {
8261 let bytes = common::to_bytes(body).await.unwrap_or_default();
8262 let encoded = common::to_string(&bytes);
8263 match serde_json::from_str(&encoded) {
8264 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8265 Err(error) => {
8266 dlg.response_json_decode_error(&encoded, &error);
8267 return Err(common::Error::JsonDecodeError(
8268 encoded.to_string(),
8269 error,
8270 ));
8271 }
8272 }
8273 };
8274
8275 dlg.finished(true);
8276 return Ok(response);
8277 }
8278 }
8279 }
8280 }
8281
8282 /// Required. The parent, which owns this collection of targets.
8283 ///
8284 /// Sets the *parent* path property to the given value.
8285 ///
8286 /// Even though the property as already been set when instantiating this call,
8287 /// we provide this method for API completeness.
8288 pub fn parent(
8289 mut self,
8290 new_value: &str,
8291 ) -> ProjectLocationImageImportImageImportJobListCall<'a, C> {
8292 self._parent = new_value.to_string();
8293 self
8294 }
8295 /// 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.
8296 ///
8297 /// Sets the *page token* query property to the given value.
8298 pub fn page_token(
8299 mut self,
8300 new_value: &str,
8301 ) -> ProjectLocationImageImportImageImportJobListCall<'a, C> {
8302 self._page_token = Some(new_value.to_string());
8303 self
8304 }
8305 /// 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.
8306 ///
8307 /// Sets the *page size* query property to the given value.
8308 pub fn page_size(
8309 mut self,
8310 new_value: i32,
8311 ) -> ProjectLocationImageImportImageImportJobListCall<'a, C> {
8312 self._page_size = Some(new_value);
8313 self
8314 }
8315 /// Optional. The order by fields for the result (according to AIP-132). Currently ordering is only possible by "name" field.
8316 ///
8317 /// Sets the *order by* query property to the given value.
8318 pub fn order_by(
8319 mut self,
8320 new_value: &str,
8321 ) -> ProjectLocationImageImportImageImportJobListCall<'a, C> {
8322 self._order_by = Some(new_value.to_string());
8323 self
8324 }
8325 /// Optional. The filter request (according to AIP-160).
8326 ///
8327 /// Sets the *filter* query property to the given value.
8328 pub fn filter(
8329 mut self,
8330 new_value: &str,
8331 ) -> ProjectLocationImageImportImageImportJobListCall<'a, C> {
8332 self._filter = Some(new_value.to_string());
8333 self
8334 }
8335 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8336 /// while executing the actual API request.
8337 ///
8338 /// ````text
8339 /// It should be used to handle progress information, and to implement a certain level of resilience.
8340 /// ````
8341 ///
8342 /// Sets the *delegate* property to the given value.
8343 pub fn delegate(
8344 mut self,
8345 new_value: &'a mut dyn common::Delegate,
8346 ) -> ProjectLocationImageImportImageImportJobListCall<'a, C> {
8347 self._delegate = Some(new_value);
8348 self
8349 }
8350
8351 /// Set any additional parameter of the query string used in the request.
8352 /// It should be used to set parameters which are not yet available through their own
8353 /// setters.
8354 ///
8355 /// Please note that this method must not be used to set any of the known parameters
8356 /// which have their own setter method. If done anyway, the request will fail.
8357 ///
8358 /// # Additional Parameters
8359 ///
8360 /// * *$.xgafv* (query-string) - V1 error format.
8361 /// * *access_token* (query-string) - OAuth access token.
8362 /// * *alt* (query-string) - Data format for response.
8363 /// * *callback* (query-string) - JSONP
8364 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8365 /// * *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.
8366 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8367 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8368 /// * *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.
8369 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8370 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8371 pub fn param<T>(
8372 mut self,
8373 name: T,
8374 value: T,
8375 ) -> ProjectLocationImageImportImageImportJobListCall<'a, C>
8376 where
8377 T: AsRef<str>,
8378 {
8379 self._additional_params
8380 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8381 self
8382 }
8383
8384 /// Identifies the authorization scope for the method you are building.
8385 ///
8386 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8387 /// [`Scope::CloudPlatform`].
8388 ///
8389 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8390 /// tokens for more than one scope.
8391 ///
8392 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8393 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8394 /// sufficient, a read-write scope will do as well.
8395 pub fn add_scope<St>(
8396 mut self,
8397 scope: St,
8398 ) -> ProjectLocationImageImportImageImportJobListCall<'a, C>
8399 where
8400 St: AsRef<str>,
8401 {
8402 self._scopes.insert(String::from(scope.as_ref()));
8403 self
8404 }
8405 /// Identifies the authorization scope(s) for the method you are building.
8406 ///
8407 /// See [`Self::add_scope()`] for details.
8408 pub fn add_scopes<I, St>(
8409 mut self,
8410 scopes: I,
8411 ) -> ProjectLocationImageImportImageImportJobListCall<'a, C>
8412 where
8413 I: IntoIterator<Item = St>,
8414 St: AsRef<str>,
8415 {
8416 self._scopes
8417 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8418 self
8419 }
8420
8421 /// Removes all scopes, and no default scope will be used either.
8422 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8423 /// for details).
8424 pub fn clear_scopes(mut self) -> ProjectLocationImageImportImageImportJobListCall<'a, C> {
8425 self._scopes.clear();
8426 self
8427 }
8428}
8429
8430/// Creates a new ImageImport in a given project.
8431///
8432/// A builder for the *locations.imageImports.create* method supported by a *project* resource.
8433/// It is not used directly, but through a [`ProjectMethods`] instance.
8434///
8435/// # Example
8436///
8437/// Instantiate a resource method builder
8438///
8439/// ```test_harness,no_run
8440/// # extern crate hyper;
8441/// # extern crate hyper_rustls;
8442/// # extern crate google_vmmigration1 as vmmigration1;
8443/// use vmmigration1::api::ImageImport;
8444/// # async fn dox() {
8445/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8446///
8447/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8448/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8449/// # .with_native_roots()
8450/// # .unwrap()
8451/// # .https_only()
8452/// # .enable_http2()
8453/// # .build();
8454///
8455/// # let executor = hyper_util::rt::TokioExecutor::new();
8456/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8457/// # secret,
8458/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8459/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8460/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8461/// # ),
8462/// # ).build().await.unwrap();
8463///
8464/// # let client = hyper_util::client::legacy::Client::builder(
8465/// # hyper_util::rt::TokioExecutor::new()
8466/// # )
8467/// # .build(
8468/// # hyper_rustls::HttpsConnectorBuilder::new()
8469/// # .with_native_roots()
8470/// # .unwrap()
8471/// # .https_or_http()
8472/// # .enable_http2()
8473/// # .build()
8474/// # );
8475/// # let mut hub = VMMigrationService::new(client, auth);
8476/// // As the method needs a request, you would usually fill it with the desired information
8477/// // into the respective structure. Some of the parts shown here might not be applicable !
8478/// // Values shown here are possibly random and not representative !
8479/// let mut req = ImageImport::default();
8480///
8481/// // You can configure optional parameters by calling the respective setters at will, and
8482/// // execute the final call using `doit()`.
8483/// // Values shown here are possibly random and not representative !
8484/// let result = hub.projects().locations_image_imports_create(req, "parent")
8485/// .request_id("gubergren")
8486/// .image_import_id("ea")
8487/// .doit().await;
8488/// # }
8489/// ```
8490pub struct ProjectLocationImageImportCreateCall<'a, C>
8491where
8492 C: 'a,
8493{
8494 hub: &'a VMMigrationService<C>,
8495 _request: ImageImport,
8496 _parent: String,
8497 _request_id: Option<String>,
8498 _image_import_id: Option<String>,
8499 _delegate: Option<&'a mut dyn common::Delegate>,
8500 _additional_params: HashMap<String, String>,
8501 _scopes: BTreeSet<String>,
8502}
8503
8504impl<'a, C> common::CallBuilder for ProjectLocationImageImportCreateCall<'a, C> {}
8505
8506impl<'a, C> ProjectLocationImageImportCreateCall<'a, C>
8507where
8508 C: common::Connector,
8509{
8510 /// Perform the operation you have build so far.
8511 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8512 use std::borrow::Cow;
8513 use std::io::{Read, Seek};
8514
8515 use common::{url::Params, ToParts};
8516 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8517
8518 let mut dd = common::DefaultDelegate;
8519 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8520 dlg.begin(common::MethodInfo {
8521 id: "vmmigration.projects.locations.imageImports.create",
8522 http_method: hyper::Method::POST,
8523 });
8524
8525 for &field in ["alt", "parent", "requestId", "imageImportId"].iter() {
8526 if self._additional_params.contains_key(field) {
8527 dlg.finished(false);
8528 return Err(common::Error::FieldClash(field));
8529 }
8530 }
8531
8532 let mut params = Params::with_capacity(6 + self._additional_params.len());
8533 params.push("parent", self._parent);
8534 if let Some(value) = self._request_id.as_ref() {
8535 params.push("requestId", value);
8536 }
8537 if let Some(value) = self._image_import_id.as_ref() {
8538 params.push("imageImportId", value);
8539 }
8540
8541 params.extend(self._additional_params.iter());
8542
8543 params.push("alt", "json");
8544 let mut url = self.hub._base_url.clone() + "v1/{+parent}/imageImports";
8545 if self._scopes.is_empty() {
8546 self._scopes
8547 .insert(Scope::CloudPlatform.as_ref().to_string());
8548 }
8549
8550 #[allow(clippy::single_element_loop)]
8551 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8552 url = params.uri_replacement(url, param_name, find_this, true);
8553 }
8554 {
8555 let to_remove = ["parent"];
8556 params.remove_params(&to_remove);
8557 }
8558
8559 let url = params.parse_with_url(&url);
8560
8561 let mut json_mime_type = mime::APPLICATION_JSON;
8562 let mut request_value_reader = {
8563 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8564 common::remove_json_null_values(&mut value);
8565 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8566 serde_json::to_writer(&mut dst, &value).unwrap();
8567 dst
8568 };
8569 let request_size = request_value_reader
8570 .seek(std::io::SeekFrom::End(0))
8571 .unwrap();
8572 request_value_reader
8573 .seek(std::io::SeekFrom::Start(0))
8574 .unwrap();
8575
8576 loop {
8577 let token = match self
8578 .hub
8579 .auth
8580 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8581 .await
8582 {
8583 Ok(token) => token,
8584 Err(e) => match dlg.token(e) {
8585 Ok(token) => token,
8586 Err(e) => {
8587 dlg.finished(false);
8588 return Err(common::Error::MissingToken(e));
8589 }
8590 },
8591 };
8592 request_value_reader
8593 .seek(std::io::SeekFrom::Start(0))
8594 .unwrap();
8595 let mut req_result = {
8596 let client = &self.hub.client;
8597 dlg.pre_request();
8598 let mut req_builder = hyper::Request::builder()
8599 .method(hyper::Method::POST)
8600 .uri(url.as_str())
8601 .header(USER_AGENT, self.hub._user_agent.clone());
8602
8603 if let Some(token) = token.as_ref() {
8604 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8605 }
8606
8607 let request = req_builder
8608 .header(CONTENT_TYPE, json_mime_type.to_string())
8609 .header(CONTENT_LENGTH, request_size as u64)
8610 .body(common::to_body(
8611 request_value_reader.get_ref().clone().into(),
8612 ));
8613
8614 client.request(request.unwrap()).await
8615 };
8616
8617 match req_result {
8618 Err(err) => {
8619 if let common::Retry::After(d) = dlg.http_error(&err) {
8620 sleep(d).await;
8621 continue;
8622 }
8623 dlg.finished(false);
8624 return Err(common::Error::HttpError(err));
8625 }
8626 Ok(res) => {
8627 let (mut parts, body) = res.into_parts();
8628 let mut body = common::Body::new(body);
8629 if !parts.status.is_success() {
8630 let bytes = common::to_bytes(body).await.unwrap_or_default();
8631 let error = serde_json::from_str(&common::to_string(&bytes));
8632 let response = common::to_response(parts, bytes.into());
8633
8634 if let common::Retry::After(d) =
8635 dlg.http_failure(&response, error.as_ref().ok())
8636 {
8637 sleep(d).await;
8638 continue;
8639 }
8640
8641 dlg.finished(false);
8642
8643 return Err(match error {
8644 Ok(value) => common::Error::BadRequest(value),
8645 _ => common::Error::Failure(response),
8646 });
8647 }
8648 let response = {
8649 let bytes = common::to_bytes(body).await.unwrap_or_default();
8650 let encoded = common::to_string(&bytes);
8651 match serde_json::from_str(&encoded) {
8652 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8653 Err(error) => {
8654 dlg.response_json_decode_error(&encoded, &error);
8655 return Err(common::Error::JsonDecodeError(
8656 encoded.to_string(),
8657 error,
8658 ));
8659 }
8660 }
8661 };
8662
8663 dlg.finished(true);
8664 return Ok(response);
8665 }
8666 }
8667 }
8668 }
8669
8670 ///
8671 /// Sets the *request* property to the given value.
8672 ///
8673 /// Even though the property as already been set when instantiating this call,
8674 /// we provide this method for API completeness.
8675 pub fn request(
8676 mut self,
8677 new_value: ImageImport,
8678 ) -> ProjectLocationImageImportCreateCall<'a, C> {
8679 self._request = new_value;
8680 self
8681 }
8682 /// Required. The ImageImport's parent.
8683 ///
8684 /// Sets the *parent* path property to the given value.
8685 ///
8686 /// Even though the property as already been set when instantiating this call,
8687 /// we provide this method for API completeness.
8688 pub fn parent(mut self, new_value: &str) -> ProjectLocationImageImportCreateCall<'a, C> {
8689 self._parent = new_value.to_string();
8690 self
8691 }
8692 /// 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).
8693 ///
8694 /// Sets the *request id* query property to the given value.
8695 pub fn request_id(mut self, new_value: &str) -> ProjectLocationImageImportCreateCall<'a, C> {
8696 self._request_id = Some(new_value.to_string());
8697 self
8698 }
8699 /// 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.
8700 ///
8701 /// Sets the *image import id* query property to the given value.
8702 pub fn image_import_id(
8703 mut self,
8704 new_value: &str,
8705 ) -> ProjectLocationImageImportCreateCall<'a, C> {
8706 self._image_import_id = Some(new_value.to_string());
8707 self
8708 }
8709 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8710 /// while executing the actual API request.
8711 ///
8712 /// ````text
8713 /// It should be used to handle progress information, and to implement a certain level of resilience.
8714 /// ````
8715 ///
8716 /// Sets the *delegate* property to the given value.
8717 pub fn delegate(
8718 mut self,
8719 new_value: &'a mut dyn common::Delegate,
8720 ) -> ProjectLocationImageImportCreateCall<'a, C> {
8721 self._delegate = Some(new_value);
8722 self
8723 }
8724
8725 /// Set any additional parameter of the query string used in the request.
8726 /// It should be used to set parameters which are not yet available through their own
8727 /// setters.
8728 ///
8729 /// Please note that this method must not be used to set any of the known parameters
8730 /// which have their own setter method. If done anyway, the request will fail.
8731 ///
8732 /// # Additional Parameters
8733 ///
8734 /// * *$.xgafv* (query-string) - V1 error format.
8735 /// * *access_token* (query-string) - OAuth access token.
8736 /// * *alt* (query-string) - Data format for response.
8737 /// * *callback* (query-string) - JSONP
8738 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8739 /// * *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.
8740 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8741 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8742 /// * *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.
8743 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8744 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8745 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationImageImportCreateCall<'a, C>
8746 where
8747 T: AsRef<str>,
8748 {
8749 self._additional_params
8750 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8751 self
8752 }
8753
8754 /// Identifies the authorization scope for the method you are building.
8755 ///
8756 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8757 /// [`Scope::CloudPlatform`].
8758 ///
8759 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8760 /// tokens for more than one scope.
8761 ///
8762 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8763 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8764 /// sufficient, a read-write scope will do as well.
8765 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationImageImportCreateCall<'a, C>
8766 where
8767 St: AsRef<str>,
8768 {
8769 self._scopes.insert(String::from(scope.as_ref()));
8770 self
8771 }
8772 /// Identifies the authorization scope(s) for the method you are building.
8773 ///
8774 /// See [`Self::add_scope()`] for details.
8775 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationImageImportCreateCall<'a, C>
8776 where
8777 I: IntoIterator<Item = St>,
8778 St: AsRef<str>,
8779 {
8780 self._scopes
8781 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8782 self
8783 }
8784
8785 /// Removes all scopes, and no default scope will be used either.
8786 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8787 /// for details).
8788 pub fn clear_scopes(mut self) -> ProjectLocationImageImportCreateCall<'a, C> {
8789 self._scopes.clear();
8790 self
8791 }
8792}
8793
8794/// Deletes a single ImageImport.
8795///
8796/// A builder for the *locations.imageImports.delete* method supported by a *project* resource.
8797/// It is not used directly, but through a [`ProjectMethods`] instance.
8798///
8799/// # Example
8800///
8801/// Instantiate a resource method builder
8802///
8803/// ```test_harness,no_run
8804/// # extern crate hyper;
8805/// # extern crate hyper_rustls;
8806/// # extern crate google_vmmigration1 as vmmigration1;
8807/// # async fn dox() {
8808/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8809///
8810/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8811/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8812/// # .with_native_roots()
8813/// # .unwrap()
8814/// # .https_only()
8815/// # .enable_http2()
8816/// # .build();
8817///
8818/// # let executor = hyper_util::rt::TokioExecutor::new();
8819/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8820/// # secret,
8821/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8822/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8823/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8824/// # ),
8825/// # ).build().await.unwrap();
8826///
8827/// # let client = hyper_util::client::legacy::Client::builder(
8828/// # hyper_util::rt::TokioExecutor::new()
8829/// # )
8830/// # .build(
8831/// # hyper_rustls::HttpsConnectorBuilder::new()
8832/// # .with_native_roots()
8833/// # .unwrap()
8834/// # .https_or_http()
8835/// # .enable_http2()
8836/// # .build()
8837/// # );
8838/// # let mut hub = VMMigrationService::new(client, auth);
8839/// // You can configure optional parameters by calling the respective setters at will, and
8840/// // execute the final call using `doit()`.
8841/// // Values shown here are possibly random and not representative !
8842/// let result = hub.projects().locations_image_imports_delete("name")
8843/// .request_id("Lorem")
8844/// .doit().await;
8845/// # }
8846/// ```
8847pub struct ProjectLocationImageImportDeleteCall<'a, C>
8848where
8849 C: 'a,
8850{
8851 hub: &'a VMMigrationService<C>,
8852 _name: String,
8853 _request_id: Option<String>,
8854 _delegate: Option<&'a mut dyn common::Delegate>,
8855 _additional_params: HashMap<String, String>,
8856 _scopes: BTreeSet<String>,
8857}
8858
8859impl<'a, C> common::CallBuilder for ProjectLocationImageImportDeleteCall<'a, C> {}
8860
8861impl<'a, C> ProjectLocationImageImportDeleteCall<'a, C>
8862where
8863 C: common::Connector,
8864{
8865 /// Perform the operation you have build so far.
8866 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8867 use std::borrow::Cow;
8868 use std::io::{Read, Seek};
8869
8870 use common::{url::Params, ToParts};
8871 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8872
8873 let mut dd = common::DefaultDelegate;
8874 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8875 dlg.begin(common::MethodInfo {
8876 id: "vmmigration.projects.locations.imageImports.delete",
8877 http_method: hyper::Method::DELETE,
8878 });
8879
8880 for &field in ["alt", "name", "requestId"].iter() {
8881 if self._additional_params.contains_key(field) {
8882 dlg.finished(false);
8883 return Err(common::Error::FieldClash(field));
8884 }
8885 }
8886
8887 let mut params = Params::with_capacity(4 + self._additional_params.len());
8888 params.push("name", self._name);
8889 if let Some(value) = self._request_id.as_ref() {
8890 params.push("requestId", value);
8891 }
8892
8893 params.extend(self._additional_params.iter());
8894
8895 params.push("alt", "json");
8896 let mut url = self.hub._base_url.clone() + "v1/{+name}";
8897 if self._scopes.is_empty() {
8898 self._scopes
8899 .insert(Scope::CloudPlatform.as_ref().to_string());
8900 }
8901
8902 #[allow(clippy::single_element_loop)]
8903 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8904 url = params.uri_replacement(url, param_name, find_this, true);
8905 }
8906 {
8907 let to_remove = ["name"];
8908 params.remove_params(&to_remove);
8909 }
8910
8911 let url = params.parse_with_url(&url);
8912
8913 loop {
8914 let token = match self
8915 .hub
8916 .auth
8917 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8918 .await
8919 {
8920 Ok(token) => token,
8921 Err(e) => match dlg.token(e) {
8922 Ok(token) => token,
8923 Err(e) => {
8924 dlg.finished(false);
8925 return Err(common::Error::MissingToken(e));
8926 }
8927 },
8928 };
8929 let mut req_result = {
8930 let client = &self.hub.client;
8931 dlg.pre_request();
8932 let mut req_builder = hyper::Request::builder()
8933 .method(hyper::Method::DELETE)
8934 .uri(url.as_str())
8935 .header(USER_AGENT, self.hub._user_agent.clone());
8936
8937 if let Some(token) = token.as_ref() {
8938 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8939 }
8940
8941 let request = req_builder
8942 .header(CONTENT_LENGTH, 0_u64)
8943 .body(common::to_body::<String>(None));
8944
8945 client.request(request.unwrap()).await
8946 };
8947
8948 match req_result {
8949 Err(err) => {
8950 if let common::Retry::After(d) = dlg.http_error(&err) {
8951 sleep(d).await;
8952 continue;
8953 }
8954 dlg.finished(false);
8955 return Err(common::Error::HttpError(err));
8956 }
8957 Ok(res) => {
8958 let (mut parts, body) = res.into_parts();
8959 let mut body = common::Body::new(body);
8960 if !parts.status.is_success() {
8961 let bytes = common::to_bytes(body).await.unwrap_or_default();
8962 let error = serde_json::from_str(&common::to_string(&bytes));
8963 let response = common::to_response(parts, bytes.into());
8964
8965 if let common::Retry::After(d) =
8966 dlg.http_failure(&response, error.as_ref().ok())
8967 {
8968 sleep(d).await;
8969 continue;
8970 }
8971
8972 dlg.finished(false);
8973
8974 return Err(match error {
8975 Ok(value) => common::Error::BadRequest(value),
8976 _ => common::Error::Failure(response),
8977 });
8978 }
8979 let response = {
8980 let bytes = common::to_bytes(body).await.unwrap_or_default();
8981 let encoded = common::to_string(&bytes);
8982 match serde_json::from_str(&encoded) {
8983 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8984 Err(error) => {
8985 dlg.response_json_decode_error(&encoded, &error);
8986 return Err(common::Error::JsonDecodeError(
8987 encoded.to_string(),
8988 error,
8989 ));
8990 }
8991 }
8992 };
8993
8994 dlg.finished(true);
8995 return Ok(response);
8996 }
8997 }
8998 }
8999 }
9000
9001 /// Required. The ImageImport name.
9002 ///
9003 /// Sets the *name* path property to the given value.
9004 ///
9005 /// Even though the property as already been set when instantiating this call,
9006 /// we provide this method for API completeness.
9007 pub fn name(mut self, new_value: &str) -> ProjectLocationImageImportDeleteCall<'a, C> {
9008 self._name = new_value.to_string();
9009 self
9010 }
9011 /// 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).
9012 ///
9013 /// Sets the *request id* query property to the given value.
9014 pub fn request_id(mut self, new_value: &str) -> ProjectLocationImageImportDeleteCall<'a, C> {
9015 self._request_id = Some(new_value.to_string());
9016 self
9017 }
9018 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9019 /// while executing the actual API request.
9020 ///
9021 /// ````text
9022 /// It should be used to handle progress information, and to implement a certain level of resilience.
9023 /// ````
9024 ///
9025 /// Sets the *delegate* property to the given value.
9026 pub fn delegate(
9027 mut self,
9028 new_value: &'a mut dyn common::Delegate,
9029 ) -> ProjectLocationImageImportDeleteCall<'a, C> {
9030 self._delegate = Some(new_value);
9031 self
9032 }
9033
9034 /// Set any additional parameter of the query string used in the request.
9035 /// It should be used to set parameters which are not yet available through their own
9036 /// setters.
9037 ///
9038 /// Please note that this method must not be used to set any of the known parameters
9039 /// which have their own setter method. If done anyway, the request will fail.
9040 ///
9041 /// # Additional Parameters
9042 ///
9043 /// * *$.xgafv* (query-string) - V1 error format.
9044 /// * *access_token* (query-string) - OAuth access token.
9045 /// * *alt* (query-string) - Data format for response.
9046 /// * *callback* (query-string) - JSONP
9047 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9048 /// * *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.
9049 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9050 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9051 /// * *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.
9052 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9053 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9054 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationImageImportDeleteCall<'a, C>
9055 where
9056 T: AsRef<str>,
9057 {
9058 self._additional_params
9059 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9060 self
9061 }
9062
9063 /// Identifies the authorization scope for the method you are building.
9064 ///
9065 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9066 /// [`Scope::CloudPlatform`].
9067 ///
9068 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9069 /// tokens for more than one scope.
9070 ///
9071 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9072 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9073 /// sufficient, a read-write scope will do as well.
9074 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationImageImportDeleteCall<'a, C>
9075 where
9076 St: AsRef<str>,
9077 {
9078 self._scopes.insert(String::from(scope.as_ref()));
9079 self
9080 }
9081 /// Identifies the authorization scope(s) for the method you are building.
9082 ///
9083 /// See [`Self::add_scope()`] for details.
9084 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationImageImportDeleteCall<'a, C>
9085 where
9086 I: IntoIterator<Item = St>,
9087 St: AsRef<str>,
9088 {
9089 self._scopes
9090 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9091 self
9092 }
9093
9094 /// Removes all scopes, and no default scope will be used either.
9095 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9096 /// for details).
9097 pub fn clear_scopes(mut self) -> ProjectLocationImageImportDeleteCall<'a, C> {
9098 self._scopes.clear();
9099 self
9100 }
9101}
9102
9103/// Gets details of a single ImageImport.
9104///
9105/// A builder for the *locations.imageImports.get* method supported by a *project* resource.
9106/// It is not used directly, but through a [`ProjectMethods`] instance.
9107///
9108/// # Example
9109///
9110/// Instantiate a resource method builder
9111///
9112/// ```test_harness,no_run
9113/// # extern crate hyper;
9114/// # extern crate hyper_rustls;
9115/// # extern crate google_vmmigration1 as vmmigration1;
9116/// # async fn dox() {
9117/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9118///
9119/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9120/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9121/// # .with_native_roots()
9122/// # .unwrap()
9123/// # .https_only()
9124/// # .enable_http2()
9125/// # .build();
9126///
9127/// # let executor = hyper_util::rt::TokioExecutor::new();
9128/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9129/// # secret,
9130/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9131/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9132/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9133/// # ),
9134/// # ).build().await.unwrap();
9135///
9136/// # let client = hyper_util::client::legacy::Client::builder(
9137/// # hyper_util::rt::TokioExecutor::new()
9138/// # )
9139/// # .build(
9140/// # hyper_rustls::HttpsConnectorBuilder::new()
9141/// # .with_native_roots()
9142/// # .unwrap()
9143/// # .https_or_http()
9144/// # .enable_http2()
9145/// # .build()
9146/// # );
9147/// # let mut hub = VMMigrationService::new(client, auth);
9148/// // You can configure optional parameters by calling the respective setters at will, and
9149/// // execute the final call using `doit()`.
9150/// // Values shown here are possibly random and not representative !
9151/// let result = hub.projects().locations_image_imports_get("name")
9152/// .doit().await;
9153/// # }
9154/// ```
9155pub struct ProjectLocationImageImportGetCall<'a, C>
9156where
9157 C: 'a,
9158{
9159 hub: &'a VMMigrationService<C>,
9160 _name: String,
9161 _delegate: Option<&'a mut dyn common::Delegate>,
9162 _additional_params: HashMap<String, String>,
9163 _scopes: BTreeSet<String>,
9164}
9165
9166impl<'a, C> common::CallBuilder for ProjectLocationImageImportGetCall<'a, C> {}
9167
9168impl<'a, C> ProjectLocationImageImportGetCall<'a, C>
9169where
9170 C: common::Connector,
9171{
9172 /// Perform the operation you have build so far.
9173 pub async fn doit(mut self) -> common::Result<(common::Response, ImageImport)> {
9174 use std::borrow::Cow;
9175 use std::io::{Read, Seek};
9176
9177 use common::{url::Params, ToParts};
9178 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9179
9180 let mut dd = common::DefaultDelegate;
9181 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9182 dlg.begin(common::MethodInfo {
9183 id: "vmmigration.projects.locations.imageImports.get",
9184 http_method: hyper::Method::GET,
9185 });
9186
9187 for &field in ["alt", "name"].iter() {
9188 if self._additional_params.contains_key(field) {
9189 dlg.finished(false);
9190 return Err(common::Error::FieldClash(field));
9191 }
9192 }
9193
9194 let mut params = Params::with_capacity(3 + self._additional_params.len());
9195 params.push("name", self._name);
9196
9197 params.extend(self._additional_params.iter());
9198
9199 params.push("alt", "json");
9200 let mut url = self.hub._base_url.clone() + "v1/{+name}";
9201 if self._scopes.is_empty() {
9202 self._scopes
9203 .insert(Scope::CloudPlatform.as_ref().to_string());
9204 }
9205
9206 #[allow(clippy::single_element_loop)]
9207 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9208 url = params.uri_replacement(url, param_name, find_this, true);
9209 }
9210 {
9211 let to_remove = ["name"];
9212 params.remove_params(&to_remove);
9213 }
9214
9215 let url = params.parse_with_url(&url);
9216
9217 loop {
9218 let token = match self
9219 .hub
9220 .auth
9221 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9222 .await
9223 {
9224 Ok(token) => token,
9225 Err(e) => match dlg.token(e) {
9226 Ok(token) => token,
9227 Err(e) => {
9228 dlg.finished(false);
9229 return Err(common::Error::MissingToken(e));
9230 }
9231 },
9232 };
9233 let mut req_result = {
9234 let client = &self.hub.client;
9235 dlg.pre_request();
9236 let mut req_builder = hyper::Request::builder()
9237 .method(hyper::Method::GET)
9238 .uri(url.as_str())
9239 .header(USER_AGENT, self.hub._user_agent.clone());
9240
9241 if let Some(token) = token.as_ref() {
9242 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9243 }
9244
9245 let request = req_builder
9246 .header(CONTENT_LENGTH, 0_u64)
9247 .body(common::to_body::<String>(None));
9248
9249 client.request(request.unwrap()).await
9250 };
9251
9252 match req_result {
9253 Err(err) => {
9254 if let common::Retry::After(d) = dlg.http_error(&err) {
9255 sleep(d).await;
9256 continue;
9257 }
9258 dlg.finished(false);
9259 return Err(common::Error::HttpError(err));
9260 }
9261 Ok(res) => {
9262 let (mut parts, body) = res.into_parts();
9263 let mut body = common::Body::new(body);
9264 if !parts.status.is_success() {
9265 let bytes = common::to_bytes(body).await.unwrap_or_default();
9266 let error = serde_json::from_str(&common::to_string(&bytes));
9267 let response = common::to_response(parts, bytes.into());
9268
9269 if let common::Retry::After(d) =
9270 dlg.http_failure(&response, error.as_ref().ok())
9271 {
9272 sleep(d).await;
9273 continue;
9274 }
9275
9276 dlg.finished(false);
9277
9278 return Err(match error {
9279 Ok(value) => common::Error::BadRequest(value),
9280 _ => common::Error::Failure(response),
9281 });
9282 }
9283 let response = {
9284 let bytes = common::to_bytes(body).await.unwrap_or_default();
9285 let encoded = common::to_string(&bytes);
9286 match serde_json::from_str(&encoded) {
9287 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9288 Err(error) => {
9289 dlg.response_json_decode_error(&encoded, &error);
9290 return Err(common::Error::JsonDecodeError(
9291 encoded.to_string(),
9292 error,
9293 ));
9294 }
9295 }
9296 };
9297
9298 dlg.finished(true);
9299 return Ok(response);
9300 }
9301 }
9302 }
9303 }
9304
9305 /// Required. The ImageImport name.
9306 ///
9307 /// Sets the *name* path property to the given value.
9308 ///
9309 /// Even though the property as already been set when instantiating this call,
9310 /// we provide this method for API completeness.
9311 pub fn name(mut self, new_value: &str) -> ProjectLocationImageImportGetCall<'a, C> {
9312 self._name = new_value.to_string();
9313 self
9314 }
9315 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9316 /// while executing the actual API request.
9317 ///
9318 /// ````text
9319 /// It should be used to handle progress information, and to implement a certain level of resilience.
9320 /// ````
9321 ///
9322 /// Sets the *delegate* property to the given value.
9323 pub fn delegate(
9324 mut self,
9325 new_value: &'a mut dyn common::Delegate,
9326 ) -> ProjectLocationImageImportGetCall<'a, C> {
9327 self._delegate = Some(new_value);
9328 self
9329 }
9330
9331 /// Set any additional parameter of the query string used in the request.
9332 /// It should be used to set parameters which are not yet available through their own
9333 /// setters.
9334 ///
9335 /// Please note that this method must not be used to set any of the known parameters
9336 /// which have their own setter method. If done anyway, the request will fail.
9337 ///
9338 /// # Additional Parameters
9339 ///
9340 /// * *$.xgafv* (query-string) - V1 error format.
9341 /// * *access_token* (query-string) - OAuth access token.
9342 /// * *alt* (query-string) - Data format for response.
9343 /// * *callback* (query-string) - JSONP
9344 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9345 /// * *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.
9346 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9347 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9348 /// * *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.
9349 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9350 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9351 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationImageImportGetCall<'a, C>
9352 where
9353 T: AsRef<str>,
9354 {
9355 self._additional_params
9356 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9357 self
9358 }
9359
9360 /// Identifies the authorization scope for the method you are building.
9361 ///
9362 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9363 /// [`Scope::CloudPlatform`].
9364 ///
9365 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9366 /// tokens for more than one scope.
9367 ///
9368 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9369 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9370 /// sufficient, a read-write scope will do as well.
9371 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationImageImportGetCall<'a, C>
9372 where
9373 St: AsRef<str>,
9374 {
9375 self._scopes.insert(String::from(scope.as_ref()));
9376 self
9377 }
9378 /// Identifies the authorization scope(s) for the method you are building.
9379 ///
9380 /// See [`Self::add_scope()`] for details.
9381 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationImageImportGetCall<'a, C>
9382 where
9383 I: IntoIterator<Item = St>,
9384 St: AsRef<str>,
9385 {
9386 self._scopes
9387 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9388 self
9389 }
9390
9391 /// Removes all scopes, and no default scope will be used either.
9392 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9393 /// for details).
9394 pub fn clear_scopes(mut self) -> ProjectLocationImageImportGetCall<'a, C> {
9395 self._scopes.clear();
9396 self
9397 }
9398}
9399
9400/// Lists ImageImports in a given project.
9401///
9402/// A builder for the *locations.imageImports.list* method supported by a *project* resource.
9403/// It is not used directly, but through a [`ProjectMethods`] instance.
9404///
9405/// # Example
9406///
9407/// Instantiate a resource method builder
9408///
9409/// ```test_harness,no_run
9410/// # extern crate hyper;
9411/// # extern crate hyper_rustls;
9412/// # extern crate google_vmmigration1 as vmmigration1;
9413/// # async fn dox() {
9414/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9415///
9416/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9417/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9418/// # .with_native_roots()
9419/// # .unwrap()
9420/// # .https_only()
9421/// # .enable_http2()
9422/// # .build();
9423///
9424/// # let executor = hyper_util::rt::TokioExecutor::new();
9425/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9426/// # secret,
9427/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9428/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9429/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9430/// # ),
9431/// # ).build().await.unwrap();
9432///
9433/// # let client = hyper_util::client::legacy::Client::builder(
9434/// # hyper_util::rt::TokioExecutor::new()
9435/// # )
9436/// # .build(
9437/// # hyper_rustls::HttpsConnectorBuilder::new()
9438/// # .with_native_roots()
9439/// # .unwrap()
9440/// # .https_or_http()
9441/// # .enable_http2()
9442/// # .build()
9443/// # );
9444/// # let mut hub = VMMigrationService::new(client, auth);
9445/// // You can configure optional parameters by calling the respective setters at will, and
9446/// // execute the final call using `doit()`.
9447/// // Values shown here are possibly random and not representative !
9448/// let result = hub.projects().locations_image_imports_list("parent")
9449/// .page_token("sed")
9450/// .page_size(-70)
9451/// .order_by("sed")
9452/// .filter("no")
9453/// .doit().await;
9454/// # }
9455/// ```
9456pub struct ProjectLocationImageImportListCall<'a, C>
9457where
9458 C: 'a,
9459{
9460 hub: &'a VMMigrationService<C>,
9461 _parent: String,
9462 _page_token: Option<String>,
9463 _page_size: Option<i32>,
9464 _order_by: Option<String>,
9465 _filter: Option<String>,
9466 _delegate: Option<&'a mut dyn common::Delegate>,
9467 _additional_params: HashMap<String, String>,
9468 _scopes: BTreeSet<String>,
9469}
9470
9471impl<'a, C> common::CallBuilder for ProjectLocationImageImportListCall<'a, C> {}
9472
9473impl<'a, C> ProjectLocationImageImportListCall<'a, C>
9474where
9475 C: common::Connector,
9476{
9477 /// Perform the operation you have build so far.
9478 pub async fn doit(mut self) -> common::Result<(common::Response, ListImageImportsResponse)> {
9479 use std::borrow::Cow;
9480 use std::io::{Read, Seek};
9481
9482 use common::{url::Params, ToParts};
9483 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9484
9485 let mut dd = common::DefaultDelegate;
9486 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9487 dlg.begin(common::MethodInfo {
9488 id: "vmmigration.projects.locations.imageImports.list",
9489 http_method: hyper::Method::GET,
9490 });
9491
9492 for &field in [
9493 "alt",
9494 "parent",
9495 "pageToken",
9496 "pageSize",
9497 "orderBy",
9498 "filter",
9499 ]
9500 .iter()
9501 {
9502 if self._additional_params.contains_key(field) {
9503 dlg.finished(false);
9504 return Err(common::Error::FieldClash(field));
9505 }
9506 }
9507
9508 let mut params = Params::with_capacity(7 + self._additional_params.len());
9509 params.push("parent", self._parent);
9510 if let Some(value) = self._page_token.as_ref() {
9511 params.push("pageToken", value);
9512 }
9513 if let Some(value) = self._page_size.as_ref() {
9514 params.push("pageSize", value.to_string());
9515 }
9516 if let Some(value) = self._order_by.as_ref() {
9517 params.push("orderBy", value);
9518 }
9519 if let Some(value) = self._filter.as_ref() {
9520 params.push("filter", value);
9521 }
9522
9523 params.extend(self._additional_params.iter());
9524
9525 params.push("alt", "json");
9526 let mut url = self.hub._base_url.clone() + "v1/{+parent}/imageImports";
9527 if self._scopes.is_empty() {
9528 self._scopes
9529 .insert(Scope::CloudPlatform.as_ref().to_string());
9530 }
9531
9532 #[allow(clippy::single_element_loop)]
9533 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9534 url = params.uri_replacement(url, param_name, find_this, true);
9535 }
9536 {
9537 let to_remove = ["parent"];
9538 params.remove_params(&to_remove);
9539 }
9540
9541 let url = params.parse_with_url(&url);
9542
9543 loop {
9544 let token = match self
9545 .hub
9546 .auth
9547 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9548 .await
9549 {
9550 Ok(token) => token,
9551 Err(e) => match dlg.token(e) {
9552 Ok(token) => token,
9553 Err(e) => {
9554 dlg.finished(false);
9555 return Err(common::Error::MissingToken(e));
9556 }
9557 },
9558 };
9559 let mut req_result = {
9560 let client = &self.hub.client;
9561 dlg.pre_request();
9562 let mut req_builder = hyper::Request::builder()
9563 .method(hyper::Method::GET)
9564 .uri(url.as_str())
9565 .header(USER_AGENT, self.hub._user_agent.clone());
9566
9567 if let Some(token) = token.as_ref() {
9568 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9569 }
9570
9571 let request = req_builder
9572 .header(CONTENT_LENGTH, 0_u64)
9573 .body(common::to_body::<String>(None));
9574
9575 client.request(request.unwrap()).await
9576 };
9577
9578 match req_result {
9579 Err(err) => {
9580 if let common::Retry::After(d) = dlg.http_error(&err) {
9581 sleep(d).await;
9582 continue;
9583 }
9584 dlg.finished(false);
9585 return Err(common::Error::HttpError(err));
9586 }
9587 Ok(res) => {
9588 let (mut parts, body) = res.into_parts();
9589 let mut body = common::Body::new(body);
9590 if !parts.status.is_success() {
9591 let bytes = common::to_bytes(body).await.unwrap_or_default();
9592 let error = serde_json::from_str(&common::to_string(&bytes));
9593 let response = common::to_response(parts, bytes.into());
9594
9595 if let common::Retry::After(d) =
9596 dlg.http_failure(&response, error.as_ref().ok())
9597 {
9598 sleep(d).await;
9599 continue;
9600 }
9601
9602 dlg.finished(false);
9603
9604 return Err(match error {
9605 Ok(value) => common::Error::BadRequest(value),
9606 _ => common::Error::Failure(response),
9607 });
9608 }
9609 let response = {
9610 let bytes = common::to_bytes(body).await.unwrap_or_default();
9611 let encoded = common::to_string(&bytes);
9612 match serde_json::from_str(&encoded) {
9613 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9614 Err(error) => {
9615 dlg.response_json_decode_error(&encoded, &error);
9616 return Err(common::Error::JsonDecodeError(
9617 encoded.to_string(),
9618 error,
9619 ));
9620 }
9621 }
9622 };
9623
9624 dlg.finished(true);
9625 return Ok(response);
9626 }
9627 }
9628 }
9629 }
9630
9631 /// Required. The parent, which owns this collection of targets.
9632 ///
9633 /// Sets the *parent* path property to the given value.
9634 ///
9635 /// Even though the property as already been set when instantiating this call,
9636 /// we provide this method for API completeness.
9637 pub fn parent(mut self, new_value: &str) -> ProjectLocationImageImportListCall<'a, C> {
9638 self._parent = new_value.to_string();
9639 self
9640 }
9641 /// 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.
9642 ///
9643 /// Sets the *page token* query property to the given value.
9644 pub fn page_token(mut self, new_value: &str) -> ProjectLocationImageImportListCall<'a, C> {
9645 self._page_token = Some(new_value.to_string());
9646 self
9647 }
9648 /// 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.
9649 ///
9650 /// Sets the *page size* query property to the given value.
9651 pub fn page_size(mut self, new_value: i32) -> ProjectLocationImageImportListCall<'a, C> {
9652 self._page_size = Some(new_value);
9653 self
9654 }
9655 /// Optional. The order by fields for the result (according to AIP-132). Currently ordering is only possible by "name" field.
9656 ///
9657 /// Sets the *order by* query property to the given value.
9658 pub fn order_by(mut self, new_value: &str) -> ProjectLocationImageImportListCall<'a, C> {
9659 self._order_by = Some(new_value.to_string());
9660 self
9661 }
9662 /// Optional. The filter request (according to AIP-160).
9663 ///
9664 /// Sets the *filter* query property to the given value.
9665 pub fn filter(mut self, new_value: &str) -> ProjectLocationImageImportListCall<'a, C> {
9666 self._filter = Some(new_value.to_string());
9667 self
9668 }
9669 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9670 /// while executing the actual API request.
9671 ///
9672 /// ````text
9673 /// It should be used to handle progress information, and to implement a certain level of resilience.
9674 /// ````
9675 ///
9676 /// Sets the *delegate* property to the given value.
9677 pub fn delegate(
9678 mut self,
9679 new_value: &'a mut dyn common::Delegate,
9680 ) -> ProjectLocationImageImportListCall<'a, C> {
9681 self._delegate = Some(new_value);
9682 self
9683 }
9684
9685 /// Set any additional parameter of the query string used in the request.
9686 /// It should be used to set parameters which are not yet available through their own
9687 /// setters.
9688 ///
9689 /// Please note that this method must not be used to set any of the known parameters
9690 /// which have their own setter method. If done anyway, the request will fail.
9691 ///
9692 /// # Additional Parameters
9693 ///
9694 /// * *$.xgafv* (query-string) - V1 error format.
9695 /// * *access_token* (query-string) - OAuth access token.
9696 /// * *alt* (query-string) - Data format for response.
9697 /// * *callback* (query-string) - JSONP
9698 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9699 /// * *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.
9700 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9701 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9702 /// * *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.
9703 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9704 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9705 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationImageImportListCall<'a, C>
9706 where
9707 T: AsRef<str>,
9708 {
9709 self._additional_params
9710 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9711 self
9712 }
9713
9714 /// Identifies the authorization scope for the method you are building.
9715 ///
9716 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9717 /// [`Scope::CloudPlatform`].
9718 ///
9719 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9720 /// tokens for more than one scope.
9721 ///
9722 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9723 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9724 /// sufficient, a read-write scope will do as well.
9725 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationImageImportListCall<'a, C>
9726 where
9727 St: AsRef<str>,
9728 {
9729 self._scopes.insert(String::from(scope.as_ref()));
9730 self
9731 }
9732 /// Identifies the authorization scope(s) for the method you are building.
9733 ///
9734 /// See [`Self::add_scope()`] for details.
9735 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationImageImportListCall<'a, C>
9736 where
9737 I: IntoIterator<Item = St>,
9738 St: AsRef<str>,
9739 {
9740 self._scopes
9741 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9742 self
9743 }
9744
9745 /// Removes all scopes, and no default scope will be used either.
9746 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9747 /// for details).
9748 pub fn clear_scopes(mut self) -> ProjectLocationImageImportListCall<'a, C> {
9749 self._scopes.clear();
9750 self
9751 }
9752}
9753
9754/// 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`.
9755///
9756/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
9757/// It is not used directly, but through a [`ProjectMethods`] instance.
9758///
9759/// # Example
9760///
9761/// Instantiate a resource method builder
9762///
9763/// ```test_harness,no_run
9764/// # extern crate hyper;
9765/// # extern crate hyper_rustls;
9766/// # extern crate google_vmmigration1 as vmmigration1;
9767/// use vmmigration1::api::CancelOperationRequest;
9768/// # async fn dox() {
9769/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9770///
9771/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9772/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9773/// # .with_native_roots()
9774/// # .unwrap()
9775/// # .https_only()
9776/// # .enable_http2()
9777/// # .build();
9778///
9779/// # let executor = hyper_util::rt::TokioExecutor::new();
9780/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9781/// # secret,
9782/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9783/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9784/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9785/// # ),
9786/// # ).build().await.unwrap();
9787///
9788/// # let client = hyper_util::client::legacy::Client::builder(
9789/// # hyper_util::rt::TokioExecutor::new()
9790/// # )
9791/// # .build(
9792/// # hyper_rustls::HttpsConnectorBuilder::new()
9793/// # .with_native_roots()
9794/// # .unwrap()
9795/// # .https_or_http()
9796/// # .enable_http2()
9797/// # .build()
9798/// # );
9799/// # let mut hub = VMMigrationService::new(client, auth);
9800/// // As the method needs a request, you would usually fill it with the desired information
9801/// // into the respective structure. Some of the parts shown here might not be applicable !
9802/// // Values shown here are possibly random and not representative !
9803/// let mut req = CancelOperationRequest::default();
9804///
9805/// // You can configure optional parameters by calling the respective setters at will, and
9806/// // execute the final call using `doit()`.
9807/// // Values shown here are possibly random and not representative !
9808/// let result = hub.projects().locations_operations_cancel(req, "name")
9809/// .doit().await;
9810/// # }
9811/// ```
9812pub struct ProjectLocationOperationCancelCall<'a, C>
9813where
9814 C: 'a,
9815{
9816 hub: &'a VMMigrationService<C>,
9817 _request: CancelOperationRequest,
9818 _name: String,
9819 _delegate: Option<&'a mut dyn common::Delegate>,
9820 _additional_params: HashMap<String, String>,
9821 _scopes: BTreeSet<String>,
9822}
9823
9824impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
9825
9826impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
9827where
9828 C: common::Connector,
9829{
9830 /// Perform the operation you have build so far.
9831 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
9832 use std::borrow::Cow;
9833 use std::io::{Read, Seek};
9834
9835 use common::{url::Params, ToParts};
9836 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9837
9838 let mut dd = common::DefaultDelegate;
9839 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9840 dlg.begin(common::MethodInfo {
9841 id: "vmmigration.projects.locations.operations.cancel",
9842 http_method: hyper::Method::POST,
9843 });
9844
9845 for &field in ["alt", "name"].iter() {
9846 if self._additional_params.contains_key(field) {
9847 dlg.finished(false);
9848 return Err(common::Error::FieldClash(field));
9849 }
9850 }
9851
9852 let mut params = Params::with_capacity(4 + self._additional_params.len());
9853 params.push("name", self._name);
9854
9855 params.extend(self._additional_params.iter());
9856
9857 params.push("alt", "json");
9858 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
9859 if self._scopes.is_empty() {
9860 self._scopes
9861 .insert(Scope::CloudPlatform.as_ref().to_string());
9862 }
9863
9864 #[allow(clippy::single_element_loop)]
9865 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9866 url = params.uri_replacement(url, param_name, find_this, true);
9867 }
9868 {
9869 let to_remove = ["name"];
9870 params.remove_params(&to_remove);
9871 }
9872
9873 let url = params.parse_with_url(&url);
9874
9875 let mut json_mime_type = mime::APPLICATION_JSON;
9876 let mut request_value_reader = {
9877 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9878 common::remove_json_null_values(&mut value);
9879 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9880 serde_json::to_writer(&mut dst, &value).unwrap();
9881 dst
9882 };
9883 let request_size = request_value_reader
9884 .seek(std::io::SeekFrom::End(0))
9885 .unwrap();
9886 request_value_reader
9887 .seek(std::io::SeekFrom::Start(0))
9888 .unwrap();
9889
9890 loop {
9891 let token = match self
9892 .hub
9893 .auth
9894 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9895 .await
9896 {
9897 Ok(token) => token,
9898 Err(e) => match dlg.token(e) {
9899 Ok(token) => token,
9900 Err(e) => {
9901 dlg.finished(false);
9902 return Err(common::Error::MissingToken(e));
9903 }
9904 },
9905 };
9906 request_value_reader
9907 .seek(std::io::SeekFrom::Start(0))
9908 .unwrap();
9909 let mut req_result = {
9910 let client = &self.hub.client;
9911 dlg.pre_request();
9912 let mut req_builder = hyper::Request::builder()
9913 .method(hyper::Method::POST)
9914 .uri(url.as_str())
9915 .header(USER_AGENT, self.hub._user_agent.clone());
9916
9917 if let Some(token) = token.as_ref() {
9918 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9919 }
9920
9921 let request = req_builder
9922 .header(CONTENT_TYPE, json_mime_type.to_string())
9923 .header(CONTENT_LENGTH, request_size as u64)
9924 .body(common::to_body(
9925 request_value_reader.get_ref().clone().into(),
9926 ));
9927
9928 client.request(request.unwrap()).await
9929 };
9930
9931 match req_result {
9932 Err(err) => {
9933 if let common::Retry::After(d) = dlg.http_error(&err) {
9934 sleep(d).await;
9935 continue;
9936 }
9937 dlg.finished(false);
9938 return Err(common::Error::HttpError(err));
9939 }
9940 Ok(res) => {
9941 let (mut parts, body) = res.into_parts();
9942 let mut body = common::Body::new(body);
9943 if !parts.status.is_success() {
9944 let bytes = common::to_bytes(body).await.unwrap_or_default();
9945 let error = serde_json::from_str(&common::to_string(&bytes));
9946 let response = common::to_response(parts, bytes.into());
9947
9948 if let common::Retry::After(d) =
9949 dlg.http_failure(&response, error.as_ref().ok())
9950 {
9951 sleep(d).await;
9952 continue;
9953 }
9954
9955 dlg.finished(false);
9956
9957 return Err(match error {
9958 Ok(value) => common::Error::BadRequest(value),
9959 _ => common::Error::Failure(response),
9960 });
9961 }
9962 let response = {
9963 let bytes = common::to_bytes(body).await.unwrap_or_default();
9964 let encoded = common::to_string(&bytes);
9965 match serde_json::from_str(&encoded) {
9966 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9967 Err(error) => {
9968 dlg.response_json_decode_error(&encoded, &error);
9969 return Err(common::Error::JsonDecodeError(
9970 encoded.to_string(),
9971 error,
9972 ));
9973 }
9974 }
9975 };
9976
9977 dlg.finished(true);
9978 return Ok(response);
9979 }
9980 }
9981 }
9982 }
9983
9984 ///
9985 /// Sets the *request* property to the given value.
9986 ///
9987 /// Even though the property as already been set when instantiating this call,
9988 /// we provide this method for API completeness.
9989 pub fn request(
9990 mut self,
9991 new_value: CancelOperationRequest,
9992 ) -> ProjectLocationOperationCancelCall<'a, C> {
9993 self._request = new_value;
9994 self
9995 }
9996 /// The name of the operation resource to be cancelled.
9997 ///
9998 /// Sets the *name* path property to the given value.
9999 ///
10000 /// Even though the property as already been set when instantiating this call,
10001 /// we provide this method for API completeness.
10002 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
10003 self._name = new_value.to_string();
10004 self
10005 }
10006 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10007 /// while executing the actual API request.
10008 ///
10009 /// ````text
10010 /// It should be used to handle progress information, and to implement a certain level of resilience.
10011 /// ````
10012 ///
10013 /// Sets the *delegate* property to the given value.
10014 pub fn delegate(
10015 mut self,
10016 new_value: &'a mut dyn common::Delegate,
10017 ) -> ProjectLocationOperationCancelCall<'a, C> {
10018 self._delegate = Some(new_value);
10019 self
10020 }
10021
10022 /// Set any additional parameter of the query string used in the request.
10023 /// It should be used to set parameters which are not yet available through their own
10024 /// setters.
10025 ///
10026 /// Please note that this method must not be used to set any of the known parameters
10027 /// which have their own setter method. If done anyway, the request will fail.
10028 ///
10029 /// # Additional Parameters
10030 ///
10031 /// * *$.xgafv* (query-string) - V1 error format.
10032 /// * *access_token* (query-string) - OAuth access token.
10033 /// * *alt* (query-string) - Data format for response.
10034 /// * *callback* (query-string) - JSONP
10035 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10036 /// * *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.
10037 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10038 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10039 /// * *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.
10040 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10041 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10042 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
10043 where
10044 T: AsRef<str>,
10045 {
10046 self._additional_params
10047 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10048 self
10049 }
10050
10051 /// Identifies the authorization scope for the method you are building.
10052 ///
10053 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10054 /// [`Scope::CloudPlatform`].
10055 ///
10056 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10057 /// tokens for more than one scope.
10058 ///
10059 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10060 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10061 /// sufficient, a read-write scope will do as well.
10062 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
10063 where
10064 St: AsRef<str>,
10065 {
10066 self._scopes.insert(String::from(scope.as_ref()));
10067 self
10068 }
10069 /// Identifies the authorization scope(s) for the method you are building.
10070 ///
10071 /// See [`Self::add_scope()`] for details.
10072 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
10073 where
10074 I: IntoIterator<Item = St>,
10075 St: AsRef<str>,
10076 {
10077 self._scopes
10078 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10079 self
10080 }
10081
10082 /// Removes all scopes, and no default scope will be used either.
10083 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10084 /// for details).
10085 pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
10086 self._scopes.clear();
10087 self
10088 }
10089}
10090
10091/// 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`.
10092///
10093/// A builder for the *locations.operations.delete* method supported by a *project* resource.
10094/// It is not used directly, but through a [`ProjectMethods`] instance.
10095///
10096/// # Example
10097///
10098/// Instantiate a resource method builder
10099///
10100/// ```test_harness,no_run
10101/// # extern crate hyper;
10102/// # extern crate hyper_rustls;
10103/// # extern crate google_vmmigration1 as vmmigration1;
10104/// # async fn dox() {
10105/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10106///
10107/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10108/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10109/// # .with_native_roots()
10110/// # .unwrap()
10111/// # .https_only()
10112/// # .enable_http2()
10113/// # .build();
10114///
10115/// # let executor = hyper_util::rt::TokioExecutor::new();
10116/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10117/// # secret,
10118/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10119/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10120/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10121/// # ),
10122/// # ).build().await.unwrap();
10123///
10124/// # let client = hyper_util::client::legacy::Client::builder(
10125/// # hyper_util::rt::TokioExecutor::new()
10126/// # )
10127/// # .build(
10128/// # hyper_rustls::HttpsConnectorBuilder::new()
10129/// # .with_native_roots()
10130/// # .unwrap()
10131/// # .https_or_http()
10132/// # .enable_http2()
10133/// # .build()
10134/// # );
10135/// # let mut hub = VMMigrationService::new(client, auth);
10136/// // You can configure optional parameters by calling the respective setters at will, and
10137/// // execute the final call using `doit()`.
10138/// // Values shown here are possibly random and not representative !
10139/// let result = hub.projects().locations_operations_delete("name")
10140/// .doit().await;
10141/// # }
10142/// ```
10143pub struct ProjectLocationOperationDeleteCall<'a, C>
10144where
10145 C: 'a,
10146{
10147 hub: &'a VMMigrationService<C>,
10148 _name: String,
10149 _delegate: Option<&'a mut dyn common::Delegate>,
10150 _additional_params: HashMap<String, String>,
10151 _scopes: BTreeSet<String>,
10152}
10153
10154impl<'a, C> common::CallBuilder for ProjectLocationOperationDeleteCall<'a, C> {}
10155
10156impl<'a, C> ProjectLocationOperationDeleteCall<'a, C>
10157where
10158 C: common::Connector,
10159{
10160 /// Perform the operation you have build so far.
10161 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
10162 use std::borrow::Cow;
10163 use std::io::{Read, Seek};
10164
10165 use common::{url::Params, ToParts};
10166 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10167
10168 let mut dd = common::DefaultDelegate;
10169 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10170 dlg.begin(common::MethodInfo {
10171 id: "vmmigration.projects.locations.operations.delete",
10172 http_method: hyper::Method::DELETE,
10173 });
10174
10175 for &field in ["alt", "name"].iter() {
10176 if self._additional_params.contains_key(field) {
10177 dlg.finished(false);
10178 return Err(common::Error::FieldClash(field));
10179 }
10180 }
10181
10182 let mut params = Params::with_capacity(3 + self._additional_params.len());
10183 params.push("name", self._name);
10184
10185 params.extend(self._additional_params.iter());
10186
10187 params.push("alt", "json");
10188 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10189 if self._scopes.is_empty() {
10190 self._scopes
10191 .insert(Scope::CloudPlatform.as_ref().to_string());
10192 }
10193
10194 #[allow(clippy::single_element_loop)]
10195 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10196 url = params.uri_replacement(url, param_name, find_this, true);
10197 }
10198 {
10199 let to_remove = ["name"];
10200 params.remove_params(&to_remove);
10201 }
10202
10203 let url = params.parse_with_url(&url);
10204
10205 loop {
10206 let token = match self
10207 .hub
10208 .auth
10209 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10210 .await
10211 {
10212 Ok(token) => token,
10213 Err(e) => match dlg.token(e) {
10214 Ok(token) => token,
10215 Err(e) => {
10216 dlg.finished(false);
10217 return Err(common::Error::MissingToken(e));
10218 }
10219 },
10220 };
10221 let mut req_result = {
10222 let client = &self.hub.client;
10223 dlg.pre_request();
10224 let mut req_builder = hyper::Request::builder()
10225 .method(hyper::Method::DELETE)
10226 .uri(url.as_str())
10227 .header(USER_AGENT, self.hub._user_agent.clone());
10228
10229 if let Some(token) = token.as_ref() {
10230 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10231 }
10232
10233 let request = req_builder
10234 .header(CONTENT_LENGTH, 0_u64)
10235 .body(common::to_body::<String>(None));
10236
10237 client.request(request.unwrap()).await
10238 };
10239
10240 match req_result {
10241 Err(err) => {
10242 if let common::Retry::After(d) = dlg.http_error(&err) {
10243 sleep(d).await;
10244 continue;
10245 }
10246 dlg.finished(false);
10247 return Err(common::Error::HttpError(err));
10248 }
10249 Ok(res) => {
10250 let (mut parts, body) = res.into_parts();
10251 let mut body = common::Body::new(body);
10252 if !parts.status.is_success() {
10253 let bytes = common::to_bytes(body).await.unwrap_or_default();
10254 let error = serde_json::from_str(&common::to_string(&bytes));
10255 let response = common::to_response(parts, bytes.into());
10256
10257 if let common::Retry::After(d) =
10258 dlg.http_failure(&response, error.as_ref().ok())
10259 {
10260 sleep(d).await;
10261 continue;
10262 }
10263
10264 dlg.finished(false);
10265
10266 return Err(match error {
10267 Ok(value) => common::Error::BadRequest(value),
10268 _ => common::Error::Failure(response),
10269 });
10270 }
10271 let response = {
10272 let bytes = common::to_bytes(body).await.unwrap_or_default();
10273 let encoded = common::to_string(&bytes);
10274 match serde_json::from_str(&encoded) {
10275 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10276 Err(error) => {
10277 dlg.response_json_decode_error(&encoded, &error);
10278 return Err(common::Error::JsonDecodeError(
10279 encoded.to_string(),
10280 error,
10281 ));
10282 }
10283 }
10284 };
10285
10286 dlg.finished(true);
10287 return Ok(response);
10288 }
10289 }
10290 }
10291 }
10292
10293 /// The name of the operation resource to be deleted.
10294 ///
10295 /// Sets the *name* path property to the given value.
10296 ///
10297 /// Even though the property as already been set when instantiating this call,
10298 /// we provide this method for API completeness.
10299 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationDeleteCall<'a, C> {
10300 self._name = new_value.to_string();
10301 self
10302 }
10303 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10304 /// while executing the actual API request.
10305 ///
10306 /// ````text
10307 /// It should be used to handle progress information, and to implement a certain level of resilience.
10308 /// ````
10309 ///
10310 /// Sets the *delegate* property to the given value.
10311 pub fn delegate(
10312 mut self,
10313 new_value: &'a mut dyn common::Delegate,
10314 ) -> ProjectLocationOperationDeleteCall<'a, C> {
10315 self._delegate = Some(new_value);
10316 self
10317 }
10318
10319 /// Set any additional parameter of the query string used in the request.
10320 /// It should be used to set parameters which are not yet available through their own
10321 /// setters.
10322 ///
10323 /// Please note that this method must not be used to set any of the known parameters
10324 /// which have their own setter method. If done anyway, the request will fail.
10325 ///
10326 /// # Additional Parameters
10327 ///
10328 /// * *$.xgafv* (query-string) - V1 error format.
10329 /// * *access_token* (query-string) - OAuth access token.
10330 /// * *alt* (query-string) - Data format for response.
10331 /// * *callback* (query-string) - JSONP
10332 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10333 /// * *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.
10334 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10335 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10336 /// * *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.
10337 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10338 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10339 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationDeleteCall<'a, C>
10340 where
10341 T: AsRef<str>,
10342 {
10343 self._additional_params
10344 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10345 self
10346 }
10347
10348 /// Identifies the authorization scope for the method you are building.
10349 ///
10350 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10351 /// [`Scope::CloudPlatform`].
10352 ///
10353 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10354 /// tokens for more than one scope.
10355 ///
10356 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10357 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10358 /// sufficient, a read-write scope will do as well.
10359 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationDeleteCall<'a, C>
10360 where
10361 St: AsRef<str>,
10362 {
10363 self._scopes.insert(String::from(scope.as_ref()));
10364 self
10365 }
10366 /// Identifies the authorization scope(s) for the method you are building.
10367 ///
10368 /// See [`Self::add_scope()`] for details.
10369 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationDeleteCall<'a, C>
10370 where
10371 I: IntoIterator<Item = St>,
10372 St: AsRef<str>,
10373 {
10374 self._scopes
10375 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10376 self
10377 }
10378
10379 /// Removes all scopes, and no default scope will be used either.
10380 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10381 /// for details).
10382 pub fn clear_scopes(mut self) -> ProjectLocationOperationDeleteCall<'a, C> {
10383 self._scopes.clear();
10384 self
10385 }
10386}
10387
10388/// 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.
10389///
10390/// A builder for the *locations.operations.get* method supported by a *project* resource.
10391/// It is not used directly, but through a [`ProjectMethods`] instance.
10392///
10393/// # Example
10394///
10395/// Instantiate a resource method builder
10396///
10397/// ```test_harness,no_run
10398/// # extern crate hyper;
10399/// # extern crate hyper_rustls;
10400/// # extern crate google_vmmigration1 as vmmigration1;
10401/// # async fn dox() {
10402/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10403///
10404/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10405/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10406/// # .with_native_roots()
10407/// # .unwrap()
10408/// # .https_only()
10409/// # .enable_http2()
10410/// # .build();
10411///
10412/// # let executor = hyper_util::rt::TokioExecutor::new();
10413/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10414/// # secret,
10415/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10416/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10417/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10418/// # ),
10419/// # ).build().await.unwrap();
10420///
10421/// # let client = hyper_util::client::legacy::Client::builder(
10422/// # hyper_util::rt::TokioExecutor::new()
10423/// # )
10424/// # .build(
10425/// # hyper_rustls::HttpsConnectorBuilder::new()
10426/// # .with_native_roots()
10427/// # .unwrap()
10428/// # .https_or_http()
10429/// # .enable_http2()
10430/// # .build()
10431/// # );
10432/// # let mut hub = VMMigrationService::new(client, auth);
10433/// // You can configure optional parameters by calling the respective setters at will, and
10434/// // execute the final call using `doit()`.
10435/// // Values shown here are possibly random and not representative !
10436/// let result = hub.projects().locations_operations_get("name")
10437/// .doit().await;
10438/// # }
10439/// ```
10440pub struct ProjectLocationOperationGetCall<'a, C>
10441where
10442 C: 'a,
10443{
10444 hub: &'a VMMigrationService<C>,
10445 _name: String,
10446 _delegate: Option<&'a mut dyn common::Delegate>,
10447 _additional_params: HashMap<String, String>,
10448 _scopes: BTreeSet<String>,
10449}
10450
10451impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
10452
10453impl<'a, C> ProjectLocationOperationGetCall<'a, C>
10454where
10455 C: common::Connector,
10456{
10457 /// Perform the operation you have build so far.
10458 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10459 use std::borrow::Cow;
10460 use std::io::{Read, Seek};
10461
10462 use common::{url::Params, ToParts};
10463 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10464
10465 let mut dd = common::DefaultDelegate;
10466 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10467 dlg.begin(common::MethodInfo {
10468 id: "vmmigration.projects.locations.operations.get",
10469 http_method: hyper::Method::GET,
10470 });
10471
10472 for &field in ["alt", "name"].iter() {
10473 if self._additional_params.contains_key(field) {
10474 dlg.finished(false);
10475 return Err(common::Error::FieldClash(field));
10476 }
10477 }
10478
10479 let mut params = Params::with_capacity(3 + self._additional_params.len());
10480 params.push("name", self._name);
10481
10482 params.extend(self._additional_params.iter());
10483
10484 params.push("alt", "json");
10485 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10486 if self._scopes.is_empty() {
10487 self._scopes
10488 .insert(Scope::CloudPlatform.as_ref().to_string());
10489 }
10490
10491 #[allow(clippy::single_element_loop)]
10492 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10493 url = params.uri_replacement(url, param_name, find_this, true);
10494 }
10495 {
10496 let to_remove = ["name"];
10497 params.remove_params(&to_remove);
10498 }
10499
10500 let url = params.parse_with_url(&url);
10501
10502 loop {
10503 let token = match self
10504 .hub
10505 .auth
10506 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10507 .await
10508 {
10509 Ok(token) => token,
10510 Err(e) => match dlg.token(e) {
10511 Ok(token) => token,
10512 Err(e) => {
10513 dlg.finished(false);
10514 return Err(common::Error::MissingToken(e));
10515 }
10516 },
10517 };
10518 let mut req_result = {
10519 let client = &self.hub.client;
10520 dlg.pre_request();
10521 let mut req_builder = hyper::Request::builder()
10522 .method(hyper::Method::GET)
10523 .uri(url.as_str())
10524 .header(USER_AGENT, self.hub._user_agent.clone());
10525
10526 if let Some(token) = token.as_ref() {
10527 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10528 }
10529
10530 let request = req_builder
10531 .header(CONTENT_LENGTH, 0_u64)
10532 .body(common::to_body::<String>(None));
10533
10534 client.request(request.unwrap()).await
10535 };
10536
10537 match req_result {
10538 Err(err) => {
10539 if let common::Retry::After(d) = dlg.http_error(&err) {
10540 sleep(d).await;
10541 continue;
10542 }
10543 dlg.finished(false);
10544 return Err(common::Error::HttpError(err));
10545 }
10546 Ok(res) => {
10547 let (mut parts, body) = res.into_parts();
10548 let mut body = common::Body::new(body);
10549 if !parts.status.is_success() {
10550 let bytes = common::to_bytes(body).await.unwrap_or_default();
10551 let error = serde_json::from_str(&common::to_string(&bytes));
10552 let response = common::to_response(parts, bytes.into());
10553
10554 if let common::Retry::After(d) =
10555 dlg.http_failure(&response, error.as_ref().ok())
10556 {
10557 sleep(d).await;
10558 continue;
10559 }
10560
10561 dlg.finished(false);
10562
10563 return Err(match error {
10564 Ok(value) => common::Error::BadRequest(value),
10565 _ => common::Error::Failure(response),
10566 });
10567 }
10568 let response = {
10569 let bytes = common::to_bytes(body).await.unwrap_or_default();
10570 let encoded = common::to_string(&bytes);
10571 match serde_json::from_str(&encoded) {
10572 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10573 Err(error) => {
10574 dlg.response_json_decode_error(&encoded, &error);
10575 return Err(common::Error::JsonDecodeError(
10576 encoded.to_string(),
10577 error,
10578 ));
10579 }
10580 }
10581 };
10582
10583 dlg.finished(true);
10584 return Ok(response);
10585 }
10586 }
10587 }
10588 }
10589
10590 /// The name of the operation resource.
10591 ///
10592 /// Sets the *name* path property to the given value.
10593 ///
10594 /// Even though the property as already been set when instantiating this call,
10595 /// we provide this method for API completeness.
10596 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
10597 self._name = new_value.to_string();
10598 self
10599 }
10600 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10601 /// while executing the actual API request.
10602 ///
10603 /// ````text
10604 /// It should be used to handle progress information, and to implement a certain level of resilience.
10605 /// ````
10606 ///
10607 /// Sets the *delegate* property to the given value.
10608 pub fn delegate(
10609 mut self,
10610 new_value: &'a mut dyn common::Delegate,
10611 ) -> ProjectLocationOperationGetCall<'a, C> {
10612 self._delegate = Some(new_value);
10613 self
10614 }
10615
10616 /// Set any additional parameter of the query string used in the request.
10617 /// It should be used to set parameters which are not yet available through their own
10618 /// setters.
10619 ///
10620 /// Please note that this method must not be used to set any of the known parameters
10621 /// which have their own setter method. If done anyway, the request will fail.
10622 ///
10623 /// # Additional Parameters
10624 ///
10625 /// * *$.xgafv* (query-string) - V1 error format.
10626 /// * *access_token* (query-string) - OAuth access token.
10627 /// * *alt* (query-string) - Data format for response.
10628 /// * *callback* (query-string) - JSONP
10629 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10630 /// * *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.
10631 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10632 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10633 /// * *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.
10634 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10635 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10636 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
10637 where
10638 T: AsRef<str>,
10639 {
10640 self._additional_params
10641 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10642 self
10643 }
10644
10645 /// Identifies the authorization scope for the method you are building.
10646 ///
10647 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10648 /// [`Scope::CloudPlatform`].
10649 ///
10650 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10651 /// tokens for more than one scope.
10652 ///
10653 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10654 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10655 /// sufficient, a read-write scope will do as well.
10656 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
10657 where
10658 St: AsRef<str>,
10659 {
10660 self._scopes.insert(String::from(scope.as_ref()));
10661 self
10662 }
10663 /// Identifies the authorization scope(s) for the method you are building.
10664 ///
10665 /// See [`Self::add_scope()`] for details.
10666 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
10667 where
10668 I: IntoIterator<Item = St>,
10669 St: AsRef<str>,
10670 {
10671 self._scopes
10672 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10673 self
10674 }
10675
10676 /// Removes all scopes, and no default scope will be used either.
10677 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10678 /// for details).
10679 pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
10680 self._scopes.clear();
10681 self
10682 }
10683}
10684
10685/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
10686///
10687/// A builder for the *locations.operations.list* method supported by a *project* resource.
10688/// It is not used directly, but through a [`ProjectMethods`] instance.
10689///
10690/// # Example
10691///
10692/// Instantiate a resource method builder
10693///
10694/// ```test_harness,no_run
10695/// # extern crate hyper;
10696/// # extern crate hyper_rustls;
10697/// # extern crate google_vmmigration1 as vmmigration1;
10698/// # async fn dox() {
10699/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10700///
10701/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10702/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10703/// # .with_native_roots()
10704/// # .unwrap()
10705/// # .https_only()
10706/// # .enable_http2()
10707/// # .build();
10708///
10709/// # let executor = hyper_util::rt::TokioExecutor::new();
10710/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10711/// # secret,
10712/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10713/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10714/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10715/// # ),
10716/// # ).build().await.unwrap();
10717///
10718/// # let client = hyper_util::client::legacy::Client::builder(
10719/// # hyper_util::rt::TokioExecutor::new()
10720/// # )
10721/// # .build(
10722/// # hyper_rustls::HttpsConnectorBuilder::new()
10723/// # .with_native_roots()
10724/// # .unwrap()
10725/// # .https_or_http()
10726/// # .enable_http2()
10727/// # .build()
10728/// # );
10729/// # let mut hub = VMMigrationService::new(client, auth);
10730/// // You can configure optional parameters by calling the respective setters at will, and
10731/// // execute the final call using `doit()`.
10732/// // Values shown here are possibly random and not representative !
10733/// let result = hub.projects().locations_operations_list("name")
10734/// .return_partial_success(true)
10735/// .page_token("vero")
10736/// .page_size(-31)
10737/// .filter("sed")
10738/// .doit().await;
10739/// # }
10740/// ```
10741pub struct ProjectLocationOperationListCall<'a, C>
10742where
10743 C: 'a,
10744{
10745 hub: &'a VMMigrationService<C>,
10746 _name: String,
10747 _return_partial_success: Option<bool>,
10748 _page_token: Option<String>,
10749 _page_size: Option<i32>,
10750 _filter: Option<String>,
10751 _delegate: Option<&'a mut dyn common::Delegate>,
10752 _additional_params: HashMap<String, String>,
10753 _scopes: BTreeSet<String>,
10754}
10755
10756impl<'a, C> common::CallBuilder for ProjectLocationOperationListCall<'a, C> {}
10757
10758impl<'a, C> ProjectLocationOperationListCall<'a, C>
10759where
10760 C: common::Connector,
10761{
10762 /// Perform the operation you have build so far.
10763 pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
10764 use std::borrow::Cow;
10765 use std::io::{Read, Seek};
10766
10767 use common::{url::Params, ToParts};
10768 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10769
10770 let mut dd = common::DefaultDelegate;
10771 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10772 dlg.begin(common::MethodInfo {
10773 id: "vmmigration.projects.locations.operations.list",
10774 http_method: hyper::Method::GET,
10775 });
10776
10777 for &field in [
10778 "alt",
10779 "name",
10780 "returnPartialSuccess",
10781 "pageToken",
10782 "pageSize",
10783 "filter",
10784 ]
10785 .iter()
10786 {
10787 if self._additional_params.contains_key(field) {
10788 dlg.finished(false);
10789 return Err(common::Error::FieldClash(field));
10790 }
10791 }
10792
10793 let mut params = Params::with_capacity(7 + self._additional_params.len());
10794 params.push("name", self._name);
10795 if let Some(value) = self._return_partial_success.as_ref() {
10796 params.push("returnPartialSuccess", value.to_string());
10797 }
10798 if let Some(value) = self._page_token.as_ref() {
10799 params.push("pageToken", value);
10800 }
10801 if let Some(value) = self._page_size.as_ref() {
10802 params.push("pageSize", value.to_string());
10803 }
10804 if let Some(value) = self._filter.as_ref() {
10805 params.push("filter", value);
10806 }
10807
10808 params.extend(self._additional_params.iter());
10809
10810 params.push("alt", "json");
10811 let mut url = self.hub._base_url.clone() + "v1/{+name}/operations";
10812 if self._scopes.is_empty() {
10813 self._scopes
10814 .insert(Scope::CloudPlatform.as_ref().to_string());
10815 }
10816
10817 #[allow(clippy::single_element_loop)]
10818 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10819 url = params.uri_replacement(url, param_name, find_this, true);
10820 }
10821 {
10822 let to_remove = ["name"];
10823 params.remove_params(&to_remove);
10824 }
10825
10826 let url = params.parse_with_url(&url);
10827
10828 loop {
10829 let token = match self
10830 .hub
10831 .auth
10832 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10833 .await
10834 {
10835 Ok(token) => token,
10836 Err(e) => match dlg.token(e) {
10837 Ok(token) => token,
10838 Err(e) => {
10839 dlg.finished(false);
10840 return Err(common::Error::MissingToken(e));
10841 }
10842 },
10843 };
10844 let mut req_result = {
10845 let client = &self.hub.client;
10846 dlg.pre_request();
10847 let mut req_builder = hyper::Request::builder()
10848 .method(hyper::Method::GET)
10849 .uri(url.as_str())
10850 .header(USER_AGENT, self.hub._user_agent.clone());
10851
10852 if let Some(token) = token.as_ref() {
10853 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10854 }
10855
10856 let request = req_builder
10857 .header(CONTENT_LENGTH, 0_u64)
10858 .body(common::to_body::<String>(None));
10859
10860 client.request(request.unwrap()).await
10861 };
10862
10863 match req_result {
10864 Err(err) => {
10865 if let common::Retry::After(d) = dlg.http_error(&err) {
10866 sleep(d).await;
10867 continue;
10868 }
10869 dlg.finished(false);
10870 return Err(common::Error::HttpError(err));
10871 }
10872 Ok(res) => {
10873 let (mut parts, body) = res.into_parts();
10874 let mut body = common::Body::new(body);
10875 if !parts.status.is_success() {
10876 let bytes = common::to_bytes(body).await.unwrap_or_default();
10877 let error = serde_json::from_str(&common::to_string(&bytes));
10878 let response = common::to_response(parts, bytes.into());
10879
10880 if let common::Retry::After(d) =
10881 dlg.http_failure(&response, error.as_ref().ok())
10882 {
10883 sleep(d).await;
10884 continue;
10885 }
10886
10887 dlg.finished(false);
10888
10889 return Err(match error {
10890 Ok(value) => common::Error::BadRequest(value),
10891 _ => common::Error::Failure(response),
10892 });
10893 }
10894 let response = {
10895 let bytes = common::to_bytes(body).await.unwrap_or_default();
10896 let encoded = common::to_string(&bytes);
10897 match serde_json::from_str(&encoded) {
10898 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10899 Err(error) => {
10900 dlg.response_json_decode_error(&encoded, &error);
10901 return Err(common::Error::JsonDecodeError(
10902 encoded.to_string(),
10903 error,
10904 ));
10905 }
10906 }
10907 };
10908
10909 dlg.finished(true);
10910 return Ok(response);
10911 }
10912 }
10913 }
10914 }
10915
10916 /// The name of the operation's parent resource.
10917 ///
10918 /// Sets the *name* path property to the given value.
10919 ///
10920 /// Even though the property as already been set when instantiating this call,
10921 /// we provide this method for API completeness.
10922 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
10923 self._name = new_value.to_string();
10924 self
10925 }
10926 /// When set to `true`, operations that are reachable are returned as normal, and those that are unreachable are returned in the ListOperationsResponse.unreachable field. This can only be `true` when reading across collections. For example, when `parent` is set to `"projects/example/locations/-"`. This field is not supported by default and will result in an `UNIMPLEMENTED` error if set unless explicitly documented otherwise in service or product specific documentation.
10927 ///
10928 /// Sets the *return partial success* query property to the given value.
10929 pub fn return_partial_success(
10930 mut self,
10931 new_value: bool,
10932 ) -> ProjectLocationOperationListCall<'a, C> {
10933 self._return_partial_success = Some(new_value);
10934 self
10935 }
10936 /// The standard list page token.
10937 ///
10938 /// Sets the *page token* query property to the given value.
10939 pub fn page_token(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
10940 self._page_token = Some(new_value.to_string());
10941 self
10942 }
10943 /// The standard list page size.
10944 ///
10945 /// Sets the *page size* query property to the given value.
10946 pub fn page_size(mut self, new_value: i32) -> ProjectLocationOperationListCall<'a, C> {
10947 self._page_size = Some(new_value);
10948 self
10949 }
10950 /// The standard list filter.
10951 ///
10952 /// Sets the *filter* query property to the given value.
10953 pub fn filter(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
10954 self._filter = Some(new_value.to_string());
10955 self
10956 }
10957 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10958 /// while executing the actual API request.
10959 ///
10960 /// ````text
10961 /// It should be used to handle progress information, and to implement a certain level of resilience.
10962 /// ````
10963 ///
10964 /// Sets the *delegate* property to the given value.
10965 pub fn delegate(
10966 mut self,
10967 new_value: &'a mut dyn common::Delegate,
10968 ) -> ProjectLocationOperationListCall<'a, C> {
10969 self._delegate = Some(new_value);
10970 self
10971 }
10972
10973 /// Set any additional parameter of the query string used in the request.
10974 /// It should be used to set parameters which are not yet available through their own
10975 /// setters.
10976 ///
10977 /// Please note that this method must not be used to set any of the known parameters
10978 /// which have their own setter method. If done anyway, the request will fail.
10979 ///
10980 /// # Additional Parameters
10981 ///
10982 /// * *$.xgafv* (query-string) - V1 error format.
10983 /// * *access_token* (query-string) - OAuth access token.
10984 /// * *alt* (query-string) - Data format for response.
10985 /// * *callback* (query-string) - JSONP
10986 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10987 /// * *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.
10988 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10989 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10990 /// * *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.
10991 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10992 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10993 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationListCall<'a, C>
10994 where
10995 T: AsRef<str>,
10996 {
10997 self._additional_params
10998 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10999 self
11000 }
11001
11002 /// Identifies the authorization scope for the method you are building.
11003 ///
11004 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11005 /// [`Scope::CloudPlatform`].
11006 ///
11007 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11008 /// tokens for more than one scope.
11009 ///
11010 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11011 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11012 /// sufficient, a read-write scope will do as well.
11013 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationListCall<'a, C>
11014 where
11015 St: AsRef<str>,
11016 {
11017 self._scopes.insert(String::from(scope.as_ref()));
11018 self
11019 }
11020 /// Identifies the authorization scope(s) for the method you are building.
11021 ///
11022 /// See [`Self::add_scope()`] for details.
11023 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationListCall<'a, C>
11024 where
11025 I: IntoIterator<Item = St>,
11026 St: AsRef<str>,
11027 {
11028 self._scopes
11029 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11030 self
11031 }
11032
11033 /// Removes all scopes, and no default scope will be used either.
11034 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11035 /// for details).
11036 pub fn clear_scopes(mut self) -> ProjectLocationOperationListCall<'a, C> {
11037 self._scopes.clear();
11038 self
11039 }
11040}
11041
11042/// Creates a new DatacenterConnector in a given Source.
11043///
11044/// A builder for the *locations.sources.datacenterConnectors.create* method supported by a *project* resource.
11045/// It is not used directly, but through a [`ProjectMethods`] instance.
11046///
11047/// # Example
11048///
11049/// Instantiate a resource method builder
11050///
11051/// ```test_harness,no_run
11052/// # extern crate hyper;
11053/// # extern crate hyper_rustls;
11054/// # extern crate google_vmmigration1 as vmmigration1;
11055/// use vmmigration1::api::DatacenterConnector;
11056/// # async fn dox() {
11057/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11058///
11059/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11060/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11061/// # .with_native_roots()
11062/// # .unwrap()
11063/// # .https_only()
11064/// # .enable_http2()
11065/// # .build();
11066///
11067/// # let executor = hyper_util::rt::TokioExecutor::new();
11068/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11069/// # secret,
11070/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11071/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11072/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11073/// # ),
11074/// # ).build().await.unwrap();
11075///
11076/// # let client = hyper_util::client::legacy::Client::builder(
11077/// # hyper_util::rt::TokioExecutor::new()
11078/// # )
11079/// # .build(
11080/// # hyper_rustls::HttpsConnectorBuilder::new()
11081/// # .with_native_roots()
11082/// # .unwrap()
11083/// # .https_or_http()
11084/// # .enable_http2()
11085/// # .build()
11086/// # );
11087/// # let mut hub = VMMigrationService::new(client, auth);
11088/// // As the method needs a request, you would usually fill it with the desired information
11089/// // into the respective structure. Some of the parts shown here might not be applicable !
11090/// // Values shown here are possibly random and not representative !
11091/// let mut req = DatacenterConnector::default();
11092///
11093/// // You can configure optional parameters by calling the respective setters at will, and
11094/// // execute the final call using `doit()`.
11095/// // Values shown here are possibly random and not representative !
11096/// let result = hub.projects().locations_sources_datacenter_connectors_create(req, "parent")
11097/// .request_id("dolore")
11098/// .datacenter_connector_id("et")
11099/// .doit().await;
11100/// # }
11101/// ```
11102pub struct ProjectLocationSourceDatacenterConnectorCreateCall<'a, C>
11103where
11104 C: 'a,
11105{
11106 hub: &'a VMMigrationService<C>,
11107 _request: DatacenterConnector,
11108 _parent: String,
11109 _request_id: Option<String>,
11110 _datacenter_connector_id: Option<String>,
11111 _delegate: Option<&'a mut dyn common::Delegate>,
11112 _additional_params: HashMap<String, String>,
11113 _scopes: BTreeSet<String>,
11114}
11115
11116impl<'a, C> common::CallBuilder for ProjectLocationSourceDatacenterConnectorCreateCall<'a, C> {}
11117
11118impl<'a, C> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C>
11119where
11120 C: common::Connector,
11121{
11122 /// Perform the operation you have build so far.
11123 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11124 use std::borrow::Cow;
11125 use std::io::{Read, Seek};
11126
11127 use common::{url::Params, ToParts};
11128 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11129
11130 let mut dd = common::DefaultDelegate;
11131 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11132 dlg.begin(common::MethodInfo {
11133 id: "vmmigration.projects.locations.sources.datacenterConnectors.create",
11134 http_method: hyper::Method::POST,
11135 });
11136
11137 for &field in ["alt", "parent", "requestId", "datacenterConnectorId"].iter() {
11138 if self._additional_params.contains_key(field) {
11139 dlg.finished(false);
11140 return Err(common::Error::FieldClash(field));
11141 }
11142 }
11143
11144 let mut params = Params::with_capacity(6 + self._additional_params.len());
11145 params.push("parent", self._parent);
11146 if let Some(value) = self._request_id.as_ref() {
11147 params.push("requestId", value);
11148 }
11149 if let Some(value) = self._datacenter_connector_id.as_ref() {
11150 params.push("datacenterConnectorId", value);
11151 }
11152
11153 params.extend(self._additional_params.iter());
11154
11155 params.push("alt", "json");
11156 let mut url = self.hub._base_url.clone() + "v1/{+parent}/datacenterConnectors";
11157 if self._scopes.is_empty() {
11158 self._scopes
11159 .insert(Scope::CloudPlatform.as_ref().to_string());
11160 }
11161
11162 #[allow(clippy::single_element_loop)]
11163 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11164 url = params.uri_replacement(url, param_name, find_this, true);
11165 }
11166 {
11167 let to_remove = ["parent"];
11168 params.remove_params(&to_remove);
11169 }
11170
11171 let url = params.parse_with_url(&url);
11172
11173 let mut json_mime_type = mime::APPLICATION_JSON;
11174 let mut request_value_reader = {
11175 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11176 common::remove_json_null_values(&mut value);
11177 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11178 serde_json::to_writer(&mut dst, &value).unwrap();
11179 dst
11180 };
11181 let request_size = request_value_reader
11182 .seek(std::io::SeekFrom::End(0))
11183 .unwrap();
11184 request_value_reader
11185 .seek(std::io::SeekFrom::Start(0))
11186 .unwrap();
11187
11188 loop {
11189 let token = match self
11190 .hub
11191 .auth
11192 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11193 .await
11194 {
11195 Ok(token) => token,
11196 Err(e) => match dlg.token(e) {
11197 Ok(token) => token,
11198 Err(e) => {
11199 dlg.finished(false);
11200 return Err(common::Error::MissingToken(e));
11201 }
11202 },
11203 };
11204 request_value_reader
11205 .seek(std::io::SeekFrom::Start(0))
11206 .unwrap();
11207 let mut req_result = {
11208 let client = &self.hub.client;
11209 dlg.pre_request();
11210 let mut req_builder = hyper::Request::builder()
11211 .method(hyper::Method::POST)
11212 .uri(url.as_str())
11213 .header(USER_AGENT, self.hub._user_agent.clone());
11214
11215 if let Some(token) = token.as_ref() {
11216 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11217 }
11218
11219 let request = req_builder
11220 .header(CONTENT_TYPE, json_mime_type.to_string())
11221 .header(CONTENT_LENGTH, request_size as u64)
11222 .body(common::to_body(
11223 request_value_reader.get_ref().clone().into(),
11224 ));
11225
11226 client.request(request.unwrap()).await
11227 };
11228
11229 match req_result {
11230 Err(err) => {
11231 if let common::Retry::After(d) = dlg.http_error(&err) {
11232 sleep(d).await;
11233 continue;
11234 }
11235 dlg.finished(false);
11236 return Err(common::Error::HttpError(err));
11237 }
11238 Ok(res) => {
11239 let (mut parts, body) = res.into_parts();
11240 let mut body = common::Body::new(body);
11241 if !parts.status.is_success() {
11242 let bytes = common::to_bytes(body).await.unwrap_or_default();
11243 let error = serde_json::from_str(&common::to_string(&bytes));
11244 let response = common::to_response(parts, bytes.into());
11245
11246 if let common::Retry::After(d) =
11247 dlg.http_failure(&response, error.as_ref().ok())
11248 {
11249 sleep(d).await;
11250 continue;
11251 }
11252
11253 dlg.finished(false);
11254
11255 return Err(match error {
11256 Ok(value) => common::Error::BadRequest(value),
11257 _ => common::Error::Failure(response),
11258 });
11259 }
11260 let response = {
11261 let bytes = common::to_bytes(body).await.unwrap_or_default();
11262 let encoded = common::to_string(&bytes);
11263 match serde_json::from_str(&encoded) {
11264 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11265 Err(error) => {
11266 dlg.response_json_decode_error(&encoded, &error);
11267 return Err(common::Error::JsonDecodeError(
11268 encoded.to_string(),
11269 error,
11270 ));
11271 }
11272 }
11273 };
11274
11275 dlg.finished(true);
11276 return Ok(response);
11277 }
11278 }
11279 }
11280 }
11281
11282 ///
11283 /// Sets the *request* property to the given value.
11284 ///
11285 /// Even though the property as already been set when instantiating this call,
11286 /// we provide this method for API completeness.
11287 pub fn request(
11288 mut self,
11289 new_value: DatacenterConnector,
11290 ) -> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C> {
11291 self._request = new_value;
11292 self
11293 }
11294 /// 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`
11295 ///
11296 /// Sets the *parent* path property to the given value.
11297 ///
11298 /// Even though the property as already been set when instantiating this call,
11299 /// we provide this method for API completeness.
11300 pub fn parent(
11301 mut self,
11302 new_value: &str,
11303 ) -> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C> {
11304 self._parent = new_value.to_string();
11305 self
11306 }
11307 /// 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).
11308 ///
11309 /// Sets the *request id* query property to the given value.
11310 pub fn request_id(
11311 mut self,
11312 new_value: &str,
11313 ) -> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C> {
11314 self._request_id = Some(new_value.to_string());
11315 self
11316 }
11317 /// Required. The datacenterConnector identifier.
11318 ///
11319 /// Sets the *datacenter connector id* query property to the given value.
11320 pub fn datacenter_connector_id(
11321 mut self,
11322 new_value: &str,
11323 ) -> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C> {
11324 self._datacenter_connector_id = Some(new_value.to_string());
11325 self
11326 }
11327 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11328 /// while executing the actual API request.
11329 ///
11330 /// ````text
11331 /// It should be used to handle progress information, and to implement a certain level of resilience.
11332 /// ````
11333 ///
11334 /// Sets the *delegate* property to the given value.
11335 pub fn delegate(
11336 mut self,
11337 new_value: &'a mut dyn common::Delegate,
11338 ) -> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C> {
11339 self._delegate = Some(new_value);
11340 self
11341 }
11342
11343 /// Set any additional parameter of the query string used in the request.
11344 /// It should be used to set parameters which are not yet available through their own
11345 /// setters.
11346 ///
11347 /// Please note that this method must not be used to set any of the known parameters
11348 /// which have their own setter method. If done anyway, the request will fail.
11349 ///
11350 /// # Additional Parameters
11351 ///
11352 /// * *$.xgafv* (query-string) - V1 error format.
11353 /// * *access_token* (query-string) - OAuth access token.
11354 /// * *alt* (query-string) - Data format for response.
11355 /// * *callback* (query-string) - JSONP
11356 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11357 /// * *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.
11358 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11359 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11360 /// * *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.
11361 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11362 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11363 pub fn param<T>(
11364 mut self,
11365 name: T,
11366 value: T,
11367 ) -> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C>
11368 where
11369 T: AsRef<str>,
11370 {
11371 self._additional_params
11372 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11373 self
11374 }
11375
11376 /// Identifies the authorization scope for the method you are building.
11377 ///
11378 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11379 /// [`Scope::CloudPlatform`].
11380 ///
11381 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11382 /// tokens for more than one scope.
11383 ///
11384 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11385 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11386 /// sufficient, a read-write scope will do as well.
11387 pub fn add_scope<St>(
11388 mut self,
11389 scope: St,
11390 ) -> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C>
11391 where
11392 St: AsRef<str>,
11393 {
11394 self._scopes.insert(String::from(scope.as_ref()));
11395 self
11396 }
11397 /// Identifies the authorization scope(s) for the method you are building.
11398 ///
11399 /// See [`Self::add_scope()`] for details.
11400 pub fn add_scopes<I, St>(
11401 mut self,
11402 scopes: I,
11403 ) -> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C>
11404 where
11405 I: IntoIterator<Item = St>,
11406 St: AsRef<str>,
11407 {
11408 self._scopes
11409 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11410 self
11411 }
11412
11413 /// Removes all scopes, and no default scope will be used either.
11414 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11415 /// for details).
11416 pub fn clear_scopes(mut self) -> ProjectLocationSourceDatacenterConnectorCreateCall<'a, C> {
11417 self._scopes.clear();
11418 self
11419 }
11420}
11421
11422/// Deletes a single DatacenterConnector.
11423///
11424/// A builder for the *locations.sources.datacenterConnectors.delete* method supported by a *project* resource.
11425/// It is not used directly, but through a [`ProjectMethods`] instance.
11426///
11427/// # Example
11428///
11429/// Instantiate a resource method builder
11430///
11431/// ```test_harness,no_run
11432/// # extern crate hyper;
11433/// # extern crate hyper_rustls;
11434/// # extern crate google_vmmigration1 as vmmigration1;
11435/// # async fn dox() {
11436/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11437///
11438/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11439/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11440/// # .with_native_roots()
11441/// # .unwrap()
11442/// # .https_only()
11443/// # .enable_http2()
11444/// # .build();
11445///
11446/// # let executor = hyper_util::rt::TokioExecutor::new();
11447/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11448/// # secret,
11449/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11450/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11451/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11452/// # ),
11453/// # ).build().await.unwrap();
11454///
11455/// # let client = hyper_util::client::legacy::Client::builder(
11456/// # hyper_util::rt::TokioExecutor::new()
11457/// # )
11458/// # .build(
11459/// # hyper_rustls::HttpsConnectorBuilder::new()
11460/// # .with_native_roots()
11461/// # .unwrap()
11462/// # .https_or_http()
11463/// # .enable_http2()
11464/// # .build()
11465/// # );
11466/// # let mut hub = VMMigrationService::new(client, auth);
11467/// // You can configure optional parameters by calling the respective setters at will, and
11468/// // execute the final call using `doit()`.
11469/// // Values shown here are possibly random and not representative !
11470/// let result = hub.projects().locations_sources_datacenter_connectors_delete("name")
11471/// .request_id("amet.")
11472/// .doit().await;
11473/// # }
11474/// ```
11475pub struct ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C>
11476where
11477 C: 'a,
11478{
11479 hub: &'a VMMigrationService<C>,
11480 _name: String,
11481 _request_id: Option<String>,
11482 _delegate: Option<&'a mut dyn common::Delegate>,
11483 _additional_params: HashMap<String, String>,
11484 _scopes: BTreeSet<String>,
11485}
11486
11487impl<'a, C> common::CallBuilder for ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C> {}
11488
11489impl<'a, C> ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C>
11490where
11491 C: common::Connector,
11492{
11493 /// Perform the operation you have build so far.
11494 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11495 use std::borrow::Cow;
11496 use std::io::{Read, Seek};
11497
11498 use common::{url::Params, ToParts};
11499 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11500
11501 let mut dd = common::DefaultDelegate;
11502 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11503 dlg.begin(common::MethodInfo {
11504 id: "vmmigration.projects.locations.sources.datacenterConnectors.delete",
11505 http_method: hyper::Method::DELETE,
11506 });
11507
11508 for &field in ["alt", "name", "requestId"].iter() {
11509 if self._additional_params.contains_key(field) {
11510 dlg.finished(false);
11511 return Err(common::Error::FieldClash(field));
11512 }
11513 }
11514
11515 let mut params = Params::with_capacity(4 + self._additional_params.len());
11516 params.push("name", self._name);
11517 if let Some(value) = self._request_id.as_ref() {
11518 params.push("requestId", value);
11519 }
11520
11521 params.extend(self._additional_params.iter());
11522
11523 params.push("alt", "json");
11524 let mut url = self.hub._base_url.clone() + "v1/{+name}";
11525 if self._scopes.is_empty() {
11526 self._scopes
11527 .insert(Scope::CloudPlatform.as_ref().to_string());
11528 }
11529
11530 #[allow(clippy::single_element_loop)]
11531 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11532 url = params.uri_replacement(url, param_name, find_this, true);
11533 }
11534 {
11535 let to_remove = ["name"];
11536 params.remove_params(&to_remove);
11537 }
11538
11539 let url = params.parse_with_url(&url);
11540
11541 loop {
11542 let token = match self
11543 .hub
11544 .auth
11545 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11546 .await
11547 {
11548 Ok(token) => token,
11549 Err(e) => match dlg.token(e) {
11550 Ok(token) => token,
11551 Err(e) => {
11552 dlg.finished(false);
11553 return Err(common::Error::MissingToken(e));
11554 }
11555 },
11556 };
11557 let mut req_result = {
11558 let client = &self.hub.client;
11559 dlg.pre_request();
11560 let mut req_builder = hyper::Request::builder()
11561 .method(hyper::Method::DELETE)
11562 .uri(url.as_str())
11563 .header(USER_AGENT, self.hub._user_agent.clone());
11564
11565 if let Some(token) = token.as_ref() {
11566 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11567 }
11568
11569 let request = req_builder
11570 .header(CONTENT_LENGTH, 0_u64)
11571 .body(common::to_body::<String>(None));
11572
11573 client.request(request.unwrap()).await
11574 };
11575
11576 match req_result {
11577 Err(err) => {
11578 if let common::Retry::After(d) = dlg.http_error(&err) {
11579 sleep(d).await;
11580 continue;
11581 }
11582 dlg.finished(false);
11583 return Err(common::Error::HttpError(err));
11584 }
11585 Ok(res) => {
11586 let (mut parts, body) = res.into_parts();
11587 let mut body = common::Body::new(body);
11588 if !parts.status.is_success() {
11589 let bytes = common::to_bytes(body).await.unwrap_or_default();
11590 let error = serde_json::from_str(&common::to_string(&bytes));
11591 let response = common::to_response(parts, bytes.into());
11592
11593 if let common::Retry::After(d) =
11594 dlg.http_failure(&response, error.as_ref().ok())
11595 {
11596 sleep(d).await;
11597 continue;
11598 }
11599
11600 dlg.finished(false);
11601
11602 return Err(match error {
11603 Ok(value) => common::Error::BadRequest(value),
11604 _ => common::Error::Failure(response),
11605 });
11606 }
11607 let response = {
11608 let bytes = common::to_bytes(body).await.unwrap_or_default();
11609 let encoded = common::to_string(&bytes);
11610 match serde_json::from_str(&encoded) {
11611 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11612 Err(error) => {
11613 dlg.response_json_decode_error(&encoded, &error);
11614 return Err(common::Error::JsonDecodeError(
11615 encoded.to_string(),
11616 error,
11617 ));
11618 }
11619 }
11620 };
11621
11622 dlg.finished(true);
11623 return Ok(response);
11624 }
11625 }
11626 }
11627 }
11628
11629 /// Required. The DatacenterConnector name.
11630 ///
11631 /// Sets the *name* path property to the given value.
11632 ///
11633 /// Even though the property as already been set when instantiating this call,
11634 /// we provide this method for API completeness.
11635 pub fn name(
11636 mut self,
11637 new_value: &str,
11638 ) -> ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C> {
11639 self._name = new_value.to_string();
11640 self
11641 }
11642 /// 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).
11643 ///
11644 /// Sets the *request id* query property to the given value.
11645 pub fn request_id(
11646 mut self,
11647 new_value: &str,
11648 ) -> ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C> {
11649 self._request_id = Some(new_value.to_string());
11650 self
11651 }
11652 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11653 /// while executing the actual API request.
11654 ///
11655 /// ````text
11656 /// It should be used to handle progress information, and to implement a certain level of resilience.
11657 /// ````
11658 ///
11659 /// Sets the *delegate* property to the given value.
11660 pub fn delegate(
11661 mut self,
11662 new_value: &'a mut dyn common::Delegate,
11663 ) -> ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C> {
11664 self._delegate = Some(new_value);
11665 self
11666 }
11667
11668 /// Set any additional parameter of the query string used in the request.
11669 /// It should be used to set parameters which are not yet available through their own
11670 /// setters.
11671 ///
11672 /// Please note that this method must not be used to set any of the known parameters
11673 /// which have their own setter method. If done anyway, the request will fail.
11674 ///
11675 /// # Additional Parameters
11676 ///
11677 /// * *$.xgafv* (query-string) - V1 error format.
11678 /// * *access_token* (query-string) - OAuth access token.
11679 /// * *alt* (query-string) - Data format for response.
11680 /// * *callback* (query-string) - JSONP
11681 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11682 /// * *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.
11683 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11684 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11685 /// * *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.
11686 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11687 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11688 pub fn param<T>(
11689 mut self,
11690 name: T,
11691 value: T,
11692 ) -> ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C>
11693 where
11694 T: AsRef<str>,
11695 {
11696 self._additional_params
11697 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11698 self
11699 }
11700
11701 /// Identifies the authorization scope for the method you are building.
11702 ///
11703 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11704 /// [`Scope::CloudPlatform`].
11705 ///
11706 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11707 /// tokens for more than one scope.
11708 ///
11709 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11710 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11711 /// sufficient, a read-write scope will do as well.
11712 pub fn add_scope<St>(
11713 mut self,
11714 scope: St,
11715 ) -> ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C>
11716 where
11717 St: AsRef<str>,
11718 {
11719 self._scopes.insert(String::from(scope.as_ref()));
11720 self
11721 }
11722 /// Identifies the authorization scope(s) for the method you are building.
11723 ///
11724 /// See [`Self::add_scope()`] for details.
11725 pub fn add_scopes<I, St>(
11726 mut self,
11727 scopes: I,
11728 ) -> ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C>
11729 where
11730 I: IntoIterator<Item = St>,
11731 St: AsRef<str>,
11732 {
11733 self._scopes
11734 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11735 self
11736 }
11737
11738 /// Removes all scopes, and no default scope will be used either.
11739 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11740 /// for details).
11741 pub fn clear_scopes(mut self) -> ProjectLocationSourceDatacenterConnectorDeleteCall<'a, C> {
11742 self._scopes.clear();
11743 self
11744 }
11745}
11746
11747/// Gets details of a single DatacenterConnector.
11748///
11749/// A builder for the *locations.sources.datacenterConnectors.get* method supported by a *project* resource.
11750/// It is not used directly, but through a [`ProjectMethods`] instance.
11751///
11752/// # Example
11753///
11754/// Instantiate a resource method builder
11755///
11756/// ```test_harness,no_run
11757/// # extern crate hyper;
11758/// # extern crate hyper_rustls;
11759/// # extern crate google_vmmigration1 as vmmigration1;
11760/// # async fn dox() {
11761/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11762///
11763/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11764/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11765/// # .with_native_roots()
11766/// # .unwrap()
11767/// # .https_only()
11768/// # .enable_http2()
11769/// # .build();
11770///
11771/// # let executor = hyper_util::rt::TokioExecutor::new();
11772/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11773/// # secret,
11774/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11775/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11776/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11777/// # ),
11778/// # ).build().await.unwrap();
11779///
11780/// # let client = hyper_util::client::legacy::Client::builder(
11781/// # hyper_util::rt::TokioExecutor::new()
11782/// # )
11783/// # .build(
11784/// # hyper_rustls::HttpsConnectorBuilder::new()
11785/// # .with_native_roots()
11786/// # .unwrap()
11787/// # .https_or_http()
11788/// # .enable_http2()
11789/// # .build()
11790/// # );
11791/// # let mut hub = VMMigrationService::new(client, auth);
11792/// // You can configure optional parameters by calling the respective setters at will, and
11793/// // execute the final call using `doit()`.
11794/// // Values shown here are possibly random and not representative !
11795/// let result = hub.projects().locations_sources_datacenter_connectors_get("name")
11796/// .doit().await;
11797/// # }
11798/// ```
11799pub struct ProjectLocationSourceDatacenterConnectorGetCall<'a, C>
11800where
11801 C: 'a,
11802{
11803 hub: &'a VMMigrationService<C>,
11804 _name: String,
11805 _delegate: Option<&'a mut dyn common::Delegate>,
11806 _additional_params: HashMap<String, String>,
11807 _scopes: BTreeSet<String>,
11808}
11809
11810impl<'a, C> common::CallBuilder for ProjectLocationSourceDatacenterConnectorGetCall<'a, C> {}
11811
11812impl<'a, C> ProjectLocationSourceDatacenterConnectorGetCall<'a, C>
11813where
11814 C: common::Connector,
11815{
11816 /// Perform the operation you have build so far.
11817 pub async fn doit(mut self) -> common::Result<(common::Response, DatacenterConnector)> {
11818 use std::borrow::Cow;
11819 use std::io::{Read, Seek};
11820
11821 use common::{url::Params, ToParts};
11822 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11823
11824 let mut dd = common::DefaultDelegate;
11825 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11826 dlg.begin(common::MethodInfo {
11827 id: "vmmigration.projects.locations.sources.datacenterConnectors.get",
11828 http_method: hyper::Method::GET,
11829 });
11830
11831 for &field in ["alt", "name"].iter() {
11832 if self._additional_params.contains_key(field) {
11833 dlg.finished(false);
11834 return Err(common::Error::FieldClash(field));
11835 }
11836 }
11837
11838 let mut params = Params::with_capacity(3 + self._additional_params.len());
11839 params.push("name", self._name);
11840
11841 params.extend(self._additional_params.iter());
11842
11843 params.push("alt", "json");
11844 let mut url = self.hub._base_url.clone() + "v1/{+name}";
11845 if self._scopes.is_empty() {
11846 self._scopes
11847 .insert(Scope::CloudPlatform.as_ref().to_string());
11848 }
11849
11850 #[allow(clippy::single_element_loop)]
11851 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11852 url = params.uri_replacement(url, param_name, find_this, true);
11853 }
11854 {
11855 let to_remove = ["name"];
11856 params.remove_params(&to_remove);
11857 }
11858
11859 let url = params.parse_with_url(&url);
11860
11861 loop {
11862 let token = match self
11863 .hub
11864 .auth
11865 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11866 .await
11867 {
11868 Ok(token) => token,
11869 Err(e) => match dlg.token(e) {
11870 Ok(token) => token,
11871 Err(e) => {
11872 dlg.finished(false);
11873 return Err(common::Error::MissingToken(e));
11874 }
11875 },
11876 };
11877 let mut req_result = {
11878 let client = &self.hub.client;
11879 dlg.pre_request();
11880 let mut req_builder = hyper::Request::builder()
11881 .method(hyper::Method::GET)
11882 .uri(url.as_str())
11883 .header(USER_AGENT, self.hub._user_agent.clone());
11884
11885 if let Some(token) = token.as_ref() {
11886 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11887 }
11888
11889 let request = req_builder
11890 .header(CONTENT_LENGTH, 0_u64)
11891 .body(common::to_body::<String>(None));
11892
11893 client.request(request.unwrap()).await
11894 };
11895
11896 match req_result {
11897 Err(err) => {
11898 if let common::Retry::After(d) = dlg.http_error(&err) {
11899 sleep(d).await;
11900 continue;
11901 }
11902 dlg.finished(false);
11903 return Err(common::Error::HttpError(err));
11904 }
11905 Ok(res) => {
11906 let (mut parts, body) = res.into_parts();
11907 let mut body = common::Body::new(body);
11908 if !parts.status.is_success() {
11909 let bytes = common::to_bytes(body).await.unwrap_or_default();
11910 let error = serde_json::from_str(&common::to_string(&bytes));
11911 let response = common::to_response(parts, bytes.into());
11912
11913 if let common::Retry::After(d) =
11914 dlg.http_failure(&response, error.as_ref().ok())
11915 {
11916 sleep(d).await;
11917 continue;
11918 }
11919
11920 dlg.finished(false);
11921
11922 return Err(match error {
11923 Ok(value) => common::Error::BadRequest(value),
11924 _ => common::Error::Failure(response),
11925 });
11926 }
11927 let response = {
11928 let bytes = common::to_bytes(body).await.unwrap_or_default();
11929 let encoded = common::to_string(&bytes);
11930 match serde_json::from_str(&encoded) {
11931 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11932 Err(error) => {
11933 dlg.response_json_decode_error(&encoded, &error);
11934 return Err(common::Error::JsonDecodeError(
11935 encoded.to_string(),
11936 error,
11937 ));
11938 }
11939 }
11940 };
11941
11942 dlg.finished(true);
11943 return Ok(response);
11944 }
11945 }
11946 }
11947 }
11948
11949 /// Required. The name of the DatacenterConnector.
11950 ///
11951 /// Sets the *name* path property to the given value.
11952 ///
11953 /// Even though the property as already been set when instantiating this call,
11954 /// we provide this method for API completeness.
11955 pub fn name(
11956 mut self,
11957 new_value: &str,
11958 ) -> ProjectLocationSourceDatacenterConnectorGetCall<'a, C> {
11959 self._name = new_value.to_string();
11960 self
11961 }
11962 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11963 /// while executing the actual API request.
11964 ///
11965 /// ````text
11966 /// It should be used to handle progress information, and to implement a certain level of resilience.
11967 /// ````
11968 ///
11969 /// Sets the *delegate* property to the given value.
11970 pub fn delegate(
11971 mut self,
11972 new_value: &'a mut dyn common::Delegate,
11973 ) -> ProjectLocationSourceDatacenterConnectorGetCall<'a, C> {
11974 self._delegate = Some(new_value);
11975 self
11976 }
11977
11978 /// Set any additional parameter of the query string used in the request.
11979 /// It should be used to set parameters which are not yet available through their own
11980 /// setters.
11981 ///
11982 /// Please note that this method must not be used to set any of the known parameters
11983 /// which have their own setter method. If done anyway, the request will fail.
11984 ///
11985 /// # Additional Parameters
11986 ///
11987 /// * *$.xgafv* (query-string) - V1 error format.
11988 /// * *access_token* (query-string) - OAuth access token.
11989 /// * *alt* (query-string) - Data format for response.
11990 /// * *callback* (query-string) - JSONP
11991 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11992 /// * *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.
11993 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11994 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11995 /// * *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.
11996 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11997 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11998 pub fn param<T>(
11999 mut self,
12000 name: T,
12001 value: T,
12002 ) -> ProjectLocationSourceDatacenterConnectorGetCall<'a, C>
12003 where
12004 T: AsRef<str>,
12005 {
12006 self._additional_params
12007 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12008 self
12009 }
12010
12011 /// Identifies the authorization scope for the method you are building.
12012 ///
12013 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12014 /// [`Scope::CloudPlatform`].
12015 ///
12016 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12017 /// tokens for more than one scope.
12018 ///
12019 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12020 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12021 /// sufficient, a read-write scope will do as well.
12022 pub fn add_scope<St>(
12023 mut self,
12024 scope: St,
12025 ) -> ProjectLocationSourceDatacenterConnectorGetCall<'a, C>
12026 where
12027 St: AsRef<str>,
12028 {
12029 self._scopes.insert(String::from(scope.as_ref()));
12030 self
12031 }
12032 /// Identifies the authorization scope(s) for the method you are building.
12033 ///
12034 /// See [`Self::add_scope()`] for details.
12035 pub fn add_scopes<I, St>(
12036 mut self,
12037 scopes: I,
12038 ) -> ProjectLocationSourceDatacenterConnectorGetCall<'a, C>
12039 where
12040 I: IntoIterator<Item = St>,
12041 St: AsRef<str>,
12042 {
12043 self._scopes
12044 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12045 self
12046 }
12047
12048 /// Removes all scopes, and no default scope will be used either.
12049 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12050 /// for details).
12051 pub fn clear_scopes(mut self) -> ProjectLocationSourceDatacenterConnectorGetCall<'a, C> {
12052 self._scopes.clear();
12053 self
12054 }
12055}
12056
12057/// Lists DatacenterConnectors in a given Source.
12058///
12059/// A builder for the *locations.sources.datacenterConnectors.list* method supported by a *project* resource.
12060/// It is not used directly, but through a [`ProjectMethods`] instance.
12061///
12062/// # Example
12063///
12064/// Instantiate a resource method builder
12065///
12066/// ```test_harness,no_run
12067/// # extern crate hyper;
12068/// # extern crate hyper_rustls;
12069/// # extern crate google_vmmigration1 as vmmigration1;
12070/// # async fn dox() {
12071/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12072///
12073/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12074/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12075/// # .with_native_roots()
12076/// # .unwrap()
12077/// # .https_only()
12078/// # .enable_http2()
12079/// # .build();
12080///
12081/// # let executor = hyper_util::rt::TokioExecutor::new();
12082/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12083/// # secret,
12084/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12085/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12086/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12087/// # ),
12088/// # ).build().await.unwrap();
12089///
12090/// # let client = hyper_util::client::legacy::Client::builder(
12091/// # hyper_util::rt::TokioExecutor::new()
12092/// # )
12093/// # .build(
12094/// # hyper_rustls::HttpsConnectorBuilder::new()
12095/// # .with_native_roots()
12096/// # .unwrap()
12097/// # .https_or_http()
12098/// # .enable_http2()
12099/// # .build()
12100/// # );
12101/// # let mut hub = VMMigrationService::new(client, auth);
12102/// // You can configure optional parameters by calling the respective setters at will, and
12103/// // execute the final call using `doit()`.
12104/// // Values shown here are possibly random and not representative !
12105/// let result = hub.projects().locations_sources_datacenter_connectors_list("parent")
12106/// .page_token("dolor")
12107/// .page_size(-18)
12108/// .order_by("et")
12109/// .filter("sadipscing")
12110/// .doit().await;
12111/// # }
12112/// ```
12113pub struct ProjectLocationSourceDatacenterConnectorListCall<'a, C>
12114where
12115 C: 'a,
12116{
12117 hub: &'a VMMigrationService<C>,
12118 _parent: String,
12119 _page_token: Option<String>,
12120 _page_size: Option<i32>,
12121 _order_by: Option<String>,
12122 _filter: Option<String>,
12123 _delegate: Option<&'a mut dyn common::Delegate>,
12124 _additional_params: HashMap<String, String>,
12125 _scopes: BTreeSet<String>,
12126}
12127
12128impl<'a, C> common::CallBuilder for ProjectLocationSourceDatacenterConnectorListCall<'a, C> {}
12129
12130impl<'a, C> ProjectLocationSourceDatacenterConnectorListCall<'a, C>
12131where
12132 C: common::Connector,
12133{
12134 /// Perform the operation you have build so far.
12135 pub async fn doit(
12136 mut self,
12137 ) -> common::Result<(common::Response, ListDatacenterConnectorsResponse)> {
12138 use std::borrow::Cow;
12139 use std::io::{Read, Seek};
12140
12141 use common::{url::Params, ToParts};
12142 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12143
12144 let mut dd = common::DefaultDelegate;
12145 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12146 dlg.begin(common::MethodInfo {
12147 id: "vmmigration.projects.locations.sources.datacenterConnectors.list",
12148 http_method: hyper::Method::GET,
12149 });
12150
12151 for &field in [
12152 "alt",
12153 "parent",
12154 "pageToken",
12155 "pageSize",
12156 "orderBy",
12157 "filter",
12158 ]
12159 .iter()
12160 {
12161 if self._additional_params.contains_key(field) {
12162 dlg.finished(false);
12163 return Err(common::Error::FieldClash(field));
12164 }
12165 }
12166
12167 let mut params = Params::with_capacity(7 + self._additional_params.len());
12168 params.push("parent", self._parent);
12169 if let Some(value) = self._page_token.as_ref() {
12170 params.push("pageToken", value);
12171 }
12172 if let Some(value) = self._page_size.as_ref() {
12173 params.push("pageSize", value.to_string());
12174 }
12175 if let Some(value) = self._order_by.as_ref() {
12176 params.push("orderBy", value);
12177 }
12178 if let Some(value) = self._filter.as_ref() {
12179 params.push("filter", value);
12180 }
12181
12182 params.extend(self._additional_params.iter());
12183
12184 params.push("alt", "json");
12185 let mut url = self.hub._base_url.clone() + "v1/{+parent}/datacenterConnectors";
12186 if self._scopes.is_empty() {
12187 self._scopes
12188 .insert(Scope::CloudPlatform.as_ref().to_string());
12189 }
12190
12191 #[allow(clippy::single_element_loop)]
12192 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12193 url = params.uri_replacement(url, param_name, find_this, true);
12194 }
12195 {
12196 let to_remove = ["parent"];
12197 params.remove_params(&to_remove);
12198 }
12199
12200 let url = params.parse_with_url(&url);
12201
12202 loop {
12203 let token = match self
12204 .hub
12205 .auth
12206 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12207 .await
12208 {
12209 Ok(token) => token,
12210 Err(e) => match dlg.token(e) {
12211 Ok(token) => token,
12212 Err(e) => {
12213 dlg.finished(false);
12214 return Err(common::Error::MissingToken(e));
12215 }
12216 },
12217 };
12218 let mut req_result = {
12219 let client = &self.hub.client;
12220 dlg.pre_request();
12221 let mut req_builder = hyper::Request::builder()
12222 .method(hyper::Method::GET)
12223 .uri(url.as_str())
12224 .header(USER_AGENT, self.hub._user_agent.clone());
12225
12226 if let Some(token) = token.as_ref() {
12227 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12228 }
12229
12230 let request = req_builder
12231 .header(CONTENT_LENGTH, 0_u64)
12232 .body(common::to_body::<String>(None));
12233
12234 client.request(request.unwrap()).await
12235 };
12236
12237 match req_result {
12238 Err(err) => {
12239 if let common::Retry::After(d) = dlg.http_error(&err) {
12240 sleep(d).await;
12241 continue;
12242 }
12243 dlg.finished(false);
12244 return Err(common::Error::HttpError(err));
12245 }
12246 Ok(res) => {
12247 let (mut parts, body) = res.into_parts();
12248 let mut body = common::Body::new(body);
12249 if !parts.status.is_success() {
12250 let bytes = common::to_bytes(body).await.unwrap_or_default();
12251 let error = serde_json::from_str(&common::to_string(&bytes));
12252 let response = common::to_response(parts, bytes.into());
12253
12254 if let common::Retry::After(d) =
12255 dlg.http_failure(&response, error.as_ref().ok())
12256 {
12257 sleep(d).await;
12258 continue;
12259 }
12260
12261 dlg.finished(false);
12262
12263 return Err(match error {
12264 Ok(value) => common::Error::BadRequest(value),
12265 _ => common::Error::Failure(response),
12266 });
12267 }
12268 let response = {
12269 let bytes = common::to_bytes(body).await.unwrap_or_default();
12270 let encoded = common::to_string(&bytes);
12271 match serde_json::from_str(&encoded) {
12272 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12273 Err(error) => {
12274 dlg.response_json_decode_error(&encoded, &error);
12275 return Err(common::Error::JsonDecodeError(
12276 encoded.to_string(),
12277 error,
12278 ));
12279 }
12280 }
12281 };
12282
12283 dlg.finished(true);
12284 return Ok(response);
12285 }
12286 }
12287 }
12288 }
12289
12290 /// Required. The parent, which owns this collection of connectors.
12291 ///
12292 /// Sets the *parent* path property to the given value.
12293 ///
12294 /// Even though the property as already been set when instantiating this call,
12295 /// we provide this method for API completeness.
12296 pub fn parent(
12297 mut self,
12298 new_value: &str,
12299 ) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C> {
12300 self._parent = new_value.to_string();
12301 self
12302 }
12303 /// 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.
12304 ///
12305 /// Sets the *page token* query property to the given value.
12306 pub fn page_token(
12307 mut self,
12308 new_value: &str,
12309 ) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C> {
12310 self._page_token = Some(new_value.to_string());
12311 self
12312 }
12313 /// 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.
12314 ///
12315 /// Sets the *page size* query property to the given value.
12316 pub fn page_size(
12317 mut self,
12318 new_value: i32,
12319 ) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C> {
12320 self._page_size = Some(new_value);
12321 self
12322 }
12323 /// Optional. the order by fields for the result.
12324 ///
12325 /// Sets the *order by* query property to the given value.
12326 pub fn order_by(
12327 mut self,
12328 new_value: &str,
12329 ) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C> {
12330 self._order_by = Some(new_value.to_string());
12331 self
12332 }
12333 /// Optional. The filter request.
12334 ///
12335 /// Sets the *filter* query property to the given value.
12336 pub fn filter(
12337 mut self,
12338 new_value: &str,
12339 ) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C> {
12340 self._filter = Some(new_value.to_string());
12341 self
12342 }
12343 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12344 /// while executing the actual API request.
12345 ///
12346 /// ````text
12347 /// It should be used to handle progress information, and to implement a certain level of resilience.
12348 /// ````
12349 ///
12350 /// Sets the *delegate* property to the given value.
12351 pub fn delegate(
12352 mut self,
12353 new_value: &'a mut dyn common::Delegate,
12354 ) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C> {
12355 self._delegate = Some(new_value);
12356 self
12357 }
12358
12359 /// Set any additional parameter of the query string used in the request.
12360 /// It should be used to set parameters which are not yet available through their own
12361 /// setters.
12362 ///
12363 /// Please note that this method must not be used to set any of the known parameters
12364 /// which have their own setter method. If done anyway, the request will fail.
12365 ///
12366 /// # Additional Parameters
12367 ///
12368 /// * *$.xgafv* (query-string) - V1 error format.
12369 /// * *access_token* (query-string) - OAuth access token.
12370 /// * *alt* (query-string) - Data format for response.
12371 /// * *callback* (query-string) - JSONP
12372 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12373 /// * *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.
12374 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12375 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12376 /// * *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.
12377 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12378 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12379 pub fn param<T>(
12380 mut self,
12381 name: T,
12382 value: T,
12383 ) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C>
12384 where
12385 T: AsRef<str>,
12386 {
12387 self._additional_params
12388 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12389 self
12390 }
12391
12392 /// Identifies the authorization scope for the method you are building.
12393 ///
12394 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12395 /// [`Scope::CloudPlatform`].
12396 ///
12397 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12398 /// tokens for more than one scope.
12399 ///
12400 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12401 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12402 /// sufficient, a read-write scope will do as well.
12403 pub fn add_scope<St>(
12404 mut self,
12405 scope: St,
12406 ) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C>
12407 where
12408 St: AsRef<str>,
12409 {
12410 self._scopes.insert(String::from(scope.as_ref()));
12411 self
12412 }
12413 /// Identifies the authorization scope(s) for the method you are building.
12414 ///
12415 /// See [`Self::add_scope()`] for details.
12416 pub fn add_scopes<I, St>(
12417 mut self,
12418 scopes: I,
12419 ) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C>
12420 where
12421 I: IntoIterator<Item = St>,
12422 St: AsRef<str>,
12423 {
12424 self._scopes
12425 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12426 self
12427 }
12428
12429 /// Removes all scopes, and no default scope will be used either.
12430 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12431 /// for details).
12432 pub fn clear_scopes(mut self) -> ProjectLocationSourceDatacenterConnectorListCall<'a, C> {
12433 self._scopes.clear();
12434 self
12435 }
12436}
12437
12438/// Upgrades the appliance relate to this DatacenterConnector to the in-place updateable version.
12439///
12440/// A builder for the *locations.sources.datacenterConnectors.upgradeAppliance* method supported by a *project* resource.
12441/// It is not used directly, but through a [`ProjectMethods`] instance.
12442///
12443/// # Example
12444///
12445/// Instantiate a resource method builder
12446///
12447/// ```test_harness,no_run
12448/// # extern crate hyper;
12449/// # extern crate hyper_rustls;
12450/// # extern crate google_vmmigration1 as vmmigration1;
12451/// use vmmigration1::api::UpgradeApplianceRequest;
12452/// # async fn dox() {
12453/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12454///
12455/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12456/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12457/// # .with_native_roots()
12458/// # .unwrap()
12459/// # .https_only()
12460/// # .enable_http2()
12461/// # .build();
12462///
12463/// # let executor = hyper_util::rt::TokioExecutor::new();
12464/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12465/// # secret,
12466/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12467/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12468/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12469/// # ),
12470/// # ).build().await.unwrap();
12471///
12472/// # let client = hyper_util::client::legacy::Client::builder(
12473/// # hyper_util::rt::TokioExecutor::new()
12474/// # )
12475/// # .build(
12476/// # hyper_rustls::HttpsConnectorBuilder::new()
12477/// # .with_native_roots()
12478/// # .unwrap()
12479/// # .https_or_http()
12480/// # .enable_http2()
12481/// # .build()
12482/// # );
12483/// # let mut hub = VMMigrationService::new(client, auth);
12484/// // As the method needs a request, you would usually fill it with the desired information
12485/// // into the respective structure. Some of the parts shown here might not be applicable !
12486/// // Values shown here are possibly random and not representative !
12487/// let mut req = UpgradeApplianceRequest::default();
12488///
12489/// // You can configure optional parameters by calling the respective setters at will, and
12490/// // execute the final call using `doit()`.
12491/// // Values shown here are possibly random and not representative !
12492/// let result = hub.projects().locations_sources_datacenter_connectors_upgrade_appliance(req, "datacenterConnector")
12493/// .doit().await;
12494/// # }
12495/// ```
12496pub struct ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C>
12497where
12498 C: 'a,
12499{
12500 hub: &'a VMMigrationService<C>,
12501 _request: UpgradeApplianceRequest,
12502 _datacenter_connector: String,
12503 _delegate: Option<&'a mut dyn common::Delegate>,
12504 _additional_params: HashMap<String, String>,
12505 _scopes: BTreeSet<String>,
12506}
12507
12508impl<'a, C> common::CallBuilder
12509 for ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C>
12510{
12511}
12512
12513impl<'a, C> ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C>
12514where
12515 C: common::Connector,
12516{
12517 /// Perform the operation you have build so far.
12518 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12519 use std::borrow::Cow;
12520 use std::io::{Read, Seek};
12521
12522 use common::{url::Params, ToParts};
12523 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12524
12525 let mut dd = common::DefaultDelegate;
12526 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12527 dlg.begin(common::MethodInfo {
12528 id: "vmmigration.projects.locations.sources.datacenterConnectors.upgradeAppliance",
12529 http_method: hyper::Method::POST,
12530 });
12531
12532 for &field in ["alt", "datacenterConnector"].iter() {
12533 if self._additional_params.contains_key(field) {
12534 dlg.finished(false);
12535 return Err(common::Error::FieldClash(field));
12536 }
12537 }
12538
12539 let mut params = Params::with_capacity(4 + self._additional_params.len());
12540 params.push("datacenterConnector", self._datacenter_connector);
12541
12542 params.extend(self._additional_params.iter());
12543
12544 params.push("alt", "json");
12545 let mut url = self.hub._base_url.clone() + "v1/{+datacenterConnector}:upgradeAppliance";
12546 if self._scopes.is_empty() {
12547 self._scopes
12548 .insert(Scope::CloudPlatform.as_ref().to_string());
12549 }
12550
12551 #[allow(clippy::single_element_loop)]
12552 for &(find_this, param_name) in [("{+datacenterConnector}", "datacenterConnector")].iter() {
12553 url = params.uri_replacement(url, param_name, find_this, true);
12554 }
12555 {
12556 let to_remove = ["datacenterConnector"];
12557 params.remove_params(&to_remove);
12558 }
12559
12560 let url = params.parse_with_url(&url);
12561
12562 let mut json_mime_type = mime::APPLICATION_JSON;
12563 let mut request_value_reader = {
12564 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12565 common::remove_json_null_values(&mut value);
12566 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12567 serde_json::to_writer(&mut dst, &value).unwrap();
12568 dst
12569 };
12570 let request_size = request_value_reader
12571 .seek(std::io::SeekFrom::End(0))
12572 .unwrap();
12573 request_value_reader
12574 .seek(std::io::SeekFrom::Start(0))
12575 .unwrap();
12576
12577 loop {
12578 let token = match self
12579 .hub
12580 .auth
12581 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12582 .await
12583 {
12584 Ok(token) => token,
12585 Err(e) => match dlg.token(e) {
12586 Ok(token) => token,
12587 Err(e) => {
12588 dlg.finished(false);
12589 return Err(common::Error::MissingToken(e));
12590 }
12591 },
12592 };
12593 request_value_reader
12594 .seek(std::io::SeekFrom::Start(0))
12595 .unwrap();
12596 let mut req_result = {
12597 let client = &self.hub.client;
12598 dlg.pre_request();
12599 let mut req_builder = hyper::Request::builder()
12600 .method(hyper::Method::POST)
12601 .uri(url.as_str())
12602 .header(USER_AGENT, self.hub._user_agent.clone());
12603
12604 if let Some(token) = token.as_ref() {
12605 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12606 }
12607
12608 let request = req_builder
12609 .header(CONTENT_TYPE, json_mime_type.to_string())
12610 .header(CONTENT_LENGTH, request_size as u64)
12611 .body(common::to_body(
12612 request_value_reader.get_ref().clone().into(),
12613 ));
12614
12615 client.request(request.unwrap()).await
12616 };
12617
12618 match req_result {
12619 Err(err) => {
12620 if let common::Retry::After(d) = dlg.http_error(&err) {
12621 sleep(d).await;
12622 continue;
12623 }
12624 dlg.finished(false);
12625 return Err(common::Error::HttpError(err));
12626 }
12627 Ok(res) => {
12628 let (mut parts, body) = res.into_parts();
12629 let mut body = common::Body::new(body);
12630 if !parts.status.is_success() {
12631 let bytes = common::to_bytes(body).await.unwrap_or_default();
12632 let error = serde_json::from_str(&common::to_string(&bytes));
12633 let response = common::to_response(parts, bytes.into());
12634
12635 if let common::Retry::After(d) =
12636 dlg.http_failure(&response, error.as_ref().ok())
12637 {
12638 sleep(d).await;
12639 continue;
12640 }
12641
12642 dlg.finished(false);
12643
12644 return Err(match error {
12645 Ok(value) => common::Error::BadRequest(value),
12646 _ => common::Error::Failure(response),
12647 });
12648 }
12649 let response = {
12650 let bytes = common::to_bytes(body).await.unwrap_or_default();
12651 let encoded = common::to_string(&bytes);
12652 match serde_json::from_str(&encoded) {
12653 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12654 Err(error) => {
12655 dlg.response_json_decode_error(&encoded, &error);
12656 return Err(common::Error::JsonDecodeError(
12657 encoded.to_string(),
12658 error,
12659 ));
12660 }
12661 }
12662 };
12663
12664 dlg.finished(true);
12665 return Ok(response);
12666 }
12667 }
12668 }
12669 }
12670
12671 ///
12672 /// Sets the *request* property to the given value.
12673 ///
12674 /// Even though the property as already been set when instantiating this call,
12675 /// we provide this method for API completeness.
12676 pub fn request(
12677 mut self,
12678 new_value: UpgradeApplianceRequest,
12679 ) -> ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C> {
12680 self._request = new_value;
12681 self
12682 }
12683 /// Required. The DatacenterConnector name.
12684 ///
12685 /// Sets the *datacenter connector* path property to the given value.
12686 ///
12687 /// Even though the property as already been set when instantiating this call,
12688 /// we provide this method for API completeness.
12689 pub fn datacenter_connector(
12690 mut self,
12691 new_value: &str,
12692 ) -> ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C> {
12693 self._datacenter_connector = new_value.to_string();
12694 self
12695 }
12696 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12697 /// while executing the actual API request.
12698 ///
12699 /// ````text
12700 /// It should be used to handle progress information, and to implement a certain level of resilience.
12701 /// ````
12702 ///
12703 /// Sets the *delegate* property to the given value.
12704 pub fn delegate(
12705 mut self,
12706 new_value: &'a mut dyn common::Delegate,
12707 ) -> ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C> {
12708 self._delegate = Some(new_value);
12709 self
12710 }
12711
12712 /// Set any additional parameter of the query string used in the request.
12713 /// It should be used to set parameters which are not yet available through their own
12714 /// setters.
12715 ///
12716 /// Please note that this method must not be used to set any of the known parameters
12717 /// which have their own setter method. If done anyway, the request will fail.
12718 ///
12719 /// # Additional Parameters
12720 ///
12721 /// * *$.xgafv* (query-string) - V1 error format.
12722 /// * *access_token* (query-string) - OAuth access token.
12723 /// * *alt* (query-string) - Data format for response.
12724 /// * *callback* (query-string) - JSONP
12725 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12726 /// * *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.
12727 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12728 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12729 /// * *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.
12730 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12731 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12732 pub fn param<T>(
12733 mut self,
12734 name: T,
12735 value: T,
12736 ) -> ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C>
12737 where
12738 T: AsRef<str>,
12739 {
12740 self._additional_params
12741 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12742 self
12743 }
12744
12745 /// Identifies the authorization scope for the method you are building.
12746 ///
12747 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12748 /// [`Scope::CloudPlatform`].
12749 ///
12750 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12751 /// tokens for more than one scope.
12752 ///
12753 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12754 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12755 /// sufficient, a read-write scope will do as well.
12756 pub fn add_scope<St>(
12757 mut self,
12758 scope: St,
12759 ) -> ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C>
12760 where
12761 St: AsRef<str>,
12762 {
12763 self._scopes.insert(String::from(scope.as_ref()));
12764 self
12765 }
12766 /// Identifies the authorization scope(s) for the method you are building.
12767 ///
12768 /// See [`Self::add_scope()`] for details.
12769 pub fn add_scopes<I, St>(
12770 mut self,
12771 scopes: I,
12772 ) -> ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C>
12773 where
12774 I: IntoIterator<Item = St>,
12775 St: AsRef<str>,
12776 {
12777 self._scopes
12778 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12779 self
12780 }
12781
12782 /// Removes all scopes, and no default scope will be used either.
12783 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12784 /// for details).
12785 pub fn clear_scopes(
12786 mut self,
12787 ) -> ProjectLocationSourceDatacenterConnectorUpgradeApplianceCall<'a, C> {
12788 self._scopes.clear();
12789 self
12790 }
12791}
12792
12793/// Cancels the disk migration job.
12794///
12795/// A builder for the *locations.sources.diskMigrationJobs.cancel* method supported by a *project* resource.
12796/// It is not used directly, but through a [`ProjectMethods`] instance.
12797///
12798/// # Example
12799///
12800/// Instantiate a resource method builder
12801///
12802/// ```test_harness,no_run
12803/// # extern crate hyper;
12804/// # extern crate hyper_rustls;
12805/// # extern crate google_vmmigration1 as vmmigration1;
12806/// use vmmigration1::api::CancelDiskMigrationJobRequest;
12807/// # async fn dox() {
12808/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12809///
12810/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12811/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12812/// # .with_native_roots()
12813/// # .unwrap()
12814/// # .https_only()
12815/// # .enable_http2()
12816/// # .build();
12817///
12818/// # let executor = hyper_util::rt::TokioExecutor::new();
12819/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12820/// # secret,
12821/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12822/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12823/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12824/// # ),
12825/// # ).build().await.unwrap();
12826///
12827/// # let client = hyper_util::client::legacy::Client::builder(
12828/// # hyper_util::rt::TokioExecutor::new()
12829/// # )
12830/// # .build(
12831/// # hyper_rustls::HttpsConnectorBuilder::new()
12832/// # .with_native_roots()
12833/// # .unwrap()
12834/// # .https_or_http()
12835/// # .enable_http2()
12836/// # .build()
12837/// # );
12838/// # let mut hub = VMMigrationService::new(client, auth);
12839/// // As the method needs a request, you would usually fill it with the desired information
12840/// // into the respective structure. Some of the parts shown here might not be applicable !
12841/// // Values shown here are possibly random and not representative !
12842/// let mut req = CancelDiskMigrationJobRequest::default();
12843///
12844/// // You can configure optional parameters by calling the respective setters at will, and
12845/// // execute the final call using `doit()`.
12846/// // Values shown here are possibly random and not representative !
12847/// let result = hub.projects().locations_sources_disk_migration_jobs_cancel(req, "name")
12848/// .doit().await;
12849/// # }
12850/// ```
12851pub struct ProjectLocationSourceDiskMigrationJobCancelCall<'a, C>
12852where
12853 C: 'a,
12854{
12855 hub: &'a VMMigrationService<C>,
12856 _request: CancelDiskMigrationJobRequest,
12857 _name: String,
12858 _delegate: Option<&'a mut dyn common::Delegate>,
12859 _additional_params: HashMap<String, String>,
12860 _scopes: BTreeSet<String>,
12861}
12862
12863impl<'a, C> common::CallBuilder for ProjectLocationSourceDiskMigrationJobCancelCall<'a, C> {}
12864
12865impl<'a, C> ProjectLocationSourceDiskMigrationJobCancelCall<'a, C>
12866where
12867 C: common::Connector,
12868{
12869 /// Perform the operation you have build so far.
12870 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12871 use std::borrow::Cow;
12872 use std::io::{Read, Seek};
12873
12874 use common::{url::Params, ToParts};
12875 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12876
12877 let mut dd = common::DefaultDelegate;
12878 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12879 dlg.begin(common::MethodInfo {
12880 id: "vmmigration.projects.locations.sources.diskMigrationJobs.cancel",
12881 http_method: hyper::Method::POST,
12882 });
12883
12884 for &field in ["alt", "name"].iter() {
12885 if self._additional_params.contains_key(field) {
12886 dlg.finished(false);
12887 return Err(common::Error::FieldClash(field));
12888 }
12889 }
12890
12891 let mut params = Params::with_capacity(4 + self._additional_params.len());
12892 params.push("name", self._name);
12893
12894 params.extend(self._additional_params.iter());
12895
12896 params.push("alt", "json");
12897 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
12898 if self._scopes.is_empty() {
12899 self._scopes
12900 .insert(Scope::CloudPlatform.as_ref().to_string());
12901 }
12902
12903 #[allow(clippy::single_element_loop)]
12904 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12905 url = params.uri_replacement(url, param_name, find_this, true);
12906 }
12907 {
12908 let to_remove = ["name"];
12909 params.remove_params(&to_remove);
12910 }
12911
12912 let url = params.parse_with_url(&url);
12913
12914 let mut json_mime_type = mime::APPLICATION_JSON;
12915 let mut request_value_reader = {
12916 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12917 common::remove_json_null_values(&mut value);
12918 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12919 serde_json::to_writer(&mut dst, &value).unwrap();
12920 dst
12921 };
12922 let request_size = request_value_reader
12923 .seek(std::io::SeekFrom::End(0))
12924 .unwrap();
12925 request_value_reader
12926 .seek(std::io::SeekFrom::Start(0))
12927 .unwrap();
12928
12929 loop {
12930 let token = match self
12931 .hub
12932 .auth
12933 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12934 .await
12935 {
12936 Ok(token) => token,
12937 Err(e) => match dlg.token(e) {
12938 Ok(token) => token,
12939 Err(e) => {
12940 dlg.finished(false);
12941 return Err(common::Error::MissingToken(e));
12942 }
12943 },
12944 };
12945 request_value_reader
12946 .seek(std::io::SeekFrom::Start(0))
12947 .unwrap();
12948 let mut req_result = {
12949 let client = &self.hub.client;
12950 dlg.pre_request();
12951 let mut req_builder = hyper::Request::builder()
12952 .method(hyper::Method::POST)
12953 .uri(url.as_str())
12954 .header(USER_AGENT, self.hub._user_agent.clone());
12955
12956 if let Some(token) = token.as_ref() {
12957 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12958 }
12959
12960 let request = req_builder
12961 .header(CONTENT_TYPE, json_mime_type.to_string())
12962 .header(CONTENT_LENGTH, request_size as u64)
12963 .body(common::to_body(
12964 request_value_reader.get_ref().clone().into(),
12965 ));
12966
12967 client.request(request.unwrap()).await
12968 };
12969
12970 match req_result {
12971 Err(err) => {
12972 if let common::Retry::After(d) = dlg.http_error(&err) {
12973 sleep(d).await;
12974 continue;
12975 }
12976 dlg.finished(false);
12977 return Err(common::Error::HttpError(err));
12978 }
12979 Ok(res) => {
12980 let (mut parts, body) = res.into_parts();
12981 let mut body = common::Body::new(body);
12982 if !parts.status.is_success() {
12983 let bytes = common::to_bytes(body).await.unwrap_or_default();
12984 let error = serde_json::from_str(&common::to_string(&bytes));
12985 let response = common::to_response(parts, bytes.into());
12986
12987 if let common::Retry::After(d) =
12988 dlg.http_failure(&response, error.as_ref().ok())
12989 {
12990 sleep(d).await;
12991 continue;
12992 }
12993
12994 dlg.finished(false);
12995
12996 return Err(match error {
12997 Ok(value) => common::Error::BadRequest(value),
12998 _ => common::Error::Failure(response),
12999 });
13000 }
13001 let response = {
13002 let bytes = common::to_bytes(body).await.unwrap_or_default();
13003 let encoded = common::to_string(&bytes);
13004 match serde_json::from_str(&encoded) {
13005 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13006 Err(error) => {
13007 dlg.response_json_decode_error(&encoded, &error);
13008 return Err(common::Error::JsonDecodeError(
13009 encoded.to_string(),
13010 error,
13011 ));
13012 }
13013 }
13014 };
13015
13016 dlg.finished(true);
13017 return Ok(response);
13018 }
13019 }
13020 }
13021 }
13022
13023 ///
13024 /// Sets the *request* property to the given value.
13025 ///
13026 /// Even though the property as already been set when instantiating this call,
13027 /// we provide this method for API completeness.
13028 pub fn request(
13029 mut self,
13030 new_value: CancelDiskMigrationJobRequest,
13031 ) -> ProjectLocationSourceDiskMigrationJobCancelCall<'a, C> {
13032 self._request = new_value;
13033 self
13034 }
13035 /// Required. The name of the DiskMigrationJob.
13036 ///
13037 /// Sets the *name* path property to the given value.
13038 ///
13039 /// Even though the property as already been set when instantiating this call,
13040 /// we provide this method for API completeness.
13041 pub fn name(
13042 mut self,
13043 new_value: &str,
13044 ) -> ProjectLocationSourceDiskMigrationJobCancelCall<'a, C> {
13045 self._name = new_value.to_string();
13046 self
13047 }
13048 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13049 /// while executing the actual API request.
13050 ///
13051 /// ````text
13052 /// It should be used to handle progress information, and to implement a certain level of resilience.
13053 /// ````
13054 ///
13055 /// Sets the *delegate* property to the given value.
13056 pub fn delegate(
13057 mut self,
13058 new_value: &'a mut dyn common::Delegate,
13059 ) -> ProjectLocationSourceDiskMigrationJobCancelCall<'a, C> {
13060 self._delegate = Some(new_value);
13061 self
13062 }
13063
13064 /// Set any additional parameter of the query string used in the request.
13065 /// It should be used to set parameters which are not yet available through their own
13066 /// setters.
13067 ///
13068 /// Please note that this method must not be used to set any of the known parameters
13069 /// which have their own setter method. If done anyway, the request will fail.
13070 ///
13071 /// # Additional Parameters
13072 ///
13073 /// * *$.xgafv* (query-string) - V1 error format.
13074 /// * *access_token* (query-string) - OAuth access token.
13075 /// * *alt* (query-string) - Data format for response.
13076 /// * *callback* (query-string) - JSONP
13077 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13078 /// * *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.
13079 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13080 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13081 /// * *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.
13082 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13083 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13084 pub fn param<T>(
13085 mut self,
13086 name: T,
13087 value: T,
13088 ) -> ProjectLocationSourceDiskMigrationJobCancelCall<'a, C>
13089 where
13090 T: AsRef<str>,
13091 {
13092 self._additional_params
13093 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13094 self
13095 }
13096
13097 /// Identifies the authorization scope for the method you are building.
13098 ///
13099 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13100 /// [`Scope::CloudPlatform`].
13101 ///
13102 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13103 /// tokens for more than one scope.
13104 ///
13105 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13106 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13107 /// sufficient, a read-write scope will do as well.
13108 pub fn add_scope<St>(
13109 mut self,
13110 scope: St,
13111 ) -> ProjectLocationSourceDiskMigrationJobCancelCall<'a, C>
13112 where
13113 St: AsRef<str>,
13114 {
13115 self._scopes.insert(String::from(scope.as_ref()));
13116 self
13117 }
13118 /// Identifies the authorization scope(s) for the method you are building.
13119 ///
13120 /// See [`Self::add_scope()`] for details.
13121 pub fn add_scopes<I, St>(
13122 mut self,
13123 scopes: I,
13124 ) -> ProjectLocationSourceDiskMigrationJobCancelCall<'a, C>
13125 where
13126 I: IntoIterator<Item = St>,
13127 St: AsRef<str>,
13128 {
13129 self._scopes
13130 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13131 self
13132 }
13133
13134 /// Removes all scopes, and no default scope will be used either.
13135 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13136 /// for details).
13137 pub fn clear_scopes(mut self) -> ProjectLocationSourceDiskMigrationJobCancelCall<'a, C> {
13138 self._scopes.clear();
13139 self
13140 }
13141}
13142
13143/// Creates a new disk migration job in a given Source.
13144///
13145/// A builder for the *locations.sources.diskMigrationJobs.create* method supported by a *project* resource.
13146/// It is not used directly, but through a [`ProjectMethods`] instance.
13147///
13148/// # Example
13149///
13150/// Instantiate a resource method builder
13151///
13152/// ```test_harness,no_run
13153/// # extern crate hyper;
13154/// # extern crate hyper_rustls;
13155/// # extern crate google_vmmigration1 as vmmigration1;
13156/// use vmmigration1::api::DiskMigrationJob;
13157/// # async fn dox() {
13158/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13159///
13160/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13161/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13162/// # .with_native_roots()
13163/// # .unwrap()
13164/// # .https_only()
13165/// # .enable_http2()
13166/// # .build();
13167///
13168/// # let executor = hyper_util::rt::TokioExecutor::new();
13169/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13170/// # secret,
13171/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13172/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13173/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13174/// # ),
13175/// # ).build().await.unwrap();
13176///
13177/// # let client = hyper_util::client::legacy::Client::builder(
13178/// # hyper_util::rt::TokioExecutor::new()
13179/// # )
13180/// # .build(
13181/// # hyper_rustls::HttpsConnectorBuilder::new()
13182/// # .with_native_roots()
13183/// # .unwrap()
13184/// # .https_or_http()
13185/// # .enable_http2()
13186/// # .build()
13187/// # );
13188/// # let mut hub = VMMigrationService::new(client, auth);
13189/// // As the method needs a request, you would usually fill it with the desired information
13190/// // into the respective structure. Some of the parts shown here might not be applicable !
13191/// // Values shown here are possibly random and not representative !
13192/// let mut req = DiskMigrationJob::default();
13193///
13194/// // You can configure optional parameters by calling the respective setters at will, and
13195/// // execute the final call using `doit()`.
13196/// // Values shown here are possibly random and not representative !
13197/// let result = hub.projects().locations_sources_disk_migration_jobs_create(req, "parent")
13198/// .request_id("vero")
13199/// .disk_migration_job_id("vero")
13200/// .doit().await;
13201/// # }
13202/// ```
13203pub struct ProjectLocationSourceDiskMigrationJobCreateCall<'a, C>
13204where
13205 C: 'a,
13206{
13207 hub: &'a VMMigrationService<C>,
13208 _request: DiskMigrationJob,
13209 _parent: String,
13210 _request_id: Option<String>,
13211 _disk_migration_job_id: Option<String>,
13212 _delegate: Option<&'a mut dyn common::Delegate>,
13213 _additional_params: HashMap<String, String>,
13214 _scopes: BTreeSet<String>,
13215}
13216
13217impl<'a, C> common::CallBuilder for ProjectLocationSourceDiskMigrationJobCreateCall<'a, C> {}
13218
13219impl<'a, C> ProjectLocationSourceDiskMigrationJobCreateCall<'a, C>
13220where
13221 C: common::Connector,
13222{
13223 /// Perform the operation you have build so far.
13224 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13225 use std::borrow::Cow;
13226 use std::io::{Read, Seek};
13227
13228 use common::{url::Params, ToParts};
13229 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13230
13231 let mut dd = common::DefaultDelegate;
13232 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13233 dlg.begin(common::MethodInfo {
13234 id: "vmmigration.projects.locations.sources.diskMigrationJobs.create",
13235 http_method: hyper::Method::POST,
13236 });
13237
13238 for &field in ["alt", "parent", "requestId", "diskMigrationJobId"].iter() {
13239 if self._additional_params.contains_key(field) {
13240 dlg.finished(false);
13241 return Err(common::Error::FieldClash(field));
13242 }
13243 }
13244
13245 let mut params = Params::with_capacity(6 + self._additional_params.len());
13246 params.push("parent", self._parent);
13247 if let Some(value) = self._request_id.as_ref() {
13248 params.push("requestId", value);
13249 }
13250 if let Some(value) = self._disk_migration_job_id.as_ref() {
13251 params.push("diskMigrationJobId", value);
13252 }
13253
13254 params.extend(self._additional_params.iter());
13255
13256 params.push("alt", "json");
13257 let mut url = self.hub._base_url.clone() + "v1/{+parent}/diskMigrationJobs";
13258 if self._scopes.is_empty() {
13259 self._scopes
13260 .insert(Scope::CloudPlatform.as_ref().to_string());
13261 }
13262
13263 #[allow(clippy::single_element_loop)]
13264 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13265 url = params.uri_replacement(url, param_name, find_this, true);
13266 }
13267 {
13268 let to_remove = ["parent"];
13269 params.remove_params(&to_remove);
13270 }
13271
13272 let url = params.parse_with_url(&url);
13273
13274 let mut json_mime_type = mime::APPLICATION_JSON;
13275 let mut request_value_reader = {
13276 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13277 common::remove_json_null_values(&mut value);
13278 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13279 serde_json::to_writer(&mut dst, &value).unwrap();
13280 dst
13281 };
13282 let request_size = request_value_reader
13283 .seek(std::io::SeekFrom::End(0))
13284 .unwrap();
13285 request_value_reader
13286 .seek(std::io::SeekFrom::Start(0))
13287 .unwrap();
13288
13289 loop {
13290 let token = match self
13291 .hub
13292 .auth
13293 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13294 .await
13295 {
13296 Ok(token) => token,
13297 Err(e) => match dlg.token(e) {
13298 Ok(token) => token,
13299 Err(e) => {
13300 dlg.finished(false);
13301 return Err(common::Error::MissingToken(e));
13302 }
13303 },
13304 };
13305 request_value_reader
13306 .seek(std::io::SeekFrom::Start(0))
13307 .unwrap();
13308 let mut req_result = {
13309 let client = &self.hub.client;
13310 dlg.pre_request();
13311 let mut req_builder = hyper::Request::builder()
13312 .method(hyper::Method::POST)
13313 .uri(url.as_str())
13314 .header(USER_AGENT, self.hub._user_agent.clone());
13315
13316 if let Some(token) = token.as_ref() {
13317 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13318 }
13319
13320 let request = req_builder
13321 .header(CONTENT_TYPE, json_mime_type.to_string())
13322 .header(CONTENT_LENGTH, request_size as u64)
13323 .body(common::to_body(
13324 request_value_reader.get_ref().clone().into(),
13325 ));
13326
13327 client.request(request.unwrap()).await
13328 };
13329
13330 match req_result {
13331 Err(err) => {
13332 if let common::Retry::After(d) = dlg.http_error(&err) {
13333 sleep(d).await;
13334 continue;
13335 }
13336 dlg.finished(false);
13337 return Err(common::Error::HttpError(err));
13338 }
13339 Ok(res) => {
13340 let (mut parts, body) = res.into_parts();
13341 let mut body = common::Body::new(body);
13342 if !parts.status.is_success() {
13343 let bytes = common::to_bytes(body).await.unwrap_or_default();
13344 let error = serde_json::from_str(&common::to_string(&bytes));
13345 let response = common::to_response(parts, bytes.into());
13346
13347 if let common::Retry::After(d) =
13348 dlg.http_failure(&response, error.as_ref().ok())
13349 {
13350 sleep(d).await;
13351 continue;
13352 }
13353
13354 dlg.finished(false);
13355
13356 return Err(match error {
13357 Ok(value) => common::Error::BadRequest(value),
13358 _ => common::Error::Failure(response),
13359 });
13360 }
13361 let response = {
13362 let bytes = common::to_bytes(body).await.unwrap_or_default();
13363 let encoded = common::to_string(&bytes);
13364 match serde_json::from_str(&encoded) {
13365 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13366 Err(error) => {
13367 dlg.response_json_decode_error(&encoded, &error);
13368 return Err(common::Error::JsonDecodeError(
13369 encoded.to_string(),
13370 error,
13371 ));
13372 }
13373 }
13374 };
13375
13376 dlg.finished(true);
13377 return Ok(response);
13378 }
13379 }
13380 }
13381 }
13382
13383 ///
13384 /// Sets the *request* property to the given value.
13385 ///
13386 /// Even though the property as already been set when instantiating this call,
13387 /// we provide this method for API completeness.
13388 pub fn request(
13389 mut self,
13390 new_value: DiskMigrationJob,
13391 ) -> ProjectLocationSourceDiskMigrationJobCreateCall<'a, C> {
13392 self._request = new_value;
13393 self
13394 }
13395 /// Required. The DiskMigrationJob's parent.
13396 ///
13397 /// Sets the *parent* path property to the given value.
13398 ///
13399 /// Even though the property as already been set when instantiating this call,
13400 /// we provide this method for API completeness.
13401 pub fn parent(
13402 mut self,
13403 new_value: &str,
13404 ) -> ProjectLocationSourceDiskMigrationJobCreateCall<'a, C> {
13405 self._parent = new_value.to_string();
13406 self
13407 }
13408 /// 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 timed 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).
13409 ///
13410 /// Sets the *request id* query property to the given value.
13411 pub fn request_id(
13412 mut self,
13413 new_value: &str,
13414 ) -> ProjectLocationSourceDiskMigrationJobCreateCall<'a, C> {
13415 self._request_id = Some(new_value.to_string());
13416 self
13417 }
13418 /// Required. The DiskMigrationJob identifier. The maximum length of this value is 63 characters. Valid characters are lower case Latin letters, digits and hyphen. It must start with a Latin letter and must not end with a hyphen.
13419 ///
13420 /// Sets the *disk migration job id* query property to the given value.
13421 pub fn disk_migration_job_id(
13422 mut self,
13423 new_value: &str,
13424 ) -> ProjectLocationSourceDiskMigrationJobCreateCall<'a, C> {
13425 self._disk_migration_job_id = Some(new_value.to_string());
13426 self
13427 }
13428 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13429 /// while executing the actual API request.
13430 ///
13431 /// ````text
13432 /// It should be used to handle progress information, and to implement a certain level of resilience.
13433 /// ````
13434 ///
13435 /// Sets the *delegate* property to the given value.
13436 pub fn delegate(
13437 mut self,
13438 new_value: &'a mut dyn common::Delegate,
13439 ) -> ProjectLocationSourceDiskMigrationJobCreateCall<'a, C> {
13440 self._delegate = Some(new_value);
13441 self
13442 }
13443
13444 /// Set any additional parameter of the query string used in the request.
13445 /// It should be used to set parameters which are not yet available through their own
13446 /// setters.
13447 ///
13448 /// Please note that this method must not be used to set any of the known parameters
13449 /// which have their own setter method. If done anyway, the request will fail.
13450 ///
13451 /// # Additional Parameters
13452 ///
13453 /// * *$.xgafv* (query-string) - V1 error format.
13454 /// * *access_token* (query-string) - OAuth access token.
13455 /// * *alt* (query-string) - Data format for response.
13456 /// * *callback* (query-string) - JSONP
13457 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13458 /// * *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.
13459 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13460 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13461 /// * *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.
13462 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13463 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13464 pub fn param<T>(
13465 mut self,
13466 name: T,
13467 value: T,
13468 ) -> ProjectLocationSourceDiskMigrationJobCreateCall<'a, C>
13469 where
13470 T: AsRef<str>,
13471 {
13472 self._additional_params
13473 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13474 self
13475 }
13476
13477 /// Identifies the authorization scope for the method you are building.
13478 ///
13479 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13480 /// [`Scope::CloudPlatform`].
13481 ///
13482 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13483 /// tokens for more than one scope.
13484 ///
13485 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13486 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13487 /// sufficient, a read-write scope will do as well.
13488 pub fn add_scope<St>(
13489 mut self,
13490 scope: St,
13491 ) -> ProjectLocationSourceDiskMigrationJobCreateCall<'a, C>
13492 where
13493 St: AsRef<str>,
13494 {
13495 self._scopes.insert(String::from(scope.as_ref()));
13496 self
13497 }
13498 /// Identifies the authorization scope(s) for the method you are building.
13499 ///
13500 /// See [`Self::add_scope()`] for details.
13501 pub fn add_scopes<I, St>(
13502 mut self,
13503 scopes: I,
13504 ) -> ProjectLocationSourceDiskMigrationJobCreateCall<'a, C>
13505 where
13506 I: IntoIterator<Item = St>,
13507 St: AsRef<str>,
13508 {
13509 self._scopes
13510 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13511 self
13512 }
13513
13514 /// Removes all scopes, and no default scope will be used either.
13515 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13516 /// for details).
13517 pub fn clear_scopes(mut self) -> ProjectLocationSourceDiskMigrationJobCreateCall<'a, C> {
13518 self._scopes.clear();
13519 self
13520 }
13521}
13522
13523/// Deletes a single DiskMigrationJob.
13524///
13525/// A builder for the *locations.sources.diskMigrationJobs.delete* method supported by a *project* resource.
13526/// It is not used directly, but through a [`ProjectMethods`] instance.
13527///
13528/// # Example
13529///
13530/// Instantiate a resource method builder
13531///
13532/// ```test_harness,no_run
13533/// # extern crate hyper;
13534/// # extern crate hyper_rustls;
13535/// # extern crate google_vmmigration1 as vmmigration1;
13536/// # async fn dox() {
13537/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13538///
13539/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13540/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13541/// # .with_native_roots()
13542/// # .unwrap()
13543/// # .https_only()
13544/// # .enable_http2()
13545/// # .build();
13546///
13547/// # let executor = hyper_util::rt::TokioExecutor::new();
13548/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13549/// # secret,
13550/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13551/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13552/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13553/// # ),
13554/// # ).build().await.unwrap();
13555///
13556/// # let client = hyper_util::client::legacy::Client::builder(
13557/// # hyper_util::rt::TokioExecutor::new()
13558/// # )
13559/// # .build(
13560/// # hyper_rustls::HttpsConnectorBuilder::new()
13561/// # .with_native_roots()
13562/// # .unwrap()
13563/// # .https_or_http()
13564/// # .enable_http2()
13565/// # .build()
13566/// # );
13567/// # let mut hub = VMMigrationService::new(client, auth);
13568/// // You can configure optional parameters by calling the respective setters at will, and
13569/// // execute the final call using `doit()`.
13570/// // Values shown here are possibly random and not representative !
13571/// let result = hub.projects().locations_sources_disk_migration_jobs_delete("name")
13572/// .doit().await;
13573/// # }
13574/// ```
13575pub struct ProjectLocationSourceDiskMigrationJobDeleteCall<'a, C>
13576where
13577 C: 'a,
13578{
13579 hub: &'a VMMigrationService<C>,
13580 _name: String,
13581 _delegate: Option<&'a mut dyn common::Delegate>,
13582 _additional_params: HashMap<String, String>,
13583 _scopes: BTreeSet<String>,
13584}
13585
13586impl<'a, C> common::CallBuilder for ProjectLocationSourceDiskMigrationJobDeleteCall<'a, C> {}
13587
13588impl<'a, C> ProjectLocationSourceDiskMigrationJobDeleteCall<'a, C>
13589where
13590 C: common::Connector,
13591{
13592 /// Perform the operation you have build so far.
13593 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13594 use std::borrow::Cow;
13595 use std::io::{Read, Seek};
13596
13597 use common::{url::Params, ToParts};
13598 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13599
13600 let mut dd = common::DefaultDelegate;
13601 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13602 dlg.begin(common::MethodInfo {
13603 id: "vmmigration.projects.locations.sources.diskMigrationJobs.delete",
13604 http_method: hyper::Method::DELETE,
13605 });
13606
13607 for &field in ["alt", "name"].iter() {
13608 if self._additional_params.contains_key(field) {
13609 dlg.finished(false);
13610 return Err(common::Error::FieldClash(field));
13611 }
13612 }
13613
13614 let mut params = Params::with_capacity(3 + self._additional_params.len());
13615 params.push("name", self._name);
13616
13617 params.extend(self._additional_params.iter());
13618
13619 params.push("alt", "json");
13620 let mut url = self.hub._base_url.clone() + "v1/{+name}";
13621 if self._scopes.is_empty() {
13622 self._scopes
13623 .insert(Scope::CloudPlatform.as_ref().to_string());
13624 }
13625
13626 #[allow(clippy::single_element_loop)]
13627 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13628 url = params.uri_replacement(url, param_name, find_this, true);
13629 }
13630 {
13631 let to_remove = ["name"];
13632 params.remove_params(&to_remove);
13633 }
13634
13635 let url = params.parse_with_url(&url);
13636
13637 loop {
13638 let token = match self
13639 .hub
13640 .auth
13641 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13642 .await
13643 {
13644 Ok(token) => token,
13645 Err(e) => match dlg.token(e) {
13646 Ok(token) => token,
13647 Err(e) => {
13648 dlg.finished(false);
13649 return Err(common::Error::MissingToken(e));
13650 }
13651 },
13652 };
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::DELETE)
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_LENGTH, 0_u64)
13667 .body(common::to_body::<String>(None));
13668
13669 client.request(request.unwrap()).await
13670 };
13671
13672 match req_result {
13673 Err(err) => {
13674 if let common::Retry::After(d) = dlg.http_error(&err) {
13675 sleep(d).await;
13676 continue;
13677 }
13678 dlg.finished(false);
13679 return Err(common::Error::HttpError(err));
13680 }
13681 Ok(res) => {
13682 let (mut parts, body) = res.into_parts();
13683 let mut body = common::Body::new(body);
13684 if !parts.status.is_success() {
13685 let bytes = common::to_bytes(body).await.unwrap_or_default();
13686 let error = serde_json::from_str(&common::to_string(&bytes));
13687 let response = common::to_response(parts, bytes.into());
13688
13689 if let common::Retry::After(d) =
13690 dlg.http_failure(&response, error.as_ref().ok())
13691 {
13692 sleep(d).await;
13693 continue;
13694 }
13695
13696 dlg.finished(false);
13697
13698 return Err(match error {
13699 Ok(value) => common::Error::BadRequest(value),
13700 _ => common::Error::Failure(response),
13701 });
13702 }
13703 let response = {
13704 let bytes = common::to_bytes(body).await.unwrap_or_default();
13705 let encoded = common::to_string(&bytes);
13706 match serde_json::from_str(&encoded) {
13707 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13708 Err(error) => {
13709 dlg.response_json_decode_error(&encoded, &error);
13710 return Err(common::Error::JsonDecodeError(
13711 encoded.to_string(),
13712 error,
13713 ));
13714 }
13715 }
13716 };
13717
13718 dlg.finished(true);
13719 return Ok(response);
13720 }
13721 }
13722 }
13723 }
13724
13725 /// Required. The name of the DiskMigrationJob.
13726 ///
13727 /// Sets the *name* path property to the given value.
13728 ///
13729 /// Even though the property as already been set when instantiating this call,
13730 /// we provide this method for API completeness.
13731 pub fn name(
13732 mut self,
13733 new_value: &str,
13734 ) -> ProjectLocationSourceDiskMigrationJobDeleteCall<'a, C> {
13735 self._name = new_value.to_string();
13736 self
13737 }
13738 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13739 /// while executing the actual API request.
13740 ///
13741 /// ````text
13742 /// It should be used to handle progress information, and to implement a certain level of resilience.
13743 /// ````
13744 ///
13745 /// Sets the *delegate* property to the given value.
13746 pub fn delegate(
13747 mut self,
13748 new_value: &'a mut dyn common::Delegate,
13749 ) -> ProjectLocationSourceDiskMigrationJobDeleteCall<'a, C> {
13750 self._delegate = Some(new_value);
13751 self
13752 }
13753
13754 /// Set any additional parameter of the query string used in the request.
13755 /// It should be used to set parameters which are not yet available through their own
13756 /// setters.
13757 ///
13758 /// Please note that this method must not be used to set any of the known parameters
13759 /// which have their own setter method. If done anyway, the request will fail.
13760 ///
13761 /// # Additional Parameters
13762 ///
13763 /// * *$.xgafv* (query-string) - V1 error format.
13764 /// * *access_token* (query-string) - OAuth access token.
13765 /// * *alt* (query-string) - Data format for response.
13766 /// * *callback* (query-string) - JSONP
13767 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13768 /// * *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.
13769 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13770 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13771 /// * *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.
13772 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13773 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13774 pub fn param<T>(
13775 mut self,
13776 name: T,
13777 value: T,
13778 ) -> ProjectLocationSourceDiskMigrationJobDeleteCall<'a, C>
13779 where
13780 T: AsRef<str>,
13781 {
13782 self._additional_params
13783 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13784 self
13785 }
13786
13787 /// Identifies the authorization scope for the method you are building.
13788 ///
13789 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13790 /// [`Scope::CloudPlatform`].
13791 ///
13792 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13793 /// tokens for more than one scope.
13794 ///
13795 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13796 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13797 /// sufficient, a read-write scope will do as well.
13798 pub fn add_scope<St>(
13799 mut self,
13800 scope: St,
13801 ) -> ProjectLocationSourceDiskMigrationJobDeleteCall<'a, C>
13802 where
13803 St: AsRef<str>,
13804 {
13805 self._scopes.insert(String::from(scope.as_ref()));
13806 self
13807 }
13808 /// Identifies the authorization scope(s) for the method you are building.
13809 ///
13810 /// See [`Self::add_scope()`] for details.
13811 pub fn add_scopes<I, St>(
13812 mut self,
13813 scopes: I,
13814 ) -> ProjectLocationSourceDiskMigrationJobDeleteCall<'a, C>
13815 where
13816 I: IntoIterator<Item = St>,
13817 St: AsRef<str>,
13818 {
13819 self._scopes
13820 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13821 self
13822 }
13823
13824 /// Removes all scopes, and no default scope will be used either.
13825 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13826 /// for details).
13827 pub fn clear_scopes(mut self) -> ProjectLocationSourceDiskMigrationJobDeleteCall<'a, C> {
13828 self._scopes.clear();
13829 self
13830 }
13831}
13832
13833/// Gets details of a single DiskMigrationJob.
13834///
13835/// A builder for the *locations.sources.diskMigrationJobs.get* method supported by a *project* resource.
13836/// It is not used directly, but through a [`ProjectMethods`] instance.
13837///
13838/// # Example
13839///
13840/// Instantiate a resource method builder
13841///
13842/// ```test_harness,no_run
13843/// # extern crate hyper;
13844/// # extern crate hyper_rustls;
13845/// # extern crate google_vmmigration1 as vmmigration1;
13846/// # async fn dox() {
13847/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13848///
13849/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13850/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13851/// # .with_native_roots()
13852/// # .unwrap()
13853/// # .https_only()
13854/// # .enable_http2()
13855/// # .build();
13856///
13857/// # let executor = hyper_util::rt::TokioExecutor::new();
13858/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13859/// # secret,
13860/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13861/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13862/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13863/// # ),
13864/// # ).build().await.unwrap();
13865///
13866/// # let client = hyper_util::client::legacy::Client::builder(
13867/// # hyper_util::rt::TokioExecutor::new()
13868/// # )
13869/// # .build(
13870/// # hyper_rustls::HttpsConnectorBuilder::new()
13871/// # .with_native_roots()
13872/// # .unwrap()
13873/// # .https_or_http()
13874/// # .enable_http2()
13875/// # .build()
13876/// # );
13877/// # let mut hub = VMMigrationService::new(client, auth);
13878/// // You can configure optional parameters by calling the respective setters at will, and
13879/// // execute the final call using `doit()`.
13880/// // Values shown here are possibly random and not representative !
13881/// let result = hub.projects().locations_sources_disk_migration_jobs_get("name")
13882/// .doit().await;
13883/// # }
13884/// ```
13885pub struct ProjectLocationSourceDiskMigrationJobGetCall<'a, C>
13886where
13887 C: 'a,
13888{
13889 hub: &'a VMMigrationService<C>,
13890 _name: String,
13891 _delegate: Option<&'a mut dyn common::Delegate>,
13892 _additional_params: HashMap<String, String>,
13893 _scopes: BTreeSet<String>,
13894}
13895
13896impl<'a, C> common::CallBuilder for ProjectLocationSourceDiskMigrationJobGetCall<'a, C> {}
13897
13898impl<'a, C> ProjectLocationSourceDiskMigrationJobGetCall<'a, C>
13899where
13900 C: common::Connector,
13901{
13902 /// Perform the operation you have build so far.
13903 pub async fn doit(mut self) -> common::Result<(common::Response, DiskMigrationJob)> {
13904 use std::borrow::Cow;
13905 use std::io::{Read, Seek};
13906
13907 use common::{url::Params, ToParts};
13908 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13909
13910 let mut dd = common::DefaultDelegate;
13911 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13912 dlg.begin(common::MethodInfo {
13913 id: "vmmigration.projects.locations.sources.diskMigrationJobs.get",
13914 http_method: hyper::Method::GET,
13915 });
13916
13917 for &field in ["alt", "name"].iter() {
13918 if self._additional_params.contains_key(field) {
13919 dlg.finished(false);
13920 return Err(common::Error::FieldClash(field));
13921 }
13922 }
13923
13924 let mut params = Params::with_capacity(3 + self._additional_params.len());
13925 params.push("name", self._name);
13926
13927 params.extend(self._additional_params.iter());
13928
13929 params.push("alt", "json");
13930 let mut url = self.hub._base_url.clone() + "v1/{+name}";
13931 if self._scopes.is_empty() {
13932 self._scopes
13933 .insert(Scope::CloudPlatform.as_ref().to_string());
13934 }
13935
13936 #[allow(clippy::single_element_loop)]
13937 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13938 url = params.uri_replacement(url, param_name, find_this, true);
13939 }
13940 {
13941 let to_remove = ["name"];
13942 params.remove_params(&to_remove);
13943 }
13944
13945 let url = params.parse_with_url(&url);
13946
13947 loop {
13948 let token = match self
13949 .hub
13950 .auth
13951 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13952 .await
13953 {
13954 Ok(token) => token,
13955 Err(e) => match dlg.token(e) {
13956 Ok(token) => token,
13957 Err(e) => {
13958 dlg.finished(false);
13959 return Err(common::Error::MissingToken(e));
13960 }
13961 },
13962 };
13963 let mut req_result = {
13964 let client = &self.hub.client;
13965 dlg.pre_request();
13966 let mut req_builder = hyper::Request::builder()
13967 .method(hyper::Method::GET)
13968 .uri(url.as_str())
13969 .header(USER_AGENT, self.hub._user_agent.clone());
13970
13971 if let Some(token) = token.as_ref() {
13972 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13973 }
13974
13975 let request = req_builder
13976 .header(CONTENT_LENGTH, 0_u64)
13977 .body(common::to_body::<String>(None));
13978
13979 client.request(request.unwrap()).await
13980 };
13981
13982 match req_result {
13983 Err(err) => {
13984 if let common::Retry::After(d) = dlg.http_error(&err) {
13985 sleep(d).await;
13986 continue;
13987 }
13988 dlg.finished(false);
13989 return Err(common::Error::HttpError(err));
13990 }
13991 Ok(res) => {
13992 let (mut parts, body) = res.into_parts();
13993 let mut body = common::Body::new(body);
13994 if !parts.status.is_success() {
13995 let bytes = common::to_bytes(body).await.unwrap_or_default();
13996 let error = serde_json::from_str(&common::to_string(&bytes));
13997 let response = common::to_response(parts, bytes.into());
13998
13999 if let common::Retry::After(d) =
14000 dlg.http_failure(&response, error.as_ref().ok())
14001 {
14002 sleep(d).await;
14003 continue;
14004 }
14005
14006 dlg.finished(false);
14007
14008 return Err(match error {
14009 Ok(value) => common::Error::BadRequest(value),
14010 _ => common::Error::Failure(response),
14011 });
14012 }
14013 let response = {
14014 let bytes = common::to_bytes(body).await.unwrap_or_default();
14015 let encoded = common::to_string(&bytes);
14016 match serde_json::from_str(&encoded) {
14017 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14018 Err(error) => {
14019 dlg.response_json_decode_error(&encoded, &error);
14020 return Err(common::Error::JsonDecodeError(
14021 encoded.to_string(),
14022 error,
14023 ));
14024 }
14025 }
14026 };
14027
14028 dlg.finished(true);
14029 return Ok(response);
14030 }
14031 }
14032 }
14033 }
14034
14035 /// Required. The name of the DiskMigrationJob.
14036 ///
14037 /// Sets the *name* path property to the given value.
14038 ///
14039 /// Even though the property as already been set when instantiating this call,
14040 /// we provide this method for API completeness.
14041 pub fn name(mut self, new_value: &str) -> ProjectLocationSourceDiskMigrationJobGetCall<'a, C> {
14042 self._name = new_value.to_string();
14043 self
14044 }
14045 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14046 /// while executing the actual API request.
14047 ///
14048 /// ````text
14049 /// It should be used to handle progress information, and to implement a certain level of resilience.
14050 /// ````
14051 ///
14052 /// Sets the *delegate* property to the given value.
14053 pub fn delegate(
14054 mut self,
14055 new_value: &'a mut dyn common::Delegate,
14056 ) -> ProjectLocationSourceDiskMigrationJobGetCall<'a, C> {
14057 self._delegate = Some(new_value);
14058 self
14059 }
14060
14061 /// Set any additional parameter of the query string used in the request.
14062 /// It should be used to set parameters which are not yet available through their own
14063 /// setters.
14064 ///
14065 /// Please note that this method must not be used to set any of the known parameters
14066 /// which have their own setter method. If done anyway, the request will fail.
14067 ///
14068 /// # Additional Parameters
14069 ///
14070 /// * *$.xgafv* (query-string) - V1 error format.
14071 /// * *access_token* (query-string) - OAuth access token.
14072 /// * *alt* (query-string) - Data format for response.
14073 /// * *callback* (query-string) - JSONP
14074 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14075 /// * *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.
14076 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14077 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14078 /// * *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.
14079 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14080 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14081 pub fn param<T>(
14082 mut self,
14083 name: T,
14084 value: T,
14085 ) -> ProjectLocationSourceDiskMigrationJobGetCall<'a, C>
14086 where
14087 T: AsRef<str>,
14088 {
14089 self._additional_params
14090 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14091 self
14092 }
14093
14094 /// Identifies the authorization scope for the method you are building.
14095 ///
14096 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14097 /// [`Scope::CloudPlatform`].
14098 ///
14099 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14100 /// tokens for more than one scope.
14101 ///
14102 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14103 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14104 /// sufficient, a read-write scope will do as well.
14105 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceDiskMigrationJobGetCall<'a, C>
14106 where
14107 St: AsRef<str>,
14108 {
14109 self._scopes.insert(String::from(scope.as_ref()));
14110 self
14111 }
14112 /// Identifies the authorization scope(s) for the method you are building.
14113 ///
14114 /// See [`Self::add_scope()`] for details.
14115 pub fn add_scopes<I, St>(
14116 mut self,
14117 scopes: I,
14118 ) -> ProjectLocationSourceDiskMigrationJobGetCall<'a, C>
14119 where
14120 I: IntoIterator<Item = St>,
14121 St: AsRef<str>,
14122 {
14123 self._scopes
14124 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14125 self
14126 }
14127
14128 /// Removes all scopes, and no default scope will be used either.
14129 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14130 /// for details).
14131 pub fn clear_scopes(mut self) -> ProjectLocationSourceDiskMigrationJobGetCall<'a, C> {
14132 self._scopes.clear();
14133 self
14134 }
14135}
14136
14137/// Lists DiskMigrationJobs in a given Source.
14138///
14139/// A builder for the *locations.sources.diskMigrationJobs.list* method supported by a *project* resource.
14140/// It is not used directly, but through a [`ProjectMethods`] instance.
14141///
14142/// # Example
14143///
14144/// Instantiate a resource method builder
14145///
14146/// ```test_harness,no_run
14147/// # extern crate hyper;
14148/// # extern crate hyper_rustls;
14149/// # extern crate google_vmmigration1 as vmmigration1;
14150/// # async fn dox() {
14151/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14152///
14153/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14154/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14155/// # .with_native_roots()
14156/// # .unwrap()
14157/// # .https_only()
14158/// # .enable_http2()
14159/// # .build();
14160///
14161/// # let executor = hyper_util::rt::TokioExecutor::new();
14162/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14163/// # secret,
14164/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14165/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14166/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14167/// # ),
14168/// # ).build().await.unwrap();
14169///
14170/// # let client = hyper_util::client::legacy::Client::builder(
14171/// # hyper_util::rt::TokioExecutor::new()
14172/// # )
14173/// # .build(
14174/// # hyper_rustls::HttpsConnectorBuilder::new()
14175/// # .with_native_roots()
14176/// # .unwrap()
14177/// # .https_or_http()
14178/// # .enable_http2()
14179/// # .build()
14180/// # );
14181/// # let mut hub = VMMigrationService::new(client, auth);
14182/// // You can configure optional parameters by calling the respective setters at will, and
14183/// // execute the final call using `doit()`.
14184/// // Values shown here are possibly random and not representative !
14185/// let result = hub.projects().locations_sources_disk_migration_jobs_list("parent")
14186/// .page_token("elitr")
14187/// .page_size(-6)
14188/// .order_by("diam")
14189/// .filter("no")
14190/// .doit().await;
14191/// # }
14192/// ```
14193pub struct ProjectLocationSourceDiskMigrationJobListCall<'a, C>
14194where
14195 C: 'a,
14196{
14197 hub: &'a VMMigrationService<C>,
14198 _parent: String,
14199 _page_token: Option<String>,
14200 _page_size: Option<i32>,
14201 _order_by: Option<String>,
14202 _filter: Option<String>,
14203 _delegate: Option<&'a mut dyn common::Delegate>,
14204 _additional_params: HashMap<String, String>,
14205 _scopes: BTreeSet<String>,
14206}
14207
14208impl<'a, C> common::CallBuilder for ProjectLocationSourceDiskMigrationJobListCall<'a, C> {}
14209
14210impl<'a, C> ProjectLocationSourceDiskMigrationJobListCall<'a, C>
14211where
14212 C: common::Connector,
14213{
14214 /// Perform the operation you have build so far.
14215 pub async fn doit(
14216 mut self,
14217 ) -> common::Result<(common::Response, ListDiskMigrationJobsResponse)> {
14218 use std::borrow::Cow;
14219 use std::io::{Read, Seek};
14220
14221 use common::{url::Params, ToParts};
14222 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14223
14224 let mut dd = common::DefaultDelegate;
14225 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14226 dlg.begin(common::MethodInfo {
14227 id: "vmmigration.projects.locations.sources.diskMigrationJobs.list",
14228 http_method: hyper::Method::GET,
14229 });
14230
14231 for &field in [
14232 "alt",
14233 "parent",
14234 "pageToken",
14235 "pageSize",
14236 "orderBy",
14237 "filter",
14238 ]
14239 .iter()
14240 {
14241 if self._additional_params.contains_key(field) {
14242 dlg.finished(false);
14243 return Err(common::Error::FieldClash(field));
14244 }
14245 }
14246
14247 let mut params = Params::with_capacity(7 + self._additional_params.len());
14248 params.push("parent", self._parent);
14249 if let Some(value) = self._page_token.as_ref() {
14250 params.push("pageToken", value);
14251 }
14252 if let Some(value) = self._page_size.as_ref() {
14253 params.push("pageSize", value.to_string());
14254 }
14255 if let Some(value) = self._order_by.as_ref() {
14256 params.push("orderBy", value);
14257 }
14258 if let Some(value) = self._filter.as_ref() {
14259 params.push("filter", value);
14260 }
14261
14262 params.extend(self._additional_params.iter());
14263
14264 params.push("alt", "json");
14265 let mut url = self.hub._base_url.clone() + "v1/{+parent}/diskMigrationJobs";
14266 if self._scopes.is_empty() {
14267 self._scopes
14268 .insert(Scope::CloudPlatform.as_ref().to_string());
14269 }
14270
14271 #[allow(clippy::single_element_loop)]
14272 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14273 url = params.uri_replacement(url, param_name, find_this, true);
14274 }
14275 {
14276 let to_remove = ["parent"];
14277 params.remove_params(&to_remove);
14278 }
14279
14280 let url = params.parse_with_url(&url);
14281
14282 loop {
14283 let token = match self
14284 .hub
14285 .auth
14286 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14287 .await
14288 {
14289 Ok(token) => token,
14290 Err(e) => match dlg.token(e) {
14291 Ok(token) => token,
14292 Err(e) => {
14293 dlg.finished(false);
14294 return Err(common::Error::MissingToken(e));
14295 }
14296 },
14297 };
14298 let mut req_result = {
14299 let client = &self.hub.client;
14300 dlg.pre_request();
14301 let mut req_builder = hyper::Request::builder()
14302 .method(hyper::Method::GET)
14303 .uri(url.as_str())
14304 .header(USER_AGENT, self.hub._user_agent.clone());
14305
14306 if let Some(token) = token.as_ref() {
14307 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14308 }
14309
14310 let request = req_builder
14311 .header(CONTENT_LENGTH, 0_u64)
14312 .body(common::to_body::<String>(None));
14313
14314 client.request(request.unwrap()).await
14315 };
14316
14317 match req_result {
14318 Err(err) => {
14319 if let common::Retry::After(d) = dlg.http_error(&err) {
14320 sleep(d).await;
14321 continue;
14322 }
14323 dlg.finished(false);
14324 return Err(common::Error::HttpError(err));
14325 }
14326 Ok(res) => {
14327 let (mut parts, body) = res.into_parts();
14328 let mut body = common::Body::new(body);
14329 if !parts.status.is_success() {
14330 let bytes = common::to_bytes(body).await.unwrap_or_default();
14331 let error = serde_json::from_str(&common::to_string(&bytes));
14332 let response = common::to_response(parts, bytes.into());
14333
14334 if let common::Retry::After(d) =
14335 dlg.http_failure(&response, error.as_ref().ok())
14336 {
14337 sleep(d).await;
14338 continue;
14339 }
14340
14341 dlg.finished(false);
14342
14343 return Err(match error {
14344 Ok(value) => common::Error::BadRequest(value),
14345 _ => common::Error::Failure(response),
14346 });
14347 }
14348 let response = {
14349 let bytes = common::to_bytes(body).await.unwrap_or_default();
14350 let encoded = common::to_string(&bytes);
14351 match serde_json::from_str(&encoded) {
14352 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14353 Err(error) => {
14354 dlg.response_json_decode_error(&encoded, &error);
14355 return Err(common::Error::JsonDecodeError(
14356 encoded.to_string(),
14357 error,
14358 ));
14359 }
14360 }
14361 };
14362
14363 dlg.finished(true);
14364 return Ok(response);
14365 }
14366 }
14367 }
14368 }
14369
14370 /// Required. The parent, which owns this collection of DiskMigrationJobs.
14371 ///
14372 /// Sets the *parent* path property to the given value.
14373 ///
14374 /// Even though the property as already been set when instantiating this call,
14375 /// we provide this method for API completeness.
14376 pub fn parent(
14377 mut self,
14378 new_value: &str,
14379 ) -> ProjectLocationSourceDiskMigrationJobListCall<'a, C> {
14380 self._parent = new_value.to_string();
14381 self
14382 }
14383 /// Optional. A page token, received from a previous `ListDiskMigrationJobs` call. Provide this to retrieve the subsequent page. When paginating, all parameters provided to `ListDiskMigrationJobs` except `page_size` must match the call that provided the page token.
14384 ///
14385 /// Sets the *page token* query property to the given value.
14386 pub fn page_token(
14387 mut self,
14388 new_value: &str,
14389 ) -> ProjectLocationSourceDiskMigrationJobListCall<'a, C> {
14390 self._page_token = Some(new_value.to_string());
14391 self
14392 }
14393 /// Optional. The maximum number of disk migration jobs to return. The service may return fewer than this value. If unspecified, at most 500 disk migration jobs will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
14394 ///
14395 /// Sets the *page size* query property to the given value.
14396 pub fn page_size(
14397 mut self,
14398 new_value: i32,
14399 ) -> ProjectLocationSourceDiskMigrationJobListCall<'a, C> {
14400 self._page_size = Some(new_value);
14401 self
14402 }
14403 /// Optional. Ordering of the result list.
14404 ///
14405 /// Sets the *order by* query property to the given value.
14406 pub fn order_by(
14407 mut self,
14408 new_value: &str,
14409 ) -> ProjectLocationSourceDiskMigrationJobListCall<'a, C> {
14410 self._order_by = Some(new_value.to_string());
14411 self
14412 }
14413 /// Optional. The filter request (according to AIP-160).
14414 ///
14415 /// Sets the *filter* query property to the given value.
14416 pub fn filter(
14417 mut self,
14418 new_value: &str,
14419 ) -> ProjectLocationSourceDiskMigrationJobListCall<'a, C> {
14420 self._filter = Some(new_value.to_string());
14421 self
14422 }
14423 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14424 /// while executing the actual API request.
14425 ///
14426 /// ````text
14427 /// It should be used to handle progress information, and to implement a certain level of resilience.
14428 /// ````
14429 ///
14430 /// Sets the *delegate* property to the given value.
14431 pub fn delegate(
14432 mut self,
14433 new_value: &'a mut dyn common::Delegate,
14434 ) -> ProjectLocationSourceDiskMigrationJobListCall<'a, C> {
14435 self._delegate = Some(new_value);
14436 self
14437 }
14438
14439 /// Set any additional parameter of the query string used in the request.
14440 /// It should be used to set parameters which are not yet available through their own
14441 /// setters.
14442 ///
14443 /// Please note that this method must not be used to set any of the known parameters
14444 /// which have their own setter method. If done anyway, the request will fail.
14445 ///
14446 /// # Additional Parameters
14447 ///
14448 /// * *$.xgafv* (query-string) - V1 error format.
14449 /// * *access_token* (query-string) - OAuth access token.
14450 /// * *alt* (query-string) - Data format for response.
14451 /// * *callback* (query-string) - JSONP
14452 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14453 /// * *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.
14454 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14455 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14456 /// * *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.
14457 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14458 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14459 pub fn param<T>(
14460 mut self,
14461 name: T,
14462 value: T,
14463 ) -> ProjectLocationSourceDiskMigrationJobListCall<'a, C>
14464 where
14465 T: AsRef<str>,
14466 {
14467 self._additional_params
14468 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14469 self
14470 }
14471
14472 /// Identifies the authorization scope for the method you are building.
14473 ///
14474 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14475 /// [`Scope::CloudPlatform`].
14476 ///
14477 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14478 /// tokens for more than one scope.
14479 ///
14480 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14481 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14482 /// sufficient, a read-write scope will do as well.
14483 pub fn add_scope<St>(
14484 mut self,
14485 scope: St,
14486 ) -> ProjectLocationSourceDiskMigrationJobListCall<'a, C>
14487 where
14488 St: AsRef<str>,
14489 {
14490 self._scopes.insert(String::from(scope.as_ref()));
14491 self
14492 }
14493 /// Identifies the authorization scope(s) for the method you are building.
14494 ///
14495 /// See [`Self::add_scope()`] for details.
14496 pub fn add_scopes<I, St>(
14497 mut self,
14498 scopes: I,
14499 ) -> ProjectLocationSourceDiskMigrationJobListCall<'a, C>
14500 where
14501 I: IntoIterator<Item = St>,
14502 St: AsRef<str>,
14503 {
14504 self._scopes
14505 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14506 self
14507 }
14508
14509 /// Removes all scopes, and no default scope will be used either.
14510 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14511 /// for details).
14512 pub fn clear_scopes(mut self) -> ProjectLocationSourceDiskMigrationJobListCall<'a, C> {
14513 self._scopes.clear();
14514 self
14515 }
14516}
14517
14518/// Updates the parameters of a single DiskMigrationJob.
14519///
14520/// A builder for the *locations.sources.diskMigrationJobs.patch* method supported by a *project* resource.
14521/// It is not used directly, but through a [`ProjectMethods`] instance.
14522///
14523/// # Example
14524///
14525/// Instantiate a resource method builder
14526///
14527/// ```test_harness,no_run
14528/// # extern crate hyper;
14529/// # extern crate hyper_rustls;
14530/// # extern crate google_vmmigration1 as vmmigration1;
14531/// use vmmigration1::api::DiskMigrationJob;
14532/// # async fn dox() {
14533/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14534///
14535/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14536/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14537/// # .with_native_roots()
14538/// # .unwrap()
14539/// # .https_only()
14540/// # .enable_http2()
14541/// # .build();
14542///
14543/// # let executor = hyper_util::rt::TokioExecutor::new();
14544/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14545/// # secret,
14546/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14547/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14548/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14549/// # ),
14550/// # ).build().await.unwrap();
14551///
14552/// # let client = hyper_util::client::legacy::Client::builder(
14553/// # hyper_util::rt::TokioExecutor::new()
14554/// # )
14555/// # .build(
14556/// # hyper_rustls::HttpsConnectorBuilder::new()
14557/// # .with_native_roots()
14558/// # .unwrap()
14559/// # .https_or_http()
14560/// # .enable_http2()
14561/// # .build()
14562/// # );
14563/// # let mut hub = VMMigrationService::new(client, auth);
14564/// // As the method needs a request, you would usually fill it with the desired information
14565/// // into the respective structure. Some of the parts shown here might not be applicable !
14566/// // Values shown here are possibly random and not representative !
14567/// let mut req = DiskMigrationJob::default();
14568///
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_disk_migration_jobs_patch(req, "name")
14573/// .update_mask(FieldMask::new::<&str>(&[]))
14574/// .request_id("accusam")
14575/// .doit().await;
14576/// # }
14577/// ```
14578pub struct ProjectLocationSourceDiskMigrationJobPatchCall<'a, C>
14579where
14580 C: 'a,
14581{
14582 hub: &'a VMMigrationService<C>,
14583 _request: DiskMigrationJob,
14584 _name: String,
14585 _update_mask: Option<common::FieldMask>,
14586 _request_id: Option<String>,
14587 _delegate: Option<&'a mut dyn common::Delegate>,
14588 _additional_params: HashMap<String, String>,
14589 _scopes: BTreeSet<String>,
14590}
14591
14592impl<'a, C> common::CallBuilder for ProjectLocationSourceDiskMigrationJobPatchCall<'a, C> {}
14593
14594impl<'a, C> ProjectLocationSourceDiskMigrationJobPatchCall<'a, C>
14595where
14596 C: common::Connector,
14597{
14598 /// Perform the operation you have build so far.
14599 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
14600 use std::borrow::Cow;
14601 use std::io::{Read, Seek};
14602
14603 use common::{url::Params, ToParts};
14604 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14605
14606 let mut dd = common::DefaultDelegate;
14607 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14608 dlg.begin(common::MethodInfo {
14609 id: "vmmigration.projects.locations.sources.diskMigrationJobs.patch",
14610 http_method: hyper::Method::PATCH,
14611 });
14612
14613 for &field in ["alt", "name", "updateMask", "requestId"].iter() {
14614 if self._additional_params.contains_key(field) {
14615 dlg.finished(false);
14616 return Err(common::Error::FieldClash(field));
14617 }
14618 }
14619
14620 let mut params = Params::with_capacity(6 + self._additional_params.len());
14621 params.push("name", self._name);
14622 if let Some(value) = self._update_mask.as_ref() {
14623 params.push("updateMask", value.to_string());
14624 }
14625 if let Some(value) = self._request_id.as_ref() {
14626 params.push("requestId", value);
14627 }
14628
14629 params.extend(self._additional_params.iter());
14630
14631 params.push("alt", "json");
14632 let mut url = self.hub._base_url.clone() + "v1/{+name}";
14633 if self._scopes.is_empty() {
14634 self._scopes
14635 .insert(Scope::CloudPlatform.as_ref().to_string());
14636 }
14637
14638 #[allow(clippy::single_element_loop)]
14639 for &(find_this, param_name) in [("{+name}", "name")].iter() {
14640 url = params.uri_replacement(url, param_name, find_this, true);
14641 }
14642 {
14643 let to_remove = ["name"];
14644 params.remove_params(&to_remove);
14645 }
14646
14647 let url = params.parse_with_url(&url);
14648
14649 let mut json_mime_type = mime::APPLICATION_JSON;
14650 let mut request_value_reader = {
14651 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14652 common::remove_json_null_values(&mut value);
14653 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14654 serde_json::to_writer(&mut dst, &value).unwrap();
14655 dst
14656 };
14657 let request_size = request_value_reader
14658 .seek(std::io::SeekFrom::End(0))
14659 .unwrap();
14660 request_value_reader
14661 .seek(std::io::SeekFrom::Start(0))
14662 .unwrap();
14663
14664 loop {
14665 let token = match self
14666 .hub
14667 .auth
14668 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14669 .await
14670 {
14671 Ok(token) => token,
14672 Err(e) => match dlg.token(e) {
14673 Ok(token) => token,
14674 Err(e) => {
14675 dlg.finished(false);
14676 return Err(common::Error::MissingToken(e));
14677 }
14678 },
14679 };
14680 request_value_reader
14681 .seek(std::io::SeekFrom::Start(0))
14682 .unwrap();
14683 let mut req_result = {
14684 let client = &self.hub.client;
14685 dlg.pre_request();
14686 let mut req_builder = hyper::Request::builder()
14687 .method(hyper::Method::PATCH)
14688 .uri(url.as_str())
14689 .header(USER_AGENT, self.hub._user_agent.clone());
14690
14691 if let Some(token) = token.as_ref() {
14692 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14693 }
14694
14695 let request = req_builder
14696 .header(CONTENT_TYPE, json_mime_type.to_string())
14697 .header(CONTENT_LENGTH, request_size as u64)
14698 .body(common::to_body(
14699 request_value_reader.get_ref().clone().into(),
14700 ));
14701
14702 client.request(request.unwrap()).await
14703 };
14704
14705 match req_result {
14706 Err(err) => {
14707 if let common::Retry::After(d) = dlg.http_error(&err) {
14708 sleep(d).await;
14709 continue;
14710 }
14711 dlg.finished(false);
14712 return Err(common::Error::HttpError(err));
14713 }
14714 Ok(res) => {
14715 let (mut parts, body) = res.into_parts();
14716 let mut body = common::Body::new(body);
14717 if !parts.status.is_success() {
14718 let bytes = common::to_bytes(body).await.unwrap_or_default();
14719 let error = serde_json::from_str(&common::to_string(&bytes));
14720 let response = common::to_response(parts, bytes.into());
14721
14722 if let common::Retry::After(d) =
14723 dlg.http_failure(&response, error.as_ref().ok())
14724 {
14725 sleep(d).await;
14726 continue;
14727 }
14728
14729 dlg.finished(false);
14730
14731 return Err(match error {
14732 Ok(value) => common::Error::BadRequest(value),
14733 _ => common::Error::Failure(response),
14734 });
14735 }
14736 let response = {
14737 let bytes = common::to_bytes(body).await.unwrap_or_default();
14738 let encoded = common::to_string(&bytes);
14739 match serde_json::from_str(&encoded) {
14740 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14741 Err(error) => {
14742 dlg.response_json_decode_error(&encoded, &error);
14743 return Err(common::Error::JsonDecodeError(
14744 encoded.to_string(),
14745 error,
14746 ));
14747 }
14748 }
14749 };
14750
14751 dlg.finished(true);
14752 return Ok(response);
14753 }
14754 }
14755 }
14756 }
14757
14758 ///
14759 /// Sets the *request* property to the given value.
14760 ///
14761 /// Even though the property as already been set when instantiating this call,
14762 /// we provide this method for API completeness.
14763 pub fn request(
14764 mut self,
14765 new_value: DiskMigrationJob,
14766 ) -> ProjectLocationSourceDiskMigrationJobPatchCall<'a, C> {
14767 self._request = new_value;
14768 self
14769 }
14770 /// Output only. Identifier. The identifier of the DiskMigrationJob.
14771 ///
14772 /// Sets the *name* path property to the given value.
14773 ///
14774 /// Even though the property as already been set when instantiating this call,
14775 /// we provide this method for API completeness.
14776 pub fn name(
14777 mut self,
14778 new_value: &str,
14779 ) -> ProjectLocationSourceDiskMigrationJobPatchCall<'a, C> {
14780 self._name = new_value.to_string();
14781 self
14782 }
14783 /// Optional. Field mask is used to specify the fields to be overwritten in the DiskMigrationJob 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 a mask equivalent to all fields that are populated (have a non-empty value), will be implied.
14784 ///
14785 /// Sets the *update mask* query property to the given value.
14786 pub fn update_mask(
14787 mut self,
14788 new_value: common::FieldMask,
14789 ) -> ProjectLocationSourceDiskMigrationJobPatchCall<'a, C> {
14790 self._update_mask = Some(new_value);
14791 self
14792 }
14793 /// 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 timed 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).
14794 ///
14795 /// Sets the *request id* query property to the given value.
14796 pub fn request_id(
14797 mut self,
14798 new_value: &str,
14799 ) -> ProjectLocationSourceDiskMigrationJobPatchCall<'a, C> {
14800 self._request_id = Some(new_value.to_string());
14801 self
14802 }
14803 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14804 /// while executing the actual API request.
14805 ///
14806 /// ````text
14807 /// It should be used to handle progress information, and to implement a certain level of resilience.
14808 /// ````
14809 ///
14810 /// Sets the *delegate* property to the given value.
14811 pub fn delegate(
14812 mut self,
14813 new_value: &'a mut dyn common::Delegate,
14814 ) -> ProjectLocationSourceDiskMigrationJobPatchCall<'a, C> {
14815 self._delegate = Some(new_value);
14816 self
14817 }
14818
14819 /// Set any additional parameter of the query string used in the request.
14820 /// It should be used to set parameters which are not yet available through their own
14821 /// setters.
14822 ///
14823 /// Please note that this method must not be used to set any of the known parameters
14824 /// which have their own setter method. If done anyway, the request will fail.
14825 ///
14826 /// # Additional Parameters
14827 ///
14828 /// * *$.xgafv* (query-string) - V1 error format.
14829 /// * *access_token* (query-string) - OAuth access token.
14830 /// * *alt* (query-string) - Data format for response.
14831 /// * *callback* (query-string) - JSONP
14832 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14833 /// * *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.
14834 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14835 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14836 /// * *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.
14837 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14838 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14839 pub fn param<T>(
14840 mut self,
14841 name: T,
14842 value: T,
14843 ) -> ProjectLocationSourceDiskMigrationJobPatchCall<'a, C>
14844 where
14845 T: AsRef<str>,
14846 {
14847 self._additional_params
14848 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14849 self
14850 }
14851
14852 /// Identifies the authorization scope for the method you are building.
14853 ///
14854 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14855 /// [`Scope::CloudPlatform`].
14856 ///
14857 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14858 /// tokens for more than one scope.
14859 ///
14860 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14861 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14862 /// sufficient, a read-write scope will do as well.
14863 pub fn add_scope<St>(
14864 mut self,
14865 scope: St,
14866 ) -> ProjectLocationSourceDiskMigrationJobPatchCall<'a, C>
14867 where
14868 St: AsRef<str>,
14869 {
14870 self._scopes.insert(String::from(scope.as_ref()));
14871 self
14872 }
14873 /// Identifies the authorization scope(s) for the method you are building.
14874 ///
14875 /// See [`Self::add_scope()`] for details.
14876 pub fn add_scopes<I, St>(
14877 mut self,
14878 scopes: I,
14879 ) -> ProjectLocationSourceDiskMigrationJobPatchCall<'a, C>
14880 where
14881 I: IntoIterator<Item = St>,
14882 St: AsRef<str>,
14883 {
14884 self._scopes
14885 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14886 self
14887 }
14888
14889 /// Removes all scopes, and no default scope will be used either.
14890 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14891 /// for details).
14892 pub fn clear_scopes(mut self) -> ProjectLocationSourceDiskMigrationJobPatchCall<'a, C> {
14893 self._scopes.clear();
14894 self
14895 }
14896}
14897
14898/// Runs the disk migration job.
14899///
14900/// A builder for the *locations.sources.diskMigrationJobs.run* method supported by a *project* resource.
14901/// It is not used directly, but through a [`ProjectMethods`] instance.
14902///
14903/// # Example
14904///
14905/// Instantiate a resource method builder
14906///
14907/// ```test_harness,no_run
14908/// # extern crate hyper;
14909/// # extern crate hyper_rustls;
14910/// # extern crate google_vmmigration1 as vmmigration1;
14911/// use vmmigration1::api::RunDiskMigrationJobRequest;
14912/// # async fn dox() {
14913/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14914///
14915/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14916/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14917/// # .with_native_roots()
14918/// # .unwrap()
14919/// # .https_only()
14920/// # .enable_http2()
14921/// # .build();
14922///
14923/// # let executor = hyper_util::rt::TokioExecutor::new();
14924/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14925/// # secret,
14926/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14927/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14928/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14929/// # ),
14930/// # ).build().await.unwrap();
14931///
14932/// # let client = hyper_util::client::legacy::Client::builder(
14933/// # hyper_util::rt::TokioExecutor::new()
14934/// # )
14935/// # .build(
14936/// # hyper_rustls::HttpsConnectorBuilder::new()
14937/// # .with_native_roots()
14938/// # .unwrap()
14939/// # .https_or_http()
14940/// # .enable_http2()
14941/// # .build()
14942/// # );
14943/// # let mut hub = VMMigrationService::new(client, auth);
14944/// // As the method needs a request, you would usually fill it with the desired information
14945/// // into the respective structure. Some of the parts shown here might not be applicable !
14946/// // Values shown here are possibly random and not representative !
14947/// let mut req = RunDiskMigrationJobRequest::default();
14948///
14949/// // You can configure optional parameters by calling the respective setters at will, and
14950/// // execute the final call using `doit()`.
14951/// // Values shown here are possibly random and not representative !
14952/// let result = hub.projects().locations_sources_disk_migration_jobs_run(req, "name")
14953/// .doit().await;
14954/// # }
14955/// ```
14956pub struct ProjectLocationSourceDiskMigrationJobRunCall<'a, C>
14957where
14958 C: 'a,
14959{
14960 hub: &'a VMMigrationService<C>,
14961 _request: RunDiskMigrationJobRequest,
14962 _name: String,
14963 _delegate: Option<&'a mut dyn common::Delegate>,
14964 _additional_params: HashMap<String, String>,
14965 _scopes: BTreeSet<String>,
14966}
14967
14968impl<'a, C> common::CallBuilder for ProjectLocationSourceDiskMigrationJobRunCall<'a, C> {}
14969
14970impl<'a, C> ProjectLocationSourceDiskMigrationJobRunCall<'a, C>
14971where
14972 C: common::Connector,
14973{
14974 /// Perform the operation you have build so far.
14975 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
14976 use std::borrow::Cow;
14977 use std::io::{Read, Seek};
14978
14979 use common::{url::Params, ToParts};
14980 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14981
14982 let mut dd = common::DefaultDelegate;
14983 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14984 dlg.begin(common::MethodInfo {
14985 id: "vmmigration.projects.locations.sources.diskMigrationJobs.run",
14986 http_method: hyper::Method::POST,
14987 });
14988
14989 for &field in ["alt", "name"].iter() {
14990 if self._additional_params.contains_key(field) {
14991 dlg.finished(false);
14992 return Err(common::Error::FieldClash(field));
14993 }
14994 }
14995
14996 let mut params = Params::with_capacity(4 + self._additional_params.len());
14997 params.push("name", self._name);
14998
14999 params.extend(self._additional_params.iter());
15000
15001 params.push("alt", "json");
15002 let mut url = self.hub._base_url.clone() + "v1/{+name}:run";
15003 if self._scopes.is_empty() {
15004 self._scopes
15005 .insert(Scope::CloudPlatform.as_ref().to_string());
15006 }
15007
15008 #[allow(clippy::single_element_loop)]
15009 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15010 url = params.uri_replacement(url, param_name, find_this, true);
15011 }
15012 {
15013 let to_remove = ["name"];
15014 params.remove_params(&to_remove);
15015 }
15016
15017 let url = params.parse_with_url(&url);
15018
15019 let mut json_mime_type = mime::APPLICATION_JSON;
15020 let mut request_value_reader = {
15021 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15022 common::remove_json_null_values(&mut value);
15023 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15024 serde_json::to_writer(&mut dst, &value).unwrap();
15025 dst
15026 };
15027 let request_size = request_value_reader
15028 .seek(std::io::SeekFrom::End(0))
15029 .unwrap();
15030 request_value_reader
15031 .seek(std::io::SeekFrom::Start(0))
15032 .unwrap();
15033
15034 loop {
15035 let token = match self
15036 .hub
15037 .auth
15038 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15039 .await
15040 {
15041 Ok(token) => token,
15042 Err(e) => match dlg.token(e) {
15043 Ok(token) => token,
15044 Err(e) => {
15045 dlg.finished(false);
15046 return Err(common::Error::MissingToken(e));
15047 }
15048 },
15049 };
15050 request_value_reader
15051 .seek(std::io::SeekFrom::Start(0))
15052 .unwrap();
15053 let mut req_result = {
15054 let client = &self.hub.client;
15055 dlg.pre_request();
15056 let mut req_builder = hyper::Request::builder()
15057 .method(hyper::Method::POST)
15058 .uri(url.as_str())
15059 .header(USER_AGENT, self.hub._user_agent.clone());
15060
15061 if let Some(token) = token.as_ref() {
15062 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15063 }
15064
15065 let request = req_builder
15066 .header(CONTENT_TYPE, json_mime_type.to_string())
15067 .header(CONTENT_LENGTH, request_size as u64)
15068 .body(common::to_body(
15069 request_value_reader.get_ref().clone().into(),
15070 ));
15071
15072 client.request(request.unwrap()).await
15073 };
15074
15075 match req_result {
15076 Err(err) => {
15077 if let common::Retry::After(d) = dlg.http_error(&err) {
15078 sleep(d).await;
15079 continue;
15080 }
15081 dlg.finished(false);
15082 return Err(common::Error::HttpError(err));
15083 }
15084 Ok(res) => {
15085 let (mut parts, body) = res.into_parts();
15086 let mut body = common::Body::new(body);
15087 if !parts.status.is_success() {
15088 let bytes = common::to_bytes(body).await.unwrap_or_default();
15089 let error = serde_json::from_str(&common::to_string(&bytes));
15090 let response = common::to_response(parts, bytes.into());
15091
15092 if let common::Retry::After(d) =
15093 dlg.http_failure(&response, error.as_ref().ok())
15094 {
15095 sleep(d).await;
15096 continue;
15097 }
15098
15099 dlg.finished(false);
15100
15101 return Err(match error {
15102 Ok(value) => common::Error::BadRequest(value),
15103 _ => common::Error::Failure(response),
15104 });
15105 }
15106 let response = {
15107 let bytes = common::to_bytes(body).await.unwrap_or_default();
15108 let encoded = common::to_string(&bytes);
15109 match serde_json::from_str(&encoded) {
15110 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15111 Err(error) => {
15112 dlg.response_json_decode_error(&encoded, &error);
15113 return Err(common::Error::JsonDecodeError(
15114 encoded.to_string(),
15115 error,
15116 ));
15117 }
15118 }
15119 };
15120
15121 dlg.finished(true);
15122 return Ok(response);
15123 }
15124 }
15125 }
15126 }
15127
15128 ///
15129 /// Sets the *request* property to the given value.
15130 ///
15131 /// Even though the property as already been set when instantiating this call,
15132 /// we provide this method for API completeness.
15133 pub fn request(
15134 mut self,
15135 new_value: RunDiskMigrationJobRequest,
15136 ) -> ProjectLocationSourceDiskMigrationJobRunCall<'a, C> {
15137 self._request = new_value;
15138 self
15139 }
15140 /// Required. The name of the DiskMigrationJob.
15141 ///
15142 /// Sets the *name* path property to the given value.
15143 ///
15144 /// Even though the property as already been set when instantiating this call,
15145 /// we provide this method for API completeness.
15146 pub fn name(mut self, new_value: &str) -> ProjectLocationSourceDiskMigrationJobRunCall<'a, C> {
15147 self._name = new_value.to_string();
15148 self
15149 }
15150 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15151 /// while executing the actual API request.
15152 ///
15153 /// ````text
15154 /// It should be used to handle progress information, and to implement a certain level of resilience.
15155 /// ````
15156 ///
15157 /// Sets the *delegate* property to the given value.
15158 pub fn delegate(
15159 mut self,
15160 new_value: &'a mut dyn common::Delegate,
15161 ) -> ProjectLocationSourceDiskMigrationJobRunCall<'a, C> {
15162 self._delegate = Some(new_value);
15163 self
15164 }
15165
15166 /// Set any additional parameter of the query string used in the request.
15167 /// It should be used to set parameters which are not yet available through their own
15168 /// setters.
15169 ///
15170 /// Please note that this method must not be used to set any of the known parameters
15171 /// which have their own setter method. If done anyway, the request will fail.
15172 ///
15173 /// # Additional Parameters
15174 ///
15175 /// * *$.xgafv* (query-string) - V1 error format.
15176 /// * *access_token* (query-string) - OAuth access token.
15177 /// * *alt* (query-string) - Data format for response.
15178 /// * *callback* (query-string) - JSONP
15179 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15180 /// * *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.
15181 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15182 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15183 /// * *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.
15184 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15185 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15186 pub fn param<T>(
15187 mut self,
15188 name: T,
15189 value: T,
15190 ) -> ProjectLocationSourceDiskMigrationJobRunCall<'a, C>
15191 where
15192 T: AsRef<str>,
15193 {
15194 self._additional_params
15195 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15196 self
15197 }
15198
15199 /// Identifies the authorization scope for the method you are building.
15200 ///
15201 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15202 /// [`Scope::CloudPlatform`].
15203 ///
15204 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15205 /// tokens for more than one scope.
15206 ///
15207 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15208 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15209 /// sufficient, a read-write scope will do as well.
15210 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceDiskMigrationJobRunCall<'a, C>
15211 where
15212 St: AsRef<str>,
15213 {
15214 self._scopes.insert(String::from(scope.as_ref()));
15215 self
15216 }
15217 /// Identifies the authorization scope(s) for the method you are building.
15218 ///
15219 /// See [`Self::add_scope()`] for details.
15220 pub fn add_scopes<I, St>(
15221 mut self,
15222 scopes: I,
15223 ) -> ProjectLocationSourceDiskMigrationJobRunCall<'a, C>
15224 where
15225 I: IntoIterator<Item = St>,
15226 St: AsRef<str>,
15227 {
15228 self._scopes
15229 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15230 self
15231 }
15232
15233 /// Removes all scopes, and no default scope will be used either.
15234 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15235 /// for details).
15236 pub fn clear_scopes(mut self) -> ProjectLocationSourceDiskMigrationJobRunCall<'a, C> {
15237 self._scopes.clear();
15238 self
15239 }
15240}
15241
15242/// Initiates the cancellation of a running clone job.
15243///
15244/// A builder for the *locations.sources.migratingVms.cloneJobs.cancel* method supported by a *project* resource.
15245/// It is not used directly, but through a [`ProjectMethods`] instance.
15246///
15247/// # Example
15248///
15249/// Instantiate a resource method builder
15250///
15251/// ```test_harness,no_run
15252/// # extern crate hyper;
15253/// # extern crate hyper_rustls;
15254/// # extern crate google_vmmigration1 as vmmigration1;
15255/// use vmmigration1::api::CancelCloneJobRequest;
15256/// # async fn dox() {
15257/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15258///
15259/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15260/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15261/// # .with_native_roots()
15262/// # .unwrap()
15263/// # .https_only()
15264/// # .enable_http2()
15265/// # .build();
15266///
15267/// # let executor = hyper_util::rt::TokioExecutor::new();
15268/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15269/// # secret,
15270/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15271/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15272/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15273/// # ),
15274/// # ).build().await.unwrap();
15275///
15276/// # let client = hyper_util::client::legacy::Client::builder(
15277/// # hyper_util::rt::TokioExecutor::new()
15278/// # )
15279/// # .build(
15280/// # hyper_rustls::HttpsConnectorBuilder::new()
15281/// # .with_native_roots()
15282/// # .unwrap()
15283/// # .https_or_http()
15284/// # .enable_http2()
15285/// # .build()
15286/// # );
15287/// # let mut hub = VMMigrationService::new(client, auth);
15288/// // As the method needs a request, you would usually fill it with the desired information
15289/// // into the respective structure. Some of the parts shown here might not be applicable !
15290/// // Values shown here are possibly random and not representative !
15291/// let mut req = CancelCloneJobRequest::default();
15292///
15293/// // You can configure optional parameters by calling the respective setters at will, and
15294/// // execute the final call using `doit()`.
15295/// // Values shown here are possibly random and not representative !
15296/// let result = hub.projects().locations_sources_migrating_vms_clone_jobs_cancel(req, "name")
15297/// .doit().await;
15298/// # }
15299/// ```
15300pub struct ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C>
15301where
15302 C: 'a,
15303{
15304 hub: &'a VMMigrationService<C>,
15305 _request: CancelCloneJobRequest,
15306 _name: String,
15307 _delegate: Option<&'a mut dyn common::Delegate>,
15308 _additional_params: HashMap<String, String>,
15309 _scopes: BTreeSet<String>,
15310}
15311
15312impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C> {}
15313
15314impl<'a, C> ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C>
15315where
15316 C: common::Connector,
15317{
15318 /// Perform the operation you have build so far.
15319 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15320 use std::borrow::Cow;
15321 use std::io::{Read, Seek};
15322
15323 use common::{url::Params, ToParts};
15324 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15325
15326 let mut dd = common::DefaultDelegate;
15327 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15328 dlg.begin(common::MethodInfo {
15329 id: "vmmigration.projects.locations.sources.migratingVms.cloneJobs.cancel",
15330 http_method: hyper::Method::POST,
15331 });
15332
15333 for &field in ["alt", "name"].iter() {
15334 if self._additional_params.contains_key(field) {
15335 dlg.finished(false);
15336 return Err(common::Error::FieldClash(field));
15337 }
15338 }
15339
15340 let mut params = Params::with_capacity(4 + self._additional_params.len());
15341 params.push("name", self._name);
15342
15343 params.extend(self._additional_params.iter());
15344
15345 params.push("alt", "json");
15346 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
15347 if self._scopes.is_empty() {
15348 self._scopes
15349 .insert(Scope::CloudPlatform.as_ref().to_string());
15350 }
15351
15352 #[allow(clippy::single_element_loop)]
15353 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15354 url = params.uri_replacement(url, param_name, find_this, true);
15355 }
15356 {
15357 let to_remove = ["name"];
15358 params.remove_params(&to_remove);
15359 }
15360
15361 let url = params.parse_with_url(&url);
15362
15363 let mut json_mime_type = mime::APPLICATION_JSON;
15364 let mut request_value_reader = {
15365 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15366 common::remove_json_null_values(&mut value);
15367 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15368 serde_json::to_writer(&mut dst, &value).unwrap();
15369 dst
15370 };
15371 let request_size = request_value_reader
15372 .seek(std::io::SeekFrom::End(0))
15373 .unwrap();
15374 request_value_reader
15375 .seek(std::io::SeekFrom::Start(0))
15376 .unwrap();
15377
15378 loop {
15379 let token = match self
15380 .hub
15381 .auth
15382 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15383 .await
15384 {
15385 Ok(token) => token,
15386 Err(e) => match dlg.token(e) {
15387 Ok(token) => token,
15388 Err(e) => {
15389 dlg.finished(false);
15390 return Err(common::Error::MissingToken(e));
15391 }
15392 },
15393 };
15394 request_value_reader
15395 .seek(std::io::SeekFrom::Start(0))
15396 .unwrap();
15397 let mut req_result = {
15398 let client = &self.hub.client;
15399 dlg.pre_request();
15400 let mut req_builder = hyper::Request::builder()
15401 .method(hyper::Method::POST)
15402 .uri(url.as_str())
15403 .header(USER_AGENT, self.hub._user_agent.clone());
15404
15405 if let Some(token) = token.as_ref() {
15406 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15407 }
15408
15409 let request = req_builder
15410 .header(CONTENT_TYPE, json_mime_type.to_string())
15411 .header(CONTENT_LENGTH, request_size as u64)
15412 .body(common::to_body(
15413 request_value_reader.get_ref().clone().into(),
15414 ));
15415
15416 client.request(request.unwrap()).await
15417 };
15418
15419 match req_result {
15420 Err(err) => {
15421 if let common::Retry::After(d) = dlg.http_error(&err) {
15422 sleep(d).await;
15423 continue;
15424 }
15425 dlg.finished(false);
15426 return Err(common::Error::HttpError(err));
15427 }
15428 Ok(res) => {
15429 let (mut parts, body) = res.into_parts();
15430 let mut body = common::Body::new(body);
15431 if !parts.status.is_success() {
15432 let bytes = common::to_bytes(body).await.unwrap_or_default();
15433 let error = serde_json::from_str(&common::to_string(&bytes));
15434 let response = common::to_response(parts, bytes.into());
15435
15436 if let common::Retry::After(d) =
15437 dlg.http_failure(&response, error.as_ref().ok())
15438 {
15439 sleep(d).await;
15440 continue;
15441 }
15442
15443 dlg.finished(false);
15444
15445 return Err(match error {
15446 Ok(value) => common::Error::BadRequest(value),
15447 _ => common::Error::Failure(response),
15448 });
15449 }
15450 let response = {
15451 let bytes = common::to_bytes(body).await.unwrap_or_default();
15452 let encoded = common::to_string(&bytes);
15453 match serde_json::from_str(&encoded) {
15454 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15455 Err(error) => {
15456 dlg.response_json_decode_error(&encoded, &error);
15457 return Err(common::Error::JsonDecodeError(
15458 encoded.to_string(),
15459 error,
15460 ));
15461 }
15462 }
15463 };
15464
15465 dlg.finished(true);
15466 return Ok(response);
15467 }
15468 }
15469 }
15470 }
15471
15472 ///
15473 /// Sets the *request* property to the given value.
15474 ///
15475 /// Even though the property as already been set when instantiating this call,
15476 /// we provide this method for API completeness.
15477 pub fn request(
15478 mut self,
15479 new_value: CancelCloneJobRequest,
15480 ) -> ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C> {
15481 self._request = new_value;
15482 self
15483 }
15484 /// Required. The clone job id
15485 ///
15486 /// Sets the *name* path property to the given value.
15487 ///
15488 /// Even though the property as already been set when instantiating this call,
15489 /// we provide this method for API completeness.
15490 pub fn name(
15491 mut self,
15492 new_value: &str,
15493 ) -> ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C> {
15494 self._name = new_value.to_string();
15495 self
15496 }
15497 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15498 /// while executing the actual API request.
15499 ///
15500 /// ````text
15501 /// It should be used to handle progress information, and to implement a certain level of resilience.
15502 /// ````
15503 ///
15504 /// Sets the *delegate* property to the given value.
15505 pub fn delegate(
15506 mut self,
15507 new_value: &'a mut dyn common::Delegate,
15508 ) -> ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C> {
15509 self._delegate = Some(new_value);
15510 self
15511 }
15512
15513 /// Set any additional parameter of the query string used in the request.
15514 /// It should be used to set parameters which are not yet available through their own
15515 /// setters.
15516 ///
15517 /// Please note that this method must not be used to set any of the known parameters
15518 /// which have their own setter method. If done anyway, the request will fail.
15519 ///
15520 /// # Additional Parameters
15521 ///
15522 /// * *$.xgafv* (query-string) - V1 error format.
15523 /// * *access_token* (query-string) - OAuth access token.
15524 /// * *alt* (query-string) - Data format for response.
15525 /// * *callback* (query-string) - JSONP
15526 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15527 /// * *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.
15528 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15529 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15530 /// * *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.
15531 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15532 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15533 pub fn param<T>(
15534 mut self,
15535 name: T,
15536 value: T,
15537 ) -> ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C>
15538 where
15539 T: AsRef<str>,
15540 {
15541 self._additional_params
15542 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15543 self
15544 }
15545
15546 /// Identifies the authorization scope for the method you are building.
15547 ///
15548 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15549 /// [`Scope::CloudPlatform`].
15550 ///
15551 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15552 /// tokens for more than one scope.
15553 ///
15554 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15555 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15556 /// sufficient, a read-write scope will do as well.
15557 pub fn add_scope<St>(
15558 mut self,
15559 scope: St,
15560 ) -> ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C>
15561 where
15562 St: AsRef<str>,
15563 {
15564 self._scopes.insert(String::from(scope.as_ref()));
15565 self
15566 }
15567 /// Identifies the authorization scope(s) for the method you are building.
15568 ///
15569 /// See [`Self::add_scope()`] for details.
15570 pub fn add_scopes<I, St>(
15571 mut self,
15572 scopes: I,
15573 ) -> ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C>
15574 where
15575 I: IntoIterator<Item = St>,
15576 St: AsRef<str>,
15577 {
15578 self._scopes
15579 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15580 self
15581 }
15582
15583 /// Removes all scopes, and no default scope will be used either.
15584 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15585 /// for details).
15586 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmCloneJobCancelCall<'a, C> {
15587 self._scopes.clear();
15588 self
15589 }
15590}
15591
15592/// Initiates a Clone of a specific migrating VM.
15593///
15594/// A builder for the *locations.sources.migratingVms.cloneJobs.create* method supported by a *project* resource.
15595/// It is not used directly, but through a [`ProjectMethods`] instance.
15596///
15597/// # Example
15598///
15599/// Instantiate a resource method builder
15600///
15601/// ```test_harness,no_run
15602/// # extern crate hyper;
15603/// # extern crate hyper_rustls;
15604/// # extern crate google_vmmigration1 as vmmigration1;
15605/// use vmmigration1::api::CloneJob;
15606/// # async fn dox() {
15607/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15608///
15609/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15610/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15611/// # .with_native_roots()
15612/// # .unwrap()
15613/// # .https_only()
15614/// # .enable_http2()
15615/// # .build();
15616///
15617/// # let executor = hyper_util::rt::TokioExecutor::new();
15618/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15619/// # secret,
15620/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15621/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15622/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15623/// # ),
15624/// # ).build().await.unwrap();
15625///
15626/// # let client = hyper_util::client::legacy::Client::builder(
15627/// # hyper_util::rt::TokioExecutor::new()
15628/// # )
15629/// # .build(
15630/// # hyper_rustls::HttpsConnectorBuilder::new()
15631/// # .with_native_roots()
15632/// # .unwrap()
15633/// # .https_or_http()
15634/// # .enable_http2()
15635/// # .build()
15636/// # );
15637/// # let mut hub = VMMigrationService::new(client, auth);
15638/// // As the method needs a request, you would usually fill it with the desired information
15639/// // into the respective structure. Some of the parts shown here might not be applicable !
15640/// // Values shown here are possibly random and not representative !
15641/// let mut req = CloneJob::default();
15642///
15643/// // You can configure optional parameters by calling the respective setters at will, and
15644/// // execute the final call using `doit()`.
15645/// // Values shown here are possibly random and not representative !
15646/// let result = hub.projects().locations_sources_migrating_vms_clone_jobs_create(req, "parent")
15647/// .request_id("et")
15648/// .clone_job_id("erat")
15649/// .doit().await;
15650/// # }
15651/// ```
15652pub struct ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C>
15653where
15654 C: 'a,
15655{
15656 hub: &'a VMMigrationService<C>,
15657 _request: CloneJob,
15658 _parent: String,
15659 _request_id: Option<String>,
15660 _clone_job_id: Option<String>,
15661 _delegate: Option<&'a mut dyn common::Delegate>,
15662 _additional_params: HashMap<String, String>,
15663 _scopes: BTreeSet<String>,
15664}
15665
15666impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C> {}
15667
15668impl<'a, C> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C>
15669where
15670 C: common::Connector,
15671{
15672 /// Perform the operation you have build so far.
15673 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15674 use std::borrow::Cow;
15675 use std::io::{Read, Seek};
15676
15677 use common::{url::Params, ToParts};
15678 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15679
15680 let mut dd = common::DefaultDelegate;
15681 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15682 dlg.begin(common::MethodInfo {
15683 id: "vmmigration.projects.locations.sources.migratingVms.cloneJobs.create",
15684 http_method: hyper::Method::POST,
15685 });
15686
15687 for &field in ["alt", "parent", "requestId", "cloneJobId"].iter() {
15688 if self._additional_params.contains_key(field) {
15689 dlg.finished(false);
15690 return Err(common::Error::FieldClash(field));
15691 }
15692 }
15693
15694 let mut params = Params::with_capacity(6 + self._additional_params.len());
15695 params.push("parent", self._parent);
15696 if let Some(value) = self._request_id.as_ref() {
15697 params.push("requestId", value);
15698 }
15699 if let Some(value) = self._clone_job_id.as_ref() {
15700 params.push("cloneJobId", value);
15701 }
15702
15703 params.extend(self._additional_params.iter());
15704
15705 params.push("alt", "json");
15706 let mut url = self.hub._base_url.clone() + "v1/{+parent}/cloneJobs";
15707 if self._scopes.is_empty() {
15708 self._scopes
15709 .insert(Scope::CloudPlatform.as_ref().to_string());
15710 }
15711
15712 #[allow(clippy::single_element_loop)]
15713 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
15714 url = params.uri_replacement(url, param_name, find_this, true);
15715 }
15716 {
15717 let to_remove = ["parent"];
15718 params.remove_params(&to_remove);
15719 }
15720
15721 let url = params.parse_with_url(&url);
15722
15723 let mut json_mime_type = mime::APPLICATION_JSON;
15724 let mut request_value_reader = {
15725 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15726 common::remove_json_null_values(&mut value);
15727 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15728 serde_json::to_writer(&mut dst, &value).unwrap();
15729 dst
15730 };
15731 let request_size = request_value_reader
15732 .seek(std::io::SeekFrom::End(0))
15733 .unwrap();
15734 request_value_reader
15735 .seek(std::io::SeekFrom::Start(0))
15736 .unwrap();
15737
15738 loop {
15739 let token = match self
15740 .hub
15741 .auth
15742 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15743 .await
15744 {
15745 Ok(token) => token,
15746 Err(e) => match dlg.token(e) {
15747 Ok(token) => token,
15748 Err(e) => {
15749 dlg.finished(false);
15750 return Err(common::Error::MissingToken(e));
15751 }
15752 },
15753 };
15754 request_value_reader
15755 .seek(std::io::SeekFrom::Start(0))
15756 .unwrap();
15757 let mut req_result = {
15758 let client = &self.hub.client;
15759 dlg.pre_request();
15760 let mut req_builder = hyper::Request::builder()
15761 .method(hyper::Method::POST)
15762 .uri(url.as_str())
15763 .header(USER_AGENT, self.hub._user_agent.clone());
15764
15765 if let Some(token) = token.as_ref() {
15766 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15767 }
15768
15769 let request = req_builder
15770 .header(CONTENT_TYPE, json_mime_type.to_string())
15771 .header(CONTENT_LENGTH, request_size as u64)
15772 .body(common::to_body(
15773 request_value_reader.get_ref().clone().into(),
15774 ));
15775
15776 client.request(request.unwrap()).await
15777 };
15778
15779 match req_result {
15780 Err(err) => {
15781 if let common::Retry::After(d) = dlg.http_error(&err) {
15782 sleep(d).await;
15783 continue;
15784 }
15785 dlg.finished(false);
15786 return Err(common::Error::HttpError(err));
15787 }
15788 Ok(res) => {
15789 let (mut parts, body) = res.into_parts();
15790 let mut body = common::Body::new(body);
15791 if !parts.status.is_success() {
15792 let bytes = common::to_bytes(body).await.unwrap_or_default();
15793 let error = serde_json::from_str(&common::to_string(&bytes));
15794 let response = common::to_response(parts, bytes.into());
15795
15796 if let common::Retry::After(d) =
15797 dlg.http_failure(&response, error.as_ref().ok())
15798 {
15799 sleep(d).await;
15800 continue;
15801 }
15802
15803 dlg.finished(false);
15804
15805 return Err(match error {
15806 Ok(value) => common::Error::BadRequest(value),
15807 _ => common::Error::Failure(response),
15808 });
15809 }
15810 let response = {
15811 let bytes = common::to_bytes(body).await.unwrap_or_default();
15812 let encoded = common::to_string(&bytes);
15813 match serde_json::from_str(&encoded) {
15814 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15815 Err(error) => {
15816 dlg.response_json_decode_error(&encoded, &error);
15817 return Err(common::Error::JsonDecodeError(
15818 encoded.to_string(),
15819 error,
15820 ));
15821 }
15822 }
15823 };
15824
15825 dlg.finished(true);
15826 return Ok(response);
15827 }
15828 }
15829 }
15830 }
15831
15832 ///
15833 /// Sets the *request* property to the given value.
15834 ///
15835 /// Even though the property as already been set when instantiating this call,
15836 /// we provide this method for API completeness.
15837 pub fn request(
15838 mut self,
15839 new_value: CloneJob,
15840 ) -> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C> {
15841 self._request = new_value;
15842 self
15843 }
15844 /// Required. The Clone's parent.
15845 ///
15846 /// Sets the *parent* path property to the given value.
15847 ///
15848 /// Even though the property as already been set when instantiating this call,
15849 /// we provide this method for API completeness.
15850 pub fn parent(
15851 mut self,
15852 new_value: &str,
15853 ) -> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C> {
15854 self._parent = new_value.to_string();
15855 self
15856 }
15857 /// 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).
15858 ///
15859 /// Sets the *request id* query property to the given value.
15860 pub fn request_id(
15861 mut self,
15862 new_value: &str,
15863 ) -> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C> {
15864 self._request_id = Some(new_value.to_string());
15865 self
15866 }
15867 /// Required. The clone job identifier.
15868 ///
15869 /// Sets the *clone job id* query property to the given value.
15870 pub fn clone_job_id(
15871 mut self,
15872 new_value: &str,
15873 ) -> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C> {
15874 self._clone_job_id = Some(new_value.to_string());
15875 self
15876 }
15877 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15878 /// while executing the actual API request.
15879 ///
15880 /// ````text
15881 /// It should be used to handle progress information, and to implement a certain level of resilience.
15882 /// ````
15883 ///
15884 /// Sets the *delegate* property to the given value.
15885 pub fn delegate(
15886 mut self,
15887 new_value: &'a mut dyn common::Delegate,
15888 ) -> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C> {
15889 self._delegate = Some(new_value);
15890 self
15891 }
15892
15893 /// Set any additional parameter of the query string used in the request.
15894 /// It should be used to set parameters which are not yet available through their own
15895 /// setters.
15896 ///
15897 /// Please note that this method must not be used to set any of the known parameters
15898 /// which have their own setter method. If done anyway, the request will fail.
15899 ///
15900 /// # Additional Parameters
15901 ///
15902 /// * *$.xgafv* (query-string) - V1 error format.
15903 /// * *access_token* (query-string) - OAuth access token.
15904 /// * *alt* (query-string) - Data format for response.
15905 /// * *callback* (query-string) - JSONP
15906 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15907 /// * *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.
15908 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15909 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15910 /// * *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.
15911 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15912 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15913 pub fn param<T>(
15914 mut self,
15915 name: T,
15916 value: T,
15917 ) -> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C>
15918 where
15919 T: AsRef<str>,
15920 {
15921 self._additional_params
15922 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15923 self
15924 }
15925
15926 /// Identifies the authorization scope for the method you are building.
15927 ///
15928 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15929 /// [`Scope::CloudPlatform`].
15930 ///
15931 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15932 /// tokens for more than one scope.
15933 ///
15934 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15935 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15936 /// sufficient, a read-write scope will do as well.
15937 pub fn add_scope<St>(
15938 mut self,
15939 scope: St,
15940 ) -> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C>
15941 where
15942 St: AsRef<str>,
15943 {
15944 self._scopes.insert(String::from(scope.as_ref()));
15945 self
15946 }
15947 /// Identifies the authorization scope(s) for the method you are building.
15948 ///
15949 /// See [`Self::add_scope()`] for details.
15950 pub fn add_scopes<I, St>(
15951 mut self,
15952 scopes: I,
15953 ) -> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C>
15954 where
15955 I: IntoIterator<Item = St>,
15956 St: AsRef<str>,
15957 {
15958 self._scopes
15959 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15960 self
15961 }
15962
15963 /// Removes all scopes, and no default scope will be used either.
15964 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15965 /// for details).
15966 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmCloneJobCreateCall<'a, C> {
15967 self._scopes.clear();
15968 self
15969 }
15970}
15971
15972/// Gets details of a single CloneJob.
15973///
15974/// A builder for the *locations.sources.migratingVms.cloneJobs.get* method supported by a *project* resource.
15975/// It is not used directly, but through a [`ProjectMethods`] instance.
15976///
15977/// # Example
15978///
15979/// Instantiate a resource method builder
15980///
15981/// ```test_harness,no_run
15982/// # extern crate hyper;
15983/// # extern crate hyper_rustls;
15984/// # extern crate google_vmmigration1 as vmmigration1;
15985/// # async fn dox() {
15986/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15987///
15988/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15989/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15990/// # .with_native_roots()
15991/// # .unwrap()
15992/// # .https_only()
15993/// # .enable_http2()
15994/// # .build();
15995///
15996/// # let executor = hyper_util::rt::TokioExecutor::new();
15997/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15998/// # secret,
15999/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16000/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16001/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16002/// # ),
16003/// # ).build().await.unwrap();
16004///
16005/// # let client = hyper_util::client::legacy::Client::builder(
16006/// # hyper_util::rt::TokioExecutor::new()
16007/// # )
16008/// # .build(
16009/// # hyper_rustls::HttpsConnectorBuilder::new()
16010/// # .with_native_roots()
16011/// # .unwrap()
16012/// # .https_or_http()
16013/// # .enable_http2()
16014/// # .build()
16015/// # );
16016/// # let mut hub = VMMigrationService::new(client, auth);
16017/// // You can configure optional parameters by calling the respective setters at will, and
16018/// // execute the final call using `doit()`.
16019/// // Values shown here are possibly random and not representative !
16020/// let result = hub.projects().locations_sources_migrating_vms_clone_jobs_get("name")
16021/// .doit().await;
16022/// # }
16023/// ```
16024pub struct ProjectLocationSourceMigratingVmCloneJobGetCall<'a, C>
16025where
16026 C: 'a,
16027{
16028 hub: &'a VMMigrationService<C>,
16029 _name: String,
16030 _delegate: Option<&'a mut dyn common::Delegate>,
16031 _additional_params: HashMap<String, String>,
16032 _scopes: BTreeSet<String>,
16033}
16034
16035impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmCloneJobGetCall<'a, C> {}
16036
16037impl<'a, C> ProjectLocationSourceMigratingVmCloneJobGetCall<'a, C>
16038where
16039 C: common::Connector,
16040{
16041 /// Perform the operation you have build so far.
16042 pub async fn doit(mut self) -> common::Result<(common::Response, CloneJob)> {
16043 use std::borrow::Cow;
16044 use std::io::{Read, Seek};
16045
16046 use common::{url::Params, ToParts};
16047 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16048
16049 let mut dd = common::DefaultDelegate;
16050 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16051 dlg.begin(common::MethodInfo {
16052 id: "vmmigration.projects.locations.sources.migratingVms.cloneJobs.get",
16053 http_method: hyper::Method::GET,
16054 });
16055
16056 for &field in ["alt", "name"].iter() {
16057 if self._additional_params.contains_key(field) {
16058 dlg.finished(false);
16059 return Err(common::Error::FieldClash(field));
16060 }
16061 }
16062
16063 let mut params = Params::with_capacity(3 + self._additional_params.len());
16064 params.push("name", self._name);
16065
16066 params.extend(self._additional_params.iter());
16067
16068 params.push("alt", "json");
16069 let mut url = self.hub._base_url.clone() + "v1/{+name}";
16070 if self._scopes.is_empty() {
16071 self._scopes
16072 .insert(Scope::CloudPlatform.as_ref().to_string());
16073 }
16074
16075 #[allow(clippy::single_element_loop)]
16076 for &(find_this, param_name) in [("{+name}", "name")].iter() {
16077 url = params.uri_replacement(url, param_name, find_this, true);
16078 }
16079 {
16080 let to_remove = ["name"];
16081 params.remove_params(&to_remove);
16082 }
16083
16084 let url = params.parse_with_url(&url);
16085
16086 loop {
16087 let token = match self
16088 .hub
16089 .auth
16090 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16091 .await
16092 {
16093 Ok(token) => token,
16094 Err(e) => match dlg.token(e) {
16095 Ok(token) => token,
16096 Err(e) => {
16097 dlg.finished(false);
16098 return Err(common::Error::MissingToken(e));
16099 }
16100 },
16101 };
16102 let mut req_result = {
16103 let client = &self.hub.client;
16104 dlg.pre_request();
16105 let mut req_builder = hyper::Request::builder()
16106 .method(hyper::Method::GET)
16107 .uri(url.as_str())
16108 .header(USER_AGENT, self.hub._user_agent.clone());
16109
16110 if let Some(token) = token.as_ref() {
16111 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16112 }
16113
16114 let request = req_builder
16115 .header(CONTENT_LENGTH, 0_u64)
16116 .body(common::to_body::<String>(None));
16117
16118 client.request(request.unwrap()).await
16119 };
16120
16121 match req_result {
16122 Err(err) => {
16123 if let common::Retry::After(d) = dlg.http_error(&err) {
16124 sleep(d).await;
16125 continue;
16126 }
16127 dlg.finished(false);
16128 return Err(common::Error::HttpError(err));
16129 }
16130 Ok(res) => {
16131 let (mut parts, body) = res.into_parts();
16132 let mut body = common::Body::new(body);
16133 if !parts.status.is_success() {
16134 let bytes = common::to_bytes(body).await.unwrap_or_default();
16135 let error = serde_json::from_str(&common::to_string(&bytes));
16136 let response = common::to_response(parts, bytes.into());
16137
16138 if let common::Retry::After(d) =
16139 dlg.http_failure(&response, error.as_ref().ok())
16140 {
16141 sleep(d).await;
16142 continue;
16143 }
16144
16145 dlg.finished(false);
16146
16147 return Err(match error {
16148 Ok(value) => common::Error::BadRequest(value),
16149 _ => common::Error::Failure(response),
16150 });
16151 }
16152 let response = {
16153 let bytes = common::to_bytes(body).await.unwrap_or_default();
16154 let encoded = common::to_string(&bytes);
16155 match serde_json::from_str(&encoded) {
16156 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16157 Err(error) => {
16158 dlg.response_json_decode_error(&encoded, &error);
16159 return Err(common::Error::JsonDecodeError(
16160 encoded.to_string(),
16161 error,
16162 ));
16163 }
16164 }
16165 };
16166
16167 dlg.finished(true);
16168 return Ok(response);
16169 }
16170 }
16171 }
16172 }
16173
16174 /// Required. The name of the CloneJob.
16175 ///
16176 /// Sets the *name* path property to the given value.
16177 ///
16178 /// Even though the property as already been set when instantiating this call,
16179 /// we provide this method for API completeness.
16180 pub fn name(
16181 mut self,
16182 new_value: &str,
16183 ) -> ProjectLocationSourceMigratingVmCloneJobGetCall<'a, C> {
16184 self._name = new_value.to_string();
16185 self
16186 }
16187 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16188 /// while executing the actual API request.
16189 ///
16190 /// ````text
16191 /// It should be used to handle progress information, and to implement a certain level of resilience.
16192 /// ````
16193 ///
16194 /// Sets the *delegate* property to the given value.
16195 pub fn delegate(
16196 mut self,
16197 new_value: &'a mut dyn common::Delegate,
16198 ) -> ProjectLocationSourceMigratingVmCloneJobGetCall<'a, C> {
16199 self._delegate = Some(new_value);
16200 self
16201 }
16202
16203 /// Set any additional parameter of the query string used in the request.
16204 /// It should be used to set parameters which are not yet available through their own
16205 /// setters.
16206 ///
16207 /// Please note that this method must not be used to set any of the known parameters
16208 /// which have their own setter method. If done anyway, the request will fail.
16209 ///
16210 /// # Additional Parameters
16211 ///
16212 /// * *$.xgafv* (query-string) - V1 error format.
16213 /// * *access_token* (query-string) - OAuth access token.
16214 /// * *alt* (query-string) - Data format for response.
16215 /// * *callback* (query-string) - JSONP
16216 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16217 /// * *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.
16218 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16219 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16220 /// * *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.
16221 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16222 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16223 pub fn param<T>(
16224 mut self,
16225 name: T,
16226 value: T,
16227 ) -> ProjectLocationSourceMigratingVmCloneJobGetCall<'a, C>
16228 where
16229 T: AsRef<str>,
16230 {
16231 self._additional_params
16232 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16233 self
16234 }
16235
16236 /// Identifies the authorization scope for the method you are building.
16237 ///
16238 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16239 /// [`Scope::CloudPlatform`].
16240 ///
16241 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16242 /// tokens for more than one scope.
16243 ///
16244 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16245 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16246 /// sufficient, a read-write scope will do as well.
16247 pub fn add_scope<St>(
16248 mut self,
16249 scope: St,
16250 ) -> ProjectLocationSourceMigratingVmCloneJobGetCall<'a, C>
16251 where
16252 St: AsRef<str>,
16253 {
16254 self._scopes.insert(String::from(scope.as_ref()));
16255 self
16256 }
16257 /// Identifies the authorization scope(s) for the method you are building.
16258 ///
16259 /// See [`Self::add_scope()`] for details.
16260 pub fn add_scopes<I, St>(
16261 mut self,
16262 scopes: I,
16263 ) -> ProjectLocationSourceMigratingVmCloneJobGetCall<'a, C>
16264 where
16265 I: IntoIterator<Item = St>,
16266 St: AsRef<str>,
16267 {
16268 self._scopes
16269 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16270 self
16271 }
16272
16273 /// Removes all scopes, and no default scope will be used either.
16274 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16275 /// for details).
16276 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmCloneJobGetCall<'a, C> {
16277 self._scopes.clear();
16278 self
16279 }
16280}
16281
16282/// Lists the CloneJobs of a migrating VM. Only 25 most recent CloneJobs are listed.
16283///
16284/// A builder for the *locations.sources.migratingVms.cloneJobs.list* method supported by a *project* resource.
16285/// It is not used directly, but through a [`ProjectMethods`] instance.
16286///
16287/// # Example
16288///
16289/// Instantiate a resource method builder
16290///
16291/// ```test_harness,no_run
16292/// # extern crate hyper;
16293/// # extern crate hyper_rustls;
16294/// # extern crate google_vmmigration1 as vmmigration1;
16295/// # async fn dox() {
16296/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16297///
16298/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16299/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16300/// # .with_native_roots()
16301/// # .unwrap()
16302/// # .https_only()
16303/// # .enable_http2()
16304/// # .build();
16305///
16306/// # let executor = hyper_util::rt::TokioExecutor::new();
16307/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16308/// # secret,
16309/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16310/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16311/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16312/// # ),
16313/// # ).build().await.unwrap();
16314///
16315/// # let client = hyper_util::client::legacy::Client::builder(
16316/// # hyper_util::rt::TokioExecutor::new()
16317/// # )
16318/// # .build(
16319/// # hyper_rustls::HttpsConnectorBuilder::new()
16320/// # .with_native_roots()
16321/// # .unwrap()
16322/// # .https_or_http()
16323/// # .enable_http2()
16324/// # .build()
16325/// # );
16326/// # let mut hub = VMMigrationService::new(client, auth);
16327/// // You can configure optional parameters by calling the respective setters at will, and
16328/// // execute the final call using `doit()`.
16329/// // Values shown here are possibly random and not representative !
16330/// let result = hub.projects().locations_sources_migrating_vms_clone_jobs_list("parent")
16331/// .page_token("sed")
16332/// .page_size(-9)
16333/// .order_by("dolores")
16334/// .filter("gubergren")
16335/// .doit().await;
16336/// # }
16337/// ```
16338pub struct ProjectLocationSourceMigratingVmCloneJobListCall<'a, C>
16339where
16340 C: 'a,
16341{
16342 hub: &'a VMMigrationService<C>,
16343 _parent: String,
16344 _page_token: Option<String>,
16345 _page_size: Option<i32>,
16346 _order_by: Option<String>,
16347 _filter: Option<String>,
16348 _delegate: Option<&'a mut dyn common::Delegate>,
16349 _additional_params: HashMap<String, String>,
16350 _scopes: BTreeSet<String>,
16351}
16352
16353impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmCloneJobListCall<'a, C> {}
16354
16355impl<'a, C> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C>
16356where
16357 C: common::Connector,
16358{
16359 /// Perform the operation you have build so far.
16360 pub async fn doit(mut self) -> common::Result<(common::Response, ListCloneJobsResponse)> {
16361 use std::borrow::Cow;
16362 use std::io::{Read, Seek};
16363
16364 use common::{url::Params, ToParts};
16365 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16366
16367 let mut dd = common::DefaultDelegate;
16368 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16369 dlg.begin(common::MethodInfo {
16370 id: "vmmigration.projects.locations.sources.migratingVms.cloneJobs.list",
16371 http_method: hyper::Method::GET,
16372 });
16373
16374 for &field in [
16375 "alt",
16376 "parent",
16377 "pageToken",
16378 "pageSize",
16379 "orderBy",
16380 "filter",
16381 ]
16382 .iter()
16383 {
16384 if self._additional_params.contains_key(field) {
16385 dlg.finished(false);
16386 return Err(common::Error::FieldClash(field));
16387 }
16388 }
16389
16390 let mut params = Params::with_capacity(7 + self._additional_params.len());
16391 params.push("parent", self._parent);
16392 if let Some(value) = self._page_token.as_ref() {
16393 params.push("pageToken", value);
16394 }
16395 if let Some(value) = self._page_size.as_ref() {
16396 params.push("pageSize", value.to_string());
16397 }
16398 if let Some(value) = self._order_by.as_ref() {
16399 params.push("orderBy", value);
16400 }
16401 if let Some(value) = self._filter.as_ref() {
16402 params.push("filter", value);
16403 }
16404
16405 params.extend(self._additional_params.iter());
16406
16407 params.push("alt", "json");
16408 let mut url = self.hub._base_url.clone() + "v1/{+parent}/cloneJobs";
16409 if self._scopes.is_empty() {
16410 self._scopes
16411 .insert(Scope::CloudPlatform.as_ref().to_string());
16412 }
16413
16414 #[allow(clippy::single_element_loop)]
16415 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
16416 url = params.uri_replacement(url, param_name, find_this, true);
16417 }
16418 {
16419 let to_remove = ["parent"];
16420 params.remove_params(&to_remove);
16421 }
16422
16423 let url = params.parse_with_url(&url);
16424
16425 loop {
16426 let token = match self
16427 .hub
16428 .auth
16429 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16430 .await
16431 {
16432 Ok(token) => token,
16433 Err(e) => match dlg.token(e) {
16434 Ok(token) => token,
16435 Err(e) => {
16436 dlg.finished(false);
16437 return Err(common::Error::MissingToken(e));
16438 }
16439 },
16440 };
16441 let mut req_result = {
16442 let client = &self.hub.client;
16443 dlg.pre_request();
16444 let mut req_builder = hyper::Request::builder()
16445 .method(hyper::Method::GET)
16446 .uri(url.as_str())
16447 .header(USER_AGENT, self.hub._user_agent.clone());
16448
16449 if let Some(token) = token.as_ref() {
16450 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16451 }
16452
16453 let request = req_builder
16454 .header(CONTENT_LENGTH, 0_u64)
16455 .body(common::to_body::<String>(None));
16456
16457 client.request(request.unwrap()).await
16458 };
16459
16460 match req_result {
16461 Err(err) => {
16462 if let common::Retry::After(d) = dlg.http_error(&err) {
16463 sleep(d).await;
16464 continue;
16465 }
16466 dlg.finished(false);
16467 return Err(common::Error::HttpError(err));
16468 }
16469 Ok(res) => {
16470 let (mut parts, body) = res.into_parts();
16471 let mut body = common::Body::new(body);
16472 if !parts.status.is_success() {
16473 let bytes = common::to_bytes(body).await.unwrap_or_default();
16474 let error = serde_json::from_str(&common::to_string(&bytes));
16475 let response = common::to_response(parts, bytes.into());
16476
16477 if let common::Retry::After(d) =
16478 dlg.http_failure(&response, error.as_ref().ok())
16479 {
16480 sleep(d).await;
16481 continue;
16482 }
16483
16484 dlg.finished(false);
16485
16486 return Err(match error {
16487 Ok(value) => common::Error::BadRequest(value),
16488 _ => common::Error::Failure(response),
16489 });
16490 }
16491 let response = {
16492 let bytes = common::to_bytes(body).await.unwrap_or_default();
16493 let encoded = common::to_string(&bytes);
16494 match serde_json::from_str(&encoded) {
16495 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16496 Err(error) => {
16497 dlg.response_json_decode_error(&encoded, &error);
16498 return Err(common::Error::JsonDecodeError(
16499 encoded.to_string(),
16500 error,
16501 ));
16502 }
16503 }
16504 };
16505
16506 dlg.finished(true);
16507 return Ok(response);
16508 }
16509 }
16510 }
16511 }
16512
16513 /// Required. The parent, which owns this collection of source VMs.
16514 ///
16515 /// Sets the *parent* path property to the given value.
16516 ///
16517 /// Even though the property as already been set when instantiating this call,
16518 /// we provide this method for API completeness.
16519 pub fn parent(
16520 mut self,
16521 new_value: &str,
16522 ) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C> {
16523 self._parent = new_value.to_string();
16524 self
16525 }
16526 /// 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.
16527 ///
16528 /// Sets the *page token* query property to the given value.
16529 pub fn page_token(
16530 mut self,
16531 new_value: &str,
16532 ) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C> {
16533 self._page_token = Some(new_value.to_string());
16534 self
16535 }
16536 /// 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.
16537 ///
16538 /// Sets the *page size* query property to the given value.
16539 pub fn page_size(
16540 mut self,
16541 new_value: i32,
16542 ) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C> {
16543 self._page_size = Some(new_value);
16544 self
16545 }
16546 /// Optional. the order by fields for the result.
16547 ///
16548 /// Sets the *order by* query property to the given value.
16549 pub fn order_by(
16550 mut self,
16551 new_value: &str,
16552 ) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C> {
16553 self._order_by = Some(new_value.to_string());
16554 self
16555 }
16556 /// Optional. The filter request.
16557 ///
16558 /// Sets the *filter* query property to the given value.
16559 pub fn filter(
16560 mut self,
16561 new_value: &str,
16562 ) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C> {
16563 self._filter = Some(new_value.to_string());
16564 self
16565 }
16566 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16567 /// while executing the actual API request.
16568 ///
16569 /// ````text
16570 /// It should be used to handle progress information, and to implement a certain level of resilience.
16571 /// ````
16572 ///
16573 /// Sets the *delegate* property to the given value.
16574 pub fn delegate(
16575 mut self,
16576 new_value: &'a mut dyn common::Delegate,
16577 ) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C> {
16578 self._delegate = Some(new_value);
16579 self
16580 }
16581
16582 /// Set any additional parameter of the query string used in the request.
16583 /// It should be used to set parameters which are not yet available through their own
16584 /// setters.
16585 ///
16586 /// Please note that this method must not be used to set any of the known parameters
16587 /// which have their own setter method. If done anyway, the request will fail.
16588 ///
16589 /// # Additional Parameters
16590 ///
16591 /// * *$.xgafv* (query-string) - V1 error format.
16592 /// * *access_token* (query-string) - OAuth access token.
16593 /// * *alt* (query-string) - Data format for response.
16594 /// * *callback* (query-string) - JSONP
16595 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16596 /// * *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.
16597 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16598 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16599 /// * *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.
16600 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16601 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16602 pub fn param<T>(
16603 mut self,
16604 name: T,
16605 value: T,
16606 ) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C>
16607 where
16608 T: AsRef<str>,
16609 {
16610 self._additional_params
16611 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16612 self
16613 }
16614
16615 /// Identifies the authorization scope for the method you are building.
16616 ///
16617 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16618 /// [`Scope::CloudPlatform`].
16619 ///
16620 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16621 /// tokens for more than one scope.
16622 ///
16623 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16624 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16625 /// sufficient, a read-write scope will do as well.
16626 pub fn add_scope<St>(
16627 mut self,
16628 scope: St,
16629 ) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C>
16630 where
16631 St: AsRef<str>,
16632 {
16633 self._scopes.insert(String::from(scope.as_ref()));
16634 self
16635 }
16636 /// Identifies the authorization scope(s) for the method you are building.
16637 ///
16638 /// See [`Self::add_scope()`] for details.
16639 pub fn add_scopes<I, St>(
16640 mut self,
16641 scopes: I,
16642 ) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C>
16643 where
16644 I: IntoIterator<Item = St>,
16645 St: AsRef<str>,
16646 {
16647 self._scopes
16648 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16649 self
16650 }
16651
16652 /// Removes all scopes, and no default scope will be used either.
16653 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16654 /// for details).
16655 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmCloneJobListCall<'a, C> {
16656 self._scopes.clear();
16657 self
16658 }
16659}
16660
16661/// Initiates the cancellation of a running cutover job.
16662///
16663/// A builder for the *locations.sources.migratingVms.cutoverJobs.cancel* method supported by a *project* resource.
16664/// It is not used directly, but through a [`ProjectMethods`] instance.
16665///
16666/// # Example
16667///
16668/// Instantiate a resource method builder
16669///
16670/// ```test_harness,no_run
16671/// # extern crate hyper;
16672/// # extern crate hyper_rustls;
16673/// # extern crate google_vmmigration1 as vmmigration1;
16674/// use vmmigration1::api::CancelCutoverJobRequest;
16675/// # async fn dox() {
16676/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16677///
16678/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16679/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16680/// # .with_native_roots()
16681/// # .unwrap()
16682/// # .https_only()
16683/// # .enable_http2()
16684/// # .build();
16685///
16686/// # let executor = hyper_util::rt::TokioExecutor::new();
16687/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16688/// # secret,
16689/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16690/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16691/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16692/// # ),
16693/// # ).build().await.unwrap();
16694///
16695/// # let client = hyper_util::client::legacy::Client::builder(
16696/// # hyper_util::rt::TokioExecutor::new()
16697/// # )
16698/// # .build(
16699/// # hyper_rustls::HttpsConnectorBuilder::new()
16700/// # .with_native_roots()
16701/// # .unwrap()
16702/// # .https_or_http()
16703/// # .enable_http2()
16704/// # .build()
16705/// # );
16706/// # let mut hub = VMMigrationService::new(client, auth);
16707/// // As the method needs a request, you would usually fill it with the desired information
16708/// // into the respective structure. Some of the parts shown here might not be applicable !
16709/// // Values shown here are possibly random and not representative !
16710/// let mut req = CancelCutoverJobRequest::default();
16711///
16712/// // You can configure optional parameters by calling the respective setters at will, and
16713/// // execute the final call using `doit()`.
16714/// // Values shown here are possibly random and not representative !
16715/// let result = hub.projects().locations_sources_migrating_vms_cutover_jobs_cancel(req, "name")
16716/// .doit().await;
16717/// # }
16718/// ```
16719pub struct ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C>
16720where
16721 C: 'a,
16722{
16723 hub: &'a VMMigrationService<C>,
16724 _request: CancelCutoverJobRequest,
16725 _name: String,
16726 _delegate: Option<&'a mut dyn common::Delegate>,
16727 _additional_params: HashMap<String, String>,
16728 _scopes: BTreeSet<String>,
16729}
16730
16731impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C> {}
16732
16733impl<'a, C> ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C>
16734where
16735 C: common::Connector,
16736{
16737 /// Perform the operation you have build so far.
16738 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
16739 use std::borrow::Cow;
16740 use std::io::{Read, Seek};
16741
16742 use common::{url::Params, ToParts};
16743 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16744
16745 let mut dd = common::DefaultDelegate;
16746 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16747 dlg.begin(common::MethodInfo {
16748 id: "vmmigration.projects.locations.sources.migratingVms.cutoverJobs.cancel",
16749 http_method: hyper::Method::POST,
16750 });
16751
16752 for &field in ["alt", "name"].iter() {
16753 if self._additional_params.contains_key(field) {
16754 dlg.finished(false);
16755 return Err(common::Error::FieldClash(field));
16756 }
16757 }
16758
16759 let mut params = Params::with_capacity(4 + self._additional_params.len());
16760 params.push("name", self._name);
16761
16762 params.extend(self._additional_params.iter());
16763
16764 params.push("alt", "json");
16765 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
16766 if self._scopes.is_empty() {
16767 self._scopes
16768 .insert(Scope::CloudPlatform.as_ref().to_string());
16769 }
16770
16771 #[allow(clippy::single_element_loop)]
16772 for &(find_this, param_name) in [("{+name}", "name")].iter() {
16773 url = params.uri_replacement(url, param_name, find_this, true);
16774 }
16775 {
16776 let to_remove = ["name"];
16777 params.remove_params(&to_remove);
16778 }
16779
16780 let url = params.parse_with_url(&url);
16781
16782 let mut json_mime_type = mime::APPLICATION_JSON;
16783 let mut request_value_reader = {
16784 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16785 common::remove_json_null_values(&mut value);
16786 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16787 serde_json::to_writer(&mut dst, &value).unwrap();
16788 dst
16789 };
16790 let request_size = request_value_reader
16791 .seek(std::io::SeekFrom::End(0))
16792 .unwrap();
16793 request_value_reader
16794 .seek(std::io::SeekFrom::Start(0))
16795 .unwrap();
16796
16797 loop {
16798 let token = match self
16799 .hub
16800 .auth
16801 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16802 .await
16803 {
16804 Ok(token) => token,
16805 Err(e) => match dlg.token(e) {
16806 Ok(token) => token,
16807 Err(e) => {
16808 dlg.finished(false);
16809 return Err(common::Error::MissingToken(e));
16810 }
16811 },
16812 };
16813 request_value_reader
16814 .seek(std::io::SeekFrom::Start(0))
16815 .unwrap();
16816 let mut req_result = {
16817 let client = &self.hub.client;
16818 dlg.pre_request();
16819 let mut req_builder = hyper::Request::builder()
16820 .method(hyper::Method::POST)
16821 .uri(url.as_str())
16822 .header(USER_AGENT, self.hub._user_agent.clone());
16823
16824 if let Some(token) = token.as_ref() {
16825 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16826 }
16827
16828 let request = req_builder
16829 .header(CONTENT_TYPE, json_mime_type.to_string())
16830 .header(CONTENT_LENGTH, request_size as u64)
16831 .body(common::to_body(
16832 request_value_reader.get_ref().clone().into(),
16833 ));
16834
16835 client.request(request.unwrap()).await
16836 };
16837
16838 match req_result {
16839 Err(err) => {
16840 if let common::Retry::After(d) = dlg.http_error(&err) {
16841 sleep(d).await;
16842 continue;
16843 }
16844 dlg.finished(false);
16845 return Err(common::Error::HttpError(err));
16846 }
16847 Ok(res) => {
16848 let (mut parts, body) = res.into_parts();
16849 let mut body = common::Body::new(body);
16850 if !parts.status.is_success() {
16851 let bytes = common::to_bytes(body).await.unwrap_or_default();
16852 let error = serde_json::from_str(&common::to_string(&bytes));
16853 let response = common::to_response(parts, bytes.into());
16854
16855 if let common::Retry::After(d) =
16856 dlg.http_failure(&response, error.as_ref().ok())
16857 {
16858 sleep(d).await;
16859 continue;
16860 }
16861
16862 dlg.finished(false);
16863
16864 return Err(match error {
16865 Ok(value) => common::Error::BadRequest(value),
16866 _ => common::Error::Failure(response),
16867 });
16868 }
16869 let response = {
16870 let bytes = common::to_bytes(body).await.unwrap_or_default();
16871 let encoded = common::to_string(&bytes);
16872 match serde_json::from_str(&encoded) {
16873 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16874 Err(error) => {
16875 dlg.response_json_decode_error(&encoded, &error);
16876 return Err(common::Error::JsonDecodeError(
16877 encoded.to_string(),
16878 error,
16879 ));
16880 }
16881 }
16882 };
16883
16884 dlg.finished(true);
16885 return Ok(response);
16886 }
16887 }
16888 }
16889 }
16890
16891 ///
16892 /// Sets the *request* property to the given value.
16893 ///
16894 /// Even though the property as already been set when instantiating this call,
16895 /// we provide this method for API completeness.
16896 pub fn request(
16897 mut self,
16898 new_value: CancelCutoverJobRequest,
16899 ) -> ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C> {
16900 self._request = new_value;
16901 self
16902 }
16903 /// Required. The cutover job id
16904 ///
16905 /// Sets the *name* path property to the given value.
16906 ///
16907 /// Even though the property as already been set when instantiating this call,
16908 /// we provide this method for API completeness.
16909 pub fn name(
16910 mut self,
16911 new_value: &str,
16912 ) -> ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C> {
16913 self._name = new_value.to_string();
16914 self
16915 }
16916 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16917 /// while executing the actual API request.
16918 ///
16919 /// ````text
16920 /// It should be used to handle progress information, and to implement a certain level of resilience.
16921 /// ````
16922 ///
16923 /// Sets the *delegate* property to the given value.
16924 pub fn delegate(
16925 mut self,
16926 new_value: &'a mut dyn common::Delegate,
16927 ) -> ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C> {
16928 self._delegate = Some(new_value);
16929 self
16930 }
16931
16932 /// Set any additional parameter of the query string used in the request.
16933 /// It should be used to set parameters which are not yet available through their own
16934 /// setters.
16935 ///
16936 /// Please note that this method must not be used to set any of the known parameters
16937 /// which have their own setter method. If done anyway, the request will fail.
16938 ///
16939 /// # Additional Parameters
16940 ///
16941 /// * *$.xgafv* (query-string) - V1 error format.
16942 /// * *access_token* (query-string) - OAuth access token.
16943 /// * *alt* (query-string) - Data format for response.
16944 /// * *callback* (query-string) - JSONP
16945 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16946 /// * *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.
16947 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16948 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16949 /// * *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.
16950 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16951 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16952 pub fn param<T>(
16953 mut self,
16954 name: T,
16955 value: T,
16956 ) -> ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C>
16957 where
16958 T: AsRef<str>,
16959 {
16960 self._additional_params
16961 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16962 self
16963 }
16964
16965 /// Identifies the authorization scope for the method you are building.
16966 ///
16967 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16968 /// [`Scope::CloudPlatform`].
16969 ///
16970 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16971 /// tokens for more than one scope.
16972 ///
16973 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16974 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16975 /// sufficient, a read-write scope will do as well.
16976 pub fn add_scope<St>(
16977 mut self,
16978 scope: St,
16979 ) -> ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C>
16980 where
16981 St: AsRef<str>,
16982 {
16983 self._scopes.insert(String::from(scope.as_ref()));
16984 self
16985 }
16986 /// Identifies the authorization scope(s) for the method you are building.
16987 ///
16988 /// See [`Self::add_scope()`] for details.
16989 pub fn add_scopes<I, St>(
16990 mut self,
16991 scopes: I,
16992 ) -> ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C>
16993 where
16994 I: IntoIterator<Item = St>,
16995 St: AsRef<str>,
16996 {
16997 self._scopes
16998 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16999 self
17000 }
17001
17002 /// Removes all scopes, and no default scope will be used either.
17003 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17004 /// for details).
17005 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmCutoverJobCancelCall<'a, C> {
17006 self._scopes.clear();
17007 self
17008 }
17009}
17010
17011/// 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.
17012///
17013/// A builder for the *locations.sources.migratingVms.cutoverJobs.create* method supported by a *project* resource.
17014/// It is not used directly, but through a [`ProjectMethods`] instance.
17015///
17016/// # Example
17017///
17018/// Instantiate a resource method builder
17019///
17020/// ```test_harness,no_run
17021/// # extern crate hyper;
17022/// # extern crate hyper_rustls;
17023/// # extern crate google_vmmigration1 as vmmigration1;
17024/// use vmmigration1::api::CutoverJob;
17025/// # async fn dox() {
17026/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17027///
17028/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17029/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17030/// # .with_native_roots()
17031/// # .unwrap()
17032/// # .https_only()
17033/// # .enable_http2()
17034/// # .build();
17035///
17036/// # let executor = hyper_util::rt::TokioExecutor::new();
17037/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17038/// # secret,
17039/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17040/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17041/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17042/// # ),
17043/// # ).build().await.unwrap();
17044///
17045/// # let client = hyper_util::client::legacy::Client::builder(
17046/// # hyper_util::rt::TokioExecutor::new()
17047/// # )
17048/// # .build(
17049/// # hyper_rustls::HttpsConnectorBuilder::new()
17050/// # .with_native_roots()
17051/// # .unwrap()
17052/// # .https_or_http()
17053/// # .enable_http2()
17054/// # .build()
17055/// # );
17056/// # let mut hub = VMMigrationService::new(client, auth);
17057/// // As the method needs a request, you would usually fill it with the desired information
17058/// // into the respective structure. Some of the parts shown here might not be applicable !
17059/// // Values shown here are possibly random and not representative !
17060/// let mut req = CutoverJob::default();
17061///
17062/// // You can configure optional parameters by calling the respective setters at will, and
17063/// // execute the final call using `doit()`.
17064/// // Values shown here are possibly random and not representative !
17065/// let result = hub.projects().locations_sources_migrating_vms_cutover_jobs_create(req, "parent")
17066/// .request_id("voluptua.")
17067/// .cutover_job_id("dolore")
17068/// .doit().await;
17069/// # }
17070/// ```
17071pub struct ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C>
17072where
17073 C: 'a,
17074{
17075 hub: &'a VMMigrationService<C>,
17076 _request: CutoverJob,
17077 _parent: String,
17078 _request_id: Option<String>,
17079 _cutover_job_id: Option<String>,
17080 _delegate: Option<&'a mut dyn common::Delegate>,
17081 _additional_params: HashMap<String, String>,
17082 _scopes: BTreeSet<String>,
17083}
17084
17085impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C> {}
17086
17087impl<'a, C> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C>
17088where
17089 C: common::Connector,
17090{
17091 /// Perform the operation you have build so far.
17092 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
17093 use std::borrow::Cow;
17094 use std::io::{Read, Seek};
17095
17096 use common::{url::Params, ToParts};
17097 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17098
17099 let mut dd = common::DefaultDelegate;
17100 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17101 dlg.begin(common::MethodInfo {
17102 id: "vmmigration.projects.locations.sources.migratingVms.cutoverJobs.create",
17103 http_method: hyper::Method::POST,
17104 });
17105
17106 for &field in ["alt", "parent", "requestId", "cutoverJobId"].iter() {
17107 if self._additional_params.contains_key(field) {
17108 dlg.finished(false);
17109 return Err(common::Error::FieldClash(field));
17110 }
17111 }
17112
17113 let mut params = Params::with_capacity(6 + self._additional_params.len());
17114 params.push("parent", self._parent);
17115 if let Some(value) = self._request_id.as_ref() {
17116 params.push("requestId", value);
17117 }
17118 if let Some(value) = self._cutover_job_id.as_ref() {
17119 params.push("cutoverJobId", value);
17120 }
17121
17122 params.extend(self._additional_params.iter());
17123
17124 params.push("alt", "json");
17125 let mut url = self.hub._base_url.clone() + "v1/{+parent}/cutoverJobs";
17126 if self._scopes.is_empty() {
17127 self._scopes
17128 .insert(Scope::CloudPlatform.as_ref().to_string());
17129 }
17130
17131 #[allow(clippy::single_element_loop)]
17132 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
17133 url = params.uri_replacement(url, param_name, find_this, true);
17134 }
17135 {
17136 let to_remove = ["parent"];
17137 params.remove_params(&to_remove);
17138 }
17139
17140 let url = params.parse_with_url(&url);
17141
17142 let mut json_mime_type = mime::APPLICATION_JSON;
17143 let mut request_value_reader = {
17144 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17145 common::remove_json_null_values(&mut value);
17146 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17147 serde_json::to_writer(&mut dst, &value).unwrap();
17148 dst
17149 };
17150 let request_size = request_value_reader
17151 .seek(std::io::SeekFrom::End(0))
17152 .unwrap();
17153 request_value_reader
17154 .seek(std::io::SeekFrom::Start(0))
17155 .unwrap();
17156
17157 loop {
17158 let token = match self
17159 .hub
17160 .auth
17161 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17162 .await
17163 {
17164 Ok(token) => token,
17165 Err(e) => match dlg.token(e) {
17166 Ok(token) => token,
17167 Err(e) => {
17168 dlg.finished(false);
17169 return Err(common::Error::MissingToken(e));
17170 }
17171 },
17172 };
17173 request_value_reader
17174 .seek(std::io::SeekFrom::Start(0))
17175 .unwrap();
17176 let mut req_result = {
17177 let client = &self.hub.client;
17178 dlg.pre_request();
17179 let mut req_builder = hyper::Request::builder()
17180 .method(hyper::Method::POST)
17181 .uri(url.as_str())
17182 .header(USER_AGENT, self.hub._user_agent.clone());
17183
17184 if let Some(token) = token.as_ref() {
17185 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17186 }
17187
17188 let request = req_builder
17189 .header(CONTENT_TYPE, json_mime_type.to_string())
17190 .header(CONTENT_LENGTH, request_size as u64)
17191 .body(common::to_body(
17192 request_value_reader.get_ref().clone().into(),
17193 ));
17194
17195 client.request(request.unwrap()).await
17196 };
17197
17198 match req_result {
17199 Err(err) => {
17200 if let common::Retry::After(d) = dlg.http_error(&err) {
17201 sleep(d).await;
17202 continue;
17203 }
17204 dlg.finished(false);
17205 return Err(common::Error::HttpError(err));
17206 }
17207 Ok(res) => {
17208 let (mut parts, body) = res.into_parts();
17209 let mut body = common::Body::new(body);
17210 if !parts.status.is_success() {
17211 let bytes = common::to_bytes(body).await.unwrap_or_default();
17212 let error = serde_json::from_str(&common::to_string(&bytes));
17213 let response = common::to_response(parts, bytes.into());
17214
17215 if let common::Retry::After(d) =
17216 dlg.http_failure(&response, error.as_ref().ok())
17217 {
17218 sleep(d).await;
17219 continue;
17220 }
17221
17222 dlg.finished(false);
17223
17224 return Err(match error {
17225 Ok(value) => common::Error::BadRequest(value),
17226 _ => common::Error::Failure(response),
17227 });
17228 }
17229 let response = {
17230 let bytes = common::to_bytes(body).await.unwrap_or_default();
17231 let encoded = common::to_string(&bytes);
17232 match serde_json::from_str(&encoded) {
17233 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17234 Err(error) => {
17235 dlg.response_json_decode_error(&encoded, &error);
17236 return Err(common::Error::JsonDecodeError(
17237 encoded.to_string(),
17238 error,
17239 ));
17240 }
17241 }
17242 };
17243
17244 dlg.finished(true);
17245 return Ok(response);
17246 }
17247 }
17248 }
17249 }
17250
17251 ///
17252 /// Sets the *request* property to the given value.
17253 ///
17254 /// Even though the property as already been set when instantiating this call,
17255 /// we provide this method for API completeness.
17256 pub fn request(
17257 mut self,
17258 new_value: CutoverJob,
17259 ) -> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C> {
17260 self._request = new_value;
17261 self
17262 }
17263 /// Required. The Cutover's parent.
17264 ///
17265 /// Sets the *parent* path property to the given value.
17266 ///
17267 /// Even though the property as already been set when instantiating this call,
17268 /// we provide this method for API completeness.
17269 pub fn parent(
17270 mut self,
17271 new_value: &str,
17272 ) -> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C> {
17273 self._parent = new_value.to_string();
17274 self
17275 }
17276 /// 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).
17277 ///
17278 /// Sets the *request id* query property to the given value.
17279 pub fn request_id(
17280 mut self,
17281 new_value: &str,
17282 ) -> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C> {
17283 self._request_id = Some(new_value.to_string());
17284 self
17285 }
17286 /// Required. The cutover job identifier.
17287 ///
17288 /// Sets the *cutover job id* query property to the given value.
17289 pub fn cutover_job_id(
17290 mut self,
17291 new_value: &str,
17292 ) -> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C> {
17293 self._cutover_job_id = Some(new_value.to_string());
17294 self
17295 }
17296 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17297 /// while executing the actual API request.
17298 ///
17299 /// ````text
17300 /// It should be used to handle progress information, and to implement a certain level of resilience.
17301 /// ````
17302 ///
17303 /// Sets the *delegate* property to the given value.
17304 pub fn delegate(
17305 mut self,
17306 new_value: &'a mut dyn common::Delegate,
17307 ) -> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C> {
17308 self._delegate = Some(new_value);
17309 self
17310 }
17311
17312 /// Set any additional parameter of the query string used in the request.
17313 /// It should be used to set parameters which are not yet available through their own
17314 /// setters.
17315 ///
17316 /// Please note that this method must not be used to set any of the known parameters
17317 /// which have their own setter method. If done anyway, the request will fail.
17318 ///
17319 /// # Additional Parameters
17320 ///
17321 /// * *$.xgafv* (query-string) - V1 error format.
17322 /// * *access_token* (query-string) - OAuth access token.
17323 /// * *alt* (query-string) - Data format for response.
17324 /// * *callback* (query-string) - JSONP
17325 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17326 /// * *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.
17327 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17328 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17329 /// * *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.
17330 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17331 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17332 pub fn param<T>(
17333 mut self,
17334 name: T,
17335 value: T,
17336 ) -> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C>
17337 where
17338 T: AsRef<str>,
17339 {
17340 self._additional_params
17341 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17342 self
17343 }
17344
17345 /// Identifies the authorization scope for the method you are building.
17346 ///
17347 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17348 /// [`Scope::CloudPlatform`].
17349 ///
17350 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17351 /// tokens for more than one scope.
17352 ///
17353 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17354 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17355 /// sufficient, a read-write scope will do as well.
17356 pub fn add_scope<St>(
17357 mut self,
17358 scope: St,
17359 ) -> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C>
17360 where
17361 St: AsRef<str>,
17362 {
17363 self._scopes.insert(String::from(scope.as_ref()));
17364 self
17365 }
17366 /// Identifies the authorization scope(s) for the method you are building.
17367 ///
17368 /// See [`Self::add_scope()`] for details.
17369 pub fn add_scopes<I, St>(
17370 mut self,
17371 scopes: I,
17372 ) -> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C>
17373 where
17374 I: IntoIterator<Item = St>,
17375 St: AsRef<str>,
17376 {
17377 self._scopes
17378 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17379 self
17380 }
17381
17382 /// Removes all scopes, and no default scope will be used either.
17383 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17384 /// for details).
17385 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmCutoverJobCreateCall<'a, C> {
17386 self._scopes.clear();
17387 self
17388 }
17389}
17390
17391/// Gets details of a single CutoverJob.
17392///
17393/// A builder for the *locations.sources.migratingVms.cutoverJobs.get* method supported by a *project* resource.
17394/// It is not used directly, but through a [`ProjectMethods`] instance.
17395///
17396/// # Example
17397///
17398/// Instantiate a resource method builder
17399///
17400/// ```test_harness,no_run
17401/// # extern crate hyper;
17402/// # extern crate hyper_rustls;
17403/// # extern crate google_vmmigration1 as vmmigration1;
17404/// # async fn dox() {
17405/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17406///
17407/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17408/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17409/// # .with_native_roots()
17410/// # .unwrap()
17411/// # .https_only()
17412/// # .enable_http2()
17413/// # .build();
17414///
17415/// # let executor = hyper_util::rt::TokioExecutor::new();
17416/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17417/// # secret,
17418/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17419/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17420/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17421/// # ),
17422/// # ).build().await.unwrap();
17423///
17424/// # let client = hyper_util::client::legacy::Client::builder(
17425/// # hyper_util::rt::TokioExecutor::new()
17426/// # )
17427/// # .build(
17428/// # hyper_rustls::HttpsConnectorBuilder::new()
17429/// # .with_native_roots()
17430/// # .unwrap()
17431/// # .https_or_http()
17432/// # .enable_http2()
17433/// # .build()
17434/// # );
17435/// # let mut hub = VMMigrationService::new(client, auth);
17436/// // You can configure optional parameters by calling the respective setters at will, and
17437/// // execute the final call using `doit()`.
17438/// // Values shown here are possibly random and not representative !
17439/// let result = hub.projects().locations_sources_migrating_vms_cutover_jobs_get("name")
17440/// .doit().await;
17441/// # }
17442/// ```
17443pub struct ProjectLocationSourceMigratingVmCutoverJobGetCall<'a, C>
17444where
17445 C: 'a,
17446{
17447 hub: &'a VMMigrationService<C>,
17448 _name: String,
17449 _delegate: Option<&'a mut dyn common::Delegate>,
17450 _additional_params: HashMap<String, String>,
17451 _scopes: BTreeSet<String>,
17452}
17453
17454impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmCutoverJobGetCall<'a, C> {}
17455
17456impl<'a, C> ProjectLocationSourceMigratingVmCutoverJobGetCall<'a, C>
17457where
17458 C: common::Connector,
17459{
17460 /// Perform the operation you have build so far.
17461 pub async fn doit(mut self) -> common::Result<(common::Response, CutoverJob)> {
17462 use std::borrow::Cow;
17463 use std::io::{Read, Seek};
17464
17465 use common::{url::Params, ToParts};
17466 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17467
17468 let mut dd = common::DefaultDelegate;
17469 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17470 dlg.begin(common::MethodInfo {
17471 id: "vmmigration.projects.locations.sources.migratingVms.cutoverJobs.get",
17472 http_method: hyper::Method::GET,
17473 });
17474
17475 for &field in ["alt", "name"].iter() {
17476 if self._additional_params.contains_key(field) {
17477 dlg.finished(false);
17478 return Err(common::Error::FieldClash(field));
17479 }
17480 }
17481
17482 let mut params = Params::with_capacity(3 + self._additional_params.len());
17483 params.push("name", self._name);
17484
17485 params.extend(self._additional_params.iter());
17486
17487 params.push("alt", "json");
17488 let mut url = self.hub._base_url.clone() + "v1/{+name}";
17489 if self._scopes.is_empty() {
17490 self._scopes
17491 .insert(Scope::CloudPlatform.as_ref().to_string());
17492 }
17493
17494 #[allow(clippy::single_element_loop)]
17495 for &(find_this, param_name) in [("{+name}", "name")].iter() {
17496 url = params.uri_replacement(url, param_name, find_this, true);
17497 }
17498 {
17499 let to_remove = ["name"];
17500 params.remove_params(&to_remove);
17501 }
17502
17503 let url = params.parse_with_url(&url);
17504
17505 loop {
17506 let token = match self
17507 .hub
17508 .auth
17509 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17510 .await
17511 {
17512 Ok(token) => token,
17513 Err(e) => match dlg.token(e) {
17514 Ok(token) => token,
17515 Err(e) => {
17516 dlg.finished(false);
17517 return Err(common::Error::MissingToken(e));
17518 }
17519 },
17520 };
17521 let mut req_result = {
17522 let client = &self.hub.client;
17523 dlg.pre_request();
17524 let mut req_builder = hyper::Request::builder()
17525 .method(hyper::Method::GET)
17526 .uri(url.as_str())
17527 .header(USER_AGENT, self.hub._user_agent.clone());
17528
17529 if let Some(token) = token.as_ref() {
17530 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17531 }
17532
17533 let request = req_builder
17534 .header(CONTENT_LENGTH, 0_u64)
17535 .body(common::to_body::<String>(None));
17536
17537 client.request(request.unwrap()).await
17538 };
17539
17540 match req_result {
17541 Err(err) => {
17542 if let common::Retry::After(d) = dlg.http_error(&err) {
17543 sleep(d).await;
17544 continue;
17545 }
17546 dlg.finished(false);
17547 return Err(common::Error::HttpError(err));
17548 }
17549 Ok(res) => {
17550 let (mut parts, body) = res.into_parts();
17551 let mut body = common::Body::new(body);
17552 if !parts.status.is_success() {
17553 let bytes = common::to_bytes(body).await.unwrap_or_default();
17554 let error = serde_json::from_str(&common::to_string(&bytes));
17555 let response = common::to_response(parts, bytes.into());
17556
17557 if let common::Retry::After(d) =
17558 dlg.http_failure(&response, error.as_ref().ok())
17559 {
17560 sleep(d).await;
17561 continue;
17562 }
17563
17564 dlg.finished(false);
17565
17566 return Err(match error {
17567 Ok(value) => common::Error::BadRequest(value),
17568 _ => common::Error::Failure(response),
17569 });
17570 }
17571 let response = {
17572 let bytes = common::to_bytes(body).await.unwrap_or_default();
17573 let encoded = common::to_string(&bytes);
17574 match serde_json::from_str(&encoded) {
17575 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17576 Err(error) => {
17577 dlg.response_json_decode_error(&encoded, &error);
17578 return Err(common::Error::JsonDecodeError(
17579 encoded.to_string(),
17580 error,
17581 ));
17582 }
17583 }
17584 };
17585
17586 dlg.finished(true);
17587 return Ok(response);
17588 }
17589 }
17590 }
17591 }
17592
17593 /// Required. The name of the CutoverJob.
17594 ///
17595 /// Sets the *name* path property to the given value.
17596 ///
17597 /// Even though the property as already been set when instantiating this call,
17598 /// we provide this method for API completeness.
17599 pub fn name(
17600 mut self,
17601 new_value: &str,
17602 ) -> ProjectLocationSourceMigratingVmCutoverJobGetCall<'a, C> {
17603 self._name = new_value.to_string();
17604 self
17605 }
17606 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17607 /// while executing the actual API request.
17608 ///
17609 /// ````text
17610 /// It should be used to handle progress information, and to implement a certain level of resilience.
17611 /// ````
17612 ///
17613 /// Sets the *delegate* property to the given value.
17614 pub fn delegate(
17615 mut self,
17616 new_value: &'a mut dyn common::Delegate,
17617 ) -> ProjectLocationSourceMigratingVmCutoverJobGetCall<'a, C> {
17618 self._delegate = Some(new_value);
17619 self
17620 }
17621
17622 /// Set any additional parameter of the query string used in the request.
17623 /// It should be used to set parameters which are not yet available through their own
17624 /// setters.
17625 ///
17626 /// Please note that this method must not be used to set any of the known parameters
17627 /// which have their own setter method. If done anyway, the request will fail.
17628 ///
17629 /// # Additional Parameters
17630 ///
17631 /// * *$.xgafv* (query-string) - V1 error format.
17632 /// * *access_token* (query-string) - OAuth access token.
17633 /// * *alt* (query-string) - Data format for response.
17634 /// * *callback* (query-string) - JSONP
17635 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17636 /// * *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.
17637 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17638 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17639 /// * *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.
17640 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17641 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17642 pub fn param<T>(
17643 mut self,
17644 name: T,
17645 value: T,
17646 ) -> ProjectLocationSourceMigratingVmCutoverJobGetCall<'a, C>
17647 where
17648 T: AsRef<str>,
17649 {
17650 self._additional_params
17651 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17652 self
17653 }
17654
17655 /// Identifies the authorization scope for the method you are building.
17656 ///
17657 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17658 /// [`Scope::CloudPlatform`].
17659 ///
17660 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17661 /// tokens for more than one scope.
17662 ///
17663 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17664 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17665 /// sufficient, a read-write scope will do as well.
17666 pub fn add_scope<St>(
17667 mut self,
17668 scope: St,
17669 ) -> ProjectLocationSourceMigratingVmCutoverJobGetCall<'a, C>
17670 where
17671 St: AsRef<str>,
17672 {
17673 self._scopes.insert(String::from(scope.as_ref()));
17674 self
17675 }
17676 /// Identifies the authorization scope(s) for the method you are building.
17677 ///
17678 /// See [`Self::add_scope()`] for details.
17679 pub fn add_scopes<I, St>(
17680 mut self,
17681 scopes: I,
17682 ) -> ProjectLocationSourceMigratingVmCutoverJobGetCall<'a, C>
17683 where
17684 I: IntoIterator<Item = St>,
17685 St: AsRef<str>,
17686 {
17687 self._scopes
17688 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17689 self
17690 }
17691
17692 /// Removes all scopes, and no default scope will be used either.
17693 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17694 /// for details).
17695 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmCutoverJobGetCall<'a, C> {
17696 self._scopes.clear();
17697 self
17698 }
17699}
17700
17701/// Lists the CutoverJobs of a migrating VM. Only 25 most recent CutoverJobs are listed.
17702///
17703/// A builder for the *locations.sources.migratingVms.cutoverJobs.list* method supported by a *project* resource.
17704/// It is not used directly, but through a [`ProjectMethods`] instance.
17705///
17706/// # Example
17707///
17708/// Instantiate a resource method builder
17709///
17710/// ```test_harness,no_run
17711/// # extern crate hyper;
17712/// # extern crate hyper_rustls;
17713/// # extern crate google_vmmigration1 as vmmigration1;
17714/// # async fn dox() {
17715/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17716///
17717/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17718/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17719/// # .with_native_roots()
17720/// # .unwrap()
17721/// # .https_only()
17722/// # .enable_http2()
17723/// # .build();
17724///
17725/// # let executor = hyper_util::rt::TokioExecutor::new();
17726/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17727/// # secret,
17728/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17729/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17730/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17731/// # ),
17732/// # ).build().await.unwrap();
17733///
17734/// # let client = hyper_util::client::legacy::Client::builder(
17735/// # hyper_util::rt::TokioExecutor::new()
17736/// # )
17737/// # .build(
17738/// # hyper_rustls::HttpsConnectorBuilder::new()
17739/// # .with_native_roots()
17740/// # .unwrap()
17741/// # .https_or_http()
17742/// # .enable_http2()
17743/// # .build()
17744/// # );
17745/// # let mut hub = VMMigrationService::new(client, auth);
17746/// // You can configure optional parameters by calling the respective setters at will, and
17747/// // execute the final call using `doit()`.
17748/// // Values shown here are possibly random and not representative !
17749/// let result = hub.projects().locations_sources_migrating_vms_cutover_jobs_list("parent")
17750/// .page_token("voluptua.")
17751/// .page_size(-2)
17752/// .order_by("ea")
17753/// .filter("sadipscing")
17754/// .doit().await;
17755/// # }
17756/// ```
17757pub struct ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C>
17758where
17759 C: 'a,
17760{
17761 hub: &'a VMMigrationService<C>,
17762 _parent: String,
17763 _page_token: Option<String>,
17764 _page_size: Option<i32>,
17765 _order_by: Option<String>,
17766 _filter: Option<String>,
17767 _delegate: Option<&'a mut dyn common::Delegate>,
17768 _additional_params: HashMap<String, String>,
17769 _scopes: BTreeSet<String>,
17770}
17771
17772impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C> {}
17773
17774impl<'a, C> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C>
17775where
17776 C: common::Connector,
17777{
17778 /// Perform the operation you have build so far.
17779 pub async fn doit(mut self) -> common::Result<(common::Response, ListCutoverJobsResponse)> {
17780 use std::borrow::Cow;
17781 use std::io::{Read, Seek};
17782
17783 use common::{url::Params, ToParts};
17784 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17785
17786 let mut dd = common::DefaultDelegate;
17787 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17788 dlg.begin(common::MethodInfo {
17789 id: "vmmigration.projects.locations.sources.migratingVms.cutoverJobs.list",
17790 http_method: hyper::Method::GET,
17791 });
17792
17793 for &field in [
17794 "alt",
17795 "parent",
17796 "pageToken",
17797 "pageSize",
17798 "orderBy",
17799 "filter",
17800 ]
17801 .iter()
17802 {
17803 if self._additional_params.contains_key(field) {
17804 dlg.finished(false);
17805 return Err(common::Error::FieldClash(field));
17806 }
17807 }
17808
17809 let mut params = Params::with_capacity(7 + self._additional_params.len());
17810 params.push("parent", self._parent);
17811 if let Some(value) = self._page_token.as_ref() {
17812 params.push("pageToken", value);
17813 }
17814 if let Some(value) = self._page_size.as_ref() {
17815 params.push("pageSize", value.to_string());
17816 }
17817 if let Some(value) = self._order_by.as_ref() {
17818 params.push("orderBy", value);
17819 }
17820 if let Some(value) = self._filter.as_ref() {
17821 params.push("filter", value);
17822 }
17823
17824 params.extend(self._additional_params.iter());
17825
17826 params.push("alt", "json");
17827 let mut url = self.hub._base_url.clone() + "v1/{+parent}/cutoverJobs";
17828 if self._scopes.is_empty() {
17829 self._scopes
17830 .insert(Scope::CloudPlatform.as_ref().to_string());
17831 }
17832
17833 #[allow(clippy::single_element_loop)]
17834 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
17835 url = params.uri_replacement(url, param_name, find_this, true);
17836 }
17837 {
17838 let to_remove = ["parent"];
17839 params.remove_params(&to_remove);
17840 }
17841
17842 let url = params.parse_with_url(&url);
17843
17844 loop {
17845 let token = match self
17846 .hub
17847 .auth
17848 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17849 .await
17850 {
17851 Ok(token) => token,
17852 Err(e) => match dlg.token(e) {
17853 Ok(token) => token,
17854 Err(e) => {
17855 dlg.finished(false);
17856 return Err(common::Error::MissingToken(e));
17857 }
17858 },
17859 };
17860 let mut req_result = {
17861 let client = &self.hub.client;
17862 dlg.pre_request();
17863 let mut req_builder = hyper::Request::builder()
17864 .method(hyper::Method::GET)
17865 .uri(url.as_str())
17866 .header(USER_AGENT, self.hub._user_agent.clone());
17867
17868 if let Some(token) = token.as_ref() {
17869 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17870 }
17871
17872 let request = req_builder
17873 .header(CONTENT_LENGTH, 0_u64)
17874 .body(common::to_body::<String>(None));
17875
17876 client.request(request.unwrap()).await
17877 };
17878
17879 match req_result {
17880 Err(err) => {
17881 if let common::Retry::After(d) = dlg.http_error(&err) {
17882 sleep(d).await;
17883 continue;
17884 }
17885 dlg.finished(false);
17886 return Err(common::Error::HttpError(err));
17887 }
17888 Ok(res) => {
17889 let (mut parts, body) = res.into_parts();
17890 let mut body = common::Body::new(body);
17891 if !parts.status.is_success() {
17892 let bytes = common::to_bytes(body).await.unwrap_or_default();
17893 let error = serde_json::from_str(&common::to_string(&bytes));
17894 let response = common::to_response(parts, bytes.into());
17895
17896 if let common::Retry::After(d) =
17897 dlg.http_failure(&response, error.as_ref().ok())
17898 {
17899 sleep(d).await;
17900 continue;
17901 }
17902
17903 dlg.finished(false);
17904
17905 return Err(match error {
17906 Ok(value) => common::Error::BadRequest(value),
17907 _ => common::Error::Failure(response),
17908 });
17909 }
17910 let response = {
17911 let bytes = common::to_bytes(body).await.unwrap_or_default();
17912 let encoded = common::to_string(&bytes);
17913 match serde_json::from_str(&encoded) {
17914 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17915 Err(error) => {
17916 dlg.response_json_decode_error(&encoded, &error);
17917 return Err(common::Error::JsonDecodeError(
17918 encoded.to_string(),
17919 error,
17920 ));
17921 }
17922 }
17923 };
17924
17925 dlg.finished(true);
17926 return Ok(response);
17927 }
17928 }
17929 }
17930 }
17931
17932 /// Required. The parent, which owns this collection of migrating VMs.
17933 ///
17934 /// Sets the *parent* path property to the given value.
17935 ///
17936 /// Even though the property as already been set when instantiating this call,
17937 /// we provide this method for API completeness.
17938 pub fn parent(
17939 mut self,
17940 new_value: &str,
17941 ) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C> {
17942 self._parent = new_value.to_string();
17943 self
17944 }
17945 /// 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.
17946 ///
17947 /// Sets the *page token* query property to the given value.
17948 pub fn page_token(
17949 mut self,
17950 new_value: &str,
17951 ) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C> {
17952 self._page_token = Some(new_value.to_string());
17953 self
17954 }
17955 /// 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.
17956 ///
17957 /// Sets the *page size* query property to the given value.
17958 pub fn page_size(
17959 mut self,
17960 new_value: i32,
17961 ) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C> {
17962 self._page_size = Some(new_value);
17963 self
17964 }
17965 /// Optional. the order by fields for the result.
17966 ///
17967 /// Sets the *order by* query property to the given value.
17968 pub fn order_by(
17969 mut self,
17970 new_value: &str,
17971 ) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C> {
17972 self._order_by = Some(new_value.to_string());
17973 self
17974 }
17975 /// Optional. The filter request.
17976 ///
17977 /// Sets the *filter* query property to the given value.
17978 pub fn filter(
17979 mut self,
17980 new_value: &str,
17981 ) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C> {
17982 self._filter = Some(new_value.to_string());
17983 self
17984 }
17985 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17986 /// while executing the actual API request.
17987 ///
17988 /// ````text
17989 /// It should be used to handle progress information, and to implement a certain level of resilience.
17990 /// ````
17991 ///
17992 /// Sets the *delegate* property to the given value.
17993 pub fn delegate(
17994 mut self,
17995 new_value: &'a mut dyn common::Delegate,
17996 ) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C> {
17997 self._delegate = Some(new_value);
17998 self
17999 }
18000
18001 /// Set any additional parameter of the query string used in the request.
18002 /// It should be used to set parameters which are not yet available through their own
18003 /// setters.
18004 ///
18005 /// Please note that this method must not be used to set any of the known parameters
18006 /// which have their own setter method. If done anyway, the request will fail.
18007 ///
18008 /// # Additional Parameters
18009 ///
18010 /// * *$.xgafv* (query-string) - V1 error format.
18011 /// * *access_token* (query-string) - OAuth access token.
18012 /// * *alt* (query-string) - Data format for response.
18013 /// * *callback* (query-string) - JSONP
18014 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18015 /// * *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.
18016 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18017 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18018 /// * *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.
18019 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18020 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18021 pub fn param<T>(
18022 mut self,
18023 name: T,
18024 value: T,
18025 ) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C>
18026 where
18027 T: AsRef<str>,
18028 {
18029 self._additional_params
18030 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18031 self
18032 }
18033
18034 /// Identifies the authorization scope for the method you are building.
18035 ///
18036 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18037 /// [`Scope::CloudPlatform`].
18038 ///
18039 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18040 /// tokens for more than one scope.
18041 ///
18042 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18043 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18044 /// sufficient, a read-write scope will do as well.
18045 pub fn add_scope<St>(
18046 mut self,
18047 scope: St,
18048 ) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C>
18049 where
18050 St: AsRef<str>,
18051 {
18052 self._scopes.insert(String::from(scope.as_ref()));
18053 self
18054 }
18055 /// Identifies the authorization scope(s) for the method you are building.
18056 ///
18057 /// See [`Self::add_scope()`] for details.
18058 pub fn add_scopes<I, St>(
18059 mut self,
18060 scopes: I,
18061 ) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C>
18062 where
18063 I: IntoIterator<Item = St>,
18064 St: AsRef<str>,
18065 {
18066 self._scopes
18067 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18068 self
18069 }
18070
18071 /// Removes all scopes, and no default scope will be used either.
18072 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18073 /// for details).
18074 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmCutoverJobListCall<'a, C> {
18075 self._scopes.clear();
18076 self
18077 }
18078}
18079
18080/// Gets details of a single ReplicationCycle.
18081///
18082/// A builder for the *locations.sources.migratingVms.replicationCycles.get* method supported by a *project* resource.
18083/// It is not used directly, but through a [`ProjectMethods`] instance.
18084///
18085/// # Example
18086///
18087/// Instantiate a resource method builder
18088///
18089/// ```test_harness,no_run
18090/// # extern crate hyper;
18091/// # extern crate hyper_rustls;
18092/// # extern crate google_vmmigration1 as vmmigration1;
18093/// # async fn dox() {
18094/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18095///
18096/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18097/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18098/// # .with_native_roots()
18099/// # .unwrap()
18100/// # .https_only()
18101/// # .enable_http2()
18102/// # .build();
18103///
18104/// # let executor = hyper_util::rt::TokioExecutor::new();
18105/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18106/// # secret,
18107/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18108/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18109/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18110/// # ),
18111/// # ).build().await.unwrap();
18112///
18113/// # let client = hyper_util::client::legacy::Client::builder(
18114/// # hyper_util::rt::TokioExecutor::new()
18115/// # )
18116/// # .build(
18117/// # hyper_rustls::HttpsConnectorBuilder::new()
18118/// # .with_native_roots()
18119/// # .unwrap()
18120/// # .https_or_http()
18121/// # .enable_http2()
18122/// # .build()
18123/// # );
18124/// # let mut hub = VMMigrationService::new(client, auth);
18125/// // You can configure optional parameters by calling the respective setters at will, and
18126/// // execute the final call using `doit()`.
18127/// // Values shown here are possibly random and not representative !
18128/// let result = hub.projects().locations_sources_migrating_vms_replication_cycles_get("name")
18129/// .doit().await;
18130/// # }
18131/// ```
18132pub struct ProjectLocationSourceMigratingVmReplicationCycleGetCall<'a, C>
18133where
18134 C: 'a,
18135{
18136 hub: &'a VMMigrationService<C>,
18137 _name: String,
18138 _delegate: Option<&'a mut dyn common::Delegate>,
18139 _additional_params: HashMap<String, String>,
18140 _scopes: BTreeSet<String>,
18141}
18142
18143impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmReplicationCycleGetCall<'a, C> {}
18144
18145impl<'a, C> ProjectLocationSourceMigratingVmReplicationCycleGetCall<'a, C>
18146where
18147 C: common::Connector,
18148{
18149 /// Perform the operation you have build so far.
18150 pub async fn doit(mut self) -> common::Result<(common::Response, ReplicationCycle)> {
18151 use std::borrow::Cow;
18152 use std::io::{Read, Seek};
18153
18154 use common::{url::Params, ToParts};
18155 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18156
18157 let mut dd = common::DefaultDelegate;
18158 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18159 dlg.begin(common::MethodInfo {
18160 id: "vmmigration.projects.locations.sources.migratingVms.replicationCycles.get",
18161 http_method: hyper::Method::GET,
18162 });
18163
18164 for &field in ["alt", "name"].iter() {
18165 if self._additional_params.contains_key(field) {
18166 dlg.finished(false);
18167 return Err(common::Error::FieldClash(field));
18168 }
18169 }
18170
18171 let mut params = Params::with_capacity(3 + self._additional_params.len());
18172 params.push("name", self._name);
18173
18174 params.extend(self._additional_params.iter());
18175
18176 params.push("alt", "json");
18177 let mut url = self.hub._base_url.clone() + "v1/{+name}";
18178 if self._scopes.is_empty() {
18179 self._scopes
18180 .insert(Scope::CloudPlatform.as_ref().to_string());
18181 }
18182
18183 #[allow(clippy::single_element_loop)]
18184 for &(find_this, param_name) in [("{+name}", "name")].iter() {
18185 url = params.uri_replacement(url, param_name, find_this, true);
18186 }
18187 {
18188 let to_remove = ["name"];
18189 params.remove_params(&to_remove);
18190 }
18191
18192 let url = params.parse_with_url(&url);
18193
18194 loop {
18195 let token = match self
18196 .hub
18197 .auth
18198 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18199 .await
18200 {
18201 Ok(token) => token,
18202 Err(e) => match dlg.token(e) {
18203 Ok(token) => token,
18204 Err(e) => {
18205 dlg.finished(false);
18206 return Err(common::Error::MissingToken(e));
18207 }
18208 },
18209 };
18210 let mut req_result = {
18211 let client = &self.hub.client;
18212 dlg.pre_request();
18213 let mut req_builder = hyper::Request::builder()
18214 .method(hyper::Method::GET)
18215 .uri(url.as_str())
18216 .header(USER_AGENT, self.hub._user_agent.clone());
18217
18218 if let Some(token) = token.as_ref() {
18219 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18220 }
18221
18222 let request = req_builder
18223 .header(CONTENT_LENGTH, 0_u64)
18224 .body(common::to_body::<String>(None));
18225
18226 client.request(request.unwrap()).await
18227 };
18228
18229 match req_result {
18230 Err(err) => {
18231 if let common::Retry::After(d) = dlg.http_error(&err) {
18232 sleep(d).await;
18233 continue;
18234 }
18235 dlg.finished(false);
18236 return Err(common::Error::HttpError(err));
18237 }
18238 Ok(res) => {
18239 let (mut parts, body) = res.into_parts();
18240 let mut body = common::Body::new(body);
18241 if !parts.status.is_success() {
18242 let bytes = common::to_bytes(body).await.unwrap_or_default();
18243 let error = serde_json::from_str(&common::to_string(&bytes));
18244 let response = common::to_response(parts, bytes.into());
18245
18246 if let common::Retry::After(d) =
18247 dlg.http_failure(&response, error.as_ref().ok())
18248 {
18249 sleep(d).await;
18250 continue;
18251 }
18252
18253 dlg.finished(false);
18254
18255 return Err(match error {
18256 Ok(value) => common::Error::BadRequest(value),
18257 _ => common::Error::Failure(response),
18258 });
18259 }
18260 let response = {
18261 let bytes = common::to_bytes(body).await.unwrap_or_default();
18262 let encoded = common::to_string(&bytes);
18263 match serde_json::from_str(&encoded) {
18264 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18265 Err(error) => {
18266 dlg.response_json_decode_error(&encoded, &error);
18267 return Err(common::Error::JsonDecodeError(
18268 encoded.to_string(),
18269 error,
18270 ));
18271 }
18272 }
18273 };
18274
18275 dlg.finished(true);
18276 return Ok(response);
18277 }
18278 }
18279 }
18280 }
18281
18282 /// Required. The name of the ReplicationCycle.
18283 ///
18284 /// Sets the *name* path property to the given value.
18285 ///
18286 /// Even though the property as already been set when instantiating this call,
18287 /// we provide this method for API completeness.
18288 pub fn name(
18289 mut self,
18290 new_value: &str,
18291 ) -> ProjectLocationSourceMigratingVmReplicationCycleGetCall<'a, C> {
18292 self._name = new_value.to_string();
18293 self
18294 }
18295 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18296 /// while executing the actual API request.
18297 ///
18298 /// ````text
18299 /// It should be used to handle progress information, and to implement a certain level of resilience.
18300 /// ````
18301 ///
18302 /// Sets the *delegate* property to the given value.
18303 pub fn delegate(
18304 mut self,
18305 new_value: &'a mut dyn common::Delegate,
18306 ) -> ProjectLocationSourceMigratingVmReplicationCycleGetCall<'a, C> {
18307 self._delegate = Some(new_value);
18308 self
18309 }
18310
18311 /// Set any additional parameter of the query string used in the request.
18312 /// It should be used to set parameters which are not yet available through their own
18313 /// setters.
18314 ///
18315 /// Please note that this method must not be used to set any of the known parameters
18316 /// which have their own setter method. If done anyway, the request will fail.
18317 ///
18318 /// # Additional Parameters
18319 ///
18320 /// * *$.xgafv* (query-string) - V1 error format.
18321 /// * *access_token* (query-string) - OAuth access token.
18322 /// * *alt* (query-string) - Data format for response.
18323 /// * *callback* (query-string) - JSONP
18324 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18325 /// * *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.
18326 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18327 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18328 /// * *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.
18329 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18330 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18331 pub fn param<T>(
18332 mut self,
18333 name: T,
18334 value: T,
18335 ) -> ProjectLocationSourceMigratingVmReplicationCycleGetCall<'a, C>
18336 where
18337 T: AsRef<str>,
18338 {
18339 self._additional_params
18340 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18341 self
18342 }
18343
18344 /// Identifies the authorization scope for the method you are building.
18345 ///
18346 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18347 /// [`Scope::CloudPlatform`].
18348 ///
18349 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18350 /// tokens for more than one scope.
18351 ///
18352 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18353 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18354 /// sufficient, a read-write scope will do as well.
18355 pub fn add_scope<St>(
18356 mut self,
18357 scope: St,
18358 ) -> ProjectLocationSourceMigratingVmReplicationCycleGetCall<'a, C>
18359 where
18360 St: AsRef<str>,
18361 {
18362 self._scopes.insert(String::from(scope.as_ref()));
18363 self
18364 }
18365 /// Identifies the authorization scope(s) for the method you are building.
18366 ///
18367 /// See [`Self::add_scope()`] for details.
18368 pub fn add_scopes<I, St>(
18369 mut self,
18370 scopes: I,
18371 ) -> ProjectLocationSourceMigratingVmReplicationCycleGetCall<'a, C>
18372 where
18373 I: IntoIterator<Item = St>,
18374 St: AsRef<str>,
18375 {
18376 self._scopes
18377 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18378 self
18379 }
18380
18381 /// Removes all scopes, and no default scope will be used either.
18382 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18383 /// for details).
18384 pub fn clear_scopes(
18385 mut self,
18386 ) -> ProjectLocationSourceMigratingVmReplicationCycleGetCall<'a, C> {
18387 self._scopes.clear();
18388 self
18389 }
18390}
18391
18392/// Lists ReplicationCycles in a given MigratingVM.
18393///
18394/// A builder for the *locations.sources.migratingVms.replicationCycles.list* method supported by a *project* resource.
18395/// It is not used directly, but through a [`ProjectMethods`] instance.
18396///
18397/// # Example
18398///
18399/// Instantiate a resource method builder
18400///
18401/// ```test_harness,no_run
18402/// # extern crate hyper;
18403/// # extern crate hyper_rustls;
18404/// # extern crate google_vmmigration1 as vmmigration1;
18405/// # async fn dox() {
18406/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18407///
18408/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18409/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18410/// # .with_native_roots()
18411/// # .unwrap()
18412/// # .https_only()
18413/// # .enable_http2()
18414/// # .build();
18415///
18416/// # let executor = hyper_util::rt::TokioExecutor::new();
18417/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18418/// # secret,
18419/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18420/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18421/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18422/// # ),
18423/// # ).build().await.unwrap();
18424///
18425/// # let client = hyper_util::client::legacy::Client::builder(
18426/// # hyper_util::rt::TokioExecutor::new()
18427/// # )
18428/// # .build(
18429/// # hyper_rustls::HttpsConnectorBuilder::new()
18430/// # .with_native_roots()
18431/// # .unwrap()
18432/// # .https_or_http()
18433/// # .enable_http2()
18434/// # .build()
18435/// # );
18436/// # let mut hub = VMMigrationService::new(client, auth);
18437/// // You can configure optional parameters by calling the respective setters at will, and
18438/// // execute the final call using `doit()`.
18439/// // Values shown here are possibly random and not representative !
18440/// let result = hub.projects().locations_sources_migrating_vms_replication_cycles_list("parent")
18441/// .page_token("no")
18442/// .page_size(-7)
18443/// .order_by("At")
18444/// .filter("sed")
18445/// .doit().await;
18446/// # }
18447/// ```
18448pub struct ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C>
18449where
18450 C: 'a,
18451{
18452 hub: &'a VMMigrationService<C>,
18453 _parent: String,
18454 _page_token: Option<String>,
18455 _page_size: Option<i32>,
18456 _order_by: Option<String>,
18457 _filter: Option<String>,
18458 _delegate: Option<&'a mut dyn common::Delegate>,
18459 _additional_params: HashMap<String, String>,
18460 _scopes: BTreeSet<String>,
18461}
18462
18463impl<'a, C> common::CallBuilder
18464 for ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C>
18465{
18466}
18467
18468impl<'a, C> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C>
18469where
18470 C: common::Connector,
18471{
18472 /// Perform the operation you have build so far.
18473 pub async fn doit(
18474 mut self,
18475 ) -> common::Result<(common::Response, ListReplicationCyclesResponse)> {
18476 use std::borrow::Cow;
18477 use std::io::{Read, Seek};
18478
18479 use common::{url::Params, ToParts};
18480 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18481
18482 let mut dd = common::DefaultDelegate;
18483 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18484 dlg.begin(common::MethodInfo {
18485 id: "vmmigration.projects.locations.sources.migratingVms.replicationCycles.list",
18486 http_method: hyper::Method::GET,
18487 });
18488
18489 for &field in [
18490 "alt",
18491 "parent",
18492 "pageToken",
18493 "pageSize",
18494 "orderBy",
18495 "filter",
18496 ]
18497 .iter()
18498 {
18499 if self._additional_params.contains_key(field) {
18500 dlg.finished(false);
18501 return Err(common::Error::FieldClash(field));
18502 }
18503 }
18504
18505 let mut params = Params::with_capacity(7 + self._additional_params.len());
18506 params.push("parent", self._parent);
18507 if let Some(value) = self._page_token.as_ref() {
18508 params.push("pageToken", value);
18509 }
18510 if let Some(value) = self._page_size.as_ref() {
18511 params.push("pageSize", value.to_string());
18512 }
18513 if let Some(value) = self._order_by.as_ref() {
18514 params.push("orderBy", value);
18515 }
18516 if let Some(value) = self._filter.as_ref() {
18517 params.push("filter", value);
18518 }
18519
18520 params.extend(self._additional_params.iter());
18521
18522 params.push("alt", "json");
18523 let mut url = self.hub._base_url.clone() + "v1/{+parent}/replicationCycles";
18524 if self._scopes.is_empty() {
18525 self._scopes
18526 .insert(Scope::CloudPlatform.as_ref().to_string());
18527 }
18528
18529 #[allow(clippy::single_element_loop)]
18530 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
18531 url = params.uri_replacement(url, param_name, find_this, true);
18532 }
18533 {
18534 let to_remove = ["parent"];
18535 params.remove_params(&to_remove);
18536 }
18537
18538 let url = params.parse_with_url(&url);
18539
18540 loop {
18541 let token = match self
18542 .hub
18543 .auth
18544 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18545 .await
18546 {
18547 Ok(token) => token,
18548 Err(e) => match dlg.token(e) {
18549 Ok(token) => token,
18550 Err(e) => {
18551 dlg.finished(false);
18552 return Err(common::Error::MissingToken(e));
18553 }
18554 },
18555 };
18556 let mut req_result = {
18557 let client = &self.hub.client;
18558 dlg.pre_request();
18559 let mut req_builder = hyper::Request::builder()
18560 .method(hyper::Method::GET)
18561 .uri(url.as_str())
18562 .header(USER_AGENT, self.hub._user_agent.clone());
18563
18564 if let Some(token) = token.as_ref() {
18565 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18566 }
18567
18568 let request = req_builder
18569 .header(CONTENT_LENGTH, 0_u64)
18570 .body(common::to_body::<String>(None));
18571
18572 client.request(request.unwrap()).await
18573 };
18574
18575 match req_result {
18576 Err(err) => {
18577 if let common::Retry::After(d) = dlg.http_error(&err) {
18578 sleep(d).await;
18579 continue;
18580 }
18581 dlg.finished(false);
18582 return Err(common::Error::HttpError(err));
18583 }
18584 Ok(res) => {
18585 let (mut parts, body) = res.into_parts();
18586 let mut body = common::Body::new(body);
18587 if !parts.status.is_success() {
18588 let bytes = common::to_bytes(body).await.unwrap_or_default();
18589 let error = serde_json::from_str(&common::to_string(&bytes));
18590 let response = common::to_response(parts, bytes.into());
18591
18592 if let common::Retry::After(d) =
18593 dlg.http_failure(&response, error.as_ref().ok())
18594 {
18595 sleep(d).await;
18596 continue;
18597 }
18598
18599 dlg.finished(false);
18600
18601 return Err(match error {
18602 Ok(value) => common::Error::BadRequest(value),
18603 _ => common::Error::Failure(response),
18604 });
18605 }
18606 let response = {
18607 let bytes = common::to_bytes(body).await.unwrap_or_default();
18608 let encoded = common::to_string(&bytes);
18609 match serde_json::from_str(&encoded) {
18610 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18611 Err(error) => {
18612 dlg.response_json_decode_error(&encoded, &error);
18613 return Err(common::Error::JsonDecodeError(
18614 encoded.to_string(),
18615 error,
18616 ));
18617 }
18618 }
18619 };
18620
18621 dlg.finished(true);
18622 return Ok(response);
18623 }
18624 }
18625 }
18626 }
18627
18628 /// Required. The parent, which owns this collection of ReplicationCycles.
18629 ///
18630 /// Sets the *parent* path property to the given value.
18631 ///
18632 /// Even though the property as already been set when instantiating this call,
18633 /// we provide this method for API completeness.
18634 pub fn parent(
18635 mut self,
18636 new_value: &str,
18637 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C> {
18638 self._parent = new_value.to_string();
18639 self
18640 }
18641 /// 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.
18642 ///
18643 /// Sets the *page token* query property to the given value.
18644 pub fn page_token(
18645 mut self,
18646 new_value: &str,
18647 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C> {
18648 self._page_token = Some(new_value.to_string());
18649 self
18650 }
18651 /// 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.
18652 ///
18653 /// Sets the *page size* query property to the given value.
18654 pub fn page_size(
18655 mut self,
18656 new_value: i32,
18657 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C> {
18658 self._page_size = Some(new_value);
18659 self
18660 }
18661 /// Optional. the order by fields for the result.
18662 ///
18663 /// Sets the *order by* query property to the given value.
18664 pub fn order_by(
18665 mut self,
18666 new_value: &str,
18667 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C> {
18668 self._order_by = Some(new_value.to_string());
18669 self
18670 }
18671 /// Optional. The filter request.
18672 ///
18673 /// Sets the *filter* query property to the given value.
18674 pub fn filter(
18675 mut self,
18676 new_value: &str,
18677 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C> {
18678 self._filter = Some(new_value.to_string());
18679 self
18680 }
18681 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18682 /// while executing the actual API request.
18683 ///
18684 /// ````text
18685 /// It should be used to handle progress information, and to implement a certain level of resilience.
18686 /// ````
18687 ///
18688 /// Sets the *delegate* property to the given value.
18689 pub fn delegate(
18690 mut self,
18691 new_value: &'a mut dyn common::Delegate,
18692 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C> {
18693 self._delegate = Some(new_value);
18694 self
18695 }
18696
18697 /// Set any additional parameter of the query string used in the request.
18698 /// It should be used to set parameters which are not yet available through their own
18699 /// setters.
18700 ///
18701 /// Please note that this method must not be used to set any of the known parameters
18702 /// which have their own setter method. If done anyway, the request will fail.
18703 ///
18704 /// # Additional Parameters
18705 ///
18706 /// * *$.xgafv* (query-string) - V1 error format.
18707 /// * *access_token* (query-string) - OAuth access token.
18708 /// * *alt* (query-string) - Data format for response.
18709 /// * *callback* (query-string) - JSONP
18710 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18711 /// * *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.
18712 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18713 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18714 /// * *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.
18715 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18716 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18717 pub fn param<T>(
18718 mut self,
18719 name: T,
18720 value: T,
18721 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C>
18722 where
18723 T: AsRef<str>,
18724 {
18725 self._additional_params
18726 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18727 self
18728 }
18729
18730 /// Identifies the authorization scope for the method you are building.
18731 ///
18732 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18733 /// [`Scope::CloudPlatform`].
18734 ///
18735 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18736 /// tokens for more than one scope.
18737 ///
18738 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18739 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18740 /// sufficient, a read-write scope will do as well.
18741 pub fn add_scope<St>(
18742 mut self,
18743 scope: St,
18744 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C>
18745 where
18746 St: AsRef<str>,
18747 {
18748 self._scopes.insert(String::from(scope.as_ref()));
18749 self
18750 }
18751 /// Identifies the authorization scope(s) for the method you are building.
18752 ///
18753 /// See [`Self::add_scope()`] for details.
18754 pub fn add_scopes<I, St>(
18755 mut self,
18756 scopes: I,
18757 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C>
18758 where
18759 I: IntoIterator<Item = St>,
18760 St: AsRef<str>,
18761 {
18762 self._scopes
18763 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18764 self
18765 }
18766
18767 /// Removes all scopes, and no default scope will be used either.
18768 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18769 /// for details).
18770 pub fn clear_scopes(
18771 mut self,
18772 ) -> ProjectLocationSourceMigratingVmReplicationCycleListCall<'a, C> {
18773 self._scopes.clear();
18774 self
18775 }
18776}
18777
18778/// Creates a new MigratingVm in a given Source.
18779///
18780/// A builder for the *locations.sources.migratingVms.create* method supported by a *project* resource.
18781/// It is not used directly, but through a [`ProjectMethods`] instance.
18782///
18783/// # Example
18784///
18785/// Instantiate a resource method builder
18786///
18787/// ```test_harness,no_run
18788/// # extern crate hyper;
18789/// # extern crate hyper_rustls;
18790/// # extern crate google_vmmigration1 as vmmigration1;
18791/// use vmmigration1::api::MigratingVm;
18792/// # async fn dox() {
18793/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18794///
18795/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18796/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18797/// # .with_native_roots()
18798/// # .unwrap()
18799/// # .https_only()
18800/// # .enable_http2()
18801/// # .build();
18802///
18803/// # let executor = hyper_util::rt::TokioExecutor::new();
18804/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18805/// # secret,
18806/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18807/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18808/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18809/// # ),
18810/// # ).build().await.unwrap();
18811///
18812/// # let client = hyper_util::client::legacy::Client::builder(
18813/// # hyper_util::rt::TokioExecutor::new()
18814/// # )
18815/// # .build(
18816/// # hyper_rustls::HttpsConnectorBuilder::new()
18817/// # .with_native_roots()
18818/// # .unwrap()
18819/// # .https_or_http()
18820/// # .enable_http2()
18821/// # .build()
18822/// # );
18823/// # let mut hub = VMMigrationService::new(client, auth);
18824/// // As the method needs a request, you would usually fill it with the desired information
18825/// // into the respective structure. Some of the parts shown here might not be applicable !
18826/// // Values shown here are possibly random and not representative !
18827/// let mut req = MigratingVm::default();
18828///
18829/// // You can configure optional parameters by calling the respective setters at will, and
18830/// // execute the final call using `doit()`.
18831/// // Values shown here are possibly random and not representative !
18832/// let result = hub.projects().locations_sources_migrating_vms_create(req, "parent")
18833/// .request_id("et")
18834/// .migrating_vm_id("tempor")
18835/// .doit().await;
18836/// # }
18837/// ```
18838pub struct ProjectLocationSourceMigratingVmCreateCall<'a, C>
18839where
18840 C: 'a,
18841{
18842 hub: &'a VMMigrationService<C>,
18843 _request: MigratingVm,
18844 _parent: String,
18845 _request_id: Option<String>,
18846 _migrating_vm_id: Option<String>,
18847 _delegate: Option<&'a mut dyn common::Delegate>,
18848 _additional_params: HashMap<String, String>,
18849 _scopes: BTreeSet<String>,
18850}
18851
18852impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmCreateCall<'a, C> {}
18853
18854impl<'a, C> ProjectLocationSourceMigratingVmCreateCall<'a, C>
18855where
18856 C: common::Connector,
18857{
18858 /// Perform the operation you have build so far.
18859 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
18860 use std::borrow::Cow;
18861 use std::io::{Read, Seek};
18862
18863 use common::{url::Params, ToParts};
18864 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18865
18866 let mut dd = common::DefaultDelegate;
18867 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18868 dlg.begin(common::MethodInfo {
18869 id: "vmmigration.projects.locations.sources.migratingVms.create",
18870 http_method: hyper::Method::POST,
18871 });
18872
18873 for &field in ["alt", "parent", "requestId", "migratingVmId"].iter() {
18874 if self._additional_params.contains_key(field) {
18875 dlg.finished(false);
18876 return Err(common::Error::FieldClash(field));
18877 }
18878 }
18879
18880 let mut params = Params::with_capacity(6 + self._additional_params.len());
18881 params.push("parent", self._parent);
18882 if let Some(value) = self._request_id.as_ref() {
18883 params.push("requestId", value);
18884 }
18885 if let Some(value) = self._migrating_vm_id.as_ref() {
18886 params.push("migratingVmId", value);
18887 }
18888
18889 params.extend(self._additional_params.iter());
18890
18891 params.push("alt", "json");
18892 let mut url = self.hub._base_url.clone() + "v1/{+parent}/migratingVms";
18893 if self._scopes.is_empty() {
18894 self._scopes
18895 .insert(Scope::CloudPlatform.as_ref().to_string());
18896 }
18897
18898 #[allow(clippy::single_element_loop)]
18899 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
18900 url = params.uri_replacement(url, param_name, find_this, true);
18901 }
18902 {
18903 let to_remove = ["parent"];
18904 params.remove_params(&to_remove);
18905 }
18906
18907 let url = params.parse_with_url(&url);
18908
18909 let mut json_mime_type = mime::APPLICATION_JSON;
18910 let mut request_value_reader = {
18911 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18912 common::remove_json_null_values(&mut value);
18913 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18914 serde_json::to_writer(&mut dst, &value).unwrap();
18915 dst
18916 };
18917 let request_size = request_value_reader
18918 .seek(std::io::SeekFrom::End(0))
18919 .unwrap();
18920 request_value_reader
18921 .seek(std::io::SeekFrom::Start(0))
18922 .unwrap();
18923
18924 loop {
18925 let token = match self
18926 .hub
18927 .auth
18928 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18929 .await
18930 {
18931 Ok(token) => token,
18932 Err(e) => match dlg.token(e) {
18933 Ok(token) => token,
18934 Err(e) => {
18935 dlg.finished(false);
18936 return Err(common::Error::MissingToken(e));
18937 }
18938 },
18939 };
18940 request_value_reader
18941 .seek(std::io::SeekFrom::Start(0))
18942 .unwrap();
18943 let mut req_result = {
18944 let client = &self.hub.client;
18945 dlg.pre_request();
18946 let mut req_builder = hyper::Request::builder()
18947 .method(hyper::Method::POST)
18948 .uri(url.as_str())
18949 .header(USER_AGENT, self.hub._user_agent.clone());
18950
18951 if let Some(token) = token.as_ref() {
18952 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18953 }
18954
18955 let request = req_builder
18956 .header(CONTENT_TYPE, json_mime_type.to_string())
18957 .header(CONTENT_LENGTH, request_size as u64)
18958 .body(common::to_body(
18959 request_value_reader.get_ref().clone().into(),
18960 ));
18961
18962 client.request(request.unwrap()).await
18963 };
18964
18965 match req_result {
18966 Err(err) => {
18967 if let common::Retry::After(d) = dlg.http_error(&err) {
18968 sleep(d).await;
18969 continue;
18970 }
18971 dlg.finished(false);
18972 return Err(common::Error::HttpError(err));
18973 }
18974 Ok(res) => {
18975 let (mut parts, body) = res.into_parts();
18976 let mut body = common::Body::new(body);
18977 if !parts.status.is_success() {
18978 let bytes = common::to_bytes(body).await.unwrap_or_default();
18979 let error = serde_json::from_str(&common::to_string(&bytes));
18980 let response = common::to_response(parts, bytes.into());
18981
18982 if let common::Retry::After(d) =
18983 dlg.http_failure(&response, error.as_ref().ok())
18984 {
18985 sleep(d).await;
18986 continue;
18987 }
18988
18989 dlg.finished(false);
18990
18991 return Err(match error {
18992 Ok(value) => common::Error::BadRequest(value),
18993 _ => common::Error::Failure(response),
18994 });
18995 }
18996 let response = {
18997 let bytes = common::to_bytes(body).await.unwrap_or_default();
18998 let encoded = common::to_string(&bytes);
18999 match serde_json::from_str(&encoded) {
19000 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19001 Err(error) => {
19002 dlg.response_json_decode_error(&encoded, &error);
19003 return Err(common::Error::JsonDecodeError(
19004 encoded.to_string(),
19005 error,
19006 ));
19007 }
19008 }
19009 };
19010
19011 dlg.finished(true);
19012 return Ok(response);
19013 }
19014 }
19015 }
19016 }
19017
19018 ///
19019 /// Sets the *request* property to the given value.
19020 ///
19021 /// Even though the property as already been set when instantiating this call,
19022 /// we provide this method for API completeness.
19023 pub fn request(
19024 mut self,
19025 new_value: MigratingVm,
19026 ) -> ProjectLocationSourceMigratingVmCreateCall<'a, C> {
19027 self._request = new_value;
19028 self
19029 }
19030 /// Required. The MigratingVm's parent.
19031 ///
19032 /// Sets the *parent* path property to the given value.
19033 ///
19034 /// Even though the property as already been set when instantiating this call,
19035 /// we provide this method for API completeness.
19036 pub fn parent(mut self, new_value: &str) -> ProjectLocationSourceMigratingVmCreateCall<'a, C> {
19037 self._parent = new_value.to_string();
19038 self
19039 }
19040 /// 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).
19041 ///
19042 /// Sets the *request id* query property to the given value.
19043 pub fn request_id(
19044 mut self,
19045 new_value: &str,
19046 ) -> ProjectLocationSourceMigratingVmCreateCall<'a, C> {
19047 self._request_id = Some(new_value.to_string());
19048 self
19049 }
19050 /// Required. The migratingVm identifier.
19051 ///
19052 /// Sets the *migrating vm id* query property to the given value.
19053 pub fn migrating_vm_id(
19054 mut self,
19055 new_value: &str,
19056 ) -> ProjectLocationSourceMigratingVmCreateCall<'a, C> {
19057 self._migrating_vm_id = Some(new_value.to_string());
19058 self
19059 }
19060 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19061 /// while executing the actual API request.
19062 ///
19063 /// ````text
19064 /// It should be used to handle progress information, and to implement a certain level of resilience.
19065 /// ````
19066 ///
19067 /// Sets the *delegate* property to the given value.
19068 pub fn delegate(
19069 mut self,
19070 new_value: &'a mut dyn common::Delegate,
19071 ) -> ProjectLocationSourceMigratingVmCreateCall<'a, C> {
19072 self._delegate = Some(new_value);
19073 self
19074 }
19075
19076 /// Set any additional parameter of the query string used in the request.
19077 /// It should be used to set parameters which are not yet available through their own
19078 /// setters.
19079 ///
19080 /// Please note that this method must not be used to set any of the known parameters
19081 /// which have their own setter method. If done anyway, the request will fail.
19082 ///
19083 /// # Additional Parameters
19084 ///
19085 /// * *$.xgafv* (query-string) - V1 error format.
19086 /// * *access_token* (query-string) - OAuth access token.
19087 /// * *alt* (query-string) - Data format for response.
19088 /// * *callback* (query-string) - JSONP
19089 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19090 /// * *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.
19091 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19092 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19093 /// * *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.
19094 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19095 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19096 pub fn param<T>(
19097 mut self,
19098 name: T,
19099 value: T,
19100 ) -> ProjectLocationSourceMigratingVmCreateCall<'a, C>
19101 where
19102 T: AsRef<str>,
19103 {
19104 self._additional_params
19105 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19106 self
19107 }
19108
19109 /// Identifies the authorization scope for the method you are building.
19110 ///
19111 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19112 /// [`Scope::CloudPlatform`].
19113 ///
19114 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19115 /// tokens for more than one scope.
19116 ///
19117 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19118 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19119 /// sufficient, a read-write scope will do as well.
19120 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceMigratingVmCreateCall<'a, C>
19121 where
19122 St: AsRef<str>,
19123 {
19124 self._scopes.insert(String::from(scope.as_ref()));
19125 self
19126 }
19127 /// Identifies the authorization scope(s) for the method you are building.
19128 ///
19129 /// See [`Self::add_scope()`] for details.
19130 pub fn add_scopes<I, St>(
19131 mut self,
19132 scopes: I,
19133 ) -> ProjectLocationSourceMigratingVmCreateCall<'a, C>
19134 where
19135 I: IntoIterator<Item = St>,
19136 St: AsRef<str>,
19137 {
19138 self._scopes
19139 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19140 self
19141 }
19142
19143 /// Removes all scopes, and no default scope will be used either.
19144 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19145 /// for details).
19146 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmCreateCall<'a, C> {
19147 self._scopes.clear();
19148 self
19149 }
19150}
19151
19152/// Deletes a single MigratingVm.
19153///
19154/// A builder for the *locations.sources.migratingVms.delete* method supported by a *project* resource.
19155/// It is not used directly, but through a [`ProjectMethods`] instance.
19156///
19157/// # Example
19158///
19159/// Instantiate a resource method builder
19160///
19161/// ```test_harness,no_run
19162/// # extern crate hyper;
19163/// # extern crate hyper_rustls;
19164/// # extern crate google_vmmigration1 as vmmigration1;
19165/// # async fn dox() {
19166/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19167///
19168/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19169/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19170/// # .with_native_roots()
19171/// # .unwrap()
19172/// # .https_only()
19173/// # .enable_http2()
19174/// # .build();
19175///
19176/// # let executor = hyper_util::rt::TokioExecutor::new();
19177/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19178/// # secret,
19179/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19180/// # yup_oauth2::client::CustomHyperClientBuilder::from(
19181/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
19182/// # ),
19183/// # ).build().await.unwrap();
19184///
19185/// # let client = hyper_util::client::legacy::Client::builder(
19186/// # hyper_util::rt::TokioExecutor::new()
19187/// # )
19188/// # .build(
19189/// # hyper_rustls::HttpsConnectorBuilder::new()
19190/// # .with_native_roots()
19191/// # .unwrap()
19192/// # .https_or_http()
19193/// # .enable_http2()
19194/// # .build()
19195/// # );
19196/// # let mut hub = VMMigrationService::new(client, auth);
19197/// // You can configure optional parameters by calling the respective setters at will, and
19198/// // execute the final call using `doit()`.
19199/// // Values shown here are possibly random and not representative !
19200/// let result = hub.projects().locations_sources_migrating_vms_delete("name")
19201/// .doit().await;
19202/// # }
19203/// ```
19204pub struct ProjectLocationSourceMigratingVmDeleteCall<'a, C>
19205where
19206 C: 'a,
19207{
19208 hub: &'a VMMigrationService<C>,
19209 _name: String,
19210 _delegate: Option<&'a mut dyn common::Delegate>,
19211 _additional_params: HashMap<String, String>,
19212 _scopes: BTreeSet<String>,
19213}
19214
19215impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmDeleteCall<'a, C> {}
19216
19217impl<'a, C> ProjectLocationSourceMigratingVmDeleteCall<'a, C>
19218where
19219 C: common::Connector,
19220{
19221 /// Perform the operation you have build so far.
19222 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
19223 use std::borrow::Cow;
19224 use std::io::{Read, Seek};
19225
19226 use common::{url::Params, ToParts};
19227 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19228
19229 let mut dd = common::DefaultDelegate;
19230 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19231 dlg.begin(common::MethodInfo {
19232 id: "vmmigration.projects.locations.sources.migratingVms.delete",
19233 http_method: hyper::Method::DELETE,
19234 });
19235
19236 for &field in ["alt", "name"].iter() {
19237 if self._additional_params.contains_key(field) {
19238 dlg.finished(false);
19239 return Err(common::Error::FieldClash(field));
19240 }
19241 }
19242
19243 let mut params = Params::with_capacity(3 + self._additional_params.len());
19244 params.push("name", self._name);
19245
19246 params.extend(self._additional_params.iter());
19247
19248 params.push("alt", "json");
19249 let mut url = self.hub._base_url.clone() + "v1/{+name}";
19250 if self._scopes.is_empty() {
19251 self._scopes
19252 .insert(Scope::CloudPlatform.as_ref().to_string());
19253 }
19254
19255 #[allow(clippy::single_element_loop)]
19256 for &(find_this, param_name) in [("{+name}", "name")].iter() {
19257 url = params.uri_replacement(url, param_name, find_this, true);
19258 }
19259 {
19260 let to_remove = ["name"];
19261 params.remove_params(&to_remove);
19262 }
19263
19264 let url = params.parse_with_url(&url);
19265
19266 loop {
19267 let token = match self
19268 .hub
19269 .auth
19270 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19271 .await
19272 {
19273 Ok(token) => token,
19274 Err(e) => match dlg.token(e) {
19275 Ok(token) => token,
19276 Err(e) => {
19277 dlg.finished(false);
19278 return Err(common::Error::MissingToken(e));
19279 }
19280 },
19281 };
19282 let mut req_result = {
19283 let client = &self.hub.client;
19284 dlg.pre_request();
19285 let mut req_builder = hyper::Request::builder()
19286 .method(hyper::Method::DELETE)
19287 .uri(url.as_str())
19288 .header(USER_AGENT, self.hub._user_agent.clone());
19289
19290 if let Some(token) = token.as_ref() {
19291 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19292 }
19293
19294 let request = req_builder
19295 .header(CONTENT_LENGTH, 0_u64)
19296 .body(common::to_body::<String>(None));
19297
19298 client.request(request.unwrap()).await
19299 };
19300
19301 match req_result {
19302 Err(err) => {
19303 if let common::Retry::After(d) = dlg.http_error(&err) {
19304 sleep(d).await;
19305 continue;
19306 }
19307 dlg.finished(false);
19308 return Err(common::Error::HttpError(err));
19309 }
19310 Ok(res) => {
19311 let (mut parts, body) = res.into_parts();
19312 let mut body = common::Body::new(body);
19313 if !parts.status.is_success() {
19314 let bytes = common::to_bytes(body).await.unwrap_or_default();
19315 let error = serde_json::from_str(&common::to_string(&bytes));
19316 let response = common::to_response(parts, bytes.into());
19317
19318 if let common::Retry::After(d) =
19319 dlg.http_failure(&response, error.as_ref().ok())
19320 {
19321 sleep(d).await;
19322 continue;
19323 }
19324
19325 dlg.finished(false);
19326
19327 return Err(match error {
19328 Ok(value) => common::Error::BadRequest(value),
19329 _ => common::Error::Failure(response),
19330 });
19331 }
19332 let response = {
19333 let bytes = common::to_bytes(body).await.unwrap_or_default();
19334 let encoded = common::to_string(&bytes);
19335 match serde_json::from_str(&encoded) {
19336 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19337 Err(error) => {
19338 dlg.response_json_decode_error(&encoded, &error);
19339 return Err(common::Error::JsonDecodeError(
19340 encoded.to_string(),
19341 error,
19342 ));
19343 }
19344 }
19345 };
19346
19347 dlg.finished(true);
19348 return Ok(response);
19349 }
19350 }
19351 }
19352 }
19353
19354 /// Required. The name of the MigratingVm.
19355 ///
19356 /// Sets the *name* path property to the given value.
19357 ///
19358 /// Even though the property as already been set when instantiating this call,
19359 /// we provide this method for API completeness.
19360 pub fn name(mut self, new_value: &str) -> ProjectLocationSourceMigratingVmDeleteCall<'a, C> {
19361 self._name = new_value.to_string();
19362 self
19363 }
19364 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19365 /// while executing the actual API request.
19366 ///
19367 /// ````text
19368 /// It should be used to handle progress information, and to implement a certain level of resilience.
19369 /// ````
19370 ///
19371 /// Sets the *delegate* property to the given value.
19372 pub fn delegate(
19373 mut self,
19374 new_value: &'a mut dyn common::Delegate,
19375 ) -> ProjectLocationSourceMigratingVmDeleteCall<'a, C> {
19376 self._delegate = Some(new_value);
19377 self
19378 }
19379
19380 /// Set any additional parameter of the query string used in the request.
19381 /// It should be used to set parameters which are not yet available through their own
19382 /// setters.
19383 ///
19384 /// Please note that this method must not be used to set any of the known parameters
19385 /// which have their own setter method. If done anyway, the request will fail.
19386 ///
19387 /// # Additional Parameters
19388 ///
19389 /// * *$.xgafv* (query-string) - V1 error format.
19390 /// * *access_token* (query-string) - OAuth access token.
19391 /// * *alt* (query-string) - Data format for response.
19392 /// * *callback* (query-string) - JSONP
19393 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19394 /// * *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.
19395 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19396 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19397 /// * *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.
19398 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19399 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19400 pub fn param<T>(
19401 mut self,
19402 name: T,
19403 value: T,
19404 ) -> ProjectLocationSourceMigratingVmDeleteCall<'a, C>
19405 where
19406 T: AsRef<str>,
19407 {
19408 self._additional_params
19409 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19410 self
19411 }
19412
19413 /// Identifies the authorization scope for the method you are building.
19414 ///
19415 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19416 /// [`Scope::CloudPlatform`].
19417 ///
19418 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19419 /// tokens for more than one scope.
19420 ///
19421 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19422 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19423 /// sufficient, a read-write scope will do as well.
19424 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceMigratingVmDeleteCall<'a, C>
19425 where
19426 St: AsRef<str>,
19427 {
19428 self._scopes.insert(String::from(scope.as_ref()));
19429 self
19430 }
19431 /// Identifies the authorization scope(s) for the method you are building.
19432 ///
19433 /// See [`Self::add_scope()`] for details.
19434 pub fn add_scopes<I, St>(
19435 mut self,
19436 scopes: I,
19437 ) -> ProjectLocationSourceMigratingVmDeleteCall<'a, C>
19438 where
19439 I: IntoIterator<Item = St>,
19440 St: AsRef<str>,
19441 {
19442 self._scopes
19443 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19444 self
19445 }
19446
19447 /// Removes all scopes, and no default scope will be used either.
19448 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19449 /// for details).
19450 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmDeleteCall<'a, C> {
19451 self._scopes.clear();
19452 self
19453 }
19454}
19455
19456/// Extend the migrating VM time to live.
19457///
19458/// A builder for the *locations.sources.migratingVms.extendMigration* method supported by a *project* resource.
19459/// It is not used directly, but through a [`ProjectMethods`] instance.
19460///
19461/// # Example
19462///
19463/// Instantiate a resource method builder
19464///
19465/// ```test_harness,no_run
19466/// # extern crate hyper;
19467/// # extern crate hyper_rustls;
19468/// # extern crate google_vmmigration1 as vmmigration1;
19469/// use vmmigration1::api::ExtendMigrationRequest;
19470/// # async fn dox() {
19471/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19472///
19473/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19474/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19475/// # .with_native_roots()
19476/// # .unwrap()
19477/// # .https_only()
19478/// # .enable_http2()
19479/// # .build();
19480///
19481/// # let executor = hyper_util::rt::TokioExecutor::new();
19482/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19483/// # secret,
19484/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19485/// # yup_oauth2::client::CustomHyperClientBuilder::from(
19486/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
19487/// # ),
19488/// # ).build().await.unwrap();
19489///
19490/// # let client = hyper_util::client::legacy::Client::builder(
19491/// # hyper_util::rt::TokioExecutor::new()
19492/// # )
19493/// # .build(
19494/// # hyper_rustls::HttpsConnectorBuilder::new()
19495/// # .with_native_roots()
19496/// # .unwrap()
19497/// # .https_or_http()
19498/// # .enable_http2()
19499/// # .build()
19500/// # );
19501/// # let mut hub = VMMigrationService::new(client, auth);
19502/// // As the method needs a request, you would usually fill it with the desired information
19503/// // into the respective structure. Some of the parts shown here might not be applicable !
19504/// // Values shown here are possibly random and not representative !
19505/// let mut req = ExtendMigrationRequest::default();
19506///
19507/// // You can configure optional parameters by calling the respective setters at will, and
19508/// // execute the final call using `doit()`.
19509/// // Values shown here are possibly random and not representative !
19510/// let result = hub.projects().locations_sources_migrating_vms_extend_migration(req, "migratingVm")
19511/// .doit().await;
19512/// # }
19513/// ```
19514pub struct ProjectLocationSourceMigratingVmExtendMigrationCall<'a, C>
19515where
19516 C: 'a,
19517{
19518 hub: &'a VMMigrationService<C>,
19519 _request: ExtendMigrationRequest,
19520 _migrating_vm: String,
19521 _delegate: Option<&'a mut dyn common::Delegate>,
19522 _additional_params: HashMap<String, String>,
19523 _scopes: BTreeSet<String>,
19524}
19525
19526impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmExtendMigrationCall<'a, C> {}
19527
19528impl<'a, C> ProjectLocationSourceMigratingVmExtendMigrationCall<'a, C>
19529where
19530 C: common::Connector,
19531{
19532 /// Perform the operation you have build so far.
19533 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
19534 use std::borrow::Cow;
19535 use std::io::{Read, Seek};
19536
19537 use common::{url::Params, ToParts};
19538 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19539
19540 let mut dd = common::DefaultDelegate;
19541 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19542 dlg.begin(common::MethodInfo {
19543 id: "vmmigration.projects.locations.sources.migratingVms.extendMigration",
19544 http_method: hyper::Method::POST,
19545 });
19546
19547 for &field in ["alt", "migratingVm"].iter() {
19548 if self._additional_params.contains_key(field) {
19549 dlg.finished(false);
19550 return Err(common::Error::FieldClash(field));
19551 }
19552 }
19553
19554 let mut params = Params::with_capacity(4 + self._additional_params.len());
19555 params.push("migratingVm", self._migrating_vm);
19556
19557 params.extend(self._additional_params.iter());
19558
19559 params.push("alt", "json");
19560 let mut url = self.hub._base_url.clone() + "v1/{+migratingVm}:extendMigration";
19561 if self._scopes.is_empty() {
19562 self._scopes
19563 .insert(Scope::CloudPlatform.as_ref().to_string());
19564 }
19565
19566 #[allow(clippy::single_element_loop)]
19567 for &(find_this, param_name) in [("{+migratingVm}", "migratingVm")].iter() {
19568 url = params.uri_replacement(url, param_name, find_this, true);
19569 }
19570 {
19571 let to_remove = ["migratingVm"];
19572 params.remove_params(&to_remove);
19573 }
19574
19575 let url = params.parse_with_url(&url);
19576
19577 let mut json_mime_type = mime::APPLICATION_JSON;
19578 let mut request_value_reader = {
19579 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19580 common::remove_json_null_values(&mut value);
19581 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19582 serde_json::to_writer(&mut dst, &value).unwrap();
19583 dst
19584 };
19585 let request_size = request_value_reader
19586 .seek(std::io::SeekFrom::End(0))
19587 .unwrap();
19588 request_value_reader
19589 .seek(std::io::SeekFrom::Start(0))
19590 .unwrap();
19591
19592 loop {
19593 let token = match self
19594 .hub
19595 .auth
19596 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19597 .await
19598 {
19599 Ok(token) => token,
19600 Err(e) => match dlg.token(e) {
19601 Ok(token) => token,
19602 Err(e) => {
19603 dlg.finished(false);
19604 return Err(common::Error::MissingToken(e));
19605 }
19606 },
19607 };
19608 request_value_reader
19609 .seek(std::io::SeekFrom::Start(0))
19610 .unwrap();
19611 let mut req_result = {
19612 let client = &self.hub.client;
19613 dlg.pre_request();
19614 let mut req_builder = hyper::Request::builder()
19615 .method(hyper::Method::POST)
19616 .uri(url.as_str())
19617 .header(USER_AGENT, self.hub._user_agent.clone());
19618
19619 if let Some(token) = token.as_ref() {
19620 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19621 }
19622
19623 let request = req_builder
19624 .header(CONTENT_TYPE, json_mime_type.to_string())
19625 .header(CONTENT_LENGTH, request_size as u64)
19626 .body(common::to_body(
19627 request_value_reader.get_ref().clone().into(),
19628 ));
19629
19630 client.request(request.unwrap()).await
19631 };
19632
19633 match req_result {
19634 Err(err) => {
19635 if let common::Retry::After(d) = dlg.http_error(&err) {
19636 sleep(d).await;
19637 continue;
19638 }
19639 dlg.finished(false);
19640 return Err(common::Error::HttpError(err));
19641 }
19642 Ok(res) => {
19643 let (mut parts, body) = res.into_parts();
19644 let mut body = common::Body::new(body);
19645 if !parts.status.is_success() {
19646 let bytes = common::to_bytes(body).await.unwrap_or_default();
19647 let error = serde_json::from_str(&common::to_string(&bytes));
19648 let response = common::to_response(parts, bytes.into());
19649
19650 if let common::Retry::After(d) =
19651 dlg.http_failure(&response, error.as_ref().ok())
19652 {
19653 sleep(d).await;
19654 continue;
19655 }
19656
19657 dlg.finished(false);
19658
19659 return Err(match error {
19660 Ok(value) => common::Error::BadRequest(value),
19661 _ => common::Error::Failure(response),
19662 });
19663 }
19664 let response = {
19665 let bytes = common::to_bytes(body).await.unwrap_or_default();
19666 let encoded = common::to_string(&bytes);
19667 match serde_json::from_str(&encoded) {
19668 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19669 Err(error) => {
19670 dlg.response_json_decode_error(&encoded, &error);
19671 return Err(common::Error::JsonDecodeError(
19672 encoded.to_string(),
19673 error,
19674 ));
19675 }
19676 }
19677 };
19678
19679 dlg.finished(true);
19680 return Ok(response);
19681 }
19682 }
19683 }
19684 }
19685
19686 ///
19687 /// Sets the *request* property to the given value.
19688 ///
19689 /// Even though the property as already been set when instantiating this call,
19690 /// we provide this method for API completeness.
19691 pub fn request(
19692 mut self,
19693 new_value: ExtendMigrationRequest,
19694 ) -> ProjectLocationSourceMigratingVmExtendMigrationCall<'a, C> {
19695 self._request = new_value;
19696 self
19697 }
19698 /// Required. The name of the MigratingVm.
19699 ///
19700 /// Sets the *migrating vm* path property to the given value.
19701 ///
19702 /// Even though the property as already been set when instantiating this call,
19703 /// we provide this method for API completeness.
19704 pub fn migrating_vm(
19705 mut self,
19706 new_value: &str,
19707 ) -> ProjectLocationSourceMigratingVmExtendMigrationCall<'a, C> {
19708 self._migrating_vm = new_value.to_string();
19709 self
19710 }
19711 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19712 /// while executing the actual API request.
19713 ///
19714 /// ````text
19715 /// It should be used to handle progress information, and to implement a certain level of resilience.
19716 /// ````
19717 ///
19718 /// Sets the *delegate* property to the given value.
19719 pub fn delegate(
19720 mut self,
19721 new_value: &'a mut dyn common::Delegate,
19722 ) -> ProjectLocationSourceMigratingVmExtendMigrationCall<'a, C> {
19723 self._delegate = Some(new_value);
19724 self
19725 }
19726
19727 /// Set any additional parameter of the query string used in the request.
19728 /// It should be used to set parameters which are not yet available through their own
19729 /// setters.
19730 ///
19731 /// Please note that this method must not be used to set any of the known parameters
19732 /// which have their own setter method. If done anyway, the request will fail.
19733 ///
19734 /// # Additional Parameters
19735 ///
19736 /// * *$.xgafv* (query-string) - V1 error format.
19737 /// * *access_token* (query-string) - OAuth access token.
19738 /// * *alt* (query-string) - Data format for response.
19739 /// * *callback* (query-string) - JSONP
19740 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19741 /// * *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.
19742 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19743 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19744 /// * *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.
19745 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19746 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19747 pub fn param<T>(
19748 mut self,
19749 name: T,
19750 value: T,
19751 ) -> ProjectLocationSourceMigratingVmExtendMigrationCall<'a, C>
19752 where
19753 T: AsRef<str>,
19754 {
19755 self._additional_params
19756 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19757 self
19758 }
19759
19760 /// Identifies the authorization scope for the method you are building.
19761 ///
19762 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19763 /// [`Scope::CloudPlatform`].
19764 ///
19765 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19766 /// tokens for more than one scope.
19767 ///
19768 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19769 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19770 /// sufficient, a read-write scope will do as well.
19771 pub fn add_scope<St>(
19772 mut self,
19773 scope: St,
19774 ) -> ProjectLocationSourceMigratingVmExtendMigrationCall<'a, C>
19775 where
19776 St: AsRef<str>,
19777 {
19778 self._scopes.insert(String::from(scope.as_ref()));
19779 self
19780 }
19781 /// Identifies the authorization scope(s) for the method you are building.
19782 ///
19783 /// See [`Self::add_scope()`] for details.
19784 pub fn add_scopes<I, St>(
19785 mut self,
19786 scopes: I,
19787 ) -> ProjectLocationSourceMigratingVmExtendMigrationCall<'a, C>
19788 where
19789 I: IntoIterator<Item = St>,
19790 St: AsRef<str>,
19791 {
19792 self._scopes
19793 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19794 self
19795 }
19796
19797 /// Removes all scopes, and no default scope will be used either.
19798 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19799 /// for details).
19800 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmExtendMigrationCall<'a, C> {
19801 self._scopes.clear();
19802 self
19803 }
19804}
19805
19806/// Marks a migration as completed, deleting migration resources that are no longer being used. Only applicable after cutover is done.
19807///
19808/// A builder for the *locations.sources.migratingVms.finalizeMigration* method supported by a *project* resource.
19809/// It is not used directly, but through a [`ProjectMethods`] instance.
19810///
19811/// # Example
19812///
19813/// Instantiate a resource method builder
19814///
19815/// ```test_harness,no_run
19816/// # extern crate hyper;
19817/// # extern crate hyper_rustls;
19818/// # extern crate google_vmmigration1 as vmmigration1;
19819/// use vmmigration1::api::FinalizeMigrationRequest;
19820/// # async fn dox() {
19821/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19822///
19823/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19824/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19825/// # .with_native_roots()
19826/// # .unwrap()
19827/// # .https_only()
19828/// # .enable_http2()
19829/// # .build();
19830///
19831/// # let executor = hyper_util::rt::TokioExecutor::new();
19832/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19833/// # secret,
19834/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19835/// # yup_oauth2::client::CustomHyperClientBuilder::from(
19836/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
19837/// # ),
19838/// # ).build().await.unwrap();
19839///
19840/// # let client = hyper_util::client::legacy::Client::builder(
19841/// # hyper_util::rt::TokioExecutor::new()
19842/// # )
19843/// # .build(
19844/// # hyper_rustls::HttpsConnectorBuilder::new()
19845/// # .with_native_roots()
19846/// # .unwrap()
19847/// # .https_or_http()
19848/// # .enable_http2()
19849/// # .build()
19850/// # );
19851/// # let mut hub = VMMigrationService::new(client, auth);
19852/// // As the method needs a request, you would usually fill it with the desired information
19853/// // into the respective structure. Some of the parts shown here might not be applicable !
19854/// // Values shown here are possibly random and not representative !
19855/// let mut req = FinalizeMigrationRequest::default();
19856///
19857/// // You can configure optional parameters by calling the respective setters at will, and
19858/// // execute the final call using `doit()`.
19859/// // Values shown here are possibly random and not representative !
19860/// let result = hub.projects().locations_sources_migrating_vms_finalize_migration(req, "migratingVm")
19861/// .doit().await;
19862/// # }
19863/// ```
19864pub struct ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C>
19865where
19866 C: 'a,
19867{
19868 hub: &'a VMMigrationService<C>,
19869 _request: FinalizeMigrationRequest,
19870 _migrating_vm: String,
19871 _delegate: Option<&'a mut dyn common::Delegate>,
19872 _additional_params: HashMap<String, String>,
19873 _scopes: BTreeSet<String>,
19874}
19875
19876impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C> {}
19877
19878impl<'a, C> ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C>
19879where
19880 C: common::Connector,
19881{
19882 /// Perform the operation you have build so far.
19883 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
19884 use std::borrow::Cow;
19885 use std::io::{Read, Seek};
19886
19887 use common::{url::Params, ToParts};
19888 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19889
19890 let mut dd = common::DefaultDelegate;
19891 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19892 dlg.begin(common::MethodInfo {
19893 id: "vmmigration.projects.locations.sources.migratingVms.finalizeMigration",
19894 http_method: hyper::Method::POST,
19895 });
19896
19897 for &field in ["alt", "migratingVm"].iter() {
19898 if self._additional_params.contains_key(field) {
19899 dlg.finished(false);
19900 return Err(common::Error::FieldClash(field));
19901 }
19902 }
19903
19904 let mut params = Params::with_capacity(4 + self._additional_params.len());
19905 params.push("migratingVm", self._migrating_vm);
19906
19907 params.extend(self._additional_params.iter());
19908
19909 params.push("alt", "json");
19910 let mut url = self.hub._base_url.clone() + "v1/{+migratingVm}:finalizeMigration";
19911 if self._scopes.is_empty() {
19912 self._scopes
19913 .insert(Scope::CloudPlatform.as_ref().to_string());
19914 }
19915
19916 #[allow(clippy::single_element_loop)]
19917 for &(find_this, param_name) in [("{+migratingVm}", "migratingVm")].iter() {
19918 url = params.uri_replacement(url, param_name, find_this, true);
19919 }
19920 {
19921 let to_remove = ["migratingVm"];
19922 params.remove_params(&to_remove);
19923 }
19924
19925 let url = params.parse_with_url(&url);
19926
19927 let mut json_mime_type = mime::APPLICATION_JSON;
19928 let mut request_value_reader = {
19929 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19930 common::remove_json_null_values(&mut value);
19931 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19932 serde_json::to_writer(&mut dst, &value).unwrap();
19933 dst
19934 };
19935 let request_size = request_value_reader
19936 .seek(std::io::SeekFrom::End(0))
19937 .unwrap();
19938 request_value_reader
19939 .seek(std::io::SeekFrom::Start(0))
19940 .unwrap();
19941
19942 loop {
19943 let token = match self
19944 .hub
19945 .auth
19946 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19947 .await
19948 {
19949 Ok(token) => token,
19950 Err(e) => match dlg.token(e) {
19951 Ok(token) => token,
19952 Err(e) => {
19953 dlg.finished(false);
19954 return Err(common::Error::MissingToken(e));
19955 }
19956 },
19957 };
19958 request_value_reader
19959 .seek(std::io::SeekFrom::Start(0))
19960 .unwrap();
19961 let mut req_result = {
19962 let client = &self.hub.client;
19963 dlg.pre_request();
19964 let mut req_builder = hyper::Request::builder()
19965 .method(hyper::Method::POST)
19966 .uri(url.as_str())
19967 .header(USER_AGENT, self.hub._user_agent.clone());
19968
19969 if let Some(token) = token.as_ref() {
19970 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19971 }
19972
19973 let request = req_builder
19974 .header(CONTENT_TYPE, json_mime_type.to_string())
19975 .header(CONTENT_LENGTH, request_size as u64)
19976 .body(common::to_body(
19977 request_value_reader.get_ref().clone().into(),
19978 ));
19979
19980 client.request(request.unwrap()).await
19981 };
19982
19983 match req_result {
19984 Err(err) => {
19985 if let common::Retry::After(d) = dlg.http_error(&err) {
19986 sleep(d).await;
19987 continue;
19988 }
19989 dlg.finished(false);
19990 return Err(common::Error::HttpError(err));
19991 }
19992 Ok(res) => {
19993 let (mut parts, body) = res.into_parts();
19994 let mut body = common::Body::new(body);
19995 if !parts.status.is_success() {
19996 let bytes = common::to_bytes(body).await.unwrap_or_default();
19997 let error = serde_json::from_str(&common::to_string(&bytes));
19998 let response = common::to_response(parts, bytes.into());
19999
20000 if let common::Retry::After(d) =
20001 dlg.http_failure(&response, error.as_ref().ok())
20002 {
20003 sleep(d).await;
20004 continue;
20005 }
20006
20007 dlg.finished(false);
20008
20009 return Err(match error {
20010 Ok(value) => common::Error::BadRequest(value),
20011 _ => common::Error::Failure(response),
20012 });
20013 }
20014 let response = {
20015 let bytes = common::to_bytes(body).await.unwrap_or_default();
20016 let encoded = common::to_string(&bytes);
20017 match serde_json::from_str(&encoded) {
20018 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20019 Err(error) => {
20020 dlg.response_json_decode_error(&encoded, &error);
20021 return Err(common::Error::JsonDecodeError(
20022 encoded.to_string(),
20023 error,
20024 ));
20025 }
20026 }
20027 };
20028
20029 dlg.finished(true);
20030 return Ok(response);
20031 }
20032 }
20033 }
20034 }
20035
20036 ///
20037 /// Sets the *request* property to the given value.
20038 ///
20039 /// Even though the property as already been set when instantiating this call,
20040 /// we provide this method for API completeness.
20041 pub fn request(
20042 mut self,
20043 new_value: FinalizeMigrationRequest,
20044 ) -> ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C> {
20045 self._request = new_value;
20046 self
20047 }
20048 /// Required. The name of the MigratingVm.
20049 ///
20050 /// Sets the *migrating vm* path property to the given value.
20051 ///
20052 /// Even though the property as already been set when instantiating this call,
20053 /// we provide this method for API completeness.
20054 pub fn migrating_vm(
20055 mut self,
20056 new_value: &str,
20057 ) -> ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C> {
20058 self._migrating_vm = new_value.to_string();
20059 self
20060 }
20061 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20062 /// while executing the actual API request.
20063 ///
20064 /// ````text
20065 /// It should be used to handle progress information, and to implement a certain level of resilience.
20066 /// ````
20067 ///
20068 /// Sets the *delegate* property to the given value.
20069 pub fn delegate(
20070 mut self,
20071 new_value: &'a mut dyn common::Delegate,
20072 ) -> ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C> {
20073 self._delegate = Some(new_value);
20074 self
20075 }
20076
20077 /// Set any additional parameter of the query string used in the request.
20078 /// It should be used to set parameters which are not yet available through their own
20079 /// setters.
20080 ///
20081 /// Please note that this method must not be used to set any of the known parameters
20082 /// which have their own setter method. If done anyway, the request will fail.
20083 ///
20084 /// # Additional Parameters
20085 ///
20086 /// * *$.xgafv* (query-string) - V1 error format.
20087 /// * *access_token* (query-string) - OAuth access token.
20088 /// * *alt* (query-string) - Data format for response.
20089 /// * *callback* (query-string) - JSONP
20090 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20091 /// * *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.
20092 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20093 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20094 /// * *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.
20095 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20096 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20097 pub fn param<T>(
20098 mut self,
20099 name: T,
20100 value: T,
20101 ) -> ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C>
20102 where
20103 T: AsRef<str>,
20104 {
20105 self._additional_params
20106 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20107 self
20108 }
20109
20110 /// Identifies the authorization scope for the method you are building.
20111 ///
20112 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20113 /// [`Scope::CloudPlatform`].
20114 ///
20115 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20116 /// tokens for more than one scope.
20117 ///
20118 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20119 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20120 /// sufficient, a read-write scope will do as well.
20121 pub fn add_scope<St>(
20122 mut self,
20123 scope: St,
20124 ) -> ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C>
20125 where
20126 St: AsRef<str>,
20127 {
20128 self._scopes.insert(String::from(scope.as_ref()));
20129 self
20130 }
20131 /// Identifies the authorization scope(s) for the method you are building.
20132 ///
20133 /// See [`Self::add_scope()`] for details.
20134 pub fn add_scopes<I, St>(
20135 mut self,
20136 scopes: I,
20137 ) -> ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C>
20138 where
20139 I: IntoIterator<Item = St>,
20140 St: AsRef<str>,
20141 {
20142 self._scopes
20143 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20144 self
20145 }
20146
20147 /// Removes all scopes, and no default scope will be used either.
20148 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20149 /// for details).
20150 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmFinalizeMigrationCall<'a, C> {
20151 self._scopes.clear();
20152 self
20153 }
20154}
20155
20156/// Gets details of a single MigratingVm.
20157///
20158/// A builder for the *locations.sources.migratingVms.get* method supported by a *project* resource.
20159/// It is not used directly, but through a [`ProjectMethods`] instance.
20160///
20161/// # Example
20162///
20163/// Instantiate a resource method builder
20164///
20165/// ```test_harness,no_run
20166/// # extern crate hyper;
20167/// # extern crate hyper_rustls;
20168/// # extern crate google_vmmigration1 as vmmigration1;
20169/// # async fn dox() {
20170/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20171///
20172/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20173/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20174/// # .with_native_roots()
20175/// # .unwrap()
20176/// # .https_only()
20177/// # .enable_http2()
20178/// # .build();
20179///
20180/// # let executor = hyper_util::rt::TokioExecutor::new();
20181/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20182/// # secret,
20183/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20184/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20185/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20186/// # ),
20187/// # ).build().await.unwrap();
20188///
20189/// # let client = hyper_util::client::legacy::Client::builder(
20190/// # hyper_util::rt::TokioExecutor::new()
20191/// # )
20192/// # .build(
20193/// # hyper_rustls::HttpsConnectorBuilder::new()
20194/// # .with_native_roots()
20195/// # .unwrap()
20196/// # .https_or_http()
20197/// # .enable_http2()
20198/// # .build()
20199/// # );
20200/// # let mut hub = VMMigrationService::new(client, auth);
20201/// // You can configure optional parameters by calling the respective setters at will, and
20202/// // execute the final call using `doit()`.
20203/// // Values shown here are possibly random and not representative !
20204/// let result = hub.projects().locations_sources_migrating_vms_get("name")
20205/// .view("Lorem")
20206/// .doit().await;
20207/// # }
20208/// ```
20209pub struct ProjectLocationSourceMigratingVmGetCall<'a, C>
20210where
20211 C: 'a,
20212{
20213 hub: &'a VMMigrationService<C>,
20214 _name: String,
20215 _view: Option<String>,
20216 _delegate: Option<&'a mut dyn common::Delegate>,
20217 _additional_params: HashMap<String, String>,
20218 _scopes: BTreeSet<String>,
20219}
20220
20221impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmGetCall<'a, C> {}
20222
20223impl<'a, C> ProjectLocationSourceMigratingVmGetCall<'a, C>
20224where
20225 C: common::Connector,
20226{
20227 /// Perform the operation you have build so far.
20228 pub async fn doit(mut self) -> common::Result<(common::Response, MigratingVm)> {
20229 use std::borrow::Cow;
20230 use std::io::{Read, Seek};
20231
20232 use common::{url::Params, ToParts};
20233 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20234
20235 let mut dd = common::DefaultDelegate;
20236 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20237 dlg.begin(common::MethodInfo {
20238 id: "vmmigration.projects.locations.sources.migratingVms.get",
20239 http_method: hyper::Method::GET,
20240 });
20241
20242 for &field in ["alt", "name", "view"].iter() {
20243 if self._additional_params.contains_key(field) {
20244 dlg.finished(false);
20245 return Err(common::Error::FieldClash(field));
20246 }
20247 }
20248
20249 let mut params = Params::with_capacity(4 + self._additional_params.len());
20250 params.push("name", self._name);
20251 if let Some(value) = self._view.as_ref() {
20252 params.push("view", value);
20253 }
20254
20255 params.extend(self._additional_params.iter());
20256
20257 params.push("alt", "json");
20258 let mut url = self.hub._base_url.clone() + "v1/{+name}";
20259 if self._scopes.is_empty() {
20260 self._scopes
20261 .insert(Scope::CloudPlatform.as_ref().to_string());
20262 }
20263
20264 #[allow(clippy::single_element_loop)]
20265 for &(find_this, param_name) in [("{+name}", "name")].iter() {
20266 url = params.uri_replacement(url, param_name, find_this, true);
20267 }
20268 {
20269 let to_remove = ["name"];
20270 params.remove_params(&to_remove);
20271 }
20272
20273 let url = params.parse_with_url(&url);
20274
20275 loop {
20276 let token = match self
20277 .hub
20278 .auth
20279 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20280 .await
20281 {
20282 Ok(token) => token,
20283 Err(e) => match dlg.token(e) {
20284 Ok(token) => token,
20285 Err(e) => {
20286 dlg.finished(false);
20287 return Err(common::Error::MissingToken(e));
20288 }
20289 },
20290 };
20291 let mut req_result = {
20292 let client = &self.hub.client;
20293 dlg.pre_request();
20294 let mut req_builder = hyper::Request::builder()
20295 .method(hyper::Method::GET)
20296 .uri(url.as_str())
20297 .header(USER_AGENT, self.hub._user_agent.clone());
20298
20299 if let Some(token) = token.as_ref() {
20300 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20301 }
20302
20303 let request = req_builder
20304 .header(CONTENT_LENGTH, 0_u64)
20305 .body(common::to_body::<String>(None));
20306
20307 client.request(request.unwrap()).await
20308 };
20309
20310 match req_result {
20311 Err(err) => {
20312 if let common::Retry::After(d) = dlg.http_error(&err) {
20313 sleep(d).await;
20314 continue;
20315 }
20316 dlg.finished(false);
20317 return Err(common::Error::HttpError(err));
20318 }
20319 Ok(res) => {
20320 let (mut parts, body) = res.into_parts();
20321 let mut body = common::Body::new(body);
20322 if !parts.status.is_success() {
20323 let bytes = common::to_bytes(body).await.unwrap_or_default();
20324 let error = serde_json::from_str(&common::to_string(&bytes));
20325 let response = common::to_response(parts, bytes.into());
20326
20327 if let common::Retry::After(d) =
20328 dlg.http_failure(&response, error.as_ref().ok())
20329 {
20330 sleep(d).await;
20331 continue;
20332 }
20333
20334 dlg.finished(false);
20335
20336 return Err(match error {
20337 Ok(value) => common::Error::BadRequest(value),
20338 _ => common::Error::Failure(response),
20339 });
20340 }
20341 let response = {
20342 let bytes = common::to_bytes(body).await.unwrap_or_default();
20343 let encoded = common::to_string(&bytes);
20344 match serde_json::from_str(&encoded) {
20345 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20346 Err(error) => {
20347 dlg.response_json_decode_error(&encoded, &error);
20348 return Err(common::Error::JsonDecodeError(
20349 encoded.to_string(),
20350 error,
20351 ));
20352 }
20353 }
20354 };
20355
20356 dlg.finished(true);
20357 return Ok(response);
20358 }
20359 }
20360 }
20361 }
20362
20363 /// Required. The name of the MigratingVm.
20364 ///
20365 /// Sets the *name* path property to the given value.
20366 ///
20367 /// Even though the property as already been set when instantiating this call,
20368 /// we provide this method for API completeness.
20369 pub fn name(mut self, new_value: &str) -> ProjectLocationSourceMigratingVmGetCall<'a, C> {
20370 self._name = new_value.to_string();
20371 self
20372 }
20373 /// Optional. The level of details of the migrating VM.
20374 ///
20375 /// Sets the *view* query property to the given value.
20376 pub fn view(mut self, new_value: &str) -> ProjectLocationSourceMigratingVmGetCall<'a, C> {
20377 self._view = Some(new_value.to_string());
20378 self
20379 }
20380 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20381 /// while executing the actual API request.
20382 ///
20383 /// ````text
20384 /// It should be used to handle progress information, and to implement a certain level of resilience.
20385 /// ````
20386 ///
20387 /// Sets the *delegate* property to the given value.
20388 pub fn delegate(
20389 mut self,
20390 new_value: &'a mut dyn common::Delegate,
20391 ) -> ProjectLocationSourceMigratingVmGetCall<'a, C> {
20392 self._delegate = Some(new_value);
20393 self
20394 }
20395
20396 /// Set any additional parameter of the query string used in the request.
20397 /// It should be used to set parameters which are not yet available through their own
20398 /// setters.
20399 ///
20400 /// Please note that this method must not be used to set any of the known parameters
20401 /// which have their own setter method. If done anyway, the request will fail.
20402 ///
20403 /// # Additional Parameters
20404 ///
20405 /// * *$.xgafv* (query-string) - V1 error format.
20406 /// * *access_token* (query-string) - OAuth access token.
20407 /// * *alt* (query-string) - Data format for response.
20408 /// * *callback* (query-string) - JSONP
20409 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20410 /// * *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.
20411 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20412 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20413 /// * *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.
20414 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20415 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20416 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSourceMigratingVmGetCall<'a, C>
20417 where
20418 T: AsRef<str>,
20419 {
20420 self._additional_params
20421 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20422 self
20423 }
20424
20425 /// Identifies the authorization scope for the method you are building.
20426 ///
20427 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20428 /// [`Scope::CloudPlatform`].
20429 ///
20430 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20431 /// tokens for more than one scope.
20432 ///
20433 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20434 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20435 /// sufficient, a read-write scope will do as well.
20436 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceMigratingVmGetCall<'a, C>
20437 where
20438 St: AsRef<str>,
20439 {
20440 self._scopes.insert(String::from(scope.as_ref()));
20441 self
20442 }
20443 /// Identifies the authorization scope(s) for the method you are building.
20444 ///
20445 /// See [`Self::add_scope()`] for details.
20446 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSourceMigratingVmGetCall<'a, C>
20447 where
20448 I: IntoIterator<Item = St>,
20449 St: AsRef<str>,
20450 {
20451 self._scopes
20452 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20453 self
20454 }
20455
20456 /// Removes all scopes, and no default scope will be used either.
20457 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20458 /// for details).
20459 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmGetCall<'a, C> {
20460 self._scopes.clear();
20461 self
20462 }
20463}
20464
20465/// Lists MigratingVms in a given Source.
20466///
20467/// A builder for the *locations.sources.migratingVms.list* method supported by a *project* resource.
20468/// It is not used directly, but through a [`ProjectMethods`] instance.
20469///
20470/// # Example
20471///
20472/// Instantiate a resource method builder
20473///
20474/// ```test_harness,no_run
20475/// # extern crate hyper;
20476/// # extern crate hyper_rustls;
20477/// # extern crate google_vmmigration1 as vmmigration1;
20478/// # async fn dox() {
20479/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20480///
20481/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20482/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20483/// # .with_native_roots()
20484/// # .unwrap()
20485/// # .https_only()
20486/// # .enable_http2()
20487/// # .build();
20488///
20489/// # let executor = hyper_util::rt::TokioExecutor::new();
20490/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20491/// # secret,
20492/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20493/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20494/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20495/// # ),
20496/// # ).build().await.unwrap();
20497///
20498/// # let client = hyper_util::client::legacy::Client::builder(
20499/// # hyper_util::rt::TokioExecutor::new()
20500/// # )
20501/// # .build(
20502/// # hyper_rustls::HttpsConnectorBuilder::new()
20503/// # .with_native_roots()
20504/// # .unwrap()
20505/// # .https_or_http()
20506/// # .enable_http2()
20507/// # .build()
20508/// # );
20509/// # let mut hub = VMMigrationService::new(client, auth);
20510/// // You can configure optional parameters by calling the respective setters at will, and
20511/// // execute the final call using `doit()`.
20512/// // Values shown here are possibly random and not representative !
20513/// let result = hub.projects().locations_sources_migrating_vms_list("parent")
20514/// .view("sed")
20515/// .page_token("diam")
20516/// .page_size(-19)
20517/// .order_by("dolores")
20518/// .filter("et")
20519/// .doit().await;
20520/// # }
20521/// ```
20522pub struct ProjectLocationSourceMigratingVmListCall<'a, C>
20523where
20524 C: 'a,
20525{
20526 hub: &'a VMMigrationService<C>,
20527 _parent: String,
20528 _view: Option<String>,
20529 _page_token: Option<String>,
20530 _page_size: Option<i32>,
20531 _order_by: Option<String>,
20532 _filter: Option<String>,
20533 _delegate: Option<&'a mut dyn common::Delegate>,
20534 _additional_params: HashMap<String, String>,
20535 _scopes: BTreeSet<String>,
20536}
20537
20538impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmListCall<'a, C> {}
20539
20540impl<'a, C> ProjectLocationSourceMigratingVmListCall<'a, C>
20541where
20542 C: common::Connector,
20543{
20544 /// Perform the operation you have build so far.
20545 pub async fn doit(mut self) -> common::Result<(common::Response, ListMigratingVmsResponse)> {
20546 use std::borrow::Cow;
20547 use std::io::{Read, Seek};
20548
20549 use common::{url::Params, ToParts};
20550 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20551
20552 let mut dd = common::DefaultDelegate;
20553 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20554 dlg.begin(common::MethodInfo {
20555 id: "vmmigration.projects.locations.sources.migratingVms.list",
20556 http_method: hyper::Method::GET,
20557 });
20558
20559 for &field in [
20560 "alt",
20561 "parent",
20562 "view",
20563 "pageToken",
20564 "pageSize",
20565 "orderBy",
20566 "filter",
20567 ]
20568 .iter()
20569 {
20570 if self._additional_params.contains_key(field) {
20571 dlg.finished(false);
20572 return Err(common::Error::FieldClash(field));
20573 }
20574 }
20575
20576 let mut params = Params::with_capacity(8 + self._additional_params.len());
20577 params.push("parent", self._parent);
20578 if let Some(value) = self._view.as_ref() {
20579 params.push("view", value);
20580 }
20581 if let Some(value) = self._page_token.as_ref() {
20582 params.push("pageToken", value);
20583 }
20584 if let Some(value) = self._page_size.as_ref() {
20585 params.push("pageSize", value.to_string());
20586 }
20587 if let Some(value) = self._order_by.as_ref() {
20588 params.push("orderBy", value);
20589 }
20590 if let Some(value) = self._filter.as_ref() {
20591 params.push("filter", value);
20592 }
20593
20594 params.extend(self._additional_params.iter());
20595
20596 params.push("alt", "json");
20597 let mut url = self.hub._base_url.clone() + "v1/{+parent}/migratingVms";
20598 if self._scopes.is_empty() {
20599 self._scopes
20600 .insert(Scope::CloudPlatform.as_ref().to_string());
20601 }
20602
20603 #[allow(clippy::single_element_loop)]
20604 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
20605 url = params.uri_replacement(url, param_name, find_this, true);
20606 }
20607 {
20608 let to_remove = ["parent"];
20609 params.remove_params(&to_remove);
20610 }
20611
20612 let url = params.parse_with_url(&url);
20613
20614 loop {
20615 let token = match self
20616 .hub
20617 .auth
20618 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20619 .await
20620 {
20621 Ok(token) => token,
20622 Err(e) => match dlg.token(e) {
20623 Ok(token) => token,
20624 Err(e) => {
20625 dlg.finished(false);
20626 return Err(common::Error::MissingToken(e));
20627 }
20628 },
20629 };
20630 let mut req_result = {
20631 let client = &self.hub.client;
20632 dlg.pre_request();
20633 let mut req_builder = hyper::Request::builder()
20634 .method(hyper::Method::GET)
20635 .uri(url.as_str())
20636 .header(USER_AGENT, self.hub._user_agent.clone());
20637
20638 if let Some(token) = token.as_ref() {
20639 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20640 }
20641
20642 let request = req_builder
20643 .header(CONTENT_LENGTH, 0_u64)
20644 .body(common::to_body::<String>(None));
20645
20646 client.request(request.unwrap()).await
20647 };
20648
20649 match req_result {
20650 Err(err) => {
20651 if let common::Retry::After(d) = dlg.http_error(&err) {
20652 sleep(d).await;
20653 continue;
20654 }
20655 dlg.finished(false);
20656 return Err(common::Error::HttpError(err));
20657 }
20658 Ok(res) => {
20659 let (mut parts, body) = res.into_parts();
20660 let mut body = common::Body::new(body);
20661 if !parts.status.is_success() {
20662 let bytes = common::to_bytes(body).await.unwrap_or_default();
20663 let error = serde_json::from_str(&common::to_string(&bytes));
20664 let response = common::to_response(parts, bytes.into());
20665
20666 if let common::Retry::After(d) =
20667 dlg.http_failure(&response, error.as_ref().ok())
20668 {
20669 sleep(d).await;
20670 continue;
20671 }
20672
20673 dlg.finished(false);
20674
20675 return Err(match error {
20676 Ok(value) => common::Error::BadRequest(value),
20677 _ => common::Error::Failure(response),
20678 });
20679 }
20680 let response = {
20681 let bytes = common::to_bytes(body).await.unwrap_or_default();
20682 let encoded = common::to_string(&bytes);
20683 match serde_json::from_str(&encoded) {
20684 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20685 Err(error) => {
20686 dlg.response_json_decode_error(&encoded, &error);
20687 return Err(common::Error::JsonDecodeError(
20688 encoded.to_string(),
20689 error,
20690 ));
20691 }
20692 }
20693 };
20694
20695 dlg.finished(true);
20696 return Ok(response);
20697 }
20698 }
20699 }
20700 }
20701
20702 /// Required. The parent, which owns this collection of MigratingVms.
20703 ///
20704 /// Sets the *parent* path property to the given value.
20705 ///
20706 /// Even though the property as already been set when instantiating this call,
20707 /// we provide this method for API completeness.
20708 pub fn parent(mut self, new_value: &str) -> ProjectLocationSourceMigratingVmListCall<'a, C> {
20709 self._parent = new_value.to_string();
20710 self
20711 }
20712 /// Optional. The level of details of each migrating VM.
20713 ///
20714 /// Sets the *view* query property to the given value.
20715 pub fn view(mut self, new_value: &str) -> ProjectLocationSourceMigratingVmListCall<'a, C> {
20716 self._view = Some(new_value.to_string());
20717 self
20718 }
20719 /// 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.
20720 ///
20721 /// Sets the *page token* query property to the given value.
20722 pub fn page_token(
20723 mut self,
20724 new_value: &str,
20725 ) -> ProjectLocationSourceMigratingVmListCall<'a, C> {
20726 self._page_token = Some(new_value.to_string());
20727 self
20728 }
20729 /// 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.
20730 ///
20731 /// Sets the *page size* query property to the given value.
20732 pub fn page_size(mut self, new_value: i32) -> ProjectLocationSourceMigratingVmListCall<'a, C> {
20733 self._page_size = Some(new_value);
20734 self
20735 }
20736 /// Optional. the order by fields for the result.
20737 ///
20738 /// Sets the *order by* query property to the given value.
20739 pub fn order_by(mut self, new_value: &str) -> ProjectLocationSourceMigratingVmListCall<'a, C> {
20740 self._order_by = Some(new_value.to_string());
20741 self
20742 }
20743 /// Optional. The filter request.
20744 ///
20745 /// Sets the *filter* query property to the given value.
20746 pub fn filter(mut self, new_value: &str) -> ProjectLocationSourceMigratingVmListCall<'a, C> {
20747 self._filter = Some(new_value.to_string());
20748 self
20749 }
20750 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20751 /// while executing the actual API request.
20752 ///
20753 /// ````text
20754 /// It should be used to handle progress information, and to implement a certain level of resilience.
20755 /// ````
20756 ///
20757 /// Sets the *delegate* property to the given value.
20758 pub fn delegate(
20759 mut self,
20760 new_value: &'a mut dyn common::Delegate,
20761 ) -> ProjectLocationSourceMigratingVmListCall<'a, C> {
20762 self._delegate = Some(new_value);
20763 self
20764 }
20765
20766 /// Set any additional parameter of the query string used in the request.
20767 /// It should be used to set parameters which are not yet available through their own
20768 /// setters.
20769 ///
20770 /// Please note that this method must not be used to set any of the known parameters
20771 /// which have their own setter method. If done anyway, the request will fail.
20772 ///
20773 /// # Additional Parameters
20774 ///
20775 /// * *$.xgafv* (query-string) - V1 error format.
20776 /// * *access_token* (query-string) - OAuth access token.
20777 /// * *alt* (query-string) - Data format for response.
20778 /// * *callback* (query-string) - JSONP
20779 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20780 /// * *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.
20781 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20782 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20783 /// * *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.
20784 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20785 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20786 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSourceMigratingVmListCall<'a, C>
20787 where
20788 T: AsRef<str>,
20789 {
20790 self._additional_params
20791 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20792 self
20793 }
20794
20795 /// Identifies the authorization scope for the method you are building.
20796 ///
20797 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20798 /// [`Scope::CloudPlatform`].
20799 ///
20800 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20801 /// tokens for more than one scope.
20802 ///
20803 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20804 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20805 /// sufficient, a read-write scope will do as well.
20806 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceMigratingVmListCall<'a, C>
20807 where
20808 St: AsRef<str>,
20809 {
20810 self._scopes.insert(String::from(scope.as_ref()));
20811 self
20812 }
20813 /// Identifies the authorization scope(s) for the method you are building.
20814 ///
20815 /// See [`Self::add_scope()`] for details.
20816 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSourceMigratingVmListCall<'a, C>
20817 where
20818 I: IntoIterator<Item = St>,
20819 St: AsRef<str>,
20820 {
20821 self._scopes
20822 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20823 self
20824 }
20825
20826 /// Removes all scopes, and no default scope will be used either.
20827 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20828 /// for details).
20829 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmListCall<'a, C> {
20830 self._scopes.clear();
20831 self
20832 }
20833}
20834
20835/// Updates the parameters of a single MigratingVm.
20836///
20837/// A builder for the *locations.sources.migratingVms.patch* method supported by a *project* resource.
20838/// It is not used directly, but through a [`ProjectMethods`] instance.
20839///
20840/// # Example
20841///
20842/// Instantiate a resource method builder
20843///
20844/// ```test_harness,no_run
20845/// # extern crate hyper;
20846/// # extern crate hyper_rustls;
20847/// # extern crate google_vmmigration1 as vmmigration1;
20848/// use vmmigration1::api::MigratingVm;
20849/// # async fn dox() {
20850/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20851///
20852/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20853/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20854/// # .with_native_roots()
20855/// # .unwrap()
20856/// # .https_only()
20857/// # .enable_http2()
20858/// # .build();
20859///
20860/// # let executor = hyper_util::rt::TokioExecutor::new();
20861/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20862/// # secret,
20863/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20864/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20865/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20866/// # ),
20867/// # ).build().await.unwrap();
20868///
20869/// # let client = hyper_util::client::legacy::Client::builder(
20870/// # hyper_util::rt::TokioExecutor::new()
20871/// # )
20872/// # .build(
20873/// # hyper_rustls::HttpsConnectorBuilder::new()
20874/// # .with_native_roots()
20875/// # .unwrap()
20876/// # .https_or_http()
20877/// # .enable_http2()
20878/// # .build()
20879/// # );
20880/// # let mut hub = VMMigrationService::new(client, auth);
20881/// // As the method needs a request, you would usually fill it with the desired information
20882/// // into the respective structure. Some of the parts shown here might not be applicable !
20883/// // Values shown here are possibly random and not representative !
20884/// let mut req = MigratingVm::default();
20885///
20886/// // You can configure optional parameters by calling the respective setters at will, and
20887/// // execute the final call using `doit()`.
20888/// // Values shown here are possibly random and not representative !
20889/// let result = hub.projects().locations_sources_migrating_vms_patch(req, "name")
20890/// .update_mask(FieldMask::new::<&str>(&[]))
20891/// .request_id("no")
20892/// .doit().await;
20893/// # }
20894/// ```
20895pub struct ProjectLocationSourceMigratingVmPatchCall<'a, C>
20896where
20897 C: 'a,
20898{
20899 hub: &'a VMMigrationService<C>,
20900 _request: MigratingVm,
20901 _name: String,
20902 _update_mask: Option<common::FieldMask>,
20903 _request_id: Option<String>,
20904 _delegate: Option<&'a mut dyn common::Delegate>,
20905 _additional_params: HashMap<String, String>,
20906 _scopes: BTreeSet<String>,
20907}
20908
20909impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmPatchCall<'a, C> {}
20910
20911impl<'a, C> ProjectLocationSourceMigratingVmPatchCall<'a, C>
20912where
20913 C: common::Connector,
20914{
20915 /// Perform the operation you have build so far.
20916 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
20917 use std::borrow::Cow;
20918 use std::io::{Read, Seek};
20919
20920 use common::{url::Params, ToParts};
20921 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20922
20923 let mut dd = common::DefaultDelegate;
20924 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20925 dlg.begin(common::MethodInfo {
20926 id: "vmmigration.projects.locations.sources.migratingVms.patch",
20927 http_method: hyper::Method::PATCH,
20928 });
20929
20930 for &field in ["alt", "name", "updateMask", "requestId"].iter() {
20931 if self._additional_params.contains_key(field) {
20932 dlg.finished(false);
20933 return Err(common::Error::FieldClash(field));
20934 }
20935 }
20936
20937 let mut params = Params::with_capacity(6 + self._additional_params.len());
20938 params.push("name", self._name);
20939 if let Some(value) = self._update_mask.as_ref() {
20940 params.push("updateMask", value.to_string());
20941 }
20942 if let Some(value) = self._request_id.as_ref() {
20943 params.push("requestId", value);
20944 }
20945
20946 params.extend(self._additional_params.iter());
20947
20948 params.push("alt", "json");
20949 let mut url = self.hub._base_url.clone() + "v1/{+name}";
20950 if self._scopes.is_empty() {
20951 self._scopes
20952 .insert(Scope::CloudPlatform.as_ref().to_string());
20953 }
20954
20955 #[allow(clippy::single_element_loop)]
20956 for &(find_this, param_name) in [("{+name}", "name")].iter() {
20957 url = params.uri_replacement(url, param_name, find_this, true);
20958 }
20959 {
20960 let to_remove = ["name"];
20961 params.remove_params(&to_remove);
20962 }
20963
20964 let url = params.parse_with_url(&url);
20965
20966 let mut json_mime_type = mime::APPLICATION_JSON;
20967 let mut request_value_reader = {
20968 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20969 common::remove_json_null_values(&mut value);
20970 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20971 serde_json::to_writer(&mut dst, &value).unwrap();
20972 dst
20973 };
20974 let request_size = request_value_reader
20975 .seek(std::io::SeekFrom::End(0))
20976 .unwrap();
20977 request_value_reader
20978 .seek(std::io::SeekFrom::Start(0))
20979 .unwrap();
20980
20981 loop {
20982 let token = match self
20983 .hub
20984 .auth
20985 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20986 .await
20987 {
20988 Ok(token) => token,
20989 Err(e) => match dlg.token(e) {
20990 Ok(token) => token,
20991 Err(e) => {
20992 dlg.finished(false);
20993 return Err(common::Error::MissingToken(e));
20994 }
20995 },
20996 };
20997 request_value_reader
20998 .seek(std::io::SeekFrom::Start(0))
20999 .unwrap();
21000 let mut req_result = {
21001 let client = &self.hub.client;
21002 dlg.pre_request();
21003 let mut req_builder = hyper::Request::builder()
21004 .method(hyper::Method::PATCH)
21005 .uri(url.as_str())
21006 .header(USER_AGENT, self.hub._user_agent.clone());
21007
21008 if let Some(token) = token.as_ref() {
21009 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21010 }
21011
21012 let request = req_builder
21013 .header(CONTENT_TYPE, json_mime_type.to_string())
21014 .header(CONTENT_LENGTH, request_size as u64)
21015 .body(common::to_body(
21016 request_value_reader.get_ref().clone().into(),
21017 ));
21018
21019 client.request(request.unwrap()).await
21020 };
21021
21022 match req_result {
21023 Err(err) => {
21024 if let common::Retry::After(d) = dlg.http_error(&err) {
21025 sleep(d).await;
21026 continue;
21027 }
21028 dlg.finished(false);
21029 return Err(common::Error::HttpError(err));
21030 }
21031 Ok(res) => {
21032 let (mut parts, body) = res.into_parts();
21033 let mut body = common::Body::new(body);
21034 if !parts.status.is_success() {
21035 let bytes = common::to_bytes(body).await.unwrap_or_default();
21036 let error = serde_json::from_str(&common::to_string(&bytes));
21037 let response = common::to_response(parts, bytes.into());
21038
21039 if let common::Retry::After(d) =
21040 dlg.http_failure(&response, error.as_ref().ok())
21041 {
21042 sleep(d).await;
21043 continue;
21044 }
21045
21046 dlg.finished(false);
21047
21048 return Err(match error {
21049 Ok(value) => common::Error::BadRequest(value),
21050 _ => common::Error::Failure(response),
21051 });
21052 }
21053 let response = {
21054 let bytes = common::to_bytes(body).await.unwrap_or_default();
21055 let encoded = common::to_string(&bytes);
21056 match serde_json::from_str(&encoded) {
21057 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21058 Err(error) => {
21059 dlg.response_json_decode_error(&encoded, &error);
21060 return Err(common::Error::JsonDecodeError(
21061 encoded.to_string(),
21062 error,
21063 ));
21064 }
21065 }
21066 };
21067
21068 dlg.finished(true);
21069 return Ok(response);
21070 }
21071 }
21072 }
21073 }
21074
21075 ///
21076 /// Sets the *request* property to the given value.
21077 ///
21078 /// Even though the property as already been set when instantiating this call,
21079 /// we provide this method for API completeness.
21080 pub fn request(
21081 mut self,
21082 new_value: MigratingVm,
21083 ) -> ProjectLocationSourceMigratingVmPatchCall<'a, C> {
21084 self._request = new_value;
21085 self
21086 }
21087 /// Output only. The identifier of the MigratingVm.
21088 ///
21089 /// Sets the *name* path property to the given value.
21090 ///
21091 /// Even though the property as already been set when instantiating this call,
21092 /// we provide this method for API completeness.
21093 pub fn name(mut self, new_value: &str) -> ProjectLocationSourceMigratingVmPatchCall<'a, C> {
21094 self._name = new_value.to_string();
21095 self
21096 }
21097 /// 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.
21098 ///
21099 /// Sets the *update mask* query property to the given value.
21100 pub fn update_mask(
21101 mut self,
21102 new_value: common::FieldMask,
21103 ) -> ProjectLocationSourceMigratingVmPatchCall<'a, C> {
21104 self._update_mask = Some(new_value);
21105 self
21106 }
21107 /// 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).
21108 ///
21109 /// Sets the *request id* query property to the given value.
21110 pub fn request_id(
21111 mut self,
21112 new_value: &str,
21113 ) -> ProjectLocationSourceMigratingVmPatchCall<'a, C> {
21114 self._request_id = Some(new_value.to_string());
21115 self
21116 }
21117 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21118 /// while executing the actual API request.
21119 ///
21120 /// ````text
21121 /// It should be used to handle progress information, and to implement a certain level of resilience.
21122 /// ````
21123 ///
21124 /// Sets the *delegate* property to the given value.
21125 pub fn delegate(
21126 mut self,
21127 new_value: &'a mut dyn common::Delegate,
21128 ) -> ProjectLocationSourceMigratingVmPatchCall<'a, C> {
21129 self._delegate = Some(new_value);
21130 self
21131 }
21132
21133 /// Set any additional parameter of the query string used in the request.
21134 /// It should be used to set parameters which are not yet available through their own
21135 /// setters.
21136 ///
21137 /// Please note that this method must not be used to set any of the known parameters
21138 /// which have their own setter method. If done anyway, the request will fail.
21139 ///
21140 /// # Additional Parameters
21141 ///
21142 /// * *$.xgafv* (query-string) - V1 error format.
21143 /// * *access_token* (query-string) - OAuth access token.
21144 /// * *alt* (query-string) - Data format for response.
21145 /// * *callback* (query-string) - JSONP
21146 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21147 /// * *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.
21148 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21149 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21150 /// * *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.
21151 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21152 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21153 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSourceMigratingVmPatchCall<'a, C>
21154 where
21155 T: AsRef<str>,
21156 {
21157 self._additional_params
21158 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21159 self
21160 }
21161
21162 /// Identifies the authorization scope for the method you are building.
21163 ///
21164 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21165 /// [`Scope::CloudPlatform`].
21166 ///
21167 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21168 /// tokens for more than one scope.
21169 ///
21170 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21171 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21172 /// sufficient, a read-write scope will do as well.
21173 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceMigratingVmPatchCall<'a, C>
21174 where
21175 St: AsRef<str>,
21176 {
21177 self._scopes.insert(String::from(scope.as_ref()));
21178 self
21179 }
21180 /// Identifies the authorization scope(s) for the method you are building.
21181 ///
21182 /// See [`Self::add_scope()`] for details.
21183 pub fn add_scopes<I, St>(
21184 mut self,
21185 scopes: I,
21186 ) -> ProjectLocationSourceMigratingVmPatchCall<'a, C>
21187 where
21188 I: IntoIterator<Item = St>,
21189 St: AsRef<str>,
21190 {
21191 self._scopes
21192 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21193 self
21194 }
21195
21196 /// Removes all scopes, and no default scope will be used either.
21197 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21198 /// for details).
21199 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmPatchCall<'a, C> {
21200 self._scopes.clear();
21201 self
21202 }
21203}
21204
21205/// 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.
21206///
21207/// A builder for the *locations.sources.migratingVms.pauseMigration* method supported by a *project* resource.
21208/// It is not used directly, but through a [`ProjectMethods`] instance.
21209///
21210/// # Example
21211///
21212/// Instantiate a resource method builder
21213///
21214/// ```test_harness,no_run
21215/// # extern crate hyper;
21216/// # extern crate hyper_rustls;
21217/// # extern crate google_vmmigration1 as vmmigration1;
21218/// use vmmigration1::api::PauseMigrationRequest;
21219/// # async fn dox() {
21220/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21221///
21222/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21223/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21224/// # .with_native_roots()
21225/// # .unwrap()
21226/// # .https_only()
21227/// # .enable_http2()
21228/// # .build();
21229///
21230/// # let executor = hyper_util::rt::TokioExecutor::new();
21231/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21232/// # secret,
21233/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21234/// # yup_oauth2::client::CustomHyperClientBuilder::from(
21235/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
21236/// # ),
21237/// # ).build().await.unwrap();
21238///
21239/// # let client = hyper_util::client::legacy::Client::builder(
21240/// # hyper_util::rt::TokioExecutor::new()
21241/// # )
21242/// # .build(
21243/// # hyper_rustls::HttpsConnectorBuilder::new()
21244/// # .with_native_roots()
21245/// # .unwrap()
21246/// # .https_or_http()
21247/// # .enable_http2()
21248/// # .build()
21249/// # );
21250/// # let mut hub = VMMigrationService::new(client, auth);
21251/// // As the method needs a request, you would usually fill it with the desired information
21252/// // into the respective structure. Some of the parts shown here might not be applicable !
21253/// // Values shown here are possibly random and not representative !
21254/// let mut req = PauseMigrationRequest::default();
21255///
21256/// // You can configure optional parameters by calling the respective setters at will, and
21257/// // execute the final call using `doit()`.
21258/// // Values shown here are possibly random and not representative !
21259/// let result = hub.projects().locations_sources_migrating_vms_pause_migration(req, "migratingVm")
21260/// .doit().await;
21261/// # }
21262/// ```
21263pub struct ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C>
21264where
21265 C: 'a,
21266{
21267 hub: &'a VMMigrationService<C>,
21268 _request: PauseMigrationRequest,
21269 _migrating_vm: String,
21270 _delegate: Option<&'a mut dyn common::Delegate>,
21271 _additional_params: HashMap<String, String>,
21272 _scopes: BTreeSet<String>,
21273}
21274
21275impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C> {}
21276
21277impl<'a, C> ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C>
21278where
21279 C: common::Connector,
21280{
21281 /// Perform the operation you have build so far.
21282 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
21283 use std::borrow::Cow;
21284 use std::io::{Read, Seek};
21285
21286 use common::{url::Params, ToParts};
21287 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21288
21289 let mut dd = common::DefaultDelegate;
21290 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21291 dlg.begin(common::MethodInfo {
21292 id: "vmmigration.projects.locations.sources.migratingVms.pauseMigration",
21293 http_method: hyper::Method::POST,
21294 });
21295
21296 for &field in ["alt", "migratingVm"].iter() {
21297 if self._additional_params.contains_key(field) {
21298 dlg.finished(false);
21299 return Err(common::Error::FieldClash(field));
21300 }
21301 }
21302
21303 let mut params = Params::with_capacity(4 + self._additional_params.len());
21304 params.push("migratingVm", self._migrating_vm);
21305
21306 params.extend(self._additional_params.iter());
21307
21308 params.push("alt", "json");
21309 let mut url = self.hub._base_url.clone() + "v1/{+migratingVm}:pauseMigration";
21310 if self._scopes.is_empty() {
21311 self._scopes
21312 .insert(Scope::CloudPlatform.as_ref().to_string());
21313 }
21314
21315 #[allow(clippy::single_element_loop)]
21316 for &(find_this, param_name) in [("{+migratingVm}", "migratingVm")].iter() {
21317 url = params.uri_replacement(url, param_name, find_this, true);
21318 }
21319 {
21320 let to_remove = ["migratingVm"];
21321 params.remove_params(&to_remove);
21322 }
21323
21324 let url = params.parse_with_url(&url);
21325
21326 let mut json_mime_type = mime::APPLICATION_JSON;
21327 let mut request_value_reader = {
21328 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21329 common::remove_json_null_values(&mut value);
21330 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21331 serde_json::to_writer(&mut dst, &value).unwrap();
21332 dst
21333 };
21334 let request_size = request_value_reader
21335 .seek(std::io::SeekFrom::End(0))
21336 .unwrap();
21337 request_value_reader
21338 .seek(std::io::SeekFrom::Start(0))
21339 .unwrap();
21340
21341 loop {
21342 let token = match self
21343 .hub
21344 .auth
21345 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21346 .await
21347 {
21348 Ok(token) => token,
21349 Err(e) => match dlg.token(e) {
21350 Ok(token) => token,
21351 Err(e) => {
21352 dlg.finished(false);
21353 return Err(common::Error::MissingToken(e));
21354 }
21355 },
21356 };
21357 request_value_reader
21358 .seek(std::io::SeekFrom::Start(0))
21359 .unwrap();
21360 let mut req_result = {
21361 let client = &self.hub.client;
21362 dlg.pre_request();
21363 let mut req_builder = hyper::Request::builder()
21364 .method(hyper::Method::POST)
21365 .uri(url.as_str())
21366 .header(USER_AGENT, self.hub._user_agent.clone());
21367
21368 if let Some(token) = token.as_ref() {
21369 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21370 }
21371
21372 let request = req_builder
21373 .header(CONTENT_TYPE, json_mime_type.to_string())
21374 .header(CONTENT_LENGTH, request_size as u64)
21375 .body(common::to_body(
21376 request_value_reader.get_ref().clone().into(),
21377 ));
21378
21379 client.request(request.unwrap()).await
21380 };
21381
21382 match req_result {
21383 Err(err) => {
21384 if let common::Retry::After(d) = dlg.http_error(&err) {
21385 sleep(d).await;
21386 continue;
21387 }
21388 dlg.finished(false);
21389 return Err(common::Error::HttpError(err));
21390 }
21391 Ok(res) => {
21392 let (mut parts, body) = res.into_parts();
21393 let mut body = common::Body::new(body);
21394 if !parts.status.is_success() {
21395 let bytes = common::to_bytes(body).await.unwrap_or_default();
21396 let error = serde_json::from_str(&common::to_string(&bytes));
21397 let response = common::to_response(parts, bytes.into());
21398
21399 if let common::Retry::After(d) =
21400 dlg.http_failure(&response, error.as_ref().ok())
21401 {
21402 sleep(d).await;
21403 continue;
21404 }
21405
21406 dlg.finished(false);
21407
21408 return Err(match error {
21409 Ok(value) => common::Error::BadRequest(value),
21410 _ => common::Error::Failure(response),
21411 });
21412 }
21413 let response = {
21414 let bytes = common::to_bytes(body).await.unwrap_or_default();
21415 let encoded = common::to_string(&bytes);
21416 match serde_json::from_str(&encoded) {
21417 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21418 Err(error) => {
21419 dlg.response_json_decode_error(&encoded, &error);
21420 return Err(common::Error::JsonDecodeError(
21421 encoded.to_string(),
21422 error,
21423 ));
21424 }
21425 }
21426 };
21427
21428 dlg.finished(true);
21429 return Ok(response);
21430 }
21431 }
21432 }
21433 }
21434
21435 ///
21436 /// Sets the *request* property to the given value.
21437 ///
21438 /// Even though the property as already been set when instantiating this call,
21439 /// we provide this method for API completeness.
21440 pub fn request(
21441 mut self,
21442 new_value: PauseMigrationRequest,
21443 ) -> ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C> {
21444 self._request = new_value;
21445 self
21446 }
21447 /// Required. The name of the MigratingVm.
21448 ///
21449 /// Sets the *migrating vm* path property to the given value.
21450 ///
21451 /// Even though the property as already been set when instantiating this call,
21452 /// we provide this method for API completeness.
21453 pub fn migrating_vm(
21454 mut self,
21455 new_value: &str,
21456 ) -> ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C> {
21457 self._migrating_vm = new_value.to_string();
21458 self
21459 }
21460 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21461 /// while executing the actual API request.
21462 ///
21463 /// ````text
21464 /// It should be used to handle progress information, and to implement a certain level of resilience.
21465 /// ````
21466 ///
21467 /// Sets the *delegate* property to the given value.
21468 pub fn delegate(
21469 mut self,
21470 new_value: &'a mut dyn common::Delegate,
21471 ) -> ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C> {
21472 self._delegate = Some(new_value);
21473 self
21474 }
21475
21476 /// Set any additional parameter of the query string used in the request.
21477 /// It should be used to set parameters which are not yet available through their own
21478 /// setters.
21479 ///
21480 /// Please note that this method must not be used to set any of the known parameters
21481 /// which have their own setter method. If done anyway, the request will fail.
21482 ///
21483 /// # Additional Parameters
21484 ///
21485 /// * *$.xgafv* (query-string) - V1 error format.
21486 /// * *access_token* (query-string) - OAuth access token.
21487 /// * *alt* (query-string) - Data format for response.
21488 /// * *callback* (query-string) - JSONP
21489 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21490 /// * *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.
21491 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21492 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21493 /// * *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.
21494 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21495 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21496 pub fn param<T>(
21497 mut self,
21498 name: T,
21499 value: T,
21500 ) -> ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C>
21501 where
21502 T: AsRef<str>,
21503 {
21504 self._additional_params
21505 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21506 self
21507 }
21508
21509 /// Identifies the authorization scope for the method you are building.
21510 ///
21511 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21512 /// [`Scope::CloudPlatform`].
21513 ///
21514 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21515 /// tokens for more than one scope.
21516 ///
21517 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21518 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21519 /// sufficient, a read-write scope will do as well.
21520 pub fn add_scope<St>(
21521 mut self,
21522 scope: St,
21523 ) -> ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C>
21524 where
21525 St: AsRef<str>,
21526 {
21527 self._scopes.insert(String::from(scope.as_ref()));
21528 self
21529 }
21530 /// Identifies the authorization scope(s) for the method you are building.
21531 ///
21532 /// See [`Self::add_scope()`] for details.
21533 pub fn add_scopes<I, St>(
21534 mut self,
21535 scopes: I,
21536 ) -> ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C>
21537 where
21538 I: IntoIterator<Item = St>,
21539 St: AsRef<str>,
21540 {
21541 self._scopes
21542 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21543 self
21544 }
21545
21546 /// Removes all scopes, and no default scope will be used either.
21547 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21548 /// for details).
21549 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmPauseMigrationCall<'a, C> {
21550 self._scopes.clear();
21551 self
21552 }
21553}
21554
21555/// 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.
21556///
21557/// A builder for the *locations.sources.migratingVms.resumeMigration* method supported by a *project* resource.
21558/// It is not used directly, but through a [`ProjectMethods`] instance.
21559///
21560/// # Example
21561///
21562/// Instantiate a resource method builder
21563///
21564/// ```test_harness,no_run
21565/// # extern crate hyper;
21566/// # extern crate hyper_rustls;
21567/// # extern crate google_vmmigration1 as vmmigration1;
21568/// use vmmigration1::api::ResumeMigrationRequest;
21569/// # async fn dox() {
21570/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21571///
21572/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21573/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21574/// # .with_native_roots()
21575/// # .unwrap()
21576/// # .https_only()
21577/// # .enable_http2()
21578/// # .build();
21579///
21580/// # let executor = hyper_util::rt::TokioExecutor::new();
21581/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21582/// # secret,
21583/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21584/// # yup_oauth2::client::CustomHyperClientBuilder::from(
21585/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
21586/// # ),
21587/// # ).build().await.unwrap();
21588///
21589/// # let client = hyper_util::client::legacy::Client::builder(
21590/// # hyper_util::rt::TokioExecutor::new()
21591/// # )
21592/// # .build(
21593/// # hyper_rustls::HttpsConnectorBuilder::new()
21594/// # .with_native_roots()
21595/// # .unwrap()
21596/// # .https_or_http()
21597/// # .enable_http2()
21598/// # .build()
21599/// # );
21600/// # let mut hub = VMMigrationService::new(client, auth);
21601/// // As the method needs a request, you would usually fill it with the desired information
21602/// // into the respective structure. Some of the parts shown here might not be applicable !
21603/// // Values shown here are possibly random and not representative !
21604/// let mut req = ResumeMigrationRequest::default();
21605///
21606/// // You can configure optional parameters by calling the respective setters at will, and
21607/// // execute the final call using `doit()`.
21608/// // Values shown here are possibly random and not representative !
21609/// let result = hub.projects().locations_sources_migrating_vms_resume_migration(req, "migratingVm")
21610/// .doit().await;
21611/// # }
21612/// ```
21613pub struct ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C>
21614where
21615 C: 'a,
21616{
21617 hub: &'a VMMigrationService<C>,
21618 _request: ResumeMigrationRequest,
21619 _migrating_vm: String,
21620 _delegate: Option<&'a mut dyn common::Delegate>,
21621 _additional_params: HashMap<String, String>,
21622 _scopes: BTreeSet<String>,
21623}
21624
21625impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C> {}
21626
21627impl<'a, C> ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C>
21628where
21629 C: common::Connector,
21630{
21631 /// Perform the operation you have build so far.
21632 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
21633 use std::borrow::Cow;
21634 use std::io::{Read, Seek};
21635
21636 use common::{url::Params, ToParts};
21637 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21638
21639 let mut dd = common::DefaultDelegate;
21640 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21641 dlg.begin(common::MethodInfo {
21642 id: "vmmigration.projects.locations.sources.migratingVms.resumeMigration",
21643 http_method: hyper::Method::POST,
21644 });
21645
21646 for &field in ["alt", "migratingVm"].iter() {
21647 if self._additional_params.contains_key(field) {
21648 dlg.finished(false);
21649 return Err(common::Error::FieldClash(field));
21650 }
21651 }
21652
21653 let mut params = Params::with_capacity(4 + self._additional_params.len());
21654 params.push("migratingVm", self._migrating_vm);
21655
21656 params.extend(self._additional_params.iter());
21657
21658 params.push("alt", "json");
21659 let mut url = self.hub._base_url.clone() + "v1/{+migratingVm}:resumeMigration";
21660 if self._scopes.is_empty() {
21661 self._scopes
21662 .insert(Scope::CloudPlatform.as_ref().to_string());
21663 }
21664
21665 #[allow(clippy::single_element_loop)]
21666 for &(find_this, param_name) in [("{+migratingVm}", "migratingVm")].iter() {
21667 url = params.uri_replacement(url, param_name, find_this, true);
21668 }
21669 {
21670 let to_remove = ["migratingVm"];
21671 params.remove_params(&to_remove);
21672 }
21673
21674 let url = params.parse_with_url(&url);
21675
21676 let mut json_mime_type = mime::APPLICATION_JSON;
21677 let mut request_value_reader = {
21678 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21679 common::remove_json_null_values(&mut value);
21680 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21681 serde_json::to_writer(&mut dst, &value).unwrap();
21682 dst
21683 };
21684 let request_size = request_value_reader
21685 .seek(std::io::SeekFrom::End(0))
21686 .unwrap();
21687 request_value_reader
21688 .seek(std::io::SeekFrom::Start(0))
21689 .unwrap();
21690
21691 loop {
21692 let token = match self
21693 .hub
21694 .auth
21695 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21696 .await
21697 {
21698 Ok(token) => token,
21699 Err(e) => match dlg.token(e) {
21700 Ok(token) => token,
21701 Err(e) => {
21702 dlg.finished(false);
21703 return Err(common::Error::MissingToken(e));
21704 }
21705 },
21706 };
21707 request_value_reader
21708 .seek(std::io::SeekFrom::Start(0))
21709 .unwrap();
21710 let mut req_result = {
21711 let client = &self.hub.client;
21712 dlg.pre_request();
21713 let mut req_builder = hyper::Request::builder()
21714 .method(hyper::Method::POST)
21715 .uri(url.as_str())
21716 .header(USER_AGENT, self.hub._user_agent.clone());
21717
21718 if let Some(token) = token.as_ref() {
21719 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21720 }
21721
21722 let request = req_builder
21723 .header(CONTENT_TYPE, json_mime_type.to_string())
21724 .header(CONTENT_LENGTH, request_size as u64)
21725 .body(common::to_body(
21726 request_value_reader.get_ref().clone().into(),
21727 ));
21728
21729 client.request(request.unwrap()).await
21730 };
21731
21732 match req_result {
21733 Err(err) => {
21734 if let common::Retry::After(d) = dlg.http_error(&err) {
21735 sleep(d).await;
21736 continue;
21737 }
21738 dlg.finished(false);
21739 return Err(common::Error::HttpError(err));
21740 }
21741 Ok(res) => {
21742 let (mut parts, body) = res.into_parts();
21743 let mut body = common::Body::new(body);
21744 if !parts.status.is_success() {
21745 let bytes = common::to_bytes(body).await.unwrap_or_default();
21746 let error = serde_json::from_str(&common::to_string(&bytes));
21747 let response = common::to_response(parts, bytes.into());
21748
21749 if let common::Retry::After(d) =
21750 dlg.http_failure(&response, error.as_ref().ok())
21751 {
21752 sleep(d).await;
21753 continue;
21754 }
21755
21756 dlg.finished(false);
21757
21758 return Err(match error {
21759 Ok(value) => common::Error::BadRequest(value),
21760 _ => common::Error::Failure(response),
21761 });
21762 }
21763 let response = {
21764 let bytes = common::to_bytes(body).await.unwrap_or_default();
21765 let encoded = common::to_string(&bytes);
21766 match serde_json::from_str(&encoded) {
21767 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21768 Err(error) => {
21769 dlg.response_json_decode_error(&encoded, &error);
21770 return Err(common::Error::JsonDecodeError(
21771 encoded.to_string(),
21772 error,
21773 ));
21774 }
21775 }
21776 };
21777
21778 dlg.finished(true);
21779 return Ok(response);
21780 }
21781 }
21782 }
21783 }
21784
21785 ///
21786 /// Sets the *request* property to the given value.
21787 ///
21788 /// Even though the property as already been set when instantiating this call,
21789 /// we provide this method for API completeness.
21790 pub fn request(
21791 mut self,
21792 new_value: ResumeMigrationRequest,
21793 ) -> ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C> {
21794 self._request = new_value;
21795 self
21796 }
21797 /// Required. The name of the MigratingVm.
21798 ///
21799 /// Sets the *migrating vm* path property to the given value.
21800 ///
21801 /// Even though the property as already been set when instantiating this call,
21802 /// we provide this method for API completeness.
21803 pub fn migrating_vm(
21804 mut self,
21805 new_value: &str,
21806 ) -> ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C> {
21807 self._migrating_vm = new_value.to_string();
21808 self
21809 }
21810 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21811 /// while executing the actual API request.
21812 ///
21813 /// ````text
21814 /// It should be used to handle progress information, and to implement a certain level of resilience.
21815 /// ````
21816 ///
21817 /// Sets the *delegate* property to the given value.
21818 pub fn delegate(
21819 mut self,
21820 new_value: &'a mut dyn common::Delegate,
21821 ) -> ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C> {
21822 self._delegate = Some(new_value);
21823 self
21824 }
21825
21826 /// Set any additional parameter of the query string used in the request.
21827 /// It should be used to set parameters which are not yet available through their own
21828 /// setters.
21829 ///
21830 /// Please note that this method must not be used to set any of the known parameters
21831 /// which have their own setter method. If done anyway, the request will fail.
21832 ///
21833 /// # Additional Parameters
21834 ///
21835 /// * *$.xgafv* (query-string) - V1 error format.
21836 /// * *access_token* (query-string) - OAuth access token.
21837 /// * *alt* (query-string) - Data format for response.
21838 /// * *callback* (query-string) - JSONP
21839 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21840 /// * *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.
21841 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21842 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21843 /// * *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.
21844 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21845 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21846 pub fn param<T>(
21847 mut self,
21848 name: T,
21849 value: T,
21850 ) -> ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C>
21851 where
21852 T: AsRef<str>,
21853 {
21854 self._additional_params
21855 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21856 self
21857 }
21858
21859 /// Identifies the authorization scope for the method you are building.
21860 ///
21861 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21862 /// [`Scope::CloudPlatform`].
21863 ///
21864 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21865 /// tokens for more than one scope.
21866 ///
21867 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21868 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21869 /// sufficient, a read-write scope will do as well.
21870 pub fn add_scope<St>(
21871 mut self,
21872 scope: St,
21873 ) -> ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C>
21874 where
21875 St: AsRef<str>,
21876 {
21877 self._scopes.insert(String::from(scope.as_ref()));
21878 self
21879 }
21880 /// Identifies the authorization scope(s) for the method you are building.
21881 ///
21882 /// See [`Self::add_scope()`] for details.
21883 pub fn add_scopes<I, St>(
21884 mut self,
21885 scopes: I,
21886 ) -> ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C>
21887 where
21888 I: IntoIterator<Item = St>,
21889 St: AsRef<str>,
21890 {
21891 self._scopes
21892 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21893 self
21894 }
21895
21896 /// Removes all scopes, and no default scope will be used either.
21897 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21898 /// for details).
21899 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmResumeMigrationCall<'a, C> {
21900 self._scopes.clear();
21901 self
21902 }
21903}
21904
21905/// Starts migration for a VM. Starts the process of uploading data and creating snapshots, in replication cycles scheduled by the policy.
21906///
21907/// A builder for the *locations.sources.migratingVms.startMigration* method supported by a *project* resource.
21908/// It is not used directly, but through a [`ProjectMethods`] instance.
21909///
21910/// # Example
21911///
21912/// Instantiate a resource method builder
21913///
21914/// ```test_harness,no_run
21915/// # extern crate hyper;
21916/// # extern crate hyper_rustls;
21917/// # extern crate google_vmmigration1 as vmmigration1;
21918/// use vmmigration1::api::StartMigrationRequest;
21919/// # async fn dox() {
21920/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21921///
21922/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21923/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21924/// # .with_native_roots()
21925/// # .unwrap()
21926/// # .https_only()
21927/// # .enable_http2()
21928/// # .build();
21929///
21930/// # let executor = hyper_util::rt::TokioExecutor::new();
21931/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21932/// # secret,
21933/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21934/// # yup_oauth2::client::CustomHyperClientBuilder::from(
21935/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
21936/// # ),
21937/// # ).build().await.unwrap();
21938///
21939/// # let client = hyper_util::client::legacy::Client::builder(
21940/// # hyper_util::rt::TokioExecutor::new()
21941/// # )
21942/// # .build(
21943/// # hyper_rustls::HttpsConnectorBuilder::new()
21944/// # .with_native_roots()
21945/// # .unwrap()
21946/// # .https_or_http()
21947/// # .enable_http2()
21948/// # .build()
21949/// # );
21950/// # let mut hub = VMMigrationService::new(client, auth);
21951/// // As the method needs a request, you would usually fill it with the desired information
21952/// // into the respective structure. Some of the parts shown here might not be applicable !
21953/// // Values shown here are possibly random and not representative !
21954/// let mut req = StartMigrationRequest::default();
21955///
21956/// // You can configure optional parameters by calling the respective setters at will, and
21957/// // execute the final call using `doit()`.
21958/// // Values shown here are possibly random and not representative !
21959/// let result = hub.projects().locations_sources_migrating_vms_start_migration(req, "migratingVm")
21960/// .doit().await;
21961/// # }
21962/// ```
21963pub struct ProjectLocationSourceMigratingVmStartMigrationCall<'a, C>
21964where
21965 C: 'a,
21966{
21967 hub: &'a VMMigrationService<C>,
21968 _request: StartMigrationRequest,
21969 _migrating_vm: String,
21970 _delegate: Option<&'a mut dyn common::Delegate>,
21971 _additional_params: HashMap<String, String>,
21972 _scopes: BTreeSet<String>,
21973}
21974
21975impl<'a, C> common::CallBuilder for ProjectLocationSourceMigratingVmStartMigrationCall<'a, C> {}
21976
21977impl<'a, C> ProjectLocationSourceMigratingVmStartMigrationCall<'a, C>
21978where
21979 C: common::Connector,
21980{
21981 /// Perform the operation you have build so far.
21982 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
21983 use std::borrow::Cow;
21984 use std::io::{Read, Seek};
21985
21986 use common::{url::Params, ToParts};
21987 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21988
21989 let mut dd = common::DefaultDelegate;
21990 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21991 dlg.begin(common::MethodInfo {
21992 id: "vmmigration.projects.locations.sources.migratingVms.startMigration",
21993 http_method: hyper::Method::POST,
21994 });
21995
21996 for &field in ["alt", "migratingVm"].iter() {
21997 if self._additional_params.contains_key(field) {
21998 dlg.finished(false);
21999 return Err(common::Error::FieldClash(field));
22000 }
22001 }
22002
22003 let mut params = Params::with_capacity(4 + self._additional_params.len());
22004 params.push("migratingVm", self._migrating_vm);
22005
22006 params.extend(self._additional_params.iter());
22007
22008 params.push("alt", "json");
22009 let mut url = self.hub._base_url.clone() + "v1/{+migratingVm}:startMigration";
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 [("{+migratingVm}", "migratingVm")].iter() {
22017 url = params.uri_replacement(url, param_name, find_this, true);
22018 }
22019 {
22020 let to_remove = ["migratingVm"];
22021 params.remove_params(&to_remove);
22022 }
22023
22024 let url = params.parse_with_url(&url);
22025
22026 let mut json_mime_type = mime::APPLICATION_JSON;
22027 let mut request_value_reader = {
22028 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22029 common::remove_json_null_values(&mut value);
22030 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22031 serde_json::to_writer(&mut dst, &value).unwrap();
22032 dst
22033 };
22034 let request_size = request_value_reader
22035 .seek(std::io::SeekFrom::End(0))
22036 .unwrap();
22037 request_value_reader
22038 .seek(std::io::SeekFrom::Start(0))
22039 .unwrap();
22040
22041 loop {
22042 let token = match self
22043 .hub
22044 .auth
22045 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22046 .await
22047 {
22048 Ok(token) => token,
22049 Err(e) => match dlg.token(e) {
22050 Ok(token) => token,
22051 Err(e) => {
22052 dlg.finished(false);
22053 return Err(common::Error::MissingToken(e));
22054 }
22055 },
22056 };
22057 request_value_reader
22058 .seek(std::io::SeekFrom::Start(0))
22059 .unwrap();
22060 let mut req_result = {
22061 let client = &self.hub.client;
22062 dlg.pre_request();
22063 let mut req_builder = hyper::Request::builder()
22064 .method(hyper::Method::POST)
22065 .uri(url.as_str())
22066 .header(USER_AGENT, self.hub._user_agent.clone());
22067
22068 if let Some(token) = token.as_ref() {
22069 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22070 }
22071
22072 let request = req_builder
22073 .header(CONTENT_TYPE, json_mime_type.to_string())
22074 .header(CONTENT_LENGTH, request_size as u64)
22075 .body(common::to_body(
22076 request_value_reader.get_ref().clone().into(),
22077 ));
22078
22079 client.request(request.unwrap()).await
22080 };
22081
22082 match req_result {
22083 Err(err) => {
22084 if let common::Retry::After(d) = dlg.http_error(&err) {
22085 sleep(d).await;
22086 continue;
22087 }
22088 dlg.finished(false);
22089 return Err(common::Error::HttpError(err));
22090 }
22091 Ok(res) => {
22092 let (mut parts, body) = res.into_parts();
22093 let mut body = common::Body::new(body);
22094 if !parts.status.is_success() {
22095 let bytes = common::to_bytes(body).await.unwrap_or_default();
22096 let error = serde_json::from_str(&common::to_string(&bytes));
22097 let response = common::to_response(parts, bytes.into());
22098
22099 if let common::Retry::After(d) =
22100 dlg.http_failure(&response, error.as_ref().ok())
22101 {
22102 sleep(d).await;
22103 continue;
22104 }
22105
22106 dlg.finished(false);
22107
22108 return Err(match error {
22109 Ok(value) => common::Error::BadRequest(value),
22110 _ => common::Error::Failure(response),
22111 });
22112 }
22113 let response = {
22114 let bytes = common::to_bytes(body).await.unwrap_or_default();
22115 let encoded = common::to_string(&bytes);
22116 match serde_json::from_str(&encoded) {
22117 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22118 Err(error) => {
22119 dlg.response_json_decode_error(&encoded, &error);
22120 return Err(common::Error::JsonDecodeError(
22121 encoded.to_string(),
22122 error,
22123 ));
22124 }
22125 }
22126 };
22127
22128 dlg.finished(true);
22129 return Ok(response);
22130 }
22131 }
22132 }
22133 }
22134
22135 ///
22136 /// Sets the *request* property to the given value.
22137 ///
22138 /// Even though the property as already been set when instantiating this call,
22139 /// we provide this method for API completeness.
22140 pub fn request(
22141 mut self,
22142 new_value: StartMigrationRequest,
22143 ) -> ProjectLocationSourceMigratingVmStartMigrationCall<'a, C> {
22144 self._request = new_value;
22145 self
22146 }
22147 /// Required. The name of the MigratingVm.
22148 ///
22149 /// Sets the *migrating vm* path property to the given value.
22150 ///
22151 /// Even though the property as already been set when instantiating this call,
22152 /// we provide this method for API completeness.
22153 pub fn migrating_vm(
22154 mut self,
22155 new_value: &str,
22156 ) -> ProjectLocationSourceMigratingVmStartMigrationCall<'a, C> {
22157 self._migrating_vm = new_value.to_string();
22158 self
22159 }
22160 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22161 /// while executing the actual API request.
22162 ///
22163 /// ````text
22164 /// It should be used to handle progress information, and to implement a certain level of resilience.
22165 /// ````
22166 ///
22167 /// Sets the *delegate* property to the given value.
22168 pub fn delegate(
22169 mut self,
22170 new_value: &'a mut dyn common::Delegate,
22171 ) -> ProjectLocationSourceMigratingVmStartMigrationCall<'a, C> {
22172 self._delegate = Some(new_value);
22173 self
22174 }
22175
22176 /// Set any additional parameter of the query string used in the request.
22177 /// It should be used to set parameters which are not yet available through their own
22178 /// setters.
22179 ///
22180 /// Please note that this method must not be used to set any of the known parameters
22181 /// which have their own setter method. If done anyway, the request will fail.
22182 ///
22183 /// # Additional Parameters
22184 ///
22185 /// * *$.xgafv* (query-string) - V1 error format.
22186 /// * *access_token* (query-string) - OAuth access token.
22187 /// * *alt* (query-string) - Data format for response.
22188 /// * *callback* (query-string) - JSONP
22189 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22190 /// * *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.
22191 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22192 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22193 /// * *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.
22194 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22195 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22196 pub fn param<T>(
22197 mut self,
22198 name: T,
22199 value: T,
22200 ) -> ProjectLocationSourceMigratingVmStartMigrationCall<'a, C>
22201 where
22202 T: AsRef<str>,
22203 {
22204 self._additional_params
22205 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22206 self
22207 }
22208
22209 /// Identifies the authorization scope for the method you are building.
22210 ///
22211 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22212 /// [`Scope::CloudPlatform`].
22213 ///
22214 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22215 /// tokens for more than one scope.
22216 ///
22217 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22218 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22219 /// sufficient, a read-write scope will do as well.
22220 pub fn add_scope<St>(
22221 mut self,
22222 scope: St,
22223 ) -> ProjectLocationSourceMigratingVmStartMigrationCall<'a, C>
22224 where
22225 St: AsRef<str>,
22226 {
22227 self._scopes.insert(String::from(scope.as_ref()));
22228 self
22229 }
22230 /// Identifies the authorization scope(s) for the method you are building.
22231 ///
22232 /// See [`Self::add_scope()`] for details.
22233 pub fn add_scopes<I, St>(
22234 mut self,
22235 scopes: I,
22236 ) -> ProjectLocationSourceMigratingVmStartMigrationCall<'a, C>
22237 where
22238 I: IntoIterator<Item = St>,
22239 St: AsRef<str>,
22240 {
22241 self._scopes
22242 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22243 self
22244 }
22245
22246 /// Removes all scopes, and no default scope will be used either.
22247 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22248 /// for details).
22249 pub fn clear_scopes(mut self) -> ProjectLocationSourceMigratingVmStartMigrationCall<'a, C> {
22250 self._scopes.clear();
22251 self
22252 }
22253}
22254
22255/// Creates a new UtilizationReport.
22256///
22257/// A builder for the *locations.sources.utilizationReports.create* method supported by a *project* resource.
22258/// It is not used directly, but through a [`ProjectMethods`] instance.
22259///
22260/// # Example
22261///
22262/// Instantiate a resource method builder
22263///
22264/// ```test_harness,no_run
22265/// # extern crate hyper;
22266/// # extern crate hyper_rustls;
22267/// # extern crate google_vmmigration1 as vmmigration1;
22268/// use vmmigration1::api::UtilizationReport;
22269/// # async fn dox() {
22270/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22271///
22272/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22273/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22274/// # .with_native_roots()
22275/// # .unwrap()
22276/// # .https_only()
22277/// # .enable_http2()
22278/// # .build();
22279///
22280/// # let executor = hyper_util::rt::TokioExecutor::new();
22281/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22282/// # secret,
22283/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22284/// # yup_oauth2::client::CustomHyperClientBuilder::from(
22285/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
22286/// # ),
22287/// # ).build().await.unwrap();
22288///
22289/// # let client = hyper_util::client::legacy::Client::builder(
22290/// # hyper_util::rt::TokioExecutor::new()
22291/// # )
22292/// # .build(
22293/// # hyper_rustls::HttpsConnectorBuilder::new()
22294/// # .with_native_roots()
22295/// # .unwrap()
22296/// # .https_or_http()
22297/// # .enable_http2()
22298/// # .build()
22299/// # );
22300/// # let mut hub = VMMigrationService::new(client, auth);
22301/// // As the method needs a request, you would usually fill it with the desired information
22302/// // into the respective structure. Some of the parts shown here might not be applicable !
22303/// // Values shown here are possibly random and not representative !
22304/// let mut req = UtilizationReport::default();
22305///
22306/// // You can configure optional parameters by calling the respective setters at will, and
22307/// // execute the final call using `doit()`.
22308/// // Values shown here are possibly random and not representative !
22309/// let result = hub.projects().locations_sources_utilization_reports_create(req, "parent")
22310/// .utilization_report_id("nonumy")
22311/// .request_id("At")
22312/// .doit().await;
22313/// # }
22314/// ```
22315pub struct ProjectLocationSourceUtilizationReportCreateCall<'a, C>
22316where
22317 C: 'a,
22318{
22319 hub: &'a VMMigrationService<C>,
22320 _request: UtilizationReport,
22321 _parent: String,
22322 _utilization_report_id: Option<String>,
22323 _request_id: Option<String>,
22324 _delegate: Option<&'a mut dyn common::Delegate>,
22325 _additional_params: HashMap<String, String>,
22326 _scopes: BTreeSet<String>,
22327}
22328
22329impl<'a, C> common::CallBuilder for ProjectLocationSourceUtilizationReportCreateCall<'a, C> {}
22330
22331impl<'a, C> ProjectLocationSourceUtilizationReportCreateCall<'a, C>
22332where
22333 C: common::Connector,
22334{
22335 /// Perform the operation you have build so far.
22336 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
22337 use std::borrow::Cow;
22338 use std::io::{Read, Seek};
22339
22340 use common::{url::Params, ToParts};
22341 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22342
22343 let mut dd = common::DefaultDelegate;
22344 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22345 dlg.begin(common::MethodInfo {
22346 id: "vmmigration.projects.locations.sources.utilizationReports.create",
22347 http_method: hyper::Method::POST,
22348 });
22349
22350 for &field in ["alt", "parent", "utilizationReportId", "requestId"].iter() {
22351 if self._additional_params.contains_key(field) {
22352 dlg.finished(false);
22353 return Err(common::Error::FieldClash(field));
22354 }
22355 }
22356
22357 let mut params = Params::with_capacity(6 + self._additional_params.len());
22358 params.push("parent", self._parent);
22359 if let Some(value) = self._utilization_report_id.as_ref() {
22360 params.push("utilizationReportId", value);
22361 }
22362 if let Some(value) = self._request_id.as_ref() {
22363 params.push("requestId", value);
22364 }
22365
22366 params.extend(self._additional_params.iter());
22367
22368 params.push("alt", "json");
22369 let mut url = self.hub._base_url.clone() + "v1/{+parent}/utilizationReports";
22370 if self._scopes.is_empty() {
22371 self._scopes
22372 .insert(Scope::CloudPlatform.as_ref().to_string());
22373 }
22374
22375 #[allow(clippy::single_element_loop)]
22376 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
22377 url = params.uri_replacement(url, param_name, find_this, true);
22378 }
22379 {
22380 let to_remove = ["parent"];
22381 params.remove_params(&to_remove);
22382 }
22383
22384 let url = params.parse_with_url(&url);
22385
22386 let mut json_mime_type = mime::APPLICATION_JSON;
22387 let mut request_value_reader = {
22388 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22389 common::remove_json_null_values(&mut value);
22390 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22391 serde_json::to_writer(&mut dst, &value).unwrap();
22392 dst
22393 };
22394 let request_size = request_value_reader
22395 .seek(std::io::SeekFrom::End(0))
22396 .unwrap();
22397 request_value_reader
22398 .seek(std::io::SeekFrom::Start(0))
22399 .unwrap();
22400
22401 loop {
22402 let token = match self
22403 .hub
22404 .auth
22405 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22406 .await
22407 {
22408 Ok(token) => token,
22409 Err(e) => match dlg.token(e) {
22410 Ok(token) => token,
22411 Err(e) => {
22412 dlg.finished(false);
22413 return Err(common::Error::MissingToken(e));
22414 }
22415 },
22416 };
22417 request_value_reader
22418 .seek(std::io::SeekFrom::Start(0))
22419 .unwrap();
22420 let mut req_result = {
22421 let client = &self.hub.client;
22422 dlg.pre_request();
22423 let mut req_builder = hyper::Request::builder()
22424 .method(hyper::Method::POST)
22425 .uri(url.as_str())
22426 .header(USER_AGENT, self.hub._user_agent.clone());
22427
22428 if let Some(token) = token.as_ref() {
22429 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22430 }
22431
22432 let request = req_builder
22433 .header(CONTENT_TYPE, json_mime_type.to_string())
22434 .header(CONTENT_LENGTH, request_size as u64)
22435 .body(common::to_body(
22436 request_value_reader.get_ref().clone().into(),
22437 ));
22438
22439 client.request(request.unwrap()).await
22440 };
22441
22442 match req_result {
22443 Err(err) => {
22444 if let common::Retry::After(d) = dlg.http_error(&err) {
22445 sleep(d).await;
22446 continue;
22447 }
22448 dlg.finished(false);
22449 return Err(common::Error::HttpError(err));
22450 }
22451 Ok(res) => {
22452 let (mut parts, body) = res.into_parts();
22453 let mut body = common::Body::new(body);
22454 if !parts.status.is_success() {
22455 let bytes = common::to_bytes(body).await.unwrap_or_default();
22456 let error = serde_json::from_str(&common::to_string(&bytes));
22457 let response = common::to_response(parts, bytes.into());
22458
22459 if let common::Retry::After(d) =
22460 dlg.http_failure(&response, error.as_ref().ok())
22461 {
22462 sleep(d).await;
22463 continue;
22464 }
22465
22466 dlg.finished(false);
22467
22468 return Err(match error {
22469 Ok(value) => common::Error::BadRequest(value),
22470 _ => common::Error::Failure(response),
22471 });
22472 }
22473 let response = {
22474 let bytes = common::to_bytes(body).await.unwrap_or_default();
22475 let encoded = common::to_string(&bytes);
22476 match serde_json::from_str(&encoded) {
22477 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22478 Err(error) => {
22479 dlg.response_json_decode_error(&encoded, &error);
22480 return Err(common::Error::JsonDecodeError(
22481 encoded.to_string(),
22482 error,
22483 ));
22484 }
22485 }
22486 };
22487
22488 dlg.finished(true);
22489 return Ok(response);
22490 }
22491 }
22492 }
22493 }
22494
22495 ///
22496 /// Sets the *request* property to the given value.
22497 ///
22498 /// Even though the property as already been set when instantiating this call,
22499 /// we provide this method for API completeness.
22500 pub fn request(
22501 mut self,
22502 new_value: UtilizationReport,
22503 ) -> ProjectLocationSourceUtilizationReportCreateCall<'a, C> {
22504 self._request = new_value;
22505 self
22506 }
22507 /// Required. The Utilization Report's parent.
22508 ///
22509 /// Sets the *parent* path property to the given value.
22510 ///
22511 /// Even though the property as already been set when instantiating this call,
22512 /// we provide this method for API completeness.
22513 pub fn parent(
22514 mut self,
22515 new_value: &str,
22516 ) -> ProjectLocationSourceUtilizationReportCreateCall<'a, C> {
22517 self._parent = new_value.to_string();
22518 self
22519 }
22520 /// 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.
22521 ///
22522 /// Sets the *utilization report id* query property to the given value.
22523 pub fn utilization_report_id(
22524 mut self,
22525 new_value: &str,
22526 ) -> ProjectLocationSourceUtilizationReportCreateCall<'a, C> {
22527 self._utilization_report_id = Some(new_value.to_string());
22528 self
22529 }
22530 /// 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).
22531 ///
22532 /// Sets the *request id* query property to the given value.
22533 pub fn request_id(
22534 mut self,
22535 new_value: &str,
22536 ) -> ProjectLocationSourceUtilizationReportCreateCall<'a, C> {
22537 self._request_id = Some(new_value.to_string());
22538 self
22539 }
22540 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22541 /// while executing the actual API request.
22542 ///
22543 /// ````text
22544 /// It should be used to handle progress information, and to implement a certain level of resilience.
22545 /// ````
22546 ///
22547 /// Sets the *delegate* property to the given value.
22548 pub fn delegate(
22549 mut self,
22550 new_value: &'a mut dyn common::Delegate,
22551 ) -> ProjectLocationSourceUtilizationReportCreateCall<'a, C> {
22552 self._delegate = Some(new_value);
22553 self
22554 }
22555
22556 /// Set any additional parameter of the query string used in the request.
22557 /// It should be used to set parameters which are not yet available through their own
22558 /// setters.
22559 ///
22560 /// Please note that this method must not be used to set any of the known parameters
22561 /// which have their own setter method. If done anyway, the request will fail.
22562 ///
22563 /// # Additional Parameters
22564 ///
22565 /// * *$.xgafv* (query-string) - V1 error format.
22566 /// * *access_token* (query-string) - OAuth access token.
22567 /// * *alt* (query-string) - Data format for response.
22568 /// * *callback* (query-string) - JSONP
22569 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22570 /// * *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.
22571 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22572 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22573 /// * *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.
22574 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22575 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22576 pub fn param<T>(
22577 mut self,
22578 name: T,
22579 value: T,
22580 ) -> ProjectLocationSourceUtilizationReportCreateCall<'a, C>
22581 where
22582 T: AsRef<str>,
22583 {
22584 self._additional_params
22585 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22586 self
22587 }
22588
22589 /// Identifies the authorization scope for the method you are building.
22590 ///
22591 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22592 /// [`Scope::CloudPlatform`].
22593 ///
22594 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22595 /// tokens for more than one scope.
22596 ///
22597 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22598 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22599 /// sufficient, a read-write scope will do as well.
22600 pub fn add_scope<St>(
22601 mut self,
22602 scope: St,
22603 ) -> ProjectLocationSourceUtilizationReportCreateCall<'a, C>
22604 where
22605 St: AsRef<str>,
22606 {
22607 self._scopes.insert(String::from(scope.as_ref()));
22608 self
22609 }
22610 /// Identifies the authorization scope(s) for the method you are building.
22611 ///
22612 /// See [`Self::add_scope()`] for details.
22613 pub fn add_scopes<I, St>(
22614 mut self,
22615 scopes: I,
22616 ) -> ProjectLocationSourceUtilizationReportCreateCall<'a, C>
22617 where
22618 I: IntoIterator<Item = St>,
22619 St: AsRef<str>,
22620 {
22621 self._scopes
22622 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22623 self
22624 }
22625
22626 /// Removes all scopes, and no default scope will be used either.
22627 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22628 /// for details).
22629 pub fn clear_scopes(mut self) -> ProjectLocationSourceUtilizationReportCreateCall<'a, C> {
22630 self._scopes.clear();
22631 self
22632 }
22633}
22634
22635/// Deletes a single Utilization Report.
22636///
22637/// A builder for the *locations.sources.utilizationReports.delete* method supported by a *project* resource.
22638/// It is not used directly, but through a [`ProjectMethods`] instance.
22639///
22640/// # Example
22641///
22642/// Instantiate a resource method builder
22643///
22644/// ```test_harness,no_run
22645/// # extern crate hyper;
22646/// # extern crate hyper_rustls;
22647/// # extern crate google_vmmigration1 as vmmigration1;
22648/// # async fn dox() {
22649/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22650///
22651/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22652/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22653/// # .with_native_roots()
22654/// # .unwrap()
22655/// # .https_only()
22656/// # .enable_http2()
22657/// # .build();
22658///
22659/// # let executor = hyper_util::rt::TokioExecutor::new();
22660/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22661/// # secret,
22662/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22663/// # yup_oauth2::client::CustomHyperClientBuilder::from(
22664/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
22665/// # ),
22666/// # ).build().await.unwrap();
22667///
22668/// # let client = hyper_util::client::legacy::Client::builder(
22669/// # hyper_util::rt::TokioExecutor::new()
22670/// # )
22671/// # .build(
22672/// # hyper_rustls::HttpsConnectorBuilder::new()
22673/// # .with_native_roots()
22674/// # .unwrap()
22675/// # .https_or_http()
22676/// # .enable_http2()
22677/// # .build()
22678/// # );
22679/// # let mut hub = VMMigrationService::new(client, auth);
22680/// // You can configure optional parameters by calling the respective setters at will, and
22681/// // execute the final call using `doit()`.
22682/// // Values shown here are possibly random and not representative !
22683/// let result = hub.projects().locations_sources_utilization_reports_delete("name")
22684/// .request_id("aliquyam")
22685/// .doit().await;
22686/// # }
22687/// ```
22688pub struct ProjectLocationSourceUtilizationReportDeleteCall<'a, C>
22689where
22690 C: 'a,
22691{
22692 hub: &'a VMMigrationService<C>,
22693 _name: String,
22694 _request_id: Option<String>,
22695 _delegate: Option<&'a mut dyn common::Delegate>,
22696 _additional_params: HashMap<String, String>,
22697 _scopes: BTreeSet<String>,
22698}
22699
22700impl<'a, C> common::CallBuilder for ProjectLocationSourceUtilizationReportDeleteCall<'a, C> {}
22701
22702impl<'a, C> ProjectLocationSourceUtilizationReportDeleteCall<'a, C>
22703where
22704 C: common::Connector,
22705{
22706 /// Perform the operation you have build so far.
22707 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
22708 use std::borrow::Cow;
22709 use std::io::{Read, Seek};
22710
22711 use common::{url::Params, ToParts};
22712 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22713
22714 let mut dd = common::DefaultDelegate;
22715 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22716 dlg.begin(common::MethodInfo {
22717 id: "vmmigration.projects.locations.sources.utilizationReports.delete",
22718 http_method: hyper::Method::DELETE,
22719 });
22720
22721 for &field in ["alt", "name", "requestId"].iter() {
22722 if self._additional_params.contains_key(field) {
22723 dlg.finished(false);
22724 return Err(common::Error::FieldClash(field));
22725 }
22726 }
22727
22728 let mut params = Params::with_capacity(4 + self._additional_params.len());
22729 params.push("name", self._name);
22730 if let Some(value) = self._request_id.as_ref() {
22731 params.push("requestId", value);
22732 }
22733
22734 params.extend(self._additional_params.iter());
22735
22736 params.push("alt", "json");
22737 let mut url = self.hub._base_url.clone() + "v1/{+name}";
22738 if self._scopes.is_empty() {
22739 self._scopes
22740 .insert(Scope::CloudPlatform.as_ref().to_string());
22741 }
22742
22743 #[allow(clippy::single_element_loop)]
22744 for &(find_this, param_name) in [("{+name}", "name")].iter() {
22745 url = params.uri_replacement(url, param_name, find_this, true);
22746 }
22747 {
22748 let to_remove = ["name"];
22749 params.remove_params(&to_remove);
22750 }
22751
22752 let url = params.parse_with_url(&url);
22753
22754 loop {
22755 let token = match self
22756 .hub
22757 .auth
22758 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22759 .await
22760 {
22761 Ok(token) => token,
22762 Err(e) => match dlg.token(e) {
22763 Ok(token) => token,
22764 Err(e) => {
22765 dlg.finished(false);
22766 return Err(common::Error::MissingToken(e));
22767 }
22768 },
22769 };
22770 let mut req_result = {
22771 let client = &self.hub.client;
22772 dlg.pre_request();
22773 let mut req_builder = hyper::Request::builder()
22774 .method(hyper::Method::DELETE)
22775 .uri(url.as_str())
22776 .header(USER_AGENT, self.hub._user_agent.clone());
22777
22778 if let Some(token) = token.as_ref() {
22779 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22780 }
22781
22782 let request = req_builder
22783 .header(CONTENT_LENGTH, 0_u64)
22784 .body(common::to_body::<String>(None));
22785
22786 client.request(request.unwrap()).await
22787 };
22788
22789 match req_result {
22790 Err(err) => {
22791 if let common::Retry::After(d) = dlg.http_error(&err) {
22792 sleep(d).await;
22793 continue;
22794 }
22795 dlg.finished(false);
22796 return Err(common::Error::HttpError(err));
22797 }
22798 Ok(res) => {
22799 let (mut parts, body) = res.into_parts();
22800 let mut body = common::Body::new(body);
22801 if !parts.status.is_success() {
22802 let bytes = common::to_bytes(body).await.unwrap_or_default();
22803 let error = serde_json::from_str(&common::to_string(&bytes));
22804 let response = common::to_response(parts, bytes.into());
22805
22806 if let common::Retry::After(d) =
22807 dlg.http_failure(&response, error.as_ref().ok())
22808 {
22809 sleep(d).await;
22810 continue;
22811 }
22812
22813 dlg.finished(false);
22814
22815 return Err(match error {
22816 Ok(value) => common::Error::BadRequest(value),
22817 _ => common::Error::Failure(response),
22818 });
22819 }
22820 let response = {
22821 let bytes = common::to_bytes(body).await.unwrap_or_default();
22822 let encoded = common::to_string(&bytes);
22823 match serde_json::from_str(&encoded) {
22824 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22825 Err(error) => {
22826 dlg.response_json_decode_error(&encoded, &error);
22827 return Err(common::Error::JsonDecodeError(
22828 encoded.to_string(),
22829 error,
22830 ));
22831 }
22832 }
22833 };
22834
22835 dlg.finished(true);
22836 return Ok(response);
22837 }
22838 }
22839 }
22840 }
22841
22842 /// Required. The Utilization Report name.
22843 ///
22844 /// Sets the *name* path property to the given value.
22845 ///
22846 /// Even though the property as already been set when instantiating this call,
22847 /// we provide this method for API completeness.
22848 pub fn name(
22849 mut self,
22850 new_value: &str,
22851 ) -> ProjectLocationSourceUtilizationReportDeleteCall<'a, C> {
22852 self._name = new_value.to_string();
22853 self
22854 }
22855 /// 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).
22856 ///
22857 /// Sets the *request id* query property to the given value.
22858 pub fn request_id(
22859 mut self,
22860 new_value: &str,
22861 ) -> ProjectLocationSourceUtilizationReportDeleteCall<'a, C> {
22862 self._request_id = Some(new_value.to_string());
22863 self
22864 }
22865 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22866 /// while executing the actual API request.
22867 ///
22868 /// ````text
22869 /// It should be used to handle progress information, and to implement a certain level of resilience.
22870 /// ````
22871 ///
22872 /// Sets the *delegate* property to the given value.
22873 pub fn delegate(
22874 mut self,
22875 new_value: &'a mut dyn common::Delegate,
22876 ) -> ProjectLocationSourceUtilizationReportDeleteCall<'a, C> {
22877 self._delegate = Some(new_value);
22878 self
22879 }
22880
22881 /// Set any additional parameter of the query string used in the request.
22882 /// It should be used to set parameters which are not yet available through their own
22883 /// setters.
22884 ///
22885 /// Please note that this method must not be used to set any of the known parameters
22886 /// which have their own setter method. If done anyway, the request will fail.
22887 ///
22888 /// # Additional Parameters
22889 ///
22890 /// * *$.xgafv* (query-string) - V1 error format.
22891 /// * *access_token* (query-string) - OAuth access token.
22892 /// * *alt* (query-string) - Data format for response.
22893 /// * *callback* (query-string) - JSONP
22894 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22895 /// * *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.
22896 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22897 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22898 /// * *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.
22899 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22900 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22901 pub fn param<T>(
22902 mut self,
22903 name: T,
22904 value: T,
22905 ) -> ProjectLocationSourceUtilizationReportDeleteCall<'a, C>
22906 where
22907 T: AsRef<str>,
22908 {
22909 self._additional_params
22910 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22911 self
22912 }
22913
22914 /// Identifies the authorization scope for the method you are building.
22915 ///
22916 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22917 /// [`Scope::CloudPlatform`].
22918 ///
22919 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22920 /// tokens for more than one scope.
22921 ///
22922 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22923 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22924 /// sufficient, a read-write scope will do as well.
22925 pub fn add_scope<St>(
22926 mut self,
22927 scope: St,
22928 ) -> ProjectLocationSourceUtilizationReportDeleteCall<'a, C>
22929 where
22930 St: AsRef<str>,
22931 {
22932 self._scopes.insert(String::from(scope.as_ref()));
22933 self
22934 }
22935 /// Identifies the authorization scope(s) for the method you are building.
22936 ///
22937 /// See [`Self::add_scope()`] for details.
22938 pub fn add_scopes<I, St>(
22939 mut self,
22940 scopes: I,
22941 ) -> ProjectLocationSourceUtilizationReportDeleteCall<'a, C>
22942 where
22943 I: IntoIterator<Item = St>,
22944 St: AsRef<str>,
22945 {
22946 self._scopes
22947 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22948 self
22949 }
22950
22951 /// Removes all scopes, and no default scope will be used either.
22952 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22953 /// for details).
22954 pub fn clear_scopes(mut self) -> ProjectLocationSourceUtilizationReportDeleteCall<'a, C> {
22955 self._scopes.clear();
22956 self
22957 }
22958}
22959
22960/// Gets a single Utilization Report.
22961///
22962/// A builder for the *locations.sources.utilizationReports.get* method supported by a *project* resource.
22963/// It is not used directly, but through a [`ProjectMethods`] instance.
22964///
22965/// # Example
22966///
22967/// Instantiate a resource method builder
22968///
22969/// ```test_harness,no_run
22970/// # extern crate hyper;
22971/// # extern crate hyper_rustls;
22972/// # extern crate google_vmmigration1 as vmmigration1;
22973/// # async fn dox() {
22974/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22975///
22976/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22977/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22978/// # .with_native_roots()
22979/// # .unwrap()
22980/// # .https_only()
22981/// # .enable_http2()
22982/// # .build();
22983///
22984/// # let executor = hyper_util::rt::TokioExecutor::new();
22985/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22986/// # secret,
22987/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22988/// # yup_oauth2::client::CustomHyperClientBuilder::from(
22989/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
22990/// # ),
22991/// # ).build().await.unwrap();
22992///
22993/// # let client = hyper_util::client::legacy::Client::builder(
22994/// # hyper_util::rt::TokioExecutor::new()
22995/// # )
22996/// # .build(
22997/// # hyper_rustls::HttpsConnectorBuilder::new()
22998/// # .with_native_roots()
22999/// # .unwrap()
23000/// # .https_or_http()
23001/// # .enable_http2()
23002/// # .build()
23003/// # );
23004/// # let mut hub = VMMigrationService::new(client, auth);
23005/// // You can configure optional parameters by calling the respective setters at will, and
23006/// // execute the final call using `doit()`.
23007/// // Values shown here are possibly random and not representative !
23008/// let result = hub.projects().locations_sources_utilization_reports_get("name")
23009/// .view("sadipscing")
23010/// .doit().await;
23011/// # }
23012/// ```
23013pub struct ProjectLocationSourceUtilizationReportGetCall<'a, C>
23014where
23015 C: 'a,
23016{
23017 hub: &'a VMMigrationService<C>,
23018 _name: String,
23019 _view: Option<String>,
23020 _delegate: Option<&'a mut dyn common::Delegate>,
23021 _additional_params: HashMap<String, String>,
23022 _scopes: BTreeSet<String>,
23023}
23024
23025impl<'a, C> common::CallBuilder for ProjectLocationSourceUtilizationReportGetCall<'a, C> {}
23026
23027impl<'a, C> ProjectLocationSourceUtilizationReportGetCall<'a, C>
23028where
23029 C: common::Connector,
23030{
23031 /// Perform the operation you have build so far.
23032 pub async fn doit(mut self) -> common::Result<(common::Response, UtilizationReport)> {
23033 use std::borrow::Cow;
23034 use std::io::{Read, Seek};
23035
23036 use common::{url::Params, ToParts};
23037 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23038
23039 let mut dd = common::DefaultDelegate;
23040 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23041 dlg.begin(common::MethodInfo {
23042 id: "vmmigration.projects.locations.sources.utilizationReports.get",
23043 http_method: hyper::Method::GET,
23044 });
23045
23046 for &field in ["alt", "name", "view"].iter() {
23047 if self._additional_params.contains_key(field) {
23048 dlg.finished(false);
23049 return Err(common::Error::FieldClash(field));
23050 }
23051 }
23052
23053 let mut params = Params::with_capacity(4 + self._additional_params.len());
23054 params.push("name", self._name);
23055 if let Some(value) = self._view.as_ref() {
23056 params.push("view", value);
23057 }
23058
23059 params.extend(self._additional_params.iter());
23060
23061 params.push("alt", "json");
23062 let mut url = self.hub._base_url.clone() + "v1/{+name}";
23063 if self._scopes.is_empty() {
23064 self._scopes
23065 .insert(Scope::CloudPlatform.as_ref().to_string());
23066 }
23067
23068 #[allow(clippy::single_element_loop)]
23069 for &(find_this, param_name) in [("{+name}", "name")].iter() {
23070 url = params.uri_replacement(url, param_name, find_this, true);
23071 }
23072 {
23073 let to_remove = ["name"];
23074 params.remove_params(&to_remove);
23075 }
23076
23077 let url = params.parse_with_url(&url);
23078
23079 loop {
23080 let token = match self
23081 .hub
23082 .auth
23083 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23084 .await
23085 {
23086 Ok(token) => token,
23087 Err(e) => match dlg.token(e) {
23088 Ok(token) => token,
23089 Err(e) => {
23090 dlg.finished(false);
23091 return Err(common::Error::MissingToken(e));
23092 }
23093 },
23094 };
23095 let mut req_result = {
23096 let client = &self.hub.client;
23097 dlg.pre_request();
23098 let mut req_builder = hyper::Request::builder()
23099 .method(hyper::Method::GET)
23100 .uri(url.as_str())
23101 .header(USER_AGENT, self.hub._user_agent.clone());
23102
23103 if let Some(token) = token.as_ref() {
23104 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23105 }
23106
23107 let request = req_builder
23108 .header(CONTENT_LENGTH, 0_u64)
23109 .body(common::to_body::<String>(None));
23110
23111 client.request(request.unwrap()).await
23112 };
23113
23114 match req_result {
23115 Err(err) => {
23116 if let common::Retry::After(d) = dlg.http_error(&err) {
23117 sleep(d).await;
23118 continue;
23119 }
23120 dlg.finished(false);
23121 return Err(common::Error::HttpError(err));
23122 }
23123 Ok(res) => {
23124 let (mut parts, body) = res.into_parts();
23125 let mut body = common::Body::new(body);
23126 if !parts.status.is_success() {
23127 let bytes = common::to_bytes(body).await.unwrap_or_default();
23128 let error = serde_json::from_str(&common::to_string(&bytes));
23129 let response = common::to_response(parts, bytes.into());
23130
23131 if let common::Retry::After(d) =
23132 dlg.http_failure(&response, error.as_ref().ok())
23133 {
23134 sleep(d).await;
23135 continue;
23136 }
23137
23138 dlg.finished(false);
23139
23140 return Err(match error {
23141 Ok(value) => common::Error::BadRequest(value),
23142 _ => common::Error::Failure(response),
23143 });
23144 }
23145 let response = {
23146 let bytes = common::to_bytes(body).await.unwrap_or_default();
23147 let encoded = common::to_string(&bytes);
23148 match serde_json::from_str(&encoded) {
23149 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23150 Err(error) => {
23151 dlg.response_json_decode_error(&encoded, &error);
23152 return Err(common::Error::JsonDecodeError(
23153 encoded.to_string(),
23154 error,
23155 ));
23156 }
23157 }
23158 };
23159
23160 dlg.finished(true);
23161 return Ok(response);
23162 }
23163 }
23164 }
23165 }
23166
23167 /// Required. The Utilization Report name.
23168 ///
23169 /// Sets the *name* path property to the given value.
23170 ///
23171 /// Even though the property as already been set when instantiating this call,
23172 /// we provide this method for API completeness.
23173 pub fn name(mut self, new_value: &str) -> ProjectLocationSourceUtilizationReportGetCall<'a, C> {
23174 self._name = new_value.to_string();
23175 self
23176 }
23177 /// Optional. The level of details of the report. Defaults to FULL
23178 ///
23179 /// Sets the *view* query property to the given value.
23180 pub fn view(mut self, new_value: &str) -> ProjectLocationSourceUtilizationReportGetCall<'a, C> {
23181 self._view = Some(new_value.to_string());
23182 self
23183 }
23184 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23185 /// while executing the actual API request.
23186 ///
23187 /// ````text
23188 /// It should be used to handle progress information, and to implement a certain level of resilience.
23189 /// ````
23190 ///
23191 /// Sets the *delegate* property to the given value.
23192 pub fn delegate(
23193 mut self,
23194 new_value: &'a mut dyn common::Delegate,
23195 ) -> ProjectLocationSourceUtilizationReportGetCall<'a, C> {
23196 self._delegate = Some(new_value);
23197 self
23198 }
23199
23200 /// Set any additional parameter of the query string used in the request.
23201 /// It should be used to set parameters which are not yet available through their own
23202 /// setters.
23203 ///
23204 /// Please note that this method must not be used to set any of the known parameters
23205 /// which have their own setter method. If done anyway, the request will fail.
23206 ///
23207 /// # Additional Parameters
23208 ///
23209 /// * *$.xgafv* (query-string) - V1 error format.
23210 /// * *access_token* (query-string) - OAuth access token.
23211 /// * *alt* (query-string) - Data format for response.
23212 /// * *callback* (query-string) - JSONP
23213 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23214 /// * *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.
23215 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23216 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23217 /// * *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.
23218 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23219 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23220 pub fn param<T>(
23221 mut self,
23222 name: T,
23223 value: T,
23224 ) -> ProjectLocationSourceUtilizationReportGetCall<'a, C>
23225 where
23226 T: AsRef<str>,
23227 {
23228 self._additional_params
23229 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23230 self
23231 }
23232
23233 /// Identifies the authorization scope for the method you are building.
23234 ///
23235 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23236 /// [`Scope::CloudPlatform`].
23237 ///
23238 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23239 /// tokens for more than one scope.
23240 ///
23241 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23242 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23243 /// sufficient, a read-write scope will do as well.
23244 pub fn add_scope<St>(
23245 mut self,
23246 scope: St,
23247 ) -> ProjectLocationSourceUtilizationReportGetCall<'a, C>
23248 where
23249 St: AsRef<str>,
23250 {
23251 self._scopes.insert(String::from(scope.as_ref()));
23252 self
23253 }
23254 /// Identifies the authorization scope(s) for the method you are building.
23255 ///
23256 /// See [`Self::add_scope()`] for details.
23257 pub fn add_scopes<I, St>(
23258 mut self,
23259 scopes: I,
23260 ) -> ProjectLocationSourceUtilizationReportGetCall<'a, C>
23261 where
23262 I: IntoIterator<Item = St>,
23263 St: AsRef<str>,
23264 {
23265 self._scopes
23266 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23267 self
23268 }
23269
23270 /// Removes all scopes, and no default scope will be used either.
23271 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23272 /// for details).
23273 pub fn clear_scopes(mut self) -> ProjectLocationSourceUtilizationReportGetCall<'a, C> {
23274 self._scopes.clear();
23275 self
23276 }
23277}
23278
23279/// Lists Utilization Reports of the given Source.
23280///
23281/// A builder for the *locations.sources.utilizationReports.list* method supported by a *project* resource.
23282/// It is not used directly, but through a [`ProjectMethods`] instance.
23283///
23284/// # Example
23285///
23286/// Instantiate a resource method builder
23287///
23288/// ```test_harness,no_run
23289/// # extern crate hyper;
23290/// # extern crate hyper_rustls;
23291/// # extern crate google_vmmigration1 as vmmigration1;
23292/// # async fn dox() {
23293/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23294///
23295/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23296/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23297/// # .with_native_roots()
23298/// # .unwrap()
23299/// # .https_only()
23300/// # .enable_http2()
23301/// # .build();
23302///
23303/// # let executor = hyper_util::rt::TokioExecutor::new();
23304/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23305/// # secret,
23306/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23307/// # yup_oauth2::client::CustomHyperClientBuilder::from(
23308/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
23309/// # ),
23310/// # ).build().await.unwrap();
23311///
23312/// # let client = hyper_util::client::legacy::Client::builder(
23313/// # hyper_util::rt::TokioExecutor::new()
23314/// # )
23315/// # .build(
23316/// # hyper_rustls::HttpsConnectorBuilder::new()
23317/// # .with_native_roots()
23318/// # .unwrap()
23319/// # .https_or_http()
23320/// # .enable_http2()
23321/// # .build()
23322/// # );
23323/// # let mut hub = VMMigrationService::new(client, auth);
23324/// // You can configure optional parameters by calling the respective setters at will, and
23325/// // execute the final call using `doit()`.
23326/// // Values shown here are possibly random and not representative !
23327/// let result = hub.projects().locations_sources_utilization_reports_list("parent")
23328/// .view("aliquyam")
23329/// .page_token("amet")
23330/// .page_size(-57)
23331/// .order_by("et")
23332/// .filter("sea")
23333/// .doit().await;
23334/// # }
23335/// ```
23336pub struct ProjectLocationSourceUtilizationReportListCall<'a, C>
23337where
23338 C: 'a,
23339{
23340 hub: &'a VMMigrationService<C>,
23341 _parent: String,
23342 _view: Option<String>,
23343 _page_token: Option<String>,
23344 _page_size: Option<i32>,
23345 _order_by: Option<String>,
23346 _filter: Option<String>,
23347 _delegate: Option<&'a mut dyn common::Delegate>,
23348 _additional_params: HashMap<String, String>,
23349 _scopes: BTreeSet<String>,
23350}
23351
23352impl<'a, C> common::CallBuilder for ProjectLocationSourceUtilizationReportListCall<'a, C> {}
23353
23354impl<'a, C> ProjectLocationSourceUtilizationReportListCall<'a, C>
23355where
23356 C: common::Connector,
23357{
23358 /// Perform the operation you have build so far.
23359 pub async fn doit(
23360 mut self,
23361 ) -> common::Result<(common::Response, ListUtilizationReportsResponse)> {
23362 use std::borrow::Cow;
23363 use std::io::{Read, Seek};
23364
23365 use common::{url::Params, ToParts};
23366 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23367
23368 let mut dd = common::DefaultDelegate;
23369 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23370 dlg.begin(common::MethodInfo {
23371 id: "vmmigration.projects.locations.sources.utilizationReports.list",
23372 http_method: hyper::Method::GET,
23373 });
23374
23375 for &field in [
23376 "alt",
23377 "parent",
23378 "view",
23379 "pageToken",
23380 "pageSize",
23381 "orderBy",
23382 "filter",
23383 ]
23384 .iter()
23385 {
23386 if self._additional_params.contains_key(field) {
23387 dlg.finished(false);
23388 return Err(common::Error::FieldClash(field));
23389 }
23390 }
23391
23392 let mut params = Params::with_capacity(8 + self._additional_params.len());
23393 params.push("parent", self._parent);
23394 if let Some(value) = self._view.as_ref() {
23395 params.push("view", value);
23396 }
23397 if let Some(value) = self._page_token.as_ref() {
23398 params.push("pageToken", value);
23399 }
23400 if let Some(value) = self._page_size.as_ref() {
23401 params.push("pageSize", value.to_string());
23402 }
23403 if let Some(value) = self._order_by.as_ref() {
23404 params.push("orderBy", value);
23405 }
23406 if let Some(value) = self._filter.as_ref() {
23407 params.push("filter", value);
23408 }
23409
23410 params.extend(self._additional_params.iter());
23411
23412 params.push("alt", "json");
23413 let mut url = self.hub._base_url.clone() + "v1/{+parent}/utilizationReports";
23414 if self._scopes.is_empty() {
23415 self._scopes
23416 .insert(Scope::CloudPlatform.as_ref().to_string());
23417 }
23418
23419 #[allow(clippy::single_element_loop)]
23420 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
23421 url = params.uri_replacement(url, param_name, find_this, true);
23422 }
23423 {
23424 let to_remove = ["parent"];
23425 params.remove_params(&to_remove);
23426 }
23427
23428 let url = params.parse_with_url(&url);
23429
23430 loop {
23431 let token = match self
23432 .hub
23433 .auth
23434 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23435 .await
23436 {
23437 Ok(token) => token,
23438 Err(e) => match dlg.token(e) {
23439 Ok(token) => token,
23440 Err(e) => {
23441 dlg.finished(false);
23442 return Err(common::Error::MissingToken(e));
23443 }
23444 },
23445 };
23446 let mut req_result = {
23447 let client = &self.hub.client;
23448 dlg.pre_request();
23449 let mut req_builder = hyper::Request::builder()
23450 .method(hyper::Method::GET)
23451 .uri(url.as_str())
23452 .header(USER_AGENT, self.hub._user_agent.clone());
23453
23454 if let Some(token) = token.as_ref() {
23455 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23456 }
23457
23458 let request = req_builder
23459 .header(CONTENT_LENGTH, 0_u64)
23460 .body(common::to_body::<String>(None));
23461
23462 client.request(request.unwrap()).await
23463 };
23464
23465 match req_result {
23466 Err(err) => {
23467 if let common::Retry::After(d) = dlg.http_error(&err) {
23468 sleep(d).await;
23469 continue;
23470 }
23471 dlg.finished(false);
23472 return Err(common::Error::HttpError(err));
23473 }
23474 Ok(res) => {
23475 let (mut parts, body) = res.into_parts();
23476 let mut body = common::Body::new(body);
23477 if !parts.status.is_success() {
23478 let bytes = common::to_bytes(body).await.unwrap_or_default();
23479 let error = serde_json::from_str(&common::to_string(&bytes));
23480 let response = common::to_response(parts, bytes.into());
23481
23482 if let common::Retry::After(d) =
23483 dlg.http_failure(&response, error.as_ref().ok())
23484 {
23485 sleep(d).await;
23486 continue;
23487 }
23488
23489 dlg.finished(false);
23490
23491 return Err(match error {
23492 Ok(value) => common::Error::BadRequest(value),
23493 _ => common::Error::Failure(response),
23494 });
23495 }
23496 let response = {
23497 let bytes = common::to_bytes(body).await.unwrap_or_default();
23498 let encoded = common::to_string(&bytes);
23499 match serde_json::from_str(&encoded) {
23500 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23501 Err(error) => {
23502 dlg.response_json_decode_error(&encoded, &error);
23503 return Err(common::Error::JsonDecodeError(
23504 encoded.to_string(),
23505 error,
23506 ));
23507 }
23508 }
23509 };
23510
23511 dlg.finished(true);
23512 return Ok(response);
23513 }
23514 }
23515 }
23516 }
23517
23518 /// Required. The Utilization Reports parent.
23519 ///
23520 /// Sets the *parent* path property to the given value.
23521 ///
23522 /// Even though the property as already been set when instantiating this call,
23523 /// we provide this method for API completeness.
23524 pub fn parent(
23525 mut self,
23526 new_value: &str,
23527 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C> {
23528 self._parent = new_value.to_string();
23529 self
23530 }
23531 /// Optional. The level of details of each report. Defaults to BASIC.
23532 ///
23533 /// Sets the *view* query property to the given value.
23534 pub fn view(
23535 mut self,
23536 new_value: &str,
23537 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C> {
23538 self._view = Some(new_value.to_string());
23539 self
23540 }
23541 /// 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.
23542 ///
23543 /// Sets the *page token* query property to the given value.
23544 pub fn page_token(
23545 mut self,
23546 new_value: &str,
23547 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C> {
23548 self._page_token = Some(new_value.to_string());
23549 self
23550 }
23551 /// 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.
23552 ///
23553 /// Sets the *page size* query property to the given value.
23554 pub fn page_size(
23555 mut self,
23556 new_value: i32,
23557 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C> {
23558 self._page_size = Some(new_value);
23559 self
23560 }
23561 /// Optional. the order by fields for the result.
23562 ///
23563 /// Sets the *order by* query property to the given value.
23564 pub fn order_by(
23565 mut self,
23566 new_value: &str,
23567 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C> {
23568 self._order_by = Some(new_value.to_string());
23569 self
23570 }
23571 /// Optional. The filter request.
23572 ///
23573 /// Sets the *filter* query property to the given value.
23574 pub fn filter(
23575 mut self,
23576 new_value: &str,
23577 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C> {
23578 self._filter = Some(new_value.to_string());
23579 self
23580 }
23581 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23582 /// while executing the actual API request.
23583 ///
23584 /// ````text
23585 /// It should be used to handle progress information, and to implement a certain level of resilience.
23586 /// ````
23587 ///
23588 /// Sets the *delegate* property to the given value.
23589 pub fn delegate(
23590 mut self,
23591 new_value: &'a mut dyn common::Delegate,
23592 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C> {
23593 self._delegate = Some(new_value);
23594 self
23595 }
23596
23597 /// Set any additional parameter of the query string used in the request.
23598 /// It should be used to set parameters which are not yet available through their own
23599 /// setters.
23600 ///
23601 /// Please note that this method must not be used to set any of the known parameters
23602 /// which have their own setter method. If done anyway, the request will fail.
23603 ///
23604 /// # Additional Parameters
23605 ///
23606 /// * *$.xgafv* (query-string) - V1 error format.
23607 /// * *access_token* (query-string) - OAuth access token.
23608 /// * *alt* (query-string) - Data format for response.
23609 /// * *callback* (query-string) - JSONP
23610 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23611 /// * *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.
23612 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23613 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23614 /// * *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.
23615 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23616 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23617 pub fn param<T>(
23618 mut self,
23619 name: T,
23620 value: T,
23621 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C>
23622 where
23623 T: AsRef<str>,
23624 {
23625 self._additional_params
23626 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23627 self
23628 }
23629
23630 /// Identifies the authorization scope for the method you are building.
23631 ///
23632 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23633 /// [`Scope::CloudPlatform`].
23634 ///
23635 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23636 /// tokens for more than one scope.
23637 ///
23638 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23639 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23640 /// sufficient, a read-write scope will do as well.
23641 pub fn add_scope<St>(
23642 mut self,
23643 scope: St,
23644 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C>
23645 where
23646 St: AsRef<str>,
23647 {
23648 self._scopes.insert(String::from(scope.as_ref()));
23649 self
23650 }
23651 /// Identifies the authorization scope(s) for the method you are building.
23652 ///
23653 /// See [`Self::add_scope()`] for details.
23654 pub fn add_scopes<I, St>(
23655 mut self,
23656 scopes: I,
23657 ) -> ProjectLocationSourceUtilizationReportListCall<'a, C>
23658 where
23659 I: IntoIterator<Item = St>,
23660 St: AsRef<str>,
23661 {
23662 self._scopes
23663 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23664 self
23665 }
23666
23667 /// Removes all scopes, and no default scope will be used either.
23668 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23669 /// for details).
23670 pub fn clear_scopes(mut self) -> ProjectLocationSourceUtilizationReportListCall<'a, C> {
23671 self._scopes.clear();
23672 self
23673 }
23674}
23675
23676/// Creates a new Source in a given project and location.
23677///
23678/// A builder for the *locations.sources.create* method supported by a *project* resource.
23679/// It is not used directly, but through a [`ProjectMethods`] instance.
23680///
23681/// # Example
23682///
23683/// Instantiate a resource method builder
23684///
23685/// ```test_harness,no_run
23686/// # extern crate hyper;
23687/// # extern crate hyper_rustls;
23688/// # extern crate google_vmmigration1 as vmmigration1;
23689/// use vmmigration1::api::Source;
23690/// # async fn dox() {
23691/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23692///
23693/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23694/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23695/// # .with_native_roots()
23696/// # .unwrap()
23697/// # .https_only()
23698/// # .enable_http2()
23699/// # .build();
23700///
23701/// # let executor = hyper_util::rt::TokioExecutor::new();
23702/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23703/// # secret,
23704/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23705/// # yup_oauth2::client::CustomHyperClientBuilder::from(
23706/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
23707/// # ),
23708/// # ).build().await.unwrap();
23709///
23710/// # let client = hyper_util::client::legacy::Client::builder(
23711/// # hyper_util::rt::TokioExecutor::new()
23712/// # )
23713/// # .build(
23714/// # hyper_rustls::HttpsConnectorBuilder::new()
23715/// # .with_native_roots()
23716/// # .unwrap()
23717/// # .https_or_http()
23718/// # .enable_http2()
23719/// # .build()
23720/// # );
23721/// # let mut hub = VMMigrationService::new(client, auth);
23722/// // As the method needs a request, you would usually fill it with the desired information
23723/// // into the respective structure. Some of the parts shown here might not be applicable !
23724/// // Values shown here are possibly random and not representative !
23725/// let mut req = Source::default();
23726///
23727/// // You can configure optional parameters by calling the respective setters at will, and
23728/// // execute the final call using `doit()`.
23729/// // Values shown here are possibly random and not representative !
23730/// let result = hub.projects().locations_sources_create(req, "parent")
23731/// .source_id("consetetur")
23732/// .request_id("Stet")
23733/// .doit().await;
23734/// # }
23735/// ```
23736pub struct ProjectLocationSourceCreateCall<'a, C>
23737where
23738 C: 'a,
23739{
23740 hub: &'a VMMigrationService<C>,
23741 _request: Source,
23742 _parent: String,
23743 _source_id: Option<String>,
23744 _request_id: Option<String>,
23745 _delegate: Option<&'a mut dyn common::Delegate>,
23746 _additional_params: HashMap<String, String>,
23747 _scopes: BTreeSet<String>,
23748}
23749
23750impl<'a, C> common::CallBuilder for ProjectLocationSourceCreateCall<'a, C> {}
23751
23752impl<'a, C> ProjectLocationSourceCreateCall<'a, C>
23753where
23754 C: common::Connector,
23755{
23756 /// Perform the operation you have build so far.
23757 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
23758 use std::borrow::Cow;
23759 use std::io::{Read, Seek};
23760
23761 use common::{url::Params, ToParts};
23762 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23763
23764 let mut dd = common::DefaultDelegate;
23765 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23766 dlg.begin(common::MethodInfo {
23767 id: "vmmigration.projects.locations.sources.create",
23768 http_method: hyper::Method::POST,
23769 });
23770
23771 for &field in ["alt", "parent", "sourceId", "requestId"].iter() {
23772 if self._additional_params.contains_key(field) {
23773 dlg.finished(false);
23774 return Err(common::Error::FieldClash(field));
23775 }
23776 }
23777
23778 let mut params = Params::with_capacity(6 + self._additional_params.len());
23779 params.push("parent", self._parent);
23780 if let Some(value) = self._source_id.as_ref() {
23781 params.push("sourceId", value);
23782 }
23783 if let Some(value) = self._request_id.as_ref() {
23784 params.push("requestId", value);
23785 }
23786
23787 params.extend(self._additional_params.iter());
23788
23789 params.push("alt", "json");
23790 let mut url = self.hub._base_url.clone() + "v1/{+parent}/sources";
23791 if self._scopes.is_empty() {
23792 self._scopes
23793 .insert(Scope::CloudPlatform.as_ref().to_string());
23794 }
23795
23796 #[allow(clippy::single_element_loop)]
23797 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
23798 url = params.uri_replacement(url, param_name, find_this, true);
23799 }
23800 {
23801 let to_remove = ["parent"];
23802 params.remove_params(&to_remove);
23803 }
23804
23805 let url = params.parse_with_url(&url);
23806
23807 let mut json_mime_type = mime::APPLICATION_JSON;
23808 let mut request_value_reader = {
23809 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23810 common::remove_json_null_values(&mut value);
23811 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23812 serde_json::to_writer(&mut dst, &value).unwrap();
23813 dst
23814 };
23815 let request_size = request_value_reader
23816 .seek(std::io::SeekFrom::End(0))
23817 .unwrap();
23818 request_value_reader
23819 .seek(std::io::SeekFrom::Start(0))
23820 .unwrap();
23821
23822 loop {
23823 let token = match self
23824 .hub
23825 .auth
23826 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23827 .await
23828 {
23829 Ok(token) => token,
23830 Err(e) => match dlg.token(e) {
23831 Ok(token) => token,
23832 Err(e) => {
23833 dlg.finished(false);
23834 return Err(common::Error::MissingToken(e));
23835 }
23836 },
23837 };
23838 request_value_reader
23839 .seek(std::io::SeekFrom::Start(0))
23840 .unwrap();
23841 let mut req_result = {
23842 let client = &self.hub.client;
23843 dlg.pre_request();
23844 let mut req_builder = hyper::Request::builder()
23845 .method(hyper::Method::POST)
23846 .uri(url.as_str())
23847 .header(USER_AGENT, self.hub._user_agent.clone());
23848
23849 if let Some(token) = token.as_ref() {
23850 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23851 }
23852
23853 let request = req_builder
23854 .header(CONTENT_TYPE, json_mime_type.to_string())
23855 .header(CONTENT_LENGTH, request_size as u64)
23856 .body(common::to_body(
23857 request_value_reader.get_ref().clone().into(),
23858 ));
23859
23860 client.request(request.unwrap()).await
23861 };
23862
23863 match req_result {
23864 Err(err) => {
23865 if let common::Retry::After(d) = dlg.http_error(&err) {
23866 sleep(d).await;
23867 continue;
23868 }
23869 dlg.finished(false);
23870 return Err(common::Error::HttpError(err));
23871 }
23872 Ok(res) => {
23873 let (mut parts, body) = res.into_parts();
23874 let mut body = common::Body::new(body);
23875 if !parts.status.is_success() {
23876 let bytes = common::to_bytes(body).await.unwrap_or_default();
23877 let error = serde_json::from_str(&common::to_string(&bytes));
23878 let response = common::to_response(parts, bytes.into());
23879
23880 if let common::Retry::After(d) =
23881 dlg.http_failure(&response, error.as_ref().ok())
23882 {
23883 sleep(d).await;
23884 continue;
23885 }
23886
23887 dlg.finished(false);
23888
23889 return Err(match error {
23890 Ok(value) => common::Error::BadRequest(value),
23891 _ => common::Error::Failure(response),
23892 });
23893 }
23894 let response = {
23895 let bytes = common::to_bytes(body).await.unwrap_or_default();
23896 let encoded = common::to_string(&bytes);
23897 match serde_json::from_str(&encoded) {
23898 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23899 Err(error) => {
23900 dlg.response_json_decode_error(&encoded, &error);
23901 return Err(common::Error::JsonDecodeError(
23902 encoded.to_string(),
23903 error,
23904 ));
23905 }
23906 }
23907 };
23908
23909 dlg.finished(true);
23910 return Ok(response);
23911 }
23912 }
23913 }
23914 }
23915
23916 ///
23917 /// Sets the *request* property to the given value.
23918 ///
23919 /// Even though the property as already been set when instantiating this call,
23920 /// we provide this method for API completeness.
23921 pub fn request(mut self, new_value: Source) -> ProjectLocationSourceCreateCall<'a, C> {
23922 self._request = new_value;
23923 self
23924 }
23925 /// Required. The Source's parent.
23926 ///
23927 /// Sets the *parent* path property to the given value.
23928 ///
23929 /// Even though the property as already been set when instantiating this call,
23930 /// we provide this method for API completeness.
23931 pub fn parent(mut self, new_value: &str) -> ProjectLocationSourceCreateCall<'a, C> {
23932 self._parent = new_value.to_string();
23933 self
23934 }
23935 /// Required. The source identifier.
23936 ///
23937 /// Sets the *source id* query property to the given value.
23938 pub fn source_id(mut self, new_value: &str) -> ProjectLocationSourceCreateCall<'a, C> {
23939 self._source_id = Some(new_value.to_string());
23940 self
23941 }
23942 /// 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).
23943 ///
23944 /// Sets the *request id* query property to the given value.
23945 pub fn request_id(mut self, new_value: &str) -> ProjectLocationSourceCreateCall<'a, C> {
23946 self._request_id = Some(new_value.to_string());
23947 self
23948 }
23949 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23950 /// while executing the actual API request.
23951 ///
23952 /// ````text
23953 /// It should be used to handle progress information, and to implement a certain level of resilience.
23954 /// ````
23955 ///
23956 /// Sets the *delegate* property to the given value.
23957 pub fn delegate(
23958 mut self,
23959 new_value: &'a mut dyn common::Delegate,
23960 ) -> ProjectLocationSourceCreateCall<'a, C> {
23961 self._delegate = Some(new_value);
23962 self
23963 }
23964
23965 /// Set any additional parameter of the query string used in the request.
23966 /// It should be used to set parameters which are not yet available through their own
23967 /// setters.
23968 ///
23969 /// Please note that this method must not be used to set any of the known parameters
23970 /// which have their own setter method. If done anyway, the request will fail.
23971 ///
23972 /// # Additional Parameters
23973 ///
23974 /// * *$.xgafv* (query-string) - V1 error format.
23975 /// * *access_token* (query-string) - OAuth access token.
23976 /// * *alt* (query-string) - Data format for response.
23977 /// * *callback* (query-string) - JSONP
23978 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23979 /// * *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.
23980 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23981 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23982 /// * *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.
23983 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23984 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23985 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSourceCreateCall<'a, C>
23986 where
23987 T: AsRef<str>,
23988 {
23989 self._additional_params
23990 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23991 self
23992 }
23993
23994 /// Identifies the authorization scope for the method you are building.
23995 ///
23996 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23997 /// [`Scope::CloudPlatform`].
23998 ///
23999 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24000 /// tokens for more than one scope.
24001 ///
24002 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24003 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24004 /// sufficient, a read-write scope will do as well.
24005 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceCreateCall<'a, C>
24006 where
24007 St: AsRef<str>,
24008 {
24009 self._scopes.insert(String::from(scope.as_ref()));
24010 self
24011 }
24012 /// Identifies the authorization scope(s) for the method you are building.
24013 ///
24014 /// See [`Self::add_scope()`] for details.
24015 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSourceCreateCall<'a, C>
24016 where
24017 I: IntoIterator<Item = St>,
24018 St: AsRef<str>,
24019 {
24020 self._scopes
24021 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24022 self
24023 }
24024
24025 /// Removes all scopes, and no default scope will be used either.
24026 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24027 /// for details).
24028 pub fn clear_scopes(mut self) -> ProjectLocationSourceCreateCall<'a, C> {
24029 self._scopes.clear();
24030 self
24031 }
24032}
24033
24034/// Deletes a single Source.
24035///
24036/// A builder for the *locations.sources.delete* method supported by a *project* resource.
24037/// It is not used directly, but through a [`ProjectMethods`] instance.
24038///
24039/// # Example
24040///
24041/// Instantiate a resource method builder
24042///
24043/// ```test_harness,no_run
24044/// # extern crate hyper;
24045/// # extern crate hyper_rustls;
24046/// # extern crate google_vmmigration1 as vmmigration1;
24047/// # async fn dox() {
24048/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24049///
24050/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24051/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24052/// # .with_native_roots()
24053/// # .unwrap()
24054/// # .https_only()
24055/// # .enable_http2()
24056/// # .build();
24057///
24058/// # let executor = hyper_util::rt::TokioExecutor::new();
24059/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24060/// # secret,
24061/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24062/// # yup_oauth2::client::CustomHyperClientBuilder::from(
24063/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
24064/// # ),
24065/// # ).build().await.unwrap();
24066///
24067/// # let client = hyper_util::client::legacy::Client::builder(
24068/// # hyper_util::rt::TokioExecutor::new()
24069/// # )
24070/// # .build(
24071/// # hyper_rustls::HttpsConnectorBuilder::new()
24072/// # .with_native_roots()
24073/// # .unwrap()
24074/// # .https_or_http()
24075/// # .enable_http2()
24076/// # .build()
24077/// # );
24078/// # let mut hub = VMMigrationService::new(client, auth);
24079/// // You can configure optional parameters by calling the respective setters at will, and
24080/// // execute the final call using `doit()`.
24081/// // Values shown here are possibly random and not representative !
24082/// let result = hub.projects().locations_sources_delete("name")
24083/// .request_id("aliquyam")
24084/// .doit().await;
24085/// # }
24086/// ```
24087pub struct ProjectLocationSourceDeleteCall<'a, C>
24088where
24089 C: 'a,
24090{
24091 hub: &'a VMMigrationService<C>,
24092 _name: String,
24093 _request_id: Option<String>,
24094 _delegate: Option<&'a mut dyn common::Delegate>,
24095 _additional_params: HashMap<String, String>,
24096 _scopes: BTreeSet<String>,
24097}
24098
24099impl<'a, C> common::CallBuilder for ProjectLocationSourceDeleteCall<'a, C> {}
24100
24101impl<'a, C> ProjectLocationSourceDeleteCall<'a, C>
24102where
24103 C: common::Connector,
24104{
24105 /// Perform the operation you have build so far.
24106 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
24107 use std::borrow::Cow;
24108 use std::io::{Read, Seek};
24109
24110 use common::{url::Params, ToParts};
24111 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24112
24113 let mut dd = common::DefaultDelegate;
24114 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24115 dlg.begin(common::MethodInfo {
24116 id: "vmmigration.projects.locations.sources.delete",
24117 http_method: hyper::Method::DELETE,
24118 });
24119
24120 for &field in ["alt", "name", "requestId"].iter() {
24121 if self._additional_params.contains_key(field) {
24122 dlg.finished(false);
24123 return Err(common::Error::FieldClash(field));
24124 }
24125 }
24126
24127 let mut params = Params::with_capacity(4 + self._additional_params.len());
24128 params.push("name", self._name);
24129 if let Some(value) = self._request_id.as_ref() {
24130 params.push("requestId", value);
24131 }
24132
24133 params.extend(self._additional_params.iter());
24134
24135 params.push("alt", "json");
24136 let mut url = self.hub._base_url.clone() + "v1/{+name}";
24137 if self._scopes.is_empty() {
24138 self._scopes
24139 .insert(Scope::CloudPlatform.as_ref().to_string());
24140 }
24141
24142 #[allow(clippy::single_element_loop)]
24143 for &(find_this, param_name) in [("{+name}", "name")].iter() {
24144 url = params.uri_replacement(url, param_name, find_this, true);
24145 }
24146 {
24147 let to_remove = ["name"];
24148 params.remove_params(&to_remove);
24149 }
24150
24151 let url = params.parse_with_url(&url);
24152
24153 loop {
24154 let token = match self
24155 .hub
24156 .auth
24157 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24158 .await
24159 {
24160 Ok(token) => token,
24161 Err(e) => match dlg.token(e) {
24162 Ok(token) => token,
24163 Err(e) => {
24164 dlg.finished(false);
24165 return Err(common::Error::MissingToken(e));
24166 }
24167 },
24168 };
24169 let mut req_result = {
24170 let client = &self.hub.client;
24171 dlg.pre_request();
24172 let mut req_builder = hyper::Request::builder()
24173 .method(hyper::Method::DELETE)
24174 .uri(url.as_str())
24175 .header(USER_AGENT, self.hub._user_agent.clone());
24176
24177 if let Some(token) = token.as_ref() {
24178 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24179 }
24180
24181 let request = req_builder
24182 .header(CONTENT_LENGTH, 0_u64)
24183 .body(common::to_body::<String>(None));
24184
24185 client.request(request.unwrap()).await
24186 };
24187
24188 match req_result {
24189 Err(err) => {
24190 if let common::Retry::After(d) = dlg.http_error(&err) {
24191 sleep(d).await;
24192 continue;
24193 }
24194 dlg.finished(false);
24195 return Err(common::Error::HttpError(err));
24196 }
24197 Ok(res) => {
24198 let (mut parts, body) = res.into_parts();
24199 let mut body = common::Body::new(body);
24200 if !parts.status.is_success() {
24201 let bytes = common::to_bytes(body).await.unwrap_or_default();
24202 let error = serde_json::from_str(&common::to_string(&bytes));
24203 let response = common::to_response(parts, bytes.into());
24204
24205 if let common::Retry::After(d) =
24206 dlg.http_failure(&response, error.as_ref().ok())
24207 {
24208 sleep(d).await;
24209 continue;
24210 }
24211
24212 dlg.finished(false);
24213
24214 return Err(match error {
24215 Ok(value) => common::Error::BadRequest(value),
24216 _ => common::Error::Failure(response),
24217 });
24218 }
24219 let response = {
24220 let bytes = common::to_bytes(body).await.unwrap_or_default();
24221 let encoded = common::to_string(&bytes);
24222 match serde_json::from_str(&encoded) {
24223 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24224 Err(error) => {
24225 dlg.response_json_decode_error(&encoded, &error);
24226 return Err(common::Error::JsonDecodeError(
24227 encoded.to_string(),
24228 error,
24229 ));
24230 }
24231 }
24232 };
24233
24234 dlg.finished(true);
24235 return Ok(response);
24236 }
24237 }
24238 }
24239 }
24240
24241 /// Required. The Source name.
24242 ///
24243 /// Sets the *name* path property to the given value.
24244 ///
24245 /// Even though the property as already been set when instantiating this call,
24246 /// we provide this method for API completeness.
24247 pub fn name(mut self, new_value: &str) -> ProjectLocationSourceDeleteCall<'a, C> {
24248 self._name = new_value.to_string();
24249 self
24250 }
24251 /// 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).
24252 ///
24253 /// Sets the *request id* query property to the given value.
24254 pub fn request_id(mut self, new_value: &str) -> ProjectLocationSourceDeleteCall<'a, C> {
24255 self._request_id = Some(new_value.to_string());
24256 self
24257 }
24258 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24259 /// while executing the actual API request.
24260 ///
24261 /// ````text
24262 /// It should be used to handle progress information, and to implement a certain level of resilience.
24263 /// ````
24264 ///
24265 /// Sets the *delegate* property to the given value.
24266 pub fn delegate(
24267 mut self,
24268 new_value: &'a mut dyn common::Delegate,
24269 ) -> ProjectLocationSourceDeleteCall<'a, C> {
24270 self._delegate = Some(new_value);
24271 self
24272 }
24273
24274 /// Set any additional parameter of the query string used in the request.
24275 /// It should be used to set parameters which are not yet available through their own
24276 /// setters.
24277 ///
24278 /// Please note that this method must not be used to set any of the known parameters
24279 /// which have their own setter method. If done anyway, the request will fail.
24280 ///
24281 /// # Additional Parameters
24282 ///
24283 /// * *$.xgafv* (query-string) - V1 error format.
24284 /// * *access_token* (query-string) - OAuth access token.
24285 /// * *alt* (query-string) - Data format for response.
24286 /// * *callback* (query-string) - JSONP
24287 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24288 /// * *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.
24289 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24290 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24291 /// * *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.
24292 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24293 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24294 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSourceDeleteCall<'a, C>
24295 where
24296 T: AsRef<str>,
24297 {
24298 self._additional_params
24299 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24300 self
24301 }
24302
24303 /// Identifies the authorization scope for the method you are building.
24304 ///
24305 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24306 /// [`Scope::CloudPlatform`].
24307 ///
24308 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24309 /// tokens for more than one scope.
24310 ///
24311 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24312 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24313 /// sufficient, a read-write scope will do as well.
24314 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceDeleteCall<'a, C>
24315 where
24316 St: AsRef<str>,
24317 {
24318 self._scopes.insert(String::from(scope.as_ref()));
24319 self
24320 }
24321 /// Identifies the authorization scope(s) for the method you are building.
24322 ///
24323 /// See [`Self::add_scope()`] for details.
24324 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSourceDeleteCall<'a, C>
24325 where
24326 I: IntoIterator<Item = St>,
24327 St: AsRef<str>,
24328 {
24329 self._scopes
24330 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24331 self
24332 }
24333
24334 /// Removes all scopes, and no default scope will be used either.
24335 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24336 /// for details).
24337 pub fn clear_scopes(mut self) -> ProjectLocationSourceDeleteCall<'a, C> {
24338 self._scopes.clear();
24339 self
24340 }
24341}
24342
24343/// 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.
24344///
24345/// A builder for the *locations.sources.fetchInventory* method supported by a *project* resource.
24346/// It is not used directly, but through a [`ProjectMethods`] instance.
24347///
24348/// # Example
24349///
24350/// Instantiate a resource method builder
24351///
24352/// ```test_harness,no_run
24353/// # extern crate hyper;
24354/// # extern crate hyper_rustls;
24355/// # extern crate google_vmmigration1 as vmmigration1;
24356/// # async fn dox() {
24357/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24358///
24359/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24360/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24361/// # .with_native_roots()
24362/// # .unwrap()
24363/// # .https_only()
24364/// # .enable_http2()
24365/// # .build();
24366///
24367/// # let executor = hyper_util::rt::TokioExecutor::new();
24368/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24369/// # secret,
24370/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24371/// # yup_oauth2::client::CustomHyperClientBuilder::from(
24372/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
24373/// # ),
24374/// # ).build().await.unwrap();
24375///
24376/// # let client = hyper_util::client::legacy::Client::builder(
24377/// # hyper_util::rt::TokioExecutor::new()
24378/// # )
24379/// # .build(
24380/// # hyper_rustls::HttpsConnectorBuilder::new()
24381/// # .with_native_roots()
24382/// # .unwrap()
24383/// # .https_or_http()
24384/// # .enable_http2()
24385/// # .build()
24386/// # );
24387/// # let mut hub = VMMigrationService::new(client, auth);
24388/// // You can configure optional parameters by calling the respective setters at will, and
24389/// // execute the final call using `doit()`.
24390/// // Values shown here are possibly random and not representative !
24391/// let result = hub.projects().locations_sources_fetch_inventory("source")
24392/// .page_token("duo")
24393/// .page_size(-42)
24394/// .force_refresh(true)
24395/// .doit().await;
24396/// # }
24397/// ```
24398pub struct ProjectLocationSourceFetchInventoryCall<'a, C>
24399where
24400 C: 'a,
24401{
24402 hub: &'a VMMigrationService<C>,
24403 _source: String,
24404 _page_token: Option<String>,
24405 _page_size: Option<i32>,
24406 _force_refresh: Option<bool>,
24407 _delegate: Option<&'a mut dyn common::Delegate>,
24408 _additional_params: HashMap<String, String>,
24409 _scopes: BTreeSet<String>,
24410}
24411
24412impl<'a, C> common::CallBuilder for ProjectLocationSourceFetchInventoryCall<'a, C> {}
24413
24414impl<'a, C> ProjectLocationSourceFetchInventoryCall<'a, C>
24415where
24416 C: common::Connector,
24417{
24418 /// Perform the operation you have build so far.
24419 pub async fn doit(mut self) -> common::Result<(common::Response, FetchInventoryResponse)> {
24420 use std::borrow::Cow;
24421 use std::io::{Read, Seek};
24422
24423 use common::{url::Params, ToParts};
24424 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24425
24426 let mut dd = common::DefaultDelegate;
24427 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24428 dlg.begin(common::MethodInfo {
24429 id: "vmmigration.projects.locations.sources.fetchInventory",
24430 http_method: hyper::Method::GET,
24431 });
24432
24433 for &field in ["alt", "source", "pageToken", "pageSize", "forceRefresh"].iter() {
24434 if self._additional_params.contains_key(field) {
24435 dlg.finished(false);
24436 return Err(common::Error::FieldClash(field));
24437 }
24438 }
24439
24440 let mut params = Params::with_capacity(6 + self._additional_params.len());
24441 params.push("source", self._source);
24442 if let Some(value) = self._page_token.as_ref() {
24443 params.push("pageToken", value);
24444 }
24445 if let Some(value) = self._page_size.as_ref() {
24446 params.push("pageSize", value.to_string());
24447 }
24448 if let Some(value) = self._force_refresh.as_ref() {
24449 params.push("forceRefresh", value.to_string());
24450 }
24451
24452 params.extend(self._additional_params.iter());
24453
24454 params.push("alt", "json");
24455 let mut url = self.hub._base_url.clone() + "v1/{+source}:fetchInventory";
24456 if self._scopes.is_empty() {
24457 self._scopes
24458 .insert(Scope::CloudPlatform.as_ref().to_string());
24459 }
24460
24461 #[allow(clippy::single_element_loop)]
24462 for &(find_this, param_name) in [("{+source}", "source")].iter() {
24463 url = params.uri_replacement(url, param_name, find_this, true);
24464 }
24465 {
24466 let to_remove = ["source"];
24467 params.remove_params(&to_remove);
24468 }
24469
24470 let url = params.parse_with_url(&url);
24471
24472 loop {
24473 let token = match self
24474 .hub
24475 .auth
24476 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24477 .await
24478 {
24479 Ok(token) => token,
24480 Err(e) => match dlg.token(e) {
24481 Ok(token) => token,
24482 Err(e) => {
24483 dlg.finished(false);
24484 return Err(common::Error::MissingToken(e));
24485 }
24486 },
24487 };
24488 let mut req_result = {
24489 let client = &self.hub.client;
24490 dlg.pre_request();
24491 let mut req_builder = hyper::Request::builder()
24492 .method(hyper::Method::GET)
24493 .uri(url.as_str())
24494 .header(USER_AGENT, self.hub._user_agent.clone());
24495
24496 if let Some(token) = token.as_ref() {
24497 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24498 }
24499
24500 let request = req_builder
24501 .header(CONTENT_LENGTH, 0_u64)
24502 .body(common::to_body::<String>(None));
24503
24504 client.request(request.unwrap()).await
24505 };
24506
24507 match req_result {
24508 Err(err) => {
24509 if let common::Retry::After(d) = dlg.http_error(&err) {
24510 sleep(d).await;
24511 continue;
24512 }
24513 dlg.finished(false);
24514 return Err(common::Error::HttpError(err));
24515 }
24516 Ok(res) => {
24517 let (mut parts, body) = res.into_parts();
24518 let mut body = common::Body::new(body);
24519 if !parts.status.is_success() {
24520 let bytes = common::to_bytes(body).await.unwrap_or_default();
24521 let error = serde_json::from_str(&common::to_string(&bytes));
24522 let response = common::to_response(parts, bytes.into());
24523
24524 if let common::Retry::After(d) =
24525 dlg.http_failure(&response, error.as_ref().ok())
24526 {
24527 sleep(d).await;
24528 continue;
24529 }
24530
24531 dlg.finished(false);
24532
24533 return Err(match error {
24534 Ok(value) => common::Error::BadRequest(value),
24535 _ => common::Error::Failure(response),
24536 });
24537 }
24538 let response = {
24539 let bytes = common::to_bytes(body).await.unwrap_or_default();
24540 let encoded = common::to_string(&bytes);
24541 match serde_json::from_str(&encoded) {
24542 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24543 Err(error) => {
24544 dlg.response_json_decode_error(&encoded, &error);
24545 return Err(common::Error::JsonDecodeError(
24546 encoded.to_string(),
24547 error,
24548 ));
24549 }
24550 }
24551 };
24552
24553 dlg.finished(true);
24554 return Ok(response);
24555 }
24556 }
24557 }
24558 }
24559
24560 /// Required. The name of the Source.
24561 ///
24562 /// Sets the *source* path property to the given value.
24563 ///
24564 /// Even though the property as already been set when instantiating this call,
24565 /// we provide this method for API completeness.
24566 pub fn source(mut self, new_value: &str) -> ProjectLocationSourceFetchInventoryCall<'a, C> {
24567 self._source = new_value.to_string();
24568 self
24569 }
24570 /// 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.
24571 ///
24572 /// Sets the *page token* query property to the given value.
24573 pub fn page_token(mut self, new_value: &str) -> ProjectLocationSourceFetchInventoryCall<'a, C> {
24574 self._page_token = Some(new_value.to_string());
24575 self
24576 }
24577 /// 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.
24578 ///
24579 /// Sets the *page size* query property to the given value.
24580 pub fn page_size(mut self, new_value: i32) -> ProjectLocationSourceFetchInventoryCall<'a, C> {
24581 self._page_size = Some(new_value);
24582 self
24583 }
24584 /// 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.
24585 ///
24586 /// Sets the *force refresh* query property to the given value.
24587 pub fn force_refresh(
24588 mut self,
24589 new_value: bool,
24590 ) -> ProjectLocationSourceFetchInventoryCall<'a, C> {
24591 self._force_refresh = Some(new_value);
24592 self
24593 }
24594 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24595 /// while executing the actual API request.
24596 ///
24597 /// ````text
24598 /// It should be used to handle progress information, and to implement a certain level of resilience.
24599 /// ````
24600 ///
24601 /// Sets the *delegate* property to the given value.
24602 pub fn delegate(
24603 mut self,
24604 new_value: &'a mut dyn common::Delegate,
24605 ) -> ProjectLocationSourceFetchInventoryCall<'a, C> {
24606 self._delegate = Some(new_value);
24607 self
24608 }
24609
24610 /// Set any additional parameter of the query string used in the request.
24611 /// It should be used to set parameters which are not yet available through their own
24612 /// setters.
24613 ///
24614 /// Please note that this method must not be used to set any of the known parameters
24615 /// which have their own setter method. If done anyway, the request will fail.
24616 ///
24617 /// # Additional Parameters
24618 ///
24619 /// * *$.xgafv* (query-string) - V1 error format.
24620 /// * *access_token* (query-string) - OAuth access token.
24621 /// * *alt* (query-string) - Data format for response.
24622 /// * *callback* (query-string) - JSONP
24623 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24624 /// * *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.
24625 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24626 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24627 /// * *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.
24628 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24629 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24630 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSourceFetchInventoryCall<'a, C>
24631 where
24632 T: AsRef<str>,
24633 {
24634 self._additional_params
24635 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24636 self
24637 }
24638
24639 /// Identifies the authorization scope for the method you are building.
24640 ///
24641 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24642 /// [`Scope::CloudPlatform`].
24643 ///
24644 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24645 /// tokens for more than one scope.
24646 ///
24647 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24648 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24649 /// sufficient, a read-write scope will do as well.
24650 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceFetchInventoryCall<'a, C>
24651 where
24652 St: AsRef<str>,
24653 {
24654 self._scopes.insert(String::from(scope.as_ref()));
24655 self
24656 }
24657 /// Identifies the authorization scope(s) for the method you are building.
24658 ///
24659 /// See [`Self::add_scope()`] for details.
24660 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSourceFetchInventoryCall<'a, C>
24661 where
24662 I: IntoIterator<Item = St>,
24663 St: AsRef<str>,
24664 {
24665 self._scopes
24666 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24667 self
24668 }
24669
24670 /// Removes all scopes, and no default scope will be used either.
24671 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24672 /// for details).
24673 pub fn clear_scopes(mut self) -> ProjectLocationSourceFetchInventoryCall<'a, C> {
24674 self._scopes.clear();
24675 self
24676 }
24677}
24678
24679/// List remote source's inventory of storage resources. The remote source is another cloud vendor (e.g. AWS, Azure). The inventory describes the list of existing storage resources in that source. Note that this operation lists the resources on the remote source, as opposed to listing the MigratingVms resources in the vmmigration service.
24680///
24681/// A builder for the *locations.sources.fetchStorageInventory* method supported by a *project* resource.
24682/// It is not used directly, but through a [`ProjectMethods`] instance.
24683///
24684/// # Example
24685///
24686/// Instantiate a resource method builder
24687///
24688/// ```test_harness,no_run
24689/// # extern crate hyper;
24690/// # extern crate hyper_rustls;
24691/// # extern crate google_vmmigration1 as vmmigration1;
24692/// # async fn dox() {
24693/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24694///
24695/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24696/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24697/// # .with_native_roots()
24698/// # .unwrap()
24699/// # .https_only()
24700/// # .enable_http2()
24701/// # .build();
24702///
24703/// # let executor = hyper_util::rt::TokioExecutor::new();
24704/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24705/// # secret,
24706/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24707/// # yup_oauth2::client::CustomHyperClientBuilder::from(
24708/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
24709/// # ),
24710/// # ).build().await.unwrap();
24711///
24712/// # let client = hyper_util::client::legacy::Client::builder(
24713/// # hyper_util::rt::TokioExecutor::new()
24714/// # )
24715/// # .build(
24716/// # hyper_rustls::HttpsConnectorBuilder::new()
24717/// # .with_native_roots()
24718/// # .unwrap()
24719/// # .https_or_http()
24720/// # .enable_http2()
24721/// # .build()
24722/// # );
24723/// # let mut hub = VMMigrationService::new(client, auth);
24724/// // You can configure optional parameters by calling the respective setters at will, and
24725/// // execute the final call using `doit()`.
24726/// // Values shown here are possibly random and not representative !
24727/// let result = hub.projects().locations_sources_fetch_storage_inventory("source")
24728/// .type_("sed")
24729/// .page_token("eos")
24730/// .page_size(-56)
24731/// .force_refresh(true)
24732/// .doit().await;
24733/// # }
24734/// ```
24735pub struct ProjectLocationSourceFetchStorageInventoryCall<'a, C>
24736where
24737 C: 'a,
24738{
24739 hub: &'a VMMigrationService<C>,
24740 _source: String,
24741 _type_: Option<String>,
24742 _page_token: Option<String>,
24743 _page_size: Option<i32>,
24744 _force_refresh: Option<bool>,
24745 _delegate: Option<&'a mut dyn common::Delegate>,
24746 _additional_params: HashMap<String, String>,
24747 _scopes: BTreeSet<String>,
24748}
24749
24750impl<'a, C> common::CallBuilder for ProjectLocationSourceFetchStorageInventoryCall<'a, C> {}
24751
24752impl<'a, C> ProjectLocationSourceFetchStorageInventoryCall<'a, C>
24753where
24754 C: common::Connector,
24755{
24756 /// Perform the operation you have build so far.
24757 pub async fn doit(
24758 mut self,
24759 ) -> common::Result<(common::Response, FetchStorageInventoryResponse)> {
24760 use std::borrow::Cow;
24761 use std::io::{Read, Seek};
24762
24763 use common::{url::Params, ToParts};
24764 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24765
24766 let mut dd = common::DefaultDelegate;
24767 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24768 dlg.begin(common::MethodInfo {
24769 id: "vmmigration.projects.locations.sources.fetchStorageInventory",
24770 http_method: hyper::Method::GET,
24771 });
24772
24773 for &field in [
24774 "alt",
24775 "source",
24776 "type",
24777 "pageToken",
24778 "pageSize",
24779 "forceRefresh",
24780 ]
24781 .iter()
24782 {
24783 if self._additional_params.contains_key(field) {
24784 dlg.finished(false);
24785 return Err(common::Error::FieldClash(field));
24786 }
24787 }
24788
24789 let mut params = Params::with_capacity(7 + self._additional_params.len());
24790 params.push("source", self._source);
24791 if let Some(value) = self._type_.as_ref() {
24792 params.push("type", value);
24793 }
24794 if let Some(value) = self._page_token.as_ref() {
24795 params.push("pageToken", value);
24796 }
24797 if let Some(value) = self._page_size.as_ref() {
24798 params.push("pageSize", value.to_string());
24799 }
24800 if let Some(value) = self._force_refresh.as_ref() {
24801 params.push("forceRefresh", value.to_string());
24802 }
24803
24804 params.extend(self._additional_params.iter());
24805
24806 params.push("alt", "json");
24807 let mut url = self.hub._base_url.clone() + "v1/{+source}:fetchStorageInventory";
24808 if self._scopes.is_empty() {
24809 self._scopes
24810 .insert(Scope::CloudPlatform.as_ref().to_string());
24811 }
24812
24813 #[allow(clippy::single_element_loop)]
24814 for &(find_this, param_name) in [("{+source}", "source")].iter() {
24815 url = params.uri_replacement(url, param_name, find_this, true);
24816 }
24817 {
24818 let to_remove = ["source"];
24819 params.remove_params(&to_remove);
24820 }
24821
24822 let url = params.parse_with_url(&url);
24823
24824 loop {
24825 let token = match self
24826 .hub
24827 .auth
24828 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24829 .await
24830 {
24831 Ok(token) => token,
24832 Err(e) => match dlg.token(e) {
24833 Ok(token) => token,
24834 Err(e) => {
24835 dlg.finished(false);
24836 return Err(common::Error::MissingToken(e));
24837 }
24838 },
24839 };
24840 let mut req_result = {
24841 let client = &self.hub.client;
24842 dlg.pre_request();
24843 let mut req_builder = hyper::Request::builder()
24844 .method(hyper::Method::GET)
24845 .uri(url.as_str())
24846 .header(USER_AGENT, self.hub._user_agent.clone());
24847
24848 if let Some(token) = token.as_ref() {
24849 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24850 }
24851
24852 let request = req_builder
24853 .header(CONTENT_LENGTH, 0_u64)
24854 .body(common::to_body::<String>(None));
24855
24856 client.request(request.unwrap()).await
24857 };
24858
24859 match req_result {
24860 Err(err) => {
24861 if let common::Retry::After(d) = dlg.http_error(&err) {
24862 sleep(d).await;
24863 continue;
24864 }
24865 dlg.finished(false);
24866 return Err(common::Error::HttpError(err));
24867 }
24868 Ok(res) => {
24869 let (mut parts, body) = res.into_parts();
24870 let mut body = common::Body::new(body);
24871 if !parts.status.is_success() {
24872 let bytes = common::to_bytes(body).await.unwrap_or_default();
24873 let error = serde_json::from_str(&common::to_string(&bytes));
24874 let response = common::to_response(parts, bytes.into());
24875
24876 if let common::Retry::After(d) =
24877 dlg.http_failure(&response, error.as_ref().ok())
24878 {
24879 sleep(d).await;
24880 continue;
24881 }
24882
24883 dlg.finished(false);
24884
24885 return Err(match error {
24886 Ok(value) => common::Error::BadRequest(value),
24887 _ => common::Error::Failure(response),
24888 });
24889 }
24890 let response = {
24891 let bytes = common::to_bytes(body).await.unwrap_or_default();
24892 let encoded = common::to_string(&bytes);
24893 match serde_json::from_str(&encoded) {
24894 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24895 Err(error) => {
24896 dlg.response_json_decode_error(&encoded, &error);
24897 return Err(common::Error::JsonDecodeError(
24898 encoded.to_string(),
24899 error,
24900 ));
24901 }
24902 }
24903 };
24904
24905 dlg.finished(true);
24906 return Ok(response);
24907 }
24908 }
24909 }
24910 }
24911
24912 /// Required. The name of the Source.
24913 ///
24914 /// Sets the *source* path property to the given value.
24915 ///
24916 /// Even though the property as already been set when instantiating this call,
24917 /// we provide this method for API completeness.
24918 pub fn source(
24919 mut self,
24920 new_value: &str,
24921 ) -> ProjectLocationSourceFetchStorageInventoryCall<'a, C> {
24922 self._source = new_value.to_string();
24923 self
24924 }
24925 /// Required. The type of the storage inventory to fetch.
24926 ///
24927 /// Sets the *type* query property to the given value.
24928 pub fn type_(
24929 mut self,
24930 new_value: &str,
24931 ) -> ProjectLocationSourceFetchStorageInventoryCall<'a, C> {
24932 self._type_ = Some(new_value.to_string());
24933 self
24934 }
24935 /// Optional. A page token, received from a previous `FetchStorageInventory` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `FetchStorageInventory` must match the call that provided the page token.
24936 ///
24937 /// Sets the *page token* query property to the given value.
24938 pub fn page_token(
24939 mut self,
24940 new_value: &str,
24941 ) -> ProjectLocationSourceFetchStorageInventoryCall<'a, C> {
24942 self._page_token = Some(new_value.to_string());
24943 self
24944 }
24945 /// Optional. The maximum number of VMs to return. The service may return fewer than this value.
24946 ///
24947 /// Sets the *page size* query property to the given value.
24948 pub fn page_size(
24949 mut self,
24950 new_value: i32,
24951 ) -> ProjectLocationSourceFetchStorageInventoryCall<'a, C> {
24952 self._page_size = Some(new_value);
24953 self
24954 }
24955 /// Optional. 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.
24956 ///
24957 /// Sets the *force refresh* query property to the given value.
24958 pub fn force_refresh(
24959 mut self,
24960 new_value: bool,
24961 ) -> ProjectLocationSourceFetchStorageInventoryCall<'a, C> {
24962 self._force_refresh = Some(new_value);
24963 self
24964 }
24965 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24966 /// while executing the actual API request.
24967 ///
24968 /// ````text
24969 /// It should be used to handle progress information, and to implement a certain level of resilience.
24970 /// ````
24971 ///
24972 /// Sets the *delegate* property to the given value.
24973 pub fn delegate(
24974 mut self,
24975 new_value: &'a mut dyn common::Delegate,
24976 ) -> ProjectLocationSourceFetchStorageInventoryCall<'a, C> {
24977 self._delegate = Some(new_value);
24978 self
24979 }
24980
24981 /// Set any additional parameter of the query string used in the request.
24982 /// It should be used to set parameters which are not yet available through their own
24983 /// setters.
24984 ///
24985 /// Please note that this method must not be used to set any of the known parameters
24986 /// which have their own setter method. If done anyway, the request will fail.
24987 ///
24988 /// # Additional Parameters
24989 ///
24990 /// * *$.xgafv* (query-string) - V1 error format.
24991 /// * *access_token* (query-string) - OAuth access token.
24992 /// * *alt* (query-string) - Data format for response.
24993 /// * *callback* (query-string) - JSONP
24994 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24995 /// * *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.
24996 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24997 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24998 /// * *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.
24999 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25000 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25001 pub fn param<T>(
25002 mut self,
25003 name: T,
25004 value: T,
25005 ) -> ProjectLocationSourceFetchStorageInventoryCall<'a, C>
25006 where
25007 T: AsRef<str>,
25008 {
25009 self._additional_params
25010 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25011 self
25012 }
25013
25014 /// Identifies the authorization scope for the method you are building.
25015 ///
25016 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25017 /// [`Scope::CloudPlatform`].
25018 ///
25019 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25020 /// tokens for more than one scope.
25021 ///
25022 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25023 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25024 /// sufficient, a read-write scope will do as well.
25025 pub fn add_scope<St>(
25026 mut self,
25027 scope: St,
25028 ) -> ProjectLocationSourceFetchStorageInventoryCall<'a, C>
25029 where
25030 St: AsRef<str>,
25031 {
25032 self._scopes.insert(String::from(scope.as_ref()));
25033 self
25034 }
25035 /// Identifies the authorization scope(s) for the method you are building.
25036 ///
25037 /// See [`Self::add_scope()`] for details.
25038 pub fn add_scopes<I, St>(
25039 mut self,
25040 scopes: I,
25041 ) -> ProjectLocationSourceFetchStorageInventoryCall<'a, C>
25042 where
25043 I: IntoIterator<Item = St>,
25044 St: AsRef<str>,
25045 {
25046 self._scopes
25047 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25048 self
25049 }
25050
25051 /// Removes all scopes, and no default scope will be used either.
25052 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25053 /// for details).
25054 pub fn clear_scopes(mut self) -> ProjectLocationSourceFetchStorageInventoryCall<'a, C> {
25055 self._scopes.clear();
25056 self
25057 }
25058}
25059
25060/// Gets details of a single Source.
25061///
25062/// A builder for the *locations.sources.get* method supported by a *project* resource.
25063/// It is not used directly, but through a [`ProjectMethods`] instance.
25064///
25065/// # Example
25066///
25067/// Instantiate a resource method builder
25068///
25069/// ```test_harness,no_run
25070/// # extern crate hyper;
25071/// # extern crate hyper_rustls;
25072/// # extern crate google_vmmigration1 as vmmigration1;
25073/// # async fn dox() {
25074/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25075///
25076/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25077/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25078/// # .with_native_roots()
25079/// # .unwrap()
25080/// # .https_only()
25081/// # .enable_http2()
25082/// # .build();
25083///
25084/// # let executor = hyper_util::rt::TokioExecutor::new();
25085/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25086/// # secret,
25087/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25088/// # yup_oauth2::client::CustomHyperClientBuilder::from(
25089/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
25090/// # ),
25091/// # ).build().await.unwrap();
25092///
25093/// # let client = hyper_util::client::legacy::Client::builder(
25094/// # hyper_util::rt::TokioExecutor::new()
25095/// # )
25096/// # .build(
25097/// # hyper_rustls::HttpsConnectorBuilder::new()
25098/// # .with_native_roots()
25099/// # .unwrap()
25100/// # .https_or_http()
25101/// # .enable_http2()
25102/// # .build()
25103/// # );
25104/// # let mut hub = VMMigrationService::new(client, auth);
25105/// // You can configure optional parameters by calling the respective setters at will, and
25106/// // execute the final call using `doit()`.
25107/// // Values shown here are possibly random and not representative !
25108/// let result = hub.projects().locations_sources_get("name")
25109/// .doit().await;
25110/// # }
25111/// ```
25112pub struct ProjectLocationSourceGetCall<'a, C>
25113where
25114 C: 'a,
25115{
25116 hub: &'a VMMigrationService<C>,
25117 _name: String,
25118 _delegate: Option<&'a mut dyn common::Delegate>,
25119 _additional_params: HashMap<String, String>,
25120 _scopes: BTreeSet<String>,
25121}
25122
25123impl<'a, C> common::CallBuilder for ProjectLocationSourceGetCall<'a, C> {}
25124
25125impl<'a, C> ProjectLocationSourceGetCall<'a, C>
25126where
25127 C: common::Connector,
25128{
25129 /// Perform the operation you have build so far.
25130 pub async fn doit(mut self) -> common::Result<(common::Response, Source)> {
25131 use std::borrow::Cow;
25132 use std::io::{Read, Seek};
25133
25134 use common::{url::Params, ToParts};
25135 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25136
25137 let mut dd = common::DefaultDelegate;
25138 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25139 dlg.begin(common::MethodInfo {
25140 id: "vmmigration.projects.locations.sources.get",
25141 http_method: hyper::Method::GET,
25142 });
25143
25144 for &field in ["alt", "name"].iter() {
25145 if self._additional_params.contains_key(field) {
25146 dlg.finished(false);
25147 return Err(common::Error::FieldClash(field));
25148 }
25149 }
25150
25151 let mut params = Params::with_capacity(3 + self._additional_params.len());
25152 params.push("name", self._name);
25153
25154 params.extend(self._additional_params.iter());
25155
25156 params.push("alt", "json");
25157 let mut url = self.hub._base_url.clone() + "v1/{+name}";
25158 if self._scopes.is_empty() {
25159 self._scopes
25160 .insert(Scope::CloudPlatform.as_ref().to_string());
25161 }
25162
25163 #[allow(clippy::single_element_loop)]
25164 for &(find_this, param_name) in [("{+name}", "name")].iter() {
25165 url = params.uri_replacement(url, param_name, find_this, true);
25166 }
25167 {
25168 let to_remove = ["name"];
25169 params.remove_params(&to_remove);
25170 }
25171
25172 let url = params.parse_with_url(&url);
25173
25174 loop {
25175 let token = match self
25176 .hub
25177 .auth
25178 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25179 .await
25180 {
25181 Ok(token) => token,
25182 Err(e) => match dlg.token(e) {
25183 Ok(token) => token,
25184 Err(e) => {
25185 dlg.finished(false);
25186 return Err(common::Error::MissingToken(e));
25187 }
25188 },
25189 };
25190 let mut req_result = {
25191 let client = &self.hub.client;
25192 dlg.pre_request();
25193 let mut req_builder = hyper::Request::builder()
25194 .method(hyper::Method::GET)
25195 .uri(url.as_str())
25196 .header(USER_AGENT, self.hub._user_agent.clone());
25197
25198 if let Some(token) = token.as_ref() {
25199 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25200 }
25201
25202 let request = req_builder
25203 .header(CONTENT_LENGTH, 0_u64)
25204 .body(common::to_body::<String>(None));
25205
25206 client.request(request.unwrap()).await
25207 };
25208
25209 match req_result {
25210 Err(err) => {
25211 if let common::Retry::After(d) = dlg.http_error(&err) {
25212 sleep(d).await;
25213 continue;
25214 }
25215 dlg.finished(false);
25216 return Err(common::Error::HttpError(err));
25217 }
25218 Ok(res) => {
25219 let (mut parts, body) = res.into_parts();
25220 let mut body = common::Body::new(body);
25221 if !parts.status.is_success() {
25222 let bytes = common::to_bytes(body).await.unwrap_or_default();
25223 let error = serde_json::from_str(&common::to_string(&bytes));
25224 let response = common::to_response(parts, bytes.into());
25225
25226 if let common::Retry::After(d) =
25227 dlg.http_failure(&response, error.as_ref().ok())
25228 {
25229 sleep(d).await;
25230 continue;
25231 }
25232
25233 dlg.finished(false);
25234
25235 return Err(match error {
25236 Ok(value) => common::Error::BadRequest(value),
25237 _ => common::Error::Failure(response),
25238 });
25239 }
25240 let response = {
25241 let bytes = common::to_bytes(body).await.unwrap_or_default();
25242 let encoded = common::to_string(&bytes);
25243 match serde_json::from_str(&encoded) {
25244 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25245 Err(error) => {
25246 dlg.response_json_decode_error(&encoded, &error);
25247 return Err(common::Error::JsonDecodeError(
25248 encoded.to_string(),
25249 error,
25250 ));
25251 }
25252 }
25253 };
25254
25255 dlg.finished(true);
25256 return Ok(response);
25257 }
25258 }
25259 }
25260 }
25261
25262 /// Required. The Source name.
25263 ///
25264 /// Sets the *name* path property to the given value.
25265 ///
25266 /// Even though the property as already been set when instantiating this call,
25267 /// we provide this method for API completeness.
25268 pub fn name(mut self, new_value: &str) -> ProjectLocationSourceGetCall<'a, C> {
25269 self._name = new_value.to_string();
25270 self
25271 }
25272 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25273 /// while executing the actual API request.
25274 ///
25275 /// ````text
25276 /// It should be used to handle progress information, and to implement a certain level of resilience.
25277 /// ````
25278 ///
25279 /// Sets the *delegate* property to the given value.
25280 pub fn delegate(
25281 mut self,
25282 new_value: &'a mut dyn common::Delegate,
25283 ) -> ProjectLocationSourceGetCall<'a, C> {
25284 self._delegate = Some(new_value);
25285 self
25286 }
25287
25288 /// Set any additional parameter of the query string used in the request.
25289 /// It should be used to set parameters which are not yet available through their own
25290 /// setters.
25291 ///
25292 /// Please note that this method must not be used to set any of the known parameters
25293 /// which have their own setter method. If done anyway, the request will fail.
25294 ///
25295 /// # Additional Parameters
25296 ///
25297 /// * *$.xgafv* (query-string) - V1 error format.
25298 /// * *access_token* (query-string) - OAuth access token.
25299 /// * *alt* (query-string) - Data format for response.
25300 /// * *callback* (query-string) - JSONP
25301 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25302 /// * *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.
25303 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25304 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25305 /// * *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.
25306 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25307 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25308 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSourceGetCall<'a, C>
25309 where
25310 T: AsRef<str>,
25311 {
25312 self._additional_params
25313 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25314 self
25315 }
25316
25317 /// Identifies the authorization scope for the method you are building.
25318 ///
25319 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25320 /// [`Scope::CloudPlatform`].
25321 ///
25322 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25323 /// tokens for more than one scope.
25324 ///
25325 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25326 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25327 /// sufficient, a read-write scope will do as well.
25328 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceGetCall<'a, C>
25329 where
25330 St: AsRef<str>,
25331 {
25332 self._scopes.insert(String::from(scope.as_ref()));
25333 self
25334 }
25335 /// Identifies the authorization scope(s) for the method you are building.
25336 ///
25337 /// See [`Self::add_scope()`] for details.
25338 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSourceGetCall<'a, C>
25339 where
25340 I: IntoIterator<Item = St>,
25341 St: AsRef<str>,
25342 {
25343 self._scopes
25344 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25345 self
25346 }
25347
25348 /// Removes all scopes, and no default scope will be used either.
25349 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25350 /// for details).
25351 pub fn clear_scopes(mut self) -> ProjectLocationSourceGetCall<'a, C> {
25352 self._scopes.clear();
25353 self
25354 }
25355}
25356
25357/// Lists Sources in a given project and location.
25358///
25359/// A builder for the *locations.sources.list* method supported by a *project* resource.
25360/// It is not used directly, but through a [`ProjectMethods`] instance.
25361///
25362/// # Example
25363///
25364/// Instantiate a resource method builder
25365///
25366/// ```test_harness,no_run
25367/// # extern crate hyper;
25368/// # extern crate hyper_rustls;
25369/// # extern crate google_vmmigration1 as vmmigration1;
25370/// # async fn dox() {
25371/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25372///
25373/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25374/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25375/// # .with_native_roots()
25376/// # .unwrap()
25377/// # .https_only()
25378/// # .enable_http2()
25379/// # .build();
25380///
25381/// # let executor = hyper_util::rt::TokioExecutor::new();
25382/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25383/// # secret,
25384/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25385/// # yup_oauth2::client::CustomHyperClientBuilder::from(
25386/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
25387/// # ),
25388/// # ).build().await.unwrap();
25389///
25390/// # let client = hyper_util::client::legacy::Client::builder(
25391/// # hyper_util::rt::TokioExecutor::new()
25392/// # )
25393/// # .build(
25394/// # hyper_rustls::HttpsConnectorBuilder::new()
25395/// # .with_native_roots()
25396/// # .unwrap()
25397/// # .https_or_http()
25398/// # .enable_http2()
25399/// # .build()
25400/// # );
25401/// # let mut hub = VMMigrationService::new(client, auth);
25402/// // You can configure optional parameters by calling the respective setters at will, and
25403/// // execute the final call using `doit()`.
25404/// // Values shown here are possibly random and not representative !
25405/// let result = hub.projects().locations_sources_list("parent")
25406/// .page_token("At")
25407/// .page_size(-84)
25408/// .order_by("eirmod")
25409/// .filter("Lorem")
25410/// .doit().await;
25411/// # }
25412/// ```
25413pub struct ProjectLocationSourceListCall<'a, C>
25414where
25415 C: 'a,
25416{
25417 hub: &'a VMMigrationService<C>,
25418 _parent: String,
25419 _page_token: Option<String>,
25420 _page_size: Option<i32>,
25421 _order_by: Option<String>,
25422 _filter: Option<String>,
25423 _delegate: Option<&'a mut dyn common::Delegate>,
25424 _additional_params: HashMap<String, String>,
25425 _scopes: BTreeSet<String>,
25426}
25427
25428impl<'a, C> common::CallBuilder for ProjectLocationSourceListCall<'a, C> {}
25429
25430impl<'a, C> ProjectLocationSourceListCall<'a, C>
25431where
25432 C: common::Connector,
25433{
25434 /// Perform the operation you have build so far.
25435 pub async fn doit(mut self) -> common::Result<(common::Response, ListSourcesResponse)> {
25436 use std::borrow::Cow;
25437 use std::io::{Read, Seek};
25438
25439 use common::{url::Params, ToParts};
25440 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25441
25442 let mut dd = common::DefaultDelegate;
25443 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25444 dlg.begin(common::MethodInfo {
25445 id: "vmmigration.projects.locations.sources.list",
25446 http_method: hyper::Method::GET,
25447 });
25448
25449 for &field in [
25450 "alt",
25451 "parent",
25452 "pageToken",
25453 "pageSize",
25454 "orderBy",
25455 "filter",
25456 ]
25457 .iter()
25458 {
25459 if self._additional_params.contains_key(field) {
25460 dlg.finished(false);
25461 return Err(common::Error::FieldClash(field));
25462 }
25463 }
25464
25465 let mut params = Params::with_capacity(7 + self._additional_params.len());
25466 params.push("parent", self._parent);
25467 if let Some(value) = self._page_token.as_ref() {
25468 params.push("pageToken", value);
25469 }
25470 if let Some(value) = self._page_size.as_ref() {
25471 params.push("pageSize", value.to_string());
25472 }
25473 if let Some(value) = self._order_by.as_ref() {
25474 params.push("orderBy", value);
25475 }
25476 if let Some(value) = self._filter.as_ref() {
25477 params.push("filter", value);
25478 }
25479
25480 params.extend(self._additional_params.iter());
25481
25482 params.push("alt", "json");
25483 let mut url = self.hub._base_url.clone() + "v1/{+parent}/sources";
25484 if self._scopes.is_empty() {
25485 self._scopes
25486 .insert(Scope::CloudPlatform.as_ref().to_string());
25487 }
25488
25489 #[allow(clippy::single_element_loop)]
25490 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
25491 url = params.uri_replacement(url, param_name, find_this, true);
25492 }
25493 {
25494 let to_remove = ["parent"];
25495 params.remove_params(&to_remove);
25496 }
25497
25498 let url = params.parse_with_url(&url);
25499
25500 loop {
25501 let token = match self
25502 .hub
25503 .auth
25504 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25505 .await
25506 {
25507 Ok(token) => token,
25508 Err(e) => match dlg.token(e) {
25509 Ok(token) => token,
25510 Err(e) => {
25511 dlg.finished(false);
25512 return Err(common::Error::MissingToken(e));
25513 }
25514 },
25515 };
25516 let mut req_result = {
25517 let client = &self.hub.client;
25518 dlg.pre_request();
25519 let mut req_builder = hyper::Request::builder()
25520 .method(hyper::Method::GET)
25521 .uri(url.as_str())
25522 .header(USER_AGENT, self.hub._user_agent.clone());
25523
25524 if let Some(token) = token.as_ref() {
25525 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25526 }
25527
25528 let request = req_builder
25529 .header(CONTENT_LENGTH, 0_u64)
25530 .body(common::to_body::<String>(None));
25531
25532 client.request(request.unwrap()).await
25533 };
25534
25535 match req_result {
25536 Err(err) => {
25537 if let common::Retry::After(d) = dlg.http_error(&err) {
25538 sleep(d).await;
25539 continue;
25540 }
25541 dlg.finished(false);
25542 return Err(common::Error::HttpError(err));
25543 }
25544 Ok(res) => {
25545 let (mut parts, body) = res.into_parts();
25546 let mut body = common::Body::new(body);
25547 if !parts.status.is_success() {
25548 let bytes = common::to_bytes(body).await.unwrap_or_default();
25549 let error = serde_json::from_str(&common::to_string(&bytes));
25550 let response = common::to_response(parts, bytes.into());
25551
25552 if let common::Retry::After(d) =
25553 dlg.http_failure(&response, error.as_ref().ok())
25554 {
25555 sleep(d).await;
25556 continue;
25557 }
25558
25559 dlg.finished(false);
25560
25561 return Err(match error {
25562 Ok(value) => common::Error::BadRequest(value),
25563 _ => common::Error::Failure(response),
25564 });
25565 }
25566 let response = {
25567 let bytes = common::to_bytes(body).await.unwrap_or_default();
25568 let encoded = common::to_string(&bytes);
25569 match serde_json::from_str(&encoded) {
25570 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25571 Err(error) => {
25572 dlg.response_json_decode_error(&encoded, &error);
25573 return Err(common::Error::JsonDecodeError(
25574 encoded.to_string(),
25575 error,
25576 ));
25577 }
25578 }
25579 };
25580
25581 dlg.finished(true);
25582 return Ok(response);
25583 }
25584 }
25585 }
25586 }
25587
25588 /// Required. The parent, which owns this collection of sources.
25589 ///
25590 /// Sets the *parent* path property to the given value.
25591 ///
25592 /// Even though the property as already been set when instantiating this call,
25593 /// we provide this method for API completeness.
25594 pub fn parent(mut self, new_value: &str) -> ProjectLocationSourceListCall<'a, C> {
25595 self._parent = new_value.to_string();
25596 self
25597 }
25598 /// 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.
25599 ///
25600 /// Sets the *page token* query property to the given value.
25601 pub fn page_token(mut self, new_value: &str) -> ProjectLocationSourceListCall<'a, C> {
25602 self._page_token = Some(new_value.to_string());
25603 self
25604 }
25605 /// 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.
25606 ///
25607 /// Sets the *page size* query property to the given value.
25608 pub fn page_size(mut self, new_value: i32) -> ProjectLocationSourceListCall<'a, C> {
25609 self._page_size = Some(new_value);
25610 self
25611 }
25612 /// Optional. the order by fields for the result.
25613 ///
25614 /// Sets the *order by* query property to the given value.
25615 pub fn order_by(mut self, new_value: &str) -> ProjectLocationSourceListCall<'a, C> {
25616 self._order_by = Some(new_value.to_string());
25617 self
25618 }
25619 /// Optional. The filter request.
25620 ///
25621 /// Sets the *filter* query property to the given value.
25622 pub fn filter(mut self, new_value: &str) -> ProjectLocationSourceListCall<'a, C> {
25623 self._filter = Some(new_value.to_string());
25624 self
25625 }
25626 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25627 /// while executing the actual API request.
25628 ///
25629 /// ````text
25630 /// It should be used to handle progress information, and to implement a certain level of resilience.
25631 /// ````
25632 ///
25633 /// Sets the *delegate* property to the given value.
25634 pub fn delegate(
25635 mut self,
25636 new_value: &'a mut dyn common::Delegate,
25637 ) -> ProjectLocationSourceListCall<'a, C> {
25638 self._delegate = Some(new_value);
25639 self
25640 }
25641
25642 /// Set any additional parameter of the query string used in the request.
25643 /// It should be used to set parameters which are not yet available through their own
25644 /// setters.
25645 ///
25646 /// Please note that this method must not be used to set any of the known parameters
25647 /// which have their own setter method. If done anyway, the request will fail.
25648 ///
25649 /// # Additional Parameters
25650 ///
25651 /// * *$.xgafv* (query-string) - V1 error format.
25652 /// * *access_token* (query-string) - OAuth access token.
25653 /// * *alt* (query-string) - Data format for response.
25654 /// * *callback* (query-string) - JSONP
25655 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25656 /// * *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.
25657 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25658 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25659 /// * *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.
25660 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25661 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25662 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSourceListCall<'a, C>
25663 where
25664 T: AsRef<str>,
25665 {
25666 self._additional_params
25667 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25668 self
25669 }
25670
25671 /// Identifies the authorization scope for the method you are building.
25672 ///
25673 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25674 /// [`Scope::CloudPlatform`].
25675 ///
25676 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25677 /// tokens for more than one scope.
25678 ///
25679 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25680 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25681 /// sufficient, a read-write scope will do as well.
25682 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourceListCall<'a, C>
25683 where
25684 St: AsRef<str>,
25685 {
25686 self._scopes.insert(String::from(scope.as_ref()));
25687 self
25688 }
25689 /// Identifies the authorization scope(s) for the method you are building.
25690 ///
25691 /// See [`Self::add_scope()`] for details.
25692 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSourceListCall<'a, C>
25693 where
25694 I: IntoIterator<Item = St>,
25695 St: AsRef<str>,
25696 {
25697 self._scopes
25698 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25699 self
25700 }
25701
25702 /// Removes all scopes, and no default scope will be used either.
25703 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25704 /// for details).
25705 pub fn clear_scopes(mut self) -> ProjectLocationSourceListCall<'a, C> {
25706 self._scopes.clear();
25707 self
25708 }
25709}
25710
25711/// Updates the parameters of a single Source.
25712///
25713/// A builder for the *locations.sources.patch* method supported by a *project* resource.
25714/// It is not used directly, but through a [`ProjectMethods`] instance.
25715///
25716/// # Example
25717///
25718/// Instantiate a resource method builder
25719///
25720/// ```test_harness,no_run
25721/// # extern crate hyper;
25722/// # extern crate hyper_rustls;
25723/// # extern crate google_vmmigration1 as vmmigration1;
25724/// use vmmigration1::api::Source;
25725/// # async fn dox() {
25726/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25727///
25728/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25729/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25730/// # .with_native_roots()
25731/// # .unwrap()
25732/// # .https_only()
25733/// # .enable_http2()
25734/// # .build();
25735///
25736/// # let executor = hyper_util::rt::TokioExecutor::new();
25737/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25738/// # secret,
25739/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25740/// # yup_oauth2::client::CustomHyperClientBuilder::from(
25741/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
25742/// # ),
25743/// # ).build().await.unwrap();
25744///
25745/// # let client = hyper_util::client::legacy::Client::builder(
25746/// # hyper_util::rt::TokioExecutor::new()
25747/// # )
25748/// # .build(
25749/// # hyper_rustls::HttpsConnectorBuilder::new()
25750/// # .with_native_roots()
25751/// # .unwrap()
25752/// # .https_or_http()
25753/// # .enable_http2()
25754/// # .build()
25755/// # );
25756/// # let mut hub = VMMigrationService::new(client, auth);
25757/// // As the method needs a request, you would usually fill it with the desired information
25758/// // into the respective structure. Some of the parts shown here might not be applicable !
25759/// // Values shown here are possibly random and not representative !
25760/// let mut req = Source::default();
25761///
25762/// // You can configure optional parameters by calling the respective setters at will, and
25763/// // execute the final call using `doit()`.
25764/// // Values shown here are possibly random and not representative !
25765/// let result = hub.projects().locations_sources_patch(req, "name")
25766/// .update_mask(FieldMask::new::<&str>(&[]))
25767/// .request_id("amet")
25768/// .doit().await;
25769/// # }
25770/// ```
25771pub struct ProjectLocationSourcePatchCall<'a, C>
25772where
25773 C: 'a,
25774{
25775 hub: &'a VMMigrationService<C>,
25776 _request: Source,
25777 _name: String,
25778 _update_mask: Option<common::FieldMask>,
25779 _request_id: Option<String>,
25780 _delegate: Option<&'a mut dyn common::Delegate>,
25781 _additional_params: HashMap<String, String>,
25782 _scopes: BTreeSet<String>,
25783}
25784
25785impl<'a, C> common::CallBuilder for ProjectLocationSourcePatchCall<'a, C> {}
25786
25787impl<'a, C> ProjectLocationSourcePatchCall<'a, C>
25788where
25789 C: common::Connector,
25790{
25791 /// Perform the operation you have build so far.
25792 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
25793 use std::borrow::Cow;
25794 use std::io::{Read, Seek};
25795
25796 use common::{url::Params, ToParts};
25797 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25798
25799 let mut dd = common::DefaultDelegate;
25800 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25801 dlg.begin(common::MethodInfo {
25802 id: "vmmigration.projects.locations.sources.patch",
25803 http_method: hyper::Method::PATCH,
25804 });
25805
25806 for &field in ["alt", "name", "updateMask", "requestId"].iter() {
25807 if self._additional_params.contains_key(field) {
25808 dlg.finished(false);
25809 return Err(common::Error::FieldClash(field));
25810 }
25811 }
25812
25813 let mut params = Params::with_capacity(6 + self._additional_params.len());
25814 params.push("name", self._name);
25815 if let Some(value) = self._update_mask.as_ref() {
25816 params.push("updateMask", value.to_string());
25817 }
25818 if let Some(value) = self._request_id.as_ref() {
25819 params.push("requestId", value);
25820 }
25821
25822 params.extend(self._additional_params.iter());
25823
25824 params.push("alt", "json");
25825 let mut url = self.hub._base_url.clone() + "v1/{+name}";
25826 if self._scopes.is_empty() {
25827 self._scopes
25828 .insert(Scope::CloudPlatform.as_ref().to_string());
25829 }
25830
25831 #[allow(clippy::single_element_loop)]
25832 for &(find_this, param_name) in [("{+name}", "name")].iter() {
25833 url = params.uri_replacement(url, param_name, find_this, true);
25834 }
25835 {
25836 let to_remove = ["name"];
25837 params.remove_params(&to_remove);
25838 }
25839
25840 let url = params.parse_with_url(&url);
25841
25842 let mut json_mime_type = mime::APPLICATION_JSON;
25843 let mut request_value_reader = {
25844 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25845 common::remove_json_null_values(&mut value);
25846 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25847 serde_json::to_writer(&mut dst, &value).unwrap();
25848 dst
25849 };
25850 let request_size = request_value_reader
25851 .seek(std::io::SeekFrom::End(0))
25852 .unwrap();
25853 request_value_reader
25854 .seek(std::io::SeekFrom::Start(0))
25855 .unwrap();
25856
25857 loop {
25858 let token = match self
25859 .hub
25860 .auth
25861 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25862 .await
25863 {
25864 Ok(token) => token,
25865 Err(e) => match dlg.token(e) {
25866 Ok(token) => token,
25867 Err(e) => {
25868 dlg.finished(false);
25869 return Err(common::Error::MissingToken(e));
25870 }
25871 },
25872 };
25873 request_value_reader
25874 .seek(std::io::SeekFrom::Start(0))
25875 .unwrap();
25876 let mut req_result = {
25877 let client = &self.hub.client;
25878 dlg.pre_request();
25879 let mut req_builder = hyper::Request::builder()
25880 .method(hyper::Method::PATCH)
25881 .uri(url.as_str())
25882 .header(USER_AGENT, self.hub._user_agent.clone());
25883
25884 if let Some(token) = token.as_ref() {
25885 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25886 }
25887
25888 let request = req_builder
25889 .header(CONTENT_TYPE, json_mime_type.to_string())
25890 .header(CONTENT_LENGTH, request_size as u64)
25891 .body(common::to_body(
25892 request_value_reader.get_ref().clone().into(),
25893 ));
25894
25895 client.request(request.unwrap()).await
25896 };
25897
25898 match req_result {
25899 Err(err) => {
25900 if let common::Retry::After(d) = dlg.http_error(&err) {
25901 sleep(d).await;
25902 continue;
25903 }
25904 dlg.finished(false);
25905 return Err(common::Error::HttpError(err));
25906 }
25907 Ok(res) => {
25908 let (mut parts, body) = res.into_parts();
25909 let mut body = common::Body::new(body);
25910 if !parts.status.is_success() {
25911 let bytes = common::to_bytes(body).await.unwrap_or_default();
25912 let error = serde_json::from_str(&common::to_string(&bytes));
25913 let response = common::to_response(parts, bytes.into());
25914
25915 if let common::Retry::After(d) =
25916 dlg.http_failure(&response, error.as_ref().ok())
25917 {
25918 sleep(d).await;
25919 continue;
25920 }
25921
25922 dlg.finished(false);
25923
25924 return Err(match error {
25925 Ok(value) => common::Error::BadRequest(value),
25926 _ => common::Error::Failure(response),
25927 });
25928 }
25929 let response = {
25930 let bytes = common::to_bytes(body).await.unwrap_or_default();
25931 let encoded = common::to_string(&bytes);
25932 match serde_json::from_str(&encoded) {
25933 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25934 Err(error) => {
25935 dlg.response_json_decode_error(&encoded, &error);
25936 return Err(common::Error::JsonDecodeError(
25937 encoded.to_string(),
25938 error,
25939 ));
25940 }
25941 }
25942 };
25943
25944 dlg.finished(true);
25945 return Ok(response);
25946 }
25947 }
25948 }
25949 }
25950
25951 ///
25952 /// Sets the *request* property to the given value.
25953 ///
25954 /// Even though the property as already been set when instantiating this call,
25955 /// we provide this method for API completeness.
25956 pub fn request(mut self, new_value: Source) -> ProjectLocationSourcePatchCall<'a, C> {
25957 self._request = new_value;
25958 self
25959 }
25960 /// Output only. The Source name.
25961 ///
25962 /// Sets the *name* path property to the given value.
25963 ///
25964 /// Even though the property as already been set when instantiating this call,
25965 /// we provide this method for API completeness.
25966 pub fn name(mut self, new_value: &str) -> ProjectLocationSourcePatchCall<'a, C> {
25967 self._name = new_value.to_string();
25968 self
25969 }
25970 /// 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.
25971 ///
25972 /// Sets the *update mask* query property to the given value.
25973 pub fn update_mask(
25974 mut self,
25975 new_value: common::FieldMask,
25976 ) -> ProjectLocationSourcePatchCall<'a, C> {
25977 self._update_mask = Some(new_value);
25978 self
25979 }
25980 /// 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).
25981 ///
25982 /// Sets the *request id* query property to the given value.
25983 pub fn request_id(mut self, new_value: &str) -> ProjectLocationSourcePatchCall<'a, C> {
25984 self._request_id = Some(new_value.to_string());
25985 self
25986 }
25987 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25988 /// while executing the actual API request.
25989 ///
25990 /// ````text
25991 /// It should be used to handle progress information, and to implement a certain level of resilience.
25992 /// ````
25993 ///
25994 /// Sets the *delegate* property to the given value.
25995 pub fn delegate(
25996 mut self,
25997 new_value: &'a mut dyn common::Delegate,
25998 ) -> ProjectLocationSourcePatchCall<'a, C> {
25999 self._delegate = Some(new_value);
26000 self
26001 }
26002
26003 /// Set any additional parameter of the query string used in the request.
26004 /// It should be used to set parameters which are not yet available through their own
26005 /// setters.
26006 ///
26007 /// Please note that this method must not be used to set any of the known parameters
26008 /// which have their own setter method. If done anyway, the request will fail.
26009 ///
26010 /// # Additional Parameters
26011 ///
26012 /// * *$.xgafv* (query-string) - V1 error format.
26013 /// * *access_token* (query-string) - OAuth access token.
26014 /// * *alt* (query-string) - Data format for response.
26015 /// * *callback* (query-string) - JSONP
26016 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26017 /// * *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.
26018 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26019 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26020 /// * *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.
26021 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26022 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26023 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSourcePatchCall<'a, C>
26024 where
26025 T: AsRef<str>,
26026 {
26027 self._additional_params
26028 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26029 self
26030 }
26031
26032 /// Identifies the authorization scope for the method you are building.
26033 ///
26034 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26035 /// [`Scope::CloudPlatform`].
26036 ///
26037 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26038 /// tokens for more than one scope.
26039 ///
26040 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26041 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26042 /// sufficient, a read-write scope will do as well.
26043 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSourcePatchCall<'a, C>
26044 where
26045 St: AsRef<str>,
26046 {
26047 self._scopes.insert(String::from(scope.as_ref()));
26048 self
26049 }
26050 /// Identifies the authorization scope(s) for the method you are building.
26051 ///
26052 /// See [`Self::add_scope()`] for details.
26053 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSourcePatchCall<'a, C>
26054 where
26055 I: IntoIterator<Item = St>,
26056 St: AsRef<str>,
26057 {
26058 self._scopes
26059 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26060 self
26061 }
26062
26063 /// Removes all scopes, and no default scope will be used either.
26064 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26065 /// for details).
26066 pub fn clear_scopes(mut self) -> ProjectLocationSourcePatchCall<'a, C> {
26067 self._scopes.clear();
26068 self
26069 }
26070}
26071
26072/// Creates a new TargetProject in a given project. NOTE: TargetProject is a global resource; hence the only supported value for location is `global`.
26073///
26074/// A builder for the *locations.targetProjects.create* method supported by a *project* resource.
26075/// It is not used directly, but through a [`ProjectMethods`] instance.
26076///
26077/// # Example
26078///
26079/// Instantiate a resource method builder
26080///
26081/// ```test_harness,no_run
26082/// # extern crate hyper;
26083/// # extern crate hyper_rustls;
26084/// # extern crate google_vmmigration1 as vmmigration1;
26085/// use vmmigration1::api::TargetProject;
26086/// # async fn dox() {
26087/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26088///
26089/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26090/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26091/// # .with_native_roots()
26092/// # .unwrap()
26093/// # .https_only()
26094/// # .enable_http2()
26095/// # .build();
26096///
26097/// # let executor = hyper_util::rt::TokioExecutor::new();
26098/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26099/// # secret,
26100/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26101/// # yup_oauth2::client::CustomHyperClientBuilder::from(
26102/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
26103/// # ),
26104/// # ).build().await.unwrap();
26105///
26106/// # let client = hyper_util::client::legacy::Client::builder(
26107/// # hyper_util::rt::TokioExecutor::new()
26108/// # )
26109/// # .build(
26110/// # hyper_rustls::HttpsConnectorBuilder::new()
26111/// # .with_native_roots()
26112/// # .unwrap()
26113/// # .https_or_http()
26114/// # .enable_http2()
26115/// # .build()
26116/// # );
26117/// # let mut hub = VMMigrationService::new(client, auth);
26118/// // As the method needs a request, you would usually fill it with the desired information
26119/// // into the respective structure. Some of the parts shown here might not be applicable !
26120/// // Values shown here are possibly random and not representative !
26121/// let mut req = TargetProject::default();
26122///
26123/// // You can configure optional parameters by calling the respective setters at will, and
26124/// // execute the final call using `doit()`.
26125/// // Values shown here are possibly random and not representative !
26126/// let result = hub.projects().locations_target_projects_create(req, "parent")
26127/// .target_project_id("dolores")
26128/// .request_id("erat")
26129/// .doit().await;
26130/// # }
26131/// ```
26132pub struct ProjectLocationTargetProjectCreateCall<'a, C>
26133where
26134 C: 'a,
26135{
26136 hub: &'a VMMigrationService<C>,
26137 _request: TargetProject,
26138 _parent: String,
26139 _target_project_id: Option<String>,
26140 _request_id: Option<String>,
26141 _delegate: Option<&'a mut dyn common::Delegate>,
26142 _additional_params: HashMap<String, String>,
26143 _scopes: BTreeSet<String>,
26144}
26145
26146impl<'a, C> common::CallBuilder for ProjectLocationTargetProjectCreateCall<'a, C> {}
26147
26148impl<'a, C> ProjectLocationTargetProjectCreateCall<'a, C>
26149where
26150 C: common::Connector,
26151{
26152 /// Perform the operation you have build so far.
26153 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
26154 use std::borrow::Cow;
26155 use std::io::{Read, Seek};
26156
26157 use common::{url::Params, ToParts};
26158 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26159
26160 let mut dd = common::DefaultDelegate;
26161 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26162 dlg.begin(common::MethodInfo {
26163 id: "vmmigration.projects.locations.targetProjects.create",
26164 http_method: hyper::Method::POST,
26165 });
26166
26167 for &field in ["alt", "parent", "targetProjectId", "requestId"].iter() {
26168 if self._additional_params.contains_key(field) {
26169 dlg.finished(false);
26170 return Err(common::Error::FieldClash(field));
26171 }
26172 }
26173
26174 let mut params = Params::with_capacity(6 + self._additional_params.len());
26175 params.push("parent", self._parent);
26176 if let Some(value) = self._target_project_id.as_ref() {
26177 params.push("targetProjectId", value);
26178 }
26179 if let Some(value) = self._request_id.as_ref() {
26180 params.push("requestId", value);
26181 }
26182
26183 params.extend(self._additional_params.iter());
26184
26185 params.push("alt", "json");
26186 let mut url = self.hub._base_url.clone() + "v1/{+parent}/targetProjects";
26187 if self._scopes.is_empty() {
26188 self._scopes
26189 .insert(Scope::CloudPlatform.as_ref().to_string());
26190 }
26191
26192 #[allow(clippy::single_element_loop)]
26193 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
26194 url = params.uri_replacement(url, param_name, find_this, true);
26195 }
26196 {
26197 let to_remove = ["parent"];
26198 params.remove_params(&to_remove);
26199 }
26200
26201 let url = params.parse_with_url(&url);
26202
26203 let mut json_mime_type = mime::APPLICATION_JSON;
26204 let mut request_value_reader = {
26205 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
26206 common::remove_json_null_values(&mut value);
26207 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
26208 serde_json::to_writer(&mut dst, &value).unwrap();
26209 dst
26210 };
26211 let request_size = request_value_reader
26212 .seek(std::io::SeekFrom::End(0))
26213 .unwrap();
26214 request_value_reader
26215 .seek(std::io::SeekFrom::Start(0))
26216 .unwrap();
26217
26218 loop {
26219 let token = match self
26220 .hub
26221 .auth
26222 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26223 .await
26224 {
26225 Ok(token) => token,
26226 Err(e) => match dlg.token(e) {
26227 Ok(token) => token,
26228 Err(e) => {
26229 dlg.finished(false);
26230 return Err(common::Error::MissingToken(e));
26231 }
26232 },
26233 };
26234 request_value_reader
26235 .seek(std::io::SeekFrom::Start(0))
26236 .unwrap();
26237 let mut req_result = {
26238 let client = &self.hub.client;
26239 dlg.pre_request();
26240 let mut req_builder = hyper::Request::builder()
26241 .method(hyper::Method::POST)
26242 .uri(url.as_str())
26243 .header(USER_AGENT, self.hub._user_agent.clone());
26244
26245 if let Some(token) = token.as_ref() {
26246 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26247 }
26248
26249 let request = req_builder
26250 .header(CONTENT_TYPE, json_mime_type.to_string())
26251 .header(CONTENT_LENGTH, request_size as u64)
26252 .body(common::to_body(
26253 request_value_reader.get_ref().clone().into(),
26254 ));
26255
26256 client.request(request.unwrap()).await
26257 };
26258
26259 match req_result {
26260 Err(err) => {
26261 if let common::Retry::After(d) = dlg.http_error(&err) {
26262 sleep(d).await;
26263 continue;
26264 }
26265 dlg.finished(false);
26266 return Err(common::Error::HttpError(err));
26267 }
26268 Ok(res) => {
26269 let (mut parts, body) = res.into_parts();
26270 let mut body = common::Body::new(body);
26271 if !parts.status.is_success() {
26272 let bytes = common::to_bytes(body).await.unwrap_or_default();
26273 let error = serde_json::from_str(&common::to_string(&bytes));
26274 let response = common::to_response(parts, bytes.into());
26275
26276 if let common::Retry::After(d) =
26277 dlg.http_failure(&response, error.as_ref().ok())
26278 {
26279 sleep(d).await;
26280 continue;
26281 }
26282
26283 dlg.finished(false);
26284
26285 return Err(match error {
26286 Ok(value) => common::Error::BadRequest(value),
26287 _ => common::Error::Failure(response),
26288 });
26289 }
26290 let response = {
26291 let bytes = common::to_bytes(body).await.unwrap_or_default();
26292 let encoded = common::to_string(&bytes);
26293 match serde_json::from_str(&encoded) {
26294 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26295 Err(error) => {
26296 dlg.response_json_decode_error(&encoded, &error);
26297 return Err(common::Error::JsonDecodeError(
26298 encoded.to_string(),
26299 error,
26300 ));
26301 }
26302 }
26303 };
26304
26305 dlg.finished(true);
26306 return Ok(response);
26307 }
26308 }
26309 }
26310 }
26311
26312 ///
26313 /// Sets the *request* property to the given value.
26314 ///
26315 /// Even though the property as already been set when instantiating this call,
26316 /// we provide this method for API completeness.
26317 pub fn request(
26318 mut self,
26319 new_value: TargetProject,
26320 ) -> ProjectLocationTargetProjectCreateCall<'a, C> {
26321 self._request = new_value;
26322 self
26323 }
26324 /// Required. The TargetProject's parent.
26325 ///
26326 /// Sets the *parent* path property to the given value.
26327 ///
26328 /// Even though the property as already been set when instantiating this call,
26329 /// we provide this method for API completeness.
26330 pub fn parent(mut self, new_value: &str) -> ProjectLocationTargetProjectCreateCall<'a, C> {
26331 self._parent = new_value.to_string();
26332 self
26333 }
26334 /// Required. The target_project identifier.
26335 ///
26336 /// Sets the *target project id* query property to the given value.
26337 pub fn target_project_id(
26338 mut self,
26339 new_value: &str,
26340 ) -> ProjectLocationTargetProjectCreateCall<'a, C> {
26341 self._target_project_id = Some(new_value.to_string());
26342 self
26343 }
26344 /// 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).
26345 ///
26346 /// Sets the *request id* query property to the given value.
26347 pub fn request_id(mut self, new_value: &str) -> ProjectLocationTargetProjectCreateCall<'a, C> {
26348 self._request_id = Some(new_value.to_string());
26349 self
26350 }
26351 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26352 /// while executing the actual API request.
26353 ///
26354 /// ````text
26355 /// It should be used to handle progress information, and to implement a certain level of resilience.
26356 /// ````
26357 ///
26358 /// Sets the *delegate* property to the given value.
26359 pub fn delegate(
26360 mut self,
26361 new_value: &'a mut dyn common::Delegate,
26362 ) -> ProjectLocationTargetProjectCreateCall<'a, C> {
26363 self._delegate = Some(new_value);
26364 self
26365 }
26366
26367 /// Set any additional parameter of the query string used in the request.
26368 /// It should be used to set parameters which are not yet available through their own
26369 /// setters.
26370 ///
26371 /// Please note that this method must not be used to set any of the known parameters
26372 /// which have their own setter method. If done anyway, the request will fail.
26373 ///
26374 /// # Additional Parameters
26375 ///
26376 /// * *$.xgafv* (query-string) - V1 error format.
26377 /// * *access_token* (query-string) - OAuth access token.
26378 /// * *alt* (query-string) - Data format for response.
26379 /// * *callback* (query-string) - JSONP
26380 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26381 /// * *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.
26382 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26383 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26384 /// * *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.
26385 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26386 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26387 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTargetProjectCreateCall<'a, C>
26388 where
26389 T: AsRef<str>,
26390 {
26391 self._additional_params
26392 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26393 self
26394 }
26395
26396 /// Identifies the authorization scope for the method you are building.
26397 ///
26398 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26399 /// [`Scope::CloudPlatform`].
26400 ///
26401 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26402 /// tokens for more than one scope.
26403 ///
26404 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26405 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26406 /// sufficient, a read-write scope will do as well.
26407 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTargetProjectCreateCall<'a, C>
26408 where
26409 St: AsRef<str>,
26410 {
26411 self._scopes.insert(String::from(scope.as_ref()));
26412 self
26413 }
26414 /// Identifies the authorization scope(s) for the method you are building.
26415 ///
26416 /// See [`Self::add_scope()`] for details.
26417 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTargetProjectCreateCall<'a, C>
26418 where
26419 I: IntoIterator<Item = St>,
26420 St: AsRef<str>,
26421 {
26422 self._scopes
26423 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26424 self
26425 }
26426
26427 /// Removes all scopes, and no default scope will be used either.
26428 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26429 /// for details).
26430 pub fn clear_scopes(mut self) -> ProjectLocationTargetProjectCreateCall<'a, C> {
26431 self._scopes.clear();
26432 self
26433 }
26434}
26435
26436/// Deletes a single TargetProject. NOTE: TargetProject is a global resource; hence the only supported value for location is `global`.
26437///
26438/// A builder for the *locations.targetProjects.delete* method supported by a *project* resource.
26439/// It is not used directly, but through a [`ProjectMethods`] instance.
26440///
26441/// # Example
26442///
26443/// Instantiate a resource method builder
26444///
26445/// ```test_harness,no_run
26446/// # extern crate hyper;
26447/// # extern crate hyper_rustls;
26448/// # extern crate google_vmmigration1 as vmmigration1;
26449/// # async fn dox() {
26450/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26451///
26452/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26453/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26454/// # .with_native_roots()
26455/// # .unwrap()
26456/// # .https_only()
26457/// # .enable_http2()
26458/// # .build();
26459///
26460/// # let executor = hyper_util::rt::TokioExecutor::new();
26461/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26462/// # secret,
26463/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26464/// # yup_oauth2::client::CustomHyperClientBuilder::from(
26465/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
26466/// # ),
26467/// # ).build().await.unwrap();
26468///
26469/// # let client = hyper_util::client::legacy::Client::builder(
26470/// # hyper_util::rt::TokioExecutor::new()
26471/// # )
26472/// # .build(
26473/// # hyper_rustls::HttpsConnectorBuilder::new()
26474/// # .with_native_roots()
26475/// # .unwrap()
26476/// # .https_or_http()
26477/// # .enable_http2()
26478/// # .build()
26479/// # );
26480/// # let mut hub = VMMigrationService::new(client, auth);
26481/// // You can configure optional parameters by calling the respective setters at will, and
26482/// // execute the final call using `doit()`.
26483/// // Values shown here are possibly random and not representative !
26484/// let result = hub.projects().locations_target_projects_delete("name")
26485/// .request_id("sea")
26486/// .doit().await;
26487/// # }
26488/// ```
26489pub struct ProjectLocationTargetProjectDeleteCall<'a, C>
26490where
26491 C: 'a,
26492{
26493 hub: &'a VMMigrationService<C>,
26494 _name: String,
26495 _request_id: Option<String>,
26496 _delegate: Option<&'a mut dyn common::Delegate>,
26497 _additional_params: HashMap<String, String>,
26498 _scopes: BTreeSet<String>,
26499}
26500
26501impl<'a, C> common::CallBuilder for ProjectLocationTargetProjectDeleteCall<'a, C> {}
26502
26503impl<'a, C> ProjectLocationTargetProjectDeleteCall<'a, C>
26504where
26505 C: common::Connector,
26506{
26507 /// Perform the operation you have build so far.
26508 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
26509 use std::borrow::Cow;
26510 use std::io::{Read, Seek};
26511
26512 use common::{url::Params, ToParts};
26513 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26514
26515 let mut dd = common::DefaultDelegate;
26516 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26517 dlg.begin(common::MethodInfo {
26518 id: "vmmigration.projects.locations.targetProjects.delete",
26519 http_method: hyper::Method::DELETE,
26520 });
26521
26522 for &field in ["alt", "name", "requestId"].iter() {
26523 if self._additional_params.contains_key(field) {
26524 dlg.finished(false);
26525 return Err(common::Error::FieldClash(field));
26526 }
26527 }
26528
26529 let mut params = Params::with_capacity(4 + self._additional_params.len());
26530 params.push("name", self._name);
26531 if let Some(value) = self._request_id.as_ref() {
26532 params.push("requestId", value);
26533 }
26534
26535 params.extend(self._additional_params.iter());
26536
26537 params.push("alt", "json");
26538 let mut url = self.hub._base_url.clone() + "v1/{+name}";
26539 if self._scopes.is_empty() {
26540 self._scopes
26541 .insert(Scope::CloudPlatform.as_ref().to_string());
26542 }
26543
26544 #[allow(clippy::single_element_loop)]
26545 for &(find_this, param_name) in [("{+name}", "name")].iter() {
26546 url = params.uri_replacement(url, param_name, find_this, true);
26547 }
26548 {
26549 let to_remove = ["name"];
26550 params.remove_params(&to_remove);
26551 }
26552
26553 let url = params.parse_with_url(&url);
26554
26555 loop {
26556 let token = match self
26557 .hub
26558 .auth
26559 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26560 .await
26561 {
26562 Ok(token) => token,
26563 Err(e) => match dlg.token(e) {
26564 Ok(token) => token,
26565 Err(e) => {
26566 dlg.finished(false);
26567 return Err(common::Error::MissingToken(e));
26568 }
26569 },
26570 };
26571 let mut req_result = {
26572 let client = &self.hub.client;
26573 dlg.pre_request();
26574 let mut req_builder = hyper::Request::builder()
26575 .method(hyper::Method::DELETE)
26576 .uri(url.as_str())
26577 .header(USER_AGENT, self.hub._user_agent.clone());
26578
26579 if let Some(token) = token.as_ref() {
26580 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26581 }
26582
26583 let request = req_builder
26584 .header(CONTENT_LENGTH, 0_u64)
26585 .body(common::to_body::<String>(None));
26586
26587 client.request(request.unwrap()).await
26588 };
26589
26590 match req_result {
26591 Err(err) => {
26592 if let common::Retry::After(d) = dlg.http_error(&err) {
26593 sleep(d).await;
26594 continue;
26595 }
26596 dlg.finished(false);
26597 return Err(common::Error::HttpError(err));
26598 }
26599 Ok(res) => {
26600 let (mut parts, body) = res.into_parts();
26601 let mut body = common::Body::new(body);
26602 if !parts.status.is_success() {
26603 let bytes = common::to_bytes(body).await.unwrap_or_default();
26604 let error = serde_json::from_str(&common::to_string(&bytes));
26605 let response = common::to_response(parts, bytes.into());
26606
26607 if let common::Retry::After(d) =
26608 dlg.http_failure(&response, error.as_ref().ok())
26609 {
26610 sleep(d).await;
26611 continue;
26612 }
26613
26614 dlg.finished(false);
26615
26616 return Err(match error {
26617 Ok(value) => common::Error::BadRequest(value),
26618 _ => common::Error::Failure(response),
26619 });
26620 }
26621 let response = {
26622 let bytes = common::to_bytes(body).await.unwrap_or_default();
26623 let encoded = common::to_string(&bytes);
26624 match serde_json::from_str(&encoded) {
26625 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26626 Err(error) => {
26627 dlg.response_json_decode_error(&encoded, &error);
26628 return Err(common::Error::JsonDecodeError(
26629 encoded.to_string(),
26630 error,
26631 ));
26632 }
26633 }
26634 };
26635
26636 dlg.finished(true);
26637 return Ok(response);
26638 }
26639 }
26640 }
26641 }
26642
26643 /// Required. The TargetProject name.
26644 ///
26645 /// Sets the *name* path property to the given value.
26646 ///
26647 /// Even though the property as already been set when instantiating this call,
26648 /// we provide this method for API completeness.
26649 pub fn name(mut self, new_value: &str) -> ProjectLocationTargetProjectDeleteCall<'a, C> {
26650 self._name = new_value.to_string();
26651 self
26652 }
26653 /// 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).
26654 ///
26655 /// Sets the *request id* query property to the given value.
26656 pub fn request_id(mut self, new_value: &str) -> ProjectLocationTargetProjectDeleteCall<'a, C> {
26657 self._request_id = Some(new_value.to_string());
26658 self
26659 }
26660 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26661 /// while executing the actual API request.
26662 ///
26663 /// ````text
26664 /// It should be used to handle progress information, and to implement a certain level of resilience.
26665 /// ````
26666 ///
26667 /// Sets the *delegate* property to the given value.
26668 pub fn delegate(
26669 mut self,
26670 new_value: &'a mut dyn common::Delegate,
26671 ) -> ProjectLocationTargetProjectDeleteCall<'a, C> {
26672 self._delegate = Some(new_value);
26673 self
26674 }
26675
26676 /// Set any additional parameter of the query string used in the request.
26677 /// It should be used to set parameters which are not yet available through their own
26678 /// setters.
26679 ///
26680 /// Please note that this method must not be used to set any of the known parameters
26681 /// which have their own setter method. If done anyway, the request will fail.
26682 ///
26683 /// # Additional Parameters
26684 ///
26685 /// * *$.xgafv* (query-string) - V1 error format.
26686 /// * *access_token* (query-string) - OAuth access token.
26687 /// * *alt* (query-string) - Data format for response.
26688 /// * *callback* (query-string) - JSONP
26689 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26690 /// * *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.
26691 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26692 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26693 /// * *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.
26694 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26695 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26696 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTargetProjectDeleteCall<'a, C>
26697 where
26698 T: AsRef<str>,
26699 {
26700 self._additional_params
26701 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26702 self
26703 }
26704
26705 /// Identifies the authorization scope for the method you are building.
26706 ///
26707 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26708 /// [`Scope::CloudPlatform`].
26709 ///
26710 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26711 /// tokens for more than one scope.
26712 ///
26713 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26714 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26715 /// sufficient, a read-write scope will do as well.
26716 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTargetProjectDeleteCall<'a, C>
26717 where
26718 St: AsRef<str>,
26719 {
26720 self._scopes.insert(String::from(scope.as_ref()));
26721 self
26722 }
26723 /// Identifies the authorization scope(s) for the method you are building.
26724 ///
26725 /// See [`Self::add_scope()`] for details.
26726 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTargetProjectDeleteCall<'a, C>
26727 where
26728 I: IntoIterator<Item = St>,
26729 St: AsRef<str>,
26730 {
26731 self._scopes
26732 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26733 self
26734 }
26735
26736 /// Removes all scopes, and no default scope will be used either.
26737 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26738 /// for details).
26739 pub fn clear_scopes(mut self) -> ProjectLocationTargetProjectDeleteCall<'a, C> {
26740 self._scopes.clear();
26741 self
26742 }
26743}
26744
26745/// Gets details of a single TargetProject. NOTE: TargetProject is a global resource; hence the only supported value for location is `global`.
26746///
26747/// A builder for the *locations.targetProjects.get* method supported by a *project* resource.
26748/// It is not used directly, but through a [`ProjectMethods`] instance.
26749///
26750/// # Example
26751///
26752/// Instantiate a resource method builder
26753///
26754/// ```test_harness,no_run
26755/// # extern crate hyper;
26756/// # extern crate hyper_rustls;
26757/// # extern crate google_vmmigration1 as vmmigration1;
26758/// # async fn dox() {
26759/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26760///
26761/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26762/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26763/// # .with_native_roots()
26764/// # .unwrap()
26765/// # .https_only()
26766/// # .enable_http2()
26767/// # .build();
26768///
26769/// # let executor = hyper_util::rt::TokioExecutor::new();
26770/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26771/// # secret,
26772/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26773/// # yup_oauth2::client::CustomHyperClientBuilder::from(
26774/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
26775/// # ),
26776/// # ).build().await.unwrap();
26777///
26778/// # let client = hyper_util::client::legacy::Client::builder(
26779/// # hyper_util::rt::TokioExecutor::new()
26780/// # )
26781/// # .build(
26782/// # hyper_rustls::HttpsConnectorBuilder::new()
26783/// # .with_native_roots()
26784/// # .unwrap()
26785/// # .https_or_http()
26786/// # .enable_http2()
26787/// # .build()
26788/// # );
26789/// # let mut hub = VMMigrationService::new(client, auth);
26790/// // You can configure optional parameters by calling the respective setters at will, and
26791/// // execute the final call using `doit()`.
26792/// // Values shown here are possibly random and not representative !
26793/// let result = hub.projects().locations_target_projects_get("name")
26794/// .doit().await;
26795/// # }
26796/// ```
26797pub struct ProjectLocationTargetProjectGetCall<'a, C>
26798where
26799 C: 'a,
26800{
26801 hub: &'a VMMigrationService<C>,
26802 _name: String,
26803 _delegate: Option<&'a mut dyn common::Delegate>,
26804 _additional_params: HashMap<String, String>,
26805 _scopes: BTreeSet<String>,
26806}
26807
26808impl<'a, C> common::CallBuilder for ProjectLocationTargetProjectGetCall<'a, C> {}
26809
26810impl<'a, C> ProjectLocationTargetProjectGetCall<'a, C>
26811where
26812 C: common::Connector,
26813{
26814 /// Perform the operation you have build so far.
26815 pub async fn doit(mut self) -> common::Result<(common::Response, TargetProject)> {
26816 use std::borrow::Cow;
26817 use std::io::{Read, Seek};
26818
26819 use common::{url::Params, ToParts};
26820 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26821
26822 let mut dd = common::DefaultDelegate;
26823 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26824 dlg.begin(common::MethodInfo {
26825 id: "vmmigration.projects.locations.targetProjects.get",
26826 http_method: hyper::Method::GET,
26827 });
26828
26829 for &field in ["alt", "name"].iter() {
26830 if self._additional_params.contains_key(field) {
26831 dlg.finished(false);
26832 return Err(common::Error::FieldClash(field));
26833 }
26834 }
26835
26836 let mut params = Params::with_capacity(3 + self._additional_params.len());
26837 params.push("name", self._name);
26838
26839 params.extend(self._additional_params.iter());
26840
26841 params.push("alt", "json");
26842 let mut url = self.hub._base_url.clone() + "v1/{+name}";
26843 if self._scopes.is_empty() {
26844 self._scopes
26845 .insert(Scope::CloudPlatform.as_ref().to_string());
26846 }
26847
26848 #[allow(clippy::single_element_loop)]
26849 for &(find_this, param_name) in [("{+name}", "name")].iter() {
26850 url = params.uri_replacement(url, param_name, find_this, true);
26851 }
26852 {
26853 let to_remove = ["name"];
26854 params.remove_params(&to_remove);
26855 }
26856
26857 let url = params.parse_with_url(&url);
26858
26859 loop {
26860 let token = match self
26861 .hub
26862 .auth
26863 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26864 .await
26865 {
26866 Ok(token) => token,
26867 Err(e) => match dlg.token(e) {
26868 Ok(token) => token,
26869 Err(e) => {
26870 dlg.finished(false);
26871 return Err(common::Error::MissingToken(e));
26872 }
26873 },
26874 };
26875 let mut req_result = {
26876 let client = &self.hub.client;
26877 dlg.pre_request();
26878 let mut req_builder = hyper::Request::builder()
26879 .method(hyper::Method::GET)
26880 .uri(url.as_str())
26881 .header(USER_AGENT, self.hub._user_agent.clone());
26882
26883 if let Some(token) = token.as_ref() {
26884 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26885 }
26886
26887 let request = req_builder
26888 .header(CONTENT_LENGTH, 0_u64)
26889 .body(common::to_body::<String>(None));
26890
26891 client.request(request.unwrap()).await
26892 };
26893
26894 match req_result {
26895 Err(err) => {
26896 if let common::Retry::After(d) = dlg.http_error(&err) {
26897 sleep(d).await;
26898 continue;
26899 }
26900 dlg.finished(false);
26901 return Err(common::Error::HttpError(err));
26902 }
26903 Ok(res) => {
26904 let (mut parts, body) = res.into_parts();
26905 let mut body = common::Body::new(body);
26906 if !parts.status.is_success() {
26907 let bytes = common::to_bytes(body).await.unwrap_or_default();
26908 let error = serde_json::from_str(&common::to_string(&bytes));
26909 let response = common::to_response(parts, bytes.into());
26910
26911 if let common::Retry::After(d) =
26912 dlg.http_failure(&response, error.as_ref().ok())
26913 {
26914 sleep(d).await;
26915 continue;
26916 }
26917
26918 dlg.finished(false);
26919
26920 return Err(match error {
26921 Ok(value) => common::Error::BadRequest(value),
26922 _ => common::Error::Failure(response),
26923 });
26924 }
26925 let response = {
26926 let bytes = common::to_bytes(body).await.unwrap_or_default();
26927 let encoded = common::to_string(&bytes);
26928 match serde_json::from_str(&encoded) {
26929 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26930 Err(error) => {
26931 dlg.response_json_decode_error(&encoded, &error);
26932 return Err(common::Error::JsonDecodeError(
26933 encoded.to_string(),
26934 error,
26935 ));
26936 }
26937 }
26938 };
26939
26940 dlg.finished(true);
26941 return Ok(response);
26942 }
26943 }
26944 }
26945 }
26946
26947 /// Required. The TargetProject name.
26948 ///
26949 /// Sets the *name* path property to the given value.
26950 ///
26951 /// Even though the property as already been set when instantiating this call,
26952 /// we provide this method for API completeness.
26953 pub fn name(mut self, new_value: &str) -> ProjectLocationTargetProjectGetCall<'a, C> {
26954 self._name = new_value.to_string();
26955 self
26956 }
26957 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26958 /// while executing the actual API request.
26959 ///
26960 /// ````text
26961 /// It should be used to handle progress information, and to implement a certain level of resilience.
26962 /// ````
26963 ///
26964 /// Sets the *delegate* property to the given value.
26965 pub fn delegate(
26966 mut self,
26967 new_value: &'a mut dyn common::Delegate,
26968 ) -> ProjectLocationTargetProjectGetCall<'a, C> {
26969 self._delegate = Some(new_value);
26970 self
26971 }
26972
26973 /// Set any additional parameter of the query string used in the request.
26974 /// It should be used to set parameters which are not yet available through their own
26975 /// setters.
26976 ///
26977 /// Please note that this method must not be used to set any of the known parameters
26978 /// which have their own setter method. If done anyway, the request will fail.
26979 ///
26980 /// # Additional Parameters
26981 ///
26982 /// * *$.xgafv* (query-string) - V1 error format.
26983 /// * *access_token* (query-string) - OAuth access token.
26984 /// * *alt* (query-string) - Data format for response.
26985 /// * *callback* (query-string) - JSONP
26986 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26987 /// * *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.
26988 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26989 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26990 /// * *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.
26991 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26992 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26993 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTargetProjectGetCall<'a, C>
26994 where
26995 T: AsRef<str>,
26996 {
26997 self._additional_params
26998 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26999 self
27000 }
27001
27002 /// Identifies the authorization scope for the method you are building.
27003 ///
27004 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27005 /// [`Scope::CloudPlatform`].
27006 ///
27007 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27008 /// tokens for more than one scope.
27009 ///
27010 /// Usually there is more than one suitable scope to authorize an operation, some of which may
27011 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27012 /// sufficient, a read-write scope will do as well.
27013 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTargetProjectGetCall<'a, C>
27014 where
27015 St: AsRef<str>,
27016 {
27017 self._scopes.insert(String::from(scope.as_ref()));
27018 self
27019 }
27020 /// Identifies the authorization scope(s) for the method you are building.
27021 ///
27022 /// See [`Self::add_scope()`] for details.
27023 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTargetProjectGetCall<'a, C>
27024 where
27025 I: IntoIterator<Item = St>,
27026 St: AsRef<str>,
27027 {
27028 self._scopes
27029 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27030 self
27031 }
27032
27033 /// Removes all scopes, and no default scope will be used either.
27034 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27035 /// for details).
27036 pub fn clear_scopes(mut self) -> ProjectLocationTargetProjectGetCall<'a, C> {
27037 self._scopes.clear();
27038 self
27039 }
27040}
27041
27042/// Lists TargetProjects in a given project. NOTE: TargetProject is a global resource; hence the only supported value for location is `global`.
27043///
27044/// A builder for the *locations.targetProjects.list* method supported by a *project* resource.
27045/// It is not used directly, but through a [`ProjectMethods`] instance.
27046///
27047/// # Example
27048///
27049/// Instantiate a resource method builder
27050///
27051/// ```test_harness,no_run
27052/// # extern crate hyper;
27053/// # extern crate hyper_rustls;
27054/// # extern crate google_vmmigration1 as vmmigration1;
27055/// # async fn dox() {
27056/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27057///
27058/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27059/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27060/// # .with_native_roots()
27061/// # .unwrap()
27062/// # .https_only()
27063/// # .enable_http2()
27064/// # .build();
27065///
27066/// # let executor = hyper_util::rt::TokioExecutor::new();
27067/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27068/// # secret,
27069/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27070/// # yup_oauth2::client::CustomHyperClientBuilder::from(
27071/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
27072/// # ),
27073/// # ).build().await.unwrap();
27074///
27075/// # let client = hyper_util::client::legacy::Client::builder(
27076/// # hyper_util::rt::TokioExecutor::new()
27077/// # )
27078/// # .build(
27079/// # hyper_rustls::HttpsConnectorBuilder::new()
27080/// # .with_native_roots()
27081/// # .unwrap()
27082/// # .https_or_http()
27083/// # .enable_http2()
27084/// # .build()
27085/// # );
27086/// # let mut hub = VMMigrationService::new(client, auth);
27087/// // You can configure optional parameters by calling the respective setters at will, and
27088/// // execute the final call using `doit()`.
27089/// // Values shown here are possibly random and not representative !
27090/// let result = hub.projects().locations_target_projects_list("parent")
27091/// .page_token("et")
27092/// .page_size(-77)
27093/// .order_by("dolor")
27094/// .filter("et")
27095/// .doit().await;
27096/// # }
27097/// ```
27098pub struct ProjectLocationTargetProjectListCall<'a, C>
27099where
27100 C: 'a,
27101{
27102 hub: &'a VMMigrationService<C>,
27103 _parent: String,
27104 _page_token: Option<String>,
27105 _page_size: Option<i32>,
27106 _order_by: Option<String>,
27107 _filter: Option<String>,
27108 _delegate: Option<&'a mut dyn common::Delegate>,
27109 _additional_params: HashMap<String, String>,
27110 _scopes: BTreeSet<String>,
27111}
27112
27113impl<'a, C> common::CallBuilder for ProjectLocationTargetProjectListCall<'a, C> {}
27114
27115impl<'a, C> ProjectLocationTargetProjectListCall<'a, C>
27116where
27117 C: common::Connector,
27118{
27119 /// Perform the operation you have build so far.
27120 pub async fn doit(mut self) -> common::Result<(common::Response, ListTargetProjectsResponse)> {
27121 use std::borrow::Cow;
27122 use std::io::{Read, Seek};
27123
27124 use common::{url::Params, ToParts};
27125 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27126
27127 let mut dd = common::DefaultDelegate;
27128 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27129 dlg.begin(common::MethodInfo {
27130 id: "vmmigration.projects.locations.targetProjects.list",
27131 http_method: hyper::Method::GET,
27132 });
27133
27134 for &field in [
27135 "alt",
27136 "parent",
27137 "pageToken",
27138 "pageSize",
27139 "orderBy",
27140 "filter",
27141 ]
27142 .iter()
27143 {
27144 if self._additional_params.contains_key(field) {
27145 dlg.finished(false);
27146 return Err(common::Error::FieldClash(field));
27147 }
27148 }
27149
27150 let mut params = Params::with_capacity(7 + self._additional_params.len());
27151 params.push("parent", self._parent);
27152 if let Some(value) = self._page_token.as_ref() {
27153 params.push("pageToken", value);
27154 }
27155 if let Some(value) = self._page_size.as_ref() {
27156 params.push("pageSize", value.to_string());
27157 }
27158 if let Some(value) = self._order_by.as_ref() {
27159 params.push("orderBy", value);
27160 }
27161 if let Some(value) = self._filter.as_ref() {
27162 params.push("filter", value);
27163 }
27164
27165 params.extend(self._additional_params.iter());
27166
27167 params.push("alt", "json");
27168 let mut url = self.hub._base_url.clone() + "v1/{+parent}/targetProjects";
27169 if self._scopes.is_empty() {
27170 self._scopes
27171 .insert(Scope::CloudPlatform.as_ref().to_string());
27172 }
27173
27174 #[allow(clippy::single_element_loop)]
27175 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
27176 url = params.uri_replacement(url, param_name, find_this, true);
27177 }
27178 {
27179 let to_remove = ["parent"];
27180 params.remove_params(&to_remove);
27181 }
27182
27183 let url = params.parse_with_url(&url);
27184
27185 loop {
27186 let token = match self
27187 .hub
27188 .auth
27189 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27190 .await
27191 {
27192 Ok(token) => token,
27193 Err(e) => match dlg.token(e) {
27194 Ok(token) => token,
27195 Err(e) => {
27196 dlg.finished(false);
27197 return Err(common::Error::MissingToken(e));
27198 }
27199 },
27200 };
27201 let mut req_result = {
27202 let client = &self.hub.client;
27203 dlg.pre_request();
27204 let mut req_builder = hyper::Request::builder()
27205 .method(hyper::Method::GET)
27206 .uri(url.as_str())
27207 .header(USER_AGENT, self.hub._user_agent.clone());
27208
27209 if let Some(token) = token.as_ref() {
27210 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27211 }
27212
27213 let request = req_builder
27214 .header(CONTENT_LENGTH, 0_u64)
27215 .body(common::to_body::<String>(None));
27216
27217 client.request(request.unwrap()).await
27218 };
27219
27220 match req_result {
27221 Err(err) => {
27222 if let common::Retry::After(d) = dlg.http_error(&err) {
27223 sleep(d).await;
27224 continue;
27225 }
27226 dlg.finished(false);
27227 return Err(common::Error::HttpError(err));
27228 }
27229 Ok(res) => {
27230 let (mut parts, body) = res.into_parts();
27231 let mut body = common::Body::new(body);
27232 if !parts.status.is_success() {
27233 let bytes = common::to_bytes(body).await.unwrap_or_default();
27234 let error = serde_json::from_str(&common::to_string(&bytes));
27235 let response = common::to_response(parts, bytes.into());
27236
27237 if let common::Retry::After(d) =
27238 dlg.http_failure(&response, error.as_ref().ok())
27239 {
27240 sleep(d).await;
27241 continue;
27242 }
27243
27244 dlg.finished(false);
27245
27246 return Err(match error {
27247 Ok(value) => common::Error::BadRequest(value),
27248 _ => common::Error::Failure(response),
27249 });
27250 }
27251 let response = {
27252 let bytes = common::to_bytes(body).await.unwrap_or_default();
27253 let encoded = common::to_string(&bytes);
27254 match serde_json::from_str(&encoded) {
27255 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27256 Err(error) => {
27257 dlg.response_json_decode_error(&encoded, &error);
27258 return Err(common::Error::JsonDecodeError(
27259 encoded.to_string(),
27260 error,
27261 ));
27262 }
27263 }
27264 };
27265
27266 dlg.finished(true);
27267 return Ok(response);
27268 }
27269 }
27270 }
27271 }
27272
27273 /// Required. The parent, which owns this collection of targets.
27274 ///
27275 /// Sets the *parent* path property to the given value.
27276 ///
27277 /// Even though the property as already been set when instantiating this call,
27278 /// we provide this method for API completeness.
27279 pub fn parent(mut self, new_value: &str) -> ProjectLocationTargetProjectListCall<'a, C> {
27280 self._parent = new_value.to_string();
27281 self
27282 }
27283 /// 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.
27284 ///
27285 /// Sets the *page token* query property to the given value.
27286 pub fn page_token(mut self, new_value: &str) -> ProjectLocationTargetProjectListCall<'a, C> {
27287 self._page_token = Some(new_value.to_string());
27288 self
27289 }
27290 /// 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.
27291 ///
27292 /// Sets the *page size* query property to the given value.
27293 pub fn page_size(mut self, new_value: i32) -> ProjectLocationTargetProjectListCall<'a, C> {
27294 self._page_size = Some(new_value);
27295 self
27296 }
27297 /// Optional. the order by fields for the result.
27298 ///
27299 /// Sets the *order by* query property to the given value.
27300 pub fn order_by(mut self, new_value: &str) -> ProjectLocationTargetProjectListCall<'a, C> {
27301 self._order_by = Some(new_value.to_string());
27302 self
27303 }
27304 /// Optional. The filter request.
27305 ///
27306 /// Sets the *filter* query property to the given value.
27307 pub fn filter(mut self, new_value: &str) -> ProjectLocationTargetProjectListCall<'a, C> {
27308 self._filter = Some(new_value.to_string());
27309 self
27310 }
27311 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27312 /// while executing the actual API request.
27313 ///
27314 /// ````text
27315 /// It should be used to handle progress information, and to implement a certain level of resilience.
27316 /// ````
27317 ///
27318 /// Sets the *delegate* property to the given value.
27319 pub fn delegate(
27320 mut self,
27321 new_value: &'a mut dyn common::Delegate,
27322 ) -> ProjectLocationTargetProjectListCall<'a, C> {
27323 self._delegate = Some(new_value);
27324 self
27325 }
27326
27327 /// Set any additional parameter of the query string used in the request.
27328 /// It should be used to set parameters which are not yet available through their own
27329 /// setters.
27330 ///
27331 /// Please note that this method must not be used to set any of the known parameters
27332 /// which have their own setter method. If done anyway, the request will fail.
27333 ///
27334 /// # Additional Parameters
27335 ///
27336 /// * *$.xgafv* (query-string) - V1 error format.
27337 /// * *access_token* (query-string) - OAuth access token.
27338 /// * *alt* (query-string) - Data format for response.
27339 /// * *callback* (query-string) - JSONP
27340 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27341 /// * *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.
27342 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27343 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27344 /// * *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.
27345 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27346 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27347 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTargetProjectListCall<'a, C>
27348 where
27349 T: AsRef<str>,
27350 {
27351 self._additional_params
27352 .insert(name.as_ref().to_string(), value.as_ref().to_string());
27353 self
27354 }
27355
27356 /// Identifies the authorization scope for the method you are building.
27357 ///
27358 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27359 /// [`Scope::CloudPlatform`].
27360 ///
27361 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27362 /// tokens for more than one scope.
27363 ///
27364 /// Usually there is more than one suitable scope to authorize an operation, some of which may
27365 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27366 /// sufficient, a read-write scope will do as well.
27367 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTargetProjectListCall<'a, C>
27368 where
27369 St: AsRef<str>,
27370 {
27371 self._scopes.insert(String::from(scope.as_ref()));
27372 self
27373 }
27374 /// Identifies the authorization scope(s) for the method you are building.
27375 ///
27376 /// See [`Self::add_scope()`] for details.
27377 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTargetProjectListCall<'a, C>
27378 where
27379 I: IntoIterator<Item = St>,
27380 St: AsRef<str>,
27381 {
27382 self._scopes
27383 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27384 self
27385 }
27386
27387 /// Removes all scopes, and no default scope will be used either.
27388 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27389 /// for details).
27390 pub fn clear_scopes(mut self) -> ProjectLocationTargetProjectListCall<'a, C> {
27391 self._scopes.clear();
27392 self
27393 }
27394}
27395
27396/// Updates the parameters of a single TargetProject. NOTE: TargetProject is a global resource; hence the only supported value for location is `global`.
27397///
27398/// A builder for the *locations.targetProjects.patch* method supported by a *project* resource.
27399/// It is not used directly, but through a [`ProjectMethods`] instance.
27400///
27401/// # Example
27402///
27403/// Instantiate a resource method builder
27404///
27405/// ```test_harness,no_run
27406/// # extern crate hyper;
27407/// # extern crate hyper_rustls;
27408/// # extern crate google_vmmigration1 as vmmigration1;
27409/// use vmmigration1::api::TargetProject;
27410/// # async fn dox() {
27411/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27412///
27413/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27414/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27415/// # .with_native_roots()
27416/// # .unwrap()
27417/// # .https_only()
27418/// # .enable_http2()
27419/// # .build();
27420///
27421/// # let executor = hyper_util::rt::TokioExecutor::new();
27422/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27423/// # secret,
27424/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27425/// # yup_oauth2::client::CustomHyperClientBuilder::from(
27426/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
27427/// # ),
27428/// # ).build().await.unwrap();
27429///
27430/// # let client = hyper_util::client::legacy::Client::builder(
27431/// # hyper_util::rt::TokioExecutor::new()
27432/// # )
27433/// # .build(
27434/// # hyper_rustls::HttpsConnectorBuilder::new()
27435/// # .with_native_roots()
27436/// # .unwrap()
27437/// # .https_or_http()
27438/// # .enable_http2()
27439/// # .build()
27440/// # );
27441/// # let mut hub = VMMigrationService::new(client, auth);
27442/// // As the method needs a request, you would usually fill it with the desired information
27443/// // into the respective structure. Some of the parts shown here might not be applicable !
27444/// // Values shown here are possibly random and not representative !
27445/// let mut req = TargetProject::default();
27446///
27447/// // You can configure optional parameters by calling the respective setters at will, and
27448/// // execute the final call using `doit()`.
27449/// // Values shown here are possibly random and not representative !
27450/// let result = hub.projects().locations_target_projects_patch(req, "name")
27451/// .update_mask(FieldMask::new::<&str>(&[]))
27452/// .request_id("erat")
27453/// .doit().await;
27454/// # }
27455/// ```
27456pub struct ProjectLocationTargetProjectPatchCall<'a, C>
27457where
27458 C: 'a,
27459{
27460 hub: &'a VMMigrationService<C>,
27461 _request: TargetProject,
27462 _name: String,
27463 _update_mask: Option<common::FieldMask>,
27464 _request_id: Option<String>,
27465 _delegate: Option<&'a mut dyn common::Delegate>,
27466 _additional_params: HashMap<String, String>,
27467 _scopes: BTreeSet<String>,
27468}
27469
27470impl<'a, C> common::CallBuilder for ProjectLocationTargetProjectPatchCall<'a, C> {}
27471
27472impl<'a, C> ProjectLocationTargetProjectPatchCall<'a, C>
27473where
27474 C: common::Connector,
27475{
27476 /// Perform the operation you have build so far.
27477 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
27478 use std::borrow::Cow;
27479 use std::io::{Read, Seek};
27480
27481 use common::{url::Params, ToParts};
27482 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27483
27484 let mut dd = common::DefaultDelegate;
27485 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27486 dlg.begin(common::MethodInfo {
27487 id: "vmmigration.projects.locations.targetProjects.patch",
27488 http_method: hyper::Method::PATCH,
27489 });
27490
27491 for &field in ["alt", "name", "updateMask", "requestId"].iter() {
27492 if self._additional_params.contains_key(field) {
27493 dlg.finished(false);
27494 return Err(common::Error::FieldClash(field));
27495 }
27496 }
27497
27498 let mut params = Params::with_capacity(6 + self._additional_params.len());
27499 params.push("name", self._name);
27500 if let Some(value) = self._update_mask.as_ref() {
27501 params.push("updateMask", value.to_string());
27502 }
27503 if let Some(value) = self._request_id.as_ref() {
27504 params.push("requestId", value);
27505 }
27506
27507 params.extend(self._additional_params.iter());
27508
27509 params.push("alt", "json");
27510 let mut url = self.hub._base_url.clone() + "v1/{+name}";
27511 if self._scopes.is_empty() {
27512 self._scopes
27513 .insert(Scope::CloudPlatform.as_ref().to_string());
27514 }
27515
27516 #[allow(clippy::single_element_loop)]
27517 for &(find_this, param_name) in [("{+name}", "name")].iter() {
27518 url = params.uri_replacement(url, param_name, find_this, true);
27519 }
27520 {
27521 let to_remove = ["name"];
27522 params.remove_params(&to_remove);
27523 }
27524
27525 let url = params.parse_with_url(&url);
27526
27527 let mut json_mime_type = mime::APPLICATION_JSON;
27528 let mut request_value_reader = {
27529 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
27530 common::remove_json_null_values(&mut value);
27531 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
27532 serde_json::to_writer(&mut dst, &value).unwrap();
27533 dst
27534 };
27535 let request_size = request_value_reader
27536 .seek(std::io::SeekFrom::End(0))
27537 .unwrap();
27538 request_value_reader
27539 .seek(std::io::SeekFrom::Start(0))
27540 .unwrap();
27541
27542 loop {
27543 let token = match self
27544 .hub
27545 .auth
27546 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27547 .await
27548 {
27549 Ok(token) => token,
27550 Err(e) => match dlg.token(e) {
27551 Ok(token) => token,
27552 Err(e) => {
27553 dlg.finished(false);
27554 return Err(common::Error::MissingToken(e));
27555 }
27556 },
27557 };
27558 request_value_reader
27559 .seek(std::io::SeekFrom::Start(0))
27560 .unwrap();
27561 let mut req_result = {
27562 let client = &self.hub.client;
27563 dlg.pre_request();
27564 let mut req_builder = hyper::Request::builder()
27565 .method(hyper::Method::PATCH)
27566 .uri(url.as_str())
27567 .header(USER_AGENT, self.hub._user_agent.clone());
27568
27569 if let Some(token) = token.as_ref() {
27570 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27571 }
27572
27573 let request = req_builder
27574 .header(CONTENT_TYPE, json_mime_type.to_string())
27575 .header(CONTENT_LENGTH, request_size as u64)
27576 .body(common::to_body(
27577 request_value_reader.get_ref().clone().into(),
27578 ));
27579
27580 client.request(request.unwrap()).await
27581 };
27582
27583 match req_result {
27584 Err(err) => {
27585 if let common::Retry::After(d) = dlg.http_error(&err) {
27586 sleep(d).await;
27587 continue;
27588 }
27589 dlg.finished(false);
27590 return Err(common::Error::HttpError(err));
27591 }
27592 Ok(res) => {
27593 let (mut parts, body) = res.into_parts();
27594 let mut body = common::Body::new(body);
27595 if !parts.status.is_success() {
27596 let bytes = common::to_bytes(body).await.unwrap_or_default();
27597 let error = serde_json::from_str(&common::to_string(&bytes));
27598 let response = common::to_response(parts, bytes.into());
27599
27600 if let common::Retry::After(d) =
27601 dlg.http_failure(&response, error.as_ref().ok())
27602 {
27603 sleep(d).await;
27604 continue;
27605 }
27606
27607 dlg.finished(false);
27608
27609 return Err(match error {
27610 Ok(value) => common::Error::BadRequest(value),
27611 _ => common::Error::Failure(response),
27612 });
27613 }
27614 let response = {
27615 let bytes = common::to_bytes(body).await.unwrap_or_default();
27616 let encoded = common::to_string(&bytes);
27617 match serde_json::from_str(&encoded) {
27618 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27619 Err(error) => {
27620 dlg.response_json_decode_error(&encoded, &error);
27621 return Err(common::Error::JsonDecodeError(
27622 encoded.to_string(),
27623 error,
27624 ));
27625 }
27626 }
27627 };
27628
27629 dlg.finished(true);
27630 return Ok(response);
27631 }
27632 }
27633 }
27634 }
27635
27636 ///
27637 /// Sets the *request* property to the given value.
27638 ///
27639 /// Even though the property as already been set when instantiating this call,
27640 /// we provide this method for API completeness.
27641 pub fn request(
27642 mut self,
27643 new_value: TargetProject,
27644 ) -> ProjectLocationTargetProjectPatchCall<'a, C> {
27645 self._request = new_value;
27646 self
27647 }
27648 /// Output only. The name of the target project.
27649 ///
27650 /// Sets the *name* path property to the given value.
27651 ///
27652 /// Even though the property as already been set when instantiating this call,
27653 /// we provide this method for API completeness.
27654 pub fn name(mut self, new_value: &str) -> ProjectLocationTargetProjectPatchCall<'a, C> {
27655 self._name = new_value.to_string();
27656 self
27657 }
27658 /// 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.
27659 ///
27660 /// Sets the *update mask* query property to the given value.
27661 pub fn update_mask(
27662 mut self,
27663 new_value: common::FieldMask,
27664 ) -> ProjectLocationTargetProjectPatchCall<'a, C> {
27665 self._update_mask = Some(new_value);
27666 self
27667 }
27668 /// 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).
27669 ///
27670 /// Sets the *request id* query property to the given value.
27671 pub fn request_id(mut self, new_value: &str) -> ProjectLocationTargetProjectPatchCall<'a, C> {
27672 self._request_id = Some(new_value.to_string());
27673 self
27674 }
27675 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27676 /// while executing the actual API request.
27677 ///
27678 /// ````text
27679 /// It should be used to handle progress information, and to implement a certain level of resilience.
27680 /// ````
27681 ///
27682 /// Sets the *delegate* property to the given value.
27683 pub fn delegate(
27684 mut self,
27685 new_value: &'a mut dyn common::Delegate,
27686 ) -> ProjectLocationTargetProjectPatchCall<'a, C> {
27687 self._delegate = Some(new_value);
27688 self
27689 }
27690
27691 /// Set any additional parameter of the query string used in the request.
27692 /// It should be used to set parameters which are not yet available through their own
27693 /// setters.
27694 ///
27695 /// Please note that this method must not be used to set any of the known parameters
27696 /// which have their own setter method. If done anyway, the request will fail.
27697 ///
27698 /// # Additional Parameters
27699 ///
27700 /// * *$.xgafv* (query-string) - V1 error format.
27701 /// * *access_token* (query-string) - OAuth access token.
27702 /// * *alt* (query-string) - Data format for response.
27703 /// * *callback* (query-string) - JSONP
27704 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27705 /// * *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.
27706 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27707 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27708 /// * *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.
27709 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27710 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27711 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTargetProjectPatchCall<'a, C>
27712 where
27713 T: AsRef<str>,
27714 {
27715 self._additional_params
27716 .insert(name.as_ref().to_string(), value.as_ref().to_string());
27717 self
27718 }
27719
27720 /// Identifies the authorization scope for the method you are building.
27721 ///
27722 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27723 /// [`Scope::CloudPlatform`].
27724 ///
27725 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27726 /// tokens for more than one scope.
27727 ///
27728 /// Usually there is more than one suitable scope to authorize an operation, some of which may
27729 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27730 /// sufficient, a read-write scope will do as well.
27731 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTargetProjectPatchCall<'a, C>
27732 where
27733 St: AsRef<str>,
27734 {
27735 self._scopes.insert(String::from(scope.as_ref()));
27736 self
27737 }
27738 /// Identifies the authorization scope(s) for the method you are building.
27739 ///
27740 /// See [`Self::add_scope()`] for details.
27741 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTargetProjectPatchCall<'a, C>
27742 where
27743 I: IntoIterator<Item = St>,
27744 St: AsRef<str>,
27745 {
27746 self._scopes
27747 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27748 self
27749 }
27750
27751 /// Removes all scopes, and no default scope will be used either.
27752 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27753 /// for details).
27754 pub fn clear_scopes(mut self) -> ProjectLocationTargetProjectPatchCall<'a, C> {
27755 self._scopes.clear();
27756 self
27757 }
27758}
27759
27760/// Gets information about a location.
27761///
27762/// A builder for the *locations.get* method supported by a *project* resource.
27763/// It is not used directly, but through a [`ProjectMethods`] instance.
27764///
27765/// # Example
27766///
27767/// Instantiate a resource method builder
27768///
27769/// ```test_harness,no_run
27770/// # extern crate hyper;
27771/// # extern crate hyper_rustls;
27772/// # extern crate google_vmmigration1 as vmmigration1;
27773/// # async fn dox() {
27774/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27775///
27776/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27777/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27778/// # .with_native_roots()
27779/// # .unwrap()
27780/// # .https_only()
27781/// # .enable_http2()
27782/// # .build();
27783///
27784/// # let executor = hyper_util::rt::TokioExecutor::new();
27785/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27786/// # secret,
27787/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27788/// # yup_oauth2::client::CustomHyperClientBuilder::from(
27789/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
27790/// # ),
27791/// # ).build().await.unwrap();
27792///
27793/// # let client = hyper_util::client::legacy::Client::builder(
27794/// # hyper_util::rt::TokioExecutor::new()
27795/// # )
27796/// # .build(
27797/// # hyper_rustls::HttpsConnectorBuilder::new()
27798/// # .with_native_roots()
27799/// # .unwrap()
27800/// # .https_or_http()
27801/// # .enable_http2()
27802/// # .build()
27803/// # );
27804/// # let mut hub = VMMigrationService::new(client, auth);
27805/// // You can configure optional parameters by calling the respective setters at will, and
27806/// // execute the final call using `doit()`.
27807/// // Values shown here are possibly random and not representative !
27808/// let result = hub.projects().locations_get("name")
27809/// .doit().await;
27810/// # }
27811/// ```
27812pub struct ProjectLocationGetCall<'a, C>
27813where
27814 C: 'a,
27815{
27816 hub: &'a VMMigrationService<C>,
27817 _name: String,
27818 _delegate: Option<&'a mut dyn common::Delegate>,
27819 _additional_params: HashMap<String, String>,
27820 _scopes: BTreeSet<String>,
27821}
27822
27823impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
27824
27825impl<'a, C> ProjectLocationGetCall<'a, C>
27826where
27827 C: common::Connector,
27828{
27829 /// Perform the operation you have build so far.
27830 pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
27831 use std::borrow::Cow;
27832 use std::io::{Read, Seek};
27833
27834 use common::{url::Params, ToParts};
27835 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27836
27837 let mut dd = common::DefaultDelegate;
27838 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27839 dlg.begin(common::MethodInfo {
27840 id: "vmmigration.projects.locations.get",
27841 http_method: hyper::Method::GET,
27842 });
27843
27844 for &field in ["alt", "name"].iter() {
27845 if self._additional_params.contains_key(field) {
27846 dlg.finished(false);
27847 return Err(common::Error::FieldClash(field));
27848 }
27849 }
27850
27851 let mut params = Params::with_capacity(3 + self._additional_params.len());
27852 params.push("name", self._name);
27853
27854 params.extend(self._additional_params.iter());
27855
27856 params.push("alt", "json");
27857 let mut url = self.hub._base_url.clone() + "v1/{+name}";
27858 if self._scopes.is_empty() {
27859 self._scopes
27860 .insert(Scope::CloudPlatform.as_ref().to_string());
27861 }
27862
27863 #[allow(clippy::single_element_loop)]
27864 for &(find_this, param_name) in [("{+name}", "name")].iter() {
27865 url = params.uri_replacement(url, param_name, find_this, true);
27866 }
27867 {
27868 let to_remove = ["name"];
27869 params.remove_params(&to_remove);
27870 }
27871
27872 let url = params.parse_with_url(&url);
27873
27874 loop {
27875 let token = match self
27876 .hub
27877 .auth
27878 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27879 .await
27880 {
27881 Ok(token) => token,
27882 Err(e) => match dlg.token(e) {
27883 Ok(token) => token,
27884 Err(e) => {
27885 dlg.finished(false);
27886 return Err(common::Error::MissingToken(e));
27887 }
27888 },
27889 };
27890 let mut req_result = {
27891 let client = &self.hub.client;
27892 dlg.pre_request();
27893 let mut req_builder = hyper::Request::builder()
27894 .method(hyper::Method::GET)
27895 .uri(url.as_str())
27896 .header(USER_AGENT, self.hub._user_agent.clone());
27897
27898 if let Some(token) = token.as_ref() {
27899 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27900 }
27901
27902 let request = req_builder
27903 .header(CONTENT_LENGTH, 0_u64)
27904 .body(common::to_body::<String>(None));
27905
27906 client.request(request.unwrap()).await
27907 };
27908
27909 match req_result {
27910 Err(err) => {
27911 if let common::Retry::After(d) = dlg.http_error(&err) {
27912 sleep(d).await;
27913 continue;
27914 }
27915 dlg.finished(false);
27916 return Err(common::Error::HttpError(err));
27917 }
27918 Ok(res) => {
27919 let (mut parts, body) = res.into_parts();
27920 let mut body = common::Body::new(body);
27921 if !parts.status.is_success() {
27922 let bytes = common::to_bytes(body).await.unwrap_or_default();
27923 let error = serde_json::from_str(&common::to_string(&bytes));
27924 let response = common::to_response(parts, bytes.into());
27925
27926 if let common::Retry::After(d) =
27927 dlg.http_failure(&response, error.as_ref().ok())
27928 {
27929 sleep(d).await;
27930 continue;
27931 }
27932
27933 dlg.finished(false);
27934
27935 return Err(match error {
27936 Ok(value) => common::Error::BadRequest(value),
27937 _ => common::Error::Failure(response),
27938 });
27939 }
27940 let response = {
27941 let bytes = common::to_bytes(body).await.unwrap_or_default();
27942 let encoded = common::to_string(&bytes);
27943 match serde_json::from_str(&encoded) {
27944 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27945 Err(error) => {
27946 dlg.response_json_decode_error(&encoded, &error);
27947 return Err(common::Error::JsonDecodeError(
27948 encoded.to_string(),
27949 error,
27950 ));
27951 }
27952 }
27953 };
27954
27955 dlg.finished(true);
27956 return Ok(response);
27957 }
27958 }
27959 }
27960 }
27961
27962 /// Resource name for the location.
27963 ///
27964 /// Sets the *name* path property to the given value.
27965 ///
27966 /// Even though the property as already been set when instantiating this call,
27967 /// we provide this method for API completeness.
27968 pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
27969 self._name = new_value.to_string();
27970 self
27971 }
27972 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27973 /// while executing the actual API request.
27974 ///
27975 /// ````text
27976 /// It should be used to handle progress information, and to implement a certain level of resilience.
27977 /// ````
27978 ///
27979 /// Sets the *delegate* property to the given value.
27980 pub fn delegate(
27981 mut self,
27982 new_value: &'a mut dyn common::Delegate,
27983 ) -> ProjectLocationGetCall<'a, C> {
27984 self._delegate = Some(new_value);
27985 self
27986 }
27987
27988 /// Set any additional parameter of the query string used in the request.
27989 /// It should be used to set parameters which are not yet available through their own
27990 /// setters.
27991 ///
27992 /// Please note that this method must not be used to set any of the known parameters
27993 /// which have their own setter method. If done anyway, the request will fail.
27994 ///
27995 /// # Additional Parameters
27996 ///
27997 /// * *$.xgafv* (query-string) - V1 error format.
27998 /// * *access_token* (query-string) - OAuth access token.
27999 /// * *alt* (query-string) - Data format for response.
28000 /// * *callback* (query-string) - JSONP
28001 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28002 /// * *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.
28003 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28004 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28005 /// * *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.
28006 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28007 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28008 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
28009 where
28010 T: AsRef<str>,
28011 {
28012 self._additional_params
28013 .insert(name.as_ref().to_string(), value.as_ref().to_string());
28014 self
28015 }
28016
28017 /// Identifies the authorization scope for the method you are building.
28018 ///
28019 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28020 /// [`Scope::CloudPlatform`].
28021 ///
28022 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28023 /// tokens for more than one scope.
28024 ///
28025 /// Usually there is more than one suitable scope to authorize an operation, some of which may
28026 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28027 /// sufficient, a read-write scope will do as well.
28028 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
28029 where
28030 St: AsRef<str>,
28031 {
28032 self._scopes.insert(String::from(scope.as_ref()));
28033 self
28034 }
28035 /// Identifies the authorization scope(s) for the method you are building.
28036 ///
28037 /// See [`Self::add_scope()`] for details.
28038 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
28039 where
28040 I: IntoIterator<Item = St>,
28041 St: AsRef<str>,
28042 {
28043 self._scopes
28044 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28045 self
28046 }
28047
28048 /// Removes all scopes, and no default scope will be used either.
28049 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28050 /// for details).
28051 pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
28052 self._scopes.clear();
28053 self
28054 }
28055}
28056
28057/// Lists information about the supported locations for this service.
28058///
28059/// A builder for the *locations.list* method supported by a *project* resource.
28060/// It is not used directly, but through a [`ProjectMethods`] instance.
28061///
28062/// # Example
28063///
28064/// Instantiate a resource method builder
28065///
28066/// ```test_harness,no_run
28067/// # extern crate hyper;
28068/// # extern crate hyper_rustls;
28069/// # extern crate google_vmmigration1 as vmmigration1;
28070/// # async fn dox() {
28071/// # use vmmigration1::{VMMigrationService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28072///
28073/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28074/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28075/// # .with_native_roots()
28076/// # .unwrap()
28077/// # .https_only()
28078/// # .enable_http2()
28079/// # .build();
28080///
28081/// # let executor = hyper_util::rt::TokioExecutor::new();
28082/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28083/// # secret,
28084/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28085/// # yup_oauth2::client::CustomHyperClientBuilder::from(
28086/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
28087/// # ),
28088/// # ).build().await.unwrap();
28089///
28090/// # let client = hyper_util::client::legacy::Client::builder(
28091/// # hyper_util::rt::TokioExecutor::new()
28092/// # )
28093/// # .build(
28094/// # hyper_rustls::HttpsConnectorBuilder::new()
28095/// # .with_native_roots()
28096/// # .unwrap()
28097/// # .https_or_http()
28098/// # .enable_http2()
28099/// # .build()
28100/// # );
28101/// # let mut hub = VMMigrationService::new(client, auth);
28102/// // You can configure optional parameters by calling the respective setters at will, and
28103/// // execute the final call using `doit()`.
28104/// // Values shown here are possibly random and not representative !
28105/// let result = hub.projects().locations_list("name")
28106/// .page_token("et")
28107/// .page_size(-12)
28108/// .filter("justo")
28109/// .add_extra_location_types("sea")
28110/// .doit().await;
28111/// # }
28112/// ```
28113pub struct ProjectLocationListCall<'a, C>
28114where
28115 C: 'a,
28116{
28117 hub: &'a VMMigrationService<C>,
28118 _name: String,
28119 _page_token: Option<String>,
28120 _page_size: Option<i32>,
28121 _filter: Option<String>,
28122 _extra_location_types: Vec<String>,
28123 _delegate: Option<&'a mut dyn common::Delegate>,
28124 _additional_params: HashMap<String, String>,
28125 _scopes: BTreeSet<String>,
28126}
28127
28128impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
28129
28130impl<'a, C> ProjectLocationListCall<'a, C>
28131where
28132 C: common::Connector,
28133{
28134 /// Perform the operation you have build so far.
28135 pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
28136 use std::borrow::Cow;
28137 use std::io::{Read, Seek};
28138
28139 use common::{url::Params, ToParts};
28140 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28141
28142 let mut dd = common::DefaultDelegate;
28143 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28144 dlg.begin(common::MethodInfo {
28145 id: "vmmigration.projects.locations.list",
28146 http_method: hyper::Method::GET,
28147 });
28148
28149 for &field in [
28150 "alt",
28151 "name",
28152 "pageToken",
28153 "pageSize",
28154 "filter",
28155 "extraLocationTypes",
28156 ]
28157 .iter()
28158 {
28159 if self._additional_params.contains_key(field) {
28160 dlg.finished(false);
28161 return Err(common::Error::FieldClash(field));
28162 }
28163 }
28164
28165 let mut params = Params::with_capacity(7 + self._additional_params.len());
28166 params.push("name", self._name);
28167 if let Some(value) = self._page_token.as_ref() {
28168 params.push("pageToken", value);
28169 }
28170 if let Some(value) = self._page_size.as_ref() {
28171 params.push("pageSize", value.to_string());
28172 }
28173 if let Some(value) = self._filter.as_ref() {
28174 params.push("filter", value);
28175 }
28176 if !self._extra_location_types.is_empty() {
28177 for f in self._extra_location_types.iter() {
28178 params.push("extraLocationTypes", f);
28179 }
28180 }
28181
28182 params.extend(self._additional_params.iter());
28183
28184 params.push("alt", "json");
28185 let mut url = self.hub._base_url.clone() + "v1/{+name}/locations";
28186 if self._scopes.is_empty() {
28187 self._scopes
28188 .insert(Scope::CloudPlatform.as_ref().to_string());
28189 }
28190
28191 #[allow(clippy::single_element_loop)]
28192 for &(find_this, param_name) in [("{+name}", "name")].iter() {
28193 url = params.uri_replacement(url, param_name, find_this, true);
28194 }
28195 {
28196 let to_remove = ["name"];
28197 params.remove_params(&to_remove);
28198 }
28199
28200 let url = params.parse_with_url(&url);
28201
28202 loop {
28203 let token = match self
28204 .hub
28205 .auth
28206 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28207 .await
28208 {
28209 Ok(token) => token,
28210 Err(e) => match dlg.token(e) {
28211 Ok(token) => token,
28212 Err(e) => {
28213 dlg.finished(false);
28214 return Err(common::Error::MissingToken(e));
28215 }
28216 },
28217 };
28218 let mut req_result = {
28219 let client = &self.hub.client;
28220 dlg.pre_request();
28221 let mut req_builder = hyper::Request::builder()
28222 .method(hyper::Method::GET)
28223 .uri(url.as_str())
28224 .header(USER_AGENT, self.hub._user_agent.clone());
28225
28226 if let Some(token) = token.as_ref() {
28227 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28228 }
28229
28230 let request = req_builder
28231 .header(CONTENT_LENGTH, 0_u64)
28232 .body(common::to_body::<String>(None));
28233
28234 client.request(request.unwrap()).await
28235 };
28236
28237 match req_result {
28238 Err(err) => {
28239 if let common::Retry::After(d) = dlg.http_error(&err) {
28240 sleep(d).await;
28241 continue;
28242 }
28243 dlg.finished(false);
28244 return Err(common::Error::HttpError(err));
28245 }
28246 Ok(res) => {
28247 let (mut parts, body) = res.into_parts();
28248 let mut body = common::Body::new(body);
28249 if !parts.status.is_success() {
28250 let bytes = common::to_bytes(body).await.unwrap_or_default();
28251 let error = serde_json::from_str(&common::to_string(&bytes));
28252 let response = common::to_response(parts, bytes.into());
28253
28254 if let common::Retry::After(d) =
28255 dlg.http_failure(&response, error.as_ref().ok())
28256 {
28257 sleep(d).await;
28258 continue;
28259 }
28260
28261 dlg.finished(false);
28262
28263 return Err(match error {
28264 Ok(value) => common::Error::BadRequest(value),
28265 _ => common::Error::Failure(response),
28266 });
28267 }
28268 let response = {
28269 let bytes = common::to_bytes(body).await.unwrap_or_default();
28270 let encoded = common::to_string(&bytes);
28271 match serde_json::from_str(&encoded) {
28272 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28273 Err(error) => {
28274 dlg.response_json_decode_error(&encoded, &error);
28275 return Err(common::Error::JsonDecodeError(
28276 encoded.to_string(),
28277 error,
28278 ));
28279 }
28280 }
28281 };
28282
28283 dlg.finished(true);
28284 return Ok(response);
28285 }
28286 }
28287 }
28288 }
28289
28290 /// The resource that owns the locations collection, if applicable.
28291 ///
28292 /// Sets the *name* path property to the given value.
28293 ///
28294 /// Even though the property as already been set when instantiating this call,
28295 /// we provide this method for API completeness.
28296 pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
28297 self._name = new_value.to_string();
28298 self
28299 }
28300 /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
28301 ///
28302 /// Sets the *page token* query property to the given value.
28303 pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
28304 self._page_token = Some(new_value.to_string());
28305 self
28306 }
28307 /// The maximum number of results to return. If not set, the service selects a default.
28308 ///
28309 /// Sets the *page size* query property to the given value.
28310 pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
28311 self._page_size = Some(new_value);
28312 self
28313 }
28314 /// 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).
28315 ///
28316 /// Sets the *filter* query property to the given value.
28317 pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
28318 self._filter = Some(new_value.to_string());
28319 self
28320 }
28321 /// Optional. Do not use this field. It is unsupported and is ignored unless explicitly documented otherwise. This is primarily for internal usage.
28322 ///
28323 /// Append the given value to the *extra location types* query property.
28324 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
28325 pub fn add_extra_location_types(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
28326 self._extra_location_types.push(new_value.to_string());
28327 self
28328 }
28329 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28330 /// while executing the actual API request.
28331 ///
28332 /// ````text
28333 /// It should be used to handle progress information, and to implement a certain level of resilience.
28334 /// ````
28335 ///
28336 /// Sets the *delegate* property to the given value.
28337 pub fn delegate(
28338 mut self,
28339 new_value: &'a mut dyn common::Delegate,
28340 ) -> ProjectLocationListCall<'a, C> {
28341 self._delegate = Some(new_value);
28342 self
28343 }
28344
28345 /// Set any additional parameter of the query string used in the request.
28346 /// It should be used to set parameters which are not yet available through their own
28347 /// setters.
28348 ///
28349 /// Please note that this method must not be used to set any of the known parameters
28350 /// which have their own setter method. If done anyway, the request will fail.
28351 ///
28352 /// # Additional Parameters
28353 ///
28354 /// * *$.xgafv* (query-string) - V1 error format.
28355 /// * *access_token* (query-string) - OAuth access token.
28356 /// * *alt* (query-string) - Data format for response.
28357 /// * *callback* (query-string) - JSONP
28358 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28359 /// * *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.
28360 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28361 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28362 /// * *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.
28363 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28364 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28365 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
28366 where
28367 T: AsRef<str>,
28368 {
28369 self._additional_params
28370 .insert(name.as_ref().to_string(), value.as_ref().to_string());
28371 self
28372 }
28373
28374 /// Identifies the authorization scope for the method you are building.
28375 ///
28376 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28377 /// [`Scope::CloudPlatform`].
28378 ///
28379 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28380 /// tokens for more than one scope.
28381 ///
28382 /// Usually there is more than one suitable scope to authorize an operation, some of which may
28383 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28384 /// sufficient, a read-write scope will do as well.
28385 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
28386 where
28387 St: AsRef<str>,
28388 {
28389 self._scopes.insert(String::from(scope.as_ref()));
28390 self
28391 }
28392 /// Identifies the authorization scope(s) for the method you are building.
28393 ///
28394 /// See [`Self::add_scope()`] for details.
28395 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
28396 where
28397 I: IntoIterator<Item = St>,
28398 St: AsRef<str>,
28399 {
28400 self._scopes
28401 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28402 self
28403 }
28404
28405 /// Removes all scopes, and no default scope will be used either.
28406 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28407 /// for details).
28408 pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
28409 self._scopes.clear();
28410 self
28411 }
28412}