google_iamcredentials1/
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    /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17    CloudPlatform,
18}
19
20impl AsRef<str> for Scope {
21    fn as_ref(&self) -> &str {
22        match *self {
23            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
24        }
25    }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30    fn default() -> Scope {
31        Scope::CloudPlatform
32    }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all IAMCredentials related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_iamcredentials1 as iamcredentials1;
49/// use iamcredentials1::api::GenerateIdTokenRequest;
50/// use iamcredentials1::{Result, Error};
51/// # async fn dox() {
52/// use iamcredentials1::{IAMCredentials, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace  `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
63///     .with_native_roots()
64///     .unwrap()
65///     .https_only()
66///     .enable_http2()
67///     .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71///     secret,
72///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73///     yup_oauth2::client::CustomHyperClientBuilder::from(
74///         hyper_util::client::legacy::Client::builder(executor).build(connector),
75///     ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79///     hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82///     hyper_rustls::HttpsConnectorBuilder::new()
83///         .with_native_roots()
84///         .unwrap()
85///         .https_or_http()
86///         .enable_http2()
87///         .build()
88/// );
89/// let mut hub = IAMCredentials::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = GenerateIdTokenRequest::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.projects().service_accounts_generate_id_token(req, "name")
99///              .doit().await;
100///
101/// match result {
102///     Err(e) => match e {
103///         // The Error enum provides details about what exactly happened.
104///         // You can also just use its `Debug`, `Display` or `Error` traits
105///          Error::HttpError(_)
106///         |Error::Io(_)
107///         |Error::MissingAPIKey
108///         |Error::MissingToken(_)
109///         |Error::Cancelled
110///         |Error::UploadSizeLimitExceeded(_, _)
111///         |Error::Failure(_)
112///         |Error::BadRequest(_)
113///         |Error::FieldClash(_)
114///         |Error::JsonDecodeError(_, _) => println!("{}", e),
115///     },
116///     Ok(res) => println!("Success: {:?}", res),
117/// }
118/// # }
119/// ```
120#[derive(Clone)]
121pub struct IAMCredentials<C> {
122    pub client: common::Client<C>,
123    pub auth: Box<dyn common::GetToken>,
124    _user_agent: String,
125    _base_url: String,
126    _root_url: String,
127}
128
129impl<C> common::Hub for IAMCredentials<C> {}
130
131impl<'a, C> IAMCredentials<C> {
132    pub fn new<A: 'static + common::GetToken>(
133        client: common::Client<C>,
134        auth: A,
135    ) -> IAMCredentials<C> {
136        IAMCredentials {
137            client,
138            auth: Box::new(auth),
139            _user_agent: "google-api-rust-client/7.0.0".to_string(),
140            _base_url: "https://iamcredentials.googleapis.com/".to_string(),
141            _root_url: "https://iamcredentials.googleapis.com/".to_string(),
142        }
143    }
144
145    pub fn locations(&'a self) -> LocationMethods<'a, C> {
146        LocationMethods { hub: self }
147    }
148    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
149        ProjectMethods { hub: self }
150    }
151
152    /// Set the user-agent header field to use in all requests to the server.
153    /// It defaults to `google-api-rust-client/7.0.0`.
154    ///
155    /// Returns the previously set user-agent.
156    pub fn user_agent(&mut self, agent_name: String) -> String {
157        std::mem::replace(&mut self._user_agent, agent_name)
158    }
159
160    /// Set the base url to use in all requests to the server.
161    /// It defaults to `https://iamcredentials.googleapis.com/`.
162    ///
163    /// Returns the previously set base url.
164    pub fn base_url(&mut self, new_base_url: String) -> String {
165        std::mem::replace(&mut self._base_url, new_base_url)
166    }
167
168    /// Set the root url to use in all requests to the server.
169    /// It defaults to `https://iamcredentials.googleapis.com/`.
170    ///
171    /// Returns the previously set root url.
172    pub fn root_url(&mut self, new_root_url: String) -> String {
173        std::mem::replace(&mut self._root_url, new_root_url)
174    }
175}
176
177// ############
178// SCHEMAS ###
179// ##########
180/// There is no detailed description.
181///
182/// # Activities
183///
184/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
185/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
186///
187/// * [service accounts generate access token projects](ProjectServiceAccountGenerateAccessTokenCall) (request)
188#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
189#[serde_with::serde_as]
190#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
191pub struct GenerateAccessTokenRequest {
192    /// The sequence of service accounts in a delegation chain. This field is required for [delegated requests](https://cloud.google.com/iam/help/credentials/delegated-request). For [direct requests](https://cloud.google.com/iam/help/credentials/direct-request), which are more common, do not specify this field. Each service account must be granted the `roles/iam.serviceAccountTokenCreator` role on its next service account in the chain. The last service account in the chain must be granted the `roles/iam.serviceAccountTokenCreator` role on the service account that is specified in the `name` field of the request. The delegates must have the following format: `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is required; replacing it with a project ID is invalid.
193    pub delegates: Option<Vec<String>>,
194    /// The desired lifetime duration of the access token in seconds. By default, the maximum allowed value is 1 hour. To set a lifetime of up to 12 hours, you can add the service account as an allowed value in an Organization Policy that enforces the `constraints/iam.allowServiceAccountCredentialLifetimeExtension` constraint. See detailed instructions at https://cloud.google.com/iam/help/credentials/lifetime If a value is not specified, the token's lifetime will be set to a default value of 1 hour.
195    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
196    pub lifetime: Option<chrono::Duration>,
197    /// Required. Code to identify the scopes to be included in the OAuth 2.0 access token. See https://developers.google.com/identity/protocols/googlescopes for more information. At least one value required.
198    pub scope: Option<Vec<String>>,
199}
200
201impl common::RequestValue for GenerateAccessTokenRequest {}
202
203/// There is no detailed description.
204///
205/// # Activities
206///
207/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
208/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
209///
210/// * [service accounts generate access token projects](ProjectServiceAccountGenerateAccessTokenCall) (response)
211#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
212#[serde_with::serde_as]
213#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
214pub struct GenerateAccessTokenResponse {
215    /// The OAuth 2.0 access token.
216    #[serde(rename = "accessToken")]
217    pub access_token: Option<String>,
218    /// Token expiration time. The expiration time is always set.
219    #[serde(rename = "expireTime")]
220    pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
221}
222
223impl common::ResponseResult for GenerateAccessTokenResponse {}
224
225/// There is no detailed description.
226///
227/// # Activities
228///
229/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
230/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
231///
232/// * [service accounts generate id token projects](ProjectServiceAccountGenerateIdTokenCall) (request)
233#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
234#[serde_with::serde_as]
235#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
236pub struct GenerateIdTokenRequest {
237    /// Required. The audience for the token, such as the API or account that this token grants access to.
238    pub audience: Option<String>,
239    /// The sequence of service accounts in a delegation chain. Each service account must be granted the `roles/iam.serviceAccountTokenCreator` role on its next service account in the chain. The last service account in the chain must be granted the `roles/iam.serviceAccountTokenCreator` role on the service account that is specified in the `name` field of the request. The delegates must have the following format: `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is required; replacing it with a project ID is invalid.
240    pub delegates: Option<Vec<String>>,
241    /// Include the service account email in the token. If set to `true`, the token will contain `email` and `email_verified` claims.
242    #[serde(rename = "includeEmail")]
243    pub include_email: Option<bool>,
244    /// Include the organization number of the service account in the token. If set to `true`, the token will contain a `google.organization_number` claim. The value of the claim will be `null` if the service account isn't associated with an organization.
245    #[serde(rename = "organizationNumberIncluded")]
246    pub organization_number_included: Option<bool>,
247}
248
249impl common::RequestValue for GenerateIdTokenRequest {}
250
251/// There is no detailed description.
252///
253/// # Activities
254///
255/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
256/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
257///
258/// * [service accounts generate id token projects](ProjectServiceAccountGenerateIdTokenCall) (response)
259#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
260#[serde_with::serde_as]
261#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
262pub struct GenerateIdTokenResponse {
263    /// The OpenId Connect ID token. The token is a JSON Web Token (JWT) that contains a payload with claims. See the [JSON Web Token spec](https://tools.ietf.org/html/rfc7519) for more information. Here is an example of a decoded JWT payload: ``` { "iss": "https://accounts.google.com", "iat": 1496953245, "exp": 1496953245, "aud": "https://www.example.com", "sub": "107517467455664443765", "azp": "107517467455664443765", "email": "my-iam-account@my-project.iam.gserviceaccount.com", "email_verified": true, "google": { "organization_number": 123456 } } ```
264    pub token: Option<String>,
265}
266
267impl common::ResponseResult for GenerateIdTokenResponse {}
268
269/// Represents a list of allowed locations for given service account.
270///
271/// # Activities
272///
273/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
274/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
275///
276/// * [service accounts get allowed locations projects](ProjectServiceAccountGetAllowedLocationCall) (response)
277#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
278#[serde_with::serde_as]
279#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
280pub struct ServiceAccountAllowedLocations {
281    /// Output only. The hex encoded bitmap of the trust boundary locations
282    #[serde(rename = "encodedLocations")]
283    pub encoded_locations: Option<String>,
284    /// Output only. The human readable trust boundary locations. For example, ["us-central1", "europe-west1"]
285    pub locations: Option<Vec<String>>,
286}
287
288impl common::ResponseResult for ServiceAccountAllowedLocations {}
289
290/// There is no detailed description.
291///
292/// # Activities
293///
294/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
295/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
296///
297/// * [service accounts sign blob projects](ProjectServiceAccountSignBlobCall) (request)
298#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
299#[serde_with::serde_as]
300#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
301pub struct SignBlobRequest {
302    /// The sequence of service accounts in a delegation chain. Each service account must be granted the `roles/iam.serviceAccountTokenCreator` role on its next service account in the chain. The last service account in the chain must be granted the `roles/iam.serviceAccountTokenCreator` role on the service account that is specified in the `name` field of the request. The delegates must have the following format: `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is required; replacing it with a project ID is invalid.
303    pub delegates: Option<Vec<String>>,
304    /// Required. The bytes to sign.
305    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
306    pub payload: Option<Vec<u8>>,
307}
308
309impl common::RequestValue for SignBlobRequest {}
310
311/// There is no detailed description.
312///
313/// # Activities
314///
315/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
316/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
317///
318/// * [service accounts sign blob projects](ProjectServiceAccountSignBlobCall) (response)
319#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
320#[serde_with::serde_as]
321#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
322pub struct SignBlobResponse {
323    /// The ID of the key used to sign the blob. The key used for signing will remain valid for at least 12 hours after the blob is signed. To verify the signature, you can retrieve the public key in several formats from the following endpoints: - RSA public key wrapped in an X.509 v3 certificate: `https://www.googleapis.com/service_accounts/v1/metadata/x509/{ACCOUNT_EMAIL}` - Raw key in JSON format: `https://www.googleapis.com/service_accounts/v1/metadata/raw/{ACCOUNT_EMAIL}` - JSON Web Key (JWK): `https://www.googleapis.com/service_accounts/v1/metadata/jwk/{ACCOUNT_EMAIL}`
324    #[serde(rename = "keyId")]
325    pub key_id: Option<String>,
326    /// The signature for the blob. Does not include the original blob. After the key pair referenced by the `key_id` response field expires, Google no longer exposes the public key that can be used to verify the blob. As a result, the receiver can no longer verify the signature.
327    #[serde(rename = "signedBlob")]
328    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
329    pub signed_blob: Option<Vec<u8>>,
330}
331
332impl common::ResponseResult for SignBlobResponse {}
333
334/// There is no detailed description.
335///
336/// # Activities
337///
338/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
339/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
340///
341/// * [service accounts sign jwt projects](ProjectServiceAccountSignJwtCall) (request)
342#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
343#[serde_with::serde_as]
344#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
345pub struct SignJwtRequest {
346    /// The sequence of service accounts in a delegation chain. Each service account must be granted the `roles/iam.serviceAccountTokenCreator` role on its next service account in the chain. The last service account in the chain must be granted the `roles/iam.serviceAccountTokenCreator` role on the service account that is specified in the `name` field of the request. The delegates must have the following format: `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is required; replacing it with a project ID is invalid.
347    pub delegates: Option<Vec<String>>,
348    /// Required. The JWT payload to sign. Must be a serialized JSON object that contains a JWT Claims Set. For example: `{"sub": "user@example.com", "iat": 313435}` If the JWT Claims Set contains an expiration time (`exp`) claim, it must be an integer timestamp that is not in the past and no more than 12 hours in the future.
349    pub payload: Option<String>,
350}
351
352impl common::RequestValue for SignJwtRequest {}
353
354/// There is no detailed description.
355///
356/// # Activities
357///
358/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
359/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
360///
361/// * [service accounts sign jwt projects](ProjectServiceAccountSignJwtCall) (response)
362#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
363#[serde_with::serde_as]
364#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
365pub struct SignJwtResponse {
366    /// The ID of the key used to sign the JWT. The key used for signing will remain valid for at least 12 hours after the JWT is signed. To verify the signature, you can retrieve the public key in several formats from the following endpoints: - RSA public key wrapped in an X.509 v3 certificate: `https://www.googleapis.com/service_accounts/v1/metadata/x509/{ACCOUNT_EMAIL}` - Raw key in JSON format: `https://www.googleapis.com/service_accounts/v1/metadata/raw/{ACCOUNT_EMAIL}` - JSON Web Key (JWK): `https://www.googleapis.com/service_accounts/v1/metadata/jwk/{ACCOUNT_EMAIL}`
367    #[serde(rename = "keyId")]
368    pub key_id: Option<String>,
369    /// The signed JWT. Contains the automatically generated header; the client-supplied payload; and the signature, which is generated using the key referenced by the `kid` field in the header. After the key pair referenced by the `key_id` response field expires, Google no longer exposes the public key that can be used to verify the JWT. As a result, the receiver can no longer verify the signature.
370    #[serde(rename = "signedJwt")]
371    pub signed_jwt: Option<String>,
372}
373
374impl common::ResponseResult for SignJwtResponse {}
375
376/// Represents a list of allowed locations for given workforce pool.
377///
378/// # Activities
379///
380/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
381/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
382///
383/// * [workforce pools get allowed locations locations](LocationWorkforcePoolGetAllowedLocationCall) (response)
384#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
385#[serde_with::serde_as]
386#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
387pub struct WorkforcePoolAllowedLocations {
388    /// Output only. The hex encoded bitmap of the trust boundary locations
389    #[serde(rename = "encodedLocations")]
390    pub encoded_locations: Option<String>,
391    /// Output only. The human readable trust boundary locations. For example, ["us-central1", "europe-west1"]
392    pub locations: Option<Vec<String>>,
393}
394
395impl common::ResponseResult for WorkforcePoolAllowedLocations {}
396
397/// Represents a list of allowed locations for given workload identity pool.
398///
399/// # Activities
400///
401/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
402/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
403///
404/// * [locations workload identity pools get allowed locations projects](ProjectLocationWorkloadIdentityPoolGetAllowedLocationCall) (response)
405#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
406#[serde_with::serde_as]
407#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
408pub struct WorkloadIdentityPoolAllowedLocations {
409    /// Output only. The hex encoded bitmap of the trust boundary locations
410    #[serde(rename = "encodedLocations")]
411    pub encoded_locations: Option<String>,
412    /// Output only. The human readable trust boundary locations. For example, ["us-central1", "europe-west1"]
413    pub locations: Option<Vec<String>>,
414}
415
416impl common::ResponseResult for WorkloadIdentityPoolAllowedLocations {}
417
418// ###################
419// MethodBuilders ###
420// #################
421
422/// A builder providing access to all methods supported on *location* resources.
423/// It is not used directly, but through the [`IAMCredentials`] hub.
424///
425/// # Example
426///
427/// Instantiate a resource builder
428///
429/// ```test_harness,no_run
430/// extern crate hyper;
431/// extern crate hyper_rustls;
432/// extern crate google_iamcredentials1 as iamcredentials1;
433///
434/// # async fn dox() {
435/// use iamcredentials1::{IAMCredentials, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
436///
437/// let secret: yup_oauth2::ApplicationSecret = Default::default();
438/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
439///     .with_native_roots()
440///     .unwrap()
441///     .https_only()
442///     .enable_http2()
443///     .build();
444///
445/// let executor = hyper_util::rt::TokioExecutor::new();
446/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
447///     secret,
448///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
449///     yup_oauth2::client::CustomHyperClientBuilder::from(
450///         hyper_util::client::legacy::Client::builder(executor).build(connector),
451///     ),
452/// ).build().await.unwrap();
453///
454/// let client = hyper_util::client::legacy::Client::builder(
455///     hyper_util::rt::TokioExecutor::new()
456/// )
457/// .build(
458///     hyper_rustls::HttpsConnectorBuilder::new()
459///         .with_native_roots()
460///         .unwrap()
461///         .https_or_http()
462///         .enable_http2()
463///         .build()
464/// );
465/// let mut hub = IAMCredentials::new(client, auth);
466/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
467/// // like `workforce_pools_get_allowed_locations(...)`
468/// // to build up your call.
469/// let rb = hub.locations();
470/// # }
471/// ```
472pub struct LocationMethods<'a, C>
473where
474    C: 'a,
475{
476    hub: &'a IAMCredentials<C>,
477}
478
479impl<'a, C> common::MethodsBuilder for LocationMethods<'a, C> {}
480
481impl<'a, C> LocationMethods<'a, C> {
482    /// Create a builder to help you perform the following task:
483    ///
484    /// Returns the trust boundary info for a given workforce pool.
485    ///
486    /// # Arguments
487    ///
488    /// * `name` - Required. Resource name of workforce pool.
489    pub fn workforce_pools_get_allowed_locations(
490        &self,
491        name: &str,
492    ) -> LocationWorkforcePoolGetAllowedLocationCall<'a, C> {
493        LocationWorkforcePoolGetAllowedLocationCall {
494            hub: self.hub,
495            _name: name.to_string(),
496            _delegate: Default::default(),
497            _additional_params: Default::default(),
498        }
499    }
500}
501
502/// A builder providing access to all methods supported on *project* resources.
503/// It is not used directly, but through the [`IAMCredentials`] hub.
504///
505/// # Example
506///
507/// Instantiate a resource builder
508///
509/// ```test_harness,no_run
510/// extern crate hyper;
511/// extern crate hyper_rustls;
512/// extern crate google_iamcredentials1 as iamcredentials1;
513///
514/// # async fn dox() {
515/// use iamcredentials1::{IAMCredentials, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
516///
517/// let secret: yup_oauth2::ApplicationSecret = Default::default();
518/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
519///     .with_native_roots()
520///     .unwrap()
521///     .https_only()
522///     .enable_http2()
523///     .build();
524///
525/// let executor = hyper_util::rt::TokioExecutor::new();
526/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
527///     secret,
528///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
529///     yup_oauth2::client::CustomHyperClientBuilder::from(
530///         hyper_util::client::legacy::Client::builder(executor).build(connector),
531///     ),
532/// ).build().await.unwrap();
533///
534/// let client = hyper_util::client::legacy::Client::builder(
535///     hyper_util::rt::TokioExecutor::new()
536/// )
537/// .build(
538///     hyper_rustls::HttpsConnectorBuilder::new()
539///         .with_native_roots()
540///         .unwrap()
541///         .https_or_http()
542///         .enable_http2()
543///         .build()
544/// );
545/// let mut hub = IAMCredentials::new(client, auth);
546/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
547/// // like `locations_workload_identity_pools_get_allowed_locations(...)`, `service_accounts_generate_access_token(...)`, `service_accounts_generate_id_token(...)`, `service_accounts_get_allowed_locations(...)`, `service_accounts_sign_blob(...)` and `service_accounts_sign_jwt(...)`
548/// // to build up your call.
549/// let rb = hub.projects();
550/// # }
551/// ```
552pub struct ProjectMethods<'a, C>
553where
554    C: 'a,
555{
556    hub: &'a IAMCredentials<C>,
557}
558
559impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
560
561impl<'a, C> ProjectMethods<'a, C> {
562    /// Create a builder to help you perform the following task:
563    ///
564    /// Returns the trust boundary info for a given workload identity pool.
565    ///
566    /// # Arguments
567    ///
568    /// * `name` - Required. Resource name of workload identity pool.
569    pub fn locations_workload_identity_pools_get_allowed_locations(
570        &self,
571        name: &str,
572    ) -> ProjectLocationWorkloadIdentityPoolGetAllowedLocationCall<'a, C> {
573        ProjectLocationWorkloadIdentityPoolGetAllowedLocationCall {
574            hub: self.hub,
575            _name: name.to_string(),
576            _delegate: Default::default(),
577            _additional_params: Default::default(),
578        }
579    }
580
581    /// Create a builder to help you perform the following task:
582    ///
583    /// Generates an OAuth 2.0 access token for a service account.
584    ///
585    /// # Arguments
586    ///
587    /// * `request` - No description provided.
588    /// * `name` - Required. The resource name of the service account for which the credentials are requested, in the following format: `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is required; replacing it with a project ID is invalid.
589    pub fn service_accounts_generate_access_token(
590        &self,
591        request: GenerateAccessTokenRequest,
592        name: &str,
593    ) -> ProjectServiceAccountGenerateAccessTokenCall<'a, C> {
594        ProjectServiceAccountGenerateAccessTokenCall {
595            hub: self.hub,
596            _request: request,
597            _name: name.to_string(),
598            _delegate: Default::default(),
599            _additional_params: Default::default(),
600            _scopes: Default::default(),
601        }
602    }
603
604    /// Create a builder to help you perform the following task:
605    ///
606    /// Generates an OpenID Connect ID token for a service account.
607    ///
608    /// # Arguments
609    ///
610    /// * `request` - No description provided.
611    /// * `name` - Required. The resource name of the service account for which the credentials are requested, in the following format: `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is required; replacing it with a project ID is invalid.
612    pub fn service_accounts_generate_id_token(
613        &self,
614        request: GenerateIdTokenRequest,
615        name: &str,
616    ) -> ProjectServiceAccountGenerateIdTokenCall<'a, C> {
617        ProjectServiceAccountGenerateIdTokenCall {
618            hub: self.hub,
619            _request: request,
620            _name: name.to_string(),
621            _delegate: Default::default(),
622            _additional_params: Default::default(),
623            _scopes: Default::default(),
624        }
625    }
626
627    /// Create a builder to help you perform the following task:
628    ///
629    /// Returns the trust boundary info for a given service account.
630    ///
631    /// # Arguments
632    ///
633    /// * `name` - Required. Resource name of service account.
634    pub fn service_accounts_get_allowed_locations(
635        &self,
636        name: &str,
637    ) -> ProjectServiceAccountGetAllowedLocationCall<'a, C> {
638        ProjectServiceAccountGetAllowedLocationCall {
639            hub: self.hub,
640            _name: name.to_string(),
641            _delegate: Default::default(),
642            _additional_params: Default::default(),
643        }
644    }
645
646    /// Create a builder to help you perform the following task:
647    ///
648    /// Signs a blob using a service account's system-managed private key.
649    ///
650    /// # Arguments
651    ///
652    /// * `request` - No description provided.
653    /// * `name` - Required. The resource name of the service account for which the credentials are requested, in the following format: `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is required; replacing it with a project ID is invalid.
654    pub fn service_accounts_sign_blob(
655        &self,
656        request: SignBlobRequest,
657        name: &str,
658    ) -> ProjectServiceAccountSignBlobCall<'a, C> {
659        ProjectServiceAccountSignBlobCall {
660            hub: self.hub,
661            _request: request,
662            _name: name.to_string(),
663            _delegate: Default::default(),
664            _additional_params: Default::default(),
665            _scopes: Default::default(),
666        }
667    }
668
669    /// Create a builder to help you perform the following task:
670    ///
671    /// Signs a JWT using a service account's system-managed private key.
672    ///
673    /// # Arguments
674    ///
675    /// * `request` - No description provided.
676    /// * `name` - Required. The resource name of the service account for which the credentials are requested, in the following format: `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is required; replacing it with a project ID is invalid.
677    pub fn service_accounts_sign_jwt(
678        &self,
679        request: SignJwtRequest,
680        name: &str,
681    ) -> ProjectServiceAccountSignJwtCall<'a, C> {
682        ProjectServiceAccountSignJwtCall {
683            hub: self.hub,
684            _request: request,
685            _name: name.to_string(),
686            _delegate: Default::default(),
687            _additional_params: Default::default(),
688            _scopes: Default::default(),
689        }
690    }
691}
692
693// ###################
694// CallBuilders   ###
695// #################
696
697/// Returns the trust boundary info for a given workforce pool.
698///
699/// A builder for the *workforcePools.getAllowedLocations* method supported by a *location* resource.
700/// It is not used directly, but through a [`LocationMethods`] instance.
701///
702/// # Example
703///
704/// Instantiate a resource method builder
705///
706/// ```test_harness,no_run
707/// # extern crate hyper;
708/// # extern crate hyper_rustls;
709/// # extern crate google_iamcredentials1 as iamcredentials1;
710/// # async fn dox() {
711/// # use iamcredentials1::{IAMCredentials, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
712///
713/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
714/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
715/// #     .with_native_roots()
716/// #     .unwrap()
717/// #     .https_only()
718/// #     .enable_http2()
719/// #     .build();
720///
721/// # let executor = hyper_util::rt::TokioExecutor::new();
722/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
723/// #     secret,
724/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
725/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
726/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
727/// #     ),
728/// # ).build().await.unwrap();
729///
730/// # let client = hyper_util::client::legacy::Client::builder(
731/// #     hyper_util::rt::TokioExecutor::new()
732/// # )
733/// # .build(
734/// #     hyper_rustls::HttpsConnectorBuilder::new()
735/// #         .with_native_roots()
736/// #         .unwrap()
737/// #         .https_or_http()
738/// #         .enable_http2()
739/// #         .build()
740/// # );
741/// # let mut hub = IAMCredentials::new(client, auth);
742/// // You can configure optional parameters by calling the respective setters at will, and
743/// // execute the final call using `doit()`.
744/// // Values shown here are possibly random and not representative !
745/// let result = hub.locations().workforce_pools_get_allowed_locations("name")
746///              .doit().await;
747/// # }
748/// ```
749pub struct LocationWorkforcePoolGetAllowedLocationCall<'a, C>
750where
751    C: 'a,
752{
753    hub: &'a IAMCredentials<C>,
754    _name: String,
755    _delegate: Option<&'a mut dyn common::Delegate>,
756    _additional_params: HashMap<String, String>,
757}
758
759impl<'a, C> common::CallBuilder for LocationWorkforcePoolGetAllowedLocationCall<'a, C> {}
760
761impl<'a, C> LocationWorkforcePoolGetAllowedLocationCall<'a, C>
762where
763    C: common::Connector,
764{
765    /// Perform the operation you have build so far.
766    pub async fn doit(
767        mut self,
768    ) -> common::Result<(common::Response, WorkforcePoolAllowedLocations)> {
769        use std::borrow::Cow;
770        use std::io::{Read, Seek};
771
772        use common::{url::Params, ToParts};
773        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
774
775        let mut dd = common::DefaultDelegate;
776        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
777        dlg.begin(common::MethodInfo {
778            id: "iamcredentials.locations.workforcePools.getAllowedLocations",
779            http_method: hyper::Method::GET,
780        });
781
782        for &field in ["alt", "name"].iter() {
783            if self._additional_params.contains_key(field) {
784                dlg.finished(false);
785                return Err(common::Error::FieldClash(field));
786            }
787        }
788
789        let mut params = Params::with_capacity(3 + self._additional_params.len());
790        params.push("name", self._name);
791
792        params.extend(self._additional_params.iter());
793
794        params.push("alt", "json");
795        let mut url = self.hub._base_url.clone() + "v1/{+name}/allowedLocations";
796
797        match dlg.api_key() {
798            Some(value) => params.push("key", value),
799            None => {
800                dlg.finished(false);
801                return Err(common::Error::MissingAPIKey);
802            }
803        }
804
805        #[allow(clippy::single_element_loop)]
806        for &(find_this, param_name) in [("{+name}", "name")].iter() {
807            url = params.uri_replacement(url, param_name, find_this, true);
808        }
809        {
810            let to_remove = ["name"];
811            params.remove_params(&to_remove);
812        }
813
814        let url = params.parse_with_url(&url);
815
816        loop {
817            let mut req_result = {
818                let client = &self.hub.client;
819                dlg.pre_request();
820                let mut req_builder = hyper::Request::builder()
821                    .method(hyper::Method::GET)
822                    .uri(url.as_str())
823                    .header(USER_AGENT, self.hub._user_agent.clone());
824
825                let request = req_builder
826                    .header(CONTENT_LENGTH, 0_u64)
827                    .body(common::to_body::<String>(None));
828
829                client.request(request.unwrap()).await
830            };
831
832            match req_result {
833                Err(err) => {
834                    if let common::Retry::After(d) = dlg.http_error(&err) {
835                        sleep(d).await;
836                        continue;
837                    }
838                    dlg.finished(false);
839                    return Err(common::Error::HttpError(err));
840                }
841                Ok(res) => {
842                    let (mut parts, body) = res.into_parts();
843                    let mut body = common::Body::new(body);
844                    if !parts.status.is_success() {
845                        let bytes = common::to_bytes(body).await.unwrap_or_default();
846                        let error = serde_json::from_str(&common::to_string(&bytes));
847                        let response = common::to_response(parts, bytes.into());
848
849                        if let common::Retry::After(d) =
850                            dlg.http_failure(&response, error.as_ref().ok())
851                        {
852                            sleep(d).await;
853                            continue;
854                        }
855
856                        dlg.finished(false);
857
858                        return Err(match error {
859                            Ok(value) => common::Error::BadRequest(value),
860                            _ => common::Error::Failure(response),
861                        });
862                    }
863                    let response = {
864                        let bytes = common::to_bytes(body).await.unwrap_or_default();
865                        let encoded = common::to_string(&bytes);
866                        match serde_json::from_str(&encoded) {
867                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
868                            Err(error) => {
869                                dlg.response_json_decode_error(&encoded, &error);
870                                return Err(common::Error::JsonDecodeError(
871                                    encoded.to_string(),
872                                    error,
873                                ));
874                            }
875                        }
876                    };
877
878                    dlg.finished(true);
879                    return Ok(response);
880                }
881            }
882        }
883    }
884
885    /// Required. Resource name of workforce pool.
886    ///
887    /// Sets the *name* path property to the given value.
888    ///
889    /// Even though the property as already been set when instantiating this call,
890    /// we provide this method for API completeness.
891    pub fn name(mut self, new_value: &str) -> LocationWorkforcePoolGetAllowedLocationCall<'a, C> {
892        self._name = new_value.to_string();
893        self
894    }
895    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
896    /// while executing the actual API request.
897    ///
898    /// ````text
899    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
900    /// ````
901    ///
902    /// Sets the *delegate* property to the given value.
903    pub fn delegate(
904        mut self,
905        new_value: &'a mut dyn common::Delegate,
906    ) -> LocationWorkforcePoolGetAllowedLocationCall<'a, C> {
907        self._delegate = Some(new_value);
908        self
909    }
910
911    /// Set any additional parameter of the query string used in the request.
912    /// It should be used to set parameters which are not yet available through their own
913    /// setters.
914    ///
915    /// Please note that this method must not be used to set any of the known parameters
916    /// which have their own setter method. If done anyway, the request will fail.
917    ///
918    /// # Additional Parameters
919    ///
920    /// * *$.xgafv* (query-string) - V1 error format.
921    /// * *access_token* (query-string) - OAuth access token.
922    /// * *alt* (query-string) - Data format for response.
923    /// * *callback* (query-string) - JSONP
924    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
925    /// * *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.
926    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
927    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
928    /// * *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.
929    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
930    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
931    pub fn param<T>(
932        mut self,
933        name: T,
934        value: T,
935    ) -> LocationWorkforcePoolGetAllowedLocationCall<'a, C>
936    where
937        T: AsRef<str>,
938    {
939        self._additional_params
940            .insert(name.as_ref().to_string(), value.as_ref().to_string());
941        self
942    }
943}
944
945/// Returns the trust boundary info for a given workload identity pool.
946///
947/// A builder for the *locations.workloadIdentityPools.getAllowedLocations* method supported by a *project* resource.
948/// It is not used directly, but through a [`ProjectMethods`] instance.
949///
950/// # Example
951///
952/// Instantiate a resource method builder
953///
954/// ```test_harness,no_run
955/// # extern crate hyper;
956/// # extern crate hyper_rustls;
957/// # extern crate google_iamcredentials1 as iamcredentials1;
958/// # async fn dox() {
959/// # use iamcredentials1::{IAMCredentials, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
960///
961/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
962/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
963/// #     .with_native_roots()
964/// #     .unwrap()
965/// #     .https_only()
966/// #     .enable_http2()
967/// #     .build();
968///
969/// # let executor = hyper_util::rt::TokioExecutor::new();
970/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
971/// #     secret,
972/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
973/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
974/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
975/// #     ),
976/// # ).build().await.unwrap();
977///
978/// # let client = hyper_util::client::legacy::Client::builder(
979/// #     hyper_util::rt::TokioExecutor::new()
980/// # )
981/// # .build(
982/// #     hyper_rustls::HttpsConnectorBuilder::new()
983/// #         .with_native_roots()
984/// #         .unwrap()
985/// #         .https_or_http()
986/// #         .enable_http2()
987/// #         .build()
988/// # );
989/// # let mut hub = IAMCredentials::new(client, auth);
990/// // You can configure optional parameters by calling the respective setters at will, and
991/// // execute the final call using `doit()`.
992/// // Values shown here are possibly random and not representative !
993/// let result = hub.projects().locations_workload_identity_pools_get_allowed_locations("name")
994///              .doit().await;
995/// # }
996/// ```
997pub struct ProjectLocationWorkloadIdentityPoolGetAllowedLocationCall<'a, C>
998where
999    C: 'a,
1000{
1001    hub: &'a IAMCredentials<C>,
1002    _name: String,
1003    _delegate: Option<&'a mut dyn common::Delegate>,
1004    _additional_params: HashMap<String, String>,
1005}
1006
1007impl<'a, C> common::CallBuilder
1008    for ProjectLocationWorkloadIdentityPoolGetAllowedLocationCall<'a, C>
1009{
1010}
1011
1012impl<'a, C> ProjectLocationWorkloadIdentityPoolGetAllowedLocationCall<'a, C>
1013where
1014    C: common::Connector,
1015{
1016    /// Perform the operation you have build so far.
1017    pub async fn doit(
1018        mut self,
1019    ) -> common::Result<(common::Response, WorkloadIdentityPoolAllowedLocations)> {
1020        use std::borrow::Cow;
1021        use std::io::{Read, Seek};
1022
1023        use common::{url::Params, ToParts};
1024        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1025
1026        let mut dd = common::DefaultDelegate;
1027        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1028        dlg.begin(common::MethodInfo {
1029            id: "iamcredentials.projects.locations.workloadIdentityPools.getAllowedLocations",
1030            http_method: hyper::Method::GET,
1031        });
1032
1033        for &field in ["alt", "name"].iter() {
1034            if self._additional_params.contains_key(field) {
1035                dlg.finished(false);
1036                return Err(common::Error::FieldClash(field));
1037            }
1038        }
1039
1040        let mut params = Params::with_capacity(3 + self._additional_params.len());
1041        params.push("name", self._name);
1042
1043        params.extend(self._additional_params.iter());
1044
1045        params.push("alt", "json");
1046        let mut url = self.hub._base_url.clone() + "v1/{+name}/allowedLocations";
1047
1048        match dlg.api_key() {
1049            Some(value) => params.push("key", value),
1050            None => {
1051                dlg.finished(false);
1052                return Err(common::Error::MissingAPIKey);
1053            }
1054        }
1055
1056        #[allow(clippy::single_element_loop)]
1057        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1058            url = params.uri_replacement(url, param_name, find_this, true);
1059        }
1060        {
1061            let to_remove = ["name"];
1062            params.remove_params(&to_remove);
1063        }
1064
1065        let url = params.parse_with_url(&url);
1066
1067        loop {
1068            let mut req_result = {
1069                let client = &self.hub.client;
1070                dlg.pre_request();
1071                let mut req_builder = hyper::Request::builder()
1072                    .method(hyper::Method::GET)
1073                    .uri(url.as_str())
1074                    .header(USER_AGENT, self.hub._user_agent.clone());
1075
1076                let request = req_builder
1077                    .header(CONTENT_LENGTH, 0_u64)
1078                    .body(common::to_body::<String>(None));
1079
1080                client.request(request.unwrap()).await
1081            };
1082
1083            match req_result {
1084                Err(err) => {
1085                    if let common::Retry::After(d) = dlg.http_error(&err) {
1086                        sleep(d).await;
1087                        continue;
1088                    }
1089                    dlg.finished(false);
1090                    return Err(common::Error::HttpError(err));
1091                }
1092                Ok(res) => {
1093                    let (mut parts, body) = res.into_parts();
1094                    let mut body = common::Body::new(body);
1095                    if !parts.status.is_success() {
1096                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1097                        let error = serde_json::from_str(&common::to_string(&bytes));
1098                        let response = common::to_response(parts, bytes.into());
1099
1100                        if let common::Retry::After(d) =
1101                            dlg.http_failure(&response, error.as_ref().ok())
1102                        {
1103                            sleep(d).await;
1104                            continue;
1105                        }
1106
1107                        dlg.finished(false);
1108
1109                        return Err(match error {
1110                            Ok(value) => common::Error::BadRequest(value),
1111                            _ => common::Error::Failure(response),
1112                        });
1113                    }
1114                    let response = {
1115                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1116                        let encoded = common::to_string(&bytes);
1117                        match serde_json::from_str(&encoded) {
1118                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1119                            Err(error) => {
1120                                dlg.response_json_decode_error(&encoded, &error);
1121                                return Err(common::Error::JsonDecodeError(
1122                                    encoded.to_string(),
1123                                    error,
1124                                ));
1125                            }
1126                        }
1127                    };
1128
1129                    dlg.finished(true);
1130                    return Ok(response);
1131                }
1132            }
1133        }
1134    }
1135
1136    /// Required. Resource name of workload identity pool.
1137    ///
1138    /// Sets the *name* path property to the given value.
1139    ///
1140    /// Even though the property as already been set when instantiating this call,
1141    /// we provide this method for API completeness.
1142    pub fn name(
1143        mut self,
1144        new_value: &str,
1145    ) -> ProjectLocationWorkloadIdentityPoolGetAllowedLocationCall<'a, C> {
1146        self._name = new_value.to_string();
1147        self
1148    }
1149    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1150    /// while executing the actual API request.
1151    ///
1152    /// ````text
1153    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1154    /// ````
1155    ///
1156    /// Sets the *delegate* property to the given value.
1157    pub fn delegate(
1158        mut self,
1159        new_value: &'a mut dyn common::Delegate,
1160    ) -> ProjectLocationWorkloadIdentityPoolGetAllowedLocationCall<'a, C> {
1161        self._delegate = Some(new_value);
1162        self
1163    }
1164
1165    /// Set any additional parameter of the query string used in the request.
1166    /// It should be used to set parameters which are not yet available through their own
1167    /// setters.
1168    ///
1169    /// Please note that this method must not be used to set any of the known parameters
1170    /// which have their own setter method. If done anyway, the request will fail.
1171    ///
1172    /// # Additional Parameters
1173    ///
1174    /// * *$.xgafv* (query-string) - V1 error format.
1175    /// * *access_token* (query-string) - OAuth access token.
1176    /// * *alt* (query-string) - Data format for response.
1177    /// * *callback* (query-string) - JSONP
1178    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1179    /// * *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.
1180    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1181    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1182    /// * *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.
1183    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1184    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1185    pub fn param<T>(
1186        mut self,
1187        name: T,
1188        value: T,
1189    ) -> ProjectLocationWorkloadIdentityPoolGetAllowedLocationCall<'a, C>
1190    where
1191        T: AsRef<str>,
1192    {
1193        self._additional_params
1194            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1195        self
1196    }
1197}
1198
1199/// Generates an OAuth 2.0 access token for a service account.
1200///
1201/// A builder for the *serviceAccounts.generateAccessToken* method supported by a *project* resource.
1202/// It is not used directly, but through a [`ProjectMethods`] instance.
1203///
1204/// # Example
1205///
1206/// Instantiate a resource method builder
1207///
1208/// ```test_harness,no_run
1209/// # extern crate hyper;
1210/// # extern crate hyper_rustls;
1211/// # extern crate google_iamcredentials1 as iamcredentials1;
1212/// use iamcredentials1::api::GenerateAccessTokenRequest;
1213/// # async fn dox() {
1214/// # use iamcredentials1::{IAMCredentials, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1215///
1216/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1217/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1218/// #     .with_native_roots()
1219/// #     .unwrap()
1220/// #     .https_only()
1221/// #     .enable_http2()
1222/// #     .build();
1223///
1224/// # let executor = hyper_util::rt::TokioExecutor::new();
1225/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1226/// #     secret,
1227/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1228/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1229/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1230/// #     ),
1231/// # ).build().await.unwrap();
1232///
1233/// # let client = hyper_util::client::legacy::Client::builder(
1234/// #     hyper_util::rt::TokioExecutor::new()
1235/// # )
1236/// # .build(
1237/// #     hyper_rustls::HttpsConnectorBuilder::new()
1238/// #         .with_native_roots()
1239/// #         .unwrap()
1240/// #         .https_or_http()
1241/// #         .enable_http2()
1242/// #         .build()
1243/// # );
1244/// # let mut hub = IAMCredentials::new(client, auth);
1245/// // As the method needs a request, you would usually fill it with the desired information
1246/// // into the respective structure. Some of the parts shown here might not be applicable !
1247/// // Values shown here are possibly random and not representative !
1248/// let mut req = GenerateAccessTokenRequest::default();
1249///
1250/// // You can configure optional parameters by calling the respective setters at will, and
1251/// // execute the final call using `doit()`.
1252/// // Values shown here are possibly random and not representative !
1253/// let result = hub.projects().service_accounts_generate_access_token(req, "name")
1254///              .doit().await;
1255/// # }
1256/// ```
1257pub struct ProjectServiceAccountGenerateAccessTokenCall<'a, C>
1258where
1259    C: 'a,
1260{
1261    hub: &'a IAMCredentials<C>,
1262    _request: GenerateAccessTokenRequest,
1263    _name: String,
1264    _delegate: Option<&'a mut dyn common::Delegate>,
1265    _additional_params: HashMap<String, String>,
1266    _scopes: BTreeSet<String>,
1267}
1268
1269impl<'a, C> common::CallBuilder for ProjectServiceAccountGenerateAccessTokenCall<'a, C> {}
1270
1271impl<'a, C> ProjectServiceAccountGenerateAccessTokenCall<'a, C>
1272where
1273    C: common::Connector,
1274{
1275    /// Perform the operation you have build so far.
1276    pub async fn doit(mut self) -> common::Result<(common::Response, GenerateAccessTokenResponse)> {
1277        use std::borrow::Cow;
1278        use std::io::{Read, Seek};
1279
1280        use common::{url::Params, ToParts};
1281        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1282
1283        let mut dd = common::DefaultDelegate;
1284        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1285        dlg.begin(common::MethodInfo {
1286            id: "iamcredentials.projects.serviceAccounts.generateAccessToken",
1287            http_method: hyper::Method::POST,
1288        });
1289
1290        for &field in ["alt", "name"].iter() {
1291            if self._additional_params.contains_key(field) {
1292                dlg.finished(false);
1293                return Err(common::Error::FieldClash(field));
1294            }
1295        }
1296
1297        let mut params = Params::with_capacity(4 + self._additional_params.len());
1298        params.push("name", self._name);
1299
1300        params.extend(self._additional_params.iter());
1301
1302        params.push("alt", "json");
1303        let mut url = self.hub._base_url.clone() + "v1/{+name}:generateAccessToken";
1304        if self._scopes.is_empty() {
1305            self._scopes
1306                .insert(Scope::CloudPlatform.as_ref().to_string());
1307        }
1308
1309        #[allow(clippy::single_element_loop)]
1310        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1311            url = params.uri_replacement(url, param_name, find_this, true);
1312        }
1313        {
1314            let to_remove = ["name"];
1315            params.remove_params(&to_remove);
1316        }
1317
1318        let url = params.parse_with_url(&url);
1319
1320        let mut json_mime_type = mime::APPLICATION_JSON;
1321        let mut request_value_reader = {
1322            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1323            common::remove_json_null_values(&mut value);
1324            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1325            serde_json::to_writer(&mut dst, &value).unwrap();
1326            dst
1327        };
1328        let request_size = request_value_reader
1329            .seek(std::io::SeekFrom::End(0))
1330            .unwrap();
1331        request_value_reader
1332            .seek(std::io::SeekFrom::Start(0))
1333            .unwrap();
1334
1335        loop {
1336            let token = match self
1337                .hub
1338                .auth
1339                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1340                .await
1341            {
1342                Ok(token) => token,
1343                Err(e) => match dlg.token(e) {
1344                    Ok(token) => token,
1345                    Err(e) => {
1346                        dlg.finished(false);
1347                        return Err(common::Error::MissingToken(e));
1348                    }
1349                },
1350            };
1351            request_value_reader
1352                .seek(std::io::SeekFrom::Start(0))
1353                .unwrap();
1354            let mut req_result = {
1355                let client = &self.hub.client;
1356                dlg.pre_request();
1357                let mut req_builder = hyper::Request::builder()
1358                    .method(hyper::Method::POST)
1359                    .uri(url.as_str())
1360                    .header(USER_AGENT, self.hub._user_agent.clone());
1361
1362                if let Some(token) = token.as_ref() {
1363                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1364                }
1365
1366                let request = req_builder
1367                    .header(CONTENT_TYPE, json_mime_type.to_string())
1368                    .header(CONTENT_LENGTH, request_size as u64)
1369                    .body(common::to_body(
1370                        request_value_reader.get_ref().clone().into(),
1371                    ));
1372
1373                client.request(request.unwrap()).await
1374            };
1375
1376            match req_result {
1377                Err(err) => {
1378                    if let common::Retry::After(d) = dlg.http_error(&err) {
1379                        sleep(d).await;
1380                        continue;
1381                    }
1382                    dlg.finished(false);
1383                    return Err(common::Error::HttpError(err));
1384                }
1385                Ok(res) => {
1386                    let (mut parts, body) = res.into_parts();
1387                    let mut body = common::Body::new(body);
1388                    if !parts.status.is_success() {
1389                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1390                        let error = serde_json::from_str(&common::to_string(&bytes));
1391                        let response = common::to_response(parts, bytes.into());
1392
1393                        if let common::Retry::After(d) =
1394                            dlg.http_failure(&response, error.as_ref().ok())
1395                        {
1396                            sleep(d).await;
1397                            continue;
1398                        }
1399
1400                        dlg.finished(false);
1401
1402                        return Err(match error {
1403                            Ok(value) => common::Error::BadRequest(value),
1404                            _ => common::Error::Failure(response),
1405                        });
1406                    }
1407                    let response = {
1408                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1409                        let encoded = common::to_string(&bytes);
1410                        match serde_json::from_str(&encoded) {
1411                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1412                            Err(error) => {
1413                                dlg.response_json_decode_error(&encoded, &error);
1414                                return Err(common::Error::JsonDecodeError(
1415                                    encoded.to_string(),
1416                                    error,
1417                                ));
1418                            }
1419                        }
1420                    };
1421
1422                    dlg.finished(true);
1423                    return Ok(response);
1424                }
1425            }
1426        }
1427    }
1428
1429    ///
1430    /// Sets the *request* property to the given value.
1431    ///
1432    /// Even though the property as already been set when instantiating this call,
1433    /// we provide this method for API completeness.
1434    pub fn request(
1435        mut self,
1436        new_value: GenerateAccessTokenRequest,
1437    ) -> ProjectServiceAccountGenerateAccessTokenCall<'a, C> {
1438        self._request = new_value;
1439        self
1440    }
1441    /// Required. The resource name of the service account for which the credentials are requested, in the following format: `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is required; replacing it with a project ID is invalid.
1442    ///
1443    /// Sets the *name* path property to the given value.
1444    ///
1445    /// Even though the property as already been set when instantiating this call,
1446    /// we provide this method for API completeness.
1447    pub fn name(mut self, new_value: &str) -> ProjectServiceAccountGenerateAccessTokenCall<'a, C> {
1448        self._name = new_value.to_string();
1449        self
1450    }
1451    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1452    /// while executing the actual API request.
1453    ///
1454    /// ````text
1455    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1456    /// ````
1457    ///
1458    /// Sets the *delegate* property to the given value.
1459    pub fn delegate(
1460        mut self,
1461        new_value: &'a mut dyn common::Delegate,
1462    ) -> ProjectServiceAccountGenerateAccessTokenCall<'a, C> {
1463        self._delegate = Some(new_value);
1464        self
1465    }
1466
1467    /// Set any additional parameter of the query string used in the request.
1468    /// It should be used to set parameters which are not yet available through their own
1469    /// setters.
1470    ///
1471    /// Please note that this method must not be used to set any of the known parameters
1472    /// which have their own setter method. If done anyway, the request will fail.
1473    ///
1474    /// # Additional Parameters
1475    ///
1476    /// * *$.xgafv* (query-string) - V1 error format.
1477    /// * *access_token* (query-string) - OAuth access token.
1478    /// * *alt* (query-string) - Data format for response.
1479    /// * *callback* (query-string) - JSONP
1480    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1481    /// * *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.
1482    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1483    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1484    /// * *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.
1485    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1486    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1487    pub fn param<T>(
1488        mut self,
1489        name: T,
1490        value: T,
1491    ) -> ProjectServiceAccountGenerateAccessTokenCall<'a, C>
1492    where
1493        T: AsRef<str>,
1494    {
1495        self._additional_params
1496            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1497        self
1498    }
1499
1500    /// Identifies the authorization scope for the method you are building.
1501    ///
1502    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1503    /// [`Scope::CloudPlatform`].
1504    ///
1505    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1506    /// tokens for more than one scope.
1507    ///
1508    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1509    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1510    /// sufficient, a read-write scope will do as well.
1511    pub fn add_scope<St>(mut self, scope: St) -> ProjectServiceAccountGenerateAccessTokenCall<'a, C>
1512    where
1513        St: AsRef<str>,
1514    {
1515        self._scopes.insert(String::from(scope.as_ref()));
1516        self
1517    }
1518    /// Identifies the authorization scope(s) for the method you are building.
1519    ///
1520    /// See [`Self::add_scope()`] for details.
1521    pub fn add_scopes<I, St>(
1522        mut self,
1523        scopes: I,
1524    ) -> ProjectServiceAccountGenerateAccessTokenCall<'a, C>
1525    where
1526        I: IntoIterator<Item = St>,
1527        St: AsRef<str>,
1528    {
1529        self._scopes
1530            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1531        self
1532    }
1533
1534    /// Removes all scopes, and no default scope will be used either.
1535    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1536    /// for details).
1537    pub fn clear_scopes(mut self) -> ProjectServiceAccountGenerateAccessTokenCall<'a, C> {
1538        self._scopes.clear();
1539        self
1540    }
1541}
1542
1543/// Generates an OpenID Connect ID token for a service account.
1544///
1545/// A builder for the *serviceAccounts.generateIdToken* method supported by a *project* resource.
1546/// It is not used directly, but through a [`ProjectMethods`] instance.
1547///
1548/// # Example
1549///
1550/// Instantiate a resource method builder
1551///
1552/// ```test_harness,no_run
1553/// # extern crate hyper;
1554/// # extern crate hyper_rustls;
1555/// # extern crate google_iamcredentials1 as iamcredentials1;
1556/// use iamcredentials1::api::GenerateIdTokenRequest;
1557/// # async fn dox() {
1558/// # use iamcredentials1::{IAMCredentials, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1559///
1560/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1561/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1562/// #     .with_native_roots()
1563/// #     .unwrap()
1564/// #     .https_only()
1565/// #     .enable_http2()
1566/// #     .build();
1567///
1568/// # let executor = hyper_util::rt::TokioExecutor::new();
1569/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1570/// #     secret,
1571/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1572/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1573/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1574/// #     ),
1575/// # ).build().await.unwrap();
1576///
1577/// # let client = hyper_util::client::legacy::Client::builder(
1578/// #     hyper_util::rt::TokioExecutor::new()
1579/// # )
1580/// # .build(
1581/// #     hyper_rustls::HttpsConnectorBuilder::new()
1582/// #         .with_native_roots()
1583/// #         .unwrap()
1584/// #         .https_or_http()
1585/// #         .enable_http2()
1586/// #         .build()
1587/// # );
1588/// # let mut hub = IAMCredentials::new(client, auth);
1589/// // As the method needs a request, you would usually fill it with the desired information
1590/// // into the respective structure. Some of the parts shown here might not be applicable !
1591/// // Values shown here are possibly random and not representative !
1592/// let mut req = GenerateIdTokenRequest::default();
1593///
1594/// // You can configure optional parameters by calling the respective setters at will, and
1595/// // execute the final call using `doit()`.
1596/// // Values shown here are possibly random and not representative !
1597/// let result = hub.projects().service_accounts_generate_id_token(req, "name")
1598///              .doit().await;
1599/// # }
1600/// ```
1601pub struct ProjectServiceAccountGenerateIdTokenCall<'a, C>
1602where
1603    C: 'a,
1604{
1605    hub: &'a IAMCredentials<C>,
1606    _request: GenerateIdTokenRequest,
1607    _name: String,
1608    _delegate: Option<&'a mut dyn common::Delegate>,
1609    _additional_params: HashMap<String, String>,
1610    _scopes: BTreeSet<String>,
1611}
1612
1613impl<'a, C> common::CallBuilder for ProjectServiceAccountGenerateIdTokenCall<'a, C> {}
1614
1615impl<'a, C> ProjectServiceAccountGenerateIdTokenCall<'a, C>
1616where
1617    C: common::Connector,
1618{
1619    /// Perform the operation you have build so far.
1620    pub async fn doit(mut self) -> common::Result<(common::Response, GenerateIdTokenResponse)> {
1621        use std::borrow::Cow;
1622        use std::io::{Read, Seek};
1623
1624        use common::{url::Params, ToParts};
1625        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1626
1627        let mut dd = common::DefaultDelegate;
1628        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1629        dlg.begin(common::MethodInfo {
1630            id: "iamcredentials.projects.serviceAccounts.generateIdToken",
1631            http_method: hyper::Method::POST,
1632        });
1633
1634        for &field in ["alt", "name"].iter() {
1635            if self._additional_params.contains_key(field) {
1636                dlg.finished(false);
1637                return Err(common::Error::FieldClash(field));
1638            }
1639        }
1640
1641        let mut params = Params::with_capacity(4 + self._additional_params.len());
1642        params.push("name", self._name);
1643
1644        params.extend(self._additional_params.iter());
1645
1646        params.push("alt", "json");
1647        let mut url = self.hub._base_url.clone() + "v1/{+name}:generateIdToken";
1648        if self._scopes.is_empty() {
1649            self._scopes
1650                .insert(Scope::CloudPlatform.as_ref().to_string());
1651        }
1652
1653        #[allow(clippy::single_element_loop)]
1654        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1655            url = params.uri_replacement(url, param_name, find_this, true);
1656        }
1657        {
1658            let to_remove = ["name"];
1659            params.remove_params(&to_remove);
1660        }
1661
1662        let url = params.parse_with_url(&url);
1663
1664        let mut json_mime_type = mime::APPLICATION_JSON;
1665        let mut request_value_reader = {
1666            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1667            common::remove_json_null_values(&mut value);
1668            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1669            serde_json::to_writer(&mut dst, &value).unwrap();
1670            dst
1671        };
1672        let request_size = request_value_reader
1673            .seek(std::io::SeekFrom::End(0))
1674            .unwrap();
1675        request_value_reader
1676            .seek(std::io::SeekFrom::Start(0))
1677            .unwrap();
1678
1679        loop {
1680            let token = match self
1681                .hub
1682                .auth
1683                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1684                .await
1685            {
1686                Ok(token) => token,
1687                Err(e) => match dlg.token(e) {
1688                    Ok(token) => token,
1689                    Err(e) => {
1690                        dlg.finished(false);
1691                        return Err(common::Error::MissingToken(e));
1692                    }
1693                },
1694            };
1695            request_value_reader
1696                .seek(std::io::SeekFrom::Start(0))
1697                .unwrap();
1698            let mut req_result = {
1699                let client = &self.hub.client;
1700                dlg.pre_request();
1701                let mut req_builder = hyper::Request::builder()
1702                    .method(hyper::Method::POST)
1703                    .uri(url.as_str())
1704                    .header(USER_AGENT, self.hub._user_agent.clone());
1705
1706                if let Some(token) = token.as_ref() {
1707                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1708                }
1709
1710                let request = req_builder
1711                    .header(CONTENT_TYPE, json_mime_type.to_string())
1712                    .header(CONTENT_LENGTH, request_size as u64)
1713                    .body(common::to_body(
1714                        request_value_reader.get_ref().clone().into(),
1715                    ));
1716
1717                client.request(request.unwrap()).await
1718            };
1719
1720            match req_result {
1721                Err(err) => {
1722                    if let common::Retry::After(d) = dlg.http_error(&err) {
1723                        sleep(d).await;
1724                        continue;
1725                    }
1726                    dlg.finished(false);
1727                    return Err(common::Error::HttpError(err));
1728                }
1729                Ok(res) => {
1730                    let (mut parts, body) = res.into_parts();
1731                    let mut body = common::Body::new(body);
1732                    if !parts.status.is_success() {
1733                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1734                        let error = serde_json::from_str(&common::to_string(&bytes));
1735                        let response = common::to_response(parts, bytes.into());
1736
1737                        if let common::Retry::After(d) =
1738                            dlg.http_failure(&response, error.as_ref().ok())
1739                        {
1740                            sleep(d).await;
1741                            continue;
1742                        }
1743
1744                        dlg.finished(false);
1745
1746                        return Err(match error {
1747                            Ok(value) => common::Error::BadRequest(value),
1748                            _ => common::Error::Failure(response),
1749                        });
1750                    }
1751                    let response = {
1752                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1753                        let encoded = common::to_string(&bytes);
1754                        match serde_json::from_str(&encoded) {
1755                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1756                            Err(error) => {
1757                                dlg.response_json_decode_error(&encoded, &error);
1758                                return Err(common::Error::JsonDecodeError(
1759                                    encoded.to_string(),
1760                                    error,
1761                                ));
1762                            }
1763                        }
1764                    };
1765
1766                    dlg.finished(true);
1767                    return Ok(response);
1768                }
1769            }
1770        }
1771    }
1772
1773    ///
1774    /// Sets the *request* property to the given value.
1775    ///
1776    /// Even though the property as already been set when instantiating this call,
1777    /// we provide this method for API completeness.
1778    pub fn request(
1779        mut self,
1780        new_value: GenerateIdTokenRequest,
1781    ) -> ProjectServiceAccountGenerateIdTokenCall<'a, C> {
1782        self._request = new_value;
1783        self
1784    }
1785    /// Required. The resource name of the service account for which the credentials are requested, in the following format: `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is required; replacing it with a project ID is invalid.
1786    ///
1787    /// Sets the *name* path property to the given value.
1788    ///
1789    /// Even though the property as already been set when instantiating this call,
1790    /// we provide this method for API completeness.
1791    pub fn name(mut self, new_value: &str) -> ProjectServiceAccountGenerateIdTokenCall<'a, C> {
1792        self._name = new_value.to_string();
1793        self
1794    }
1795    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1796    /// while executing the actual API request.
1797    ///
1798    /// ````text
1799    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1800    /// ````
1801    ///
1802    /// Sets the *delegate* property to the given value.
1803    pub fn delegate(
1804        mut self,
1805        new_value: &'a mut dyn common::Delegate,
1806    ) -> ProjectServiceAccountGenerateIdTokenCall<'a, C> {
1807        self._delegate = Some(new_value);
1808        self
1809    }
1810
1811    /// Set any additional parameter of the query string used in the request.
1812    /// It should be used to set parameters which are not yet available through their own
1813    /// setters.
1814    ///
1815    /// Please note that this method must not be used to set any of the known parameters
1816    /// which have their own setter method. If done anyway, the request will fail.
1817    ///
1818    /// # Additional Parameters
1819    ///
1820    /// * *$.xgafv* (query-string) - V1 error format.
1821    /// * *access_token* (query-string) - OAuth access token.
1822    /// * *alt* (query-string) - Data format for response.
1823    /// * *callback* (query-string) - JSONP
1824    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1825    /// * *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.
1826    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1827    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1828    /// * *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.
1829    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1830    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1831    pub fn param<T>(mut self, name: T, value: T) -> ProjectServiceAccountGenerateIdTokenCall<'a, C>
1832    where
1833        T: AsRef<str>,
1834    {
1835        self._additional_params
1836            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1837        self
1838    }
1839
1840    /// Identifies the authorization scope for the method you are building.
1841    ///
1842    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1843    /// [`Scope::CloudPlatform`].
1844    ///
1845    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1846    /// tokens for more than one scope.
1847    ///
1848    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1849    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1850    /// sufficient, a read-write scope will do as well.
1851    pub fn add_scope<St>(mut self, scope: St) -> ProjectServiceAccountGenerateIdTokenCall<'a, C>
1852    where
1853        St: AsRef<str>,
1854    {
1855        self._scopes.insert(String::from(scope.as_ref()));
1856        self
1857    }
1858    /// Identifies the authorization scope(s) for the method you are building.
1859    ///
1860    /// See [`Self::add_scope()`] for details.
1861    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectServiceAccountGenerateIdTokenCall<'a, C>
1862    where
1863        I: IntoIterator<Item = St>,
1864        St: AsRef<str>,
1865    {
1866        self._scopes
1867            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1868        self
1869    }
1870
1871    /// Removes all scopes, and no default scope will be used either.
1872    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1873    /// for details).
1874    pub fn clear_scopes(mut self) -> ProjectServiceAccountGenerateIdTokenCall<'a, C> {
1875        self._scopes.clear();
1876        self
1877    }
1878}
1879
1880/// Returns the trust boundary info for a given service account.
1881///
1882/// A builder for the *serviceAccounts.getAllowedLocations* method supported by a *project* resource.
1883/// It is not used directly, but through a [`ProjectMethods`] instance.
1884///
1885/// # Example
1886///
1887/// Instantiate a resource method builder
1888///
1889/// ```test_harness,no_run
1890/// # extern crate hyper;
1891/// # extern crate hyper_rustls;
1892/// # extern crate google_iamcredentials1 as iamcredentials1;
1893/// # async fn dox() {
1894/// # use iamcredentials1::{IAMCredentials, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1895///
1896/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1897/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1898/// #     .with_native_roots()
1899/// #     .unwrap()
1900/// #     .https_only()
1901/// #     .enable_http2()
1902/// #     .build();
1903///
1904/// # let executor = hyper_util::rt::TokioExecutor::new();
1905/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1906/// #     secret,
1907/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1908/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1909/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1910/// #     ),
1911/// # ).build().await.unwrap();
1912///
1913/// # let client = hyper_util::client::legacy::Client::builder(
1914/// #     hyper_util::rt::TokioExecutor::new()
1915/// # )
1916/// # .build(
1917/// #     hyper_rustls::HttpsConnectorBuilder::new()
1918/// #         .with_native_roots()
1919/// #         .unwrap()
1920/// #         .https_or_http()
1921/// #         .enable_http2()
1922/// #         .build()
1923/// # );
1924/// # let mut hub = IAMCredentials::new(client, auth);
1925/// // You can configure optional parameters by calling the respective setters at will, and
1926/// // execute the final call using `doit()`.
1927/// // Values shown here are possibly random and not representative !
1928/// let result = hub.projects().service_accounts_get_allowed_locations("name")
1929///              .doit().await;
1930/// # }
1931/// ```
1932pub struct ProjectServiceAccountGetAllowedLocationCall<'a, C>
1933where
1934    C: 'a,
1935{
1936    hub: &'a IAMCredentials<C>,
1937    _name: String,
1938    _delegate: Option<&'a mut dyn common::Delegate>,
1939    _additional_params: HashMap<String, String>,
1940}
1941
1942impl<'a, C> common::CallBuilder for ProjectServiceAccountGetAllowedLocationCall<'a, C> {}
1943
1944impl<'a, C> ProjectServiceAccountGetAllowedLocationCall<'a, C>
1945where
1946    C: common::Connector,
1947{
1948    /// Perform the operation you have build so far.
1949    pub async fn doit(
1950        mut self,
1951    ) -> common::Result<(common::Response, ServiceAccountAllowedLocations)> {
1952        use std::borrow::Cow;
1953        use std::io::{Read, Seek};
1954
1955        use common::{url::Params, ToParts};
1956        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1957
1958        let mut dd = common::DefaultDelegate;
1959        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1960        dlg.begin(common::MethodInfo {
1961            id: "iamcredentials.projects.serviceAccounts.getAllowedLocations",
1962            http_method: hyper::Method::GET,
1963        });
1964
1965        for &field in ["alt", "name"].iter() {
1966            if self._additional_params.contains_key(field) {
1967                dlg.finished(false);
1968                return Err(common::Error::FieldClash(field));
1969            }
1970        }
1971
1972        let mut params = Params::with_capacity(3 + self._additional_params.len());
1973        params.push("name", self._name);
1974
1975        params.extend(self._additional_params.iter());
1976
1977        params.push("alt", "json");
1978        let mut url = self.hub._base_url.clone() + "v1/{+name}/allowedLocations";
1979
1980        match dlg.api_key() {
1981            Some(value) => params.push("key", value),
1982            None => {
1983                dlg.finished(false);
1984                return Err(common::Error::MissingAPIKey);
1985            }
1986        }
1987
1988        #[allow(clippy::single_element_loop)]
1989        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1990            url = params.uri_replacement(url, param_name, find_this, true);
1991        }
1992        {
1993            let to_remove = ["name"];
1994            params.remove_params(&to_remove);
1995        }
1996
1997        let url = params.parse_with_url(&url);
1998
1999        loop {
2000            let mut req_result = {
2001                let client = &self.hub.client;
2002                dlg.pre_request();
2003                let mut req_builder = hyper::Request::builder()
2004                    .method(hyper::Method::GET)
2005                    .uri(url.as_str())
2006                    .header(USER_AGENT, self.hub._user_agent.clone());
2007
2008                let request = req_builder
2009                    .header(CONTENT_LENGTH, 0_u64)
2010                    .body(common::to_body::<String>(None));
2011
2012                client.request(request.unwrap()).await
2013            };
2014
2015            match req_result {
2016                Err(err) => {
2017                    if let common::Retry::After(d) = dlg.http_error(&err) {
2018                        sleep(d).await;
2019                        continue;
2020                    }
2021                    dlg.finished(false);
2022                    return Err(common::Error::HttpError(err));
2023                }
2024                Ok(res) => {
2025                    let (mut parts, body) = res.into_parts();
2026                    let mut body = common::Body::new(body);
2027                    if !parts.status.is_success() {
2028                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2029                        let error = serde_json::from_str(&common::to_string(&bytes));
2030                        let response = common::to_response(parts, bytes.into());
2031
2032                        if let common::Retry::After(d) =
2033                            dlg.http_failure(&response, error.as_ref().ok())
2034                        {
2035                            sleep(d).await;
2036                            continue;
2037                        }
2038
2039                        dlg.finished(false);
2040
2041                        return Err(match error {
2042                            Ok(value) => common::Error::BadRequest(value),
2043                            _ => common::Error::Failure(response),
2044                        });
2045                    }
2046                    let response = {
2047                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2048                        let encoded = common::to_string(&bytes);
2049                        match serde_json::from_str(&encoded) {
2050                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2051                            Err(error) => {
2052                                dlg.response_json_decode_error(&encoded, &error);
2053                                return Err(common::Error::JsonDecodeError(
2054                                    encoded.to_string(),
2055                                    error,
2056                                ));
2057                            }
2058                        }
2059                    };
2060
2061                    dlg.finished(true);
2062                    return Ok(response);
2063                }
2064            }
2065        }
2066    }
2067
2068    /// Required. Resource name of service account.
2069    ///
2070    /// Sets the *name* path property to the given value.
2071    ///
2072    /// Even though the property as already been set when instantiating this call,
2073    /// we provide this method for API completeness.
2074    pub fn name(mut self, new_value: &str) -> ProjectServiceAccountGetAllowedLocationCall<'a, C> {
2075        self._name = new_value.to_string();
2076        self
2077    }
2078    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2079    /// while executing the actual API request.
2080    ///
2081    /// ````text
2082    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2083    /// ````
2084    ///
2085    /// Sets the *delegate* property to the given value.
2086    pub fn delegate(
2087        mut self,
2088        new_value: &'a mut dyn common::Delegate,
2089    ) -> ProjectServiceAccountGetAllowedLocationCall<'a, C> {
2090        self._delegate = Some(new_value);
2091        self
2092    }
2093
2094    /// Set any additional parameter of the query string used in the request.
2095    /// It should be used to set parameters which are not yet available through their own
2096    /// setters.
2097    ///
2098    /// Please note that this method must not be used to set any of the known parameters
2099    /// which have their own setter method. If done anyway, the request will fail.
2100    ///
2101    /// # Additional Parameters
2102    ///
2103    /// * *$.xgafv* (query-string) - V1 error format.
2104    /// * *access_token* (query-string) - OAuth access token.
2105    /// * *alt* (query-string) - Data format for response.
2106    /// * *callback* (query-string) - JSONP
2107    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2108    /// * *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.
2109    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2110    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2111    /// * *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.
2112    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2113    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2114    pub fn param<T>(
2115        mut self,
2116        name: T,
2117        value: T,
2118    ) -> ProjectServiceAccountGetAllowedLocationCall<'a, C>
2119    where
2120        T: AsRef<str>,
2121    {
2122        self._additional_params
2123            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2124        self
2125    }
2126}
2127
2128/// Signs a blob using a service account's system-managed private key.
2129///
2130/// A builder for the *serviceAccounts.signBlob* method supported by a *project* resource.
2131/// It is not used directly, but through a [`ProjectMethods`] instance.
2132///
2133/// # Example
2134///
2135/// Instantiate a resource method builder
2136///
2137/// ```test_harness,no_run
2138/// # extern crate hyper;
2139/// # extern crate hyper_rustls;
2140/// # extern crate google_iamcredentials1 as iamcredentials1;
2141/// use iamcredentials1::api::SignBlobRequest;
2142/// # async fn dox() {
2143/// # use iamcredentials1::{IAMCredentials, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2144///
2145/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2146/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2147/// #     .with_native_roots()
2148/// #     .unwrap()
2149/// #     .https_only()
2150/// #     .enable_http2()
2151/// #     .build();
2152///
2153/// # let executor = hyper_util::rt::TokioExecutor::new();
2154/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2155/// #     secret,
2156/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2157/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2158/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2159/// #     ),
2160/// # ).build().await.unwrap();
2161///
2162/// # let client = hyper_util::client::legacy::Client::builder(
2163/// #     hyper_util::rt::TokioExecutor::new()
2164/// # )
2165/// # .build(
2166/// #     hyper_rustls::HttpsConnectorBuilder::new()
2167/// #         .with_native_roots()
2168/// #         .unwrap()
2169/// #         .https_or_http()
2170/// #         .enable_http2()
2171/// #         .build()
2172/// # );
2173/// # let mut hub = IAMCredentials::new(client, auth);
2174/// // As the method needs a request, you would usually fill it with the desired information
2175/// // into the respective structure. Some of the parts shown here might not be applicable !
2176/// // Values shown here are possibly random and not representative !
2177/// let mut req = SignBlobRequest::default();
2178///
2179/// // You can configure optional parameters by calling the respective setters at will, and
2180/// // execute the final call using `doit()`.
2181/// // Values shown here are possibly random and not representative !
2182/// let result = hub.projects().service_accounts_sign_blob(req, "name")
2183///              .doit().await;
2184/// # }
2185/// ```
2186pub struct ProjectServiceAccountSignBlobCall<'a, C>
2187where
2188    C: 'a,
2189{
2190    hub: &'a IAMCredentials<C>,
2191    _request: SignBlobRequest,
2192    _name: String,
2193    _delegate: Option<&'a mut dyn common::Delegate>,
2194    _additional_params: HashMap<String, String>,
2195    _scopes: BTreeSet<String>,
2196}
2197
2198impl<'a, C> common::CallBuilder for ProjectServiceAccountSignBlobCall<'a, C> {}
2199
2200impl<'a, C> ProjectServiceAccountSignBlobCall<'a, C>
2201where
2202    C: common::Connector,
2203{
2204    /// Perform the operation you have build so far.
2205    pub async fn doit(mut self) -> common::Result<(common::Response, SignBlobResponse)> {
2206        use std::borrow::Cow;
2207        use std::io::{Read, Seek};
2208
2209        use common::{url::Params, ToParts};
2210        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2211
2212        let mut dd = common::DefaultDelegate;
2213        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2214        dlg.begin(common::MethodInfo {
2215            id: "iamcredentials.projects.serviceAccounts.signBlob",
2216            http_method: hyper::Method::POST,
2217        });
2218
2219        for &field in ["alt", "name"].iter() {
2220            if self._additional_params.contains_key(field) {
2221                dlg.finished(false);
2222                return Err(common::Error::FieldClash(field));
2223            }
2224        }
2225
2226        let mut params = Params::with_capacity(4 + self._additional_params.len());
2227        params.push("name", self._name);
2228
2229        params.extend(self._additional_params.iter());
2230
2231        params.push("alt", "json");
2232        let mut url = self.hub._base_url.clone() + "v1/{+name}:signBlob";
2233        if self._scopes.is_empty() {
2234            self._scopes
2235                .insert(Scope::CloudPlatform.as_ref().to_string());
2236        }
2237
2238        #[allow(clippy::single_element_loop)]
2239        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2240            url = params.uri_replacement(url, param_name, find_this, true);
2241        }
2242        {
2243            let to_remove = ["name"];
2244            params.remove_params(&to_remove);
2245        }
2246
2247        let url = params.parse_with_url(&url);
2248
2249        let mut json_mime_type = mime::APPLICATION_JSON;
2250        let mut request_value_reader = {
2251            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2252            common::remove_json_null_values(&mut value);
2253            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2254            serde_json::to_writer(&mut dst, &value).unwrap();
2255            dst
2256        };
2257        let request_size = request_value_reader
2258            .seek(std::io::SeekFrom::End(0))
2259            .unwrap();
2260        request_value_reader
2261            .seek(std::io::SeekFrom::Start(0))
2262            .unwrap();
2263
2264        loop {
2265            let token = match self
2266                .hub
2267                .auth
2268                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2269                .await
2270            {
2271                Ok(token) => token,
2272                Err(e) => match dlg.token(e) {
2273                    Ok(token) => token,
2274                    Err(e) => {
2275                        dlg.finished(false);
2276                        return Err(common::Error::MissingToken(e));
2277                    }
2278                },
2279            };
2280            request_value_reader
2281                .seek(std::io::SeekFrom::Start(0))
2282                .unwrap();
2283            let mut req_result = {
2284                let client = &self.hub.client;
2285                dlg.pre_request();
2286                let mut req_builder = hyper::Request::builder()
2287                    .method(hyper::Method::POST)
2288                    .uri(url.as_str())
2289                    .header(USER_AGENT, self.hub._user_agent.clone());
2290
2291                if let Some(token) = token.as_ref() {
2292                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2293                }
2294
2295                let request = req_builder
2296                    .header(CONTENT_TYPE, json_mime_type.to_string())
2297                    .header(CONTENT_LENGTH, request_size as u64)
2298                    .body(common::to_body(
2299                        request_value_reader.get_ref().clone().into(),
2300                    ));
2301
2302                client.request(request.unwrap()).await
2303            };
2304
2305            match req_result {
2306                Err(err) => {
2307                    if let common::Retry::After(d) = dlg.http_error(&err) {
2308                        sleep(d).await;
2309                        continue;
2310                    }
2311                    dlg.finished(false);
2312                    return Err(common::Error::HttpError(err));
2313                }
2314                Ok(res) => {
2315                    let (mut parts, body) = res.into_parts();
2316                    let mut body = common::Body::new(body);
2317                    if !parts.status.is_success() {
2318                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2319                        let error = serde_json::from_str(&common::to_string(&bytes));
2320                        let response = common::to_response(parts, bytes.into());
2321
2322                        if let common::Retry::After(d) =
2323                            dlg.http_failure(&response, error.as_ref().ok())
2324                        {
2325                            sleep(d).await;
2326                            continue;
2327                        }
2328
2329                        dlg.finished(false);
2330
2331                        return Err(match error {
2332                            Ok(value) => common::Error::BadRequest(value),
2333                            _ => common::Error::Failure(response),
2334                        });
2335                    }
2336                    let response = {
2337                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2338                        let encoded = common::to_string(&bytes);
2339                        match serde_json::from_str(&encoded) {
2340                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2341                            Err(error) => {
2342                                dlg.response_json_decode_error(&encoded, &error);
2343                                return Err(common::Error::JsonDecodeError(
2344                                    encoded.to_string(),
2345                                    error,
2346                                ));
2347                            }
2348                        }
2349                    };
2350
2351                    dlg.finished(true);
2352                    return Ok(response);
2353                }
2354            }
2355        }
2356    }
2357
2358    ///
2359    /// Sets the *request* property to the given value.
2360    ///
2361    /// Even though the property as already been set when instantiating this call,
2362    /// we provide this method for API completeness.
2363    pub fn request(
2364        mut self,
2365        new_value: SignBlobRequest,
2366    ) -> ProjectServiceAccountSignBlobCall<'a, C> {
2367        self._request = new_value;
2368        self
2369    }
2370    /// Required. The resource name of the service account for which the credentials are requested, in the following format: `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is required; replacing it with a project ID is invalid.
2371    ///
2372    /// Sets the *name* path property to the given value.
2373    ///
2374    /// Even though the property as already been set when instantiating this call,
2375    /// we provide this method for API completeness.
2376    pub fn name(mut self, new_value: &str) -> ProjectServiceAccountSignBlobCall<'a, C> {
2377        self._name = new_value.to_string();
2378        self
2379    }
2380    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2381    /// while executing the actual API request.
2382    ///
2383    /// ````text
2384    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2385    /// ````
2386    ///
2387    /// Sets the *delegate* property to the given value.
2388    pub fn delegate(
2389        mut self,
2390        new_value: &'a mut dyn common::Delegate,
2391    ) -> ProjectServiceAccountSignBlobCall<'a, C> {
2392        self._delegate = Some(new_value);
2393        self
2394    }
2395
2396    /// Set any additional parameter of the query string used in the request.
2397    /// It should be used to set parameters which are not yet available through their own
2398    /// setters.
2399    ///
2400    /// Please note that this method must not be used to set any of the known parameters
2401    /// which have their own setter method. If done anyway, the request will fail.
2402    ///
2403    /// # Additional Parameters
2404    ///
2405    /// * *$.xgafv* (query-string) - V1 error format.
2406    /// * *access_token* (query-string) - OAuth access token.
2407    /// * *alt* (query-string) - Data format for response.
2408    /// * *callback* (query-string) - JSONP
2409    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2410    /// * *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.
2411    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2412    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2413    /// * *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.
2414    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2415    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2416    pub fn param<T>(mut self, name: T, value: T) -> ProjectServiceAccountSignBlobCall<'a, C>
2417    where
2418        T: AsRef<str>,
2419    {
2420        self._additional_params
2421            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2422        self
2423    }
2424
2425    /// Identifies the authorization scope for the method you are building.
2426    ///
2427    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2428    /// [`Scope::CloudPlatform`].
2429    ///
2430    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2431    /// tokens for more than one scope.
2432    ///
2433    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2434    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2435    /// sufficient, a read-write scope will do as well.
2436    pub fn add_scope<St>(mut self, scope: St) -> ProjectServiceAccountSignBlobCall<'a, C>
2437    where
2438        St: AsRef<str>,
2439    {
2440        self._scopes.insert(String::from(scope.as_ref()));
2441        self
2442    }
2443    /// Identifies the authorization scope(s) for the method you are building.
2444    ///
2445    /// See [`Self::add_scope()`] for details.
2446    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectServiceAccountSignBlobCall<'a, C>
2447    where
2448        I: IntoIterator<Item = St>,
2449        St: AsRef<str>,
2450    {
2451        self._scopes
2452            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2453        self
2454    }
2455
2456    /// Removes all scopes, and no default scope will be used either.
2457    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2458    /// for details).
2459    pub fn clear_scopes(mut self) -> ProjectServiceAccountSignBlobCall<'a, C> {
2460        self._scopes.clear();
2461        self
2462    }
2463}
2464
2465/// Signs a JWT using a service account's system-managed private key.
2466///
2467/// A builder for the *serviceAccounts.signJwt* method supported by a *project* resource.
2468/// It is not used directly, but through a [`ProjectMethods`] instance.
2469///
2470/// # Example
2471///
2472/// Instantiate a resource method builder
2473///
2474/// ```test_harness,no_run
2475/// # extern crate hyper;
2476/// # extern crate hyper_rustls;
2477/// # extern crate google_iamcredentials1 as iamcredentials1;
2478/// use iamcredentials1::api::SignJwtRequest;
2479/// # async fn dox() {
2480/// # use iamcredentials1::{IAMCredentials, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2481///
2482/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2483/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2484/// #     .with_native_roots()
2485/// #     .unwrap()
2486/// #     .https_only()
2487/// #     .enable_http2()
2488/// #     .build();
2489///
2490/// # let executor = hyper_util::rt::TokioExecutor::new();
2491/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2492/// #     secret,
2493/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2494/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2495/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2496/// #     ),
2497/// # ).build().await.unwrap();
2498///
2499/// # let client = hyper_util::client::legacy::Client::builder(
2500/// #     hyper_util::rt::TokioExecutor::new()
2501/// # )
2502/// # .build(
2503/// #     hyper_rustls::HttpsConnectorBuilder::new()
2504/// #         .with_native_roots()
2505/// #         .unwrap()
2506/// #         .https_or_http()
2507/// #         .enable_http2()
2508/// #         .build()
2509/// # );
2510/// # let mut hub = IAMCredentials::new(client, auth);
2511/// // As the method needs a request, you would usually fill it with the desired information
2512/// // into the respective structure. Some of the parts shown here might not be applicable !
2513/// // Values shown here are possibly random and not representative !
2514/// let mut req = SignJwtRequest::default();
2515///
2516/// // You can configure optional parameters by calling the respective setters at will, and
2517/// // execute the final call using `doit()`.
2518/// // Values shown here are possibly random and not representative !
2519/// let result = hub.projects().service_accounts_sign_jwt(req, "name")
2520///              .doit().await;
2521/// # }
2522/// ```
2523pub struct ProjectServiceAccountSignJwtCall<'a, C>
2524where
2525    C: 'a,
2526{
2527    hub: &'a IAMCredentials<C>,
2528    _request: SignJwtRequest,
2529    _name: String,
2530    _delegate: Option<&'a mut dyn common::Delegate>,
2531    _additional_params: HashMap<String, String>,
2532    _scopes: BTreeSet<String>,
2533}
2534
2535impl<'a, C> common::CallBuilder for ProjectServiceAccountSignJwtCall<'a, C> {}
2536
2537impl<'a, C> ProjectServiceAccountSignJwtCall<'a, C>
2538where
2539    C: common::Connector,
2540{
2541    /// Perform the operation you have build so far.
2542    pub async fn doit(mut self) -> common::Result<(common::Response, SignJwtResponse)> {
2543        use std::borrow::Cow;
2544        use std::io::{Read, Seek};
2545
2546        use common::{url::Params, ToParts};
2547        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2548
2549        let mut dd = common::DefaultDelegate;
2550        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2551        dlg.begin(common::MethodInfo {
2552            id: "iamcredentials.projects.serviceAccounts.signJwt",
2553            http_method: hyper::Method::POST,
2554        });
2555
2556        for &field in ["alt", "name"].iter() {
2557            if self._additional_params.contains_key(field) {
2558                dlg.finished(false);
2559                return Err(common::Error::FieldClash(field));
2560            }
2561        }
2562
2563        let mut params = Params::with_capacity(4 + self._additional_params.len());
2564        params.push("name", self._name);
2565
2566        params.extend(self._additional_params.iter());
2567
2568        params.push("alt", "json");
2569        let mut url = self.hub._base_url.clone() + "v1/{+name}:signJwt";
2570        if self._scopes.is_empty() {
2571            self._scopes
2572                .insert(Scope::CloudPlatform.as_ref().to_string());
2573        }
2574
2575        #[allow(clippy::single_element_loop)]
2576        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2577            url = params.uri_replacement(url, param_name, find_this, true);
2578        }
2579        {
2580            let to_remove = ["name"];
2581            params.remove_params(&to_remove);
2582        }
2583
2584        let url = params.parse_with_url(&url);
2585
2586        let mut json_mime_type = mime::APPLICATION_JSON;
2587        let mut request_value_reader = {
2588            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2589            common::remove_json_null_values(&mut value);
2590            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2591            serde_json::to_writer(&mut dst, &value).unwrap();
2592            dst
2593        };
2594        let request_size = request_value_reader
2595            .seek(std::io::SeekFrom::End(0))
2596            .unwrap();
2597        request_value_reader
2598            .seek(std::io::SeekFrom::Start(0))
2599            .unwrap();
2600
2601        loop {
2602            let token = match self
2603                .hub
2604                .auth
2605                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2606                .await
2607            {
2608                Ok(token) => token,
2609                Err(e) => match dlg.token(e) {
2610                    Ok(token) => token,
2611                    Err(e) => {
2612                        dlg.finished(false);
2613                        return Err(common::Error::MissingToken(e));
2614                    }
2615                },
2616            };
2617            request_value_reader
2618                .seek(std::io::SeekFrom::Start(0))
2619                .unwrap();
2620            let mut req_result = {
2621                let client = &self.hub.client;
2622                dlg.pre_request();
2623                let mut req_builder = hyper::Request::builder()
2624                    .method(hyper::Method::POST)
2625                    .uri(url.as_str())
2626                    .header(USER_AGENT, self.hub._user_agent.clone());
2627
2628                if let Some(token) = token.as_ref() {
2629                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2630                }
2631
2632                let request = req_builder
2633                    .header(CONTENT_TYPE, json_mime_type.to_string())
2634                    .header(CONTENT_LENGTH, request_size as u64)
2635                    .body(common::to_body(
2636                        request_value_reader.get_ref().clone().into(),
2637                    ));
2638
2639                client.request(request.unwrap()).await
2640            };
2641
2642            match req_result {
2643                Err(err) => {
2644                    if let common::Retry::After(d) = dlg.http_error(&err) {
2645                        sleep(d).await;
2646                        continue;
2647                    }
2648                    dlg.finished(false);
2649                    return Err(common::Error::HttpError(err));
2650                }
2651                Ok(res) => {
2652                    let (mut parts, body) = res.into_parts();
2653                    let mut body = common::Body::new(body);
2654                    if !parts.status.is_success() {
2655                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2656                        let error = serde_json::from_str(&common::to_string(&bytes));
2657                        let response = common::to_response(parts, bytes.into());
2658
2659                        if let common::Retry::After(d) =
2660                            dlg.http_failure(&response, error.as_ref().ok())
2661                        {
2662                            sleep(d).await;
2663                            continue;
2664                        }
2665
2666                        dlg.finished(false);
2667
2668                        return Err(match error {
2669                            Ok(value) => common::Error::BadRequest(value),
2670                            _ => common::Error::Failure(response),
2671                        });
2672                    }
2673                    let response = {
2674                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2675                        let encoded = common::to_string(&bytes);
2676                        match serde_json::from_str(&encoded) {
2677                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2678                            Err(error) => {
2679                                dlg.response_json_decode_error(&encoded, &error);
2680                                return Err(common::Error::JsonDecodeError(
2681                                    encoded.to_string(),
2682                                    error,
2683                                ));
2684                            }
2685                        }
2686                    };
2687
2688                    dlg.finished(true);
2689                    return Ok(response);
2690                }
2691            }
2692        }
2693    }
2694
2695    ///
2696    /// Sets the *request* property to the given value.
2697    ///
2698    /// Even though the property as already been set when instantiating this call,
2699    /// we provide this method for API completeness.
2700    pub fn request(mut self, new_value: SignJwtRequest) -> ProjectServiceAccountSignJwtCall<'a, C> {
2701        self._request = new_value;
2702        self
2703    }
2704    /// Required. The resource name of the service account for which the credentials are requested, in the following format: `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is required; replacing it with a project ID is invalid.
2705    ///
2706    /// Sets the *name* path property to the given value.
2707    ///
2708    /// Even though the property as already been set when instantiating this call,
2709    /// we provide this method for API completeness.
2710    pub fn name(mut self, new_value: &str) -> ProjectServiceAccountSignJwtCall<'a, C> {
2711        self._name = new_value.to_string();
2712        self
2713    }
2714    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2715    /// while executing the actual API request.
2716    ///
2717    /// ````text
2718    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2719    /// ````
2720    ///
2721    /// Sets the *delegate* property to the given value.
2722    pub fn delegate(
2723        mut self,
2724        new_value: &'a mut dyn common::Delegate,
2725    ) -> ProjectServiceAccountSignJwtCall<'a, C> {
2726        self._delegate = Some(new_value);
2727        self
2728    }
2729
2730    /// Set any additional parameter of the query string used in the request.
2731    /// It should be used to set parameters which are not yet available through their own
2732    /// setters.
2733    ///
2734    /// Please note that this method must not be used to set any of the known parameters
2735    /// which have their own setter method. If done anyway, the request will fail.
2736    ///
2737    /// # Additional Parameters
2738    ///
2739    /// * *$.xgafv* (query-string) - V1 error format.
2740    /// * *access_token* (query-string) - OAuth access token.
2741    /// * *alt* (query-string) - Data format for response.
2742    /// * *callback* (query-string) - JSONP
2743    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2744    /// * *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.
2745    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2746    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2747    /// * *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.
2748    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2749    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2750    pub fn param<T>(mut self, name: T, value: T) -> ProjectServiceAccountSignJwtCall<'a, C>
2751    where
2752        T: AsRef<str>,
2753    {
2754        self._additional_params
2755            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2756        self
2757    }
2758
2759    /// Identifies the authorization scope for the method you are building.
2760    ///
2761    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2762    /// [`Scope::CloudPlatform`].
2763    ///
2764    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2765    /// tokens for more than one scope.
2766    ///
2767    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2768    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2769    /// sufficient, a read-write scope will do as well.
2770    pub fn add_scope<St>(mut self, scope: St) -> ProjectServiceAccountSignJwtCall<'a, C>
2771    where
2772        St: AsRef<str>,
2773    {
2774        self._scopes.insert(String::from(scope.as_ref()));
2775        self
2776    }
2777    /// Identifies the authorization scope(s) for the method you are building.
2778    ///
2779    /// See [`Self::add_scope()`] for details.
2780    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectServiceAccountSignJwtCall<'a, C>
2781    where
2782        I: IntoIterator<Item = St>,
2783        St: AsRef<str>,
2784    {
2785        self._scopes
2786            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2787        self
2788    }
2789
2790    /// Removes all scopes, and no default scope will be used either.
2791    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2792    /// for details).
2793    pub fn clear_scopes(mut self) -> ProjectServiceAccountSignJwtCall<'a, C> {
2794        self._scopes.clear();
2795        self
2796    }
2797}