google_serviceregistryalpha/
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 Cloud Platform management resources and deployment status information
23    NdevCloudman,
24
25    /// View your Google Cloud Platform management resources and deployment status information
26    NdevCloudmanReadonly,
27}
28
29impl AsRef<str> for Scope {
30    fn as_ref(&self) -> &str {
31        match *self {
32            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
33            Scope::CloudPlatformReadOnly => {
34                "https://www.googleapis.com/auth/cloud-platform.read-only"
35            }
36            Scope::NdevCloudman => "https://www.googleapis.com/auth/ndev.cloudman",
37            Scope::NdevCloudmanReadonly => "https://www.googleapis.com/auth/ndev.cloudman.readonly",
38        }
39    }
40}
41
42#[allow(clippy::derivable_impls)]
43impl Default for Scope {
44    fn default() -> Scope {
45        Scope::NdevCloudmanReadonly
46    }
47}
48
49// ########
50// HUB ###
51// ######
52
53/// Central instance to access all ServiceRegistry related resource activities
54///
55/// # Examples
56///
57/// Instantiate a new hub
58///
59/// ```test_harness,no_run
60/// extern crate hyper;
61/// extern crate hyper_rustls;
62/// extern crate google_serviceregistryalpha as serviceregistryalpha;
63/// use serviceregistryalpha::{Result, Error};
64/// # async fn dox() {
65/// use serviceregistryalpha::{ServiceRegistry, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
66///
67/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
68/// // `client_secret`, among other things.
69/// let secret: yup_oauth2::ApplicationSecret = Default::default();
70/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
71/// // unless you replace  `None` with the desired Flow.
72/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
73/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
74/// // retrieve them from storage.
75/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
76///     .with_native_roots()
77///     .unwrap()
78///     .https_only()
79///     .enable_http2()
80///     .build();
81///
82/// let executor = hyper_util::rt::TokioExecutor::new();
83/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
84///     secret,
85///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
86///     yup_oauth2::client::CustomHyperClientBuilder::from(
87///         hyper_util::client::legacy::Client::builder(executor).build(connector),
88///     ),
89/// ).build().await.unwrap();
90///
91/// let client = hyper_util::client::legacy::Client::builder(
92///     hyper_util::rt::TokioExecutor::new()
93/// )
94/// .build(
95///     hyper_rustls::HttpsConnectorBuilder::new()
96///         .with_native_roots()
97///         .unwrap()
98///         .https_or_http()
99///         .enable_http2()
100///         .build()
101/// );
102/// let mut hub = ServiceRegistry::new(client, auth);
103/// // You can configure optional parameters by calling the respective setters at will, and
104/// // execute the final call using `doit()`.
105/// // Values shown here are possibly random and not representative !
106/// let result = hub.operations().list("project")
107///              .page_token("duo")
108///              .order_by("ipsum")
109///              .max_results(39)
110///              .filter("Lorem")
111///              .doit().await;
112///
113/// match result {
114///     Err(e) => match e {
115///         // The Error enum provides details about what exactly happened.
116///         // You can also just use its `Debug`, `Display` or `Error` traits
117///          Error::HttpError(_)
118///         |Error::Io(_)
119///         |Error::MissingAPIKey
120///         |Error::MissingToken(_)
121///         |Error::Cancelled
122///         |Error::UploadSizeLimitExceeded(_, _)
123///         |Error::Failure(_)
124///         |Error::BadRequest(_)
125///         |Error::FieldClash(_)
126///         |Error::JsonDecodeError(_, _) => println!("{}", e),
127///     },
128///     Ok(res) => println!("Success: {:?}", res),
129/// }
130/// # }
131/// ```
132#[derive(Clone)]
133pub struct ServiceRegistry<C> {
134    pub client: common::Client<C>,
135    pub auth: Box<dyn common::GetToken>,
136    _user_agent: String,
137    _base_url: String,
138    _root_url: String,
139}
140
141impl<C> common::Hub for ServiceRegistry<C> {}
142
143impl<'a, C> ServiceRegistry<C> {
144    pub fn new<A: 'static + common::GetToken>(
145        client: common::Client<C>,
146        auth: A,
147    ) -> ServiceRegistry<C> {
148        ServiceRegistry {
149            client,
150            auth: Box::new(auth),
151            _user_agent: "google-api-rust-client/7.0.0".to_string(),
152            _base_url: "https://www.googleapis.com/serviceregistry/alpha/projects/".to_string(),
153            _root_url: "https://www.googleapis.com/".to_string(),
154        }
155    }
156
157    pub fn endpoints(&'a self) -> EndpointMethods<'a, C> {
158        EndpointMethods { hub: self }
159    }
160    pub fn operations(&'a self) -> OperationMethods<'a, C> {
161        OperationMethods { hub: self }
162    }
163
164    /// Set the user-agent header field to use in all requests to the server.
165    /// It defaults to `google-api-rust-client/7.0.0`.
166    ///
167    /// Returns the previously set user-agent.
168    pub fn user_agent(&mut self, agent_name: String) -> String {
169        std::mem::replace(&mut self._user_agent, agent_name)
170    }
171
172    /// Set the base url to use in all requests to the server.
173    /// It defaults to `https://www.googleapis.com/serviceregistry/alpha/projects/`.
174    ///
175    /// Returns the previously set base url.
176    pub fn base_url(&mut self, new_base_url: String) -> String {
177        std::mem::replace(&mut self._base_url, new_base_url)
178    }
179
180    /// Set the root url to use in all requests to the server.
181    /// It defaults to `https://www.googleapis.com/`.
182    ///
183    /// Returns the previously set root url.
184    pub fn root_url(&mut self, new_root_url: String) -> String {
185        std::mem::replace(&mut self._root_url, new_root_url)
186    }
187}
188
189// ############
190// SCHEMAS ###
191// ##########
192/// There is no detailed description.
193///
194/// # Activities
195///
196/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
197/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
198///
199/// * [delete endpoints](EndpointDeleteCall) (none)
200/// * [get endpoints](EndpointGetCall) (response)
201/// * [insert endpoints](EndpointInsertCall) (request)
202/// * [list endpoints](EndpointListCall) (none)
203/// * [patch endpoints](EndpointPatchCall) (request)
204/// * [update endpoints](EndpointUpdateCall) (request)
205#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
206#[serde_with::serde_as]
207#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
208pub struct Endpoint {
209    /// A user-provided address of the service represented by this endpoint. This can be an IPv4 or IPv6 address, or a hostname.
210    pub address: Option<String>,
211    /// [Output Only] Creation timestamp in RFC3339 text format.
212    #[serde(rename = "creationTimestamp")]
213    pub creation_timestamp: Option<String>,
214    /// An optional user-provided description of the endpoint.
215    pub description: Option<String>,
216    /// Supply the fingerprint value for update requests. The fingerprint value is generated by the server and ensures optimistic concurrency (so that only one update can be performed at a time). The fingerprint changes after each update.
217    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
218    pub fingerprint: Option<Vec<u8>>,
219    /// [Output Only] Unique identifier for the resource; defined by the server.
220    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
221    pub id: Option<u64>,
222    /// A user-provided name of the endpoint, which must be unique within the project. The name must comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
223    pub name: Option<String>,
224    /// An optional user-provided port of the service represented by this endpoint.
225    pub port: Option<i32>,
226    /// [Output Only] Self link for the endpoint.
227    #[serde(rename = "selfLink")]
228    pub self_link: Option<String>,
229    /// [Output Only] The current state of the endpoint, as determined by the system.
230    pub state: Option<String>,
231    /// The DNS Integration configuration for this endpoint. This must be a list of fully-qualified URLs to Compute Engine networks.
232    pub visibility: Option<EndpointEndpointVisibility>,
233}
234
235impl common::RequestValue for Endpoint {}
236impl common::Resource for Endpoint {}
237impl common::ResponseResult for Endpoint {}
238
239/// There is no detailed description.
240///
241/// This type is not used in any activity, and only used as *part* of another schema.
242///
243#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
244#[serde_with::serde_as]
245#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
246pub struct EndpointEndpointVisibility {
247    /// Google Compute Engine networks for which the name of this endpoint should be resolvable through DNS.
248    pub networks: Option<Vec<String>>,
249}
250
251impl common::Part for EndpointEndpointVisibility {}
252
253/// A response containing a partial list of Endpoints and a page token used to build the next request if the request has been truncated. Next available tag: 6
254///
255/// # Activities
256///
257/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
258/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
259///
260/// * [list endpoints](EndpointListCall) (response)
261#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
262#[serde_with::serde_as]
263#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
264pub struct EndpointsListResponse {
265    /// The endpoints contained in this response.
266    pub endpoints: Option<Vec<Endpoint>>,
267    /// [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results.
268    #[serde(rename = "nextPageToken")]
269    pub next_page_token: Option<String>,
270}
271
272impl common::ResponseResult for EndpointsListResponse {}
273
274/// An Operation resource, used to manage asynchronous API requests.
275///
276/// # Activities
277///
278/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
279/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
280///
281/// * [delete endpoints](EndpointDeleteCall) (response)
282/// * [insert endpoints](EndpointInsertCall) (response)
283/// * [patch endpoints](EndpointPatchCall) (response)
284/// * [update endpoints](EndpointUpdateCall) (response)
285/// * [get operations](OperationGetCall) (response)
286/// * [list operations](OperationListCall) (none)
287#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
288#[serde_with::serde_as]
289#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
290pub struct Operation {
291    /// [Output Only] Reserved for future use.
292    #[serde(rename = "clientOperationId")]
293    pub client_operation_id: Option<String>,
294    /// [Output Only] Creation timestamp in RFC3339 text format.
295    #[serde(rename = "creationTimestamp")]
296    pub creation_timestamp: Option<String>,
297    /// [Output Only] A textual description of the operation, which is set when the operation is created.
298    pub description: Option<String>,
299    /// [Output Only] The time that this operation was completed. This value is in RFC3339 text format.
300    #[serde(rename = "endTime")]
301    pub end_time: Option<String>,
302    /// [Output Only] If errors are generated during processing of the operation, this field will be populated.
303    pub error: Option<OperationError>,
304    /// [Output Only] If the operation fails, this field contains the HTTP error message that was returned, such as NOT FOUND.
305    #[serde(rename = "httpErrorMessage")]
306    pub http_error_message: Option<String>,
307    /// [Output Only] If the operation fails, this field contains the HTTP error status code that was returned. For example, a 404 means the resource was not found.
308    #[serde(rename = "httpErrorStatusCode")]
309    pub http_error_status_code: Option<i32>,
310    /// [Output Only] The unique identifier for the resource. This identifier is defined by the server.
311    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
312    pub id: Option<u64>,
313    /// [Output Only] The time that this operation was requested. This value is in RFC3339 text format.
314    #[serde(rename = "insertTime")]
315    pub insert_time: Option<String>,
316    /// [Output Only] Type of the resource. Always compute#operation for Operation resources.
317    pub kind: Option<String>,
318    /// [Output Only] Name of the resource.
319    pub name: Option<String>,
320    /// [Output Only] The type of operation, such as insert, update, or delete, and so on.
321    #[serde(rename = "operationType")]
322    pub operation_type: Option<String>,
323    /// [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 when the operation will be complete. This number should monotonically increase as the operation progresses.
324    pub progress: Option<i32>,
325    /// [Output Only] The URL of the region where the operation resides. Only available when performing regional operations.
326    pub region: Option<String>,
327    /// [Output Only] Server-defined URL for the resource.
328    #[serde(rename = "selfLink")]
329    pub self_link: Option<String>,
330    /// [Output Only] The time that this operation was started by the server. This value is in RFC3339 text format.
331    #[serde(rename = "startTime")]
332    pub start_time: Option<String>,
333    /// [Output Only] The status of the operation, which can be one of the following: PENDING, RUNNING, or DONE.
334    pub status: Option<String>,
335    /// [Output Only] An optional textual description of the current status of the operation.
336    #[serde(rename = "statusMessage")]
337    pub status_message: Option<String>,
338    /// [Output Only] The unique target ID, which identifies a specific incarnation of the target resource.
339    #[serde(rename = "targetId")]
340    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
341    pub target_id: Option<u64>,
342    /// [Output Only] The URL of the resource that the operation modifies.
343    #[serde(rename = "targetLink")]
344    pub target_link: Option<String>,
345    /// [Output Only] User who requested the operation, for example: user@example.com.
346    pub user: Option<String>,
347    /// [Output Only] If warning messages are generated during processing of the operation, this field will be populated.
348    pub warnings: Option<Vec<OperationWarnings>>,
349    /// [Output Only] The URL of the zone where the operation resides. Only available when performing per-zone operations.
350    pub zone: Option<String>,
351}
352
353impl common::Resource for Operation {}
354impl common::ResponseResult for Operation {}
355
356/// A response containing a partial list of operations and a page token used to build the next request if the request has been truncated.
357///
358/// # Activities
359///
360/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
361/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
362///
363/// * [list operations](OperationListCall) (response)
364#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
365#[serde_with::serde_as]
366#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
367pub struct OperationsListResponse {
368    /// [Output Only] A token used to continue a truncated list request.
369    #[serde(rename = "nextPageToken")]
370    pub next_page_token: Option<String>,
371    /// [Output Only] Operations contained in this list response.
372    pub operations: Option<Vec<Operation>>,
373}
374
375impl common::ResponseResult for OperationsListResponse {}
376
377/// [Output Only] If errors are generated during processing of the operation, this field will be populated.
378///
379/// This type is not used in any activity, and only used as *part* of another schema.
380///
381#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
382#[serde_with::serde_as]
383#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
384pub struct OperationError {
385    /// [Output Only] The array of errors encountered while processing this operation.
386    pub errors: Option<Vec<OperationErrorErrors>>,
387}
388
389impl common::NestedType for OperationError {}
390impl common::Part for OperationError {}
391
392/// [Output Only] The array of errors encountered while processing this operation.
393///
394/// This type is not used in any activity, and only used as *part* of another schema.
395///
396#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
397#[serde_with::serde_as]
398#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
399pub struct OperationErrorErrors {
400    /// [Output Only] The error type identifier for this error.
401    pub code: Option<String>,
402    /// [Output Only] Indicates the field in the request that caused the error. This property is optional.
403    pub location: Option<String>,
404    /// [Output Only] An optional, human-readable error message.
405    pub message: Option<String>,
406}
407
408impl common::NestedType for OperationErrorErrors {}
409impl common::Part for OperationErrorErrors {}
410
411/// [Output Only] If warning messages are generated during processing of the operation, this field will be populated.
412///
413/// This type is not used in any activity, and only used as *part* of another schema.
414///
415#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
416#[serde_with::serde_as]
417#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
418pub struct OperationWarnings {
419    /// [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response.
420    pub code: Option<String>,
421    /// [Output Only] Metadata about this warning in key: value format. For example:
422    /// "data": [ { "key": "scope", "value": "zones/us-east1-d" }
423    pub data: Option<Vec<OperationWarningsData>>,
424    /// [Output Only] A human-readable description of the warning code.
425    pub message: Option<String>,
426}
427
428impl common::NestedType for OperationWarnings {}
429impl common::Part for OperationWarnings {}
430
431/// [Output Only] Metadata about this warning in key: value format. For example:
432/// "data": [ { "key": "scope", "value": "zones/us-east1-d" }
433///
434/// This type is not used in any activity, and only used as *part* of another schema.
435///
436#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
437#[serde_with::serde_as]
438#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
439pub struct OperationWarningsData {
440    /// [Output Only] A key that provides more detail on the warning being returned. For example, for warnings where there are no results in a list request for a particular zone, this key might be scope and the key value might be the zone name. Other examples might be a key indicating a deprecated resource and a suggested replacement, or a warning about invalid network settings (for example, if an instance attempts to perform IP forwarding but is not enabled for IP forwarding).
441    pub key: Option<String>,
442    /// [Output Only] A warning data value corresponding to the key.
443    pub value: Option<String>,
444}
445
446impl common::NestedType for OperationWarningsData {}
447impl common::Part for OperationWarningsData {}
448
449// ###################
450// MethodBuilders ###
451// #################
452
453/// A builder providing access to all methods supported on *endpoint* resources.
454/// It is not used directly, but through the [`ServiceRegistry`] hub.
455///
456/// # Example
457///
458/// Instantiate a resource builder
459///
460/// ```test_harness,no_run
461/// extern crate hyper;
462/// extern crate hyper_rustls;
463/// extern crate google_serviceregistryalpha as serviceregistryalpha;
464///
465/// # async fn dox() {
466/// use serviceregistryalpha::{ServiceRegistry, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
467///
468/// let secret: yup_oauth2::ApplicationSecret = Default::default();
469/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
470///     .with_native_roots()
471///     .unwrap()
472///     .https_only()
473///     .enable_http2()
474///     .build();
475///
476/// let executor = hyper_util::rt::TokioExecutor::new();
477/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
478///     secret,
479///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
480///     yup_oauth2::client::CustomHyperClientBuilder::from(
481///         hyper_util::client::legacy::Client::builder(executor).build(connector),
482///     ),
483/// ).build().await.unwrap();
484///
485/// let client = hyper_util::client::legacy::Client::builder(
486///     hyper_util::rt::TokioExecutor::new()
487/// )
488/// .build(
489///     hyper_rustls::HttpsConnectorBuilder::new()
490///         .with_native_roots()
491///         .unwrap()
492///         .https_or_http()
493///         .enable_http2()
494///         .build()
495/// );
496/// let mut hub = ServiceRegistry::new(client, auth);
497/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
498/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
499/// // to build up your call.
500/// let rb = hub.endpoints();
501/// # }
502/// ```
503pub struct EndpointMethods<'a, C>
504where
505    C: 'a,
506{
507    hub: &'a ServiceRegistry<C>,
508}
509
510impl<'a, C> common::MethodsBuilder for EndpointMethods<'a, C> {}
511
512impl<'a, C> EndpointMethods<'a, C> {
513    /// Create a builder to help you perform the following task:
514    ///
515    /// Deletes an endpoint.
516    ///
517    /// # Arguments
518    ///
519    /// * `project` - The project ID for this request.
520    /// * `endpoint` - The name of the endpoint for this request.
521    pub fn delete(&self, project: &str, endpoint: &str) -> EndpointDeleteCall<'a, C> {
522        EndpointDeleteCall {
523            hub: self.hub,
524            _project: project.to_string(),
525            _endpoint: endpoint.to_string(),
526            _delegate: Default::default(),
527            _additional_params: Default::default(),
528            _scopes: Default::default(),
529        }
530    }
531
532    /// Create a builder to help you perform the following task:
533    ///
534    /// Gets an endpoint.
535    ///
536    /// # Arguments
537    ///
538    /// * `project` - The project ID for this request.
539    /// * `endpoint` - The name of the endpoint for this request.
540    pub fn get(&self, project: &str, endpoint: &str) -> EndpointGetCall<'a, C> {
541        EndpointGetCall {
542            hub: self.hub,
543            _project: project.to_string(),
544            _endpoint: endpoint.to_string(),
545            _delegate: Default::default(),
546            _additional_params: Default::default(),
547            _scopes: Default::default(),
548        }
549    }
550
551    /// Create a builder to help you perform the following task:
552    ///
553    /// Creates an endpoint.
554    ///
555    /// # Arguments
556    ///
557    /// * `request` - No description provided.
558    /// * `project` - The project ID for this request.
559    pub fn insert(&self, request: Endpoint, project: &str) -> EndpointInsertCall<'a, C> {
560        EndpointInsertCall {
561            hub: self.hub,
562            _request: request,
563            _project: project.to_string(),
564            _delegate: Default::default(),
565            _additional_params: Default::default(),
566            _scopes: Default::default(),
567        }
568    }
569
570    /// Create a builder to help you perform the following task:
571    ///
572    /// Lists endpoints for a project.
573    ///
574    /// # Arguments
575    ///
576    /// * `project` - The project ID for this request.
577    pub fn list(&self, project: &str) -> EndpointListCall<'a, C> {
578        EndpointListCall {
579            hub: self.hub,
580            _project: project.to_string(),
581            _page_token: Default::default(),
582            _order_by: Default::default(),
583            _max_results: Default::default(),
584            _filter: Default::default(),
585            _delegate: Default::default(),
586            _additional_params: Default::default(),
587            _scopes: Default::default(),
588        }
589    }
590
591    /// Create a builder to help you perform the following task:
592    ///
593    /// Updates an endpoint. This method supports patch semantics.
594    ///
595    /// # Arguments
596    ///
597    /// * `request` - No description provided.
598    /// * `project` - The project ID for this request.
599    /// * `endpoint` - The name of the endpoint for this request.
600    pub fn patch(
601        &self,
602        request: Endpoint,
603        project: &str,
604        endpoint: &str,
605    ) -> EndpointPatchCall<'a, C> {
606        EndpointPatchCall {
607            hub: self.hub,
608            _request: request,
609            _project: project.to_string(),
610            _endpoint: endpoint.to_string(),
611            _delegate: Default::default(),
612            _additional_params: Default::default(),
613            _scopes: Default::default(),
614        }
615    }
616
617    /// Create a builder to help you perform the following task:
618    ///
619    /// Updates an endpoint.
620    ///
621    /// # Arguments
622    ///
623    /// * `request` - No description provided.
624    /// * `project` - The project ID for this request.
625    /// * `endpoint` - The name of the endpoint for this request.
626    pub fn update(
627        &self,
628        request: Endpoint,
629        project: &str,
630        endpoint: &str,
631    ) -> EndpointUpdateCall<'a, C> {
632        EndpointUpdateCall {
633            hub: self.hub,
634            _request: request,
635            _project: project.to_string(),
636            _endpoint: endpoint.to_string(),
637            _delegate: Default::default(),
638            _additional_params: Default::default(),
639            _scopes: Default::default(),
640        }
641    }
642}
643
644/// A builder providing access to all methods supported on *operation* resources.
645/// It is not used directly, but through the [`ServiceRegistry`] hub.
646///
647/// # Example
648///
649/// Instantiate a resource builder
650///
651/// ```test_harness,no_run
652/// extern crate hyper;
653/// extern crate hyper_rustls;
654/// extern crate google_serviceregistryalpha as serviceregistryalpha;
655///
656/// # async fn dox() {
657/// use serviceregistryalpha::{ServiceRegistry, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
658///
659/// let secret: yup_oauth2::ApplicationSecret = Default::default();
660/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
661///     .with_native_roots()
662///     .unwrap()
663///     .https_only()
664///     .enable_http2()
665///     .build();
666///
667/// let executor = hyper_util::rt::TokioExecutor::new();
668/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
669///     secret,
670///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
671///     yup_oauth2::client::CustomHyperClientBuilder::from(
672///         hyper_util::client::legacy::Client::builder(executor).build(connector),
673///     ),
674/// ).build().await.unwrap();
675///
676/// let client = hyper_util::client::legacy::Client::builder(
677///     hyper_util::rt::TokioExecutor::new()
678/// )
679/// .build(
680///     hyper_rustls::HttpsConnectorBuilder::new()
681///         .with_native_roots()
682///         .unwrap()
683///         .https_or_http()
684///         .enable_http2()
685///         .build()
686/// );
687/// let mut hub = ServiceRegistry::new(client, auth);
688/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
689/// // like `get(...)` and `list(...)`
690/// // to build up your call.
691/// let rb = hub.operations();
692/// # }
693/// ```
694pub struct OperationMethods<'a, C>
695where
696    C: 'a,
697{
698    hub: &'a ServiceRegistry<C>,
699}
700
701impl<'a, C> common::MethodsBuilder for OperationMethods<'a, C> {}
702
703impl<'a, C> OperationMethods<'a, C> {
704    /// Create a builder to help you perform the following task:
705    ///
706    /// Gets information about a specific operation.
707    ///
708    /// # Arguments
709    ///
710    /// * `project` - The project ID for this request.
711    /// * `operation` - The name of the operation for this request.
712    pub fn get(&self, project: &str, operation: &str) -> OperationGetCall<'a, C> {
713        OperationGetCall {
714            hub: self.hub,
715            _project: project.to_string(),
716            _operation: operation.to_string(),
717            _delegate: Default::default(),
718            _additional_params: Default::default(),
719            _scopes: Default::default(),
720        }
721    }
722
723    /// Create a builder to help you perform the following task:
724    ///
725    /// Lists all operations for a project.
726    ///
727    /// # Arguments
728    ///
729    /// * `project` - The project ID for this request.
730    pub fn list(&self, project: &str) -> OperationListCall<'a, C> {
731        OperationListCall {
732            hub: self.hub,
733            _project: project.to_string(),
734            _page_token: Default::default(),
735            _order_by: Default::default(),
736            _max_results: Default::default(),
737            _filter: Default::default(),
738            _delegate: Default::default(),
739            _additional_params: Default::default(),
740            _scopes: Default::default(),
741        }
742    }
743}
744
745// ###################
746// CallBuilders   ###
747// #################
748
749/// Deletes an endpoint.
750///
751/// A builder for the *delete* method supported by a *endpoint* resource.
752/// It is not used directly, but through a [`EndpointMethods`] instance.
753///
754/// # Example
755///
756/// Instantiate a resource method builder
757///
758/// ```test_harness,no_run
759/// # extern crate hyper;
760/// # extern crate hyper_rustls;
761/// # extern crate google_serviceregistryalpha as serviceregistryalpha;
762/// # async fn dox() {
763/// # use serviceregistryalpha::{ServiceRegistry, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
764///
765/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
766/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
767/// #     .with_native_roots()
768/// #     .unwrap()
769/// #     .https_only()
770/// #     .enable_http2()
771/// #     .build();
772///
773/// # let executor = hyper_util::rt::TokioExecutor::new();
774/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
775/// #     secret,
776/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
777/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
778/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
779/// #     ),
780/// # ).build().await.unwrap();
781///
782/// # let client = hyper_util::client::legacy::Client::builder(
783/// #     hyper_util::rt::TokioExecutor::new()
784/// # )
785/// # .build(
786/// #     hyper_rustls::HttpsConnectorBuilder::new()
787/// #         .with_native_roots()
788/// #         .unwrap()
789/// #         .https_or_http()
790/// #         .enable_http2()
791/// #         .build()
792/// # );
793/// # let mut hub = ServiceRegistry::new(client, auth);
794/// // You can configure optional parameters by calling the respective setters at will, and
795/// // execute the final call using `doit()`.
796/// // Values shown here are possibly random and not representative !
797/// let result = hub.endpoints().delete("project", "endpoint")
798///              .doit().await;
799/// # }
800/// ```
801pub struct EndpointDeleteCall<'a, C>
802where
803    C: 'a,
804{
805    hub: &'a ServiceRegistry<C>,
806    _project: String,
807    _endpoint: String,
808    _delegate: Option<&'a mut dyn common::Delegate>,
809    _additional_params: HashMap<String, String>,
810    _scopes: BTreeSet<String>,
811}
812
813impl<'a, C> common::CallBuilder for EndpointDeleteCall<'a, C> {}
814
815impl<'a, C> EndpointDeleteCall<'a, C>
816where
817    C: common::Connector,
818{
819    /// Perform the operation you have build so far.
820    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
821        use std::borrow::Cow;
822        use std::io::{Read, Seek};
823
824        use common::{url::Params, ToParts};
825        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
826
827        let mut dd = common::DefaultDelegate;
828        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
829        dlg.begin(common::MethodInfo {
830            id: "serviceregistry.endpoints.delete",
831            http_method: hyper::Method::DELETE,
832        });
833
834        for &field in ["alt", "project", "endpoint"].iter() {
835            if self._additional_params.contains_key(field) {
836                dlg.finished(false);
837                return Err(common::Error::FieldClash(field));
838            }
839        }
840
841        let mut params = Params::with_capacity(4 + self._additional_params.len());
842        params.push("project", self._project);
843        params.push("endpoint", self._endpoint);
844
845        params.extend(self._additional_params.iter());
846
847        params.push("alt", "json");
848        let mut url = self.hub._base_url.clone() + "{project}/global/endpoints/{endpoint}";
849        if self._scopes.is_empty() {
850            self._scopes
851                .insert(Scope::CloudPlatform.as_ref().to_string());
852        }
853
854        #[allow(clippy::single_element_loop)]
855        for &(find_this, param_name) in
856            [("{project}", "project"), ("{endpoint}", "endpoint")].iter()
857        {
858            url = params.uri_replacement(url, param_name, find_this, false);
859        }
860        {
861            let to_remove = ["endpoint", "project"];
862            params.remove_params(&to_remove);
863        }
864
865        let url = params.parse_with_url(&url);
866
867        loop {
868            let token = match self
869                .hub
870                .auth
871                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
872                .await
873            {
874                Ok(token) => token,
875                Err(e) => match dlg.token(e) {
876                    Ok(token) => token,
877                    Err(e) => {
878                        dlg.finished(false);
879                        return Err(common::Error::MissingToken(e));
880                    }
881                },
882            };
883            let mut req_result = {
884                let client = &self.hub.client;
885                dlg.pre_request();
886                let mut req_builder = hyper::Request::builder()
887                    .method(hyper::Method::DELETE)
888                    .uri(url.as_str())
889                    .header(USER_AGENT, self.hub._user_agent.clone());
890
891                if let Some(token) = token.as_ref() {
892                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
893                }
894
895                let request = req_builder
896                    .header(CONTENT_LENGTH, 0_u64)
897                    .body(common::to_body::<String>(None));
898
899                client.request(request.unwrap()).await
900            };
901
902            match req_result {
903                Err(err) => {
904                    if let common::Retry::After(d) = dlg.http_error(&err) {
905                        sleep(d).await;
906                        continue;
907                    }
908                    dlg.finished(false);
909                    return Err(common::Error::HttpError(err));
910                }
911                Ok(res) => {
912                    let (mut parts, body) = res.into_parts();
913                    let mut body = common::Body::new(body);
914                    if !parts.status.is_success() {
915                        let bytes = common::to_bytes(body).await.unwrap_or_default();
916                        let error = serde_json::from_str(&common::to_string(&bytes));
917                        let response = common::to_response(parts, bytes.into());
918
919                        if let common::Retry::After(d) =
920                            dlg.http_failure(&response, error.as_ref().ok())
921                        {
922                            sleep(d).await;
923                            continue;
924                        }
925
926                        dlg.finished(false);
927
928                        return Err(match error {
929                            Ok(value) => common::Error::BadRequest(value),
930                            _ => common::Error::Failure(response),
931                        });
932                    }
933                    let response = {
934                        let bytes = common::to_bytes(body).await.unwrap_or_default();
935                        let encoded = common::to_string(&bytes);
936                        match serde_json::from_str(&encoded) {
937                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
938                            Err(error) => {
939                                dlg.response_json_decode_error(&encoded, &error);
940                                return Err(common::Error::JsonDecodeError(
941                                    encoded.to_string(),
942                                    error,
943                                ));
944                            }
945                        }
946                    };
947
948                    dlg.finished(true);
949                    return Ok(response);
950                }
951            }
952        }
953    }
954
955    /// The project ID for this request.
956    ///
957    /// Sets the *project* path property to the given value.
958    ///
959    /// Even though the property as already been set when instantiating this call,
960    /// we provide this method for API completeness.
961    pub fn project(mut self, new_value: &str) -> EndpointDeleteCall<'a, C> {
962        self._project = new_value.to_string();
963        self
964    }
965    /// The name of the endpoint for this request.
966    ///
967    /// Sets the *endpoint* path property to the given value.
968    ///
969    /// Even though the property as already been set when instantiating this call,
970    /// we provide this method for API completeness.
971    pub fn endpoint(mut self, new_value: &str) -> EndpointDeleteCall<'a, C> {
972        self._endpoint = new_value.to_string();
973        self
974    }
975    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
976    /// while executing the actual API request.
977    ///
978    /// ````text
979    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
980    /// ````
981    ///
982    /// Sets the *delegate* property to the given value.
983    pub fn delegate(
984        mut self,
985        new_value: &'a mut dyn common::Delegate,
986    ) -> EndpointDeleteCall<'a, C> {
987        self._delegate = Some(new_value);
988        self
989    }
990
991    /// Set any additional parameter of the query string used in the request.
992    /// It should be used to set parameters which are not yet available through their own
993    /// setters.
994    ///
995    /// Please note that this method must not be used to set any of the known parameters
996    /// which have their own setter method. If done anyway, the request will fail.
997    ///
998    /// # Additional Parameters
999    ///
1000    /// * *alt* (query-string) - Data format for the response.
1001    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1002    /// * *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.
1003    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1004    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1005    /// * *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.
1006    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1007    pub fn param<T>(mut self, name: T, value: T) -> EndpointDeleteCall<'a, C>
1008    where
1009        T: AsRef<str>,
1010    {
1011        self._additional_params
1012            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1013        self
1014    }
1015
1016    /// Identifies the authorization scope for the method you are building.
1017    ///
1018    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1019    /// [`Scope::CloudPlatform`].
1020    ///
1021    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1022    /// tokens for more than one scope.
1023    ///
1024    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1025    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1026    /// sufficient, a read-write scope will do as well.
1027    pub fn add_scope<St>(mut self, scope: St) -> EndpointDeleteCall<'a, C>
1028    where
1029        St: AsRef<str>,
1030    {
1031        self._scopes.insert(String::from(scope.as_ref()));
1032        self
1033    }
1034    /// Identifies the authorization scope(s) for the method you are building.
1035    ///
1036    /// See [`Self::add_scope()`] for details.
1037    pub fn add_scopes<I, St>(mut self, scopes: I) -> EndpointDeleteCall<'a, C>
1038    where
1039        I: IntoIterator<Item = St>,
1040        St: AsRef<str>,
1041    {
1042        self._scopes
1043            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1044        self
1045    }
1046
1047    /// Removes all scopes, and no default scope will be used either.
1048    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1049    /// for details).
1050    pub fn clear_scopes(mut self) -> EndpointDeleteCall<'a, C> {
1051        self._scopes.clear();
1052        self
1053    }
1054}
1055
1056/// Gets an endpoint.
1057///
1058/// A builder for the *get* method supported by a *endpoint* resource.
1059/// It is not used directly, but through a [`EndpointMethods`] instance.
1060///
1061/// # Example
1062///
1063/// Instantiate a resource method builder
1064///
1065/// ```test_harness,no_run
1066/// # extern crate hyper;
1067/// # extern crate hyper_rustls;
1068/// # extern crate google_serviceregistryalpha as serviceregistryalpha;
1069/// # async fn dox() {
1070/// # use serviceregistryalpha::{ServiceRegistry, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1071///
1072/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1073/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1074/// #     .with_native_roots()
1075/// #     .unwrap()
1076/// #     .https_only()
1077/// #     .enable_http2()
1078/// #     .build();
1079///
1080/// # let executor = hyper_util::rt::TokioExecutor::new();
1081/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1082/// #     secret,
1083/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1084/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1085/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1086/// #     ),
1087/// # ).build().await.unwrap();
1088///
1089/// # let client = hyper_util::client::legacy::Client::builder(
1090/// #     hyper_util::rt::TokioExecutor::new()
1091/// # )
1092/// # .build(
1093/// #     hyper_rustls::HttpsConnectorBuilder::new()
1094/// #         .with_native_roots()
1095/// #         .unwrap()
1096/// #         .https_or_http()
1097/// #         .enable_http2()
1098/// #         .build()
1099/// # );
1100/// # let mut hub = ServiceRegistry::new(client, auth);
1101/// // You can configure optional parameters by calling the respective setters at will, and
1102/// // execute the final call using `doit()`.
1103/// // Values shown here are possibly random and not representative !
1104/// let result = hub.endpoints().get("project", "endpoint")
1105///              .doit().await;
1106/// # }
1107/// ```
1108pub struct EndpointGetCall<'a, C>
1109where
1110    C: 'a,
1111{
1112    hub: &'a ServiceRegistry<C>,
1113    _project: String,
1114    _endpoint: String,
1115    _delegate: Option<&'a mut dyn common::Delegate>,
1116    _additional_params: HashMap<String, String>,
1117    _scopes: BTreeSet<String>,
1118}
1119
1120impl<'a, C> common::CallBuilder for EndpointGetCall<'a, C> {}
1121
1122impl<'a, C> EndpointGetCall<'a, C>
1123where
1124    C: common::Connector,
1125{
1126    /// Perform the operation you have build so far.
1127    pub async fn doit(mut self) -> common::Result<(common::Response, Endpoint)> {
1128        use std::borrow::Cow;
1129        use std::io::{Read, Seek};
1130
1131        use common::{url::Params, ToParts};
1132        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1133
1134        let mut dd = common::DefaultDelegate;
1135        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1136        dlg.begin(common::MethodInfo {
1137            id: "serviceregistry.endpoints.get",
1138            http_method: hyper::Method::GET,
1139        });
1140
1141        for &field in ["alt", "project", "endpoint"].iter() {
1142            if self._additional_params.contains_key(field) {
1143                dlg.finished(false);
1144                return Err(common::Error::FieldClash(field));
1145            }
1146        }
1147
1148        let mut params = Params::with_capacity(4 + self._additional_params.len());
1149        params.push("project", self._project);
1150        params.push("endpoint", self._endpoint);
1151
1152        params.extend(self._additional_params.iter());
1153
1154        params.push("alt", "json");
1155        let mut url = self.hub._base_url.clone() + "{project}/global/endpoints/{endpoint}";
1156        if self._scopes.is_empty() {
1157            self._scopes
1158                .insert(Scope::CloudPlatform.as_ref().to_string());
1159        }
1160
1161        #[allow(clippy::single_element_loop)]
1162        for &(find_this, param_name) in
1163            [("{project}", "project"), ("{endpoint}", "endpoint")].iter()
1164        {
1165            url = params.uri_replacement(url, param_name, find_this, false);
1166        }
1167        {
1168            let to_remove = ["endpoint", "project"];
1169            params.remove_params(&to_remove);
1170        }
1171
1172        let url = params.parse_with_url(&url);
1173
1174        loop {
1175            let token = match self
1176                .hub
1177                .auth
1178                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1179                .await
1180            {
1181                Ok(token) => token,
1182                Err(e) => match dlg.token(e) {
1183                    Ok(token) => token,
1184                    Err(e) => {
1185                        dlg.finished(false);
1186                        return Err(common::Error::MissingToken(e));
1187                    }
1188                },
1189            };
1190            let mut req_result = {
1191                let client = &self.hub.client;
1192                dlg.pre_request();
1193                let mut req_builder = hyper::Request::builder()
1194                    .method(hyper::Method::GET)
1195                    .uri(url.as_str())
1196                    .header(USER_AGENT, self.hub._user_agent.clone());
1197
1198                if let Some(token) = token.as_ref() {
1199                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1200                }
1201
1202                let request = req_builder
1203                    .header(CONTENT_LENGTH, 0_u64)
1204                    .body(common::to_body::<String>(None));
1205
1206                client.request(request.unwrap()).await
1207            };
1208
1209            match req_result {
1210                Err(err) => {
1211                    if let common::Retry::After(d) = dlg.http_error(&err) {
1212                        sleep(d).await;
1213                        continue;
1214                    }
1215                    dlg.finished(false);
1216                    return Err(common::Error::HttpError(err));
1217                }
1218                Ok(res) => {
1219                    let (mut parts, body) = res.into_parts();
1220                    let mut body = common::Body::new(body);
1221                    if !parts.status.is_success() {
1222                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1223                        let error = serde_json::from_str(&common::to_string(&bytes));
1224                        let response = common::to_response(parts, bytes.into());
1225
1226                        if let common::Retry::After(d) =
1227                            dlg.http_failure(&response, error.as_ref().ok())
1228                        {
1229                            sleep(d).await;
1230                            continue;
1231                        }
1232
1233                        dlg.finished(false);
1234
1235                        return Err(match error {
1236                            Ok(value) => common::Error::BadRequest(value),
1237                            _ => common::Error::Failure(response),
1238                        });
1239                    }
1240                    let response = {
1241                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1242                        let encoded = common::to_string(&bytes);
1243                        match serde_json::from_str(&encoded) {
1244                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1245                            Err(error) => {
1246                                dlg.response_json_decode_error(&encoded, &error);
1247                                return Err(common::Error::JsonDecodeError(
1248                                    encoded.to_string(),
1249                                    error,
1250                                ));
1251                            }
1252                        }
1253                    };
1254
1255                    dlg.finished(true);
1256                    return Ok(response);
1257                }
1258            }
1259        }
1260    }
1261
1262    /// The project ID for this request.
1263    ///
1264    /// Sets the *project* path property to the given value.
1265    ///
1266    /// Even though the property as already been set when instantiating this call,
1267    /// we provide this method for API completeness.
1268    pub fn project(mut self, new_value: &str) -> EndpointGetCall<'a, C> {
1269        self._project = new_value.to_string();
1270        self
1271    }
1272    /// The name of the endpoint for this request.
1273    ///
1274    /// Sets the *endpoint* path property to the given value.
1275    ///
1276    /// Even though the property as already been set when instantiating this call,
1277    /// we provide this method for API completeness.
1278    pub fn endpoint(mut self, new_value: &str) -> EndpointGetCall<'a, C> {
1279        self._endpoint = new_value.to_string();
1280        self
1281    }
1282    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1283    /// while executing the actual API request.
1284    ///
1285    /// ````text
1286    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1287    /// ````
1288    ///
1289    /// Sets the *delegate* property to the given value.
1290    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EndpointGetCall<'a, C> {
1291        self._delegate = Some(new_value);
1292        self
1293    }
1294
1295    /// Set any additional parameter of the query string used in the request.
1296    /// It should be used to set parameters which are not yet available through their own
1297    /// setters.
1298    ///
1299    /// Please note that this method must not be used to set any of the known parameters
1300    /// which have their own setter method. If done anyway, the request will fail.
1301    ///
1302    /// # Additional Parameters
1303    ///
1304    /// * *alt* (query-string) - Data format for the response.
1305    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1306    /// * *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.
1307    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1308    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1309    /// * *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.
1310    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1311    pub fn param<T>(mut self, name: T, value: T) -> EndpointGetCall<'a, C>
1312    where
1313        T: AsRef<str>,
1314    {
1315        self._additional_params
1316            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1317        self
1318    }
1319
1320    /// Identifies the authorization scope for the method you are building.
1321    ///
1322    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1323    /// [`Scope::CloudPlatform`].
1324    ///
1325    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1326    /// tokens for more than one scope.
1327    ///
1328    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1329    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1330    /// sufficient, a read-write scope will do as well.
1331    pub fn add_scope<St>(mut self, scope: St) -> EndpointGetCall<'a, C>
1332    where
1333        St: AsRef<str>,
1334    {
1335        self._scopes.insert(String::from(scope.as_ref()));
1336        self
1337    }
1338    /// Identifies the authorization scope(s) for the method you are building.
1339    ///
1340    /// See [`Self::add_scope()`] for details.
1341    pub fn add_scopes<I, St>(mut self, scopes: I) -> EndpointGetCall<'a, C>
1342    where
1343        I: IntoIterator<Item = St>,
1344        St: AsRef<str>,
1345    {
1346        self._scopes
1347            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1348        self
1349    }
1350
1351    /// Removes all scopes, and no default scope will be used either.
1352    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1353    /// for details).
1354    pub fn clear_scopes(mut self) -> EndpointGetCall<'a, C> {
1355        self._scopes.clear();
1356        self
1357    }
1358}
1359
1360/// Creates an endpoint.
1361///
1362/// A builder for the *insert* method supported by a *endpoint* resource.
1363/// It is not used directly, but through a [`EndpointMethods`] instance.
1364///
1365/// # Example
1366///
1367/// Instantiate a resource method builder
1368///
1369/// ```test_harness,no_run
1370/// # extern crate hyper;
1371/// # extern crate hyper_rustls;
1372/// # extern crate google_serviceregistryalpha as serviceregistryalpha;
1373/// use serviceregistryalpha::api::Endpoint;
1374/// # async fn dox() {
1375/// # use serviceregistryalpha::{ServiceRegistry, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1376///
1377/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1378/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1379/// #     .with_native_roots()
1380/// #     .unwrap()
1381/// #     .https_only()
1382/// #     .enable_http2()
1383/// #     .build();
1384///
1385/// # let executor = hyper_util::rt::TokioExecutor::new();
1386/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1387/// #     secret,
1388/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1389/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1390/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1391/// #     ),
1392/// # ).build().await.unwrap();
1393///
1394/// # let client = hyper_util::client::legacy::Client::builder(
1395/// #     hyper_util::rt::TokioExecutor::new()
1396/// # )
1397/// # .build(
1398/// #     hyper_rustls::HttpsConnectorBuilder::new()
1399/// #         .with_native_roots()
1400/// #         .unwrap()
1401/// #         .https_or_http()
1402/// #         .enable_http2()
1403/// #         .build()
1404/// # );
1405/// # let mut hub = ServiceRegistry::new(client, auth);
1406/// // As the method needs a request, you would usually fill it with the desired information
1407/// // into the respective structure. Some of the parts shown here might not be applicable !
1408/// // Values shown here are possibly random and not representative !
1409/// let mut req = Endpoint::default();
1410///
1411/// // You can configure optional parameters by calling the respective setters at will, and
1412/// // execute the final call using `doit()`.
1413/// // Values shown here are possibly random and not representative !
1414/// let result = hub.endpoints().insert(req, "project")
1415///              .doit().await;
1416/// # }
1417/// ```
1418pub struct EndpointInsertCall<'a, C>
1419where
1420    C: 'a,
1421{
1422    hub: &'a ServiceRegistry<C>,
1423    _request: Endpoint,
1424    _project: String,
1425    _delegate: Option<&'a mut dyn common::Delegate>,
1426    _additional_params: HashMap<String, String>,
1427    _scopes: BTreeSet<String>,
1428}
1429
1430impl<'a, C> common::CallBuilder for EndpointInsertCall<'a, C> {}
1431
1432impl<'a, C> EndpointInsertCall<'a, C>
1433where
1434    C: common::Connector,
1435{
1436    /// Perform the operation you have build so far.
1437    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1438        use std::borrow::Cow;
1439        use std::io::{Read, Seek};
1440
1441        use common::{url::Params, ToParts};
1442        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1443
1444        let mut dd = common::DefaultDelegate;
1445        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1446        dlg.begin(common::MethodInfo {
1447            id: "serviceregistry.endpoints.insert",
1448            http_method: hyper::Method::POST,
1449        });
1450
1451        for &field in ["alt", "project"].iter() {
1452            if self._additional_params.contains_key(field) {
1453                dlg.finished(false);
1454                return Err(common::Error::FieldClash(field));
1455            }
1456        }
1457
1458        let mut params = Params::with_capacity(4 + self._additional_params.len());
1459        params.push("project", self._project);
1460
1461        params.extend(self._additional_params.iter());
1462
1463        params.push("alt", "json");
1464        let mut url = self.hub._base_url.clone() + "{project}/global/endpoints";
1465        if self._scopes.is_empty() {
1466            self._scopes
1467                .insert(Scope::CloudPlatform.as_ref().to_string());
1468        }
1469
1470        #[allow(clippy::single_element_loop)]
1471        for &(find_this, param_name) in [("{project}", "project")].iter() {
1472            url = params.uri_replacement(url, param_name, find_this, false);
1473        }
1474        {
1475            let to_remove = ["project"];
1476            params.remove_params(&to_remove);
1477        }
1478
1479        let url = params.parse_with_url(&url);
1480
1481        let mut json_mime_type = mime::APPLICATION_JSON;
1482        let mut request_value_reader = {
1483            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1484            common::remove_json_null_values(&mut value);
1485            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1486            serde_json::to_writer(&mut dst, &value).unwrap();
1487            dst
1488        };
1489        let request_size = request_value_reader
1490            .seek(std::io::SeekFrom::End(0))
1491            .unwrap();
1492        request_value_reader
1493            .seek(std::io::SeekFrom::Start(0))
1494            .unwrap();
1495
1496        loop {
1497            let token = match self
1498                .hub
1499                .auth
1500                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1501                .await
1502            {
1503                Ok(token) => token,
1504                Err(e) => match dlg.token(e) {
1505                    Ok(token) => token,
1506                    Err(e) => {
1507                        dlg.finished(false);
1508                        return Err(common::Error::MissingToken(e));
1509                    }
1510                },
1511            };
1512            request_value_reader
1513                .seek(std::io::SeekFrom::Start(0))
1514                .unwrap();
1515            let mut req_result = {
1516                let client = &self.hub.client;
1517                dlg.pre_request();
1518                let mut req_builder = hyper::Request::builder()
1519                    .method(hyper::Method::POST)
1520                    .uri(url.as_str())
1521                    .header(USER_AGENT, self.hub._user_agent.clone());
1522
1523                if let Some(token) = token.as_ref() {
1524                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1525                }
1526
1527                let request = req_builder
1528                    .header(CONTENT_TYPE, json_mime_type.to_string())
1529                    .header(CONTENT_LENGTH, request_size as u64)
1530                    .body(common::to_body(
1531                        request_value_reader.get_ref().clone().into(),
1532                    ));
1533
1534                client.request(request.unwrap()).await
1535            };
1536
1537            match req_result {
1538                Err(err) => {
1539                    if let common::Retry::After(d) = dlg.http_error(&err) {
1540                        sleep(d).await;
1541                        continue;
1542                    }
1543                    dlg.finished(false);
1544                    return Err(common::Error::HttpError(err));
1545                }
1546                Ok(res) => {
1547                    let (mut parts, body) = res.into_parts();
1548                    let mut body = common::Body::new(body);
1549                    if !parts.status.is_success() {
1550                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1551                        let error = serde_json::from_str(&common::to_string(&bytes));
1552                        let response = common::to_response(parts, bytes.into());
1553
1554                        if let common::Retry::After(d) =
1555                            dlg.http_failure(&response, error.as_ref().ok())
1556                        {
1557                            sleep(d).await;
1558                            continue;
1559                        }
1560
1561                        dlg.finished(false);
1562
1563                        return Err(match error {
1564                            Ok(value) => common::Error::BadRequest(value),
1565                            _ => common::Error::Failure(response),
1566                        });
1567                    }
1568                    let response = {
1569                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1570                        let encoded = common::to_string(&bytes);
1571                        match serde_json::from_str(&encoded) {
1572                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1573                            Err(error) => {
1574                                dlg.response_json_decode_error(&encoded, &error);
1575                                return Err(common::Error::JsonDecodeError(
1576                                    encoded.to_string(),
1577                                    error,
1578                                ));
1579                            }
1580                        }
1581                    };
1582
1583                    dlg.finished(true);
1584                    return Ok(response);
1585                }
1586            }
1587        }
1588    }
1589
1590    ///
1591    /// Sets the *request* property to the given value.
1592    ///
1593    /// Even though the property as already been set when instantiating this call,
1594    /// we provide this method for API completeness.
1595    pub fn request(mut self, new_value: Endpoint) -> EndpointInsertCall<'a, C> {
1596        self._request = new_value;
1597        self
1598    }
1599    /// The project ID for this request.
1600    ///
1601    /// Sets the *project* path property to the given value.
1602    ///
1603    /// Even though the property as already been set when instantiating this call,
1604    /// we provide this method for API completeness.
1605    pub fn project(mut self, new_value: &str) -> EndpointInsertCall<'a, C> {
1606        self._project = new_value.to_string();
1607        self
1608    }
1609    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1610    /// while executing the actual API request.
1611    ///
1612    /// ````text
1613    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1614    /// ````
1615    ///
1616    /// Sets the *delegate* property to the given value.
1617    pub fn delegate(
1618        mut self,
1619        new_value: &'a mut dyn common::Delegate,
1620    ) -> EndpointInsertCall<'a, C> {
1621        self._delegate = Some(new_value);
1622        self
1623    }
1624
1625    /// Set any additional parameter of the query string used in the request.
1626    /// It should be used to set parameters which are not yet available through their own
1627    /// setters.
1628    ///
1629    /// Please note that this method must not be used to set any of the known parameters
1630    /// which have their own setter method. If done anyway, the request will fail.
1631    ///
1632    /// # Additional Parameters
1633    ///
1634    /// * *alt* (query-string) - Data format for the response.
1635    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1636    /// * *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.
1637    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1638    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1639    /// * *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.
1640    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1641    pub fn param<T>(mut self, name: T, value: T) -> EndpointInsertCall<'a, C>
1642    where
1643        T: AsRef<str>,
1644    {
1645        self._additional_params
1646            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1647        self
1648    }
1649
1650    /// Identifies the authorization scope for the method you are building.
1651    ///
1652    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1653    /// [`Scope::CloudPlatform`].
1654    ///
1655    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1656    /// tokens for more than one scope.
1657    ///
1658    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1659    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1660    /// sufficient, a read-write scope will do as well.
1661    pub fn add_scope<St>(mut self, scope: St) -> EndpointInsertCall<'a, C>
1662    where
1663        St: AsRef<str>,
1664    {
1665        self._scopes.insert(String::from(scope.as_ref()));
1666        self
1667    }
1668    /// Identifies the authorization scope(s) for the method you are building.
1669    ///
1670    /// See [`Self::add_scope()`] for details.
1671    pub fn add_scopes<I, St>(mut self, scopes: I) -> EndpointInsertCall<'a, C>
1672    where
1673        I: IntoIterator<Item = St>,
1674        St: AsRef<str>,
1675    {
1676        self._scopes
1677            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1678        self
1679    }
1680
1681    /// Removes all scopes, and no default scope will be used either.
1682    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1683    /// for details).
1684    pub fn clear_scopes(mut self) -> EndpointInsertCall<'a, C> {
1685        self._scopes.clear();
1686        self
1687    }
1688}
1689
1690/// Lists endpoints for a project.
1691///
1692/// A builder for the *list* method supported by a *endpoint* resource.
1693/// It is not used directly, but through a [`EndpointMethods`] instance.
1694///
1695/// # Example
1696///
1697/// Instantiate a resource method builder
1698///
1699/// ```test_harness,no_run
1700/// # extern crate hyper;
1701/// # extern crate hyper_rustls;
1702/// # extern crate google_serviceregistryalpha as serviceregistryalpha;
1703/// # async fn dox() {
1704/// # use serviceregistryalpha::{ServiceRegistry, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1705///
1706/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1707/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1708/// #     .with_native_roots()
1709/// #     .unwrap()
1710/// #     .https_only()
1711/// #     .enable_http2()
1712/// #     .build();
1713///
1714/// # let executor = hyper_util::rt::TokioExecutor::new();
1715/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1716/// #     secret,
1717/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1718/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1719/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1720/// #     ),
1721/// # ).build().await.unwrap();
1722///
1723/// # let client = hyper_util::client::legacy::Client::builder(
1724/// #     hyper_util::rt::TokioExecutor::new()
1725/// # )
1726/// # .build(
1727/// #     hyper_rustls::HttpsConnectorBuilder::new()
1728/// #         .with_native_roots()
1729/// #         .unwrap()
1730/// #         .https_or_http()
1731/// #         .enable_http2()
1732/// #         .build()
1733/// # );
1734/// # let mut hub = ServiceRegistry::new(client, auth);
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.endpoints().list("project")
1739///              .page_token("amet")
1740///              .order_by("duo")
1741///              .max_results(51)
1742///              .filter("sed")
1743///              .doit().await;
1744/// # }
1745/// ```
1746pub struct EndpointListCall<'a, C>
1747where
1748    C: 'a,
1749{
1750    hub: &'a ServiceRegistry<C>,
1751    _project: String,
1752    _page_token: Option<String>,
1753    _order_by: Option<String>,
1754    _max_results: Option<u32>,
1755    _filter: Option<String>,
1756    _delegate: Option<&'a mut dyn common::Delegate>,
1757    _additional_params: HashMap<String, String>,
1758    _scopes: BTreeSet<String>,
1759}
1760
1761impl<'a, C> common::CallBuilder for EndpointListCall<'a, C> {}
1762
1763impl<'a, C> EndpointListCall<'a, C>
1764where
1765    C: common::Connector,
1766{
1767    /// Perform the operation you have build so far.
1768    pub async fn doit(mut self) -> common::Result<(common::Response, EndpointsListResponse)> {
1769        use std::borrow::Cow;
1770        use std::io::{Read, Seek};
1771
1772        use common::{url::Params, ToParts};
1773        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1774
1775        let mut dd = common::DefaultDelegate;
1776        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1777        dlg.begin(common::MethodInfo {
1778            id: "serviceregistry.endpoints.list",
1779            http_method: hyper::Method::GET,
1780        });
1781
1782        for &field in [
1783            "alt",
1784            "project",
1785            "pageToken",
1786            "orderBy",
1787            "maxResults",
1788            "filter",
1789        ]
1790        .iter()
1791        {
1792            if self._additional_params.contains_key(field) {
1793                dlg.finished(false);
1794                return Err(common::Error::FieldClash(field));
1795            }
1796        }
1797
1798        let mut params = Params::with_capacity(7 + self._additional_params.len());
1799        params.push("project", self._project);
1800        if let Some(value) = self._page_token.as_ref() {
1801            params.push("pageToken", value);
1802        }
1803        if let Some(value) = self._order_by.as_ref() {
1804            params.push("orderBy", value);
1805        }
1806        if let Some(value) = self._max_results.as_ref() {
1807            params.push("maxResults", value.to_string());
1808        }
1809        if let Some(value) = self._filter.as_ref() {
1810            params.push("filter", value);
1811        }
1812
1813        params.extend(self._additional_params.iter());
1814
1815        params.push("alt", "json");
1816        let mut url = self.hub._base_url.clone() + "{project}/global/endpoints";
1817        if self._scopes.is_empty() {
1818            self._scopes
1819                .insert(Scope::CloudPlatform.as_ref().to_string());
1820        }
1821
1822        #[allow(clippy::single_element_loop)]
1823        for &(find_this, param_name) in [("{project}", "project")].iter() {
1824            url = params.uri_replacement(url, param_name, find_this, false);
1825        }
1826        {
1827            let to_remove = ["project"];
1828            params.remove_params(&to_remove);
1829        }
1830
1831        let url = params.parse_with_url(&url);
1832
1833        loop {
1834            let token = match self
1835                .hub
1836                .auth
1837                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1838                .await
1839            {
1840                Ok(token) => token,
1841                Err(e) => match dlg.token(e) {
1842                    Ok(token) => token,
1843                    Err(e) => {
1844                        dlg.finished(false);
1845                        return Err(common::Error::MissingToken(e));
1846                    }
1847                },
1848            };
1849            let mut req_result = {
1850                let client = &self.hub.client;
1851                dlg.pre_request();
1852                let mut req_builder = hyper::Request::builder()
1853                    .method(hyper::Method::GET)
1854                    .uri(url.as_str())
1855                    .header(USER_AGENT, self.hub._user_agent.clone());
1856
1857                if let Some(token) = token.as_ref() {
1858                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1859                }
1860
1861                let request = req_builder
1862                    .header(CONTENT_LENGTH, 0_u64)
1863                    .body(common::to_body::<String>(None));
1864
1865                client.request(request.unwrap()).await
1866            };
1867
1868            match req_result {
1869                Err(err) => {
1870                    if let common::Retry::After(d) = dlg.http_error(&err) {
1871                        sleep(d).await;
1872                        continue;
1873                    }
1874                    dlg.finished(false);
1875                    return Err(common::Error::HttpError(err));
1876                }
1877                Ok(res) => {
1878                    let (mut parts, body) = res.into_parts();
1879                    let mut body = common::Body::new(body);
1880                    if !parts.status.is_success() {
1881                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1882                        let error = serde_json::from_str(&common::to_string(&bytes));
1883                        let response = common::to_response(parts, bytes.into());
1884
1885                        if let common::Retry::After(d) =
1886                            dlg.http_failure(&response, error.as_ref().ok())
1887                        {
1888                            sleep(d).await;
1889                            continue;
1890                        }
1891
1892                        dlg.finished(false);
1893
1894                        return Err(match error {
1895                            Ok(value) => common::Error::BadRequest(value),
1896                            _ => common::Error::Failure(response),
1897                        });
1898                    }
1899                    let response = {
1900                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1901                        let encoded = common::to_string(&bytes);
1902                        match serde_json::from_str(&encoded) {
1903                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1904                            Err(error) => {
1905                                dlg.response_json_decode_error(&encoded, &error);
1906                                return Err(common::Error::JsonDecodeError(
1907                                    encoded.to_string(),
1908                                    error,
1909                                ));
1910                            }
1911                        }
1912                    };
1913
1914                    dlg.finished(true);
1915                    return Ok(response);
1916                }
1917            }
1918        }
1919    }
1920
1921    /// The project ID for this request.
1922    ///
1923    /// Sets the *project* path property to the given value.
1924    ///
1925    /// Even though the property as already been set when instantiating this call,
1926    /// we provide this method for API completeness.
1927    pub fn project(mut self, new_value: &str) -> EndpointListCall<'a, C> {
1928        self._project = new_value.to_string();
1929        self
1930    }
1931    /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results.
1932    ///
1933    /// Sets the *page token* query property to the given value.
1934    pub fn page_token(mut self, new_value: &str) -> EndpointListCall<'a, C> {
1935        self._page_token = Some(new_value.to_string());
1936        self
1937    }
1938    /// Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name.
1939    ///
1940    /// You can also sort results in descending order based on the creation timestamp using orderBy="creationTimestamp desc". This sorts results based on the creationTimestamp field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first.
1941    ///
1942    /// Currently, only sorting by name or creationTimestamp desc is supported.
1943    ///
1944    /// Sets the *order by* query property to the given value.
1945    pub fn order_by(mut self, new_value: &str) -> EndpointListCall<'a, C> {
1946        self._order_by = Some(new_value.to_string());
1947        self
1948    }
1949    /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests.
1950    ///
1951    /// Sets the *max results* query property to the given value.
1952    pub fn max_results(mut self, new_value: u32) -> EndpointListCall<'a, C> {
1953        self._max_results = Some(new_value);
1954        self
1955    }
1956    /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string.
1957    ///
1958    /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field.
1959    ///
1960    /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance.
1961    ///
1962    /// Compute Engine Beta API Only: When filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values.
1963    ///
1964    /// The Beta API also supports filtering on multiple expressions by providing each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters.
1965    ///
1966    /// Sets the *filter* query property to the given value.
1967    pub fn filter(mut self, new_value: &str) -> EndpointListCall<'a, C> {
1968        self._filter = Some(new_value.to_string());
1969        self
1970    }
1971    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1972    /// while executing the actual API request.
1973    ///
1974    /// ````text
1975    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1976    /// ````
1977    ///
1978    /// Sets the *delegate* property to the given value.
1979    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EndpointListCall<'a, C> {
1980        self._delegate = Some(new_value);
1981        self
1982    }
1983
1984    /// Set any additional parameter of the query string used in the request.
1985    /// It should be used to set parameters which are not yet available through their own
1986    /// setters.
1987    ///
1988    /// Please note that this method must not be used to set any of the known parameters
1989    /// which have their own setter method. If done anyway, the request will fail.
1990    ///
1991    /// # Additional Parameters
1992    ///
1993    /// * *alt* (query-string) - Data format for the response.
1994    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1995    /// * *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.
1996    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1997    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1998    /// * *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.
1999    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2000    pub fn param<T>(mut self, name: T, value: T) -> EndpointListCall<'a, C>
2001    where
2002        T: AsRef<str>,
2003    {
2004        self._additional_params
2005            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2006        self
2007    }
2008
2009    /// Identifies the authorization scope for the method you are building.
2010    ///
2011    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2012    /// [`Scope::CloudPlatform`].
2013    ///
2014    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2015    /// tokens for more than one scope.
2016    ///
2017    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2018    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2019    /// sufficient, a read-write scope will do as well.
2020    pub fn add_scope<St>(mut self, scope: St) -> EndpointListCall<'a, C>
2021    where
2022        St: AsRef<str>,
2023    {
2024        self._scopes.insert(String::from(scope.as_ref()));
2025        self
2026    }
2027    /// Identifies the authorization scope(s) for the method you are building.
2028    ///
2029    /// See [`Self::add_scope()`] for details.
2030    pub fn add_scopes<I, St>(mut self, scopes: I) -> EndpointListCall<'a, C>
2031    where
2032        I: IntoIterator<Item = St>,
2033        St: AsRef<str>,
2034    {
2035        self._scopes
2036            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2037        self
2038    }
2039
2040    /// Removes all scopes, and no default scope will be used either.
2041    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2042    /// for details).
2043    pub fn clear_scopes(mut self) -> EndpointListCall<'a, C> {
2044        self._scopes.clear();
2045        self
2046    }
2047}
2048
2049/// Updates an endpoint. This method supports patch semantics.
2050///
2051/// A builder for the *patch* method supported by a *endpoint* resource.
2052/// It is not used directly, but through a [`EndpointMethods`] instance.
2053///
2054/// # Example
2055///
2056/// Instantiate a resource method builder
2057///
2058/// ```test_harness,no_run
2059/// # extern crate hyper;
2060/// # extern crate hyper_rustls;
2061/// # extern crate google_serviceregistryalpha as serviceregistryalpha;
2062/// use serviceregistryalpha::api::Endpoint;
2063/// # async fn dox() {
2064/// # use serviceregistryalpha::{ServiceRegistry, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2065///
2066/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2067/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2068/// #     .with_native_roots()
2069/// #     .unwrap()
2070/// #     .https_only()
2071/// #     .enable_http2()
2072/// #     .build();
2073///
2074/// # let executor = hyper_util::rt::TokioExecutor::new();
2075/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2076/// #     secret,
2077/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2078/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2079/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2080/// #     ),
2081/// # ).build().await.unwrap();
2082///
2083/// # let client = hyper_util::client::legacy::Client::builder(
2084/// #     hyper_util::rt::TokioExecutor::new()
2085/// # )
2086/// # .build(
2087/// #     hyper_rustls::HttpsConnectorBuilder::new()
2088/// #         .with_native_roots()
2089/// #         .unwrap()
2090/// #         .https_or_http()
2091/// #         .enable_http2()
2092/// #         .build()
2093/// # );
2094/// # let mut hub = ServiceRegistry::new(client, auth);
2095/// // As the method needs a request, you would usually fill it with the desired information
2096/// // into the respective structure. Some of the parts shown here might not be applicable !
2097/// // Values shown here are possibly random and not representative !
2098/// let mut req = Endpoint::default();
2099///
2100/// // You can configure optional parameters by calling the respective setters at will, and
2101/// // execute the final call using `doit()`.
2102/// // Values shown here are possibly random and not representative !
2103/// let result = hub.endpoints().patch(req, "project", "endpoint")
2104///              .doit().await;
2105/// # }
2106/// ```
2107pub struct EndpointPatchCall<'a, C>
2108where
2109    C: 'a,
2110{
2111    hub: &'a ServiceRegistry<C>,
2112    _request: Endpoint,
2113    _project: String,
2114    _endpoint: String,
2115    _delegate: Option<&'a mut dyn common::Delegate>,
2116    _additional_params: HashMap<String, String>,
2117    _scopes: BTreeSet<String>,
2118}
2119
2120impl<'a, C> common::CallBuilder for EndpointPatchCall<'a, C> {}
2121
2122impl<'a, C> EndpointPatchCall<'a, C>
2123where
2124    C: common::Connector,
2125{
2126    /// Perform the operation you have build so far.
2127    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2128        use std::borrow::Cow;
2129        use std::io::{Read, Seek};
2130
2131        use common::{url::Params, ToParts};
2132        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2133
2134        let mut dd = common::DefaultDelegate;
2135        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2136        dlg.begin(common::MethodInfo {
2137            id: "serviceregistry.endpoints.patch",
2138            http_method: hyper::Method::PATCH,
2139        });
2140
2141        for &field in ["alt", "project", "endpoint"].iter() {
2142            if self._additional_params.contains_key(field) {
2143                dlg.finished(false);
2144                return Err(common::Error::FieldClash(field));
2145            }
2146        }
2147
2148        let mut params = Params::with_capacity(5 + self._additional_params.len());
2149        params.push("project", self._project);
2150        params.push("endpoint", self._endpoint);
2151
2152        params.extend(self._additional_params.iter());
2153
2154        params.push("alt", "json");
2155        let mut url = self.hub._base_url.clone() + "{project}/global/endpoints/{endpoint}";
2156        if self._scopes.is_empty() {
2157            self._scopes
2158                .insert(Scope::CloudPlatform.as_ref().to_string());
2159        }
2160
2161        #[allow(clippy::single_element_loop)]
2162        for &(find_this, param_name) in
2163            [("{project}", "project"), ("{endpoint}", "endpoint")].iter()
2164        {
2165            url = params.uri_replacement(url, param_name, find_this, false);
2166        }
2167        {
2168            let to_remove = ["endpoint", "project"];
2169            params.remove_params(&to_remove);
2170        }
2171
2172        let url = params.parse_with_url(&url);
2173
2174        let mut json_mime_type = mime::APPLICATION_JSON;
2175        let mut request_value_reader = {
2176            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2177            common::remove_json_null_values(&mut value);
2178            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2179            serde_json::to_writer(&mut dst, &value).unwrap();
2180            dst
2181        };
2182        let request_size = request_value_reader
2183            .seek(std::io::SeekFrom::End(0))
2184            .unwrap();
2185        request_value_reader
2186            .seek(std::io::SeekFrom::Start(0))
2187            .unwrap();
2188
2189        loop {
2190            let token = match self
2191                .hub
2192                .auth
2193                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2194                .await
2195            {
2196                Ok(token) => token,
2197                Err(e) => match dlg.token(e) {
2198                    Ok(token) => token,
2199                    Err(e) => {
2200                        dlg.finished(false);
2201                        return Err(common::Error::MissingToken(e));
2202                    }
2203                },
2204            };
2205            request_value_reader
2206                .seek(std::io::SeekFrom::Start(0))
2207                .unwrap();
2208            let mut req_result = {
2209                let client = &self.hub.client;
2210                dlg.pre_request();
2211                let mut req_builder = hyper::Request::builder()
2212                    .method(hyper::Method::PATCH)
2213                    .uri(url.as_str())
2214                    .header(USER_AGENT, self.hub._user_agent.clone());
2215
2216                if let Some(token) = token.as_ref() {
2217                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2218                }
2219
2220                let request = req_builder
2221                    .header(CONTENT_TYPE, json_mime_type.to_string())
2222                    .header(CONTENT_LENGTH, request_size as u64)
2223                    .body(common::to_body(
2224                        request_value_reader.get_ref().clone().into(),
2225                    ));
2226
2227                client.request(request.unwrap()).await
2228            };
2229
2230            match req_result {
2231                Err(err) => {
2232                    if let common::Retry::After(d) = dlg.http_error(&err) {
2233                        sleep(d).await;
2234                        continue;
2235                    }
2236                    dlg.finished(false);
2237                    return Err(common::Error::HttpError(err));
2238                }
2239                Ok(res) => {
2240                    let (mut parts, body) = res.into_parts();
2241                    let mut body = common::Body::new(body);
2242                    if !parts.status.is_success() {
2243                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2244                        let error = serde_json::from_str(&common::to_string(&bytes));
2245                        let response = common::to_response(parts, bytes.into());
2246
2247                        if let common::Retry::After(d) =
2248                            dlg.http_failure(&response, error.as_ref().ok())
2249                        {
2250                            sleep(d).await;
2251                            continue;
2252                        }
2253
2254                        dlg.finished(false);
2255
2256                        return Err(match error {
2257                            Ok(value) => common::Error::BadRequest(value),
2258                            _ => common::Error::Failure(response),
2259                        });
2260                    }
2261                    let response = {
2262                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2263                        let encoded = common::to_string(&bytes);
2264                        match serde_json::from_str(&encoded) {
2265                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2266                            Err(error) => {
2267                                dlg.response_json_decode_error(&encoded, &error);
2268                                return Err(common::Error::JsonDecodeError(
2269                                    encoded.to_string(),
2270                                    error,
2271                                ));
2272                            }
2273                        }
2274                    };
2275
2276                    dlg.finished(true);
2277                    return Ok(response);
2278                }
2279            }
2280        }
2281    }
2282
2283    ///
2284    /// Sets the *request* property to the given value.
2285    ///
2286    /// Even though the property as already been set when instantiating this call,
2287    /// we provide this method for API completeness.
2288    pub fn request(mut self, new_value: Endpoint) -> EndpointPatchCall<'a, C> {
2289        self._request = new_value;
2290        self
2291    }
2292    /// The project ID for this request.
2293    ///
2294    /// Sets the *project* path property to the given value.
2295    ///
2296    /// Even though the property as already been set when instantiating this call,
2297    /// we provide this method for API completeness.
2298    pub fn project(mut self, new_value: &str) -> EndpointPatchCall<'a, C> {
2299        self._project = new_value.to_string();
2300        self
2301    }
2302    /// The name of the endpoint for this request.
2303    ///
2304    /// Sets the *endpoint* path property to the given value.
2305    ///
2306    /// Even though the property as already been set when instantiating this call,
2307    /// we provide this method for API completeness.
2308    pub fn endpoint(mut self, new_value: &str) -> EndpointPatchCall<'a, C> {
2309        self._endpoint = new_value.to_string();
2310        self
2311    }
2312    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2313    /// while executing the actual API request.
2314    ///
2315    /// ````text
2316    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2317    /// ````
2318    ///
2319    /// Sets the *delegate* property to the given value.
2320    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EndpointPatchCall<'a, C> {
2321        self._delegate = Some(new_value);
2322        self
2323    }
2324
2325    /// Set any additional parameter of the query string used in the request.
2326    /// It should be used to set parameters which are not yet available through their own
2327    /// setters.
2328    ///
2329    /// Please note that this method must not be used to set any of the known parameters
2330    /// which have their own setter method. If done anyway, the request will fail.
2331    ///
2332    /// # Additional Parameters
2333    ///
2334    /// * *alt* (query-string) - Data format for the response.
2335    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2336    /// * *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.
2337    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2338    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2339    /// * *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.
2340    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2341    pub fn param<T>(mut self, name: T, value: T) -> EndpointPatchCall<'a, C>
2342    where
2343        T: AsRef<str>,
2344    {
2345        self._additional_params
2346            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2347        self
2348    }
2349
2350    /// Identifies the authorization scope for the method you are building.
2351    ///
2352    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2353    /// [`Scope::CloudPlatform`].
2354    ///
2355    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2356    /// tokens for more than one scope.
2357    ///
2358    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2359    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2360    /// sufficient, a read-write scope will do as well.
2361    pub fn add_scope<St>(mut self, scope: St) -> EndpointPatchCall<'a, C>
2362    where
2363        St: AsRef<str>,
2364    {
2365        self._scopes.insert(String::from(scope.as_ref()));
2366        self
2367    }
2368    /// Identifies the authorization scope(s) for the method you are building.
2369    ///
2370    /// See [`Self::add_scope()`] for details.
2371    pub fn add_scopes<I, St>(mut self, scopes: I) -> EndpointPatchCall<'a, C>
2372    where
2373        I: IntoIterator<Item = St>,
2374        St: AsRef<str>,
2375    {
2376        self._scopes
2377            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2378        self
2379    }
2380
2381    /// Removes all scopes, and no default scope will be used either.
2382    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2383    /// for details).
2384    pub fn clear_scopes(mut self) -> EndpointPatchCall<'a, C> {
2385        self._scopes.clear();
2386        self
2387    }
2388}
2389
2390/// Updates an endpoint.
2391///
2392/// A builder for the *update* method supported by a *endpoint* resource.
2393/// It is not used directly, but through a [`EndpointMethods`] instance.
2394///
2395/// # Example
2396///
2397/// Instantiate a resource method builder
2398///
2399/// ```test_harness,no_run
2400/// # extern crate hyper;
2401/// # extern crate hyper_rustls;
2402/// # extern crate google_serviceregistryalpha as serviceregistryalpha;
2403/// use serviceregistryalpha::api::Endpoint;
2404/// # async fn dox() {
2405/// # use serviceregistryalpha::{ServiceRegistry, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2406///
2407/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2408/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2409/// #     .with_native_roots()
2410/// #     .unwrap()
2411/// #     .https_only()
2412/// #     .enable_http2()
2413/// #     .build();
2414///
2415/// # let executor = hyper_util::rt::TokioExecutor::new();
2416/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2417/// #     secret,
2418/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2419/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2420/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2421/// #     ),
2422/// # ).build().await.unwrap();
2423///
2424/// # let client = hyper_util::client::legacy::Client::builder(
2425/// #     hyper_util::rt::TokioExecutor::new()
2426/// # )
2427/// # .build(
2428/// #     hyper_rustls::HttpsConnectorBuilder::new()
2429/// #         .with_native_roots()
2430/// #         .unwrap()
2431/// #         .https_or_http()
2432/// #         .enable_http2()
2433/// #         .build()
2434/// # );
2435/// # let mut hub = ServiceRegistry::new(client, auth);
2436/// // As the method needs a request, you would usually fill it with the desired information
2437/// // into the respective structure. Some of the parts shown here might not be applicable !
2438/// // Values shown here are possibly random and not representative !
2439/// let mut req = Endpoint::default();
2440///
2441/// // You can configure optional parameters by calling the respective setters at will, and
2442/// // execute the final call using `doit()`.
2443/// // Values shown here are possibly random and not representative !
2444/// let result = hub.endpoints().update(req, "project", "endpoint")
2445///              .doit().await;
2446/// # }
2447/// ```
2448pub struct EndpointUpdateCall<'a, C>
2449where
2450    C: 'a,
2451{
2452    hub: &'a ServiceRegistry<C>,
2453    _request: Endpoint,
2454    _project: String,
2455    _endpoint: String,
2456    _delegate: Option<&'a mut dyn common::Delegate>,
2457    _additional_params: HashMap<String, String>,
2458    _scopes: BTreeSet<String>,
2459}
2460
2461impl<'a, C> common::CallBuilder for EndpointUpdateCall<'a, C> {}
2462
2463impl<'a, C> EndpointUpdateCall<'a, C>
2464where
2465    C: common::Connector,
2466{
2467    /// Perform the operation you have build so far.
2468    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2469        use std::borrow::Cow;
2470        use std::io::{Read, Seek};
2471
2472        use common::{url::Params, ToParts};
2473        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2474
2475        let mut dd = common::DefaultDelegate;
2476        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2477        dlg.begin(common::MethodInfo {
2478            id: "serviceregistry.endpoints.update",
2479            http_method: hyper::Method::PUT,
2480        });
2481
2482        for &field in ["alt", "project", "endpoint"].iter() {
2483            if self._additional_params.contains_key(field) {
2484                dlg.finished(false);
2485                return Err(common::Error::FieldClash(field));
2486            }
2487        }
2488
2489        let mut params = Params::with_capacity(5 + self._additional_params.len());
2490        params.push("project", self._project);
2491        params.push("endpoint", self._endpoint);
2492
2493        params.extend(self._additional_params.iter());
2494
2495        params.push("alt", "json");
2496        let mut url = self.hub._base_url.clone() + "{project}/global/endpoints/{endpoint}";
2497        if self._scopes.is_empty() {
2498            self._scopes
2499                .insert(Scope::CloudPlatform.as_ref().to_string());
2500        }
2501
2502        #[allow(clippy::single_element_loop)]
2503        for &(find_this, param_name) in
2504            [("{project}", "project"), ("{endpoint}", "endpoint")].iter()
2505        {
2506            url = params.uri_replacement(url, param_name, find_this, false);
2507        }
2508        {
2509            let to_remove = ["endpoint", "project"];
2510            params.remove_params(&to_remove);
2511        }
2512
2513        let url = params.parse_with_url(&url);
2514
2515        let mut json_mime_type = mime::APPLICATION_JSON;
2516        let mut request_value_reader = {
2517            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2518            common::remove_json_null_values(&mut value);
2519            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2520            serde_json::to_writer(&mut dst, &value).unwrap();
2521            dst
2522        };
2523        let request_size = request_value_reader
2524            .seek(std::io::SeekFrom::End(0))
2525            .unwrap();
2526        request_value_reader
2527            .seek(std::io::SeekFrom::Start(0))
2528            .unwrap();
2529
2530        loop {
2531            let token = match self
2532                .hub
2533                .auth
2534                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2535                .await
2536            {
2537                Ok(token) => token,
2538                Err(e) => match dlg.token(e) {
2539                    Ok(token) => token,
2540                    Err(e) => {
2541                        dlg.finished(false);
2542                        return Err(common::Error::MissingToken(e));
2543                    }
2544                },
2545            };
2546            request_value_reader
2547                .seek(std::io::SeekFrom::Start(0))
2548                .unwrap();
2549            let mut req_result = {
2550                let client = &self.hub.client;
2551                dlg.pre_request();
2552                let mut req_builder = hyper::Request::builder()
2553                    .method(hyper::Method::PUT)
2554                    .uri(url.as_str())
2555                    .header(USER_AGENT, self.hub._user_agent.clone());
2556
2557                if let Some(token) = token.as_ref() {
2558                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2559                }
2560
2561                let request = req_builder
2562                    .header(CONTENT_TYPE, json_mime_type.to_string())
2563                    .header(CONTENT_LENGTH, request_size as u64)
2564                    .body(common::to_body(
2565                        request_value_reader.get_ref().clone().into(),
2566                    ));
2567
2568                client.request(request.unwrap()).await
2569            };
2570
2571            match req_result {
2572                Err(err) => {
2573                    if let common::Retry::After(d) = dlg.http_error(&err) {
2574                        sleep(d).await;
2575                        continue;
2576                    }
2577                    dlg.finished(false);
2578                    return Err(common::Error::HttpError(err));
2579                }
2580                Ok(res) => {
2581                    let (mut parts, body) = res.into_parts();
2582                    let mut body = common::Body::new(body);
2583                    if !parts.status.is_success() {
2584                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2585                        let error = serde_json::from_str(&common::to_string(&bytes));
2586                        let response = common::to_response(parts, bytes.into());
2587
2588                        if let common::Retry::After(d) =
2589                            dlg.http_failure(&response, error.as_ref().ok())
2590                        {
2591                            sleep(d).await;
2592                            continue;
2593                        }
2594
2595                        dlg.finished(false);
2596
2597                        return Err(match error {
2598                            Ok(value) => common::Error::BadRequest(value),
2599                            _ => common::Error::Failure(response),
2600                        });
2601                    }
2602                    let response = {
2603                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2604                        let encoded = common::to_string(&bytes);
2605                        match serde_json::from_str(&encoded) {
2606                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2607                            Err(error) => {
2608                                dlg.response_json_decode_error(&encoded, &error);
2609                                return Err(common::Error::JsonDecodeError(
2610                                    encoded.to_string(),
2611                                    error,
2612                                ));
2613                            }
2614                        }
2615                    };
2616
2617                    dlg.finished(true);
2618                    return Ok(response);
2619                }
2620            }
2621        }
2622    }
2623
2624    ///
2625    /// Sets the *request* property to the given value.
2626    ///
2627    /// Even though the property as already been set when instantiating this call,
2628    /// we provide this method for API completeness.
2629    pub fn request(mut self, new_value: Endpoint) -> EndpointUpdateCall<'a, C> {
2630        self._request = new_value;
2631        self
2632    }
2633    /// The project ID for this request.
2634    ///
2635    /// Sets the *project* path property to the given value.
2636    ///
2637    /// Even though the property as already been set when instantiating this call,
2638    /// we provide this method for API completeness.
2639    pub fn project(mut self, new_value: &str) -> EndpointUpdateCall<'a, C> {
2640        self._project = new_value.to_string();
2641        self
2642    }
2643    /// The name of the endpoint for this request.
2644    ///
2645    /// Sets the *endpoint* path property to the given value.
2646    ///
2647    /// Even though the property as already been set when instantiating this call,
2648    /// we provide this method for API completeness.
2649    pub fn endpoint(mut self, new_value: &str) -> EndpointUpdateCall<'a, C> {
2650        self._endpoint = new_value.to_string();
2651        self
2652    }
2653    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2654    /// while executing the actual API request.
2655    ///
2656    /// ````text
2657    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2658    /// ````
2659    ///
2660    /// Sets the *delegate* property to the given value.
2661    pub fn delegate(
2662        mut self,
2663        new_value: &'a mut dyn common::Delegate,
2664    ) -> EndpointUpdateCall<'a, C> {
2665        self._delegate = Some(new_value);
2666        self
2667    }
2668
2669    /// Set any additional parameter of the query string used in the request.
2670    /// It should be used to set parameters which are not yet available through their own
2671    /// setters.
2672    ///
2673    /// Please note that this method must not be used to set any of the known parameters
2674    /// which have their own setter method. If done anyway, the request will fail.
2675    ///
2676    /// # Additional Parameters
2677    ///
2678    /// * *alt* (query-string) - Data format for the response.
2679    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2680    /// * *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.
2681    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2682    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2683    /// * *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.
2684    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2685    pub fn param<T>(mut self, name: T, value: T) -> EndpointUpdateCall<'a, C>
2686    where
2687        T: AsRef<str>,
2688    {
2689        self._additional_params
2690            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2691        self
2692    }
2693
2694    /// Identifies the authorization scope for the method you are building.
2695    ///
2696    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2697    /// [`Scope::CloudPlatform`].
2698    ///
2699    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2700    /// tokens for more than one scope.
2701    ///
2702    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2703    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2704    /// sufficient, a read-write scope will do as well.
2705    pub fn add_scope<St>(mut self, scope: St) -> EndpointUpdateCall<'a, C>
2706    where
2707        St: AsRef<str>,
2708    {
2709        self._scopes.insert(String::from(scope.as_ref()));
2710        self
2711    }
2712    /// Identifies the authorization scope(s) for the method you are building.
2713    ///
2714    /// See [`Self::add_scope()`] for details.
2715    pub fn add_scopes<I, St>(mut self, scopes: I) -> EndpointUpdateCall<'a, C>
2716    where
2717        I: IntoIterator<Item = St>,
2718        St: AsRef<str>,
2719    {
2720        self._scopes
2721            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2722        self
2723    }
2724
2725    /// Removes all scopes, and no default scope will be used either.
2726    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2727    /// for details).
2728    pub fn clear_scopes(mut self) -> EndpointUpdateCall<'a, C> {
2729        self._scopes.clear();
2730        self
2731    }
2732}
2733
2734/// Gets information about a specific operation.
2735///
2736/// A builder for the *get* method supported by a *operation* resource.
2737/// It is not used directly, but through a [`OperationMethods`] instance.
2738///
2739/// # Example
2740///
2741/// Instantiate a resource method builder
2742///
2743/// ```test_harness,no_run
2744/// # extern crate hyper;
2745/// # extern crate hyper_rustls;
2746/// # extern crate google_serviceregistryalpha as serviceregistryalpha;
2747/// # async fn dox() {
2748/// # use serviceregistryalpha::{ServiceRegistry, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2749///
2750/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2751/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2752/// #     .with_native_roots()
2753/// #     .unwrap()
2754/// #     .https_only()
2755/// #     .enable_http2()
2756/// #     .build();
2757///
2758/// # let executor = hyper_util::rt::TokioExecutor::new();
2759/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2760/// #     secret,
2761/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2762/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2763/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2764/// #     ),
2765/// # ).build().await.unwrap();
2766///
2767/// # let client = hyper_util::client::legacy::Client::builder(
2768/// #     hyper_util::rt::TokioExecutor::new()
2769/// # )
2770/// # .build(
2771/// #     hyper_rustls::HttpsConnectorBuilder::new()
2772/// #         .with_native_roots()
2773/// #         .unwrap()
2774/// #         .https_or_http()
2775/// #         .enable_http2()
2776/// #         .build()
2777/// # );
2778/// # let mut hub = ServiceRegistry::new(client, auth);
2779/// // You can configure optional parameters by calling the respective setters at will, and
2780/// // execute the final call using `doit()`.
2781/// // Values shown here are possibly random and not representative !
2782/// let result = hub.operations().get("project", "operation")
2783///              .doit().await;
2784/// # }
2785/// ```
2786pub struct OperationGetCall<'a, C>
2787where
2788    C: 'a,
2789{
2790    hub: &'a ServiceRegistry<C>,
2791    _project: String,
2792    _operation: String,
2793    _delegate: Option<&'a mut dyn common::Delegate>,
2794    _additional_params: HashMap<String, String>,
2795    _scopes: BTreeSet<String>,
2796}
2797
2798impl<'a, C> common::CallBuilder for OperationGetCall<'a, C> {}
2799
2800impl<'a, C> OperationGetCall<'a, C>
2801where
2802    C: common::Connector,
2803{
2804    /// Perform the operation you have build so far.
2805    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2806        use std::borrow::Cow;
2807        use std::io::{Read, Seek};
2808
2809        use common::{url::Params, ToParts};
2810        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2811
2812        let mut dd = common::DefaultDelegate;
2813        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2814        dlg.begin(common::MethodInfo {
2815            id: "serviceregistry.operations.get",
2816            http_method: hyper::Method::GET,
2817        });
2818
2819        for &field in ["alt", "project", "operation"].iter() {
2820            if self._additional_params.contains_key(field) {
2821                dlg.finished(false);
2822                return Err(common::Error::FieldClash(field));
2823            }
2824        }
2825
2826        let mut params = Params::with_capacity(4 + self._additional_params.len());
2827        params.push("project", self._project);
2828        params.push("operation", self._operation);
2829
2830        params.extend(self._additional_params.iter());
2831
2832        params.push("alt", "json");
2833        let mut url = self.hub._base_url.clone() + "{project}/global/operations/{operation}";
2834        if self._scopes.is_empty() {
2835            self._scopes
2836                .insert(Scope::NdevCloudmanReadonly.as_ref().to_string());
2837        }
2838
2839        #[allow(clippy::single_element_loop)]
2840        for &(find_this, param_name) in
2841            [("{project}", "project"), ("{operation}", "operation")].iter()
2842        {
2843            url = params.uri_replacement(url, param_name, find_this, false);
2844        }
2845        {
2846            let to_remove = ["operation", "project"];
2847            params.remove_params(&to_remove);
2848        }
2849
2850        let url = params.parse_with_url(&url);
2851
2852        loop {
2853            let token = match self
2854                .hub
2855                .auth
2856                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2857                .await
2858            {
2859                Ok(token) => token,
2860                Err(e) => match dlg.token(e) {
2861                    Ok(token) => token,
2862                    Err(e) => {
2863                        dlg.finished(false);
2864                        return Err(common::Error::MissingToken(e));
2865                    }
2866                },
2867            };
2868            let mut req_result = {
2869                let client = &self.hub.client;
2870                dlg.pre_request();
2871                let mut req_builder = hyper::Request::builder()
2872                    .method(hyper::Method::GET)
2873                    .uri(url.as_str())
2874                    .header(USER_AGENT, self.hub._user_agent.clone());
2875
2876                if let Some(token) = token.as_ref() {
2877                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2878                }
2879
2880                let request = req_builder
2881                    .header(CONTENT_LENGTH, 0_u64)
2882                    .body(common::to_body::<String>(None));
2883
2884                client.request(request.unwrap()).await
2885            };
2886
2887            match req_result {
2888                Err(err) => {
2889                    if let common::Retry::After(d) = dlg.http_error(&err) {
2890                        sleep(d).await;
2891                        continue;
2892                    }
2893                    dlg.finished(false);
2894                    return Err(common::Error::HttpError(err));
2895                }
2896                Ok(res) => {
2897                    let (mut parts, body) = res.into_parts();
2898                    let mut body = common::Body::new(body);
2899                    if !parts.status.is_success() {
2900                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2901                        let error = serde_json::from_str(&common::to_string(&bytes));
2902                        let response = common::to_response(parts, bytes.into());
2903
2904                        if let common::Retry::After(d) =
2905                            dlg.http_failure(&response, error.as_ref().ok())
2906                        {
2907                            sleep(d).await;
2908                            continue;
2909                        }
2910
2911                        dlg.finished(false);
2912
2913                        return Err(match error {
2914                            Ok(value) => common::Error::BadRequest(value),
2915                            _ => common::Error::Failure(response),
2916                        });
2917                    }
2918                    let response = {
2919                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2920                        let encoded = common::to_string(&bytes);
2921                        match serde_json::from_str(&encoded) {
2922                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2923                            Err(error) => {
2924                                dlg.response_json_decode_error(&encoded, &error);
2925                                return Err(common::Error::JsonDecodeError(
2926                                    encoded.to_string(),
2927                                    error,
2928                                ));
2929                            }
2930                        }
2931                    };
2932
2933                    dlg.finished(true);
2934                    return Ok(response);
2935                }
2936            }
2937        }
2938    }
2939
2940    /// The project ID for this request.
2941    ///
2942    /// Sets the *project* path property to the given value.
2943    ///
2944    /// Even though the property as already been set when instantiating this call,
2945    /// we provide this method for API completeness.
2946    pub fn project(mut self, new_value: &str) -> OperationGetCall<'a, C> {
2947        self._project = new_value.to_string();
2948        self
2949    }
2950    /// The name of the operation for this request.
2951    ///
2952    /// Sets the *operation* path property to the given value.
2953    ///
2954    /// Even though the property as already been set when instantiating this call,
2955    /// we provide this method for API completeness.
2956    pub fn operation(mut self, new_value: &str) -> OperationGetCall<'a, C> {
2957        self._operation = new_value.to_string();
2958        self
2959    }
2960    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2961    /// while executing the actual API request.
2962    ///
2963    /// ````text
2964    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2965    /// ````
2966    ///
2967    /// Sets the *delegate* property to the given value.
2968    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationGetCall<'a, C> {
2969        self._delegate = Some(new_value);
2970        self
2971    }
2972
2973    /// Set any additional parameter of the query string used in the request.
2974    /// It should be used to set parameters which are not yet available through their own
2975    /// setters.
2976    ///
2977    /// Please note that this method must not be used to set any of the known parameters
2978    /// which have their own setter method. If done anyway, the request will fail.
2979    ///
2980    /// # Additional Parameters
2981    ///
2982    /// * *alt* (query-string) - Data format for the response.
2983    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2984    /// * *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.
2985    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2986    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2987    /// * *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.
2988    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2989    pub fn param<T>(mut self, name: T, value: T) -> OperationGetCall<'a, C>
2990    where
2991        T: AsRef<str>,
2992    {
2993        self._additional_params
2994            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2995        self
2996    }
2997
2998    /// Identifies the authorization scope for the method you are building.
2999    ///
3000    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3001    /// [`Scope::NdevCloudmanReadonly`].
3002    ///
3003    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3004    /// tokens for more than one scope.
3005    ///
3006    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3007    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3008    /// sufficient, a read-write scope will do as well.
3009    pub fn add_scope<St>(mut self, scope: St) -> OperationGetCall<'a, C>
3010    where
3011        St: AsRef<str>,
3012    {
3013        self._scopes.insert(String::from(scope.as_ref()));
3014        self
3015    }
3016    /// Identifies the authorization scope(s) for the method you are building.
3017    ///
3018    /// See [`Self::add_scope()`] for details.
3019    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationGetCall<'a, C>
3020    where
3021        I: IntoIterator<Item = St>,
3022        St: AsRef<str>,
3023    {
3024        self._scopes
3025            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3026        self
3027    }
3028
3029    /// Removes all scopes, and no default scope will be used either.
3030    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3031    /// for details).
3032    pub fn clear_scopes(mut self) -> OperationGetCall<'a, C> {
3033        self._scopes.clear();
3034        self
3035    }
3036}
3037
3038/// Lists all operations for a project.
3039///
3040/// A builder for the *list* method supported by a *operation* resource.
3041/// It is not used directly, but through a [`OperationMethods`] instance.
3042///
3043/// # Example
3044///
3045/// Instantiate a resource method builder
3046///
3047/// ```test_harness,no_run
3048/// # extern crate hyper;
3049/// # extern crate hyper_rustls;
3050/// # extern crate google_serviceregistryalpha as serviceregistryalpha;
3051/// # async fn dox() {
3052/// # use serviceregistryalpha::{ServiceRegistry, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3053///
3054/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3055/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3056/// #     .with_native_roots()
3057/// #     .unwrap()
3058/// #     .https_only()
3059/// #     .enable_http2()
3060/// #     .build();
3061///
3062/// # let executor = hyper_util::rt::TokioExecutor::new();
3063/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3064/// #     secret,
3065/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3066/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3067/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3068/// #     ),
3069/// # ).build().await.unwrap();
3070///
3071/// # let client = hyper_util::client::legacy::Client::builder(
3072/// #     hyper_util::rt::TokioExecutor::new()
3073/// # )
3074/// # .build(
3075/// #     hyper_rustls::HttpsConnectorBuilder::new()
3076/// #         .with_native_roots()
3077/// #         .unwrap()
3078/// #         .https_or_http()
3079/// #         .enable_http2()
3080/// #         .build()
3081/// # );
3082/// # let mut hub = ServiceRegistry::new(client, auth);
3083/// // You can configure optional parameters by calling the respective setters at will, and
3084/// // execute the final call using `doit()`.
3085/// // Values shown here are possibly random and not representative !
3086/// let result = hub.operations().list("project")
3087///              .page_token("gubergren")
3088///              .order_by("ea")
3089///              .max_results(2)
3090///              .filter("Lorem")
3091///              .doit().await;
3092/// # }
3093/// ```
3094pub struct OperationListCall<'a, C>
3095where
3096    C: 'a,
3097{
3098    hub: &'a ServiceRegistry<C>,
3099    _project: String,
3100    _page_token: Option<String>,
3101    _order_by: Option<String>,
3102    _max_results: Option<u32>,
3103    _filter: Option<String>,
3104    _delegate: Option<&'a mut dyn common::Delegate>,
3105    _additional_params: HashMap<String, String>,
3106    _scopes: BTreeSet<String>,
3107}
3108
3109impl<'a, C> common::CallBuilder for OperationListCall<'a, C> {}
3110
3111impl<'a, C> OperationListCall<'a, C>
3112where
3113    C: common::Connector,
3114{
3115    /// Perform the operation you have build so far.
3116    pub async fn doit(mut self) -> common::Result<(common::Response, OperationsListResponse)> {
3117        use std::borrow::Cow;
3118        use std::io::{Read, Seek};
3119
3120        use common::{url::Params, ToParts};
3121        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3122
3123        let mut dd = common::DefaultDelegate;
3124        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3125        dlg.begin(common::MethodInfo {
3126            id: "serviceregistry.operations.list",
3127            http_method: hyper::Method::GET,
3128        });
3129
3130        for &field in [
3131            "alt",
3132            "project",
3133            "pageToken",
3134            "orderBy",
3135            "maxResults",
3136            "filter",
3137        ]
3138        .iter()
3139        {
3140            if self._additional_params.contains_key(field) {
3141                dlg.finished(false);
3142                return Err(common::Error::FieldClash(field));
3143            }
3144        }
3145
3146        let mut params = Params::with_capacity(7 + self._additional_params.len());
3147        params.push("project", self._project);
3148        if let Some(value) = self._page_token.as_ref() {
3149            params.push("pageToken", value);
3150        }
3151        if let Some(value) = self._order_by.as_ref() {
3152            params.push("orderBy", value);
3153        }
3154        if let Some(value) = self._max_results.as_ref() {
3155            params.push("maxResults", value.to_string());
3156        }
3157        if let Some(value) = self._filter.as_ref() {
3158            params.push("filter", value);
3159        }
3160
3161        params.extend(self._additional_params.iter());
3162
3163        params.push("alt", "json");
3164        let mut url = self.hub._base_url.clone() + "{project}/global/operations";
3165        if self._scopes.is_empty() {
3166            self._scopes
3167                .insert(Scope::NdevCloudmanReadonly.as_ref().to_string());
3168        }
3169
3170        #[allow(clippy::single_element_loop)]
3171        for &(find_this, param_name) in [("{project}", "project")].iter() {
3172            url = params.uri_replacement(url, param_name, find_this, false);
3173        }
3174        {
3175            let to_remove = ["project"];
3176            params.remove_params(&to_remove);
3177        }
3178
3179        let url = params.parse_with_url(&url);
3180
3181        loop {
3182            let token = match self
3183                .hub
3184                .auth
3185                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3186                .await
3187            {
3188                Ok(token) => token,
3189                Err(e) => match dlg.token(e) {
3190                    Ok(token) => token,
3191                    Err(e) => {
3192                        dlg.finished(false);
3193                        return Err(common::Error::MissingToken(e));
3194                    }
3195                },
3196            };
3197            let mut req_result = {
3198                let client = &self.hub.client;
3199                dlg.pre_request();
3200                let mut req_builder = hyper::Request::builder()
3201                    .method(hyper::Method::GET)
3202                    .uri(url.as_str())
3203                    .header(USER_AGENT, self.hub._user_agent.clone());
3204
3205                if let Some(token) = token.as_ref() {
3206                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3207                }
3208
3209                let request = req_builder
3210                    .header(CONTENT_LENGTH, 0_u64)
3211                    .body(common::to_body::<String>(None));
3212
3213                client.request(request.unwrap()).await
3214            };
3215
3216            match req_result {
3217                Err(err) => {
3218                    if let common::Retry::After(d) = dlg.http_error(&err) {
3219                        sleep(d).await;
3220                        continue;
3221                    }
3222                    dlg.finished(false);
3223                    return Err(common::Error::HttpError(err));
3224                }
3225                Ok(res) => {
3226                    let (mut parts, body) = res.into_parts();
3227                    let mut body = common::Body::new(body);
3228                    if !parts.status.is_success() {
3229                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3230                        let error = serde_json::from_str(&common::to_string(&bytes));
3231                        let response = common::to_response(parts, bytes.into());
3232
3233                        if let common::Retry::After(d) =
3234                            dlg.http_failure(&response, error.as_ref().ok())
3235                        {
3236                            sleep(d).await;
3237                            continue;
3238                        }
3239
3240                        dlg.finished(false);
3241
3242                        return Err(match error {
3243                            Ok(value) => common::Error::BadRequest(value),
3244                            _ => common::Error::Failure(response),
3245                        });
3246                    }
3247                    let response = {
3248                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3249                        let encoded = common::to_string(&bytes);
3250                        match serde_json::from_str(&encoded) {
3251                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3252                            Err(error) => {
3253                                dlg.response_json_decode_error(&encoded, &error);
3254                                return Err(common::Error::JsonDecodeError(
3255                                    encoded.to_string(),
3256                                    error,
3257                                ));
3258                            }
3259                        }
3260                    };
3261
3262                    dlg.finished(true);
3263                    return Ok(response);
3264                }
3265            }
3266        }
3267    }
3268
3269    /// The project ID for this request.
3270    ///
3271    /// Sets the *project* path property to the given value.
3272    ///
3273    /// Even though the property as already been set when instantiating this call,
3274    /// we provide this method for API completeness.
3275    pub fn project(mut self, new_value: &str) -> OperationListCall<'a, C> {
3276        self._project = new_value.to_string();
3277        self
3278    }
3279    /// Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results.
3280    ///
3281    /// Sets the *page token* query property to the given value.
3282    pub fn page_token(mut self, new_value: &str) -> OperationListCall<'a, C> {
3283        self._page_token = Some(new_value.to_string());
3284        self
3285    }
3286    /// Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name.
3287    ///
3288    /// You can also sort results in descending order based on the creation timestamp using orderBy="creationTimestamp desc". This sorts results based on the creationTimestamp field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first.
3289    ///
3290    /// Currently, only sorting by name or creationTimestamp desc is supported.
3291    ///
3292    /// Sets the *order by* query property to the given value.
3293    pub fn order_by(mut self, new_value: &str) -> OperationListCall<'a, C> {
3294        self._order_by = Some(new_value.to_string());
3295        self
3296    }
3297    /// The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests.
3298    ///
3299    /// Sets the *max results* query property to the given value.
3300    pub fn max_results(mut self, new_value: u32) -> OperationListCall<'a, C> {
3301        self._max_results = Some(new_value);
3302        self
3303    }
3304    /// Sets a filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must be in the format: field_name comparison_string literal_string.
3305    ///
3306    /// The field_name is the name of the field you want to compare. Only atomic field types are supported (string, number, boolean). The comparison_string must be either eq (equals) or ne (not equals). The literal_string is the string value to filter to. The literal value must be valid for the type of field you are filtering by (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field.
3307    ///
3308    /// For example, to filter for instances that do not have a name of example-instance, you would use filter=name ne example-instance.
3309    ///
3310    /// Compute Engine Beta API Only: When filtering in the Beta API, you can also filter on nested fields. For example, you could filter on instances that have set the scheduling.automaticRestart field to true. Use filtering on nested fields to take advantage of labels to organize and search for results based on label values.
3311    ///
3312    /// The Beta API also supports filtering on multiple expressions by providing each separate expression within parentheses. For example, (scheduling.automaticRestart eq true) (zone eq us-central1-f). Multiple expressions are treated as AND expressions, meaning that resources must match all expressions to pass the filters.
3313    ///
3314    /// Sets the *filter* query property to the given value.
3315    pub fn filter(mut self, new_value: &str) -> OperationListCall<'a, C> {
3316        self._filter = Some(new_value.to_string());
3317        self
3318    }
3319    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3320    /// while executing the actual API request.
3321    ///
3322    /// ````text
3323    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3324    /// ````
3325    ///
3326    /// Sets the *delegate* property to the given value.
3327    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationListCall<'a, C> {
3328        self._delegate = Some(new_value);
3329        self
3330    }
3331
3332    /// Set any additional parameter of the query string used in the request.
3333    /// It should be used to set parameters which are not yet available through their own
3334    /// setters.
3335    ///
3336    /// Please note that this method must not be used to set any of the known parameters
3337    /// which have their own setter method. If done anyway, the request will fail.
3338    ///
3339    /// # Additional Parameters
3340    ///
3341    /// * *alt* (query-string) - Data format for the response.
3342    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3343    /// * *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.
3344    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3345    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3346    /// * *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.
3347    /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
3348    pub fn param<T>(mut self, name: T, value: T) -> OperationListCall<'a, C>
3349    where
3350        T: AsRef<str>,
3351    {
3352        self._additional_params
3353            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3354        self
3355    }
3356
3357    /// Identifies the authorization scope for the method you are building.
3358    ///
3359    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3360    /// [`Scope::NdevCloudmanReadonly`].
3361    ///
3362    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3363    /// tokens for more than one scope.
3364    ///
3365    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3366    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3367    /// sufficient, a read-write scope will do as well.
3368    pub fn add_scope<St>(mut self, scope: St) -> OperationListCall<'a, C>
3369    where
3370        St: AsRef<str>,
3371    {
3372        self._scopes.insert(String::from(scope.as_ref()));
3373        self
3374    }
3375    /// Identifies the authorization scope(s) for the method you are building.
3376    ///
3377    /// See [`Self::add_scope()`] for details.
3378    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationListCall<'a, C>
3379    where
3380        I: IntoIterator<Item = St>,
3381        St: AsRef<str>,
3382    {
3383        self._scopes
3384            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3385        self
3386    }
3387
3388    /// Removes all scopes, and no default scope will be used either.
3389    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3390    /// for details).
3391    pub fn clear_scopes(mut self) -> OperationListCall<'a, C> {
3392        self._scopes.clear();
3393        self
3394    }
3395}