google_replicapoolupdater1_beta1/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 replica pools
23 Replicapool,
24
25 /// View replica pools
26 ReplicapoolReadonly,
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::Replicapool => "https://www.googleapis.com/auth/replicapool",
37 Scope::ReplicapoolReadonly => "https://www.googleapis.com/auth/replicapool.readonly",
38 }
39 }
40}
41
42#[allow(clippy::derivable_impls)]
43impl Default for Scope {
44 fn default() -> Scope {
45 Scope::ReplicapoolReadonly
46 }
47}
48
49// ########
50// HUB ###
51// ######
52
53/// Central instance to access all Replicapoolupdater 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_replicapoolupdater1_beta1 as replicapoolupdater1_beta1;
63/// use replicapoolupdater1_beta1::{Result, Error};
64/// # async fn dox() {
65/// use replicapoolupdater1_beta1::{Replicapoolupdater, 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 = Replicapoolupdater::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.rolling_updates().list_instance_updates("project", "zone", "rollingUpdate")
107/// .page_token("gubergren")
108/// .max_results(26)
109/// .filter("dolor")
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 Replicapoolupdater<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 Replicapoolupdater<C> {}
141
142impl<'a, C> Replicapoolupdater<C> {
143 pub fn new<A: 'static + common::GetToken>(
144 client: common::Client<C>,
145 auth: A,
146 ) -> Replicapoolupdater<C> {
147 Replicapoolupdater {
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/replicapoolupdater/v1beta1/projects/"
152 .to_string(),
153 _root_url: "https://www.googleapis.com/".to_string(),
154 }
155 }
156
157 pub fn rolling_updates(&'a self) -> RollingUpdateMethods<'a, C> {
158 RollingUpdateMethods { hub: self }
159 }
160 pub fn zone_operations(&'a self) -> ZoneOperationMethods<'a, C> {
161 ZoneOperationMethods { hub: self }
162 }
163
164 /// Set the user-agent header field to use in all requests to the server.
165 /// It defaults to `google-api-rust-client/7.0.0`.
166 ///
167 /// Returns the previously set user-agent.
168 pub fn user_agent(&mut self, agent_name: String) -> String {
169 std::mem::replace(&mut self._user_agent, agent_name)
170 }
171
172 /// Set the base url to use in all requests to the server.
173 /// It defaults to `https://www.googleapis.com/replicapoolupdater/v1beta1/projects/`.
174 ///
175 /// Returns the previously set base url.
176 pub fn base_url(&mut self, new_base_url: String) -> String {
177 std::mem::replace(&mut self._base_url, new_base_url)
178 }
179
180 /// Set the root url to use in all requests to the server.
181 /// It defaults to `https://www.googleapis.com/`.
182 ///
183 /// Returns the previously set root url.
184 pub fn root_url(&mut self, new_root_url: String) -> String {
185 std::mem::replace(&mut self._root_url, new_root_url)
186 }
187}
188
189// ############
190// SCHEMAS ###
191// ##########
192/// Update of a single instance.
193///
194/// This type is not used in any activity, and only used as *part* of another schema.
195///
196#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
197#[serde_with::serde_as]
198#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
199pub struct InstanceUpdate {
200 /// Errors that occurred during the instance update.
201 pub error: Option<InstanceUpdateError>,
202 /// Fully-qualified URL of the instance being updated.
203 pub instance: Option<String>,
204 /// Status of the instance update. Possible values are:
205 /// - "PENDING": The instance update is pending execution.
206 /// - "ROLLING_FORWARD": The instance update is going forward.
207 /// - "ROLLING_BACK": The instance update is being rolled back.
208 /// - "PAUSED": The instance update is temporarily paused (inactive).
209 /// - "ROLLED_OUT": The instance update is finished, the instance is running the new template.
210 /// - "ROLLED_BACK": The instance update is finished, the instance has been reverted to the previous template.
211 /// - "CANCELLED": The instance update is paused and no longer can be resumed, undefined in which template the instance is running.
212 pub status: Option<String>,
213}
214
215impl common::Part for InstanceUpdate {}
216
217/// Response returned by ListInstanceUpdates method.
218///
219/// # Activities
220///
221/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
222/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
223///
224/// * [list instance updates rolling updates](RollingUpdateListInstanceUpdateCall) (response)
225#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
226#[serde_with::serde_as]
227#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
228pub struct InstanceUpdateList {
229 /// Collection of requested instance updates.
230 pub items: Option<Vec<InstanceUpdate>>,
231 /// [Output Only] Type of the resource.
232 pub kind: Option<String>,
233 /// A token used to continue a truncated list request.
234 #[serde(rename = "nextPageToken")]
235 pub next_page_token: Option<String>,
236 /// [Output Only] The fully qualified URL for the resource.
237 #[serde(rename = "selfLink")]
238 pub self_link: Option<String>,
239}
240
241impl common::ResponseResult for InstanceUpdateList {}
242
243/// An operation resource, used to manage asynchronous API requests.
244///
245/// # Activities
246///
247/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
248/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
249///
250/// * [cancel rolling updates](RollingUpdateCancelCall) (response)
251/// * [insert rolling updates](RollingUpdateInsertCall) (response)
252/// * [pause rolling updates](RollingUpdatePauseCall) (response)
253/// * [resume rolling updates](RollingUpdateResumeCall) (response)
254/// * [rollback rolling updates](RollingUpdateRollbackCall) (response)
255/// * [get zone operations](ZoneOperationGetCall) (response)
256#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
257#[serde_with::serde_as]
258#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
259pub struct Operation {
260 /// no description provided
261 #[serde(rename = "clientOperationId")]
262 pub client_operation_id: Option<String>,
263 /// [Output Only] Creation timestamp in RFC3339 text format.
264 #[serde(rename = "creationTimestamp")]
265 pub creation_timestamp: Option<String>,
266 /// no description provided
267 #[serde(rename = "endTime")]
268 pub end_time: Option<String>,
269 /// [Output Only] If errors occurred during processing of this operation, this field will be populated.
270 pub error: Option<OperationError>,
271 /// no description provided
272 #[serde(rename = "httpErrorMessage")]
273 pub http_error_message: Option<String>,
274 /// no description provided
275 #[serde(rename = "httpErrorStatusCode")]
276 pub http_error_status_code: Option<i32>,
277 /// [Output Only] Unique identifier for the resource; defined by the server.
278 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
279 pub id: Option<u64>,
280 /// [Output Only] The time that this operation was requested. This is in RFC 3339 format.
281 #[serde(rename = "insertTime")]
282 pub insert_time: Option<String>,
283 /// [Output Only] Type of the resource. Always replicapoolupdater#operation for Operation resources.
284 pub kind: Option<String>,
285 /// [Output Only] Name of the resource.
286 pub name: Option<String>,
287 /// no description provided
288 #[serde(rename = "operationType")]
289 pub operation_type: Option<String>,
290 /// no description provided
291 pub progress: Option<i32>,
292 /// [Output Only] URL of the region where the operation resides.
293 pub region: Option<String>,
294 /// [Output Only] The fully qualified URL for the resource.
295 #[serde(rename = "selfLink")]
296 pub self_link: Option<String>,
297 /// [Output Only] The time that this operation was started by the server. This is in RFC 3339 format.
298 #[serde(rename = "startTime")]
299 pub start_time: Option<String>,
300 /// [Output Only] Status of the operation. Can be one of the following: "PENDING", "RUNNING", or "DONE".
301 pub status: Option<String>,
302 /// [Output Only] An optional textual description of the current status of the operation.
303 #[serde(rename = "statusMessage")]
304 pub status_message: Option<String>,
305 /// [Output Only] Unique target id which identifies a particular incarnation of the target.
306 #[serde(rename = "targetId")]
307 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
308 pub target_id: Option<u64>,
309 /// [Output Only] URL of the resource the operation is mutating.
310 #[serde(rename = "targetLink")]
311 pub target_link: Option<String>,
312 /// no description provided
313 pub user: Option<String>,
314 /// no description provided
315 pub warnings: Option<Vec<OperationWarnings>>,
316 /// [Output Only] URL of the zone where the operation resides.
317 pub zone: Option<String>,
318}
319
320impl common::ResponseResult for Operation {}
321
322/// Contains a list of Operation resources.
323///
324/// # Activities
325///
326/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
327/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
328///
329/// * [list zone operations](ZoneOperationListCall) (response)
330#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
331#[serde_with::serde_as]
332#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
333pub struct OperationList {
334 /// [Output Only] Unique identifier for the resource; defined by the server.
335 pub id: Option<String>,
336 /// [Output Only] The Operation resources.
337 pub items: Option<Vec<Operation>>,
338 /// [Output Only] Type of resource. Always replicapoolupdater#operationList for OperationList resources.
339 pub kind: Option<String>,
340 /// [Output Only] A token used to continue a truncate.
341 #[serde(rename = "nextPageToken")]
342 pub next_page_token: Option<String>,
343 /// [Output Only] The fully qualified URL for the resource.
344 #[serde(rename = "selfLink")]
345 pub self_link: Option<String>,
346}
347
348impl common::ResponseResult for OperationList {}
349
350/// The following represents a resource describing a single update (rollout) of a group of instances to the given template.
351///
352/// # Activities
353///
354/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
355/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
356///
357/// * [cancel rolling updates](RollingUpdateCancelCall) (none)
358/// * [get rolling updates](RollingUpdateGetCall) (response)
359/// * [insert rolling updates](RollingUpdateInsertCall) (request)
360/// * [list rolling updates](RollingUpdateListCall) (none)
361/// * [list instance updates rolling updates](RollingUpdateListInstanceUpdateCall) (none)
362/// * [pause rolling updates](RollingUpdatePauseCall) (none)
363/// * [resume rolling updates](RollingUpdateResumeCall) (none)
364/// * [rollback rolling updates](RollingUpdateRollbackCall) (none)
365#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
366#[serde_with::serde_as]
367#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
368pub struct RollingUpdate {
369 /// Specifies the action to take for each instance within the instance group. This can be RECREATE which will recreate each instance and is only available for managed instance groups. It can also be REBOOT which performs a soft reboot for each instance and is only available for regular (non-managed) instance groups.
370 #[serde(rename = "actionType")]
371 pub action_type: Option<String>,
372 /// [Output Only] Creation timestamp in RFC3339 text format.
373 #[serde(rename = "creationTimestamp")]
374 pub creation_timestamp: Option<String>,
375 /// An optional textual description of the resource; provided by the client when the resource is created.
376 pub description: Option<String>,
377 /// [Output Only] Errors that occurred during the rolling update.
378 pub error: Option<RollingUpdateError>,
379 /// [Output Only] Unique identifier for the resource; defined by the server.
380 pub id: Option<String>,
381 /// Fully-qualified URL of an instance group being updated. Exactly one of instanceGroupManager and instanceGroup must be set.
382 #[serde(rename = "instanceGroup")]
383 pub instance_group: Option<String>,
384 /// Fully-qualified URL of an instance group manager being updated. Exactly one of instanceGroupManager and instanceGroup must be set.
385 #[serde(rename = "instanceGroupManager")]
386 pub instance_group_manager: Option<String>,
387 /// Fully-qualified URL of an instance template to apply.
388 #[serde(rename = "instanceTemplate")]
389 pub instance_template: Option<String>,
390 /// [Output Only] Type of the resource.
391 pub kind: Option<String>,
392 /// Fully-qualified URL of the instance template encountered while starting the update.
393 #[serde(rename = "oldInstanceTemplate")]
394 pub old_instance_template: Option<String>,
395 /// Parameters of the update process.
396 pub policy: Option<RollingUpdatePolicy>,
397 /// [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 update will be complete. This number should be monotonically increasing as the update progresses.
398 pub progress: Option<i32>,
399 /// [Output Only] The fully qualified URL for the resource.
400 #[serde(rename = "selfLink")]
401 pub self_link: Option<String>,
402 /// [Output Only] Status of the update. Possible values are:
403 /// - "ROLLING_FORWARD": The update is going forward.
404 /// - "ROLLING_BACK": The update is being rolled back.
405 /// - "PAUSED": The update is temporarily paused (inactive).
406 /// - "ROLLED_OUT": The update is finished, all instances have been updated successfully.
407 /// - "ROLLED_BACK": The update is finished, all instances have been reverted to the previous template.
408 /// - "CANCELLED": The update is paused and no longer can be resumed, undefined how many instances are running in which template.
409 pub status: Option<String>,
410 /// [Output Only] An optional textual description of the current status of the update.
411 #[serde(rename = "statusMessage")]
412 pub status_message: Option<String>,
413 /// [Output Only] User who requested the update, for example: user@example.com.
414 pub user: Option<String>,
415}
416
417impl common::RequestValue for RollingUpdate {}
418impl common::Resource for RollingUpdate {}
419impl common::ResponseResult for RollingUpdate {}
420
421/// Response returned by List method.
422///
423/// # Activities
424///
425/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
426/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
427///
428/// * [list rolling updates](RollingUpdateListCall) (response)
429#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
430#[serde_with::serde_as]
431#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
432pub struct RollingUpdateList {
433 /// Collection of requested updates.
434 pub items: Option<Vec<RollingUpdate>>,
435 /// [Output Only] Type of the resource.
436 pub kind: Option<String>,
437 /// A token used to continue a truncated list request.
438 #[serde(rename = "nextPageToken")]
439 pub next_page_token: Option<String>,
440 /// [Output Only] The fully qualified URL for the resource.
441 #[serde(rename = "selfLink")]
442 pub self_link: Option<String>,
443}
444
445impl common::ResponseResult for RollingUpdateList {}
446
447/// Errors that occurred during the instance update.
448///
449/// This type is not used in any activity, and only used as *part* of another schema.
450///
451#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
452#[serde_with::serde_as]
453#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
454pub struct InstanceUpdateError {
455 /// [Output Only] The array of errors encountered while processing this operation.
456 pub errors: Option<Vec<InstanceUpdateErrorErrors>>,
457}
458
459impl common::NestedType for InstanceUpdateError {}
460impl common::Part for InstanceUpdateError {}
461
462/// [Output Only] The array of errors encountered while processing this operation.
463///
464/// This type is not used in any activity, and only used as *part* of another schema.
465///
466#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
467#[serde_with::serde_as]
468#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
469pub struct InstanceUpdateErrorErrors {
470 /// [Output Only] The error type identifier for this error.
471 pub code: Option<String>,
472 /// [Output Only] Indicates the field in the request that caused the error. This property is optional.
473 pub location: Option<String>,
474 /// [Output Only] An optional, human-readable error message.
475 pub message: Option<String>,
476}
477
478impl common::NestedType for InstanceUpdateErrorErrors {}
479impl common::Part for InstanceUpdateErrorErrors {}
480
481/// [Output Only] If errors occurred during processing of this operation, this field will be populated.
482///
483/// This type is not used in any activity, and only used as *part* of another schema.
484///
485#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
486#[serde_with::serde_as]
487#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
488pub struct OperationError {
489 /// [Output Only] The array of errors encountered while processing this operation.
490 pub errors: Option<Vec<OperationErrorErrors>>,
491}
492
493impl common::NestedType for OperationError {}
494impl common::Part for OperationError {}
495
496/// [Output Only] The array of errors encountered while processing this operation.
497///
498/// This type is not used in any activity, and only used as *part* of another schema.
499///
500#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
501#[serde_with::serde_as]
502#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
503pub struct OperationErrorErrors {
504 /// [Output Only] The error type identifier for this error.
505 pub code: Option<String>,
506 /// [Output Only] Indicates the field in the request that caused the error. This property is optional.
507 pub location: Option<String>,
508 /// [Output Only] An optional, human-readable error message.
509 pub message: Option<String>,
510}
511
512impl common::NestedType for OperationErrorErrors {}
513impl common::Part for OperationErrorErrors {}
514
515/// There is no detailed description.
516///
517/// This type is not used in any activity, and only used as *part* of another schema.
518///
519#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
520#[serde_with::serde_as]
521#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
522pub struct OperationWarnings {
523 /// [Output only] The warning type identifier for this warning.
524 pub code: Option<String>,
525 /// [Output only] Metadata for this warning in key:value format.
526 pub data: Option<Vec<OperationWarningsData>>,
527 /// [Output only] Optional human-readable details for this warning.
528 pub message: Option<String>,
529}
530
531impl common::NestedType for OperationWarnings {}
532impl common::Part for OperationWarnings {}
533
534/// [Output only] Metadata for this warning in key:value format.
535///
536/// This type is not used in any activity, and only used as *part* of another schema.
537///
538#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
539#[serde_with::serde_as]
540#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
541pub struct OperationWarningsData {
542 /// [Output Only] Metadata key for this warning.
543 pub key: Option<String>,
544 /// [Output Only] Metadata value for this warning.
545 pub value: Option<String>,
546}
547
548impl common::NestedType for OperationWarningsData {}
549impl common::Part for OperationWarningsData {}
550
551/// [Output Only] Errors that occurred during the rolling update.
552///
553/// This type is not used in any activity, and only used as *part* of another schema.
554///
555#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
556#[serde_with::serde_as]
557#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
558pub struct RollingUpdateError {
559 /// [Output Only] The array of errors encountered while processing this operation.
560 pub errors: Option<Vec<RollingUpdateErrorErrors>>,
561}
562
563impl common::NestedType for RollingUpdateError {}
564impl common::Part for RollingUpdateError {}
565
566/// [Output Only] The array of errors encountered while processing this operation.
567///
568/// This type is not used in any activity, and only used as *part* of another schema.
569///
570#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
571#[serde_with::serde_as]
572#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
573pub struct RollingUpdateErrorErrors {
574 /// [Output Only] The error type identifier for this error.
575 pub code: Option<String>,
576 /// [Output Only] Indicates the field in the request that caused the error. This property is optional.
577 pub location: Option<String>,
578 /// [Output Only] An optional, human-readable error message.
579 pub message: Option<String>,
580}
581
582impl common::NestedType for RollingUpdateErrorErrors {}
583impl common::Part for RollingUpdateErrorErrors {}
584
585/// Parameters of the update process.
586///
587/// This type is not used in any activity, and only used as *part* of another schema.
588///
589#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
590#[serde_with::serde_as]
591#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
592pub struct RollingUpdatePolicy {
593 /// Number of instances to update before the updater pauses the rolling update.
594 #[serde(rename = "autoPauseAfterInstances")]
595 pub auto_pause_after_instances: Option<i32>,
596 /// The maximum amount of time that the updater waits for a HEALTHY state after all of the update steps are complete. If the HEALTHY state is not received before the deadline, the instance update is considered a failure.
597 #[serde(rename = "instanceStartupTimeoutSec")]
598 pub instance_startup_timeout_sec: Option<i32>,
599 /// The maximum number of instances that can be updated simultaneously. An instance update is considered complete only after the instance is restarted and initialized.
600 #[serde(rename = "maxNumConcurrentInstances")]
601 pub max_num_concurrent_instances: Option<i32>,
602 /// The maximum number of instance updates that can fail before the group update is considered a failure. An instance update is considered failed if any of its update actions (e.g. Stop call on Instance resource in Rolling Reboot) failed with permanent failure, or if the instance is in an UNHEALTHY state after it finishes all of the update actions.
603 #[serde(rename = "maxNumFailedInstances")]
604 pub max_num_failed_instances: Option<i32>,
605 /// The minimum amount of time that the updater spends to update each instance. Update time is the time it takes to complete all update actions (e.g. Stop call on Instance resource in Rolling Reboot), reboot, and initialize. If the instance update finishes early, the updater pauses for the remainder of the time before it starts the next instance update.
606 #[serde(rename = "minInstanceUpdateTimeSec")]
607 pub min_instance_update_time_sec: Option<i32>,
608}
609
610impl common::NestedType for RollingUpdatePolicy {}
611impl common::Part for RollingUpdatePolicy {}
612
613// ###################
614// MethodBuilders ###
615// #################
616
617/// A builder providing access to all methods supported on *rollingUpdate* resources.
618/// It is not used directly, but through the [`Replicapoolupdater`] hub.
619///
620/// # Example
621///
622/// Instantiate a resource builder
623///
624/// ```test_harness,no_run
625/// extern crate hyper;
626/// extern crate hyper_rustls;
627/// extern crate google_replicapoolupdater1_beta1 as replicapoolupdater1_beta1;
628///
629/// # async fn dox() {
630/// use replicapoolupdater1_beta1::{Replicapoolupdater, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
631///
632/// let secret: yup_oauth2::ApplicationSecret = Default::default();
633/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
634/// .with_native_roots()
635/// .unwrap()
636/// .https_only()
637/// .enable_http2()
638/// .build();
639///
640/// let executor = hyper_util::rt::TokioExecutor::new();
641/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
642/// secret,
643/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
644/// yup_oauth2::client::CustomHyperClientBuilder::from(
645/// hyper_util::client::legacy::Client::builder(executor).build(connector),
646/// ),
647/// ).build().await.unwrap();
648///
649/// let client = hyper_util::client::legacy::Client::builder(
650/// hyper_util::rt::TokioExecutor::new()
651/// )
652/// .build(
653/// hyper_rustls::HttpsConnectorBuilder::new()
654/// .with_native_roots()
655/// .unwrap()
656/// .https_or_http()
657/// .enable_http2()
658/// .build()
659/// );
660/// let mut hub = Replicapoolupdater::new(client, auth);
661/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
662/// // like `cancel(...)`, `get(...)`, `insert(...)`, `list(...)`, `list_instance_updates(...)`, `pause(...)`, `resume(...)` and `rollback(...)`
663/// // to build up your call.
664/// let rb = hub.rolling_updates();
665/// # }
666/// ```
667pub struct RollingUpdateMethods<'a, C>
668where
669 C: 'a,
670{
671 hub: &'a Replicapoolupdater<C>,
672}
673
674impl<'a, C> common::MethodsBuilder for RollingUpdateMethods<'a, C> {}
675
676impl<'a, C> RollingUpdateMethods<'a, C> {
677 /// Create a builder to help you perform the following task:
678 ///
679 /// Cancels an update. The update must be PAUSED before it can be cancelled. This has no effect if the update is already CANCELLED.
680 ///
681 /// # Arguments
682 ///
683 /// * `project` - The Google Developers Console project name.
684 /// * `zone` - The name of the zone in which the update's target resides.
685 /// * `rollingUpdate` - The name of the update.
686 pub fn cancel(
687 &self,
688 project: &str,
689 zone: &str,
690 rolling_update: &str,
691 ) -> RollingUpdateCancelCall<'a, C> {
692 RollingUpdateCancelCall {
693 hub: self.hub,
694 _project: project.to_string(),
695 _zone: zone.to_string(),
696 _rolling_update: rolling_update.to_string(),
697 _delegate: Default::default(),
698 _additional_params: Default::default(),
699 _scopes: Default::default(),
700 }
701 }
702
703 /// Create a builder to help you perform the following task:
704 ///
705 /// Returns information about an update.
706 ///
707 /// # Arguments
708 ///
709 /// * `project` - The Google Developers Console project name.
710 /// * `zone` - The name of the zone in which the update's target resides.
711 /// * `rollingUpdate` - The name of the update.
712 pub fn get(
713 &self,
714 project: &str,
715 zone: &str,
716 rolling_update: &str,
717 ) -> RollingUpdateGetCall<'a, C> {
718 RollingUpdateGetCall {
719 hub: self.hub,
720 _project: project.to_string(),
721 _zone: zone.to_string(),
722 _rolling_update: rolling_update.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 /// Inserts and starts a new update.
732 ///
733 /// # Arguments
734 ///
735 /// * `request` - No description provided.
736 /// * `project` - The Google Developers Console project name.
737 /// * `zone` - The name of the zone in which the update's target resides.
738 pub fn insert(
739 &self,
740 request: RollingUpdate,
741 project: &str,
742 zone: &str,
743 ) -> RollingUpdateInsertCall<'a, C> {
744 RollingUpdateInsertCall {
745 hub: self.hub,
746 _request: request,
747 _project: project.to_string(),
748 _zone: zone.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 /// Lists recent updates for a given managed instance group, in reverse chronological order and paginated format.
758 ///
759 /// # Arguments
760 ///
761 /// * `project` - The Google Developers Console project name.
762 /// * `zone` - The name of the zone in which the update's target resides.
763 pub fn list(&self, project: &str, zone: &str) -> RollingUpdateListCall<'a, C> {
764 RollingUpdateListCall {
765 hub: self.hub,
766 _project: project.to_string(),
767 _zone: zone.to_string(),
768 _page_token: Default::default(),
769 _max_results: Default::default(),
770 _filter: Default::default(),
771 _delegate: Default::default(),
772 _additional_params: Default::default(),
773 _scopes: Default::default(),
774 }
775 }
776
777 /// Create a builder to help you perform the following task:
778 ///
779 /// Lists the current status for each instance within a given update.
780 ///
781 /// # Arguments
782 ///
783 /// * `project` - The Google Developers Console project name.
784 /// * `zone` - The name of the zone in which the update's target resides.
785 /// * `rollingUpdate` - The name of the update.
786 pub fn list_instance_updates(
787 &self,
788 project: &str,
789 zone: &str,
790 rolling_update: &str,
791 ) -> RollingUpdateListInstanceUpdateCall<'a, C> {
792 RollingUpdateListInstanceUpdateCall {
793 hub: self.hub,
794 _project: project.to_string(),
795 _zone: zone.to_string(),
796 _rolling_update: rolling_update.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 /// Pauses the update in state from ROLLING_FORWARD or ROLLING_BACK. Has no effect if invoked when the state of the update is PAUSED.
809 ///
810 /// # Arguments
811 ///
812 /// * `project` - The Google Developers Console project name.
813 /// * `zone` - The name of the zone in which the update's target resides.
814 /// * `rollingUpdate` - The name of the update.
815 pub fn pause(
816 &self,
817 project: &str,
818 zone: &str,
819 rolling_update: &str,
820 ) -> RollingUpdatePauseCall<'a, C> {
821 RollingUpdatePauseCall {
822 hub: self.hub,
823 _project: project.to_string(),
824 _zone: zone.to_string(),
825 _rolling_update: rolling_update.to_string(),
826 _delegate: Default::default(),
827 _additional_params: Default::default(),
828 _scopes: Default::default(),
829 }
830 }
831
832 /// Create a builder to help you perform the following task:
833 ///
834 /// Continues an update in PAUSED state. Has no effect if invoked when the state of the update is ROLLED_OUT.
835 ///
836 /// # Arguments
837 ///
838 /// * `project` - The Google Developers Console project name.
839 /// * `zone` - The name of the zone in which the update's target resides.
840 /// * `rollingUpdate` - The name of the update.
841 pub fn resume(
842 &self,
843 project: &str,
844 zone: &str,
845 rolling_update: &str,
846 ) -> RollingUpdateResumeCall<'a, C> {
847 RollingUpdateResumeCall {
848 hub: self.hub,
849 _project: project.to_string(),
850 _zone: zone.to_string(),
851 _rolling_update: rolling_update.to_string(),
852 _delegate: Default::default(),
853 _additional_params: Default::default(),
854 _scopes: Default::default(),
855 }
856 }
857
858 /// Create a builder to help you perform the following task:
859 ///
860 /// Rolls back the update in state from ROLLING_FORWARD or PAUSED. Has no effect if invoked when the state of the update is ROLLED_BACK.
861 ///
862 /// # Arguments
863 ///
864 /// * `project` - The Google Developers Console project name.
865 /// * `zone` - The name of the zone in which the update's target resides.
866 /// * `rollingUpdate` - The name of the update.
867 pub fn rollback(
868 &self,
869 project: &str,
870 zone: &str,
871 rolling_update: &str,
872 ) -> RollingUpdateRollbackCall<'a, C> {
873 RollingUpdateRollbackCall {
874 hub: self.hub,
875 _project: project.to_string(),
876 _zone: zone.to_string(),
877 _rolling_update: rolling_update.to_string(),
878 _delegate: Default::default(),
879 _additional_params: Default::default(),
880 _scopes: Default::default(),
881 }
882 }
883}
884
885/// A builder providing access to all methods supported on *zoneOperation* resources.
886/// It is not used directly, but through the [`Replicapoolupdater`] hub.
887///
888/// # Example
889///
890/// Instantiate a resource builder
891///
892/// ```test_harness,no_run
893/// extern crate hyper;
894/// extern crate hyper_rustls;
895/// extern crate google_replicapoolupdater1_beta1 as replicapoolupdater1_beta1;
896///
897/// # async fn dox() {
898/// use replicapoolupdater1_beta1::{Replicapoolupdater, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
899///
900/// let secret: yup_oauth2::ApplicationSecret = Default::default();
901/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
902/// .with_native_roots()
903/// .unwrap()
904/// .https_only()
905/// .enable_http2()
906/// .build();
907///
908/// let executor = hyper_util::rt::TokioExecutor::new();
909/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
910/// secret,
911/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
912/// yup_oauth2::client::CustomHyperClientBuilder::from(
913/// hyper_util::client::legacy::Client::builder(executor).build(connector),
914/// ),
915/// ).build().await.unwrap();
916///
917/// let client = hyper_util::client::legacy::Client::builder(
918/// hyper_util::rt::TokioExecutor::new()
919/// )
920/// .build(
921/// hyper_rustls::HttpsConnectorBuilder::new()
922/// .with_native_roots()
923/// .unwrap()
924/// .https_or_http()
925/// .enable_http2()
926/// .build()
927/// );
928/// let mut hub = Replicapoolupdater::new(client, auth);
929/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
930/// // like `get(...)` and `list(...)`
931/// // to build up your call.
932/// let rb = hub.zone_operations();
933/// # }
934/// ```
935pub struct ZoneOperationMethods<'a, C>
936where
937 C: 'a,
938{
939 hub: &'a Replicapoolupdater<C>,
940}
941
942impl<'a, C> common::MethodsBuilder for ZoneOperationMethods<'a, C> {}
943
944impl<'a, C> ZoneOperationMethods<'a, C> {
945 /// Create a builder to help you perform the following task:
946 ///
947 /// Retrieves the specified zone-specific operation resource.
948 ///
949 /// # Arguments
950 ///
951 /// * `project` - Name of the project scoping this request.
952 /// * `zone` - Name of the zone scoping this request.
953 /// * `operation` - Name of the operation resource to return.
954 pub fn get(&self, project: &str, zone: &str, operation: &str) -> ZoneOperationGetCall<'a, C> {
955 ZoneOperationGetCall {
956 hub: self.hub,
957 _project: project.to_string(),
958 _zone: zone.to_string(),
959 _operation: operation.to_string(),
960 _delegate: Default::default(),
961 _additional_params: Default::default(),
962 _scopes: Default::default(),
963 }
964 }
965
966 /// Create a builder to help you perform the following task:
967 ///
968 /// Retrieves the list of Operation resources contained within the specified zone.
969 ///
970 /// # Arguments
971 ///
972 /// * `project` - Name of the project scoping this request.
973 /// * `zone` - Name of the zone scoping this request.
974 pub fn list(&self, project: &str, zone: &str) -> ZoneOperationListCall<'a, C> {
975 ZoneOperationListCall {
976 hub: self.hub,
977 _project: project.to_string(),
978 _zone: zone.to_string(),
979 _page_token: Default::default(),
980 _max_results: Default::default(),
981 _filter: Default::default(),
982 _delegate: Default::default(),
983 _additional_params: Default::default(),
984 _scopes: Default::default(),
985 }
986 }
987}
988
989// ###################
990// CallBuilders ###
991// #################
992
993/// Cancels an update. The update must be PAUSED before it can be cancelled. This has no effect if the update is already CANCELLED.
994///
995/// A builder for the *cancel* method supported by a *rollingUpdate* resource.
996/// It is not used directly, but through a [`RollingUpdateMethods`] instance.
997///
998/// # Example
999///
1000/// Instantiate a resource method builder
1001///
1002/// ```test_harness,no_run
1003/// # extern crate hyper;
1004/// # extern crate hyper_rustls;
1005/// # extern crate google_replicapoolupdater1_beta1 as replicapoolupdater1_beta1;
1006/// # async fn dox() {
1007/// # use replicapoolupdater1_beta1::{Replicapoolupdater, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1008///
1009/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1010/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1011/// # .with_native_roots()
1012/// # .unwrap()
1013/// # .https_only()
1014/// # .enable_http2()
1015/// # .build();
1016///
1017/// # let executor = hyper_util::rt::TokioExecutor::new();
1018/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1019/// # secret,
1020/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1021/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1022/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1023/// # ),
1024/// # ).build().await.unwrap();
1025///
1026/// # let client = hyper_util::client::legacy::Client::builder(
1027/// # hyper_util::rt::TokioExecutor::new()
1028/// # )
1029/// # .build(
1030/// # hyper_rustls::HttpsConnectorBuilder::new()
1031/// # .with_native_roots()
1032/// # .unwrap()
1033/// # .https_or_http()
1034/// # .enable_http2()
1035/// # .build()
1036/// # );
1037/// # let mut hub = Replicapoolupdater::new(client, auth);
1038/// // You can configure optional parameters by calling the respective setters at will, and
1039/// // execute the final call using `doit()`.
1040/// // Values shown here are possibly random and not representative !
1041/// let result = hub.rolling_updates().cancel("project", "zone", "rollingUpdate")
1042/// .doit().await;
1043/// # }
1044/// ```
1045pub struct RollingUpdateCancelCall<'a, C>
1046where
1047 C: 'a,
1048{
1049 hub: &'a Replicapoolupdater<C>,
1050 _project: String,
1051 _zone: String,
1052 _rolling_update: String,
1053 _delegate: Option<&'a mut dyn common::Delegate>,
1054 _additional_params: HashMap<String, String>,
1055 _scopes: BTreeSet<String>,
1056}
1057
1058impl<'a, C> common::CallBuilder for RollingUpdateCancelCall<'a, C> {}
1059
1060impl<'a, C> RollingUpdateCancelCall<'a, C>
1061where
1062 C: common::Connector,
1063{
1064 /// Perform the operation you have build so far.
1065 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1066 use std::borrow::Cow;
1067 use std::io::{Read, Seek};
1068
1069 use common::{url::Params, ToParts};
1070 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1071
1072 let mut dd = common::DefaultDelegate;
1073 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1074 dlg.begin(common::MethodInfo {
1075 id: "replicapoolupdater.rollingUpdates.cancel",
1076 http_method: hyper::Method::POST,
1077 });
1078
1079 for &field in ["alt", "project", "zone", "rollingUpdate"].iter() {
1080 if self._additional_params.contains_key(field) {
1081 dlg.finished(false);
1082 return Err(common::Error::FieldClash(field));
1083 }
1084 }
1085
1086 let mut params = Params::with_capacity(5 + self._additional_params.len());
1087 params.push("project", self._project);
1088 params.push("zone", self._zone);
1089 params.push("rollingUpdate", self._rolling_update);
1090
1091 params.extend(self._additional_params.iter());
1092
1093 params.push("alt", "json");
1094 let mut url = self.hub._base_url.clone()
1095 + "{project}/zones/{zone}/rollingUpdates/{rollingUpdate}/cancel";
1096 if self._scopes.is_empty() {
1097 self._scopes
1098 .insert(Scope::CloudPlatform.as_ref().to_string());
1099 }
1100
1101 #[allow(clippy::single_element_loop)]
1102 for &(find_this, param_name) in [
1103 ("{project}", "project"),
1104 ("{zone}", "zone"),
1105 ("{rollingUpdate}", "rollingUpdate"),
1106 ]
1107 .iter()
1108 {
1109 url = params.uri_replacement(url, param_name, find_this, false);
1110 }
1111 {
1112 let to_remove = ["rollingUpdate", "zone", "project"];
1113 params.remove_params(&to_remove);
1114 }
1115
1116 let url = params.parse_with_url(&url);
1117
1118 loop {
1119 let token = match self
1120 .hub
1121 .auth
1122 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1123 .await
1124 {
1125 Ok(token) => token,
1126 Err(e) => match dlg.token(e) {
1127 Ok(token) => token,
1128 Err(e) => {
1129 dlg.finished(false);
1130 return Err(common::Error::MissingToken(e));
1131 }
1132 },
1133 };
1134 let mut req_result = {
1135 let client = &self.hub.client;
1136 dlg.pre_request();
1137 let mut req_builder = hyper::Request::builder()
1138 .method(hyper::Method::POST)
1139 .uri(url.as_str())
1140 .header(USER_AGENT, self.hub._user_agent.clone());
1141
1142 if let Some(token) = token.as_ref() {
1143 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1144 }
1145
1146 let request = req_builder
1147 .header(CONTENT_LENGTH, 0_u64)
1148 .body(common::to_body::<String>(None));
1149
1150 client.request(request.unwrap()).await
1151 };
1152
1153 match req_result {
1154 Err(err) => {
1155 if let common::Retry::After(d) = dlg.http_error(&err) {
1156 sleep(d).await;
1157 continue;
1158 }
1159 dlg.finished(false);
1160 return Err(common::Error::HttpError(err));
1161 }
1162 Ok(res) => {
1163 let (mut parts, body) = res.into_parts();
1164 let mut body = common::Body::new(body);
1165 if !parts.status.is_success() {
1166 let bytes = common::to_bytes(body).await.unwrap_or_default();
1167 let error = serde_json::from_str(&common::to_string(&bytes));
1168 let response = common::to_response(parts, bytes.into());
1169
1170 if let common::Retry::After(d) =
1171 dlg.http_failure(&response, error.as_ref().ok())
1172 {
1173 sleep(d).await;
1174 continue;
1175 }
1176
1177 dlg.finished(false);
1178
1179 return Err(match error {
1180 Ok(value) => common::Error::BadRequest(value),
1181 _ => common::Error::Failure(response),
1182 });
1183 }
1184 let response = {
1185 let bytes = common::to_bytes(body).await.unwrap_or_default();
1186 let encoded = common::to_string(&bytes);
1187 match serde_json::from_str(&encoded) {
1188 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1189 Err(error) => {
1190 dlg.response_json_decode_error(&encoded, &error);
1191 return Err(common::Error::JsonDecodeError(
1192 encoded.to_string(),
1193 error,
1194 ));
1195 }
1196 }
1197 };
1198
1199 dlg.finished(true);
1200 return Ok(response);
1201 }
1202 }
1203 }
1204 }
1205
1206 /// The Google Developers Console project name.
1207 ///
1208 /// Sets the *project* path property to the given value.
1209 ///
1210 /// Even though the property as already been set when instantiating this call,
1211 /// we provide this method for API completeness.
1212 pub fn project(mut self, new_value: &str) -> RollingUpdateCancelCall<'a, C> {
1213 self._project = new_value.to_string();
1214 self
1215 }
1216 /// The name of the zone in which the update's target resides.
1217 ///
1218 /// Sets the *zone* path property to the given value.
1219 ///
1220 /// Even though the property as already been set when instantiating this call,
1221 /// we provide this method for API completeness.
1222 pub fn zone(mut self, new_value: &str) -> RollingUpdateCancelCall<'a, C> {
1223 self._zone = new_value.to_string();
1224 self
1225 }
1226 /// The name of the update.
1227 ///
1228 /// Sets the *rolling update* path property to the given value.
1229 ///
1230 /// Even though the property as already been set when instantiating this call,
1231 /// we provide this method for API completeness.
1232 pub fn rolling_update(mut self, new_value: &str) -> RollingUpdateCancelCall<'a, C> {
1233 self._rolling_update = new_value.to_string();
1234 self
1235 }
1236 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1237 /// while executing the actual API request.
1238 ///
1239 /// ````text
1240 /// It should be used to handle progress information, and to implement a certain level of resilience.
1241 /// ````
1242 ///
1243 /// Sets the *delegate* property to the given value.
1244 pub fn delegate(
1245 mut self,
1246 new_value: &'a mut dyn common::Delegate,
1247 ) -> RollingUpdateCancelCall<'a, C> {
1248 self._delegate = Some(new_value);
1249 self
1250 }
1251
1252 /// Set any additional parameter of the query string used in the request.
1253 /// It should be used to set parameters which are not yet available through their own
1254 /// setters.
1255 ///
1256 /// Please note that this method must not be used to set any of the known parameters
1257 /// which have their own setter method. If done anyway, the request will fail.
1258 ///
1259 /// # Additional Parameters
1260 ///
1261 /// * *alt* (query-string) - Data format for the response.
1262 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1263 /// * *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.
1264 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1265 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1266 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
1267 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
1268 pub fn param<T>(mut self, name: T, value: T) -> RollingUpdateCancelCall<'a, C>
1269 where
1270 T: AsRef<str>,
1271 {
1272 self._additional_params
1273 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1274 self
1275 }
1276
1277 /// Identifies the authorization scope for the method you are building.
1278 ///
1279 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1280 /// [`Scope::CloudPlatform`].
1281 ///
1282 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1283 /// tokens for more than one scope.
1284 ///
1285 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1286 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1287 /// sufficient, a read-write scope will do as well.
1288 pub fn add_scope<St>(mut self, scope: St) -> RollingUpdateCancelCall<'a, C>
1289 where
1290 St: AsRef<str>,
1291 {
1292 self._scopes.insert(String::from(scope.as_ref()));
1293 self
1294 }
1295 /// Identifies the authorization scope(s) for the method you are building.
1296 ///
1297 /// See [`Self::add_scope()`] for details.
1298 pub fn add_scopes<I, St>(mut self, scopes: I) -> RollingUpdateCancelCall<'a, C>
1299 where
1300 I: IntoIterator<Item = St>,
1301 St: AsRef<str>,
1302 {
1303 self._scopes
1304 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1305 self
1306 }
1307
1308 /// Removes all scopes, and no default scope will be used either.
1309 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1310 /// for details).
1311 pub fn clear_scopes(mut self) -> RollingUpdateCancelCall<'a, C> {
1312 self._scopes.clear();
1313 self
1314 }
1315}
1316
1317/// Returns information about an update.
1318///
1319/// A builder for the *get* method supported by a *rollingUpdate* resource.
1320/// It is not used directly, but through a [`RollingUpdateMethods`] instance.
1321///
1322/// # Example
1323///
1324/// Instantiate a resource method builder
1325///
1326/// ```test_harness,no_run
1327/// # extern crate hyper;
1328/// # extern crate hyper_rustls;
1329/// # extern crate google_replicapoolupdater1_beta1 as replicapoolupdater1_beta1;
1330/// # async fn dox() {
1331/// # use replicapoolupdater1_beta1::{Replicapoolupdater, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1332///
1333/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1334/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1335/// # .with_native_roots()
1336/// # .unwrap()
1337/// # .https_only()
1338/// # .enable_http2()
1339/// # .build();
1340///
1341/// # let executor = hyper_util::rt::TokioExecutor::new();
1342/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1343/// # secret,
1344/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1345/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1346/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1347/// # ),
1348/// # ).build().await.unwrap();
1349///
1350/// # let client = hyper_util::client::legacy::Client::builder(
1351/// # hyper_util::rt::TokioExecutor::new()
1352/// # )
1353/// # .build(
1354/// # hyper_rustls::HttpsConnectorBuilder::new()
1355/// # .with_native_roots()
1356/// # .unwrap()
1357/// # .https_or_http()
1358/// # .enable_http2()
1359/// # .build()
1360/// # );
1361/// # let mut hub = Replicapoolupdater::new(client, auth);
1362/// // You can configure optional parameters by calling the respective setters at will, and
1363/// // execute the final call using `doit()`.
1364/// // Values shown here are possibly random and not representative !
1365/// let result = hub.rolling_updates().get("project", "zone", "rollingUpdate")
1366/// .doit().await;
1367/// # }
1368/// ```
1369pub struct RollingUpdateGetCall<'a, C>
1370where
1371 C: 'a,
1372{
1373 hub: &'a Replicapoolupdater<C>,
1374 _project: String,
1375 _zone: String,
1376 _rolling_update: String,
1377 _delegate: Option<&'a mut dyn common::Delegate>,
1378 _additional_params: HashMap<String, String>,
1379 _scopes: BTreeSet<String>,
1380}
1381
1382impl<'a, C> common::CallBuilder for RollingUpdateGetCall<'a, C> {}
1383
1384impl<'a, C> RollingUpdateGetCall<'a, C>
1385where
1386 C: common::Connector,
1387{
1388 /// Perform the operation you have build so far.
1389 pub async fn doit(mut self) -> common::Result<(common::Response, RollingUpdate)> {
1390 use std::borrow::Cow;
1391 use std::io::{Read, Seek};
1392
1393 use common::{url::Params, ToParts};
1394 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1395
1396 let mut dd = common::DefaultDelegate;
1397 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1398 dlg.begin(common::MethodInfo {
1399 id: "replicapoolupdater.rollingUpdates.get",
1400 http_method: hyper::Method::GET,
1401 });
1402
1403 for &field in ["alt", "project", "zone", "rollingUpdate"].iter() {
1404 if self._additional_params.contains_key(field) {
1405 dlg.finished(false);
1406 return Err(common::Error::FieldClash(field));
1407 }
1408 }
1409
1410 let mut params = Params::with_capacity(5 + self._additional_params.len());
1411 params.push("project", self._project);
1412 params.push("zone", self._zone);
1413 params.push("rollingUpdate", self._rolling_update);
1414
1415 params.extend(self._additional_params.iter());
1416
1417 params.push("alt", "json");
1418 let mut url =
1419 self.hub._base_url.clone() + "{project}/zones/{zone}/rollingUpdates/{rollingUpdate}";
1420 if self._scopes.is_empty() {
1421 self._scopes
1422 .insert(Scope::ReplicapoolReadonly.as_ref().to_string());
1423 }
1424
1425 #[allow(clippy::single_element_loop)]
1426 for &(find_this, param_name) in [
1427 ("{project}", "project"),
1428 ("{zone}", "zone"),
1429 ("{rollingUpdate}", "rollingUpdate"),
1430 ]
1431 .iter()
1432 {
1433 url = params.uri_replacement(url, param_name, find_this, false);
1434 }
1435 {
1436 let to_remove = ["rollingUpdate", "zone", "project"];
1437 params.remove_params(&to_remove);
1438 }
1439
1440 let url = params.parse_with_url(&url);
1441
1442 loop {
1443 let token = match self
1444 .hub
1445 .auth
1446 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1447 .await
1448 {
1449 Ok(token) => token,
1450 Err(e) => match dlg.token(e) {
1451 Ok(token) => token,
1452 Err(e) => {
1453 dlg.finished(false);
1454 return Err(common::Error::MissingToken(e));
1455 }
1456 },
1457 };
1458 let mut req_result = {
1459 let client = &self.hub.client;
1460 dlg.pre_request();
1461 let mut req_builder = hyper::Request::builder()
1462 .method(hyper::Method::GET)
1463 .uri(url.as_str())
1464 .header(USER_AGENT, self.hub._user_agent.clone());
1465
1466 if let Some(token) = token.as_ref() {
1467 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1468 }
1469
1470 let request = req_builder
1471 .header(CONTENT_LENGTH, 0_u64)
1472 .body(common::to_body::<String>(None));
1473
1474 client.request(request.unwrap()).await
1475 };
1476
1477 match req_result {
1478 Err(err) => {
1479 if let common::Retry::After(d) = dlg.http_error(&err) {
1480 sleep(d).await;
1481 continue;
1482 }
1483 dlg.finished(false);
1484 return Err(common::Error::HttpError(err));
1485 }
1486 Ok(res) => {
1487 let (mut parts, body) = res.into_parts();
1488 let mut body = common::Body::new(body);
1489 if !parts.status.is_success() {
1490 let bytes = common::to_bytes(body).await.unwrap_or_default();
1491 let error = serde_json::from_str(&common::to_string(&bytes));
1492 let response = common::to_response(parts, bytes.into());
1493
1494 if let common::Retry::After(d) =
1495 dlg.http_failure(&response, error.as_ref().ok())
1496 {
1497 sleep(d).await;
1498 continue;
1499 }
1500
1501 dlg.finished(false);
1502
1503 return Err(match error {
1504 Ok(value) => common::Error::BadRequest(value),
1505 _ => common::Error::Failure(response),
1506 });
1507 }
1508 let response = {
1509 let bytes = common::to_bytes(body).await.unwrap_or_default();
1510 let encoded = common::to_string(&bytes);
1511 match serde_json::from_str(&encoded) {
1512 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1513 Err(error) => {
1514 dlg.response_json_decode_error(&encoded, &error);
1515 return Err(common::Error::JsonDecodeError(
1516 encoded.to_string(),
1517 error,
1518 ));
1519 }
1520 }
1521 };
1522
1523 dlg.finished(true);
1524 return Ok(response);
1525 }
1526 }
1527 }
1528 }
1529
1530 /// The Google Developers Console project name.
1531 ///
1532 /// Sets the *project* path property to the given value.
1533 ///
1534 /// Even though the property as already been set when instantiating this call,
1535 /// we provide this method for API completeness.
1536 pub fn project(mut self, new_value: &str) -> RollingUpdateGetCall<'a, C> {
1537 self._project = new_value.to_string();
1538 self
1539 }
1540 /// The name of the zone in which the update's target resides.
1541 ///
1542 /// Sets the *zone* path property to the given value.
1543 ///
1544 /// Even though the property as already been set when instantiating this call,
1545 /// we provide this method for API completeness.
1546 pub fn zone(mut self, new_value: &str) -> RollingUpdateGetCall<'a, C> {
1547 self._zone = new_value.to_string();
1548 self
1549 }
1550 /// The name of the update.
1551 ///
1552 /// Sets the *rolling update* path property to the given value.
1553 ///
1554 /// Even though the property as already been set when instantiating this call,
1555 /// we provide this method for API completeness.
1556 pub fn rolling_update(mut self, new_value: &str) -> RollingUpdateGetCall<'a, C> {
1557 self._rolling_update = new_value.to_string();
1558 self
1559 }
1560 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1561 /// while executing the actual API request.
1562 ///
1563 /// ````text
1564 /// It should be used to handle progress information, and to implement a certain level of resilience.
1565 /// ````
1566 ///
1567 /// Sets the *delegate* property to the given value.
1568 pub fn delegate(
1569 mut self,
1570 new_value: &'a mut dyn common::Delegate,
1571 ) -> RollingUpdateGetCall<'a, C> {
1572 self._delegate = Some(new_value);
1573 self
1574 }
1575
1576 /// Set any additional parameter of the query string used in the request.
1577 /// It should be used to set parameters which are not yet available through their own
1578 /// setters.
1579 ///
1580 /// Please note that this method must not be used to set any of the known parameters
1581 /// which have their own setter method. If done anyway, the request will fail.
1582 ///
1583 /// # Additional Parameters
1584 ///
1585 /// * *alt* (query-string) - Data format for the response.
1586 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1587 /// * *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.
1588 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1589 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1590 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
1591 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
1592 pub fn param<T>(mut self, name: T, value: T) -> RollingUpdateGetCall<'a, C>
1593 where
1594 T: AsRef<str>,
1595 {
1596 self._additional_params
1597 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1598 self
1599 }
1600
1601 /// Identifies the authorization scope for the method you are building.
1602 ///
1603 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1604 /// [`Scope::ReplicapoolReadonly`].
1605 ///
1606 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1607 /// tokens for more than one scope.
1608 ///
1609 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1610 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1611 /// sufficient, a read-write scope will do as well.
1612 pub fn add_scope<St>(mut self, scope: St) -> RollingUpdateGetCall<'a, C>
1613 where
1614 St: AsRef<str>,
1615 {
1616 self._scopes.insert(String::from(scope.as_ref()));
1617 self
1618 }
1619 /// Identifies the authorization scope(s) for the method you are building.
1620 ///
1621 /// See [`Self::add_scope()`] for details.
1622 pub fn add_scopes<I, St>(mut self, scopes: I) -> RollingUpdateGetCall<'a, C>
1623 where
1624 I: IntoIterator<Item = St>,
1625 St: AsRef<str>,
1626 {
1627 self._scopes
1628 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1629 self
1630 }
1631
1632 /// Removes all scopes, and no default scope will be used either.
1633 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1634 /// for details).
1635 pub fn clear_scopes(mut self) -> RollingUpdateGetCall<'a, C> {
1636 self._scopes.clear();
1637 self
1638 }
1639}
1640
1641/// Inserts and starts a new update.
1642///
1643/// A builder for the *insert* method supported by a *rollingUpdate* resource.
1644/// It is not used directly, but through a [`RollingUpdateMethods`] instance.
1645///
1646/// # Example
1647///
1648/// Instantiate a resource method builder
1649///
1650/// ```test_harness,no_run
1651/// # extern crate hyper;
1652/// # extern crate hyper_rustls;
1653/// # extern crate google_replicapoolupdater1_beta1 as replicapoolupdater1_beta1;
1654/// use replicapoolupdater1_beta1::api::RollingUpdate;
1655/// # async fn dox() {
1656/// # use replicapoolupdater1_beta1::{Replicapoolupdater, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1657///
1658/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1659/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1660/// # .with_native_roots()
1661/// # .unwrap()
1662/// # .https_only()
1663/// # .enable_http2()
1664/// # .build();
1665///
1666/// # let executor = hyper_util::rt::TokioExecutor::new();
1667/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1668/// # secret,
1669/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1670/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1671/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1672/// # ),
1673/// # ).build().await.unwrap();
1674///
1675/// # let client = hyper_util::client::legacy::Client::builder(
1676/// # hyper_util::rt::TokioExecutor::new()
1677/// # )
1678/// # .build(
1679/// # hyper_rustls::HttpsConnectorBuilder::new()
1680/// # .with_native_roots()
1681/// # .unwrap()
1682/// # .https_or_http()
1683/// # .enable_http2()
1684/// # .build()
1685/// # );
1686/// # let mut hub = Replicapoolupdater::new(client, auth);
1687/// // As the method needs a request, you would usually fill it with the desired information
1688/// // into the respective structure. Some of the parts shown here might not be applicable !
1689/// // Values shown here are possibly random and not representative !
1690/// let mut req = RollingUpdate::default();
1691///
1692/// // You can configure optional parameters by calling the respective setters at will, and
1693/// // execute the final call using `doit()`.
1694/// // Values shown here are possibly random and not representative !
1695/// let result = hub.rolling_updates().insert(req, "project", "zone")
1696/// .doit().await;
1697/// # }
1698/// ```
1699pub struct RollingUpdateInsertCall<'a, C>
1700where
1701 C: 'a,
1702{
1703 hub: &'a Replicapoolupdater<C>,
1704 _request: RollingUpdate,
1705 _project: String,
1706 _zone: String,
1707 _delegate: Option<&'a mut dyn common::Delegate>,
1708 _additional_params: HashMap<String, String>,
1709 _scopes: BTreeSet<String>,
1710}
1711
1712impl<'a, C> common::CallBuilder for RollingUpdateInsertCall<'a, C> {}
1713
1714impl<'a, C> RollingUpdateInsertCall<'a, C>
1715where
1716 C: common::Connector,
1717{
1718 /// Perform the operation you have build so far.
1719 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1720 use std::borrow::Cow;
1721 use std::io::{Read, Seek};
1722
1723 use common::{url::Params, ToParts};
1724 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1725
1726 let mut dd = common::DefaultDelegate;
1727 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1728 dlg.begin(common::MethodInfo {
1729 id: "replicapoolupdater.rollingUpdates.insert",
1730 http_method: hyper::Method::POST,
1731 });
1732
1733 for &field in ["alt", "project", "zone"].iter() {
1734 if self._additional_params.contains_key(field) {
1735 dlg.finished(false);
1736 return Err(common::Error::FieldClash(field));
1737 }
1738 }
1739
1740 let mut params = Params::with_capacity(5 + self._additional_params.len());
1741 params.push("project", self._project);
1742 params.push("zone", self._zone);
1743
1744 params.extend(self._additional_params.iter());
1745
1746 params.push("alt", "json");
1747 let mut url = self.hub._base_url.clone() + "{project}/zones/{zone}/rollingUpdates";
1748 if self._scopes.is_empty() {
1749 self._scopes
1750 .insert(Scope::CloudPlatform.as_ref().to_string());
1751 }
1752
1753 #[allow(clippy::single_element_loop)]
1754 for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() {
1755 url = params.uri_replacement(url, param_name, find_this, false);
1756 }
1757 {
1758 let to_remove = ["zone", "project"];
1759 params.remove_params(&to_remove);
1760 }
1761
1762 let url = params.parse_with_url(&url);
1763
1764 let mut json_mime_type = mime::APPLICATION_JSON;
1765 let mut request_value_reader = {
1766 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1767 common::remove_json_null_values(&mut value);
1768 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1769 serde_json::to_writer(&mut dst, &value).unwrap();
1770 dst
1771 };
1772 let request_size = request_value_reader
1773 .seek(std::io::SeekFrom::End(0))
1774 .unwrap();
1775 request_value_reader
1776 .seek(std::io::SeekFrom::Start(0))
1777 .unwrap();
1778
1779 loop {
1780 let token = match self
1781 .hub
1782 .auth
1783 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1784 .await
1785 {
1786 Ok(token) => token,
1787 Err(e) => match dlg.token(e) {
1788 Ok(token) => token,
1789 Err(e) => {
1790 dlg.finished(false);
1791 return Err(common::Error::MissingToken(e));
1792 }
1793 },
1794 };
1795 request_value_reader
1796 .seek(std::io::SeekFrom::Start(0))
1797 .unwrap();
1798 let mut req_result = {
1799 let client = &self.hub.client;
1800 dlg.pre_request();
1801 let mut req_builder = hyper::Request::builder()
1802 .method(hyper::Method::POST)
1803 .uri(url.as_str())
1804 .header(USER_AGENT, self.hub._user_agent.clone());
1805
1806 if let Some(token) = token.as_ref() {
1807 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1808 }
1809
1810 let request = req_builder
1811 .header(CONTENT_TYPE, json_mime_type.to_string())
1812 .header(CONTENT_LENGTH, request_size as u64)
1813 .body(common::to_body(
1814 request_value_reader.get_ref().clone().into(),
1815 ));
1816
1817 client.request(request.unwrap()).await
1818 };
1819
1820 match req_result {
1821 Err(err) => {
1822 if let common::Retry::After(d) = dlg.http_error(&err) {
1823 sleep(d).await;
1824 continue;
1825 }
1826 dlg.finished(false);
1827 return Err(common::Error::HttpError(err));
1828 }
1829 Ok(res) => {
1830 let (mut parts, body) = res.into_parts();
1831 let mut body = common::Body::new(body);
1832 if !parts.status.is_success() {
1833 let bytes = common::to_bytes(body).await.unwrap_or_default();
1834 let error = serde_json::from_str(&common::to_string(&bytes));
1835 let response = common::to_response(parts, bytes.into());
1836
1837 if let common::Retry::After(d) =
1838 dlg.http_failure(&response, error.as_ref().ok())
1839 {
1840 sleep(d).await;
1841 continue;
1842 }
1843
1844 dlg.finished(false);
1845
1846 return Err(match error {
1847 Ok(value) => common::Error::BadRequest(value),
1848 _ => common::Error::Failure(response),
1849 });
1850 }
1851 let response = {
1852 let bytes = common::to_bytes(body).await.unwrap_or_default();
1853 let encoded = common::to_string(&bytes);
1854 match serde_json::from_str(&encoded) {
1855 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1856 Err(error) => {
1857 dlg.response_json_decode_error(&encoded, &error);
1858 return Err(common::Error::JsonDecodeError(
1859 encoded.to_string(),
1860 error,
1861 ));
1862 }
1863 }
1864 };
1865
1866 dlg.finished(true);
1867 return Ok(response);
1868 }
1869 }
1870 }
1871 }
1872
1873 ///
1874 /// Sets the *request* property to the given value.
1875 ///
1876 /// Even though the property as already been set when instantiating this call,
1877 /// we provide this method for API completeness.
1878 pub fn request(mut self, new_value: RollingUpdate) -> RollingUpdateInsertCall<'a, C> {
1879 self._request = new_value;
1880 self
1881 }
1882 /// The Google Developers Console project name.
1883 ///
1884 /// Sets the *project* path property to the given value.
1885 ///
1886 /// Even though the property as already been set when instantiating this call,
1887 /// we provide this method for API completeness.
1888 pub fn project(mut self, new_value: &str) -> RollingUpdateInsertCall<'a, C> {
1889 self._project = new_value.to_string();
1890 self
1891 }
1892 /// The name of the zone in which the update's target resides.
1893 ///
1894 /// Sets the *zone* path property to the given value.
1895 ///
1896 /// Even though the property as already been set when instantiating this call,
1897 /// we provide this method for API completeness.
1898 pub fn zone(mut self, new_value: &str) -> RollingUpdateInsertCall<'a, C> {
1899 self._zone = new_value.to_string();
1900 self
1901 }
1902 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1903 /// while executing the actual API request.
1904 ///
1905 /// ````text
1906 /// It should be used to handle progress information, and to implement a certain level of resilience.
1907 /// ````
1908 ///
1909 /// Sets the *delegate* property to the given value.
1910 pub fn delegate(
1911 mut self,
1912 new_value: &'a mut dyn common::Delegate,
1913 ) -> RollingUpdateInsertCall<'a, C> {
1914 self._delegate = Some(new_value);
1915 self
1916 }
1917
1918 /// Set any additional parameter of the query string used in the request.
1919 /// It should be used to set parameters which are not yet available through their own
1920 /// setters.
1921 ///
1922 /// Please note that this method must not be used to set any of the known parameters
1923 /// which have their own setter method. If done anyway, the request will fail.
1924 ///
1925 /// # Additional Parameters
1926 ///
1927 /// * *alt* (query-string) - Data format for the response.
1928 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1929 /// * *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.
1930 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1931 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1932 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
1933 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
1934 pub fn param<T>(mut self, name: T, value: T) -> RollingUpdateInsertCall<'a, C>
1935 where
1936 T: AsRef<str>,
1937 {
1938 self._additional_params
1939 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1940 self
1941 }
1942
1943 /// Identifies the authorization scope for the method you are building.
1944 ///
1945 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1946 /// [`Scope::CloudPlatform`].
1947 ///
1948 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1949 /// tokens for more than one scope.
1950 ///
1951 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1952 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1953 /// sufficient, a read-write scope will do as well.
1954 pub fn add_scope<St>(mut self, scope: St) -> RollingUpdateInsertCall<'a, C>
1955 where
1956 St: AsRef<str>,
1957 {
1958 self._scopes.insert(String::from(scope.as_ref()));
1959 self
1960 }
1961 /// Identifies the authorization scope(s) for the method you are building.
1962 ///
1963 /// See [`Self::add_scope()`] for details.
1964 pub fn add_scopes<I, St>(mut self, scopes: I) -> RollingUpdateInsertCall<'a, C>
1965 where
1966 I: IntoIterator<Item = St>,
1967 St: AsRef<str>,
1968 {
1969 self._scopes
1970 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1971 self
1972 }
1973
1974 /// Removes all scopes, and no default scope will be used either.
1975 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1976 /// for details).
1977 pub fn clear_scopes(mut self) -> RollingUpdateInsertCall<'a, C> {
1978 self._scopes.clear();
1979 self
1980 }
1981}
1982
1983/// Lists recent updates for a given managed instance group, in reverse chronological order and paginated format.
1984///
1985/// A builder for the *list* method supported by a *rollingUpdate* resource.
1986/// It is not used directly, but through a [`RollingUpdateMethods`] instance.
1987///
1988/// # Example
1989///
1990/// Instantiate a resource method builder
1991///
1992/// ```test_harness,no_run
1993/// # extern crate hyper;
1994/// # extern crate hyper_rustls;
1995/// # extern crate google_replicapoolupdater1_beta1 as replicapoolupdater1_beta1;
1996/// # async fn dox() {
1997/// # use replicapoolupdater1_beta1::{Replicapoolupdater, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1998///
1999/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2000/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2001/// # .with_native_roots()
2002/// # .unwrap()
2003/// # .https_only()
2004/// # .enable_http2()
2005/// # .build();
2006///
2007/// # let executor = hyper_util::rt::TokioExecutor::new();
2008/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2009/// # secret,
2010/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2011/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2012/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2013/// # ),
2014/// # ).build().await.unwrap();
2015///
2016/// # let client = hyper_util::client::legacy::Client::builder(
2017/// # hyper_util::rt::TokioExecutor::new()
2018/// # )
2019/// # .build(
2020/// # hyper_rustls::HttpsConnectorBuilder::new()
2021/// # .with_native_roots()
2022/// # .unwrap()
2023/// # .https_or_http()
2024/// # .enable_http2()
2025/// # .build()
2026/// # );
2027/// # let mut hub = Replicapoolupdater::new(client, auth);
2028/// // You can configure optional parameters by calling the respective setters at will, and
2029/// // execute the final call using `doit()`.
2030/// // Values shown here are possibly random and not representative !
2031/// let result = hub.rolling_updates().list("project", "zone")
2032/// .page_token("est")
2033/// .max_results(51)
2034/// .filter("ipsum")
2035/// .doit().await;
2036/// # }
2037/// ```
2038pub struct RollingUpdateListCall<'a, C>
2039where
2040 C: 'a,
2041{
2042 hub: &'a Replicapoolupdater<C>,
2043 _project: String,
2044 _zone: String,
2045 _page_token: Option<String>,
2046 _max_results: Option<u32>,
2047 _filter: Option<String>,
2048 _delegate: Option<&'a mut dyn common::Delegate>,
2049 _additional_params: HashMap<String, String>,
2050 _scopes: BTreeSet<String>,
2051}
2052
2053impl<'a, C> common::CallBuilder for RollingUpdateListCall<'a, C> {}
2054
2055impl<'a, C> RollingUpdateListCall<'a, C>
2056where
2057 C: common::Connector,
2058{
2059 /// Perform the operation you have build so far.
2060 pub async fn doit(mut self) -> common::Result<(common::Response, RollingUpdateList)> {
2061 use std::borrow::Cow;
2062 use std::io::{Read, Seek};
2063
2064 use common::{url::Params, ToParts};
2065 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2066
2067 let mut dd = common::DefaultDelegate;
2068 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2069 dlg.begin(common::MethodInfo {
2070 id: "replicapoolupdater.rollingUpdates.list",
2071 http_method: hyper::Method::GET,
2072 });
2073
2074 for &field in [
2075 "alt",
2076 "project",
2077 "zone",
2078 "pageToken",
2079 "maxResults",
2080 "filter",
2081 ]
2082 .iter()
2083 {
2084 if self._additional_params.contains_key(field) {
2085 dlg.finished(false);
2086 return Err(common::Error::FieldClash(field));
2087 }
2088 }
2089
2090 let mut params = Params::with_capacity(7 + self._additional_params.len());
2091 params.push("project", self._project);
2092 params.push("zone", self._zone);
2093 if let Some(value) = self._page_token.as_ref() {
2094 params.push("pageToken", value);
2095 }
2096 if let Some(value) = self._max_results.as_ref() {
2097 params.push("maxResults", value.to_string());
2098 }
2099 if let Some(value) = self._filter.as_ref() {
2100 params.push("filter", value);
2101 }
2102
2103 params.extend(self._additional_params.iter());
2104
2105 params.push("alt", "json");
2106 let mut url = self.hub._base_url.clone() + "{project}/zones/{zone}/rollingUpdates";
2107 if self._scopes.is_empty() {
2108 self._scopes
2109 .insert(Scope::ReplicapoolReadonly.as_ref().to_string());
2110 }
2111
2112 #[allow(clippy::single_element_loop)]
2113 for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() {
2114 url = params.uri_replacement(url, param_name, find_this, false);
2115 }
2116 {
2117 let to_remove = ["zone", "project"];
2118 params.remove_params(&to_remove);
2119 }
2120
2121 let url = params.parse_with_url(&url);
2122
2123 loop {
2124 let token = match self
2125 .hub
2126 .auth
2127 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2128 .await
2129 {
2130 Ok(token) => token,
2131 Err(e) => match dlg.token(e) {
2132 Ok(token) => token,
2133 Err(e) => {
2134 dlg.finished(false);
2135 return Err(common::Error::MissingToken(e));
2136 }
2137 },
2138 };
2139 let mut req_result = {
2140 let client = &self.hub.client;
2141 dlg.pre_request();
2142 let mut req_builder = hyper::Request::builder()
2143 .method(hyper::Method::GET)
2144 .uri(url.as_str())
2145 .header(USER_AGENT, self.hub._user_agent.clone());
2146
2147 if let Some(token) = token.as_ref() {
2148 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2149 }
2150
2151 let request = req_builder
2152 .header(CONTENT_LENGTH, 0_u64)
2153 .body(common::to_body::<String>(None));
2154
2155 client.request(request.unwrap()).await
2156 };
2157
2158 match req_result {
2159 Err(err) => {
2160 if let common::Retry::After(d) = dlg.http_error(&err) {
2161 sleep(d).await;
2162 continue;
2163 }
2164 dlg.finished(false);
2165 return Err(common::Error::HttpError(err));
2166 }
2167 Ok(res) => {
2168 let (mut parts, body) = res.into_parts();
2169 let mut body = common::Body::new(body);
2170 if !parts.status.is_success() {
2171 let bytes = common::to_bytes(body).await.unwrap_or_default();
2172 let error = serde_json::from_str(&common::to_string(&bytes));
2173 let response = common::to_response(parts, bytes.into());
2174
2175 if let common::Retry::After(d) =
2176 dlg.http_failure(&response, error.as_ref().ok())
2177 {
2178 sleep(d).await;
2179 continue;
2180 }
2181
2182 dlg.finished(false);
2183
2184 return Err(match error {
2185 Ok(value) => common::Error::BadRequest(value),
2186 _ => common::Error::Failure(response),
2187 });
2188 }
2189 let response = {
2190 let bytes = common::to_bytes(body).await.unwrap_or_default();
2191 let encoded = common::to_string(&bytes);
2192 match serde_json::from_str(&encoded) {
2193 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2194 Err(error) => {
2195 dlg.response_json_decode_error(&encoded, &error);
2196 return Err(common::Error::JsonDecodeError(
2197 encoded.to_string(),
2198 error,
2199 ));
2200 }
2201 }
2202 };
2203
2204 dlg.finished(true);
2205 return Ok(response);
2206 }
2207 }
2208 }
2209 }
2210
2211 /// The Google Developers Console project name.
2212 ///
2213 /// Sets the *project* path property to the given value.
2214 ///
2215 /// Even though the property as already been set when instantiating this call,
2216 /// we provide this method for API completeness.
2217 pub fn project(mut self, new_value: &str) -> RollingUpdateListCall<'a, C> {
2218 self._project = new_value.to_string();
2219 self
2220 }
2221 /// The name of the zone in which the update's target resides.
2222 ///
2223 /// Sets the *zone* path property to the given value.
2224 ///
2225 /// Even though the property as already been set when instantiating this call,
2226 /// we provide this method for API completeness.
2227 pub fn zone(mut self, new_value: &str) -> RollingUpdateListCall<'a, C> {
2228 self._zone = new_value.to_string();
2229 self
2230 }
2231 /// Optional. Tag returned by a previous list request truncated by maxResults. Used to continue a previous list request.
2232 ///
2233 /// Sets the *page token* query property to the given value.
2234 pub fn page_token(mut self, new_value: &str) -> RollingUpdateListCall<'a, C> {
2235 self._page_token = Some(new_value.to_string());
2236 self
2237 }
2238 /// Optional. Maximum count of results to be returned. Maximum value is 500 and default value is 500.
2239 ///
2240 /// Sets the *max results* query property to the given value.
2241 pub fn max_results(mut self, new_value: u32) -> RollingUpdateListCall<'a, C> {
2242 self._max_results = Some(new_value);
2243 self
2244 }
2245 /// Optional. Filter expression for filtering listed resources.
2246 ///
2247 /// Sets the *filter* query property to the given value.
2248 pub fn filter(mut self, new_value: &str) -> RollingUpdateListCall<'a, C> {
2249 self._filter = Some(new_value.to_string());
2250 self
2251 }
2252 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2253 /// while executing the actual API request.
2254 ///
2255 /// ````text
2256 /// It should be used to handle progress information, and to implement a certain level of resilience.
2257 /// ````
2258 ///
2259 /// Sets the *delegate* property to the given value.
2260 pub fn delegate(
2261 mut self,
2262 new_value: &'a mut dyn common::Delegate,
2263 ) -> RollingUpdateListCall<'a, C> {
2264 self._delegate = Some(new_value);
2265 self
2266 }
2267
2268 /// Set any additional parameter of the query string used in the request.
2269 /// It should be used to set parameters which are not yet available through their own
2270 /// setters.
2271 ///
2272 /// Please note that this method must not be used to set any of the known parameters
2273 /// which have their own setter method. If done anyway, the request will fail.
2274 ///
2275 /// # Additional Parameters
2276 ///
2277 /// * *alt* (query-string) - Data format for the response.
2278 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2279 /// * *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.
2280 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2281 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2282 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
2283 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
2284 pub fn param<T>(mut self, name: T, value: T) -> RollingUpdateListCall<'a, C>
2285 where
2286 T: AsRef<str>,
2287 {
2288 self._additional_params
2289 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2290 self
2291 }
2292
2293 /// Identifies the authorization scope for the method you are building.
2294 ///
2295 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2296 /// [`Scope::ReplicapoolReadonly`].
2297 ///
2298 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2299 /// tokens for more than one scope.
2300 ///
2301 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2302 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2303 /// sufficient, a read-write scope will do as well.
2304 pub fn add_scope<St>(mut self, scope: St) -> RollingUpdateListCall<'a, C>
2305 where
2306 St: AsRef<str>,
2307 {
2308 self._scopes.insert(String::from(scope.as_ref()));
2309 self
2310 }
2311 /// Identifies the authorization scope(s) for the method you are building.
2312 ///
2313 /// See [`Self::add_scope()`] for details.
2314 pub fn add_scopes<I, St>(mut self, scopes: I) -> RollingUpdateListCall<'a, C>
2315 where
2316 I: IntoIterator<Item = St>,
2317 St: AsRef<str>,
2318 {
2319 self._scopes
2320 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2321 self
2322 }
2323
2324 /// Removes all scopes, and no default scope will be used either.
2325 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2326 /// for details).
2327 pub fn clear_scopes(mut self) -> RollingUpdateListCall<'a, C> {
2328 self._scopes.clear();
2329 self
2330 }
2331}
2332
2333/// Lists the current status for each instance within a given update.
2334///
2335/// A builder for the *listInstanceUpdates* method supported by a *rollingUpdate* resource.
2336/// It is not used directly, but through a [`RollingUpdateMethods`] instance.
2337///
2338/// # Example
2339///
2340/// Instantiate a resource method builder
2341///
2342/// ```test_harness,no_run
2343/// # extern crate hyper;
2344/// # extern crate hyper_rustls;
2345/// # extern crate google_replicapoolupdater1_beta1 as replicapoolupdater1_beta1;
2346/// # async fn dox() {
2347/// # use replicapoolupdater1_beta1::{Replicapoolupdater, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2348///
2349/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2350/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2351/// # .with_native_roots()
2352/// # .unwrap()
2353/// # .https_only()
2354/// # .enable_http2()
2355/// # .build();
2356///
2357/// # let executor = hyper_util::rt::TokioExecutor::new();
2358/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2359/// # secret,
2360/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2361/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2362/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2363/// # ),
2364/// # ).build().await.unwrap();
2365///
2366/// # let client = hyper_util::client::legacy::Client::builder(
2367/// # hyper_util::rt::TokioExecutor::new()
2368/// # )
2369/// # .build(
2370/// # hyper_rustls::HttpsConnectorBuilder::new()
2371/// # .with_native_roots()
2372/// # .unwrap()
2373/// # .https_or_http()
2374/// # .enable_http2()
2375/// # .build()
2376/// # );
2377/// # let mut hub = Replicapoolupdater::new(client, auth);
2378/// // You can configure optional parameters by calling the respective setters at will, and
2379/// // execute the final call using `doit()`.
2380/// // Values shown here are possibly random and not representative !
2381/// let result = hub.rolling_updates().list_instance_updates("project", "zone", "rollingUpdate")
2382/// .page_token("dolor")
2383/// .max_results(45)
2384/// .filter("eos")
2385/// .doit().await;
2386/// # }
2387/// ```
2388pub struct RollingUpdateListInstanceUpdateCall<'a, C>
2389where
2390 C: 'a,
2391{
2392 hub: &'a Replicapoolupdater<C>,
2393 _project: String,
2394 _zone: String,
2395 _rolling_update: String,
2396 _page_token: Option<String>,
2397 _max_results: Option<u32>,
2398 _filter: Option<String>,
2399 _delegate: Option<&'a mut dyn common::Delegate>,
2400 _additional_params: HashMap<String, String>,
2401 _scopes: BTreeSet<String>,
2402}
2403
2404impl<'a, C> common::CallBuilder for RollingUpdateListInstanceUpdateCall<'a, C> {}
2405
2406impl<'a, C> RollingUpdateListInstanceUpdateCall<'a, C>
2407where
2408 C: common::Connector,
2409{
2410 /// Perform the operation you have build so far.
2411 pub async fn doit(mut self) -> common::Result<(common::Response, InstanceUpdateList)> {
2412 use std::borrow::Cow;
2413 use std::io::{Read, Seek};
2414
2415 use common::{url::Params, ToParts};
2416 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2417
2418 let mut dd = common::DefaultDelegate;
2419 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2420 dlg.begin(common::MethodInfo {
2421 id: "replicapoolupdater.rollingUpdates.listInstanceUpdates",
2422 http_method: hyper::Method::GET,
2423 });
2424
2425 for &field in [
2426 "alt",
2427 "project",
2428 "zone",
2429 "rollingUpdate",
2430 "pageToken",
2431 "maxResults",
2432 "filter",
2433 ]
2434 .iter()
2435 {
2436 if self._additional_params.contains_key(field) {
2437 dlg.finished(false);
2438 return Err(common::Error::FieldClash(field));
2439 }
2440 }
2441
2442 let mut params = Params::with_capacity(8 + self._additional_params.len());
2443 params.push("project", self._project);
2444 params.push("zone", self._zone);
2445 params.push("rollingUpdate", self._rolling_update);
2446 if let Some(value) = self._page_token.as_ref() {
2447 params.push("pageToken", value);
2448 }
2449 if let Some(value) = self._max_results.as_ref() {
2450 params.push("maxResults", value.to_string());
2451 }
2452 if let Some(value) = self._filter.as_ref() {
2453 params.push("filter", value);
2454 }
2455
2456 params.extend(self._additional_params.iter());
2457
2458 params.push("alt", "json");
2459 let mut url = self.hub._base_url.clone()
2460 + "{project}/zones/{zone}/rollingUpdates/{rollingUpdate}/instanceUpdates";
2461 if self._scopes.is_empty() {
2462 self._scopes
2463 .insert(Scope::ReplicapoolReadonly.as_ref().to_string());
2464 }
2465
2466 #[allow(clippy::single_element_loop)]
2467 for &(find_this, param_name) in [
2468 ("{project}", "project"),
2469 ("{zone}", "zone"),
2470 ("{rollingUpdate}", "rollingUpdate"),
2471 ]
2472 .iter()
2473 {
2474 url = params.uri_replacement(url, param_name, find_this, false);
2475 }
2476 {
2477 let to_remove = ["rollingUpdate", "zone", "project"];
2478 params.remove_params(&to_remove);
2479 }
2480
2481 let url = params.parse_with_url(&url);
2482
2483 loop {
2484 let token = match self
2485 .hub
2486 .auth
2487 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2488 .await
2489 {
2490 Ok(token) => token,
2491 Err(e) => match dlg.token(e) {
2492 Ok(token) => token,
2493 Err(e) => {
2494 dlg.finished(false);
2495 return Err(common::Error::MissingToken(e));
2496 }
2497 },
2498 };
2499 let mut req_result = {
2500 let client = &self.hub.client;
2501 dlg.pre_request();
2502 let mut req_builder = hyper::Request::builder()
2503 .method(hyper::Method::GET)
2504 .uri(url.as_str())
2505 .header(USER_AGENT, self.hub._user_agent.clone());
2506
2507 if let Some(token) = token.as_ref() {
2508 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2509 }
2510
2511 let request = req_builder
2512 .header(CONTENT_LENGTH, 0_u64)
2513 .body(common::to_body::<String>(None));
2514
2515 client.request(request.unwrap()).await
2516 };
2517
2518 match req_result {
2519 Err(err) => {
2520 if let common::Retry::After(d) = dlg.http_error(&err) {
2521 sleep(d).await;
2522 continue;
2523 }
2524 dlg.finished(false);
2525 return Err(common::Error::HttpError(err));
2526 }
2527 Ok(res) => {
2528 let (mut parts, body) = res.into_parts();
2529 let mut body = common::Body::new(body);
2530 if !parts.status.is_success() {
2531 let bytes = common::to_bytes(body).await.unwrap_or_default();
2532 let error = serde_json::from_str(&common::to_string(&bytes));
2533 let response = common::to_response(parts, bytes.into());
2534
2535 if let common::Retry::After(d) =
2536 dlg.http_failure(&response, error.as_ref().ok())
2537 {
2538 sleep(d).await;
2539 continue;
2540 }
2541
2542 dlg.finished(false);
2543
2544 return Err(match error {
2545 Ok(value) => common::Error::BadRequest(value),
2546 _ => common::Error::Failure(response),
2547 });
2548 }
2549 let response = {
2550 let bytes = common::to_bytes(body).await.unwrap_or_default();
2551 let encoded = common::to_string(&bytes);
2552 match serde_json::from_str(&encoded) {
2553 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2554 Err(error) => {
2555 dlg.response_json_decode_error(&encoded, &error);
2556 return Err(common::Error::JsonDecodeError(
2557 encoded.to_string(),
2558 error,
2559 ));
2560 }
2561 }
2562 };
2563
2564 dlg.finished(true);
2565 return Ok(response);
2566 }
2567 }
2568 }
2569 }
2570
2571 /// The Google Developers Console project name.
2572 ///
2573 /// Sets the *project* path property to the given value.
2574 ///
2575 /// Even though the property as already been set when instantiating this call,
2576 /// we provide this method for API completeness.
2577 pub fn project(mut self, new_value: &str) -> RollingUpdateListInstanceUpdateCall<'a, C> {
2578 self._project = new_value.to_string();
2579 self
2580 }
2581 /// The name of the zone in which the update's target resides.
2582 ///
2583 /// Sets the *zone* path property to the given value.
2584 ///
2585 /// Even though the property as already been set when instantiating this call,
2586 /// we provide this method for API completeness.
2587 pub fn zone(mut self, new_value: &str) -> RollingUpdateListInstanceUpdateCall<'a, C> {
2588 self._zone = new_value.to_string();
2589 self
2590 }
2591 /// The name of the update.
2592 ///
2593 /// Sets the *rolling update* path property to the given value.
2594 ///
2595 /// Even though the property as already been set when instantiating this call,
2596 /// we provide this method for API completeness.
2597 pub fn rolling_update(mut self, new_value: &str) -> RollingUpdateListInstanceUpdateCall<'a, C> {
2598 self._rolling_update = new_value.to_string();
2599 self
2600 }
2601 /// Optional. Tag returned by a previous list request truncated by maxResults. Used to continue a previous list request.
2602 ///
2603 /// Sets the *page token* query property to the given value.
2604 pub fn page_token(mut self, new_value: &str) -> RollingUpdateListInstanceUpdateCall<'a, C> {
2605 self._page_token = Some(new_value.to_string());
2606 self
2607 }
2608 /// Optional. Maximum count of results to be returned. Maximum value is 500 and default value is 500.
2609 ///
2610 /// Sets the *max results* query property to the given value.
2611 pub fn max_results(mut self, new_value: u32) -> RollingUpdateListInstanceUpdateCall<'a, C> {
2612 self._max_results = Some(new_value);
2613 self
2614 }
2615 /// Optional. Filter expression for filtering listed resources.
2616 ///
2617 /// Sets the *filter* query property to the given value.
2618 pub fn filter(mut self, new_value: &str) -> RollingUpdateListInstanceUpdateCall<'a, C> {
2619 self._filter = Some(new_value.to_string());
2620 self
2621 }
2622 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2623 /// while executing the actual API request.
2624 ///
2625 /// ````text
2626 /// It should be used to handle progress information, and to implement a certain level of resilience.
2627 /// ````
2628 ///
2629 /// Sets the *delegate* property to the given value.
2630 pub fn delegate(
2631 mut self,
2632 new_value: &'a mut dyn common::Delegate,
2633 ) -> RollingUpdateListInstanceUpdateCall<'a, C> {
2634 self._delegate = Some(new_value);
2635 self
2636 }
2637
2638 /// Set any additional parameter of the query string used in the request.
2639 /// It should be used to set parameters which are not yet available through their own
2640 /// setters.
2641 ///
2642 /// Please note that this method must not be used to set any of the known parameters
2643 /// which have their own setter method. If done anyway, the request will fail.
2644 ///
2645 /// # Additional Parameters
2646 ///
2647 /// * *alt* (query-string) - Data format for the response.
2648 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2649 /// * *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.
2650 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2651 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2652 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
2653 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
2654 pub fn param<T>(mut self, name: T, value: T) -> RollingUpdateListInstanceUpdateCall<'a, C>
2655 where
2656 T: AsRef<str>,
2657 {
2658 self._additional_params
2659 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2660 self
2661 }
2662
2663 /// Identifies the authorization scope for the method you are building.
2664 ///
2665 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2666 /// [`Scope::ReplicapoolReadonly`].
2667 ///
2668 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2669 /// tokens for more than one scope.
2670 ///
2671 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2672 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2673 /// sufficient, a read-write scope will do as well.
2674 pub fn add_scope<St>(mut self, scope: St) -> RollingUpdateListInstanceUpdateCall<'a, C>
2675 where
2676 St: AsRef<str>,
2677 {
2678 self._scopes.insert(String::from(scope.as_ref()));
2679 self
2680 }
2681 /// Identifies the authorization scope(s) for the method you are building.
2682 ///
2683 /// See [`Self::add_scope()`] for details.
2684 pub fn add_scopes<I, St>(mut self, scopes: I) -> RollingUpdateListInstanceUpdateCall<'a, C>
2685 where
2686 I: IntoIterator<Item = St>,
2687 St: AsRef<str>,
2688 {
2689 self._scopes
2690 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2691 self
2692 }
2693
2694 /// Removes all scopes, and no default scope will be used either.
2695 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2696 /// for details).
2697 pub fn clear_scopes(mut self) -> RollingUpdateListInstanceUpdateCall<'a, C> {
2698 self._scopes.clear();
2699 self
2700 }
2701}
2702
2703/// Pauses the update in state from ROLLING_FORWARD or ROLLING_BACK. Has no effect if invoked when the state of the update is PAUSED.
2704///
2705/// A builder for the *pause* method supported by a *rollingUpdate* resource.
2706/// It is not used directly, but through a [`RollingUpdateMethods`] instance.
2707///
2708/// # Example
2709///
2710/// Instantiate a resource method builder
2711///
2712/// ```test_harness,no_run
2713/// # extern crate hyper;
2714/// # extern crate hyper_rustls;
2715/// # extern crate google_replicapoolupdater1_beta1 as replicapoolupdater1_beta1;
2716/// # async fn dox() {
2717/// # use replicapoolupdater1_beta1::{Replicapoolupdater, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2718///
2719/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2720/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2721/// # .with_native_roots()
2722/// # .unwrap()
2723/// # .https_only()
2724/// # .enable_http2()
2725/// # .build();
2726///
2727/// # let executor = hyper_util::rt::TokioExecutor::new();
2728/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2729/// # secret,
2730/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2731/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2732/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2733/// # ),
2734/// # ).build().await.unwrap();
2735///
2736/// # let client = hyper_util::client::legacy::Client::builder(
2737/// # hyper_util::rt::TokioExecutor::new()
2738/// # )
2739/// # .build(
2740/// # hyper_rustls::HttpsConnectorBuilder::new()
2741/// # .with_native_roots()
2742/// # .unwrap()
2743/// # .https_or_http()
2744/// # .enable_http2()
2745/// # .build()
2746/// # );
2747/// # let mut hub = Replicapoolupdater::new(client, auth);
2748/// // You can configure optional parameters by calling the respective setters at will, and
2749/// // execute the final call using `doit()`.
2750/// // Values shown here are possibly random and not representative !
2751/// let result = hub.rolling_updates().pause("project", "zone", "rollingUpdate")
2752/// .doit().await;
2753/// # }
2754/// ```
2755pub struct RollingUpdatePauseCall<'a, C>
2756where
2757 C: 'a,
2758{
2759 hub: &'a Replicapoolupdater<C>,
2760 _project: String,
2761 _zone: String,
2762 _rolling_update: String,
2763 _delegate: Option<&'a mut dyn common::Delegate>,
2764 _additional_params: HashMap<String, String>,
2765 _scopes: BTreeSet<String>,
2766}
2767
2768impl<'a, C> common::CallBuilder for RollingUpdatePauseCall<'a, C> {}
2769
2770impl<'a, C> RollingUpdatePauseCall<'a, C>
2771where
2772 C: common::Connector,
2773{
2774 /// Perform the operation you have build so far.
2775 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2776 use std::borrow::Cow;
2777 use std::io::{Read, Seek};
2778
2779 use common::{url::Params, ToParts};
2780 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2781
2782 let mut dd = common::DefaultDelegate;
2783 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2784 dlg.begin(common::MethodInfo {
2785 id: "replicapoolupdater.rollingUpdates.pause",
2786 http_method: hyper::Method::POST,
2787 });
2788
2789 for &field in ["alt", "project", "zone", "rollingUpdate"].iter() {
2790 if self._additional_params.contains_key(field) {
2791 dlg.finished(false);
2792 return Err(common::Error::FieldClash(field));
2793 }
2794 }
2795
2796 let mut params = Params::with_capacity(5 + self._additional_params.len());
2797 params.push("project", self._project);
2798 params.push("zone", self._zone);
2799 params.push("rollingUpdate", self._rolling_update);
2800
2801 params.extend(self._additional_params.iter());
2802
2803 params.push("alt", "json");
2804 let mut url = self.hub._base_url.clone()
2805 + "{project}/zones/{zone}/rollingUpdates/{rollingUpdate}/pause";
2806 if self._scopes.is_empty() {
2807 self._scopes
2808 .insert(Scope::CloudPlatform.as_ref().to_string());
2809 }
2810
2811 #[allow(clippy::single_element_loop)]
2812 for &(find_this, param_name) in [
2813 ("{project}", "project"),
2814 ("{zone}", "zone"),
2815 ("{rollingUpdate}", "rollingUpdate"),
2816 ]
2817 .iter()
2818 {
2819 url = params.uri_replacement(url, param_name, find_this, false);
2820 }
2821 {
2822 let to_remove = ["rollingUpdate", "zone", "project"];
2823 params.remove_params(&to_remove);
2824 }
2825
2826 let url = params.parse_with_url(&url);
2827
2828 loop {
2829 let token = match self
2830 .hub
2831 .auth
2832 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2833 .await
2834 {
2835 Ok(token) => token,
2836 Err(e) => match dlg.token(e) {
2837 Ok(token) => token,
2838 Err(e) => {
2839 dlg.finished(false);
2840 return Err(common::Error::MissingToken(e));
2841 }
2842 },
2843 };
2844 let mut req_result = {
2845 let client = &self.hub.client;
2846 dlg.pre_request();
2847 let mut req_builder = hyper::Request::builder()
2848 .method(hyper::Method::POST)
2849 .uri(url.as_str())
2850 .header(USER_AGENT, self.hub._user_agent.clone());
2851
2852 if let Some(token) = token.as_ref() {
2853 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2854 }
2855
2856 let request = req_builder
2857 .header(CONTENT_LENGTH, 0_u64)
2858 .body(common::to_body::<String>(None));
2859
2860 client.request(request.unwrap()).await
2861 };
2862
2863 match req_result {
2864 Err(err) => {
2865 if let common::Retry::After(d) = dlg.http_error(&err) {
2866 sleep(d).await;
2867 continue;
2868 }
2869 dlg.finished(false);
2870 return Err(common::Error::HttpError(err));
2871 }
2872 Ok(res) => {
2873 let (mut parts, body) = res.into_parts();
2874 let mut body = common::Body::new(body);
2875 if !parts.status.is_success() {
2876 let bytes = common::to_bytes(body).await.unwrap_or_default();
2877 let error = serde_json::from_str(&common::to_string(&bytes));
2878 let response = common::to_response(parts, bytes.into());
2879
2880 if let common::Retry::After(d) =
2881 dlg.http_failure(&response, error.as_ref().ok())
2882 {
2883 sleep(d).await;
2884 continue;
2885 }
2886
2887 dlg.finished(false);
2888
2889 return Err(match error {
2890 Ok(value) => common::Error::BadRequest(value),
2891 _ => common::Error::Failure(response),
2892 });
2893 }
2894 let response = {
2895 let bytes = common::to_bytes(body).await.unwrap_or_default();
2896 let encoded = common::to_string(&bytes);
2897 match serde_json::from_str(&encoded) {
2898 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2899 Err(error) => {
2900 dlg.response_json_decode_error(&encoded, &error);
2901 return Err(common::Error::JsonDecodeError(
2902 encoded.to_string(),
2903 error,
2904 ));
2905 }
2906 }
2907 };
2908
2909 dlg.finished(true);
2910 return Ok(response);
2911 }
2912 }
2913 }
2914 }
2915
2916 /// The Google Developers Console project name.
2917 ///
2918 /// Sets the *project* path property to the given value.
2919 ///
2920 /// Even though the property as already been set when instantiating this call,
2921 /// we provide this method for API completeness.
2922 pub fn project(mut self, new_value: &str) -> RollingUpdatePauseCall<'a, C> {
2923 self._project = new_value.to_string();
2924 self
2925 }
2926 /// The name of the zone in which the update's target resides.
2927 ///
2928 /// Sets the *zone* path property to the given value.
2929 ///
2930 /// Even though the property as already been set when instantiating this call,
2931 /// we provide this method for API completeness.
2932 pub fn zone(mut self, new_value: &str) -> RollingUpdatePauseCall<'a, C> {
2933 self._zone = new_value.to_string();
2934 self
2935 }
2936 /// The name of the update.
2937 ///
2938 /// Sets the *rolling update* path property to the given value.
2939 ///
2940 /// Even though the property as already been set when instantiating this call,
2941 /// we provide this method for API completeness.
2942 pub fn rolling_update(mut self, new_value: &str) -> RollingUpdatePauseCall<'a, C> {
2943 self._rolling_update = new_value.to_string();
2944 self
2945 }
2946 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2947 /// while executing the actual API request.
2948 ///
2949 /// ````text
2950 /// It should be used to handle progress information, and to implement a certain level of resilience.
2951 /// ````
2952 ///
2953 /// Sets the *delegate* property to the given value.
2954 pub fn delegate(
2955 mut self,
2956 new_value: &'a mut dyn common::Delegate,
2957 ) -> RollingUpdatePauseCall<'a, C> {
2958 self._delegate = Some(new_value);
2959 self
2960 }
2961
2962 /// Set any additional parameter of the query string used in the request.
2963 /// It should be used to set parameters which are not yet available through their own
2964 /// setters.
2965 ///
2966 /// Please note that this method must not be used to set any of the known parameters
2967 /// which have their own setter method. If done anyway, the request will fail.
2968 ///
2969 /// # Additional Parameters
2970 ///
2971 /// * *alt* (query-string) - Data format for the response.
2972 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2973 /// * *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.
2974 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2975 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2976 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
2977 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
2978 pub fn param<T>(mut self, name: T, value: T) -> RollingUpdatePauseCall<'a, C>
2979 where
2980 T: AsRef<str>,
2981 {
2982 self._additional_params
2983 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2984 self
2985 }
2986
2987 /// Identifies the authorization scope for the method you are building.
2988 ///
2989 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2990 /// [`Scope::CloudPlatform`].
2991 ///
2992 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2993 /// tokens for more than one scope.
2994 ///
2995 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2996 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2997 /// sufficient, a read-write scope will do as well.
2998 pub fn add_scope<St>(mut self, scope: St) -> RollingUpdatePauseCall<'a, C>
2999 where
3000 St: AsRef<str>,
3001 {
3002 self._scopes.insert(String::from(scope.as_ref()));
3003 self
3004 }
3005 /// Identifies the authorization scope(s) for the method you are building.
3006 ///
3007 /// See [`Self::add_scope()`] for details.
3008 pub fn add_scopes<I, St>(mut self, scopes: I) -> RollingUpdatePauseCall<'a, C>
3009 where
3010 I: IntoIterator<Item = St>,
3011 St: AsRef<str>,
3012 {
3013 self._scopes
3014 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3015 self
3016 }
3017
3018 /// Removes all scopes, and no default scope will be used either.
3019 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3020 /// for details).
3021 pub fn clear_scopes(mut self) -> RollingUpdatePauseCall<'a, C> {
3022 self._scopes.clear();
3023 self
3024 }
3025}
3026
3027/// Continues an update in PAUSED state. Has no effect if invoked when the state of the update is ROLLED_OUT.
3028///
3029/// A builder for the *resume* method supported by a *rollingUpdate* resource.
3030/// It is not used directly, but through a [`RollingUpdateMethods`] instance.
3031///
3032/// # Example
3033///
3034/// Instantiate a resource method builder
3035///
3036/// ```test_harness,no_run
3037/// # extern crate hyper;
3038/// # extern crate hyper_rustls;
3039/// # extern crate google_replicapoolupdater1_beta1 as replicapoolupdater1_beta1;
3040/// # async fn dox() {
3041/// # use replicapoolupdater1_beta1::{Replicapoolupdater, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3042///
3043/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3044/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3045/// # .with_native_roots()
3046/// # .unwrap()
3047/// # .https_only()
3048/// # .enable_http2()
3049/// # .build();
3050///
3051/// # let executor = hyper_util::rt::TokioExecutor::new();
3052/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3053/// # secret,
3054/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3055/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3056/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3057/// # ),
3058/// # ).build().await.unwrap();
3059///
3060/// # let client = hyper_util::client::legacy::Client::builder(
3061/// # hyper_util::rt::TokioExecutor::new()
3062/// # )
3063/// # .build(
3064/// # hyper_rustls::HttpsConnectorBuilder::new()
3065/// # .with_native_roots()
3066/// # .unwrap()
3067/// # .https_or_http()
3068/// # .enable_http2()
3069/// # .build()
3070/// # );
3071/// # let mut hub = Replicapoolupdater::new(client, auth);
3072/// // You can configure optional parameters by calling the respective setters at will, and
3073/// // execute the final call using `doit()`.
3074/// // Values shown here are possibly random and not representative !
3075/// let result = hub.rolling_updates().resume("project", "zone", "rollingUpdate")
3076/// .doit().await;
3077/// # }
3078/// ```
3079pub struct RollingUpdateResumeCall<'a, C>
3080where
3081 C: 'a,
3082{
3083 hub: &'a Replicapoolupdater<C>,
3084 _project: String,
3085 _zone: String,
3086 _rolling_update: String,
3087 _delegate: Option<&'a mut dyn common::Delegate>,
3088 _additional_params: HashMap<String, String>,
3089 _scopes: BTreeSet<String>,
3090}
3091
3092impl<'a, C> common::CallBuilder for RollingUpdateResumeCall<'a, C> {}
3093
3094impl<'a, C> RollingUpdateResumeCall<'a, C>
3095where
3096 C: common::Connector,
3097{
3098 /// Perform the operation you have build so far.
3099 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3100 use std::borrow::Cow;
3101 use std::io::{Read, Seek};
3102
3103 use common::{url::Params, ToParts};
3104 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3105
3106 let mut dd = common::DefaultDelegate;
3107 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3108 dlg.begin(common::MethodInfo {
3109 id: "replicapoolupdater.rollingUpdates.resume",
3110 http_method: hyper::Method::POST,
3111 });
3112
3113 for &field in ["alt", "project", "zone", "rollingUpdate"].iter() {
3114 if self._additional_params.contains_key(field) {
3115 dlg.finished(false);
3116 return Err(common::Error::FieldClash(field));
3117 }
3118 }
3119
3120 let mut params = Params::with_capacity(5 + self._additional_params.len());
3121 params.push("project", self._project);
3122 params.push("zone", self._zone);
3123 params.push("rollingUpdate", self._rolling_update);
3124
3125 params.extend(self._additional_params.iter());
3126
3127 params.push("alt", "json");
3128 let mut url = self.hub._base_url.clone()
3129 + "{project}/zones/{zone}/rollingUpdates/{rollingUpdate}/resume";
3130 if self._scopes.is_empty() {
3131 self._scopes
3132 .insert(Scope::CloudPlatform.as_ref().to_string());
3133 }
3134
3135 #[allow(clippy::single_element_loop)]
3136 for &(find_this, param_name) in [
3137 ("{project}", "project"),
3138 ("{zone}", "zone"),
3139 ("{rollingUpdate}", "rollingUpdate"),
3140 ]
3141 .iter()
3142 {
3143 url = params.uri_replacement(url, param_name, find_this, false);
3144 }
3145 {
3146 let to_remove = ["rollingUpdate", "zone", "project"];
3147 params.remove_params(&to_remove);
3148 }
3149
3150 let url = params.parse_with_url(&url);
3151
3152 loop {
3153 let token = match self
3154 .hub
3155 .auth
3156 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3157 .await
3158 {
3159 Ok(token) => token,
3160 Err(e) => match dlg.token(e) {
3161 Ok(token) => token,
3162 Err(e) => {
3163 dlg.finished(false);
3164 return Err(common::Error::MissingToken(e));
3165 }
3166 },
3167 };
3168 let mut req_result = {
3169 let client = &self.hub.client;
3170 dlg.pre_request();
3171 let mut req_builder = hyper::Request::builder()
3172 .method(hyper::Method::POST)
3173 .uri(url.as_str())
3174 .header(USER_AGENT, self.hub._user_agent.clone());
3175
3176 if let Some(token) = token.as_ref() {
3177 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3178 }
3179
3180 let request = req_builder
3181 .header(CONTENT_LENGTH, 0_u64)
3182 .body(common::to_body::<String>(None));
3183
3184 client.request(request.unwrap()).await
3185 };
3186
3187 match req_result {
3188 Err(err) => {
3189 if let common::Retry::After(d) = dlg.http_error(&err) {
3190 sleep(d).await;
3191 continue;
3192 }
3193 dlg.finished(false);
3194 return Err(common::Error::HttpError(err));
3195 }
3196 Ok(res) => {
3197 let (mut parts, body) = res.into_parts();
3198 let mut body = common::Body::new(body);
3199 if !parts.status.is_success() {
3200 let bytes = common::to_bytes(body).await.unwrap_or_default();
3201 let error = serde_json::from_str(&common::to_string(&bytes));
3202 let response = common::to_response(parts, bytes.into());
3203
3204 if let common::Retry::After(d) =
3205 dlg.http_failure(&response, error.as_ref().ok())
3206 {
3207 sleep(d).await;
3208 continue;
3209 }
3210
3211 dlg.finished(false);
3212
3213 return Err(match error {
3214 Ok(value) => common::Error::BadRequest(value),
3215 _ => common::Error::Failure(response),
3216 });
3217 }
3218 let response = {
3219 let bytes = common::to_bytes(body).await.unwrap_or_default();
3220 let encoded = common::to_string(&bytes);
3221 match serde_json::from_str(&encoded) {
3222 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3223 Err(error) => {
3224 dlg.response_json_decode_error(&encoded, &error);
3225 return Err(common::Error::JsonDecodeError(
3226 encoded.to_string(),
3227 error,
3228 ));
3229 }
3230 }
3231 };
3232
3233 dlg.finished(true);
3234 return Ok(response);
3235 }
3236 }
3237 }
3238 }
3239
3240 /// The Google Developers Console project name.
3241 ///
3242 /// Sets the *project* path property to the given value.
3243 ///
3244 /// Even though the property as already been set when instantiating this call,
3245 /// we provide this method for API completeness.
3246 pub fn project(mut self, new_value: &str) -> RollingUpdateResumeCall<'a, C> {
3247 self._project = new_value.to_string();
3248 self
3249 }
3250 /// The name of the zone in which the update's target resides.
3251 ///
3252 /// Sets the *zone* path property to the given value.
3253 ///
3254 /// Even though the property as already been set when instantiating this call,
3255 /// we provide this method for API completeness.
3256 pub fn zone(mut self, new_value: &str) -> RollingUpdateResumeCall<'a, C> {
3257 self._zone = new_value.to_string();
3258 self
3259 }
3260 /// The name of the update.
3261 ///
3262 /// Sets the *rolling update* path property to the given value.
3263 ///
3264 /// Even though the property as already been set when instantiating this call,
3265 /// we provide this method for API completeness.
3266 pub fn rolling_update(mut self, new_value: &str) -> RollingUpdateResumeCall<'a, C> {
3267 self._rolling_update = new_value.to_string();
3268 self
3269 }
3270 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3271 /// while executing the actual API request.
3272 ///
3273 /// ````text
3274 /// It should be used to handle progress information, and to implement a certain level of resilience.
3275 /// ````
3276 ///
3277 /// Sets the *delegate* property to the given value.
3278 pub fn delegate(
3279 mut self,
3280 new_value: &'a mut dyn common::Delegate,
3281 ) -> RollingUpdateResumeCall<'a, C> {
3282 self._delegate = Some(new_value);
3283 self
3284 }
3285
3286 /// Set any additional parameter of the query string used in the request.
3287 /// It should be used to set parameters which are not yet available through their own
3288 /// setters.
3289 ///
3290 /// Please note that this method must not be used to set any of the known parameters
3291 /// which have their own setter method. If done anyway, the request will fail.
3292 ///
3293 /// # Additional Parameters
3294 ///
3295 /// * *alt* (query-string) - Data format for the response.
3296 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3297 /// * *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.
3298 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3299 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3300 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3301 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3302 pub fn param<T>(mut self, name: T, value: T) -> RollingUpdateResumeCall<'a, C>
3303 where
3304 T: AsRef<str>,
3305 {
3306 self._additional_params
3307 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3308 self
3309 }
3310
3311 /// Identifies the authorization scope for the method you are building.
3312 ///
3313 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3314 /// [`Scope::CloudPlatform`].
3315 ///
3316 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3317 /// tokens for more than one scope.
3318 ///
3319 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3320 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3321 /// sufficient, a read-write scope will do as well.
3322 pub fn add_scope<St>(mut self, scope: St) -> RollingUpdateResumeCall<'a, C>
3323 where
3324 St: AsRef<str>,
3325 {
3326 self._scopes.insert(String::from(scope.as_ref()));
3327 self
3328 }
3329 /// Identifies the authorization scope(s) for the method you are building.
3330 ///
3331 /// See [`Self::add_scope()`] for details.
3332 pub fn add_scopes<I, St>(mut self, scopes: I) -> RollingUpdateResumeCall<'a, C>
3333 where
3334 I: IntoIterator<Item = St>,
3335 St: AsRef<str>,
3336 {
3337 self._scopes
3338 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3339 self
3340 }
3341
3342 /// Removes all scopes, and no default scope will be used either.
3343 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3344 /// for details).
3345 pub fn clear_scopes(mut self) -> RollingUpdateResumeCall<'a, C> {
3346 self._scopes.clear();
3347 self
3348 }
3349}
3350
3351/// Rolls back the update in state from ROLLING_FORWARD or PAUSED. Has no effect if invoked when the state of the update is ROLLED_BACK.
3352///
3353/// A builder for the *rollback* method supported by a *rollingUpdate* resource.
3354/// It is not used directly, but through a [`RollingUpdateMethods`] instance.
3355///
3356/// # Example
3357///
3358/// Instantiate a resource method builder
3359///
3360/// ```test_harness,no_run
3361/// # extern crate hyper;
3362/// # extern crate hyper_rustls;
3363/// # extern crate google_replicapoolupdater1_beta1 as replicapoolupdater1_beta1;
3364/// # async fn dox() {
3365/// # use replicapoolupdater1_beta1::{Replicapoolupdater, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3366///
3367/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3368/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3369/// # .with_native_roots()
3370/// # .unwrap()
3371/// # .https_only()
3372/// # .enable_http2()
3373/// # .build();
3374///
3375/// # let executor = hyper_util::rt::TokioExecutor::new();
3376/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3377/// # secret,
3378/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3379/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3380/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3381/// # ),
3382/// # ).build().await.unwrap();
3383///
3384/// # let client = hyper_util::client::legacy::Client::builder(
3385/// # hyper_util::rt::TokioExecutor::new()
3386/// # )
3387/// # .build(
3388/// # hyper_rustls::HttpsConnectorBuilder::new()
3389/// # .with_native_roots()
3390/// # .unwrap()
3391/// # .https_or_http()
3392/// # .enable_http2()
3393/// # .build()
3394/// # );
3395/// # let mut hub = Replicapoolupdater::new(client, auth);
3396/// // You can configure optional parameters by calling the respective setters at will, and
3397/// // execute the final call using `doit()`.
3398/// // Values shown here are possibly random and not representative !
3399/// let result = hub.rolling_updates().rollback("project", "zone", "rollingUpdate")
3400/// .doit().await;
3401/// # }
3402/// ```
3403pub struct RollingUpdateRollbackCall<'a, C>
3404where
3405 C: 'a,
3406{
3407 hub: &'a Replicapoolupdater<C>,
3408 _project: String,
3409 _zone: String,
3410 _rolling_update: String,
3411 _delegate: Option<&'a mut dyn common::Delegate>,
3412 _additional_params: HashMap<String, String>,
3413 _scopes: BTreeSet<String>,
3414}
3415
3416impl<'a, C> common::CallBuilder for RollingUpdateRollbackCall<'a, C> {}
3417
3418impl<'a, C> RollingUpdateRollbackCall<'a, C>
3419where
3420 C: common::Connector,
3421{
3422 /// Perform the operation you have build so far.
3423 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3424 use std::borrow::Cow;
3425 use std::io::{Read, Seek};
3426
3427 use common::{url::Params, ToParts};
3428 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3429
3430 let mut dd = common::DefaultDelegate;
3431 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3432 dlg.begin(common::MethodInfo {
3433 id: "replicapoolupdater.rollingUpdates.rollback",
3434 http_method: hyper::Method::POST,
3435 });
3436
3437 for &field in ["alt", "project", "zone", "rollingUpdate"].iter() {
3438 if self._additional_params.contains_key(field) {
3439 dlg.finished(false);
3440 return Err(common::Error::FieldClash(field));
3441 }
3442 }
3443
3444 let mut params = Params::with_capacity(5 + self._additional_params.len());
3445 params.push("project", self._project);
3446 params.push("zone", self._zone);
3447 params.push("rollingUpdate", self._rolling_update);
3448
3449 params.extend(self._additional_params.iter());
3450
3451 params.push("alt", "json");
3452 let mut url = self.hub._base_url.clone()
3453 + "{project}/zones/{zone}/rollingUpdates/{rollingUpdate}/rollback";
3454 if self._scopes.is_empty() {
3455 self._scopes
3456 .insert(Scope::CloudPlatform.as_ref().to_string());
3457 }
3458
3459 #[allow(clippy::single_element_loop)]
3460 for &(find_this, param_name) in [
3461 ("{project}", "project"),
3462 ("{zone}", "zone"),
3463 ("{rollingUpdate}", "rollingUpdate"),
3464 ]
3465 .iter()
3466 {
3467 url = params.uri_replacement(url, param_name, find_this, false);
3468 }
3469 {
3470 let to_remove = ["rollingUpdate", "zone", "project"];
3471 params.remove_params(&to_remove);
3472 }
3473
3474 let url = params.parse_with_url(&url);
3475
3476 loop {
3477 let token = match self
3478 .hub
3479 .auth
3480 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3481 .await
3482 {
3483 Ok(token) => token,
3484 Err(e) => match dlg.token(e) {
3485 Ok(token) => token,
3486 Err(e) => {
3487 dlg.finished(false);
3488 return Err(common::Error::MissingToken(e));
3489 }
3490 },
3491 };
3492 let mut req_result = {
3493 let client = &self.hub.client;
3494 dlg.pre_request();
3495 let mut req_builder = hyper::Request::builder()
3496 .method(hyper::Method::POST)
3497 .uri(url.as_str())
3498 .header(USER_AGENT, self.hub._user_agent.clone());
3499
3500 if let Some(token) = token.as_ref() {
3501 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3502 }
3503
3504 let request = req_builder
3505 .header(CONTENT_LENGTH, 0_u64)
3506 .body(common::to_body::<String>(None));
3507
3508 client.request(request.unwrap()).await
3509 };
3510
3511 match req_result {
3512 Err(err) => {
3513 if let common::Retry::After(d) = dlg.http_error(&err) {
3514 sleep(d).await;
3515 continue;
3516 }
3517 dlg.finished(false);
3518 return Err(common::Error::HttpError(err));
3519 }
3520 Ok(res) => {
3521 let (mut parts, body) = res.into_parts();
3522 let mut body = common::Body::new(body);
3523 if !parts.status.is_success() {
3524 let bytes = common::to_bytes(body).await.unwrap_or_default();
3525 let error = serde_json::from_str(&common::to_string(&bytes));
3526 let response = common::to_response(parts, bytes.into());
3527
3528 if let common::Retry::After(d) =
3529 dlg.http_failure(&response, error.as_ref().ok())
3530 {
3531 sleep(d).await;
3532 continue;
3533 }
3534
3535 dlg.finished(false);
3536
3537 return Err(match error {
3538 Ok(value) => common::Error::BadRequest(value),
3539 _ => common::Error::Failure(response),
3540 });
3541 }
3542 let response = {
3543 let bytes = common::to_bytes(body).await.unwrap_or_default();
3544 let encoded = common::to_string(&bytes);
3545 match serde_json::from_str(&encoded) {
3546 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3547 Err(error) => {
3548 dlg.response_json_decode_error(&encoded, &error);
3549 return Err(common::Error::JsonDecodeError(
3550 encoded.to_string(),
3551 error,
3552 ));
3553 }
3554 }
3555 };
3556
3557 dlg.finished(true);
3558 return Ok(response);
3559 }
3560 }
3561 }
3562 }
3563
3564 /// The Google Developers Console project name.
3565 ///
3566 /// Sets the *project* path property to the given value.
3567 ///
3568 /// Even though the property as already been set when instantiating this call,
3569 /// we provide this method for API completeness.
3570 pub fn project(mut self, new_value: &str) -> RollingUpdateRollbackCall<'a, C> {
3571 self._project = new_value.to_string();
3572 self
3573 }
3574 /// The name of the zone in which the update's target resides.
3575 ///
3576 /// Sets the *zone* path property to the given value.
3577 ///
3578 /// Even though the property as already been set when instantiating this call,
3579 /// we provide this method for API completeness.
3580 pub fn zone(mut self, new_value: &str) -> RollingUpdateRollbackCall<'a, C> {
3581 self._zone = new_value.to_string();
3582 self
3583 }
3584 /// The name of the update.
3585 ///
3586 /// Sets the *rolling update* path property to the given value.
3587 ///
3588 /// Even though the property as already been set when instantiating this call,
3589 /// we provide this method for API completeness.
3590 pub fn rolling_update(mut self, new_value: &str) -> RollingUpdateRollbackCall<'a, C> {
3591 self._rolling_update = new_value.to_string();
3592 self
3593 }
3594 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3595 /// while executing the actual API request.
3596 ///
3597 /// ````text
3598 /// It should be used to handle progress information, and to implement a certain level of resilience.
3599 /// ````
3600 ///
3601 /// Sets the *delegate* property to the given value.
3602 pub fn delegate(
3603 mut self,
3604 new_value: &'a mut dyn common::Delegate,
3605 ) -> RollingUpdateRollbackCall<'a, C> {
3606 self._delegate = Some(new_value);
3607 self
3608 }
3609
3610 /// Set any additional parameter of the query string used in the request.
3611 /// It should be used to set parameters which are not yet available through their own
3612 /// setters.
3613 ///
3614 /// Please note that this method must not be used to set any of the known parameters
3615 /// which have their own setter method. If done anyway, the request will fail.
3616 ///
3617 /// # Additional Parameters
3618 ///
3619 /// * *alt* (query-string) - Data format for the response.
3620 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3621 /// * *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.
3622 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3623 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3624 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3625 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3626 pub fn param<T>(mut self, name: T, value: T) -> RollingUpdateRollbackCall<'a, C>
3627 where
3628 T: AsRef<str>,
3629 {
3630 self._additional_params
3631 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3632 self
3633 }
3634
3635 /// Identifies the authorization scope for the method you are building.
3636 ///
3637 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3638 /// [`Scope::CloudPlatform`].
3639 ///
3640 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3641 /// tokens for more than one scope.
3642 ///
3643 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3644 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3645 /// sufficient, a read-write scope will do as well.
3646 pub fn add_scope<St>(mut self, scope: St) -> RollingUpdateRollbackCall<'a, C>
3647 where
3648 St: AsRef<str>,
3649 {
3650 self._scopes.insert(String::from(scope.as_ref()));
3651 self
3652 }
3653 /// Identifies the authorization scope(s) for the method you are building.
3654 ///
3655 /// See [`Self::add_scope()`] for details.
3656 pub fn add_scopes<I, St>(mut self, scopes: I) -> RollingUpdateRollbackCall<'a, C>
3657 where
3658 I: IntoIterator<Item = St>,
3659 St: AsRef<str>,
3660 {
3661 self._scopes
3662 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3663 self
3664 }
3665
3666 /// Removes all scopes, and no default scope will be used either.
3667 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3668 /// for details).
3669 pub fn clear_scopes(mut self) -> RollingUpdateRollbackCall<'a, C> {
3670 self._scopes.clear();
3671 self
3672 }
3673}
3674
3675/// Retrieves the specified zone-specific operation resource.
3676///
3677/// A builder for the *get* method supported by a *zoneOperation* resource.
3678/// It is not used directly, but through a [`ZoneOperationMethods`] instance.
3679///
3680/// # Example
3681///
3682/// Instantiate a resource method builder
3683///
3684/// ```test_harness,no_run
3685/// # extern crate hyper;
3686/// # extern crate hyper_rustls;
3687/// # extern crate google_replicapoolupdater1_beta1 as replicapoolupdater1_beta1;
3688/// # async fn dox() {
3689/// # use replicapoolupdater1_beta1::{Replicapoolupdater, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3690///
3691/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3692/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3693/// # .with_native_roots()
3694/// # .unwrap()
3695/// # .https_only()
3696/// # .enable_http2()
3697/// # .build();
3698///
3699/// # let executor = hyper_util::rt::TokioExecutor::new();
3700/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3701/// # secret,
3702/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3703/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3704/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3705/// # ),
3706/// # ).build().await.unwrap();
3707///
3708/// # let client = hyper_util::client::legacy::Client::builder(
3709/// # hyper_util::rt::TokioExecutor::new()
3710/// # )
3711/// # .build(
3712/// # hyper_rustls::HttpsConnectorBuilder::new()
3713/// # .with_native_roots()
3714/// # .unwrap()
3715/// # .https_or_http()
3716/// # .enable_http2()
3717/// # .build()
3718/// # );
3719/// # let mut hub = Replicapoolupdater::new(client, auth);
3720/// // You can configure optional parameters by calling the respective setters at will, and
3721/// // execute the final call using `doit()`.
3722/// // Values shown here are possibly random and not representative !
3723/// let result = hub.zone_operations().get("project", "zone", "operation")
3724/// .doit().await;
3725/// # }
3726/// ```
3727pub struct ZoneOperationGetCall<'a, C>
3728where
3729 C: 'a,
3730{
3731 hub: &'a Replicapoolupdater<C>,
3732 _project: String,
3733 _zone: String,
3734 _operation: String,
3735 _delegate: Option<&'a mut dyn common::Delegate>,
3736 _additional_params: HashMap<String, String>,
3737 _scopes: BTreeSet<String>,
3738}
3739
3740impl<'a, C> common::CallBuilder for ZoneOperationGetCall<'a, C> {}
3741
3742impl<'a, C> ZoneOperationGetCall<'a, C>
3743where
3744 C: common::Connector,
3745{
3746 /// Perform the operation you have build so far.
3747 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3748 use std::borrow::Cow;
3749 use std::io::{Read, Seek};
3750
3751 use common::{url::Params, ToParts};
3752 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3753
3754 let mut dd = common::DefaultDelegate;
3755 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3756 dlg.begin(common::MethodInfo {
3757 id: "replicapoolupdater.zoneOperations.get",
3758 http_method: hyper::Method::GET,
3759 });
3760
3761 for &field in ["alt", "project", "zone", "operation"].iter() {
3762 if self._additional_params.contains_key(field) {
3763 dlg.finished(false);
3764 return Err(common::Error::FieldClash(field));
3765 }
3766 }
3767
3768 let mut params = Params::with_capacity(5 + self._additional_params.len());
3769 params.push("project", self._project);
3770 params.push("zone", self._zone);
3771 params.push("operation", self._operation);
3772
3773 params.extend(self._additional_params.iter());
3774
3775 params.push("alt", "json");
3776 let mut url = self.hub._base_url.clone() + "{project}/zones/{zone}/operations/{operation}";
3777 if self._scopes.is_empty() {
3778 self._scopes
3779 .insert(Scope::CloudPlatform.as_ref().to_string());
3780 }
3781
3782 #[allow(clippy::single_element_loop)]
3783 for &(find_this, param_name) in [
3784 ("{project}", "project"),
3785 ("{zone}", "zone"),
3786 ("{operation}", "operation"),
3787 ]
3788 .iter()
3789 {
3790 url = params.uri_replacement(url, param_name, find_this, false);
3791 }
3792 {
3793 let to_remove = ["operation", "zone", "project"];
3794 params.remove_params(&to_remove);
3795 }
3796
3797 let url = params.parse_with_url(&url);
3798
3799 loop {
3800 let token = match self
3801 .hub
3802 .auth
3803 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3804 .await
3805 {
3806 Ok(token) => token,
3807 Err(e) => match dlg.token(e) {
3808 Ok(token) => token,
3809 Err(e) => {
3810 dlg.finished(false);
3811 return Err(common::Error::MissingToken(e));
3812 }
3813 },
3814 };
3815 let mut req_result = {
3816 let client = &self.hub.client;
3817 dlg.pre_request();
3818 let mut req_builder = hyper::Request::builder()
3819 .method(hyper::Method::GET)
3820 .uri(url.as_str())
3821 .header(USER_AGENT, self.hub._user_agent.clone());
3822
3823 if let Some(token) = token.as_ref() {
3824 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3825 }
3826
3827 let request = req_builder
3828 .header(CONTENT_LENGTH, 0_u64)
3829 .body(common::to_body::<String>(None));
3830
3831 client.request(request.unwrap()).await
3832 };
3833
3834 match req_result {
3835 Err(err) => {
3836 if let common::Retry::After(d) = dlg.http_error(&err) {
3837 sleep(d).await;
3838 continue;
3839 }
3840 dlg.finished(false);
3841 return Err(common::Error::HttpError(err));
3842 }
3843 Ok(res) => {
3844 let (mut parts, body) = res.into_parts();
3845 let mut body = common::Body::new(body);
3846 if !parts.status.is_success() {
3847 let bytes = common::to_bytes(body).await.unwrap_or_default();
3848 let error = serde_json::from_str(&common::to_string(&bytes));
3849 let response = common::to_response(parts, bytes.into());
3850
3851 if let common::Retry::After(d) =
3852 dlg.http_failure(&response, error.as_ref().ok())
3853 {
3854 sleep(d).await;
3855 continue;
3856 }
3857
3858 dlg.finished(false);
3859
3860 return Err(match error {
3861 Ok(value) => common::Error::BadRequest(value),
3862 _ => common::Error::Failure(response),
3863 });
3864 }
3865 let response = {
3866 let bytes = common::to_bytes(body).await.unwrap_or_default();
3867 let encoded = common::to_string(&bytes);
3868 match serde_json::from_str(&encoded) {
3869 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3870 Err(error) => {
3871 dlg.response_json_decode_error(&encoded, &error);
3872 return Err(common::Error::JsonDecodeError(
3873 encoded.to_string(),
3874 error,
3875 ));
3876 }
3877 }
3878 };
3879
3880 dlg.finished(true);
3881 return Ok(response);
3882 }
3883 }
3884 }
3885 }
3886
3887 /// Name of the project scoping this request.
3888 ///
3889 /// Sets the *project* path property to the given value.
3890 ///
3891 /// Even though the property as already been set when instantiating this call,
3892 /// we provide this method for API completeness.
3893 pub fn project(mut self, new_value: &str) -> ZoneOperationGetCall<'a, C> {
3894 self._project = new_value.to_string();
3895 self
3896 }
3897 /// Name of the zone scoping this request.
3898 ///
3899 /// Sets the *zone* path property to the given value.
3900 ///
3901 /// Even though the property as already been set when instantiating this call,
3902 /// we provide this method for API completeness.
3903 pub fn zone(mut self, new_value: &str) -> ZoneOperationGetCall<'a, C> {
3904 self._zone = new_value.to_string();
3905 self
3906 }
3907 /// Name of the operation resource to return.
3908 ///
3909 /// Sets the *operation* path property to the given value.
3910 ///
3911 /// Even though the property as already been set when instantiating this call,
3912 /// we provide this method for API completeness.
3913 pub fn operation(mut self, new_value: &str) -> ZoneOperationGetCall<'a, C> {
3914 self._operation = new_value.to_string();
3915 self
3916 }
3917 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3918 /// while executing the actual API request.
3919 ///
3920 /// ````text
3921 /// It should be used to handle progress information, and to implement a certain level of resilience.
3922 /// ````
3923 ///
3924 /// Sets the *delegate* property to the given value.
3925 pub fn delegate(
3926 mut self,
3927 new_value: &'a mut dyn common::Delegate,
3928 ) -> ZoneOperationGetCall<'a, C> {
3929 self._delegate = Some(new_value);
3930 self
3931 }
3932
3933 /// Set any additional parameter of the query string used in the request.
3934 /// It should be used to set parameters which are not yet available through their own
3935 /// setters.
3936 ///
3937 /// Please note that this method must not be used to set any of the known parameters
3938 /// which have their own setter method. If done anyway, the request will fail.
3939 ///
3940 /// # Additional Parameters
3941 ///
3942 /// * *alt* (query-string) - Data format for the response.
3943 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3944 /// * *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.
3945 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3946 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3947 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3948 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3949 pub fn param<T>(mut self, name: T, value: T) -> ZoneOperationGetCall<'a, C>
3950 where
3951 T: AsRef<str>,
3952 {
3953 self._additional_params
3954 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3955 self
3956 }
3957
3958 /// Identifies the authorization scope for the method you are building.
3959 ///
3960 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3961 /// [`Scope::CloudPlatform`].
3962 ///
3963 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3964 /// tokens for more than one scope.
3965 ///
3966 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3967 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3968 /// sufficient, a read-write scope will do as well.
3969 pub fn add_scope<St>(mut self, scope: St) -> ZoneOperationGetCall<'a, C>
3970 where
3971 St: AsRef<str>,
3972 {
3973 self._scopes.insert(String::from(scope.as_ref()));
3974 self
3975 }
3976 /// Identifies the authorization scope(s) for the method you are building.
3977 ///
3978 /// See [`Self::add_scope()`] for details.
3979 pub fn add_scopes<I, St>(mut self, scopes: I) -> ZoneOperationGetCall<'a, C>
3980 where
3981 I: IntoIterator<Item = St>,
3982 St: AsRef<str>,
3983 {
3984 self._scopes
3985 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3986 self
3987 }
3988
3989 /// Removes all scopes, and no default scope will be used either.
3990 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3991 /// for details).
3992 pub fn clear_scopes(mut self) -> ZoneOperationGetCall<'a, C> {
3993 self._scopes.clear();
3994 self
3995 }
3996}
3997
3998/// Retrieves the list of Operation resources contained within the specified zone.
3999///
4000/// A builder for the *list* method supported by a *zoneOperation* resource.
4001/// It is not used directly, but through a [`ZoneOperationMethods`] instance.
4002///
4003/// # Example
4004///
4005/// Instantiate a resource method builder
4006///
4007/// ```test_harness,no_run
4008/// # extern crate hyper;
4009/// # extern crate hyper_rustls;
4010/// # extern crate google_replicapoolupdater1_beta1 as replicapoolupdater1_beta1;
4011/// # async fn dox() {
4012/// # use replicapoolupdater1_beta1::{Replicapoolupdater, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4013///
4014/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4015/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4016/// # .with_native_roots()
4017/// # .unwrap()
4018/// # .https_only()
4019/// # .enable_http2()
4020/// # .build();
4021///
4022/// # let executor = hyper_util::rt::TokioExecutor::new();
4023/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4024/// # secret,
4025/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4026/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4027/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4028/// # ),
4029/// # ).build().await.unwrap();
4030///
4031/// # let client = hyper_util::client::legacy::Client::builder(
4032/// # hyper_util::rt::TokioExecutor::new()
4033/// # )
4034/// # .build(
4035/// # hyper_rustls::HttpsConnectorBuilder::new()
4036/// # .with_native_roots()
4037/// # .unwrap()
4038/// # .https_or_http()
4039/// # .enable_http2()
4040/// # .build()
4041/// # );
4042/// # let mut hub = Replicapoolupdater::new(client, auth);
4043/// // You can configure optional parameters by calling the respective setters at will, and
4044/// // execute the final call using `doit()`.
4045/// // Values shown here are possibly random and not representative !
4046/// let result = hub.zone_operations().list("project", "zone")
4047/// .page_token("duo")
4048/// .max_results(67)
4049/// .filter("et")
4050/// .doit().await;
4051/// # }
4052/// ```
4053pub struct ZoneOperationListCall<'a, C>
4054where
4055 C: 'a,
4056{
4057 hub: &'a Replicapoolupdater<C>,
4058 _project: String,
4059 _zone: String,
4060 _page_token: Option<String>,
4061 _max_results: Option<u32>,
4062 _filter: Option<String>,
4063 _delegate: Option<&'a mut dyn common::Delegate>,
4064 _additional_params: HashMap<String, String>,
4065 _scopes: BTreeSet<String>,
4066}
4067
4068impl<'a, C> common::CallBuilder for ZoneOperationListCall<'a, C> {}
4069
4070impl<'a, C> ZoneOperationListCall<'a, C>
4071where
4072 C: common::Connector,
4073{
4074 /// Perform the operation you have build so far.
4075 pub async fn doit(mut self) -> common::Result<(common::Response, OperationList)> {
4076 use std::borrow::Cow;
4077 use std::io::{Read, Seek};
4078
4079 use common::{url::Params, ToParts};
4080 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4081
4082 let mut dd = common::DefaultDelegate;
4083 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4084 dlg.begin(common::MethodInfo {
4085 id: "replicapoolupdater.zoneOperations.list",
4086 http_method: hyper::Method::GET,
4087 });
4088
4089 for &field in [
4090 "alt",
4091 "project",
4092 "zone",
4093 "pageToken",
4094 "maxResults",
4095 "filter",
4096 ]
4097 .iter()
4098 {
4099 if self._additional_params.contains_key(field) {
4100 dlg.finished(false);
4101 return Err(common::Error::FieldClash(field));
4102 }
4103 }
4104
4105 let mut params = Params::with_capacity(7 + self._additional_params.len());
4106 params.push("project", self._project);
4107 params.push("zone", self._zone);
4108 if let Some(value) = self._page_token.as_ref() {
4109 params.push("pageToken", value);
4110 }
4111 if let Some(value) = self._max_results.as_ref() {
4112 params.push("maxResults", value.to_string());
4113 }
4114 if let Some(value) = self._filter.as_ref() {
4115 params.push("filter", value);
4116 }
4117
4118 params.extend(self._additional_params.iter());
4119
4120 params.push("alt", "json");
4121 let mut url = self.hub._base_url.clone() + "{project}/zones/{zone}/operations";
4122 if self._scopes.is_empty() {
4123 self._scopes
4124 .insert(Scope::CloudPlatform.as_ref().to_string());
4125 }
4126
4127 #[allow(clippy::single_element_loop)]
4128 for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() {
4129 url = params.uri_replacement(url, param_name, find_this, false);
4130 }
4131 {
4132 let to_remove = ["zone", "project"];
4133 params.remove_params(&to_remove);
4134 }
4135
4136 let url = params.parse_with_url(&url);
4137
4138 loop {
4139 let token = match self
4140 .hub
4141 .auth
4142 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4143 .await
4144 {
4145 Ok(token) => token,
4146 Err(e) => match dlg.token(e) {
4147 Ok(token) => token,
4148 Err(e) => {
4149 dlg.finished(false);
4150 return Err(common::Error::MissingToken(e));
4151 }
4152 },
4153 };
4154 let mut req_result = {
4155 let client = &self.hub.client;
4156 dlg.pre_request();
4157 let mut req_builder = hyper::Request::builder()
4158 .method(hyper::Method::GET)
4159 .uri(url.as_str())
4160 .header(USER_AGENT, self.hub._user_agent.clone());
4161
4162 if let Some(token) = token.as_ref() {
4163 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4164 }
4165
4166 let request = req_builder
4167 .header(CONTENT_LENGTH, 0_u64)
4168 .body(common::to_body::<String>(None));
4169
4170 client.request(request.unwrap()).await
4171 };
4172
4173 match req_result {
4174 Err(err) => {
4175 if let common::Retry::After(d) = dlg.http_error(&err) {
4176 sleep(d).await;
4177 continue;
4178 }
4179 dlg.finished(false);
4180 return Err(common::Error::HttpError(err));
4181 }
4182 Ok(res) => {
4183 let (mut parts, body) = res.into_parts();
4184 let mut body = common::Body::new(body);
4185 if !parts.status.is_success() {
4186 let bytes = common::to_bytes(body).await.unwrap_or_default();
4187 let error = serde_json::from_str(&common::to_string(&bytes));
4188 let response = common::to_response(parts, bytes.into());
4189
4190 if let common::Retry::After(d) =
4191 dlg.http_failure(&response, error.as_ref().ok())
4192 {
4193 sleep(d).await;
4194 continue;
4195 }
4196
4197 dlg.finished(false);
4198
4199 return Err(match error {
4200 Ok(value) => common::Error::BadRequest(value),
4201 _ => common::Error::Failure(response),
4202 });
4203 }
4204 let response = {
4205 let bytes = common::to_bytes(body).await.unwrap_or_default();
4206 let encoded = common::to_string(&bytes);
4207 match serde_json::from_str(&encoded) {
4208 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4209 Err(error) => {
4210 dlg.response_json_decode_error(&encoded, &error);
4211 return Err(common::Error::JsonDecodeError(
4212 encoded.to_string(),
4213 error,
4214 ));
4215 }
4216 }
4217 };
4218
4219 dlg.finished(true);
4220 return Ok(response);
4221 }
4222 }
4223 }
4224 }
4225
4226 /// Name of the project scoping this request.
4227 ///
4228 /// Sets the *project* path property to the given value.
4229 ///
4230 /// Even though the property as already been set when instantiating this call,
4231 /// we provide this method for API completeness.
4232 pub fn project(mut self, new_value: &str) -> ZoneOperationListCall<'a, C> {
4233 self._project = new_value.to_string();
4234 self
4235 }
4236 /// Name of the zone scoping this request.
4237 ///
4238 /// Sets the *zone* path property to the given value.
4239 ///
4240 /// Even though the property as already been set when instantiating this call,
4241 /// we provide this method for API completeness.
4242 pub fn zone(mut self, new_value: &str) -> ZoneOperationListCall<'a, C> {
4243 self._zone = new_value.to_string();
4244 self
4245 }
4246 /// Optional. Tag returned by a previous list request truncated by maxResults. Used to continue a previous list request.
4247 ///
4248 /// Sets the *page token* query property to the given value.
4249 pub fn page_token(mut self, new_value: &str) -> ZoneOperationListCall<'a, C> {
4250 self._page_token = Some(new_value.to_string());
4251 self
4252 }
4253 /// Optional. Maximum count of results to be returned. Maximum value is 500 and default value is 500.
4254 ///
4255 /// Sets the *max results* query property to the given value.
4256 pub fn max_results(mut self, new_value: u32) -> ZoneOperationListCall<'a, C> {
4257 self._max_results = Some(new_value);
4258 self
4259 }
4260 /// Optional. Filter expression for filtering listed resources.
4261 ///
4262 /// Sets the *filter* query property to the given value.
4263 pub fn filter(mut self, new_value: &str) -> ZoneOperationListCall<'a, C> {
4264 self._filter = Some(new_value.to_string());
4265 self
4266 }
4267 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4268 /// while executing the actual API request.
4269 ///
4270 /// ````text
4271 /// It should be used to handle progress information, and to implement a certain level of resilience.
4272 /// ````
4273 ///
4274 /// Sets the *delegate* property to the given value.
4275 pub fn delegate(
4276 mut self,
4277 new_value: &'a mut dyn common::Delegate,
4278 ) -> ZoneOperationListCall<'a, C> {
4279 self._delegate = Some(new_value);
4280 self
4281 }
4282
4283 /// Set any additional parameter of the query string used in the request.
4284 /// It should be used to set parameters which are not yet available through their own
4285 /// setters.
4286 ///
4287 /// Please note that this method must not be used to set any of the known parameters
4288 /// which have their own setter method. If done anyway, the request will fail.
4289 ///
4290 /// # Additional Parameters
4291 ///
4292 /// * *alt* (query-string) - Data format for the response.
4293 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4294 /// * *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.
4295 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4296 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4297 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4298 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4299 pub fn param<T>(mut self, name: T, value: T) -> ZoneOperationListCall<'a, C>
4300 where
4301 T: AsRef<str>,
4302 {
4303 self._additional_params
4304 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4305 self
4306 }
4307
4308 /// Identifies the authorization scope for the method you are building.
4309 ///
4310 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4311 /// [`Scope::CloudPlatform`].
4312 ///
4313 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4314 /// tokens for more than one scope.
4315 ///
4316 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4317 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4318 /// sufficient, a read-write scope will do as well.
4319 pub fn add_scope<St>(mut self, scope: St) -> ZoneOperationListCall<'a, C>
4320 where
4321 St: AsRef<str>,
4322 {
4323 self._scopes.insert(String::from(scope.as_ref()));
4324 self
4325 }
4326 /// Identifies the authorization scope(s) for the method you are building.
4327 ///
4328 /// See [`Self::add_scope()`] for details.
4329 pub fn add_scopes<I, St>(mut self, scopes: I) -> ZoneOperationListCall<'a, C>
4330 where
4331 I: IntoIterator<Item = St>,
4332 St: AsRef<str>,
4333 {
4334 self._scopes
4335 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4336 self
4337 }
4338
4339 /// Removes all scopes, and no default scope will be used either.
4340 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4341 /// for details).
4342 pub fn clear_scopes(mut self) -> ZoneOperationListCall<'a, C> {
4343 self._scopes.clear();
4344 self
4345 }
4346}