google_resourceviews1_beta2/
api.rs

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