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