google_replicapool1_beta2/
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    /// View and manage your data across Google Cloud Platform services
17    CloudPlatform,
18
19    /// View your data across Google Cloud Platform services
20    CloudPlatformReadOnly,
21
22    /// View and manage your Google Compute Engine resources
23    Compute,
24
25    /// View your Google Compute Engine resources
26    ComputeReadonly,
27}
28
29impl AsRef<str> for Scope {
30    fn as_ref(&self) -> &str {
31        match *self {
32            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
33            Scope::CloudPlatformReadOnly => {
34                "https://www.googleapis.com/auth/cloud-platform.read-only"
35            }
36            Scope::Compute => "https://www.googleapis.com/auth/compute",
37            Scope::ComputeReadonly => "https://www.googleapis.com/auth/compute.readonly",
38        }
39    }
40}
41
42#[allow(clippy::derivable_impls)]
43impl Default for Scope {
44    fn default() -> Scope {
45        Scope::ComputeReadonly
46    }
47}
48
49// ########
50// HUB ###
51// ######
52
53/// Central instance to access all Replicapool related resource activities
54///
55/// # Examples
56///
57/// Instantiate a new hub
58///
59/// ```test_harness,no_run
60/// extern crate hyper;
61/// extern crate hyper_rustls;
62/// extern crate google_replicapool1_beta2 as replicapool1_beta2;
63/// use replicapool1_beta2::{Result, Error};
64/// # async fn dox() {
65/// use replicapool1_beta2::{Replicapool, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
66///
67/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
68/// // `client_secret`, among other things.
69/// let secret: yup_oauth2::ApplicationSecret = Default::default();
70/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
71/// // unless you replace  `None` with the desired Flow.
72/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
73/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
74/// // retrieve them from storage.
75/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
76///     .with_native_roots()
77///     .unwrap()
78///     .https_only()
79///     .enable_http2()
80///     .build();
81///
82/// let executor = hyper_util::rt::TokioExecutor::new();
83/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
84///     secret,
85///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
86///     yup_oauth2::client::CustomHyperClientBuilder::from(
87///         hyper_util::client::legacy::Client::builder(executor).build(connector),
88///     ),
89/// ).build().await.unwrap();
90///
91/// let client = hyper_util::client::legacy::Client::builder(
92///     hyper_util::rt::TokioExecutor::new()
93/// )
94/// .build(
95///     hyper_rustls::HttpsConnectorBuilder::new()
96///         .with_native_roots()
97///         .unwrap()
98///         .https_or_http()
99///         .enable_http2()
100///         .build()
101/// );
102/// let mut hub = Replicapool::new(client, auth);
103/// // You can configure optional parameters by calling the respective setters at will, and
104/// // execute the final call using `doit()`.
105/// // Values shown here are possibly random and not representative !
106/// let result = hub.instance_group_managers().list("project", "zone")
107///              .page_token("ipsum")
108///              .max_results(39)
109///              .filter("Lorem")
110///              .doit().await;
111///
112/// match result {
113///     Err(e) => match e {
114///         // The Error enum provides details about what exactly happened.
115///         // You can also just use its `Debug`, `Display` or `Error` traits
116///          Error::HttpError(_)
117///         |Error::Io(_)
118///         |Error::MissingAPIKey
119///         |Error::MissingToken(_)
120///         |Error::Cancelled
121///         |Error::UploadSizeLimitExceeded(_, _)
122///         |Error::Failure(_)
123///         |Error::BadRequest(_)
124///         |Error::FieldClash(_)
125///         |Error::JsonDecodeError(_, _) => println!("{}", e),
126///     },
127///     Ok(res) => println!("Success: {:?}", res),
128/// }
129/// # }
130/// ```
131#[derive(Clone)]
132pub struct Replicapool<C> {
133    pub client: common::Client<C>,
134    pub auth: Box<dyn common::GetToken>,
135    _user_agent: String,
136    _base_url: String,
137    _root_url: String,
138}
139
140impl<C> common::Hub for Replicapool<C> {}
141
142impl<'a, C> Replicapool<C> {
143    pub fn new<A: 'static + common::GetToken>(
144        client: common::Client<C>,
145        auth: A,
146    ) -> Replicapool<C> {
147        Replicapool {
148            client,
149            auth: Box::new(auth),
150            _user_agent: "google-api-rust-client/7.0.0".to_string(),
151            _base_url: "https://www.googleapis.com/replicapool/v1beta2/projects/".to_string(),
152            _root_url: "https://www.googleapis.com/".to_string(),
153        }
154    }
155
156    pub fn instance_group_managers(&'a self) -> InstanceGroupManagerMethods<'a, C> {
157        InstanceGroupManagerMethods { hub: self }
158    }
159    pub fn zone_operations(&'a self) -> ZoneOperationMethods<'a, C> {
160        ZoneOperationMethods { hub: self }
161    }
162
163    /// Set the user-agent header field to use in all requests to the server.
164    /// It defaults to `google-api-rust-client/7.0.0`.
165    ///
166    /// Returns the previously set user-agent.
167    pub fn user_agent(&mut self, agent_name: String) -> String {
168        std::mem::replace(&mut self._user_agent, agent_name)
169    }
170
171    /// Set the base url to use in all requests to the server.
172    /// It defaults to `https://www.googleapis.com/replicapool/v1beta2/projects/`.
173    ///
174    /// Returns the previously set base url.
175    pub fn base_url(&mut self, new_base_url: String) -> String {
176        std::mem::replace(&mut self._base_url, new_base_url)
177    }
178
179    /// Set the root url to use in all requests to the server.
180    /// It defaults to `https://www.googleapis.com/`.
181    ///
182    /// Returns the previously set root url.
183    pub fn root_url(&mut self, new_root_url: String) -> String {
184        std::mem::replace(&mut self._root_url, new_root_url)
185    }
186}
187
188// ############
189// SCHEMAS ###
190// ##########
191/// An Instance Group Manager resource.
192///
193/// # Activities
194///
195/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
196/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
197///
198/// * [abandon instances instance group managers](InstanceGroupManagerAbandonInstanceCall) (none)
199/// * [delete instance group managers](InstanceGroupManagerDeleteCall) (none)
200/// * [delete instances instance group managers](InstanceGroupManagerDeleteInstanceCall) (none)
201/// * [get instance group managers](InstanceGroupManagerGetCall) (response)
202/// * [insert instance group managers](InstanceGroupManagerInsertCall) (request)
203/// * [list instance group managers](InstanceGroupManagerListCall) (none)
204/// * [recreate instances instance group managers](InstanceGroupManagerRecreateInstanceCall) (none)
205/// * [resize instance group managers](InstanceGroupManagerResizeCall) (none)
206/// * [set instance template instance group managers](InstanceGroupManagerSetInstanceTemplateCall) (none)
207/// * [set target pools instance group managers](InstanceGroupManagerSetTargetPoolCall) (none)
208#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
209#[serde_with::serde_as]
210#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
211pub struct InstanceGroupManager {
212    /// The autohealing policy for this managed instance group. You can specify only one value.
213    #[serde(rename = "autoHealingPolicies")]
214    pub auto_healing_policies: Option<Vec<ReplicaPoolAutoHealingPolicy>>,
215    /// The base instance name to use for instances in this group. The value must be a valid RFC1035 name. Supported characters are lowercase letters, numbers, and hyphens (-). Instances are named by appending a hyphen and a random four-character string to the base instance name.
216    #[serde(rename = "baseInstanceName")]
217    pub base_instance_name: Option<String>,
218    /// [Output only] The time the instance group manager was created, in RFC3339 text format.
219    #[serde(rename = "creationTimestamp")]
220    pub creation_timestamp: Option<String>,
221    /// [Output only] The number of instances that currently exist and are a part of this group. This includes instances that are starting but are not yet RUNNING, and instances that are in the process of being deleted or abandoned.
222    #[serde(rename = "currentSize")]
223    pub current_size: Option<i32>,
224    /// An optional textual description of the instance group manager.
225    pub description: Option<String>,
226    /// [Output only] Fingerprint of the instance group manager. This field is used for optimistic locking. An up-to-date fingerprint must be provided in order to modify the Instance Group Manager resource.
227    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
228    pub fingerprint: Option<Vec<u8>>,
229    /// [Output only] The full URL of the instance group created by the manager. This group contains all of the instances being managed, and cannot contain non-managed instances.
230    pub group: Option<String>,
231    /// [Output only] A server-assigned unique identifier for the resource.
232    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
233    pub id: Option<u64>,
234    /// The full URL to an instance template from which all new instances will be created.
235    #[serde(rename = "instanceTemplate")]
236    pub instance_template: Option<String>,
237    /// [Output only] The resource type. Always replicapool#instanceGroupManager.
238    pub kind: Option<String>,
239    /// The name of the instance group manager. Must be 1-63 characters long and comply with RFC1035. Supported characters include lowercase letters, numbers, and hyphens.
240    pub name: Option<String>,
241    /// [Output only] The fully qualified URL for this resource.
242    #[serde(rename = "selfLink")]
243    pub self_link: Option<String>,
244    /// The full URL of all target pools to which new instances in the group are added. Updating the target pool values does not affect existing instances.
245    #[serde(rename = "targetPools")]
246    pub target_pools: Option<Vec<String>>,
247    /// [Output only] The number of instances that the manager is attempting to maintain. Deleting or abandoning instances affects this number, as does resizing the group.
248    #[serde(rename = "targetSize")]
249    pub target_size: Option<i32>,
250}
251
252impl common::RequestValue for InstanceGroupManager {}
253impl common::Resource for InstanceGroupManager {}
254impl common::ResponseResult for InstanceGroupManager {}
255
256/// There is no detailed description.
257///
258/// # Activities
259///
260/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
261/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
262///
263/// * [list instance group managers](InstanceGroupManagerListCall) (response)
264#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
265#[serde_with::serde_as]
266#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
267pub struct InstanceGroupManagerList {
268    /// Unique identifier for the resource; defined by the server (output only).
269    pub id: Option<String>,
270    /// A list of instance resources.
271    pub items: Option<Vec<InstanceGroupManager>>,
272    /// Type of resource.
273    pub kind: Option<String>,
274    /// A token used to continue a truncated list request (output only).
275    #[serde(rename = "nextPageToken")]
276    pub next_page_token: Option<String>,
277    /// Server defined URL for this resource (output only).
278    #[serde(rename = "selfLink")]
279    pub self_link: Option<String>,
280}
281
282impl common::ResponseResult for InstanceGroupManagerList {}
283
284/// There is no detailed description.
285///
286/// # Activities
287///
288/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
289/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
290///
291/// * [abandon instances instance group managers](InstanceGroupManagerAbandonInstanceCall) (request)
292#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
293#[serde_with::serde_as]
294#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
295pub struct InstanceGroupManagersAbandonInstancesRequest {
296    /// The names of one or more instances to abandon. For example:
297    /// { 'instances': [ 'instance-c3po', 'instance-r2d2' ] }
298    pub instances: Option<Vec<String>>,
299}
300
301impl common::RequestValue for InstanceGroupManagersAbandonInstancesRequest {}
302
303/// There is no detailed description.
304///
305/// # Activities
306///
307/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
308/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
309///
310/// * [delete instances instance group managers](InstanceGroupManagerDeleteInstanceCall) (request)
311#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
312#[serde_with::serde_as]
313#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
314pub struct InstanceGroupManagersDeleteInstancesRequest {
315    /// Names of instances to delete.
316    ///
317    /// Example: 'instance-foo', 'instance-bar'
318    pub instances: Option<Vec<String>>,
319}
320
321impl common::RequestValue for InstanceGroupManagersDeleteInstancesRequest {}
322
323/// There is no detailed description.
324///
325/// # Activities
326///
327/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
328/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
329///
330/// * [recreate instances instance group managers](InstanceGroupManagerRecreateInstanceCall) (request)
331#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
332#[serde_with::serde_as]
333#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
334pub struct InstanceGroupManagersRecreateInstancesRequest {
335    /// The names of one or more instances to recreate. For example:
336    /// { 'instances': [ 'instance-c3po', 'instance-r2d2' ] }
337    pub instances: Option<Vec<String>>,
338}
339
340impl common::RequestValue for InstanceGroupManagersRecreateInstancesRequest {}
341
342/// There is no detailed description.
343///
344/// # Activities
345///
346/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
347/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
348///
349/// * [set instance template instance group managers](InstanceGroupManagerSetInstanceTemplateCall) (request)
350#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
351#[serde_with::serde_as]
352#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
353pub struct InstanceGroupManagersSetInstanceTemplateRequest {
354    /// The full URL to an Instance Template from which all new instances will be created.
355    #[serde(rename = "instanceTemplate")]
356    pub instance_template: Option<String>,
357}
358
359impl common::RequestValue for InstanceGroupManagersSetInstanceTemplateRequest {}
360
361/// There is no detailed description.
362///
363/// # Activities
364///
365/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
366/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
367///
368/// * [set target pools instance group managers](InstanceGroupManagerSetTargetPoolCall) (request)
369#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
370#[serde_with::serde_as]
371#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
372pub struct InstanceGroupManagersSetTargetPoolsRequest {
373    /// The current fingerprint of the Instance Group Manager resource. If this does not match the server-side fingerprint of the resource, then the request will be rejected.
374    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
375    pub fingerprint: Option<Vec<u8>>,
376    /// A list of fully-qualified URLs to existing Target Pool resources. New instances in the Instance Group Manager will be added to the specified target pools; existing instances are not affected.
377    #[serde(rename = "targetPools")]
378    pub target_pools: Option<Vec<String>>,
379}
380
381impl common::RequestValue for InstanceGroupManagersSetTargetPoolsRequest {}
382
383/// An operation resource, used to manage asynchronous API requests.
384///
385/// # Activities
386///
387/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
388/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
389///
390/// * [abandon instances instance group managers](InstanceGroupManagerAbandonInstanceCall) (response)
391/// * [delete instance group managers](InstanceGroupManagerDeleteCall) (response)
392/// * [delete instances instance group managers](InstanceGroupManagerDeleteInstanceCall) (response)
393/// * [insert instance group managers](InstanceGroupManagerInsertCall) (response)
394/// * [recreate instances instance group managers](InstanceGroupManagerRecreateInstanceCall) (response)
395/// * [resize instance group managers](InstanceGroupManagerResizeCall) (response)
396/// * [set instance template instance group managers](InstanceGroupManagerSetInstanceTemplateCall) (response)
397/// * [set target pools instance group managers](InstanceGroupManagerSetTargetPoolCall) (response)
398/// * [get zone operations](ZoneOperationGetCall) (response)
399#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
400#[serde_with::serde_as]
401#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
402pub struct Operation {
403    /// [Output only] An optional identifier specified by the client when the mutation was initiated. Must be unique for all operation resources in the project.
404    #[serde(rename = "clientOperationId")]
405    pub client_operation_id: Option<String>,
406    /// [Output Only] The time that this operation was requested, in RFC3339 text format.
407    #[serde(rename = "creationTimestamp")]
408    pub creation_timestamp: Option<String>,
409    /// [Output Only] The time that this operation was completed, in RFC3339 text format.
410    #[serde(rename = "endTime")]
411    pub end_time: Option<String>,
412    /// [Output Only] If errors occurred during processing of this operation, this field will be populated.
413    pub error: Option<OperationError>,
414    /// [Output only] If operation fails, the HTTP error message returned.
415    #[serde(rename = "httpErrorMessage")]
416    pub http_error_message: Option<String>,
417    /// [Output only] If operation fails, the HTTP error status code returned.
418    #[serde(rename = "httpErrorStatusCode")]
419    pub http_error_status_code: Option<i32>,
420    /// [Output Only] Unique identifier for the resource, generated by the server.
421    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
422    pub id: Option<u64>,
423    /// [Output Only] The time that this operation was requested, in RFC3339 text format.
424    #[serde(rename = "insertTime")]
425    pub insert_time: Option<String>,
426    /// [Output only] Type of the resource.
427    pub kind: Option<String>,
428    /// [Output Only] Name of the resource.
429    pub name: Option<String>,
430    /// [Output only] Type of the operation. Operations include insert, update, and delete.
431    #[serde(rename = "operationType")]
432    pub operation_type: Option<String>,
433    /// [Output only] An optional progress indicator that ranges from 0 to 100. There is no requirement that this be linear or support any granularity of operations. This should not be used to guess at when the operation will be complete. This number should be monotonically increasing as the operation progresses.
434    pub progress: Option<i32>,
435    /// [Output Only] URL of the region where the operation resides. Only available when performing regional operations.
436    pub region: Option<String>,
437    /// [Output Only] Server-defined fully-qualified URL for this resource.
438    #[serde(rename = "selfLink")]
439    pub self_link: Option<String>,
440    /// [Output Only] The time that this operation was started by the server, in RFC3339 text format.
441    #[serde(rename = "startTime")]
442    pub start_time: Option<String>,
443    /// [Output Only] Status of the operation.
444    pub status: Option<String>,
445    /// [Output Only] An optional textual description of the current status of the operation.
446    #[serde(rename = "statusMessage")]
447    pub status_message: Option<String>,
448    /// [Output Only] Unique target ID which identifies a particular incarnation of the target.
449    #[serde(rename = "targetId")]
450    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
451    pub target_id: Option<u64>,
452    /// [Output only] URL of the resource the operation is mutating.
453    #[serde(rename = "targetLink")]
454    pub target_link: Option<String>,
455    /// [Output Only] User who requested the operation, for example: user@example.com.
456    pub user: Option<String>,
457    /// [Output Only] If there are issues with this operation, a warning is returned.
458    pub warnings: Option<Vec<OperationWarnings>>,
459    /// [Output Only] URL of the zone where the operation resides. Only available when performing per-zone operations.
460    pub zone: Option<String>,
461}
462
463impl common::ResponseResult for Operation {}
464
465/// There is no detailed description.
466///
467/// # Activities
468///
469/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
470/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
471///
472/// * [list zone operations](ZoneOperationListCall) (response)
473#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
474#[serde_with::serde_as]
475#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
476pub struct OperationList {
477    /// Unique identifier for the resource; defined by the server (output only).
478    pub id: Option<String>,
479    /// The operation resources.
480    pub items: Option<Vec<Operation>>,
481    /// Type of resource.
482    pub kind: Option<String>,
483    /// A token used to continue a truncated list request (output only).
484    #[serde(rename = "nextPageToken")]
485    pub next_page_token: Option<String>,
486    /// Server defined URL for this resource (output only).
487    #[serde(rename = "selfLink")]
488    pub self_link: Option<String>,
489}
490
491impl common::ResponseResult for OperationList {}
492
493/// There is no detailed description.
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 ReplicaPoolAutoHealingPolicy {
501    /// The action to perform when an instance becomes unhealthy. Possible values are RECREATE or REBOOT. RECREATE replaces an unhealthy instance with a new instance that is based on the instance template for this managed instance group. REBOOT performs a soft reboot on an instance. If the instance cannot reboot, the instance performs a hard restart.
502    #[serde(rename = "actionType")]
503    pub action_type: Option<String>,
504    /// The URL for the HealthCheck that signals autohealing.
505    #[serde(rename = "healthCheck")]
506    pub health_check: Option<String>,
507}
508
509impl common::Part for ReplicaPoolAutoHealingPolicy {}
510
511/// [Output Only] If errors occurred during processing of this operation, this field will be populated.
512///
513/// This type is not used in any activity, and only used as *part* of another schema.
514///
515#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
516#[serde_with::serde_as]
517#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
518pub struct OperationError {
519    /// [Output Only] The array of errors encountered while processing this operation.
520    pub errors: Option<Vec<OperationErrorErrors>>,
521}
522
523impl common::NestedType for OperationError {}
524impl common::Part for OperationError {}
525
526/// [Output Only] The array of errors encountered while processing this operation.
527///
528/// This type is not used in any activity, and only used as *part* of another schema.
529///
530#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
531#[serde_with::serde_as]
532#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
533pub struct OperationErrorErrors {
534    /// [Output Only] The error type identifier for this error.
535    pub code: Option<String>,
536    /// [Output Only] Indicates the field in the request which caused the error. This property is optional.
537    pub location: Option<String>,
538    /// [Output Only] An optional, human-readable error message.
539    pub message: Option<String>,
540}
541
542impl common::NestedType for OperationErrorErrors {}
543impl common::Part for OperationErrorErrors {}
544
545/// [Output Only] If there are issues with this operation, a warning is returned.
546///
547/// This type is not used in any activity, and only used as *part* of another schema.
548///
549#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
550#[serde_with::serde_as]
551#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
552pub struct OperationWarnings {
553    /// [Output only] The warning type identifier for this warning.
554    pub code: Option<String>,
555    /// [Output only] Metadata for this warning in key:value format.
556    pub data: Option<Vec<OperationWarningsData>>,
557    /// [Output only] Optional human-readable details for this warning.
558    pub message: Option<String>,
559}
560
561impl common::NestedType for OperationWarnings {}
562impl common::Part for OperationWarnings {}
563
564/// [Output only] Metadata for this warning in key:value format.
565///
566/// This type is not used in any activity, and only used as *part* of another schema.
567///
568#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
569#[serde_with::serde_as]
570#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
571pub struct OperationWarningsData {
572    /// [Output Only] Metadata key for this warning.
573    pub key: Option<String>,
574    /// [Output Only] Metadata value for this warning.
575    pub value: Option<String>,
576}
577
578impl common::NestedType for OperationWarningsData {}
579impl common::Part for OperationWarningsData {}
580
581// ###################
582// MethodBuilders ###
583// #################
584
585/// A builder providing access to all methods supported on *instanceGroupManager* resources.
586/// It is not used directly, but through the [`Replicapool`] hub.
587///
588/// # Example
589///
590/// Instantiate a resource builder
591///
592/// ```test_harness,no_run
593/// extern crate hyper;
594/// extern crate hyper_rustls;
595/// extern crate google_replicapool1_beta2 as replicapool1_beta2;
596///
597/// # async fn dox() {
598/// use replicapool1_beta2::{Replicapool, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
599///
600/// let secret: yup_oauth2::ApplicationSecret = Default::default();
601/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
602///     .with_native_roots()
603///     .unwrap()
604///     .https_only()
605///     .enable_http2()
606///     .build();
607///
608/// let executor = hyper_util::rt::TokioExecutor::new();
609/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
610///     secret,
611///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
612///     yup_oauth2::client::CustomHyperClientBuilder::from(
613///         hyper_util::client::legacy::Client::builder(executor).build(connector),
614///     ),
615/// ).build().await.unwrap();
616///
617/// let client = hyper_util::client::legacy::Client::builder(
618///     hyper_util::rt::TokioExecutor::new()
619/// )
620/// .build(
621///     hyper_rustls::HttpsConnectorBuilder::new()
622///         .with_native_roots()
623///         .unwrap()
624///         .https_or_http()
625///         .enable_http2()
626///         .build()
627/// );
628/// let mut hub = Replicapool::new(client, auth);
629/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
630/// // like `abandon_instances(...)`, `delete(...)`, `delete_instances(...)`, `get(...)`, `insert(...)`, `list(...)`, `recreate_instances(...)`, `resize(...)`, `set_instance_template(...)` and `set_target_pools(...)`
631/// // to build up your call.
632/// let rb = hub.instance_group_managers();
633/// # }
634/// ```
635pub struct InstanceGroupManagerMethods<'a, C>
636where
637    C: 'a,
638{
639    hub: &'a Replicapool<C>,
640}
641
642impl<'a, C> common::MethodsBuilder for InstanceGroupManagerMethods<'a, C> {}
643
644impl<'a, C> InstanceGroupManagerMethods<'a, C> {
645    /// Create a builder to help you perform the following task:
646    ///
647    /// Removes the specified instances from the managed instance group, and from any target pools of which they were members, without deleting the instances.
648    ///
649    /// # Arguments
650    ///
651    /// * `request` - No description provided.
652    /// * `project` - The Google Developers Console project name.
653    /// * `zone` - The name of the zone in which the instance group manager resides.
654    /// * `instanceGroupManager` - The name of the instance group manager.
655    pub fn abandon_instances(
656        &self,
657        request: InstanceGroupManagersAbandonInstancesRequest,
658        project: &str,
659        zone: &str,
660        instance_group_manager: &str,
661    ) -> InstanceGroupManagerAbandonInstanceCall<'a, C> {
662        InstanceGroupManagerAbandonInstanceCall {
663            hub: self.hub,
664            _request: request,
665            _project: project.to_string(),
666            _zone: zone.to_string(),
667            _instance_group_manager: instance_group_manager.to_string(),
668            _delegate: Default::default(),
669            _additional_params: Default::default(),
670            _scopes: Default::default(),
671        }
672    }
673
674    /// Create a builder to help you perform the following task:
675    ///
676    /// Deletes the instance group manager and all instances contained within. If you'd like to delete the manager without deleting the instances, you must first abandon the instances to remove them from the group.
677    ///
678    /// # Arguments
679    ///
680    /// * `project` - The Google Developers Console project name.
681    /// * `zone` - The name of the zone in which the instance group manager resides.
682    /// * `instanceGroupManager` - Name of the Instance Group Manager resource to delete.
683    pub fn delete(
684        &self,
685        project: &str,
686        zone: &str,
687        instance_group_manager: &str,
688    ) -> InstanceGroupManagerDeleteCall<'a, C> {
689        InstanceGroupManagerDeleteCall {
690            hub: self.hub,
691            _project: project.to_string(),
692            _zone: zone.to_string(),
693            _instance_group_manager: instance_group_manager.to_string(),
694            _delegate: Default::default(),
695            _additional_params: Default::default(),
696            _scopes: Default::default(),
697        }
698    }
699
700    /// Create a builder to help you perform the following task:
701    ///
702    /// Deletes the specified instances. The instances are deleted, then removed from the instance group and any target pools of which they were a member. The targetSize of the instance group manager is reduced by the number of instances deleted.
703    ///
704    /// # Arguments
705    ///
706    /// * `request` - No description provided.
707    /// * `project` - The Google Developers Console project name.
708    /// * `zone` - The name of the zone in which the instance group manager resides.
709    /// * `instanceGroupManager` - The name of the instance group manager.
710    pub fn delete_instances(
711        &self,
712        request: InstanceGroupManagersDeleteInstancesRequest,
713        project: &str,
714        zone: &str,
715        instance_group_manager: &str,
716    ) -> InstanceGroupManagerDeleteInstanceCall<'a, C> {
717        InstanceGroupManagerDeleteInstanceCall {
718            hub: self.hub,
719            _request: request,
720            _project: project.to_string(),
721            _zone: zone.to_string(),
722            _instance_group_manager: instance_group_manager.to_string(),
723            _delegate: Default::default(),
724            _additional_params: Default::default(),
725            _scopes: Default::default(),
726        }
727    }
728
729    /// Create a builder to help you perform the following task:
730    ///
731    /// Returns the specified Instance Group Manager resource.
732    ///
733    /// # Arguments
734    ///
735    /// * `project` - The Google Developers Console project name.
736    /// * `zone` - The name of the zone in which the instance group manager resides.
737    /// * `instanceGroupManager` - Name of the instance resource to return.
738    pub fn get(
739        &self,
740        project: &str,
741        zone: &str,
742        instance_group_manager: &str,
743    ) -> InstanceGroupManagerGetCall<'a, C> {
744        InstanceGroupManagerGetCall {
745            hub: self.hub,
746            _project: project.to_string(),
747            _zone: zone.to_string(),
748            _instance_group_manager: instance_group_manager.to_string(),
749            _delegate: Default::default(),
750            _additional_params: Default::default(),
751            _scopes: Default::default(),
752        }
753    }
754
755    /// Create a builder to help you perform the following task:
756    ///
757    /// Creates an instance group manager, as well as the instance group and the specified number of instances.
758    ///
759    /// # Arguments
760    ///
761    /// * `request` - No description provided.
762    /// * `project` - The Google Developers Console project name.
763    /// * `zone` - The name of the zone in which the instance group manager resides.
764    /// * `size` - Number of instances that should exist.
765    pub fn insert(
766        &self,
767        request: InstanceGroupManager,
768        project: &str,
769        zone: &str,
770        size: i32,
771    ) -> InstanceGroupManagerInsertCall<'a, C> {
772        InstanceGroupManagerInsertCall {
773            hub: self.hub,
774            _request: request,
775            _project: project.to_string(),
776            _zone: zone.to_string(),
777            _size: size,
778            _delegate: Default::default(),
779            _additional_params: Default::default(),
780            _scopes: Default::default(),
781        }
782    }
783
784    /// Create a builder to help you perform the following task:
785    ///
786    /// Retrieves the list of Instance Group Manager resources contained within the specified zone.
787    ///
788    /// # Arguments
789    ///
790    /// * `project` - The Google Developers Console project name.
791    /// * `zone` - The name of the zone in which the instance group manager resides.
792    pub fn list(&self, project: &str, zone: &str) -> InstanceGroupManagerListCall<'a, C> {
793        InstanceGroupManagerListCall {
794            hub: self.hub,
795            _project: project.to_string(),
796            _zone: zone.to_string(),
797            _page_token: Default::default(),
798            _max_results: Default::default(),
799            _filter: Default::default(),
800            _delegate: Default::default(),
801            _additional_params: Default::default(),
802            _scopes: Default::default(),
803        }
804    }
805
806    /// Create a builder to help you perform the following task:
807    ///
808    /// Recreates the specified instances. The instances are deleted, then recreated using the instance group manager's current instance template.
809    ///
810    /// # Arguments
811    ///
812    /// * `request` - No description provided.
813    /// * `project` - The Google Developers Console project name.
814    /// * `zone` - The name of the zone in which the instance group manager resides.
815    /// * `instanceGroupManager` - The name of the instance group manager.
816    pub fn recreate_instances(
817        &self,
818        request: InstanceGroupManagersRecreateInstancesRequest,
819        project: &str,
820        zone: &str,
821        instance_group_manager: &str,
822    ) -> InstanceGroupManagerRecreateInstanceCall<'a, C> {
823        InstanceGroupManagerRecreateInstanceCall {
824            hub: self.hub,
825            _request: request,
826            _project: project.to_string(),
827            _zone: zone.to_string(),
828            _instance_group_manager: instance_group_manager.to_string(),
829            _delegate: Default::default(),
830            _additional_params: Default::default(),
831            _scopes: Default::default(),
832        }
833    }
834
835    /// Create a builder to help you perform the following task:
836    ///
837    /// Resizes the managed instance group up or down. If resized up, new instances are created using the current instance template. If resized down, instances are removed in the order outlined in Resizing a managed instance group.
838    ///
839    /// # Arguments
840    ///
841    /// * `project` - The Google Developers Console project name.
842    /// * `zone` - The name of the zone in which the instance group manager resides.
843    /// * `instanceGroupManager` - The name of the instance group manager.
844    /// * `size` - Number of instances that should exist in this Instance Group Manager.
845    pub fn resize(
846        &self,
847        project: &str,
848        zone: &str,
849        instance_group_manager: &str,
850        size: i32,
851    ) -> InstanceGroupManagerResizeCall<'a, C> {
852        InstanceGroupManagerResizeCall {
853            hub: self.hub,
854            _project: project.to_string(),
855            _zone: zone.to_string(),
856            _instance_group_manager: instance_group_manager.to_string(),
857            _size: size,
858            _delegate: Default::default(),
859            _additional_params: Default::default(),
860            _scopes: Default::default(),
861        }
862    }
863
864    /// Create a builder to help you perform the following task:
865    ///
866    /// Sets the instance template to use when creating new instances in this group. Existing instances are not affected.
867    ///
868    /// # Arguments
869    ///
870    /// * `request` - No description provided.
871    /// * `project` - The Google Developers Console project name.
872    /// * `zone` - The name of the zone in which the instance group manager resides.
873    /// * `instanceGroupManager` - The name of the instance group manager.
874    pub fn set_instance_template(
875        &self,
876        request: InstanceGroupManagersSetInstanceTemplateRequest,
877        project: &str,
878        zone: &str,
879        instance_group_manager: &str,
880    ) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C> {
881        InstanceGroupManagerSetInstanceTemplateCall {
882            hub: self.hub,
883            _request: request,
884            _project: project.to_string(),
885            _zone: zone.to_string(),
886            _instance_group_manager: instance_group_manager.to_string(),
887            _delegate: Default::default(),
888            _additional_params: Default::default(),
889            _scopes: Default::default(),
890        }
891    }
892
893    /// Create a builder to help you perform the following task:
894    ///
895    /// Modifies the target pools to which all new instances in this group are assigned. Existing instances in the group are not affected.
896    ///
897    /// # Arguments
898    ///
899    /// * `request` - No description provided.
900    /// * `project` - The Google Developers Console project name.
901    /// * `zone` - The name of the zone in which the instance group manager resides.
902    /// * `instanceGroupManager` - The name of the instance group manager.
903    pub fn set_target_pools(
904        &self,
905        request: InstanceGroupManagersSetTargetPoolsRequest,
906        project: &str,
907        zone: &str,
908        instance_group_manager: &str,
909    ) -> InstanceGroupManagerSetTargetPoolCall<'a, C> {
910        InstanceGroupManagerSetTargetPoolCall {
911            hub: self.hub,
912            _request: request,
913            _project: project.to_string(),
914            _zone: zone.to_string(),
915            _instance_group_manager: instance_group_manager.to_string(),
916            _delegate: Default::default(),
917            _additional_params: Default::default(),
918            _scopes: Default::default(),
919        }
920    }
921}
922
923/// A builder providing access to all methods supported on *zoneOperation* resources.
924/// It is not used directly, but through the [`Replicapool`] hub.
925///
926/// # Example
927///
928/// Instantiate a resource builder
929///
930/// ```test_harness,no_run
931/// extern crate hyper;
932/// extern crate hyper_rustls;
933/// extern crate google_replicapool1_beta2 as replicapool1_beta2;
934///
935/// # async fn dox() {
936/// use replicapool1_beta2::{Replicapool, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
937///
938/// let secret: yup_oauth2::ApplicationSecret = Default::default();
939/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
940///     .with_native_roots()
941///     .unwrap()
942///     .https_only()
943///     .enable_http2()
944///     .build();
945///
946/// let executor = hyper_util::rt::TokioExecutor::new();
947/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
948///     secret,
949///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
950///     yup_oauth2::client::CustomHyperClientBuilder::from(
951///         hyper_util::client::legacy::Client::builder(executor).build(connector),
952///     ),
953/// ).build().await.unwrap();
954///
955/// let client = hyper_util::client::legacy::Client::builder(
956///     hyper_util::rt::TokioExecutor::new()
957/// )
958/// .build(
959///     hyper_rustls::HttpsConnectorBuilder::new()
960///         .with_native_roots()
961///         .unwrap()
962///         .https_or_http()
963///         .enable_http2()
964///         .build()
965/// );
966/// let mut hub = Replicapool::new(client, auth);
967/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
968/// // like `get(...)` and `list(...)`
969/// // to build up your call.
970/// let rb = hub.zone_operations();
971/// # }
972/// ```
973pub struct ZoneOperationMethods<'a, C>
974where
975    C: 'a,
976{
977    hub: &'a Replicapool<C>,
978}
979
980impl<'a, C> common::MethodsBuilder for ZoneOperationMethods<'a, C> {}
981
982impl<'a, C> ZoneOperationMethods<'a, C> {
983    /// Create a builder to help you perform the following task:
984    ///
985    /// Retrieves the specified zone-specific operation resource.
986    ///
987    /// # Arguments
988    ///
989    /// * `project` - Name of the project scoping this request.
990    /// * `zone` - Name of the zone scoping this request.
991    /// * `operation` - Name of the operation resource to return.
992    pub fn get(&self, project: &str, zone: &str, operation: &str) -> ZoneOperationGetCall<'a, C> {
993        ZoneOperationGetCall {
994            hub: self.hub,
995            _project: project.to_string(),
996            _zone: zone.to_string(),
997            _operation: operation.to_string(),
998            _delegate: Default::default(),
999            _additional_params: Default::default(),
1000            _scopes: Default::default(),
1001        }
1002    }
1003
1004    /// Create a builder to help you perform the following task:
1005    ///
1006    /// Retrieves the list of operation resources contained within the specified zone.
1007    ///
1008    /// # Arguments
1009    ///
1010    /// * `project` - Name of the project scoping this request.
1011    /// * `zone` - Name of the zone scoping this request.
1012    pub fn list(&self, project: &str, zone: &str) -> ZoneOperationListCall<'a, C> {
1013        ZoneOperationListCall {
1014            hub: self.hub,
1015            _project: project.to_string(),
1016            _zone: zone.to_string(),
1017            _page_token: Default::default(),
1018            _max_results: Default::default(),
1019            _filter: Default::default(),
1020            _delegate: Default::default(),
1021            _additional_params: Default::default(),
1022            _scopes: Default::default(),
1023        }
1024    }
1025}
1026
1027// ###################
1028// CallBuilders   ###
1029// #################
1030
1031/// Removes the specified instances from the managed instance group, and from any target pools of which they were members, without deleting the instances.
1032///
1033/// A builder for the *abandonInstances* method supported by a *instanceGroupManager* resource.
1034/// It is not used directly, but through a [`InstanceGroupManagerMethods`] instance.
1035///
1036/// # Example
1037///
1038/// Instantiate a resource method builder
1039///
1040/// ```test_harness,no_run
1041/// # extern crate hyper;
1042/// # extern crate hyper_rustls;
1043/// # extern crate google_replicapool1_beta2 as replicapool1_beta2;
1044/// use replicapool1_beta2::api::InstanceGroupManagersAbandonInstancesRequest;
1045/// # async fn dox() {
1046/// # use replicapool1_beta2::{Replicapool, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1047///
1048/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1049/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1050/// #     .with_native_roots()
1051/// #     .unwrap()
1052/// #     .https_only()
1053/// #     .enable_http2()
1054/// #     .build();
1055///
1056/// # let executor = hyper_util::rt::TokioExecutor::new();
1057/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1058/// #     secret,
1059/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1060/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1061/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1062/// #     ),
1063/// # ).build().await.unwrap();
1064///
1065/// # let client = hyper_util::client::legacy::Client::builder(
1066/// #     hyper_util::rt::TokioExecutor::new()
1067/// # )
1068/// # .build(
1069/// #     hyper_rustls::HttpsConnectorBuilder::new()
1070/// #         .with_native_roots()
1071/// #         .unwrap()
1072/// #         .https_or_http()
1073/// #         .enable_http2()
1074/// #         .build()
1075/// # );
1076/// # let mut hub = Replicapool::new(client, auth);
1077/// // As the method needs a request, you would usually fill it with the desired information
1078/// // into the respective structure. Some of the parts shown here might not be applicable !
1079/// // Values shown here are possibly random and not representative !
1080/// let mut req = InstanceGroupManagersAbandonInstancesRequest::default();
1081///
1082/// // You can configure optional parameters by calling the respective setters at will, and
1083/// // execute the final call using `doit()`.
1084/// // Values shown here are possibly random and not representative !
1085/// let result = hub.instance_group_managers().abandon_instances(req, "project", "zone", "instanceGroupManager")
1086///              .doit().await;
1087/// # }
1088/// ```
1089pub struct InstanceGroupManagerAbandonInstanceCall<'a, C>
1090where
1091    C: 'a,
1092{
1093    hub: &'a Replicapool<C>,
1094    _request: InstanceGroupManagersAbandonInstancesRequest,
1095    _project: String,
1096    _zone: String,
1097    _instance_group_manager: String,
1098    _delegate: Option<&'a mut dyn common::Delegate>,
1099    _additional_params: HashMap<String, String>,
1100    _scopes: BTreeSet<String>,
1101}
1102
1103impl<'a, C> common::CallBuilder for InstanceGroupManagerAbandonInstanceCall<'a, C> {}
1104
1105impl<'a, C> InstanceGroupManagerAbandonInstanceCall<'a, C>
1106where
1107    C: common::Connector,
1108{
1109    /// Perform the operation you have build so far.
1110    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1111        use std::borrow::Cow;
1112        use std::io::{Read, Seek};
1113
1114        use common::{url::Params, ToParts};
1115        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1116
1117        let mut dd = common::DefaultDelegate;
1118        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1119        dlg.begin(common::MethodInfo {
1120            id: "replicapool.instanceGroupManagers.abandonInstances",
1121            http_method: hyper::Method::POST,
1122        });
1123
1124        for &field in ["alt", "project", "zone", "instanceGroupManager"].iter() {
1125            if self._additional_params.contains_key(field) {
1126                dlg.finished(false);
1127                return Err(common::Error::FieldClash(field));
1128            }
1129        }
1130
1131        let mut params = Params::with_capacity(6 + self._additional_params.len());
1132        params.push("project", self._project);
1133        params.push("zone", self._zone);
1134        params.push("instanceGroupManager", self._instance_group_manager);
1135
1136        params.extend(self._additional_params.iter());
1137
1138        params.push("alt", "json");
1139        let mut url = self.hub._base_url.clone() + "{project}/zones/{zone}/instanceGroupManagers/{instanceGroupManager}/abandonInstances";
1140        if self._scopes.is_empty() {
1141            self._scopes
1142                .insert(Scope::CloudPlatform.as_ref().to_string());
1143        }
1144
1145        #[allow(clippy::single_element_loop)]
1146        for &(find_this, param_name) in [
1147            ("{project}", "project"),
1148            ("{zone}", "zone"),
1149            ("{instanceGroupManager}", "instanceGroupManager"),
1150        ]
1151        .iter()
1152        {
1153            url = params.uri_replacement(url, param_name, find_this, false);
1154        }
1155        {
1156            let to_remove = ["instanceGroupManager", "zone", "project"];
1157            params.remove_params(&to_remove);
1158        }
1159
1160        let url = params.parse_with_url(&url);
1161
1162        let mut json_mime_type = mime::APPLICATION_JSON;
1163        let mut request_value_reader = {
1164            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1165            common::remove_json_null_values(&mut value);
1166            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1167            serde_json::to_writer(&mut dst, &value).unwrap();
1168            dst
1169        };
1170        let request_size = request_value_reader
1171            .seek(std::io::SeekFrom::End(0))
1172            .unwrap();
1173        request_value_reader
1174            .seek(std::io::SeekFrom::Start(0))
1175            .unwrap();
1176
1177        loop {
1178            let token = match self
1179                .hub
1180                .auth
1181                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1182                .await
1183            {
1184                Ok(token) => token,
1185                Err(e) => match dlg.token(e) {
1186                    Ok(token) => token,
1187                    Err(e) => {
1188                        dlg.finished(false);
1189                        return Err(common::Error::MissingToken(e));
1190                    }
1191                },
1192            };
1193            request_value_reader
1194                .seek(std::io::SeekFrom::Start(0))
1195                .unwrap();
1196            let mut req_result = {
1197                let client = &self.hub.client;
1198                dlg.pre_request();
1199                let mut req_builder = hyper::Request::builder()
1200                    .method(hyper::Method::POST)
1201                    .uri(url.as_str())
1202                    .header(USER_AGENT, self.hub._user_agent.clone());
1203
1204                if let Some(token) = token.as_ref() {
1205                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1206                }
1207
1208                let request = req_builder
1209                    .header(CONTENT_TYPE, json_mime_type.to_string())
1210                    .header(CONTENT_LENGTH, request_size as u64)
1211                    .body(common::to_body(
1212                        request_value_reader.get_ref().clone().into(),
1213                    ));
1214
1215                client.request(request.unwrap()).await
1216            };
1217
1218            match req_result {
1219                Err(err) => {
1220                    if let common::Retry::After(d) = dlg.http_error(&err) {
1221                        sleep(d).await;
1222                        continue;
1223                    }
1224                    dlg.finished(false);
1225                    return Err(common::Error::HttpError(err));
1226                }
1227                Ok(res) => {
1228                    let (mut parts, body) = res.into_parts();
1229                    let mut body = common::Body::new(body);
1230                    if !parts.status.is_success() {
1231                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1232                        let error = serde_json::from_str(&common::to_string(&bytes));
1233                        let response = common::to_response(parts, bytes.into());
1234
1235                        if let common::Retry::After(d) =
1236                            dlg.http_failure(&response, error.as_ref().ok())
1237                        {
1238                            sleep(d).await;
1239                            continue;
1240                        }
1241
1242                        dlg.finished(false);
1243
1244                        return Err(match error {
1245                            Ok(value) => common::Error::BadRequest(value),
1246                            _ => common::Error::Failure(response),
1247                        });
1248                    }
1249                    let response = {
1250                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1251                        let encoded = common::to_string(&bytes);
1252                        match serde_json::from_str(&encoded) {
1253                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1254                            Err(error) => {
1255                                dlg.response_json_decode_error(&encoded, &error);
1256                                return Err(common::Error::JsonDecodeError(
1257                                    encoded.to_string(),
1258                                    error,
1259                                ));
1260                            }
1261                        }
1262                    };
1263
1264                    dlg.finished(true);
1265                    return Ok(response);
1266                }
1267            }
1268        }
1269    }
1270
1271    ///
1272    /// Sets the *request* property to the given value.
1273    ///
1274    /// Even though the property as already been set when instantiating this call,
1275    /// we provide this method for API completeness.
1276    pub fn request(
1277        mut self,
1278        new_value: InstanceGroupManagersAbandonInstancesRequest,
1279    ) -> InstanceGroupManagerAbandonInstanceCall<'a, C> {
1280        self._request = new_value;
1281        self
1282    }
1283    /// The Google Developers Console project name.
1284    ///
1285    /// Sets the *project* path property to the given value.
1286    ///
1287    /// Even though the property as already been set when instantiating this call,
1288    /// we provide this method for API completeness.
1289    pub fn project(mut self, new_value: &str) -> InstanceGroupManagerAbandonInstanceCall<'a, C> {
1290        self._project = new_value.to_string();
1291        self
1292    }
1293    /// The name of the zone in which the instance group manager resides.
1294    ///
1295    /// Sets the *zone* path property to the given value.
1296    ///
1297    /// Even though the property as already been set when instantiating this call,
1298    /// we provide this method for API completeness.
1299    pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerAbandonInstanceCall<'a, C> {
1300        self._zone = new_value.to_string();
1301        self
1302    }
1303    /// The name of the instance group manager.
1304    ///
1305    /// Sets the *instance group manager* path property to the given value.
1306    ///
1307    /// Even though the property as already been set when instantiating this call,
1308    /// we provide this method for API completeness.
1309    pub fn instance_group_manager(
1310        mut self,
1311        new_value: &str,
1312    ) -> InstanceGroupManagerAbandonInstanceCall<'a, C> {
1313        self._instance_group_manager = new_value.to_string();
1314        self
1315    }
1316    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1317    /// while executing the actual API request.
1318    ///
1319    /// ````text
1320    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1321    /// ````
1322    ///
1323    /// Sets the *delegate* property to the given value.
1324    pub fn delegate(
1325        mut self,
1326        new_value: &'a mut dyn common::Delegate,
1327    ) -> InstanceGroupManagerAbandonInstanceCall<'a, C> {
1328        self._delegate = Some(new_value);
1329        self
1330    }
1331
1332    /// Set any additional parameter of the query string used in the request.
1333    /// It should be used to set parameters which are not yet available through their own
1334    /// setters.
1335    ///
1336    /// Please note that this method must not be used to set any of the known parameters
1337    /// which have their own setter method. If done anyway, the request will fail.
1338    ///
1339    /// # Additional Parameters
1340    ///
1341    /// * *alt* (query-string) - Data format for the response.
1342    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1343    /// * *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.
1344    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1345    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1346    /// * *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. Overrides userIp if both are provided.
1347    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1348    pub fn param<T>(mut self, name: T, value: T) -> InstanceGroupManagerAbandonInstanceCall<'a, C>
1349    where
1350        T: AsRef<str>,
1351    {
1352        self._additional_params
1353            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1354        self
1355    }
1356
1357    /// Identifies the authorization scope for the method you are building.
1358    ///
1359    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1360    /// [`Scope::CloudPlatform`].
1361    ///
1362    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1363    /// tokens for more than one scope.
1364    ///
1365    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1366    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1367    /// sufficient, a read-write scope will do as well.
1368    pub fn add_scope<St>(mut self, scope: St) -> InstanceGroupManagerAbandonInstanceCall<'a, C>
1369    where
1370        St: AsRef<str>,
1371    {
1372        self._scopes.insert(String::from(scope.as_ref()));
1373        self
1374    }
1375    /// Identifies the authorization scope(s) for the method you are building.
1376    ///
1377    /// See [`Self::add_scope()`] for details.
1378    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceGroupManagerAbandonInstanceCall<'a, C>
1379    where
1380        I: IntoIterator<Item = St>,
1381        St: AsRef<str>,
1382    {
1383        self._scopes
1384            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1385        self
1386    }
1387
1388    /// Removes all scopes, and no default scope will be used either.
1389    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1390    /// for details).
1391    pub fn clear_scopes(mut self) -> InstanceGroupManagerAbandonInstanceCall<'a, C> {
1392        self._scopes.clear();
1393        self
1394    }
1395}
1396
1397/// Deletes the instance group manager and all instances contained within. If you'd like to delete the manager without deleting the instances, you must first abandon the instances to remove them from the group.
1398///
1399/// A builder for the *delete* method supported by a *instanceGroupManager* resource.
1400/// It is not used directly, but through a [`InstanceGroupManagerMethods`] instance.
1401///
1402/// # Example
1403///
1404/// Instantiate a resource method builder
1405///
1406/// ```test_harness,no_run
1407/// # extern crate hyper;
1408/// # extern crate hyper_rustls;
1409/// # extern crate google_replicapool1_beta2 as replicapool1_beta2;
1410/// # async fn dox() {
1411/// # use replicapool1_beta2::{Replicapool, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1412///
1413/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1414/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1415/// #     .with_native_roots()
1416/// #     .unwrap()
1417/// #     .https_only()
1418/// #     .enable_http2()
1419/// #     .build();
1420///
1421/// # let executor = hyper_util::rt::TokioExecutor::new();
1422/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1423/// #     secret,
1424/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1425/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1426/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1427/// #     ),
1428/// # ).build().await.unwrap();
1429///
1430/// # let client = hyper_util::client::legacy::Client::builder(
1431/// #     hyper_util::rt::TokioExecutor::new()
1432/// # )
1433/// # .build(
1434/// #     hyper_rustls::HttpsConnectorBuilder::new()
1435/// #         .with_native_roots()
1436/// #         .unwrap()
1437/// #         .https_or_http()
1438/// #         .enable_http2()
1439/// #         .build()
1440/// # );
1441/// # let mut hub = Replicapool::new(client, auth);
1442/// // You can configure optional parameters by calling the respective setters at will, and
1443/// // execute the final call using `doit()`.
1444/// // Values shown here are possibly random and not representative !
1445/// let result = hub.instance_group_managers().delete("project", "zone", "instanceGroupManager")
1446///              .doit().await;
1447/// # }
1448/// ```
1449pub struct InstanceGroupManagerDeleteCall<'a, C>
1450where
1451    C: 'a,
1452{
1453    hub: &'a Replicapool<C>,
1454    _project: String,
1455    _zone: String,
1456    _instance_group_manager: String,
1457    _delegate: Option<&'a mut dyn common::Delegate>,
1458    _additional_params: HashMap<String, String>,
1459    _scopes: BTreeSet<String>,
1460}
1461
1462impl<'a, C> common::CallBuilder for InstanceGroupManagerDeleteCall<'a, C> {}
1463
1464impl<'a, C> InstanceGroupManagerDeleteCall<'a, C>
1465where
1466    C: common::Connector,
1467{
1468    /// Perform the operation you have build so far.
1469    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1470        use std::borrow::Cow;
1471        use std::io::{Read, Seek};
1472
1473        use common::{url::Params, ToParts};
1474        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1475
1476        let mut dd = common::DefaultDelegate;
1477        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1478        dlg.begin(common::MethodInfo {
1479            id: "replicapool.instanceGroupManagers.delete",
1480            http_method: hyper::Method::DELETE,
1481        });
1482
1483        for &field in ["alt", "project", "zone", "instanceGroupManager"].iter() {
1484            if self._additional_params.contains_key(field) {
1485                dlg.finished(false);
1486                return Err(common::Error::FieldClash(field));
1487            }
1488        }
1489
1490        let mut params = Params::with_capacity(5 + self._additional_params.len());
1491        params.push("project", self._project);
1492        params.push("zone", self._zone);
1493        params.push("instanceGroupManager", self._instance_group_manager);
1494
1495        params.extend(self._additional_params.iter());
1496
1497        params.push("alt", "json");
1498        let mut url = self.hub._base_url.clone()
1499            + "{project}/zones/{zone}/instanceGroupManagers/{instanceGroupManager}";
1500        if self._scopes.is_empty() {
1501            self._scopes
1502                .insert(Scope::CloudPlatform.as_ref().to_string());
1503        }
1504
1505        #[allow(clippy::single_element_loop)]
1506        for &(find_this, param_name) in [
1507            ("{project}", "project"),
1508            ("{zone}", "zone"),
1509            ("{instanceGroupManager}", "instanceGroupManager"),
1510        ]
1511        .iter()
1512        {
1513            url = params.uri_replacement(url, param_name, find_this, false);
1514        }
1515        {
1516            let to_remove = ["instanceGroupManager", "zone", "project"];
1517            params.remove_params(&to_remove);
1518        }
1519
1520        let url = params.parse_with_url(&url);
1521
1522        loop {
1523            let token = match self
1524                .hub
1525                .auth
1526                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1527                .await
1528            {
1529                Ok(token) => token,
1530                Err(e) => match dlg.token(e) {
1531                    Ok(token) => token,
1532                    Err(e) => {
1533                        dlg.finished(false);
1534                        return Err(common::Error::MissingToken(e));
1535                    }
1536                },
1537            };
1538            let mut req_result = {
1539                let client = &self.hub.client;
1540                dlg.pre_request();
1541                let mut req_builder = hyper::Request::builder()
1542                    .method(hyper::Method::DELETE)
1543                    .uri(url.as_str())
1544                    .header(USER_AGENT, self.hub._user_agent.clone());
1545
1546                if let Some(token) = token.as_ref() {
1547                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1548                }
1549
1550                let request = req_builder
1551                    .header(CONTENT_LENGTH, 0_u64)
1552                    .body(common::to_body::<String>(None));
1553
1554                client.request(request.unwrap()).await
1555            };
1556
1557            match req_result {
1558                Err(err) => {
1559                    if let common::Retry::After(d) = dlg.http_error(&err) {
1560                        sleep(d).await;
1561                        continue;
1562                    }
1563                    dlg.finished(false);
1564                    return Err(common::Error::HttpError(err));
1565                }
1566                Ok(res) => {
1567                    let (mut parts, body) = res.into_parts();
1568                    let mut body = common::Body::new(body);
1569                    if !parts.status.is_success() {
1570                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1571                        let error = serde_json::from_str(&common::to_string(&bytes));
1572                        let response = common::to_response(parts, bytes.into());
1573
1574                        if let common::Retry::After(d) =
1575                            dlg.http_failure(&response, error.as_ref().ok())
1576                        {
1577                            sleep(d).await;
1578                            continue;
1579                        }
1580
1581                        dlg.finished(false);
1582
1583                        return Err(match error {
1584                            Ok(value) => common::Error::BadRequest(value),
1585                            _ => common::Error::Failure(response),
1586                        });
1587                    }
1588                    let response = {
1589                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1590                        let encoded = common::to_string(&bytes);
1591                        match serde_json::from_str(&encoded) {
1592                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1593                            Err(error) => {
1594                                dlg.response_json_decode_error(&encoded, &error);
1595                                return Err(common::Error::JsonDecodeError(
1596                                    encoded.to_string(),
1597                                    error,
1598                                ));
1599                            }
1600                        }
1601                    };
1602
1603                    dlg.finished(true);
1604                    return Ok(response);
1605                }
1606            }
1607        }
1608    }
1609
1610    /// The Google Developers Console project name.
1611    ///
1612    /// Sets the *project* path property to the given value.
1613    ///
1614    /// Even though the property as already been set when instantiating this call,
1615    /// we provide this method for API completeness.
1616    pub fn project(mut self, new_value: &str) -> InstanceGroupManagerDeleteCall<'a, C> {
1617        self._project = new_value.to_string();
1618        self
1619    }
1620    /// The name of the zone in which the instance group manager resides.
1621    ///
1622    /// Sets the *zone* path property to the given value.
1623    ///
1624    /// Even though the property as already been set when instantiating this call,
1625    /// we provide this method for API completeness.
1626    pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerDeleteCall<'a, C> {
1627        self._zone = new_value.to_string();
1628        self
1629    }
1630    /// Name of the Instance Group Manager resource to delete.
1631    ///
1632    /// Sets the *instance group manager* path property to the given value.
1633    ///
1634    /// Even though the property as already been set when instantiating this call,
1635    /// we provide this method for API completeness.
1636    pub fn instance_group_manager(
1637        mut self,
1638        new_value: &str,
1639    ) -> InstanceGroupManagerDeleteCall<'a, C> {
1640        self._instance_group_manager = new_value.to_string();
1641        self
1642    }
1643    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1644    /// while executing the actual API request.
1645    ///
1646    /// ````text
1647    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1648    /// ````
1649    ///
1650    /// Sets the *delegate* property to the given value.
1651    pub fn delegate(
1652        mut self,
1653        new_value: &'a mut dyn common::Delegate,
1654    ) -> InstanceGroupManagerDeleteCall<'a, C> {
1655        self._delegate = Some(new_value);
1656        self
1657    }
1658
1659    /// Set any additional parameter of the query string used in the request.
1660    /// It should be used to set parameters which are not yet available through their own
1661    /// setters.
1662    ///
1663    /// Please note that this method must not be used to set any of the known parameters
1664    /// which have their own setter method. If done anyway, the request will fail.
1665    ///
1666    /// # Additional Parameters
1667    ///
1668    /// * *alt* (query-string) - Data format for the response.
1669    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1670    /// * *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.
1671    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1672    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1673    /// * *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. Overrides userIp if both are provided.
1674    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1675    pub fn param<T>(mut self, name: T, value: T) -> InstanceGroupManagerDeleteCall<'a, C>
1676    where
1677        T: AsRef<str>,
1678    {
1679        self._additional_params
1680            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1681        self
1682    }
1683
1684    /// Identifies the authorization scope for the method you are building.
1685    ///
1686    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1687    /// [`Scope::CloudPlatform`].
1688    ///
1689    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1690    /// tokens for more than one scope.
1691    ///
1692    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1693    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1694    /// sufficient, a read-write scope will do as well.
1695    pub fn add_scope<St>(mut self, scope: St) -> InstanceGroupManagerDeleteCall<'a, C>
1696    where
1697        St: AsRef<str>,
1698    {
1699        self._scopes.insert(String::from(scope.as_ref()));
1700        self
1701    }
1702    /// Identifies the authorization scope(s) for the method you are building.
1703    ///
1704    /// See [`Self::add_scope()`] for details.
1705    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceGroupManagerDeleteCall<'a, C>
1706    where
1707        I: IntoIterator<Item = St>,
1708        St: AsRef<str>,
1709    {
1710        self._scopes
1711            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1712        self
1713    }
1714
1715    /// Removes all scopes, and no default scope will be used either.
1716    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1717    /// for details).
1718    pub fn clear_scopes(mut self) -> InstanceGroupManagerDeleteCall<'a, C> {
1719        self._scopes.clear();
1720        self
1721    }
1722}
1723
1724/// Deletes the specified instances. The instances are deleted, then removed from the instance group and any target pools of which they were a member. The targetSize of the instance group manager is reduced by the number of instances deleted.
1725///
1726/// A builder for the *deleteInstances* method supported by a *instanceGroupManager* resource.
1727/// It is not used directly, but through a [`InstanceGroupManagerMethods`] instance.
1728///
1729/// # Example
1730///
1731/// Instantiate a resource method builder
1732///
1733/// ```test_harness,no_run
1734/// # extern crate hyper;
1735/// # extern crate hyper_rustls;
1736/// # extern crate google_replicapool1_beta2 as replicapool1_beta2;
1737/// use replicapool1_beta2::api::InstanceGroupManagersDeleteInstancesRequest;
1738/// # async fn dox() {
1739/// # use replicapool1_beta2::{Replicapool, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1740///
1741/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1742/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1743/// #     .with_native_roots()
1744/// #     .unwrap()
1745/// #     .https_only()
1746/// #     .enable_http2()
1747/// #     .build();
1748///
1749/// # let executor = hyper_util::rt::TokioExecutor::new();
1750/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1751/// #     secret,
1752/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1753/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1754/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1755/// #     ),
1756/// # ).build().await.unwrap();
1757///
1758/// # let client = hyper_util::client::legacy::Client::builder(
1759/// #     hyper_util::rt::TokioExecutor::new()
1760/// # )
1761/// # .build(
1762/// #     hyper_rustls::HttpsConnectorBuilder::new()
1763/// #         .with_native_roots()
1764/// #         .unwrap()
1765/// #         .https_or_http()
1766/// #         .enable_http2()
1767/// #         .build()
1768/// # );
1769/// # let mut hub = Replicapool::new(client, auth);
1770/// // As the method needs a request, you would usually fill it with the desired information
1771/// // into the respective structure. Some of the parts shown here might not be applicable !
1772/// // Values shown here are possibly random and not representative !
1773/// let mut req = InstanceGroupManagersDeleteInstancesRequest::default();
1774///
1775/// // You can configure optional parameters by calling the respective setters at will, and
1776/// // execute the final call using `doit()`.
1777/// // Values shown here are possibly random and not representative !
1778/// let result = hub.instance_group_managers().delete_instances(req, "project", "zone", "instanceGroupManager")
1779///              .doit().await;
1780/// # }
1781/// ```
1782pub struct InstanceGroupManagerDeleteInstanceCall<'a, C>
1783where
1784    C: 'a,
1785{
1786    hub: &'a Replicapool<C>,
1787    _request: InstanceGroupManagersDeleteInstancesRequest,
1788    _project: String,
1789    _zone: String,
1790    _instance_group_manager: String,
1791    _delegate: Option<&'a mut dyn common::Delegate>,
1792    _additional_params: HashMap<String, String>,
1793    _scopes: BTreeSet<String>,
1794}
1795
1796impl<'a, C> common::CallBuilder for InstanceGroupManagerDeleteInstanceCall<'a, C> {}
1797
1798impl<'a, C> InstanceGroupManagerDeleteInstanceCall<'a, C>
1799where
1800    C: common::Connector,
1801{
1802    /// Perform the operation you have build so far.
1803    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1804        use std::borrow::Cow;
1805        use std::io::{Read, Seek};
1806
1807        use common::{url::Params, ToParts};
1808        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1809
1810        let mut dd = common::DefaultDelegate;
1811        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1812        dlg.begin(common::MethodInfo {
1813            id: "replicapool.instanceGroupManagers.deleteInstances",
1814            http_method: hyper::Method::POST,
1815        });
1816
1817        for &field in ["alt", "project", "zone", "instanceGroupManager"].iter() {
1818            if self._additional_params.contains_key(field) {
1819                dlg.finished(false);
1820                return Err(common::Error::FieldClash(field));
1821            }
1822        }
1823
1824        let mut params = Params::with_capacity(6 + self._additional_params.len());
1825        params.push("project", self._project);
1826        params.push("zone", self._zone);
1827        params.push("instanceGroupManager", self._instance_group_manager);
1828
1829        params.extend(self._additional_params.iter());
1830
1831        params.push("alt", "json");
1832        let mut url = self.hub._base_url.clone()
1833            + "{project}/zones/{zone}/instanceGroupManagers/{instanceGroupManager}/deleteInstances";
1834        if self._scopes.is_empty() {
1835            self._scopes
1836                .insert(Scope::CloudPlatform.as_ref().to_string());
1837        }
1838
1839        #[allow(clippy::single_element_loop)]
1840        for &(find_this, param_name) in [
1841            ("{project}", "project"),
1842            ("{zone}", "zone"),
1843            ("{instanceGroupManager}", "instanceGroupManager"),
1844        ]
1845        .iter()
1846        {
1847            url = params.uri_replacement(url, param_name, find_this, false);
1848        }
1849        {
1850            let to_remove = ["instanceGroupManager", "zone", "project"];
1851            params.remove_params(&to_remove);
1852        }
1853
1854        let url = params.parse_with_url(&url);
1855
1856        let mut json_mime_type = mime::APPLICATION_JSON;
1857        let mut request_value_reader = {
1858            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1859            common::remove_json_null_values(&mut value);
1860            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1861            serde_json::to_writer(&mut dst, &value).unwrap();
1862            dst
1863        };
1864        let request_size = request_value_reader
1865            .seek(std::io::SeekFrom::End(0))
1866            .unwrap();
1867        request_value_reader
1868            .seek(std::io::SeekFrom::Start(0))
1869            .unwrap();
1870
1871        loop {
1872            let token = match self
1873                .hub
1874                .auth
1875                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1876                .await
1877            {
1878                Ok(token) => token,
1879                Err(e) => match dlg.token(e) {
1880                    Ok(token) => token,
1881                    Err(e) => {
1882                        dlg.finished(false);
1883                        return Err(common::Error::MissingToken(e));
1884                    }
1885                },
1886            };
1887            request_value_reader
1888                .seek(std::io::SeekFrom::Start(0))
1889                .unwrap();
1890            let mut req_result = {
1891                let client = &self.hub.client;
1892                dlg.pre_request();
1893                let mut req_builder = hyper::Request::builder()
1894                    .method(hyper::Method::POST)
1895                    .uri(url.as_str())
1896                    .header(USER_AGENT, self.hub._user_agent.clone());
1897
1898                if let Some(token) = token.as_ref() {
1899                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1900                }
1901
1902                let request = req_builder
1903                    .header(CONTENT_TYPE, json_mime_type.to_string())
1904                    .header(CONTENT_LENGTH, request_size as u64)
1905                    .body(common::to_body(
1906                        request_value_reader.get_ref().clone().into(),
1907                    ));
1908
1909                client.request(request.unwrap()).await
1910            };
1911
1912            match req_result {
1913                Err(err) => {
1914                    if let common::Retry::After(d) = dlg.http_error(&err) {
1915                        sleep(d).await;
1916                        continue;
1917                    }
1918                    dlg.finished(false);
1919                    return Err(common::Error::HttpError(err));
1920                }
1921                Ok(res) => {
1922                    let (mut parts, body) = res.into_parts();
1923                    let mut body = common::Body::new(body);
1924                    if !parts.status.is_success() {
1925                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1926                        let error = serde_json::from_str(&common::to_string(&bytes));
1927                        let response = common::to_response(parts, bytes.into());
1928
1929                        if let common::Retry::After(d) =
1930                            dlg.http_failure(&response, error.as_ref().ok())
1931                        {
1932                            sleep(d).await;
1933                            continue;
1934                        }
1935
1936                        dlg.finished(false);
1937
1938                        return Err(match error {
1939                            Ok(value) => common::Error::BadRequest(value),
1940                            _ => common::Error::Failure(response),
1941                        });
1942                    }
1943                    let response = {
1944                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1945                        let encoded = common::to_string(&bytes);
1946                        match serde_json::from_str(&encoded) {
1947                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1948                            Err(error) => {
1949                                dlg.response_json_decode_error(&encoded, &error);
1950                                return Err(common::Error::JsonDecodeError(
1951                                    encoded.to_string(),
1952                                    error,
1953                                ));
1954                            }
1955                        }
1956                    };
1957
1958                    dlg.finished(true);
1959                    return Ok(response);
1960                }
1961            }
1962        }
1963    }
1964
1965    ///
1966    /// Sets the *request* property to the given value.
1967    ///
1968    /// Even though the property as already been set when instantiating this call,
1969    /// we provide this method for API completeness.
1970    pub fn request(
1971        mut self,
1972        new_value: InstanceGroupManagersDeleteInstancesRequest,
1973    ) -> InstanceGroupManagerDeleteInstanceCall<'a, C> {
1974        self._request = new_value;
1975        self
1976    }
1977    /// The Google Developers Console project name.
1978    ///
1979    /// Sets the *project* path property to the given value.
1980    ///
1981    /// Even though the property as already been set when instantiating this call,
1982    /// we provide this method for API completeness.
1983    pub fn project(mut self, new_value: &str) -> InstanceGroupManagerDeleteInstanceCall<'a, C> {
1984        self._project = new_value.to_string();
1985        self
1986    }
1987    /// The name of the zone in which the instance group manager resides.
1988    ///
1989    /// Sets the *zone* path property to the given value.
1990    ///
1991    /// Even though the property as already been set when instantiating this call,
1992    /// we provide this method for API completeness.
1993    pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerDeleteInstanceCall<'a, C> {
1994        self._zone = new_value.to_string();
1995        self
1996    }
1997    /// The name of the instance group manager.
1998    ///
1999    /// Sets the *instance group manager* path property to the given value.
2000    ///
2001    /// Even though the property as already been set when instantiating this call,
2002    /// we provide this method for API completeness.
2003    pub fn instance_group_manager(
2004        mut self,
2005        new_value: &str,
2006    ) -> InstanceGroupManagerDeleteInstanceCall<'a, C> {
2007        self._instance_group_manager = new_value.to_string();
2008        self
2009    }
2010    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2011    /// while executing the actual API request.
2012    ///
2013    /// ````text
2014    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2015    /// ````
2016    ///
2017    /// Sets the *delegate* property to the given value.
2018    pub fn delegate(
2019        mut self,
2020        new_value: &'a mut dyn common::Delegate,
2021    ) -> InstanceGroupManagerDeleteInstanceCall<'a, C> {
2022        self._delegate = Some(new_value);
2023        self
2024    }
2025
2026    /// Set any additional parameter of the query string used in the request.
2027    /// It should be used to set parameters which are not yet available through their own
2028    /// setters.
2029    ///
2030    /// Please note that this method must not be used to set any of the known parameters
2031    /// which have their own setter method. If done anyway, the request will fail.
2032    ///
2033    /// # Additional Parameters
2034    ///
2035    /// * *alt* (query-string) - Data format for the response.
2036    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2037    /// * *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.
2038    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2039    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2040    /// * *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. Overrides userIp if both are provided.
2041    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2042    pub fn param<T>(mut self, name: T, value: T) -> InstanceGroupManagerDeleteInstanceCall<'a, C>
2043    where
2044        T: AsRef<str>,
2045    {
2046        self._additional_params
2047            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2048        self
2049    }
2050
2051    /// Identifies the authorization scope for the method you are building.
2052    ///
2053    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2054    /// [`Scope::CloudPlatform`].
2055    ///
2056    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2057    /// tokens for more than one scope.
2058    ///
2059    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2060    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2061    /// sufficient, a read-write scope will do as well.
2062    pub fn add_scope<St>(mut self, scope: St) -> InstanceGroupManagerDeleteInstanceCall<'a, C>
2063    where
2064        St: AsRef<str>,
2065    {
2066        self._scopes.insert(String::from(scope.as_ref()));
2067        self
2068    }
2069    /// Identifies the authorization scope(s) for the method you are building.
2070    ///
2071    /// See [`Self::add_scope()`] for details.
2072    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceGroupManagerDeleteInstanceCall<'a, C>
2073    where
2074        I: IntoIterator<Item = St>,
2075        St: AsRef<str>,
2076    {
2077        self._scopes
2078            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2079        self
2080    }
2081
2082    /// Removes all scopes, and no default scope will be used either.
2083    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2084    /// for details).
2085    pub fn clear_scopes(mut self) -> InstanceGroupManagerDeleteInstanceCall<'a, C> {
2086        self._scopes.clear();
2087        self
2088    }
2089}
2090
2091/// Returns the specified Instance Group Manager resource.
2092///
2093/// A builder for the *get* method supported by a *instanceGroupManager* resource.
2094/// It is not used directly, but through a [`InstanceGroupManagerMethods`] instance.
2095///
2096/// # Example
2097///
2098/// Instantiate a resource method builder
2099///
2100/// ```test_harness,no_run
2101/// # extern crate hyper;
2102/// # extern crate hyper_rustls;
2103/// # extern crate google_replicapool1_beta2 as replicapool1_beta2;
2104/// # async fn dox() {
2105/// # use replicapool1_beta2::{Replicapool, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2106///
2107/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2108/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2109/// #     .with_native_roots()
2110/// #     .unwrap()
2111/// #     .https_only()
2112/// #     .enable_http2()
2113/// #     .build();
2114///
2115/// # let executor = hyper_util::rt::TokioExecutor::new();
2116/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2117/// #     secret,
2118/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2119/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2120/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2121/// #     ),
2122/// # ).build().await.unwrap();
2123///
2124/// # let client = hyper_util::client::legacy::Client::builder(
2125/// #     hyper_util::rt::TokioExecutor::new()
2126/// # )
2127/// # .build(
2128/// #     hyper_rustls::HttpsConnectorBuilder::new()
2129/// #         .with_native_roots()
2130/// #         .unwrap()
2131/// #         .https_or_http()
2132/// #         .enable_http2()
2133/// #         .build()
2134/// # );
2135/// # let mut hub = Replicapool::new(client, auth);
2136/// // You can configure optional parameters by calling the respective setters at will, and
2137/// // execute the final call using `doit()`.
2138/// // Values shown here are possibly random and not representative !
2139/// let result = hub.instance_group_managers().get("project", "zone", "instanceGroupManager")
2140///              .doit().await;
2141/// # }
2142/// ```
2143pub struct InstanceGroupManagerGetCall<'a, C>
2144where
2145    C: 'a,
2146{
2147    hub: &'a Replicapool<C>,
2148    _project: String,
2149    _zone: String,
2150    _instance_group_manager: String,
2151    _delegate: Option<&'a mut dyn common::Delegate>,
2152    _additional_params: HashMap<String, String>,
2153    _scopes: BTreeSet<String>,
2154}
2155
2156impl<'a, C> common::CallBuilder for InstanceGroupManagerGetCall<'a, C> {}
2157
2158impl<'a, C> InstanceGroupManagerGetCall<'a, C>
2159where
2160    C: common::Connector,
2161{
2162    /// Perform the operation you have build so far.
2163    pub async fn doit(mut self) -> common::Result<(common::Response, InstanceGroupManager)> {
2164        use std::borrow::Cow;
2165        use std::io::{Read, Seek};
2166
2167        use common::{url::Params, ToParts};
2168        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2169
2170        let mut dd = common::DefaultDelegate;
2171        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2172        dlg.begin(common::MethodInfo {
2173            id: "replicapool.instanceGroupManagers.get",
2174            http_method: hyper::Method::GET,
2175        });
2176
2177        for &field in ["alt", "project", "zone", "instanceGroupManager"].iter() {
2178            if self._additional_params.contains_key(field) {
2179                dlg.finished(false);
2180                return Err(common::Error::FieldClash(field));
2181            }
2182        }
2183
2184        let mut params = Params::with_capacity(5 + self._additional_params.len());
2185        params.push("project", self._project);
2186        params.push("zone", self._zone);
2187        params.push("instanceGroupManager", self._instance_group_manager);
2188
2189        params.extend(self._additional_params.iter());
2190
2191        params.push("alt", "json");
2192        let mut url = self.hub._base_url.clone()
2193            + "{project}/zones/{zone}/instanceGroupManagers/{instanceGroupManager}";
2194        if self._scopes.is_empty() {
2195            self._scopes
2196                .insert(Scope::ComputeReadonly.as_ref().to_string());
2197        }
2198
2199        #[allow(clippy::single_element_loop)]
2200        for &(find_this, param_name) in [
2201            ("{project}", "project"),
2202            ("{zone}", "zone"),
2203            ("{instanceGroupManager}", "instanceGroupManager"),
2204        ]
2205        .iter()
2206        {
2207            url = params.uri_replacement(url, param_name, find_this, false);
2208        }
2209        {
2210            let to_remove = ["instanceGroupManager", "zone", "project"];
2211            params.remove_params(&to_remove);
2212        }
2213
2214        let url = params.parse_with_url(&url);
2215
2216        loop {
2217            let token = match self
2218                .hub
2219                .auth
2220                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2221                .await
2222            {
2223                Ok(token) => token,
2224                Err(e) => match dlg.token(e) {
2225                    Ok(token) => token,
2226                    Err(e) => {
2227                        dlg.finished(false);
2228                        return Err(common::Error::MissingToken(e));
2229                    }
2230                },
2231            };
2232            let mut req_result = {
2233                let client = &self.hub.client;
2234                dlg.pre_request();
2235                let mut req_builder = hyper::Request::builder()
2236                    .method(hyper::Method::GET)
2237                    .uri(url.as_str())
2238                    .header(USER_AGENT, self.hub._user_agent.clone());
2239
2240                if let Some(token) = token.as_ref() {
2241                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2242                }
2243
2244                let request = req_builder
2245                    .header(CONTENT_LENGTH, 0_u64)
2246                    .body(common::to_body::<String>(None));
2247
2248                client.request(request.unwrap()).await
2249            };
2250
2251            match req_result {
2252                Err(err) => {
2253                    if let common::Retry::After(d) = dlg.http_error(&err) {
2254                        sleep(d).await;
2255                        continue;
2256                    }
2257                    dlg.finished(false);
2258                    return Err(common::Error::HttpError(err));
2259                }
2260                Ok(res) => {
2261                    let (mut parts, body) = res.into_parts();
2262                    let mut body = common::Body::new(body);
2263                    if !parts.status.is_success() {
2264                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2265                        let error = serde_json::from_str(&common::to_string(&bytes));
2266                        let response = common::to_response(parts, bytes.into());
2267
2268                        if let common::Retry::After(d) =
2269                            dlg.http_failure(&response, error.as_ref().ok())
2270                        {
2271                            sleep(d).await;
2272                            continue;
2273                        }
2274
2275                        dlg.finished(false);
2276
2277                        return Err(match error {
2278                            Ok(value) => common::Error::BadRequest(value),
2279                            _ => common::Error::Failure(response),
2280                        });
2281                    }
2282                    let response = {
2283                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2284                        let encoded = common::to_string(&bytes);
2285                        match serde_json::from_str(&encoded) {
2286                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2287                            Err(error) => {
2288                                dlg.response_json_decode_error(&encoded, &error);
2289                                return Err(common::Error::JsonDecodeError(
2290                                    encoded.to_string(),
2291                                    error,
2292                                ));
2293                            }
2294                        }
2295                    };
2296
2297                    dlg.finished(true);
2298                    return Ok(response);
2299                }
2300            }
2301        }
2302    }
2303
2304    /// The Google Developers Console project name.
2305    ///
2306    /// Sets the *project* path property to the given value.
2307    ///
2308    /// Even though the property as already been set when instantiating this call,
2309    /// we provide this method for API completeness.
2310    pub fn project(mut self, new_value: &str) -> InstanceGroupManagerGetCall<'a, C> {
2311        self._project = new_value.to_string();
2312        self
2313    }
2314    /// The name of the zone in which the instance group manager resides.
2315    ///
2316    /// Sets the *zone* path property to the given value.
2317    ///
2318    /// Even though the property as already been set when instantiating this call,
2319    /// we provide this method for API completeness.
2320    pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerGetCall<'a, C> {
2321        self._zone = new_value.to_string();
2322        self
2323    }
2324    /// Name of the instance resource to return.
2325    ///
2326    /// Sets the *instance group manager* path property to the given value.
2327    ///
2328    /// Even though the property as already been set when instantiating this call,
2329    /// we provide this method for API completeness.
2330    pub fn instance_group_manager(mut self, new_value: &str) -> InstanceGroupManagerGetCall<'a, C> {
2331        self._instance_group_manager = new_value.to_string();
2332        self
2333    }
2334    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2335    /// while executing the actual API request.
2336    ///
2337    /// ````text
2338    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2339    /// ````
2340    ///
2341    /// Sets the *delegate* property to the given value.
2342    pub fn delegate(
2343        mut self,
2344        new_value: &'a mut dyn common::Delegate,
2345    ) -> InstanceGroupManagerGetCall<'a, C> {
2346        self._delegate = Some(new_value);
2347        self
2348    }
2349
2350    /// Set any additional parameter of the query string used in the request.
2351    /// It should be used to set parameters which are not yet available through their own
2352    /// setters.
2353    ///
2354    /// Please note that this method must not be used to set any of the known parameters
2355    /// which have their own setter method. If done anyway, the request will fail.
2356    ///
2357    /// # Additional Parameters
2358    ///
2359    /// * *alt* (query-string) - Data format for the response.
2360    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2361    /// * *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.
2362    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2363    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2364    /// * *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. Overrides userIp if both are provided.
2365    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2366    pub fn param<T>(mut self, name: T, value: T) -> InstanceGroupManagerGetCall<'a, C>
2367    where
2368        T: AsRef<str>,
2369    {
2370        self._additional_params
2371            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2372        self
2373    }
2374
2375    /// Identifies the authorization scope for the method you are building.
2376    ///
2377    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2378    /// [`Scope::ComputeReadonly`].
2379    ///
2380    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2381    /// tokens for more than one scope.
2382    ///
2383    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2384    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2385    /// sufficient, a read-write scope will do as well.
2386    pub fn add_scope<St>(mut self, scope: St) -> InstanceGroupManagerGetCall<'a, C>
2387    where
2388        St: AsRef<str>,
2389    {
2390        self._scopes.insert(String::from(scope.as_ref()));
2391        self
2392    }
2393    /// Identifies the authorization scope(s) for the method you are building.
2394    ///
2395    /// See [`Self::add_scope()`] for details.
2396    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceGroupManagerGetCall<'a, C>
2397    where
2398        I: IntoIterator<Item = St>,
2399        St: AsRef<str>,
2400    {
2401        self._scopes
2402            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2403        self
2404    }
2405
2406    /// Removes all scopes, and no default scope will be used either.
2407    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2408    /// for details).
2409    pub fn clear_scopes(mut self) -> InstanceGroupManagerGetCall<'a, C> {
2410        self._scopes.clear();
2411        self
2412    }
2413}
2414
2415/// Creates an instance group manager, as well as the instance group and the specified number of instances.
2416///
2417/// A builder for the *insert* method supported by a *instanceGroupManager* resource.
2418/// It is not used directly, but through a [`InstanceGroupManagerMethods`] instance.
2419///
2420/// # Example
2421///
2422/// Instantiate a resource method builder
2423///
2424/// ```test_harness,no_run
2425/// # extern crate hyper;
2426/// # extern crate hyper_rustls;
2427/// # extern crate google_replicapool1_beta2 as replicapool1_beta2;
2428/// use replicapool1_beta2::api::InstanceGroupManager;
2429/// # async fn dox() {
2430/// # use replicapool1_beta2::{Replicapool, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2431///
2432/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2433/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2434/// #     .with_native_roots()
2435/// #     .unwrap()
2436/// #     .https_only()
2437/// #     .enable_http2()
2438/// #     .build();
2439///
2440/// # let executor = hyper_util::rt::TokioExecutor::new();
2441/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2442/// #     secret,
2443/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2444/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2445/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2446/// #     ),
2447/// # ).build().await.unwrap();
2448///
2449/// # let client = hyper_util::client::legacy::Client::builder(
2450/// #     hyper_util::rt::TokioExecutor::new()
2451/// # )
2452/// # .build(
2453/// #     hyper_rustls::HttpsConnectorBuilder::new()
2454/// #         .with_native_roots()
2455/// #         .unwrap()
2456/// #         .https_or_http()
2457/// #         .enable_http2()
2458/// #         .build()
2459/// # );
2460/// # let mut hub = Replicapool::new(client, auth);
2461/// // As the method needs a request, you would usually fill it with the desired information
2462/// // into the respective structure. Some of the parts shown here might not be applicable !
2463/// // Values shown here are possibly random and not representative !
2464/// let mut req = InstanceGroupManager::default();
2465///
2466/// // You can configure optional parameters by calling the respective setters at will, and
2467/// // execute the final call using `doit()`.
2468/// // Values shown here are possibly random and not representative !
2469/// let result = hub.instance_group_managers().insert(req, "project", "zone", -50)
2470///              .doit().await;
2471/// # }
2472/// ```
2473pub struct InstanceGroupManagerInsertCall<'a, C>
2474where
2475    C: 'a,
2476{
2477    hub: &'a Replicapool<C>,
2478    _request: InstanceGroupManager,
2479    _project: String,
2480    _zone: String,
2481    _size: i32,
2482    _delegate: Option<&'a mut dyn common::Delegate>,
2483    _additional_params: HashMap<String, String>,
2484    _scopes: BTreeSet<String>,
2485}
2486
2487impl<'a, C> common::CallBuilder for InstanceGroupManagerInsertCall<'a, C> {}
2488
2489impl<'a, C> InstanceGroupManagerInsertCall<'a, C>
2490where
2491    C: common::Connector,
2492{
2493    /// Perform the operation you have build so far.
2494    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2495        use std::borrow::Cow;
2496        use std::io::{Read, Seek};
2497
2498        use common::{url::Params, ToParts};
2499        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2500
2501        let mut dd = common::DefaultDelegate;
2502        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2503        dlg.begin(common::MethodInfo {
2504            id: "replicapool.instanceGroupManagers.insert",
2505            http_method: hyper::Method::POST,
2506        });
2507
2508        for &field in ["alt", "project", "zone", "size"].iter() {
2509            if self._additional_params.contains_key(field) {
2510                dlg.finished(false);
2511                return Err(common::Error::FieldClash(field));
2512            }
2513        }
2514
2515        let mut params = Params::with_capacity(6 + self._additional_params.len());
2516        params.push("project", self._project);
2517        params.push("zone", self._zone);
2518        params.push("size", self._size.to_string());
2519
2520        params.extend(self._additional_params.iter());
2521
2522        params.push("alt", "json");
2523        let mut url = self.hub._base_url.clone() + "{project}/zones/{zone}/instanceGroupManagers";
2524        if self._scopes.is_empty() {
2525            self._scopes
2526                .insert(Scope::CloudPlatform.as_ref().to_string());
2527        }
2528
2529        #[allow(clippy::single_element_loop)]
2530        for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() {
2531            url = params.uri_replacement(url, param_name, find_this, false);
2532        }
2533        {
2534            let to_remove = ["zone", "project"];
2535            params.remove_params(&to_remove);
2536        }
2537
2538        let url = params.parse_with_url(&url);
2539
2540        let mut json_mime_type = mime::APPLICATION_JSON;
2541        let mut request_value_reader = {
2542            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2543            common::remove_json_null_values(&mut value);
2544            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2545            serde_json::to_writer(&mut dst, &value).unwrap();
2546            dst
2547        };
2548        let request_size = request_value_reader
2549            .seek(std::io::SeekFrom::End(0))
2550            .unwrap();
2551        request_value_reader
2552            .seek(std::io::SeekFrom::Start(0))
2553            .unwrap();
2554
2555        loop {
2556            let token = match self
2557                .hub
2558                .auth
2559                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2560                .await
2561            {
2562                Ok(token) => token,
2563                Err(e) => match dlg.token(e) {
2564                    Ok(token) => token,
2565                    Err(e) => {
2566                        dlg.finished(false);
2567                        return Err(common::Error::MissingToken(e));
2568                    }
2569                },
2570            };
2571            request_value_reader
2572                .seek(std::io::SeekFrom::Start(0))
2573                .unwrap();
2574            let mut req_result = {
2575                let client = &self.hub.client;
2576                dlg.pre_request();
2577                let mut req_builder = hyper::Request::builder()
2578                    .method(hyper::Method::POST)
2579                    .uri(url.as_str())
2580                    .header(USER_AGENT, self.hub._user_agent.clone());
2581
2582                if let Some(token) = token.as_ref() {
2583                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2584                }
2585
2586                let request = req_builder
2587                    .header(CONTENT_TYPE, json_mime_type.to_string())
2588                    .header(CONTENT_LENGTH, request_size as u64)
2589                    .body(common::to_body(
2590                        request_value_reader.get_ref().clone().into(),
2591                    ));
2592
2593                client.request(request.unwrap()).await
2594            };
2595
2596            match req_result {
2597                Err(err) => {
2598                    if let common::Retry::After(d) = dlg.http_error(&err) {
2599                        sleep(d).await;
2600                        continue;
2601                    }
2602                    dlg.finished(false);
2603                    return Err(common::Error::HttpError(err));
2604                }
2605                Ok(res) => {
2606                    let (mut parts, body) = res.into_parts();
2607                    let mut body = common::Body::new(body);
2608                    if !parts.status.is_success() {
2609                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2610                        let error = serde_json::from_str(&common::to_string(&bytes));
2611                        let response = common::to_response(parts, bytes.into());
2612
2613                        if let common::Retry::After(d) =
2614                            dlg.http_failure(&response, error.as_ref().ok())
2615                        {
2616                            sleep(d).await;
2617                            continue;
2618                        }
2619
2620                        dlg.finished(false);
2621
2622                        return Err(match error {
2623                            Ok(value) => common::Error::BadRequest(value),
2624                            _ => common::Error::Failure(response),
2625                        });
2626                    }
2627                    let response = {
2628                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2629                        let encoded = common::to_string(&bytes);
2630                        match serde_json::from_str(&encoded) {
2631                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2632                            Err(error) => {
2633                                dlg.response_json_decode_error(&encoded, &error);
2634                                return Err(common::Error::JsonDecodeError(
2635                                    encoded.to_string(),
2636                                    error,
2637                                ));
2638                            }
2639                        }
2640                    };
2641
2642                    dlg.finished(true);
2643                    return Ok(response);
2644                }
2645            }
2646        }
2647    }
2648
2649    ///
2650    /// Sets the *request* property to the given value.
2651    ///
2652    /// Even though the property as already been set when instantiating this call,
2653    /// we provide this method for API completeness.
2654    pub fn request(
2655        mut self,
2656        new_value: InstanceGroupManager,
2657    ) -> InstanceGroupManagerInsertCall<'a, C> {
2658        self._request = new_value;
2659        self
2660    }
2661    /// The Google Developers Console project name.
2662    ///
2663    /// Sets the *project* path property to the given value.
2664    ///
2665    /// Even though the property as already been set when instantiating this call,
2666    /// we provide this method for API completeness.
2667    pub fn project(mut self, new_value: &str) -> InstanceGroupManagerInsertCall<'a, C> {
2668        self._project = new_value.to_string();
2669        self
2670    }
2671    /// The name of the zone in which the instance group manager resides.
2672    ///
2673    /// Sets the *zone* path property to the given value.
2674    ///
2675    /// Even though the property as already been set when instantiating this call,
2676    /// we provide this method for API completeness.
2677    pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerInsertCall<'a, C> {
2678        self._zone = new_value.to_string();
2679        self
2680    }
2681    /// Number of instances that should exist.
2682    ///
2683    /// Sets the *size* query property to the given value.
2684    ///
2685    /// Even though the property as already been set when instantiating this call,
2686    /// we provide this method for API completeness.
2687    pub fn size(mut self, new_value: i32) -> InstanceGroupManagerInsertCall<'a, C> {
2688        self._size = new_value;
2689        self
2690    }
2691    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2692    /// while executing the actual API request.
2693    ///
2694    /// ````text
2695    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2696    /// ````
2697    ///
2698    /// Sets the *delegate* property to the given value.
2699    pub fn delegate(
2700        mut self,
2701        new_value: &'a mut dyn common::Delegate,
2702    ) -> InstanceGroupManagerInsertCall<'a, C> {
2703        self._delegate = Some(new_value);
2704        self
2705    }
2706
2707    /// Set any additional parameter of the query string used in the request.
2708    /// It should be used to set parameters which are not yet available through their own
2709    /// setters.
2710    ///
2711    /// Please note that this method must not be used to set any of the known parameters
2712    /// which have their own setter method. If done anyway, the request will fail.
2713    ///
2714    /// # Additional Parameters
2715    ///
2716    /// * *alt* (query-string) - Data format for the response.
2717    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2718    /// * *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.
2719    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2720    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2721    /// * *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. Overrides userIp if both are provided.
2722    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2723    pub fn param<T>(mut self, name: T, value: T) -> InstanceGroupManagerInsertCall<'a, C>
2724    where
2725        T: AsRef<str>,
2726    {
2727        self._additional_params
2728            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2729        self
2730    }
2731
2732    /// Identifies the authorization scope for the method you are building.
2733    ///
2734    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2735    /// [`Scope::CloudPlatform`].
2736    ///
2737    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2738    /// tokens for more than one scope.
2739    ///
2740    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2741    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2742    /// sufficient, a read-write scope will do as well.
2743    pub fn add_scope<St>(mut self, scope: St) -> InstanceGroupManagerInsertCall<'a, C>
2744    where
2745        St: AsRef<str>,
2746    {
2747        self._scopes.insert(String::from(scope.as_ref()));
2748        self
2749    }
2750    /// Identifies the authorization scope(s) for the method you are building.
2751    ///
2752    /// See [`Self::add_scope()`] for details.
2753    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceGroupManagerInsertCall<'a, C>
2754    where
2755        I: IntoIterator<Item = St>,
2756        St: AsRef<str>,
2757    {
2758        self._scopes
2759            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2760        self
2761    }
2762
2763    /// Removes all scopes, and no default scope will be used either.
2764    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2765    /// for details).
2766    pub fn clear_scopes(mut self) -> InstanceGroupManagerInsertCall<'a, C> {
2767        self._scopes.clear();
2768        self
2769    }
2770}
2771
2772/// Retrieves the list of Instance Group Manager resources contained within the specified zone.
2773///
2774/// A builder for the *list* method supported by a *instanceGroupManager* resource.
2775/// It is not used directly, but through a [`InstanceGroupManagerMethods`] instance.
2776///
2777/// # Example
2778///
2779/// Instantiate a resource method builder
2780///
2781/// ```test_harness,no_run
2782/// # extern crate hyper;
2783/// # extern crate hyper_rustls;
2784/// # extern crate google_replicapool1_beta2 as replicapool1_beta2;
2785/// # async fn dox() {
2786/// # use replicapool1_beta2::{Replicapool, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2787///
2788/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2789/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2790/// #     .with_native_roots()
2791/// #     .unwrap()
2792/// #     .https_only()
2793/// #     .enable_http2()
2794/// #     .build();
2795///
2796/// # let executor = hyper_util::rt::TokioExecutor::new();
2797/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2798/// #     secret,
2799/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2800/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2801/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2802/// #     ),
2803/// # ).build().await.unwrap();
2804///
2805/// # let client = hyper_util::client::legacy::Client::builder(
2806/// #     hyper_util::rt::TokioExecutor::new()
2807/// # )
2808/// # .build(
2809/// #     hyper_rustls::HttpsConnectorBuilder::new()
2810/// #         .with_native_roots()
2811/// #         .unwrap()
2812/// #         .https_or_http()
2813/// #         .enable_http2()
2814/// #         .build()
2815/// # );
2816/// # let mut hub = Replicapool::new(client, auth);
2817/// // You can configure optional parameters by calling the respective setters at will, and
2818/// // execute the final call using `doit()`.
2819/// // Values shown here are possibly random and not representative !
2820/// let result = hub.instance_group_managers().list("project", "zone")
2821///              .page_token("gubergren")
2822///              .max_results(84)
2823///              .filter("dolor")
2824///              .doit().await;
2825/// # }
2826/// ```
2827pub struct InstanceGroupManagerListCall<'a, C>
2828where
2829    C: 'a,
2830{
2831    hub: &'a Replicapool<C>,
2832    _project: String,
2833    _zone: String,
2834    _page_token: Option<String>,
2835    _max_results: Option<u32>,
2836    _filter: Option<String>,
2837    _delegate: Option<&'a mut dyn common::Delegate>,
2838    _additional_params: HashMap<String, String>,
2839    _scopes: BTreeSet<String>,
2840}
2841
2842impl<'a, C> common::CallBuilder for InstanceGroupManagerListCall<'a, C> {}
2843
2844impl<'a, C> InstanceGroupManagerListCall<'a, C>
2845where
2846    C: common::Connector,
2847{
2848    /// Perform the operation you have build so far.
2849    pub async fn doit(mut self) -> common::Result<(common::Response, InstanceGroupManagerList)> {
2850        use std::borrow::Cow;
2851        use std::io::{Read, Seek};
2852
2853        use common::{url::Params, ToParts};
2854        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2855
2856        let mut dd = common::DefaultDelegate;
2857        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2858        dlg.begin(common::MethodInfo {
2859            id: "replicapool.instanceGroupManagers.list",
2860            http_method: hyper::Method::GET,
2861        });
2862
2863        for &field in [
2864            "alt",
2865            "project",
2866            "zone",
2867            "pageToken",
2868            "maxResults",
2869            "filter",
2870        ]
2871        .iter()
2872        {
2873            if self._additional_params.contains_key(field) {
2874                dlg.finished(false);
2875                return Err(common::Error::FieldClash(field));
2876            }
2877        }
2878
2879        let mut params = Params::with_capacity(7 + self._additional_params.len());
2880        params.push("project", self._project);
2881        params.push("zone", self._zone);
2882        if let Some(value) = self._page_token.as_ref() {
2883            params.push("pageToken", value);
2884        }
2885        if let Some(value) = self._max_results.as_ref() {
2886            params.push("maxResults", value.to_string());
2887        }
2888        if let Some(value) = self._filter.as_ref() {
2889            params.push("filter", value);
2890        }
2891
2892        params.extend(self._additional_params.iter());
2893
2894        params.push("alt", "json");
2895        let mut url = self.hub._base_url.clone() + "{project}/zones/{zone}/instanceGroupManagers";
2896        if self._scopes.is_empty() {
2897            self._scopes
2898                .insert(Scope::ComputeReadonly.as_ref().to_string());
2899        }
2900
2901        #[allow(clippy::single_element_loop)]
2902        for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() {
2903            url = params.uri_replacement(url, param_name, find_this, false);
2904        }
2905        {
2906            let to_remove = ["zone", "project"];
2907            params.remove_params(&to_remove);
2908        }
2909
2910        let url = params.parse_with_url(&url);
2911
2912        loop {
2913            let token = match self
2914                .hub
2915                .auth
2916                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2917                .await
2918            {
2919                Ok(token) => token,
2920                Err(e) => match dlg.token(e) {
2921                    Ok(token) => token,
2922                    Err(e) => {
2923                        dlg.finished(false);
2924                        return Err(common::Error::MissingToken(e));
2925                    }
2926                },
2927            };
2928            let mut req_result = {
2929                let client = &self.hub.client;
2930                dlg.pre_request();
2931                let mut req_builder = hyper::Request::builder()
2932                    .method(hyper::Method::GET)
2933                    .uri(url.as_str())
2934                    .header(USER_AGENT, self.hub._user_agent.clone());
2935
2936                if let Some(token) = token.as_ref() {
2937                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2938                }
2939
2940                let request = req_builder
2941                    .header(CONTENT_LENGTH, 0_u64)
2942                    .body(common::to_body::<String>(None));
2943
2944                client.request(request.unwrap()).await
2945            };
2946
2947            match req_result {
2948                Err(err) => {
2949                    if let common::Retry::After(d) = dlg.http_error(&err) {
2950                        sleep(d).await;
2951                        continue;
2952                    }
2953                    dlg.finished(false);
2954                    return Err(common::Error::HttpError(err));
2955                }
2956                Ok(res) => {
2957                    let (mut parts, body) = res.into_parts();
2958                    let mut body = common::Body::new(body);
2959                    if !parts.status.is_success() {
2960                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2961                        let error = serde_json::from_str(&common::to_string(&bytes));
2962                        let response = common::to_response(parts, bytes.into());
2963
2964                        if let common::Retry::After(d) =
2965                            dlg.http_failure(&response, error.as_ref().ok())
2966                        {
2967                            sleep(d).await;
2968                            continue;
2969                        }
2970
2971                        dlg.finished(false);
2972
2973                        return Err(match error {
2974                            Ok(value) => common::Error::BadRequest(value),
2975                            _ => common::Error::Failure(response),
2976                        });
2977                    }
2978                    let response = {
2979                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2980                        let encoded = common::to_string(&bytes);
2981                        match serde_json::from_str(&encoded) {
2982                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2983                            Err(error) => {
2984                                dlg.response_json_decode_error(&encoded, &error);
2985                                return Err(common::Error::JsonDecodeError(
2986                                    encoded.to_string(),
2987                                    error,
2988                                ));
2989                            }
2990                        }
2991                    };
2992
2993                    dlg.finished(true);
2994                    return Ok(response);
2995                }
2996            }
2997        }
2998    }
2999
3000    /// The Google Developers Console project name.
3001    ///
3002    /// Sets the *project* path property to the given value.
3003    ///
3004    /// Even though the property as already been set when instantiating this call,
3005    /// we provide this method for API completeness.
3006    pub fn project(mut self, new_value: &str) -> InstanceGroupManagerListCall<'a, C> {
3007        self._project = new_value.to_string();
3008        self
3009    }
3010    /// The name of the zone in which the instance group manager resides.
3011    ///
3012    /// Sets the *zone* path property to the given value.
3013    ///
3014    /// Even though the property as already been set when instantiating this call,
3015    /// we provide this method for API completeness.
3016    pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerListCall<'a, C> {
3017        self._zone = new_value.to_string();
3018        self
3019    }
3020    /// Optional. Tag returned by a previous list request truncated by maxResults. Used to continue a previous list request.
3021    ///
3022    /// Sets the *page token* query property to the given value.
3023    pub fn page_token(mut self, new_value: &str) -> InstanceGroupManagerListCall<'a, C> {
3024        self._page_token = Some(new_value.to_string());
3025        self
3026    }
3027    /// Optional. Maximum count of results to be returned. Maximum value is 500 and default value is 500.
3028    ///
3029    /// Sets the *max results* query property to the given value.
3030    pub fn max_results(mut self, new_value: u32) -> InstanceGroupManagerListCall<'a, C> {
3031        self._max_results = Some(new_value);
3032        self
3033    }
3034    /// Optional. Filter expression for filtering listed resources.
3035    ///
3036    /// Sets the *filter* query property to the given value.
3037    pub fn filter(mut self, new_value: &str) -> InstanceGroupManagerListCall<'a, C> {
3038        self._filter = Some(new_value.to_string());
3039        self
3040    }
3041    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3042    /// while executing the actual API request.
3043    ///
3044    /// ````text
3045    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3046    /// ````
3047    ///
3048    /// Sets the *delegate* property to the given value.
3049    pub fn delegate(
3050        mut self,
3051        new_value: &'a mut dyn common::Delegate,
3052    ) -> InstanceGroupManagerListCall<'a, C> {
3053        self._delegate = Some(new_value);
3054        self
3055    }
3056
3057    /// Set any additional parameter of the query string used in the request.
3058    /// It should be used to set parameters which are not yet available through their own
3059    /// setters.
3060    ///
3061    /// Please note that this method must not be used to set any of the known parameters
3062    /// which have their own setter method. If done anyway, the request will fail.
3063    ///
3064    /// # Additional Parameters
3065    ///
3066    /// * *alt* (query-string) - Data format for the response.
3067    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3068    /// * *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.
3069    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3070    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3071    /// * *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. Overrides userIp if both are provided.
3072    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
3073    pub fn param<T>(mut self, name: T, value: T) -> InstanceGroupManagerListCall<'a, C>
3074    where
3075        T: AsRef<str>,
3076    {
3077        self._additional_params
3078            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3079        self
3080    }
3081
3082    /// Identifies the authorization scope for the method you are building.
3083    ///
3084    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3085    /// [`Scope::ComputeReadonly`].
3086    ///
3087    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3088    /// tokens for more than one scope.
3089    ///
3090    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3091    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3092    /// sufficient, a read-write scope will do as well.
3093    pub fn add_scope<St>(mut self, scope: St) -> InstanceGroupManagerListCall<'a, C>
3094    where
3095        St: AsRef<str>,
3096    {
3097        self._scopes.insert(String::from(scope.as_ref()));
3098        self
3099    }
3100    /// Identifies the authorization scope(s) for the method you are building.
3101    ///
3102    /// See [`Self::add_scope()`] for details.
3103    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceGroupManagerListCall<'a, C>
3104    where
3105        I: IntoIterator<Item = St>,
3106        St: AsRef<str>,
3107    {
3108        self._scopes
3109            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3110        self
3111    }
3112
3113    /// Removes all scopes, and no default scope will be used either.
3114    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3115    /// for details).
3116    pub fn clear_scopes(mut self) -> InstanceGroupManagerListCall<'a, C> {
3117        self._scopes.clear();
3118        self
3119    }
3120}
3121
3122/// Recreates the specified instances. The instances are deleted, then recreated using the instance group manager's current instance template.
3123///
3124/// A builder for the *recreateInstances* method supported by a *instanceGroupManager* resource.
3125/// It is not used directly, but through a [`InstanceGroupManagerMethods`] instance.
3126///
3127/// # Example
3128///
3129/// Instantiate a resource method builder
3130///
3131/// ```test_harness,no_run
3132/// # extern crate hyper;
3133/// # extern crate hyper_rustls;
3134/// # extern crate google_replicapool1_beta2 as replicapool1_beta2;
3135/// use replicapool1_beta2::api::InstanceGroupManagersRecreateInstancesRequest;
3136/// # async fn dox() {
3137/// # use replicapool1_beta2::{Replicapool, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3138///
3139/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3140/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3141/// #     .with_native_roots()
3142/// #     .unwrap()
3143/// #     .https_only()
3144/// #     .enable_http2()
3145/// #     .build();
3146///
3147/// # let executor = hyper_util::rt::TokioExecutor::new();
3148/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3149/// #     secret,
3150/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3151/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3152/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3153/// #     ),
3154/// # ).build().await.unwrap();
3155///
3156/// # let client = hyper_util::client::legacy::Client::builder(
3157/// #     hyper_util::rt::TokioExecutor::new()
3158/// # )
3159/// # .build(
3160/// #     hyper_rustls::HttpsConnectorBuilder::new()
3161/// #         .with_native_roots()
3162/// #         .unwrap()
3163/// #         .https_or_http()
3164/// #         .enable_http2()
3165/// #         .build()
3166/// # );
3167/// # let mut hub = Replicapool::new(client, auth);
3168/// // As the method needs a request, you would usually fill it with the desired information
3169/// // into the respective structure. Some of the parts shown here might not be applicable !
3170/// // Values shown here are possibly random and not representative !
3171/// let mut req = InstanceGroupManagersRecreateInstancesRequest::default();
3172///
3173/// // You can configure optional parameters by calling the respective setters at will, and
3174/// // execute the final call using `doit()`.
3175/// // Values shown here are possibly random and not representative !
3176/// let result = hub.instance_group_managers().recreate_instances(req, "project", "zone", "instanceGroupManager")
3177///              .doit().await;
3178/// # }
3179/// ```
3180pub struct InstanceGroupManagerRecreateInstanceCall<'a, C>
3181where
3182    C: 'a,
3183{
3184    hub: &'a Replicapool<C>,
3185    _request: InstanceGroupManagersRecreateInstancesRequest,
3186    _project: String,
3187    _zone: String,
3188    _instance_group_manager: String,
3189    _delegate: Option<&'a mut dyn common::Delegate>,
3190    _additional_params: HashMap<String, String>,
3191    _scopes: BTreeSet<String>,
3192}
3193
3194impl<'a, C> common::CallBuilder for InstanceGroupManagerRecreateInstanceCall<'a, C> {}
3195
3196impl<'a, C> InstanceGroupManagerRecreateInstanceCall<'a, C>
3197where
3198    C: common::Connector,
3199{
3200    /// Perform the operation you have build so far.
3201    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3202        use std::borrow::Cow;
3203        use std::io::{Read, Seek};
3204
3205        use common::{url::Params, ToParts};
3206        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3207
3208        let mut dd = common::DefaultDelegate;
3209        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3210        dlg.begin(common::MethodInfo {
3211            id: "replicapool.instanceGroupManagers.recreateInstances",
3212            http_method: hyper::Method::POST,
3213        });
3214
3215        for &field in ["alt", "project", "zone", "instanceGroupManager"].iter() {
3216            if self._additional_params.contains_key(field) {
3217                dlg.finished(false);
3218                return Err(common::Error::FieldClash(field));
3219            }
3220        }
3221
3222        let mut params = Params::with_capacity(6 + self._additional_params.len());
3223        params.push("project", self._project);
3224        params.push("zone", self._zone);
3225        params.push("instanceGroupManager", self._instance_group_manager);
3226
3227        params.extend(self._additional_params.iter());
3228
3229        params.push("alt", "json");
3230        let mut url = self.hub._base_url.clone() + "{project}/zones/{zone}/instanceGroupManagers/{instanceGroupManager}/recreateInstances";
3231        if self._scopes.is_empty() {
3232            self._scopes
3233                .insert(Scope::CloudPlatform.as_ref().to_string());
3234        }
3235
3236        #[allow(clippy::single_element_loop)]
3237        for &(find_this, param_name) in [
3238            ("{project}", "project"),
3239            ("{zone}", "zone"),
3240            ("{instanceGroupManager}", "instanceGroupManager"),
3241        ]
3242        .iter()
3243        {
3244            url = params.uri_replacement(url, param_name, find_this, false);
3245        }
3246        {
3247            let to_remove = ["instanceGroupManager", "zone", "project"];
3248            params.remove_params(&to_remove);
3249        }
3250
3251        let url = params.parse_with_url(&url);
3252
3253        let mut json_mime_type = mime::APPLICATION_JSON;
3254        let mut request_value_reader = {
3255            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3256            common::remove_json_null_values(&mut value);
3257            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3258            serde_json::to_writer(&mut dst, &value).unwrap();
3259            dst
3260        };
3261        let request_size = request_value_reader
3262            .seek(std::io::SeekFrom::End(0))
3263            .unwrap();
3264        request_value_reader
3265            .seek(std::io::SeekFrom::Start(0))
3266            .unwrap();
3267
3268        loop {
3269            let token = match self
3270                .hub
3271                .auth
3272                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3273                .await
3274            {
3275                Ok(token) => token,
3276                Err(e) => match dlg.token(e) {
3277                    Ok(token) => token,
3278                    Err(e) => {
3279                        dlg.finished(false);
3280                        return Err(common::Error::MissingToken(e));
3281                    }
3282                },
3283            };
3284            request_value_reader
3285                .seek(std::io::SeekFrom::Start(0))
3286                .unwrap();
3287            let mut req_result = {
3288                let client = &self.hub.client;
3289                dlg.pre_request();
3290                let mut req_builder = hyper::Request::builder()
3291                    .method(hyper::Method::POST)
3292                    .uri(url.as_str())
3293                    .header(USER_AGENT, self.hub._user_agent.clone());
3294
3295                if let Some(token) = token.as_ref() {
3296                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3297                }
3298
3299                let request = req_builder
3300                    .header(CONTENT_TYPE, json_mime_type.to_string())
3301                    .header(CONTENT_LENGTH, request_size as u64)
3302                    .body(common::to_body(
3303                        request_value_reader.get_ref().clone().into(),
3304                    ));
3305
3306                client.request(request.unwrap()).await
3307            };
3308
3309            match req_result {
3310                Err(err) => {
3311                    if let common::Retry::After(d) = dlg.http_error(&err) {
3312                        sleep(d).await;
3313                        continue;
3314                    }
3315                    dlg.finished(false);
3316                    return Err(common::Error::HttpError(err));
3317                }
3318                Ok(res) => {
3319                    let (mut parts, body) = res.into_parts();
3320                    let mut body = common::Body::new(body);
3321                    if !parts.status.is_success() {
3322                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3323                        let error = serde_json::from_str(&common::to_string(&bytes));
3324                        let response = common::to_response(parts, bytes.into());
3325
3326                        if let common::Retry::After(d) =
3327                            dlg.http_failure(&response, error.as_ref().ok())
3328                        {
3329                            sleep(d).await;
3330                            continue;
3331                        }
3332
3333                        dlg.finished(false);
3334
3335                        return Err(match error {
3336                            Ok(value) => common::Error::BadRequest(value),
3337                            _ => common::Error::Failure(response),
3338                        });
3339                    }
3340                    let response = {
3341                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3342                        let encoded = common::to_string(&bytes);
3343                        match serde_json::from_str(&encoded) {
3344                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3345                            Err(error) => {
3346                                dlg.response_json_decode_error(&encoded, &error);
3347                                return Err(common::Error::JsonDecodeError(
3348                                    encoded.to_string(),
3349                                    error,
3350                                ));
3351                            }
3352                        }
3353                    };
3354
3355                    dlg.finished(true);
3356                    return Ok(response);
3357                }
3358            }
3359        }
3360    }
3361
3362    ///
3363    /// Sets the *request* property to the given value.
3364    ///
3365    /// Even though the property as already been set when instantiating this call,
3366    /// we provide this method for API completeness.
3367    pub fn request(
3368        mut self,
3369        new_value: InstanceGroupManagersRecreateInstancesRequest,
3370    ) -> InstanceGroupManagerRecreateInstanceCall<'a, C> {
3371        self._request = new_value;
3372        self
3373    }
3374    /// The Google Developers Console project name.
3375    ///
3376    /// Sets the *project* path property to the given value.
3377    ///
3378    /// Even though the property as already been set when instantiating this call,
3379    /// we provide this method for API completeness.
3380    pub fn project(mut self, new_value: &str) -> InstanceGroupManagerRecreateInstanceCall<'a, C> {
3381        self._project = new_value.to_string();
3382        self
3383    }
3384    /// The name of the zone in which the instance group manager resides.
3385    ///
3386    /// Sets the *zone* path property to the given value.
3387    ///
3388    /// Even though the property as already been set when instantiating this call,
3389    /// we provide this method for API completeness.
3390    pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerRecreateInstanceCall<'a, C> {
3391        self._zone = new_value.to_string();
3392        self
3393    }
3394    /// The name of the instance group manager.
3395    ///
3396    /// Sets the *instance group manager* path property to the given value.
3397    ///
3398    /// Even though the property as already been set when instantiating this call,
3399    /// we provide this method for API completeness.
3400    pub fn instance_group_manager(
3401        mut self,
3402        new_value: &str,
3403    ) -> InstanceGroupManagerRecreateInstanceCall<'a, C> {
3404        self._instance_group_manager = new_value.to_string();
3405        self
3406    }
3407    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3408    /// while executing the actual API request.
3409    ///
3410    /// ````text
3411    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3412    /// ````
3413    ///
3414    /// Sets the *delegate* property to the given value.
3415    pub fn delegate(
3416        mut self,
3417        new_value: &'a mut dyn common::Delegate,
3418    ) -> InstanceGroupManagerRecreateInstanceCall<'a, C> {
3419        self._delegate = Some(new_value);
3420        self
3421    }
3422
3423    /// Set any additional parameter of the query string used in the request.
3424    /// It should be used to set parameters which are not yet available through their own
3425    /// setters.
3426    ///
3427    /// Please note that this method must not be used to set any of the known parameters
3428    /// which have their own setter method. If done anyway, the request will fail.
3429    ///
3430    /// # Additional Parameters
3431    ///
3432    /// * *alt* (query-string) - Data format for the response.
3433    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3434    /// * *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.
3435    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3436    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3437    /// * *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. Overrides userIp if both are provided.
3438    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
3439    pub fn param<T>(mut self, name: T, value: T) -> InstanceGroupManagerRecreateInstanceCall<'a, C>
3440    where
3441        T: AsRef<str>,
3442    {
3443        self._additional_params
3444            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3445        self
3446    }
3447
3448    /// Identifies the authorization scope for the method you are building.
3449    ///
3450    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3451    /// [`Scope::CloudPlatform`].
3452    ///
3453    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3454    /// tokens for more than one scope.
3455    ///
3456    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3457    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3458    /// sufficient, a read-write scope will do as well.
3459    pub fn add_scope<St>(mut self, scope: St) -> InstanceGroupManagerRecreateInstanceCall<'a, C>
3460    where
3461        St: AsRef<str>,
3462    {
3463        self._scopes.insert(String::from(scope.as_ref()));
3464        self
3465    }
3466    /// Identifies the authorization scope(s) for the method you are building.
3467    ///
3468    /// See [`Self::add_scope()`] for details.
3469    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceGroupManagerRecreateInstanceCall<'a, C>
3470    where
3471        I: IntoIterator<Item = St>,
3472        St: AsRef<str>,
3473    {
3474        self._scopes
3475            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3476        self
3477    }
3478
3479    /// Removes all scopes, and no default scope will be used either.
3480    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3481    /// for details).
3482    pub fn clear_scopes(mut self) -> InstanceGroupManagerRecreateInstanceCall<'a, C> {
3483        self._scopes.clear();
3484        self
3485    }
3486}
3487
3488/// Resizes the managed instance group up or down. If resized up, new instances are created using the current instance template. If resized down, instances are removed in the order outlined in Resizing a managed instance group.
3489///
3490/// A builder for the *resize* method supported by a *instanceGroupManager* resource.
3491/// It is not used directly, but through a [`InstanceGroupManagerMethods`] instance.
3492///
3493/// # Example
3494///
3495/// Instantiate a resource method builder
3496///
3497/// ```test_harness,no_run
3498/// # extern crate hyper;
3499/// # extern crate hyper_rustls;
3500/// # extern crate google_replicapool1_beta2 as replicapool1_beta2;
3501/// # async fn dox() {
3502/// # use replicapool1_beta2::{Replicapool, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3503///
3504/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3505/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3506/// #     .with_native_roots()
3507/// #     .unwrap()
3508/// #     .https_only()
3509/// #     .enable_http2()
3510/// #     .build();
3511///
3512/// # let executor = hyper_util::rt::TokioExecutor::new();
3513/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3514/// #     secret,
3515/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3516/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3517/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3518/// #     ),
3519/// # ).build().await.unwrap();
3520///
3521/// # let client = hyper_util::client::legacy::Client::builder(
3522/// #     hyper_util::rt::TokioExecutor::new()
3523/// # )
3524/// # .build(
3525/// #     hyper_rustls::HttpsConnectorBuilder::new()
3526/// #         .with_native_roots()
3527/// #         .unwrap()
3528/// #         .https_or_http()
3529/// #         .enable_http2()
3530/// #         .build()
3531/// # );
3532/// # let mut hub = Replicapool::new(client, auth);
3533/// // You can configure optional parameters by calling the respective setters at will, and
3534/// // execute the final call using `doit()`.
3535/// // Values shown here are possibly random and not representative !
3536/// let result = hub.instance_group_managers().resize("project", "zone", "instanceGroupManager", -61)
3537///              .doit().await;
3538/// # }
3539/// ```
3540pub struct InstanceGroupManagerResizeCall<'a, C>
3541where
3542    C: 'a,
3543{
3544    hub: &'a Replicapool<C>,
3545    _project: String,
3546    _zone: String,
3547    _instance_group_manager: String,
3548    _size: i32,
3549    _delegate: Option<&'a mut dyn common::Delegate>,
3550    _additional_params: HashMap<String, String>,
3551    _scopes: BTreeSet<String>,
3552}
3553
3554impl<'a, C> common::CallBuilder for InstanceGroupManagerResizeCall<'a, C> {}
3555
3556impl<'a, C> InstanceGroupManagerResizeCall<'a, C>
3557where
3558    C: common::Connector,
3559{
3560    /// Perform the operation you have build so far.
3561    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3562        use std::borrow::Cow;
3563        use std::io::{Read, Seek};
3564
3565        use common::{url::Params, ToParts};
3566        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3567
3568        let mut dd = common::DefaultDelegate;
3569        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3570        dlg.begin(common::MethodInfo {
3571            id: "replicapool.instanceGroupManagers.resize",
3572            http_method: hyper::Method::POST,
3573        });
3574
3575        for &field in ["alt", "project", "zone", "instanceGroupManager", "size"].iter() {
3576            if self._additional_params.contains_key(field) {
3577                dlg.finished(false);
3578                return Err(common::Error::FieldClash(field));
3579            }
3580        }
3581
3582        let mut params = Params::with_capacity(6 + self._additional_params.len());
3583        params.push("project", self._project);
3584        params.push("zone", self._zone);
3585        params.push("instanceGroupManager", self._instance_group_manager);
3586        params.push("size", self._size.to_string());
3587
3588        params.extend(self._additional_params.iter());
3589
3590        params.push("alt", "json");
3591        let mut url = self.hub._base_url.clone()
3592            + "{project}/zones/{zone}/instanceGroupManagers/{instanceGroupManager}/resize";
3593        if self._scopes.is_empty() {
3594            self._scopes
3595                .insert(Scope::CloudPlatform.as_ref().to_string());
3596        }
3597
3598        #[allow(clippy::single_element_loop)]
3599        for &(find_this, param_name) in [
3600            ("{project}", "project"),
3601            ("{zone}", "zone"),
3602            ("{instanceGroupManager}", "instanceGroupManager"),
3603        ]
3604        .iter()
3605        {
3606            url = params.uri_replacement(url, param_name, find_this, false);
3607        }
3608        {
3609            let to_remove = ["instanceGroupManager", "zone", "project"];
3610            params.remove_params(&to_remove);
3611        }
3612
3613        let url = params.parse_with_url(&url);
3614
3615        loop {
3616            let token = match self
3617                .hub
3618                .auth
3619                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3620                .await
3621            {
3622                Ok(token) => token,
3623                Err(e) => match dlg.token(e) {
3624                    Ok(token) => token,
3625                    Err(e) => {
3626                        dlg.finished(false);
3627                        return Err(common::Error::MissingToken(e));
3628                    }
3629                },
3630            };
3631            let mut req_result = {
3632                let client = &self.hub.client;
3633                dlg.pre_request();
3634                let mut req_builder = hyper::Request::builder()
3635                    .method(hyper::Method::POST)
3636                    .uri(url.as_str())
3637                    .header(USER_AGENT, self.hub._user_agent.clone());
3638
3639                if let Some(token) = token.as_ref() {
3640                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3641                }
3642
3643                let request = req_builder
3644                    .header(CONTENT_LENGTH, 0_u64)
3645                    .body(common::to_body::<String>(None));
3646
3647                client.request(request.unwrap()).await
3648            };
3649
3650            match req_result {
3651                Err(err) => {
3652                    if let common::Retry::After(d) = dlg.http_error(&err) {
3653                        sleep(d).await;
3654                        continue;
3655                    }
3656                    dlg.finished(false);
3657                    return Err(common::Error::HttpError(err));
3658                }
3659                Ok(res) => {
3660                    let (mut parts, body) = res.into_parts();
3661                    let mut body = common::Body::new(body);
3662                    if !parts.status.is_success() {
3663                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3664                        let error = serde_json::from_str(&common::to_string(&bytes));
3665                        let response = common::to_response(parts, bytes.into());
3666
3667                        if let common::Retry::After(d) =
3668                            dlg.http_failure(&response, error.as_ref().ok())
3669                        {
3670                            sleep(d).await;
3671                            continue;
3672                        }
3673
3674                        dlg.finished(false);
3675
3676                        return Err(match error {
3677                            Ok(value) => common::Error::BadRequest(value),
3678                            _ => common::Error::Failure(response),
3679                        });
3680                    }
3681                    let response = {
3682                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3683                        let encoded = common::to_string(&bytes);
3684                        match serde_json::from_str(&encoded) {
3685                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3686                            Err(error) => {
3687                                dlg.response_json_decode_error(&encoded, &error);
3688                                return Err(common::Error::JsonDecodeError(
3689                                    encoded.to_string(),
3690                                    error,
3691                                ));
3692                            }
3693                        }
3694                    };
3695
3696                    dlg.finished(true);
3697                    return Ok(response);
3698                }
3699            }
3700        }
3701    }
3702
3703    /// The Google Developers Console project name.
3704    ///
3705    /// Sets the *project* path property to the given value.
3706    ///
3707    /// Even though the property as already been set when instantiating this call,
3708    /// we provide this method for API completeness.
3709    pub fn project(mut self, new_value: &str) -> InstanceGroupManagerResizeCall<'a, C> {
3710        self._project = new_value.to_string();
3711        self
3712    }
3713    /// The name of the zone in which the instance group manager resides.
3714    ///
3715    /// Sets the *zone* path property to the given value.
3716    ///
3717    /// Even though the property as already been set when instantiating this call,
3718    /// we provide this method for API completeness.
3719    pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerResizeCall<'a, C> {
3720        self._zone = new_value.to_string();
3721        self
3722    }
3723    /// The name of the instance group manager.
3724    ///
3725    /// Sets the *instance group manager* path property to the given value.
3726    ///
3727    /// Even though the property as already been set when instantiating this call,
3728    /// we provide this method for API completeness.
3729    pub fn instance_group_manager(
3730        mut self,
3731        new_value: &str,
3732    ) -> InstanceGroupManagerResizeCall<'a, C> {
3733        self._instance_group_manager = new_value.to_string();
3734        self
3735    }
3736    /// Number of instances that should exist in this Instance Group Manager.
3737    ///
3738    /// Sets the *size* query property to the given value.
3739    ///
3740    /// Even though the property as already been set when instantiating this call,
3741    /// we provide this method for API completeness.
3742    pub fn size(mut self, new_value: i32) -> InstanceGroupManagerResizeCall<'a, C> {
3743        self._size = new_value;
3744        self
3745    }
3746    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3747    /// while executing the actual API request.
3748    ///
3749    /// ````text
3750    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3751    /// ````
3752    ///
3753    /// Sets the *delegate* property to the given value.
3754    pub fn delegate(
3755        mut self,
3756        new_value: &'a mut dyn common::Delegate,
3757    ) -> InstanceGroupManagerResizeCall<'a, C> {
3758        self._delegate = Some(new_value);
3759        self
3760    }
3761
3762    /// Set any additional parameter of the query string used in the request.
3763    /// It should be used to set parameters which are not yet available through their own
3764    /// setters.
3765    ///
3766    /// Please note that this method must not be used to set any of the known parameters
3767    /// which have their own setter method. If done anyway, the request will fail.
3768    ///
3769    /// # Additional Parameters
3770    ///
3771    /// * *alt* (query-string) - Data format for the response.
3772    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3773    /// * *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.
3774    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3775    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3776    /// * *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. Overrides userIp if both are provided.
3777    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
3778    pub fn param<T>(mut self, name: T, value: T) -> InstanceGroupManagerResizeCall<'a, C>
3779    where
3780        T: AsRef<str>,
3781    {
3782        self._additional_params
3783            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3784        self
3785    }
3786
3787    /// Identifies the authorization scope for the method you are building.
3788    ///
3789    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3790    /// [`Scope::CloudPlatform`].
3791    ///
3792    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3793    /// tokens for more than one scope.
3794    ///
3795    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3796    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3797    /// sufficient, a read-write scope will do as well.
3798    pub fn add_scope<St>(mut self, scope: St) -> InstanceGroupManagerResizeCall<'a, C>
3799    where
3800        St: AsRef<str>,
3801    {
3802        self._scopes.insert(String::from(scope.as_ref()));
3803        self
3804    }
3805    /// Identifies the authorization scope(s) for the method you are building.
3806    ///
3807    /// See [`Self::add_scope()`] for details.
3808    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceGroupManagerResizeCall<'a, C>
3809    where
3810        I: IntoIterator<Item = St>,
3811        St: AsRef<str>,
3812    {
3813        self._scopes
3814            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3815        self
3816    }
3817
3818    /// Removes all scopes, and no default scope will be used either.
3819    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3820    /// for details).
3821    pub fn clear_scopes(mut self) -> InstanceGroupManagerResizeCall<'a, C> {
3822        self._scopes.clear();
3823        self
3824    }
3825}
3826
3827/// Sets the instance template to use when creating new instances in this group. Existing instances are not affected.
3828///
3829/// A builder for the *setInstanceTemplate* method supported by a *instanceGroupManager* resource.
3830/// It is not used directly, but through a [`InstanceGroupManagerMethods`] instance.
3831///
3832/// # Example
3833///
3834/// Instantiate a resource method builder
3835///
3836/// ```test_harness,no_run
3837/// # extern crate hyper;
3838/// # extern crate hyper_rustls;
3839/// # extern crate google_replicapool1_beta2 as replicapool1_beta2;
3840/// use replicapool1_beta2::api::InstanceGroupManagersSetInstanceTemplateRequest;
3841/// # async fn dox() {
3842/// # use replicapool1_beta2::{Replicapool, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3843///
3844/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3845/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3846/// #     .with_native_roots()
3847/// #     .unwrap()
3848/// #     .https_only()
3849/// #     .enable_http2()
3850/// #     .build();
3851///
3852/// # let executor = hyper_util::rt::TokioExecutor::new();
3853/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3854/// #     secret,
3855/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3856/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3857/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3858/// #     ),
3859/// # ).build().await.unwrap();
3860///
3861/// # let client = hyper_util::client::legacy::Client::builder(
3862/// #     hyper_util::rt::TokioExecutor::new()
3863/// # )
3864/// # .build(
3865/// #     hyper_rustls::HttpsConnectorBuilder::new()
3866/// #         .with_native_roots()
3867/// #         .unwrap()
3868/// #         .https_or_http()
3869/// #         .enable_http2()
3870/// #         .build()
3871/// # );
3872/// # let mut hub = Replicapool::new(client, auth);
3873/// // As the method needs a request, you would usually fill it with the desired information
3874/// // into the respective structure. Some of the parts shown here might not be applicable !
3875/// // Values shown here are possibly random and not representative !
3876/// let mut req = InstanceGroupManagersSetInstanceTemplateRequest::default();
3877///
3878/// // You can configure optional parameters by calling the respective setters at will, and
3879/// // execute the final call using `doit()`.
3880/// // Values shown here are possibly random and not representative !
3881/// let result = hub.instance_group_managers().set_instance_template(req, "project", "zone", "instanceGroupManager")
3882///              .doit().await;
3883/// # }
3884/// ```
3885pub struct InstanceGroupManagerSetInstanceTemplateCall<'a, C>
3886where
3887    C: 'a,
3888{
3889    hub: &'a Replicapool<C>,
3890    _request: InstanceGroupManagersSetInstanceTemplateRequest,
3891    _project: String,
3892    _zone: String,
3893    _instance_group_manager: String,
3894    _delegate: Option<&'a mut dyn common::Delegate>,
3895    _additional_params: HashMap<String, String>,
3896    _scopes: BTreeSet<String>,
3897}
3898
3899impl<'a, C> common::CallBuilder for InstanceGroupManagerSetInstanceTemplateCall<'a, C> {}
3900
3901impl<'a, C> InstanceGroupManagerSetInstanceTemplateCall<'a, C>
3902where
3903    C: common::Connector,
3904{
3905    /// Perform the operation you have build so far.
3906    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3907        use std::borrow::Cow;
3908        use std::io::{Read, Seek};
3909
3910        use common::{url::Params, ToParts};
3911        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3912
3913        let mut dd = common::DefaultDelegate;
3914        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3915        dlg.begin(common::MethodInfo {
3916            id: "replicapool.instanceGroupManagers.setInstanceTemplate",
3917            http_method: hyper::Method::POST,
3918        });
3919
3920        for &field in ["alt", "project", "zone", "instanceGroupManager"].iter() {
3921            if self._additional_params.contains_key(field) {
3922                dlg.finished(false);
3923                return Err(common::Error::FieldClash(field));
3924            }
3925        }
3926
3927        let mut params = Params::with_capacity(6 + self._additional_params.len());
3928        params.push("project", self._project);
3929        params.push("zone", self._zone);
3930        params.push("instanceGroupManager", self._instance_group_manager);
3931
3932        params.extend(self._additional_params.iter());
3933
3934        params.push("alt", "json");
3935        let mut url = self.hub._base_url.clone() + "{project}/zones/{zone}/instanceGroupManagers/{instanceGroupManager}/setInstanceTemplate";
3936        if self._scopes.is_empty() {
3937            self._scopes
3938                .insert(Scope::CloudPlatform.as_ref().to_string());
3939        }
3940
3941        #[allow(clippy::single_element_loop)]
3942        for &(find_this, param_name) in [
3943            ("{project}", "project"),
3944            ("{zone}", "zone"),
3945            ("{instanceGroupManager}", "instanceGroupManager"),
3946        ]
3947        .iter()
3948        {
3949            url = params.uri_replacement(url, param_name, find_this, false);
3950        }
3951        {
3952            let to_remove = ["instanceGroupManager", "zone", "project"];
3953            params.remove_params(&to_remove);
3954        }
3955
3956        let url = params.parse_with_url(&url);
3957
3958        let mut json_mime_type = mime::APPLICATION_JSON;
3959        let mut request_value_reader = {
3960            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3961            common::remove_json_null_values(&mut value);
3962            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3963            serde_json::to_writer(&mut dst, &value).unwrap();
3964            dst
3965        };
3966        let request_size = request_value_reader
3967            .seek(std::io::SeekFrom::End(0))
3968            .unwrap();
3969        request_value_reader
3970            .seek(std::io::SeekFrom::Start(0))
3971            .unwrap();
3972
3973        loop {
3974            let token = match self
3975                .hub
3976                .auth
3977                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3978                .await
3979            {
3980                Ok(token) => token,
3981                Err(e) => match dlg.token(e) {
3982                    Ok(token) => token,
3983                    Err(e) => {
3984                        dlg.finished(false);
3985                        return Err(common::Error::MissingToken(e));
3986                    }
3987                },
3988            };
3989            request_value_reader
3990                .seek(std::io::SeekFrom::Start(0))
3991                .unwrap();
3992            let mut req_result = {
3993                let client = &self.hub.client;
3994                dlg.pre_request();
3995                let mut req_builder = hyper::Request::builder()
3996                    .method(hyper::Method::POST)
3997                    .uri(url.as_str())
3998                    .header(USER_AGENT, self.hub._user_agent.clone());
3999
4000                if let Some(token) = token.as_ref() {
4001                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4002                }
4003
4004                let request = req_builder
4005                    .header(CONTENT_TYPE, json_mime_type.to_string())
4006                    .header(CONTENT_LENGTH, request_size as u64)
4007                    .body(common::to_body(
4008                        request_value_reader.get_ref().clone().into(),
4009                    ));
4010
4011                client.request(request.unwrap()).await
4012            };
4013
4014            match req_result {
4015                Err(err) => {
4016                    if let common::Retry::After(d) = dlg.http_error(&err) {
4017                        sleep(d).await;
4018                        continue;
4019                    }
4020                    dlg.finished(false);
4021                    return Err(common::Error::HttpError(err));
4022                }
4023                Ok(res) => {
4024                    let (mut parts, body) = res.into_parts();
4025                    let mut body = common::Body::new(body);
4026                    if !parts.status.is_success() {
4027                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4028                        let error = serde_json::from_str(&common::to_string(&bytes));
4029                        let response = common::to_response(parts, bytes.into());
4030
4031                        if let common::Retry::After(d) =
4032                            dlg.http_failure(&response, error.as_ref().ok())
4033                        {
4034                            sleep(d).await;
4035                            continue;
4036                        }
4037
4038                        dlg.finished(false);
4039
4040                        return Err(match error {
4041                            Ok(value) => common::Error::BadRequest(value),
4042                            _ => common::Error::Failure(response),
4043                        });
4044                    }
4045                    let response = {
4046                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4047                        let encoded = common::to_string(&bytes);
4048                        match serde_json::from_str(&encoded) {
4049                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4050                            Err(error) => {
4051                                dlg.response_json_decode_error(&encoded, &error);
4052                                return Err(common::Error::JsonDecodeError(
4053                                    encoded.to_string(),
4054                                    error,
4055                                ));
4056                            }
4057                        }
4058                    };
4059
4060                    dlg.finished(true);
4061                    return Ok(response);
4062                }
4063            }
4064        }
4065    }
4066
4067    ///
4068    /// Sets the *request* property to the given value.
4069    ///
4070    /// Even though the property as already been set when instantiating this call,
4071    /// we provide this method for API completeness.
4072    pub fn request(
4073        mut self,
4074        new_value: InstanceGroupManagersSetInstanceTemplateRequest,
4075    ) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C> {
4076        self._request = new_value;
4077        self
4078    }
4079    /// The Google Developers Console project name.
4080    ///
4081    /// Sets the *project* path property to the given value.
4082    ///
4083    /// Even though the property as already been set when instantiating this call,
4084    /// we provide this method for API completeness.
4085    pub fn project(
4086        mut self,
4087        new_value: &str,
4088    ) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C> {
4089        self._project = new_value.to_string();
4090        self
4091    }
4092    /// The name of the zone in which the instance group manager resides.
4093    ///
4094    /// Sets the *zone* path property to the given value.
4095    ///
4096    /// Even though the property as already been set when instantiating this call,
4097    /// we provide this method for API completeness.
4098    pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C> {
4099        self._zone = new_value.to_string();
4100        self
4101    }
4102    /// The name of the instance group manager.
4103    ///
4104    /// Sets the *instance group manager* path property to the given value.
4105    ///
4106    /// Even though the property as already been set when instantiating this call,
4107    /// we provide this method for API completeness.
4108    pub fn instance_group_manager(
4109        mut self,
4110        new_value: &str,
4111    ) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C> {
4112        self._instance_group_manager = new_value.to_string();
4113        self
4114    }
4115    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4116    /// while executing the actual API request.
4117    ///
4118    /// ````text
4119    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4120    /// ````
4121    ///
4122    /// Sets the *delegate* property to the given value.
4123    pub fn delegate(
4124        mut self,
4125        new_value: &'a mut dyn common::Delegate,
4126    ) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C> {
4127        self._delegate = Some(new_value);
4128        self
4129    }
4130
4131    /// Set any additional parameter of the query string used in the request.
4132    /// It should be used to set parameters which are not yet available through their own
4133    /// setters.
4134    ///
4135    /// Please note that this method must not be used to set any of the known parameters
4136    /// which have their own setter method. If done anyway, the request will fail.
4137    ///
4138    /// # Additional Parameters
4139    ///
4140    /// * *alt* (query-string) - Data format for the response.
4141    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4142    /// * *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.
4143    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4144    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4145    /// * *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. Overrides userIp if both are provided.
4146    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
4147    pub fn param<T>(
4148        mut self,
4149        name: T,
4150        value: T,
4151    ) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C>
4152    where
4153        T: AsRef<str>,
4154    {
4155        self._additional_params
4156            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4157        self
4158    }
4159
4160    /// Identifies the authorization scope for the method you are building.
4161    ///
4162    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4163    /// [`Scope::CloudPlatform`].
4164    ///
4165    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4166    /// tokens for more than one scope.
4167    ///
4168    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4169    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4170    /// sufficient, a read-write scope will do as well.
4171    pub fn add_scope<St>(mut self, scope: St) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C>
4172    where
4173        St: AsRef<str>,
4174    {
4175        self._scopes.insert(String::from(scope.as_ref()));
4176        self
4177    }
4178    /// Identifies the authorization scope(s) for the method you are building.
4179    ///
4180    /// See [`Self::add_scope()`] for details.
4181    pub fn add_scopes<I, St>(
4182        mut self,
4183        scopes: I,
4184    ) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C>
4185    where
4186        I: IntoIterator<Item = St>,
4187        St: AsRef<str>,
4188    {
4189        self._scopes
4190            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4191        self
4192    }
4193
4194    /// Removes all scopes, and no default scope will be used either.
4195    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4196    /// for details).
4197    pub fn clear_scopes(mut self) -> InstanceGroupManagerSetInstanceTemplateCall<'a, C> {
4198        self._scopes.clear();
4199        self
4200    }
4201}
4202
4203/// Modifies the target pools to which all new instances in this group are assigned. Existing instances in the group are not affected.
4204///
4205/// A builder for the *setTargetPools* method supported by a *instanceGroupManager* resource.
4206/// It is not used directly, but through a [`InstanceGroupManagerMethods`] instance.
4207///
4208/// # Example
4209///
4210/// Instantiate a resource method builder
4211///
4212/// ```test_harness,no_run
4213/// # extern crate hyper;
4214/// # extern crate hyper_rustls;
4215/// # extern crate google_replicapool1_beta2 as replicapool1_beta2;
4216/// use replicapool1_beta2::api::InstanceGroupManagersSetTargetPoolsRequest;
4217/// # async fn dox() {
4218/// # use replicapool1_beta2::{Replicapool, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4219///
4220/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4221/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4222/// #     .with_native_roots()
4223/// #     .unwrap()
4224/// #     .https_only()
4225/// #     .enable_http2()
4226/// #     .build();
4227///
4228/// # let executor = hyper_util::rt::TokioExecutor::new();
4229/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4230/// #     secret,
4231/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4232/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4233/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4234/// #     ),
4235/// # ).build().await.unwrap();
4236///
4237/// # let client = hyper_util::client::legacy::Client::builder(
4238/// #     hyper_util::rt::TokioExecutor::new()
4239/// # )
4240/// # .build(
4241/// #     hyper_rustls::HttpsConnectorBuilder::new()
4242/// #         .with_native_roots()
4243/// #         .unwrap()
4244/// #         .https_or_http()
4245/// #         .enable_http2()
4246/// #         .build()
4247/// # );
4248/// # let mut hub = Replicapool::new(client, auth);
4249/// // As the method needs a request, you would usually fill it with the desired information
4250/// // into the respective structure. Some of the parts shown here might not be applicable !
4251/// // Values shown here are possibly random and not representative !
4252/// let mut req = InstanceGroupManagersSetTargetPoolsRequest::default();
4253///
4254/// // You can configure optional parameters by calling the respective setters at will, and
4255/// // execute the final call using `doit()`.
4256/// // Values shown here are possibly random and not representative !
4257/// let result = hub.instance_group_managers().set_target_pools(req, "project", "zone", "instanceGroupManager")
4258///              .doit().await;
4259/// # }
4260/// ```
4261pub struct InstanceGroupManagerSetTargetPoolCall<'a, C>
4262where
4263    C: 'a,
4264{
4265    hub: &'a Replicapool<C>,
4266    _request: InstanceGroupManagersSetTargetPoolsRequest,
4267    _project: String,
4268    _zone: String,
4269    _instance_group_manager: String,
4270    _delegate: Option<&'a mut dyn common::Delegate>,
4271    _additional_params: HashMap<String, String>,
4272    _scopes: BTreeSet<String>,
4273}
4274
4275impl<'a, C> common::CallBuilder for InstanceGroupManagerSetTargetPoolCall<'a, C> {}
4276
4277impl<'a, C> InstanceGroupManagerSetTargetPoolCall<'a, C>
4278where
4279    C: common::Connector,
4280{
4281    /// Perform the operation you have build so far.
4282    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4283        use std::borrow::Cow;
4284        use std::io::{Read, Seek};
4285
4286        use common::{url::Params, ToParts};
4287        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4288
4289        let mut dd = common::DefaultDelegate;
4290        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4291        dlg.begin(common::MethodInfo {
4292            id: "replicapool.instanceGroupManagers.setTargetPools",
4293            http_method: hyper::Method::POST,
4294        });
4295
4296        for &field in ["alt", "project", "zone", "instanceGroupManager"].iter() {
4297            if self._additional_params.contains_key(field) {
4298                dlg.finished(false);
4299                return Err(common::Error::FieldClash(field));
4300            }
4301        }
4302
4303        let mut params = Params::with_capacity(6 + self._additional_params.len());
4304        params.push("project", self._project);
4305        params.push("zone", self._zone);
4306        params.push("instanceGroupManager", self._instance_group_manager);
4307
4308        params.extend(self._additional_params.iter());
4309
4310        params.push("alt", "json");
4311        let mut url = self.hub._base_url.clone()
4312            + "{project}/zones/{zone}/instanceGroupManagers/{instanceGroupManager}/setTargetPools";
4313        if self._scopes.is_empty() {
4314            self._scopes
4315                .insert(Scope::CloudPlatform.as_ref().to_string());
4316        }
4317
4318        #[allow(clippy::single_element_loop)]
4319        for &(find_this, param_name) in [
4320            ("{project}", "project"),
4321            ("{zone}", "zone"),
4322            ("{instanceGroupManager}", "instanceGroupManager"),
4323        ]
4324        .iter()
4325        {
4326            url = params.uri_replacement(url, param_name, find_this, false);
4327        }
4328        {
4329            let to_remove = ["instanceGroupManager", "zone", "project"];
4330            params.remove_params(&to_remove);
4331        }
4332
4333        let url = params.parse_with_url(&url);
4334
4335        let mut json_mime_type = mime::APPLICATION_JSON;
4336        let mut request_value_reader = {
4337            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4338            common::remove_json_null_values(&mut value);
4339            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4340            serde_json::to_writer(&mut dst, &value).unwrap();
4341            dst
4342        };
4343        let request_size = request_value_reader
4344            .seek(std::io::SeekFrom::End(0))
4345            .unwrap();
4346        request_value_reader
4347            .seek(std::io::SeekFrom::Start(0))
4348            .unwrap();
4349
4350        loop {
4351            let token = match self
4352                .hub
4353                .auth
4354                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4355                .await
4356            {
4357                Ok(token) => token,
4358                Err(e) => match dlg.token(e) {
4359                    Ok(token) => token,
4360                    Err(e) => {
4361                        dlg.finished(false);
4362                        return Err(common::Error::MissingToken(e));
4363                    }
4364                },
4365            };
4366            request_value_reader
4367                .seek(std::io::SeekFrom::Start(0))
4368                .unwrap();
4369            let mut req_result = {
4370                let client = &self.hub.client;
4371                dlg.pre_request();
4372                let mut req_builder = hyper::Request::builder()
4373                    .method(hyper::Method::POST)
4374                    .uri(url.as_str())
4375                    .header(USER_AGENT, self.hub._user_agent.clone());
4376
4377                if let Some(token) = token.as_ref() {
4378                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4379                }
4380
4381                let request = req_builder
4382                    .header(CONTENT_TYPE, json_mime_type.to_string())
4383                    .header(CONTENT_LENGTH, request_size as u64)
4384                    .body(common::to_body(
4385                        request_value_reader.get_ref().clone().into(),
4386                    ));
4387
4388                client.request(request.unwrap()).await
4389            };
4390
4391            match req_result {
4392                Err(err) => {
4393                    if let common::Retry::After(d) = dlg.http_error(&err) {
4394                        sleep(d).await;
4395                        continue;
4396                    }
4397                    dlg.finished(false);
4398                    return Err(common::Error::HttpError(err));
4399                }
4400                Ok(res) => {
4401                    let (mut parts, body) = res.into_parts();
4402                    let mut body = common::Body::new(body);
4403                    if !parts.status.is_success() {
4404                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4405                        let error = serde_json::from_str(&common::to_string(&bytes));
4406                        let response = common::to_response(parts, bytes.into());
4407
4408                        if let common::Retry::After(d) =
4409                            dlg.http_failure(&response, error.as_ref().ok())
4410                        {
4411                            sleep(d).await;
4412                            continue;
4413                        }
4414
4415                        dlg.finished(false);
4416
4417                        return Err(match error {
4418                            Ok(value) => common::Error::BadRequest(value),
4419                            _ => common::Error::Failure(response),
4420                        });
4421                    }
4422                    let response = {
4423                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4424                        let encoded = common::to_string(&bytes);
4425                        match serde_json::from_str(&encoded) {
4426                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4427                            Err(error) => {
4428                                dlg.response_json_decode_error(&encoded, &error);
4429                                return Err(common::Error::JsonDecodeError(
4430                                    encoded.to_string(),
4431                                    error,
4432                                ));
4433                            }
4434                        }
4435                    };
4436
4437                    dlg.finished(true);
4438                    return Ok(response);
4439                }
4440            }
4441        }
4442    }
4443
4444    ///
4445    /// Sets the *request* property to the given value.
4446    ///
4447    /// Even though the property as already been set when instantiating this call,
4448    /// we provide this method for API completeness.
4449    pub fn request(
4450        mut self,
4451        new_value: InstanceGroupManagersSetTargetPoolsRequest,
4452    ) -> InstanceGroupManagerSetTargetPoolCall<'a, C> {
4453        self._request = new_value;
4454        self
4455    }
4456    /// The Google Developers Console project name.
4457    ///
4458    /// Sets the *project* path property to the given value.
4459    ///
4460    /// Even though the property as already been set when instantiating this call,
4461    /// we provide this method for API completeness.
4462    pub fn project(mut self, new_value: &str) -> InstanceGroupManagerSetTargetPoolCall<'a, C> {
4463        self._project = new_value.to_string();
4464        self
4465    }
4466    /// The name of the zone in which the instance group manager resides.
4467    ///
4468    /// Sets the *zone* path property to the given value.
4469    ///
4470    /// Even though the property as already been set when instantiating this call,
4471    /// we provide this method for API completeness.
4472    pub fn zone(mut self, new_value: &str) -> InstanceGroupManagerSetTargetPoolCall<'a, C> {
4473        self._zone = new_value.to_string();
4474        self
4475    }
4476    /// The name of the instance group manager.
4477    ///
4478    /// Sets the *instance group manager* path property to the given value.
4479    ///
4480    /// Even though the property as already been set when instantiating this call,
4481    /// we provide this method for API completeness.
4482    pub fn instance_group_manager(
4483        mut self,
4484        new_value: &str,
4485    ) -> InstanceGroupManagerSetTargetPoolCall<'a, C> {
4486        self._instance_group_manager = new_value.to_string();
4487        self
4488    }
4489    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4490    /// while executing the actual API request.
4491    ///
4492    /// ````text
4493    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4494    /// ````
4495    ///
4496    /// Sets the *delegate* property to the given value.
4497    pub fn delegate(
4498        mut self,
4499        new_value: &'a mut dyn common::Delegate,
4500    ) -> InstanceGroupManagerSetTargetPoolCall<'a, C> {
4501        self._delegate = Some(new_value);
4502        self
4503    }
4504
4505    /// Set any additional parameter of the query string used in the request.
4506    /// It should be used to set parameters which are not yet available through their own
4507    /// setters.
4508    ///
4509    /// Please note that this method must not be used to set any of the known parameters
4510    /// which have their own setter method. If done anyway, the request will fail.
4511    ///
4512    /// # Additional Parameters
4513    ///
4514    /// * *alt* (query-string) - Data format for the response.
4515    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4516    /// * *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.
4517    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4518    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4519    /// * *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. Overrides userIp if both are provided.
4520    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
4521    pub fn param<T>(mut self, name: T, value: T) -> InstanceGroupManagerSetTargetPoolCall<'a, C>
4522    where
4523        T: AsRef<str>,
4524    {
4525        self._additional_params
4526            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4527        self
4528    }
4529
4530    /// Identifies the authorization scope for the method you are building.
4531    ///
4532    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4533    /// [`Scope::CloudPlatform`].
4534    ///
4535    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4536    /// tokens for more than one scope.
4537    ///
4538    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4539    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4540    /// sufficient, a read-write scope will do as well.
4541    pub fn add_scope<St>(mut self, scope: St) -> InstanceGroupManagerSetTargetPoolCall<'a, C>
4542    where
4543        St: AsRef<str>,
4544    {
4545        self._scopes.insert(String::from(scope.as_ref()));
4546        self
4547    }
4548    /// Identifies the authorization scope(s) for the method you are building.
4549    ///
4550    /// See [`Self::add_scope()`] for details.
4551    pub fn add_scopes<I, St>(mut self, scopes: I) -> InstanceGroupManagerSetTargetPoolCall<'a, C>
4552    where
4553        I: IntoIterator<Item = St>,
4554        St: AsRef<str>,
4555    {
4556        self._scopes
4557            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4558        self
4559    }
4560
4561    /// Removes all scopes, and no default scope will be used either.
4562    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4563    /// for details).
4564    pub fn clear_scopes(mut self) -> InstanceGroupManagerSetTargetPoolCall<'a, C> {
4565        self._scopes.clear();
4566        self
4567    }
4568}
4569
4570/// Retrieves the specified zone-specific operation resource.
4571///
4572/// A builder for the *get* method supported by a *zoneOperation* resource.
4573/// It is not used directly, but through a [`ZoneOperationMethods`] instance.
4574///
4575/// # Example
4576///
4577/// Instantiate a resource method builder
4578///
4579/// ```test_harness,no_run
4580/// # extern crate hyper;
4581/// # extern crate hyper_rustls;
4582/// # extern crate google_replicapool1_beta2 as replicapool1_beta2;
4583/// # async fn dox() {
4584/// # use replicapool1_beta2::{Replicapool, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4585///
4586/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4587/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4588/// #     .with_native_roots()
4589/// #     .unwrap()
4590/// #     .https_only()
4591/// #     .enable_http2()
4592/// #     .build();
4593///
4594/// # let executor = hyper_util::rt::TokioExecutor::new();
4595/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4596/// #     secret,
4597/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4598/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4599/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4600/// #     ),
4601/// # ).build().await.unwrap();
4602///
4603/// # let client = hyper_util::client::legacy::Client::builder(
4604/// #     hyper_util::rt::TokioExecutor::new()
4605/// # )
4606/// # .build(
4607/// #     hyper_rustls::HttpsConnectorBuilder::new()
4608/// #         .with_native_roots()
4609/// #         .unwrap()
4610/// #         .https_or_http()
4611/// #         .enable_http2()
4612/// #         .build()
4613/// # );
4614/// # let mut hub = Replicapool::new(client, auth);
4615/// // You can configure optional parameters by calling the respective setters at will, and
4616/// // execute the final call using `doit()`.
4617/// // Values shown here are possibly random and not representative !
4618/// let result = hub.zone_operations().get("project", "zone", "operation")
4619///              .doit().await;
4620/// # }
4621/// ```
4622pub struct ZoneOperationGetCall<'a, C>
4623where
4624    C: 'a,
4625{
4626    hub: &'a Replicapool<C>,
4627    _project: String,
4628    _zone: String,
4629    _operation: String,
4630    _delegate: Option<&'a mut dyn common::Delegate>,
4631    _additional_params: HashMap<String, String>,
4632    _scopes: BTreeSet<String>,
4633}
4634
4635impl<'a, C> common::CallBuilder for ZoneOperationGetCall<'a, C> {}
4636
4637impl<'a, C> ZoneOperationGetCall<'a, C>
4638where
4639    C: common::Connector,
4640{
4641    /// Perform the operation you have build so far.
4642    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4643        use std::borrow::Cow;
4644        use std::io::{Read, Seek};
4645
4646        use common::{url::Params, ToParts};
4647        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4648
4649        let mut dd = common::DefaultDelegate;
4650        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4651        dlg.begin(common::MethodInfo {
4652            id: "replicapool.zoneOperations.get",
4653            http_method: hyper::Method::GET,
4654        });
4655
4656        for &field in ["alt", "project", "zone", "operation"].iter() {
4657            if self._additional_params.contains_key(field) {
4658                dlg.finished(false);
4659                return Err(common::Error::FieldClash(field));
4660            }
4661        }
4662
4663        let mut params = Params::with_capacity(5 + self._additional_params.len());
4664        params.push("project", self._project);
4665        params.push("zone", self._zone);
4666        params.push("operation", self._operation);
4667
4668        params.extend(self._additional_params.iter());
4669
4670        params.push("alt", "json");
4671        let mut url = self.hub._base_url.clone() + "{project}/zones/{zone}/operations/{operation}";
4672        if self._scopes.is_empty() {
4673            self._scopes
4674                .insert(Scope::CloudPlatform.as_ref().to_string());
4675        }
4676
4677        #[allow(clippy::single_element_loop)]
4678        for &(find_this, param_name) in [
4679            ("{project}", "project"),
4680            ("{zone}", "zone"),
4681            ("{operation}", "operation"),
4682        ]
4683        .iter()
4684        {
4685            url = params.uri_replacement(url, param_name, find_this, false);
4686        }
4687        {
4688            let to_remove = ["operation", "zone", "project"];
4689            params.remove_params(&to_remove);
4690        }
4691
4692        let url = params.parse_with_url(&url);
4693
4694        loop {
4695            let token = match self
4696                .hub
4697                .auth
4698                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4699                .await
4700            {
4701                Ok(token) => token,
4702                Err(e) => match dlg.token(e) {
4703                    Ok(token) => token,
4704                    Err(e) => {
4705                        dlg.finished(false);
4706                        return Err(common::Error::MissingToken(e));
4707                    }
4708                },
4709            };
4710            let mut req_result = {
4711                let client = &self.hub.client;
4712                dlg.pre_request();
4713                let mut req_builder = hyper::Request::builder()
4714                    .method(hyper::Method::GET)
4715                    .uri(url.as_str())
4716                    .header(USER_AGENT, self.hub._user_agent.clone());
4717
4718                if let Some(token) = token.as_ref() {
4719                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4720                }
4721
4722                let request = req_builder
4723                    .header(CONTENT_LENGTH, 0_u64)
4724                    .body(common::to_body::<String>(None));
4725
4726                client.request(request.unwrap()).await
4727            };
4728
4729            match req_result {
4730                Err(err) => {
4731                    if let common::Retry::After(d) = dlg.http_error(&err) {
4732                        sleep(d).await;
4733                        continue;
4734                    }
4735                    dlg.finished(false);
4736                    return Err(common::Error::HttpError(err));
4737                }
4738                Ok(res) => {
4739                    let (mut parts, body) = res.into_parts();
4740                    let mut body = common::Body::new(body);
4741                    if !parts.status.is_success() {
4742                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4743                        let error = serde_json::from_str(&common::to_string(&bytes));
4744                        let response = common::to_response(parts, bytes.into());
4745
4746                        if let common::Retry::After(d) =
4747                            dlg.http_failure(&response, error.as_ref().ok())
4748                        {
4749                            sleep(d).await;
4750                            continue;
4751                        }
4752
4753                        dlg.finished(false);
4754
4755                        return Err(match error {
4756                            Ok(value) => common::Error::BadRequest(value),
4757                            _ => common::Error::Failure(response),
4758                        });
4759                    }
4760                    let response = {
4761                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4762                        let encoded = common::to_string(&bytes);
4763                        match serde_json::from_str(&encoded) {
4764                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4765                            Err(error) => {
4766                                dlg.response_json_decode_error(&encoded, &error);
4767                                return Err(common::Error::JsonDecodeError(
4768                                    encoded.to_string(),
4769                                    error,
4770                                ));
4771                            }
4772                        }
4773                    };
4774
4775                    dlg.finished(true);
4776                    return Ok(response);
4777                }
4778            }
4779        }
4780    }
4781
4782    /// Name of the project scoping this request.
4783    ///
4784    /// Sets the *project* path property to the given value.
4785    ///
4786    /// Even though the property as already been set when instantiating this call,
4787    /// we provide this method for API completeness.
4788    pub fn project(mut self, new_value: &str) -> ZoneOperationGetCall<'a, C> {
4789        self._project = new_value.to_string();
4790        self
4791    }
4792    /// Name of the zone scoping this request.
4793    ///
4794    /// Sets the *zone* path property to the given value.
4795    ///
4796    /// Even though the property as already been set when instantiating this call,
4797    /// we provide this method for API completeness.
4798    pub fn zone(mut self, new_value: &str) -> ZoneOperationGetCall<'a, C> {
4799        self._zone = new_value.to_string();
4800        self
4801    }
4802    /// Name of the operation resource to return.
4803    ///
4804    /// Sets the *operation* path property to the given value.
4805    ///
4806    /// Even though the property as already been set when instantiating this call,
4807    /// we provide this method for API completeness.
4808    pub fn operation(mut self, new_value: &str) -> ZoneOperationGetCall<'a, C> {
4809        self._operation = new_value.to_string();
4810        self
4811    }
4812    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4813    /// while executing the actual API request.
4814    ///
4815    /// ````text
4816    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4817    /// ````
4818    ///
4819    /// Sets the *delegate* property to the given value.
4820    pub fn delegate(
4821        mut self,
4822        new_value: &'a mut dyn common::Delegate,
4823    ) -> ZoneOperationGetCall<'a, C> {
4824        self._delegate = Some(new_value);
4825        self
4826    }
4827
4828    /// Set any additional parameter of the query string used in the request.
4829    /// It should be used to set parameters which are not yet available through their own
4830    /// setters.
4831    ///
4832    /// Please note that this method must not be used to set any of the known parameters
4833    /// which have their own setter method. If done anyway, the request will fail.
4834    ///
4835    /// # Additional Parameters
4836    ///
4837    /// * *alt* (query-string) - Data format for the response.
4838    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4839    /// * *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.
4840    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4841    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4842    /// * *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. Overrides userIp if both are provided.
4843    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
4844    pub fn param<T>(mut self, name: T, value: T) -> ZoneOperationGetCall<'a, C>
4845    where
4846        T: AsRef<str>,
4847    {
4848        self._additional_params
4849            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4850        self
4851    }
4852
4853    /// Identifies the authorization scope for the method you are building.
4854    ///
4855    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4856    /// [`Scope::CloudPlatform`].
4857    ///
4858    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4859    /// tokens for more than one scope.
4860    ///
4861    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4862    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4863    /// sufficient, a read-write scope will do as well.
4864    pub fn add_scope<St>(mut self, scope: St) -> ZoneOperationGetCall<'a, C>
4865    where
4866        St: AsRef<str>,
4867    {
4868        self._scopes.insert(String::from(scope.as_ref()));
4869        self
4870    }
4871    /// Identifies the authorization scope(s) for the method you are building.
4872    ///
4873    /// See [`Self::add_scope()`] for details.
4874    pub fn add_scopes<I, St>(mut self, scopes: I) -> ZoneOperationGetCall<'a, C>
4875    where
4876        I: IntoIterator<Item = St>,
4877        St: AsRef<str>,
4878    {
4879        self._scopes
4880            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4881        self
4882    }
4883
4884    /// Removes all scopes, and no default scope will be used either.
4885    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4886    /// for details).
4887    pub fn clear_scopes(mut self) -> ZoneOperationGetCall<'a, C> {
4888        self._scopes.clear();
4889        self
4890    }
4891}
4892
4893/// Retrieves the list of operation resources contained within the specified zone.
4894///
4895/// A builder for the *list* method supported by a *zoneOperation* resource.
4896/// It is not used directly, but through a [`ZoneOperationMethods`] instance.
4897///
4898/// # Example
4899///
4900/// Instantiate a resource method builder
4901///
4902/// ```test_harness,no_run
4903/// # extern crate hyper;
4904/// # extern crate hyper_rustls;
4905/// # extern crate google_replicapool1_beta2 as replicapool1_beta2;
4906/// # async fn dox() {
4907/// # use replicapool1_beta2::{Replicapool, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4908///
4909/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4910/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4911/// #     .with_native_roots()
4912/// #     .unwrap()
4913/// #     .https_only()
4914/// #     .enable_http2()
4915/// #     .build();
4916///
4917/// # let executor = hyper_util::rt::TokioExecutor::new();
4918/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4919/// #     secret,
4920/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4921/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4922/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4923/// #     ),
4924/// # ).build().await.unwrap();
4925///
4926/// # let client = hyper_util::client::legacy::Client::builder(
4927/// #     hyper_util::rt::TokioExecutor::new()
4928/// # )
4929/// # .build(
4930/// #     hyper_rustls::HttpsConnectorBuilder::new()
4931/// #         .with_native_roots()
4932/// #         .unwrap()
4933/// #         .https_or_http()
4934/// #         .enable_http2()
4935/// #         .build()
4936/// # );
4937/// # let mut hub = Replicapool::new(client, auth);
4938/// // You can configure optional parameters by calling the respective setters at will, and
4939/// // execute the final call using `doit()`.
4940/// // Values shown here are possibly random and not representative !
4941/// let result = hub.zone_operations().list("project", "zone")
4942///              .page_token("et")
4943///              .max_results(73)
4944///              .filter("amet.")
4945///              .doit().await;
4946/// # }
4947/// ```
4948pub struct ZoneOperationListCall<'a, C>
4949where
4950    C: 'a,
4951{
4952    hub: &'a Replicapool<C>,
4953    _project: String,
4954    _zone: String,
4955    _page_token: Option<String>,
4956    _max_results: Option<u32>,
4957    _filter: Option<String>,
4958    _delegate: Option<&'a mut dyn common::Delegate>,
4959    _additional_params: HashMap<String, String>,
4960    _scopes: BTreeSet<String>,
4961}
4962
4963impl<'a, C> common::CallBuilder for ZoneOperationListCall<'a, C> {}
4964
4965impl<'a, C> ZoneOperationListCall<'a, C>
4966where
4967    C: common::Connector,
4968{
4969    /// Perform the operation you have build so far.
4970    pub async fn doit(mut self) -> common::Result<(common::Response, OperationList)> {
4971        use std::borrow::Cow;
4972        use std::io::{Read, Seek};
4973
4974        use common::{url::Params, ToParts};
4975        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4976
4977        let mut dd = common::DefaultDelegate;
4978        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4979        dlg.begin(common::MethodInfo {
4980            id: "replicapool.zoneOperations.list",
4981            http_method: hyper::Method::GET,
4982        });
4983
4984        for &field in [
4985            "alt",
4986            "project",
4987            "zone",
4988            "pageToken",
4989            "maxResults",
4990            "filter",
4991        ]
4992        .iter()
4993        {
4994            if self._additional_params.contains_key(field) {
4995                dlg.finished(false);
4996                return Err(common::Error::FieldClash(field));
4997            }
4998        }
4999
5000        let mut params = Params::with_capacity(7 + self._additional_params.len());
5001        params.push("project", self._project);
5002        params.push("zone", self._zone);
5003        if let Some(value) = self._page_token.as_ref() {
5004            params.push("pageToken", value);
5005        }
5006        if let Some(value) = self._max_results.as_ref() {
5007            params.push("maxResults", value.to_string());
5008        }
5009        if let Some(value) = self._filter.as_ref() {
5010            params.push("filter", value);
5011        }
5012
5013        params.extend(self._additional_params.iter());
5014
5015        params.push("alt", "json");
5016        let mut url = self.hub._base_url.clone() + "{project}/zones/{zone}/operations";
5017        if self._scopes.is_empty() {
5018            self._scopes
5019                .insert(Scope::CloudPlatform.as_ref().to_string());
5020        }
5021
5022        #[allow(clippy::single_element_loop)]
5023        for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() {
5024            url = params.uri_replacement(url, param_name, find_this, false);
5025        }
5026        {
5027            let to_remove = ["zone", "project"];
5028            params.remove_params(&to_remove);
5029        }
5030
5031        let url = params.parse_with_url(&url);
5032
5033        loop {
5034            let token = match self
5035                .hub
5036                .auth
5037                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5038                .await
5039            {
5040                Ok(token) => token,
5041                Err(e) => match dlg.token(e) {
5042                    Ok(token) => token,
5043                    Err(e) => {
5044                        dlg.finished(false);
5045                        return Err(common::Error::MissingToken(e));
5046                    }
5047                },
5048            };
5049            let mut req_result = {
5050                let client = &self.hub.client;
5051                dlg.pre_request();
5052                let mut req_builder = hyper::Request::builder()
5053                    .method(hyper::Method::GET)
5054                    .uri(url.as_str())
5055                    .header(USER_AGENT, self.hub._user_agent.clone());
5056
5057                if let Some(token) = token.as_ref() {
5058                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5059                }
5060
5061                let request = req_builder
5062                    .header(CONTENT_LENGTH, 0_u64)
5063                    .body(common::to_body::<String>(None));
5064
5065                client.request(request.unwrap()).await
5066            };
5067
5068            match req_result {
5069                Err(err) => {
5070                    if let common::Retry::After(d) = dlg.http_error(&err) {
5071                        sleep(d).await;
5072                        continue;
5073                    }
5074                    dlg.finished(false);
5075                    return Err(common::Error::HttpError(err));
5076                }
5077                Ok(res) => {
5078                    let (mut parts, body) = res.into_parts();
5079                    let mut body = common::Body::new(body);
5080                    if !parts.status.is_success() {
5081                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5082                        let error = serde_json::from_str(&common::to_string(&bytes));
5083                        let response = common::to_response(parts, bytes.into());
5084
5085                        if let common::Retry::After(d) =
5086                            dlg.http_failure(&response, error.as_ref().ok())
5087                        {
5088                            sleep(d).await;
5089                            continue;
5090                        }
5091
5092                        dlg.finished(false);
5093
5094                        return Err(match error {
5095                            Ok(value) => common::Error::BadRequest(value),
5096                            _ => common::Error::Failure(response),
5097                        });
5098                    }
5099                    let response = {
5100                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5101                        let encoded = common::to_string(&bytes);
5102                        match serde_json::from_str(&encoded) {
5103                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5104                            Err(error) => {
5105                                dlg.response_json_decode_error(&encoded, &error);
5106                                return Err(common::Error::JsonDecodeError(
5107                                    encoded.to_string(),
5108                                    error,
5109                                ));
5110                            }
5111                        }
5112                    };
5113
5114                    dlg.finished(true);
5115                    return Ok(response);
5116                }
5117            }
5118        }
5119    }
5120
5121    /// Name of the project scoping this request.
5122    ///
5123    /// Sets the *project* path property to the given value.
5124    ///
5125    /// Even though the property as already been set when instantiating this call,
5126    /// we provide this method for API completeness.
5127    pub fn project(mut self, new_value: &str) -> ZoneOperationListCall<'a, C> {
5128        self._project = new_value.to_string();
5129        self
5130    }
5131    /// Name of the zone scoping this request.
5132    ///
5133    /// Sets the *zone* path property to the given value.
5134    ///
5135    /// Even though the property as already been set when instantiating this call,
5136    /// we provide this method for API completeness.
5137    pub fn zone(mut self, new_value: &str) -> ZoneOperationListCall<'a, C> {
5138        self._zone = new_value.to_string();
5139        self
5140    }
5141    /// Optional. Tag returned by a previous list request truncated by maxResults. Used to continue a previous list request.
5142    ///
5143    /// Sets the *page token* query property to the given value.
5144    pub fn page_token(mut self, new_value: &str) -> ZoneOperationListCall<'a, C> {
5145        self._page_token = Some(new_value.to_string());
5146        self
5147    }
5148    /// Optional. Maximum count of results to be returned. Maximum value is 500 and default value is 500.
5149    ///
5150    /// Sets the *max results* query property to the given value.
5151    pub fn max_results(mut self, new_value: u32) -> ZoneOperationListCall<'a, C> {
5152        self._max_results = Some(new_value);
5153        self
5154    }
5155    /// Optional. Filter expression for filtering listed resources.
5156    ///
5157    /// Sets the *filter* query property to the given value.
5158    pub fn filter(mut self, new_value: &str) -> ZoneOperationListCall<'a, C> {
5159        self._filter = Some(new_value.to_string());
5160        self
5161    }
5162    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5163    /// while executing the actual API request.
5164    ///
5165    /// ````text
5166    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5167    /// ````
5168    ///
5169    /// Sets the *delegate* property to the given value.
5170    pub fn delegate(
5171        mut self,
5172        new_value: &'a mut dyn common::Delegate,
5173    ) -> ZoneOperationListCall<'a, C> {
5174        self._delegate = Some(new_value);
5175        self
5176    }
5177
5178    /// Set any additional parameter of the query string used in the request.
5179    /// It should be used to set parameters which are not yet available through their own
5180    /// setters.
5181    ///
5182    /// Please note that this method must not be used to set any of the known parameters
5183    /// which have their own setter method. If done anyway, the request will fail.
5184    ///
5185    /// # Additional Parameters
5186    ///
5187    /// * *alt* (query-string) - Data format for the response.
5188    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5189    /// * *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.
5190    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5191    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5192    /// * *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. Overrides userIp if both are provided.
5193    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
5194    pub fn param<T>(mut self, name: T, value: T) -> ZoneOperationListCall<'a, C>
5195    where
5196        T: AsRef<str>,
5197    {
5198        self._additional_params
5199            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5200        self
5201    }
5202
5203    /// Identifies the authorization scope for the method you are building.
5204    ///
5205    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5206    /// [`Scope::CloudPlatform`].
5207    ///
5208    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5209    /// tokens for more than one scope.
5210    ///
5211    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5212    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5213    /// sufficient, a read-write scope will do as well.
5214    pub fn add_scope<St>(mut self, scope: St) -> ZoneOperationListCall<'a, C>
5215    where
5216        St: AsRef<str>,
5217    {
5218        self._scopes.insert(String::from(scope.as_ref()));
5219        self
5220    }
5221    /// Identifies the authorization scope(s) for the method you are building.
5222    ///
5223    /// See [`Self::add_scope()`] for details.
5224    pub fn add_scopes<I, St>(mut self, scopes: I) -> ZoneOperationListCall<'a, C>
5225    where
5226        I: IntoIterator<Item = St>,
5227        St: AsRef<str>,
5228    {
5229        self._scopes
5230            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5231        self
5232    }
5233
5234    /// Removes all scopes, and no default scope will be used either.
5235    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5236    /// for details).
5237    pub fn clear_scopes(mut self) -> ZoneOperationListCall<'a, C> {
5238        self._scopes.clear();
5239        self
5240    }
5241}